From 8995564ed6b9e453e144bb663303072a3c1ba305 Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Sun, 3 May 2026 11:31:53 +0100 Subject: [PATCH 1/3] refactor: Enable clang-tidy `readability-identifier-naming` check (#6571) --- .clang-tidy | 76 +- .github/scripts/rename/config.sh | 2 +- .github/scripts/rename/docs.sh | 2 +- .../workflows/reusable-clang-tidy-files.yml | 2 +- CONTRIBUTING.md | 4 +- cmake/scripts/codegen/macro_parser_common.py | 10 +- .../codegen/templates/LedgerEntry.h.mako | 12 +- .../templates/LedgerEntryTests.cpp.mako | 4 +- .../codegen/templates/Transaction.h.mako | 12 +- .../templates/TransactionTests.cpp.mako | 14 +- docs/build/sanitizers.md | 2 +- docs/consensus.md | 2 +- include/xrpl/basics/BasicConfig.h | 32 +- include/xrpl/basics/CountedObject.h | 14 +- include/xrpl/basics/DecayingSample.h | 24 +- include/xrpl/basics/Expected.h | 24 +- include/xrpl/basics/IntrusivePointer.h | 22 +- include/xrpl/basics/IntrusivePointer.ipp | 90 +- include/xrpl/basics/IntrusiveRefCounts.h | 140 +- include/xrpl/basics/LocalValue.h | 10 +- include/xrpl/basics/Log.h | 22 +- include/xrpl/basics/Number.h | 170 +- include/xrpl/basics/RangeSet.h | 2 +- include/xrpl/basics/Resolver.h | 2 +- include/xrpl/basics/ResolverAsio.h | 2 +- include/xrpl/basics/SHAMapHash.h | 6 +- include/xrpl/basics/SharedWeakCachePointer.h | 2 +- .../xrpl/basics/SharedWeakCachePointer.ipp | 6 +- include/xrpl/basics/SlabAllocator.h | 63 +- include/xrpl/basics/Slice.h | 4 +- include/xrpl/basics/StringUtilities.h | 20 +- include/xrpl/basics/TaggedCache.h | 53 +- include/xrpl/basics/TaggedCache.ipp | 230 +- include/xrpl/basics/ToString.h | 10 +- include/xrpl/basics/UnorderedContainers.h | 22 +- include/xrpl/basics/UptimeClock.h | 17 +- include/xrpl/basics/algorithm.h | 4 +- include/xrpl/basics/base64.h | 8 +- include/xrpl/basics/base_uint.h | 194 +- include/xrpl/basics/chrono.h | 22 +- include/xrpl/basics/contract.h | 10 +- include/xrpl/basics/hardened_hash.h | 22 +- include/xrpl/basics/make_SSLContext.h | 4 +- include/xrpl/basics/mulDiv.h | 2 +- .../xrpl/basics/partitioned_unordered_map.h | 172 +- include/xrpl/basics/random.h | 52 +- include/xrpl/basics/safe_cast.h | 28 +- include/xrpl/basics/scope.h | 70 +- include/xrpl/basics/spinlock.h | 31 +- include/xrpl/basics/tagged_integer.h | 132 +- include/xrpl/beast/asio/io_latency_probe.h | 149 +- include/xrpl/beast/clock/abstract_clock.h | 26 +- .../xrpl/beast/clock/basic_seconds_clock.h | 7 +- include/xrpl/beast/clock/manual_clock.h | 20 +- include/xrpl/beast/container/aged_container.h | 4 +- .../beast/container/aged_container_utility.h | 2 +- include/xrpl/beast/container/aged_map.h | 2 +- include/xrpl/beast/container/aged_multimap.h | 2 +- include/xrpl/beast/container/aged_multiset.h | 3 +- include/xrpl/beast/container/aged_set.h | 2 +- .../xrpl/beast/container/aged_unordered_map.h | 3 +- .../beast/container/aged_unordered_multimap.h | 3 +- .../beast/container/aged_unordered_multiset.h | 2 +- .../xrpl/beast/container/aged_unordered_set.h | 3 +- .../detail/aged_associative_container.h | 10 +- .../detail/aged_container_iterator.h | 87 +- .../container/detail/aged_ordered_container.h | 907 ++- .../detail/aged_unordered_container.h | 1357 +++-- .../detail/empty_base_optimization.h | 40 +- include/xrpl/beast/core/CurrentThreadName.h | 4 +- include/xrpl/beast/core/List.h | 108 +- include/xrpl/beast/core/LockFreeStack.h | 68 +- include/xrpl/beast/hash/hash_append.h | 130 +- include/xrpl/beast/hash/uhash.h | 6 +- include/xrpl/beast/hash/xxhasher.h | 22 +- include/xrpl/beast/insight/Collector.h | 38 +- include/xrpl/beast/insight/Counter.h | 8 +- include/xrpl/beast/insight/Event.h | 10 +- include/xrpl/beast/insight/Gauge.h | 14 +- include/xrpl/beast/insight/Groups.h | 2 +- include/xrpl/beast/insight/Hook.h | 6 +- include/xrpl/beast/insight/Meter.h | 10 +- include/xrpl/beast/insight/NullCollector.h | 2 +- include/xrpl/beast/insight/StatsDCollector.h | 2 +- include/xrpl/beast/net/IPAddress.h | 16 +- include/xrpl/beast/net/IPAddressConversion.h | 24 +- include/xrpl/beast/net/IPAddressV4.h | 6 +- include/xrpl/beast/net/IPAddressV6.h | 4 +- include/xrpl/beast/net/IPEndpoint.h | 62 +- include/xrpl/beast/rfc2616.h | 68 +- include/xrpl/beast/test/yield_to.h | 15 +- include/xrpl/beast/type_name.h | 2 +- include/xrpl/beast/unit_test/amount.h | 16 +- .../beast/unit_test/detail/const_container.h | 20 +- include/xrpl/beast/unit_test/global_suites.h | 20 +- include/xrpl/beast/unit_test/match.h | 78 +- include/xrpl/beast/unit_test/recorder.h | 44 +- include/xrpl/beast/unit_test/reporter.h | 88 +- include/xrpl/beast/unit_test/results.h | 44 +- include/xrpl/beast/unit_test/runner.h | 76 +- include/xrpl/beast/unit_test/suite.h | 150 +- include/xrpl/beast/unit_test/suite_info.h | 29 +- include/xrpl/beast/unit_test/suite_list.h | 6 +- include/xrpl/beast/unit_test/thread.h | 12 +- include/xrpl/beast/utility/Journal.h | 94 +- include/xrpl/beast/utility/PropertyStream.h | 52 +- include/xrpl/beast/utility/Zero.h | 28 +- include/xrpl/beast/utility/maybe_const.h | 6 +- include/xrpl/beast/utility/rngfill.h | 20 +- include/xrpl/beast/utility/temp_dir.h | 12 +- include/xrpl/beast/xor_shift_engine.h | 20 +- include/xrpl/conditions/Condition.h | 12 +- include/xrpl/conditions/Fulfillment.h | 2 +- .../xrpl/conditions/detail/PreimageSha256.h | 14 +- include/xrpl/conditions/detail/error.h | 42 +- include/xrpl/conditions/detail/utils.h | 26 +- include/xrpl/core/ClosureCounter.h | 20 +- include/xrpl/core/Coro.ipp | 33 +- include/xrpl/core/HashRouter.h | 4 +- include/xrpl/core/Job.h | 108 +- include/xrpl/core/JobQueue.h | 43 +- include/xrpl/core/JobTypeData.h | 18 +- include/xrpl/core/JobTypeInfo.h | 32 +- include/xrpl/core/JobTypes.h | 136 +- include/xrpl/core/LoadMonitor.h | 14 +- include/xrpl/core/PeerReservationTable.h | 10 +- include/xrpl/core/PerfLog.h | 14 +- include/xrpl/core/detail/Workers.h | 26 +- include/xrpl/core/detail/semaphore.h | 34 +- include/xrpl/crypto/RFC1751.h | 2 +- include/xrpl/crypto/csprng.h | 24 +- include/xrpl/crypto/secure_erase.h | 2 +- include/xrpl/json/JsonPropertyStream.h | 20 +- include/xrpl/json/Output.h | 12 +- include/xrpl/json/Writer.h | 16 +- include/xrpl/json/detail/json_assert.h | 2 +- include/xrpl/json/json_errors.h | 6 +- include/xrpl/json/json_forwards.h | 4 +- include/xrpl/json/json_reader.h | 54 +- include/xrpl/json/json_value.h | 81 +- include/xrpl/json/json_writer.h | 62 +- include/xrpl/json/to_string.h | 8 +- include/xrpl/ledger/AcceptedLedgerTx.h | 28 +- include/xrpl/ledger/AmendmentTable.h | 12 +- include/xrpl/ledger/ApplyView.h | 36 +- include/xrpl/ledger/BookDirs.h | 11 +- include/xrpl/ledger/BookListeners.h | 4 +- include/xrpl/ledger/CachedView.h | 12 +- include/xrpl/ledger/Dir.h | 24 +- include/xrpl/ledger/Ledger.h | 26 +- include/xrpl/ledger/LedgerTiming.h | 28 +- include/xrpl/ledger/OpenView.h | 48 +- include/xrpl/ledger/ReadView.h | 36 +- include/xrpl/ledger/detail/ApplyStateTable.h | 8 +- include/xrpl/ledger/detail/ApplyViewBase.h | 10 +- include/xrpl/ledger/detail/RawStateTable.h | 32 +- include/xrpl/ledger/detail/ReadViewFwdRange.h | 32 +- .../xrpl/ledger/detail/ReadViewFwdRange.ipp | 30 +- include/xrpl/ledger/helpers/AMMHelpers.h | 64 +- include/xrpl/ledger/helpers/EscrowHelpers.h | 4 +- include/xrpl/ledger/helpers/LendingHelpers.h | 24 +- include/xrpl/ledger/helpers/NFTokenHelpers.h | 4 +- include/xrpl/ledger/helpers/TokenHelpers.h | 14 +- include/xrpl/ledger/helpers/VaultHelpers.h | 4 +- include/xrpl/net/AutoSocket.h | 146 +- include/xrpl/net/HTTPClient.h | 8 +- include/xrpl/net/HTTPClientSSLContext.h | 4 +- include/xrpl/nodestore/Backend.h | 2 +- include/xrpl/nodestore/Database.h | 6 +- include/xrpl/nodestore/Manager.h | 4 +- include/xrpl/nodestore/NodeObject.h | 18 +- include/xrpl/nodestore/Scheduler.h | 4 +- include/xrpl/nodestore/Types.h | 16 +- include/xrpl/nodestore/detail/BatchWriter.h | 14 +- .../xrpl/nodestore/detail/DatabaseNodeImp.h | 4 +- .../nodestore/detail/DatabaseRotatingImp.h | 2 +- include/xrpl/nodestore/detail/DecodedBlob.h | 12 +- include/xrpl/nodestore/detail/ManagerImp.h | 6 +- include/xrpl/nodestore/detail/codec.h | 108 +- include/xrpl/nodestore/detail/varint.h | 12 +- include/xrpl/protocol/AMMCore.h | 24 +- include/xrpl/protocol/AccountID.h | 12 +- include/xrpl/protocol/AmountConversions.h | 40 +- include/xrpl/protocol/ApiVersion.h | 98 +- include/xrpl/protocol/Asset.h | 36 +- include/xrpl/protocol/Batch.h | 2 +- include/xrpl/protocol/Book.h | 22 +- include/xrpl/protocol/Concepts.h | 6 +- include/xrpl/protocol/ErrorCodes.h | 280 +- include/xrpl/protocol/Feature.h | 24 +- include/xrpl/protocol/Fees.h | 6 +- include/xrpl/protocol/HashPrefix.h | 26 +- include/xrpl/protocol/IOUAmount.h | 2 +- include/xrpl/protocol/Indexes.h | 40 +- include/xrpl/protocol/Issue.h | 16 +- include/xrpl/protocol/KeyType.h | 12 +- include/xrpl/protocol/Keylet.h | 2 +- include/xrpl/protocol/KnownFormats.h | 4 +- include/xrpl/protocol/LedgerFormats.h | 4 + include/xrpl/protocol/LedgerHeader.h | 14 +- include/xrpl/protocol/MPTAmount.h | 2 +- include/xrpl/protocol/MPTIssue.h | 16 +- include/xrpl/protocol/MultiApiJson.h | 64 +- .../xrpl/protocol/NFTSyntheticSerializer.h | 2 +- include/xrpl/protocol/NFTokenID.h | 2 +- include/xrpl/protocol/NFTokenOfferID.h | 2 +- include/xrpl/protocol/PathAsset.h | 10 +- include/xrpl/protocol/PayChan.h | 2 +- include/xrpl/protocol/Permissions.h | 2 +- include/xrpl/protocol/Protocol.h | 130 +- include/xrpl/protocol/PublicKey.h | 20 +- include/xrpl/protocol/Quality.h | 94 +- include/xrpl/protocol/QualityFunction.h | 2 +- include/xrpl/protocol/RPCErr.h | 6 +- include/xrpl/protocol/Rate.h | 2 +- include/xrpl/protocol/Rules.h | 8 +- include/xrpl/protocol/SField.h | 84 +- include/xrpl/protocol/SOTemplate.h | 15 +- include/xrpl/protocol/STAmount.h | 148 +- include/xrpl/protocol/STArray.h | 29 +- include/xrpl/protocol/STBase.h | 28 +- include/xrpl/protocol/STBitString.h | 8 +- include/xrpl/protocol/STBlob.h | 2 +- include/xrpl/protocol/STCurrency.h | 4 +- include/xrpl/protocol/STInteger.h | 2 +- include/xrpl/protocol/STIssue.h | 4 +- include/xrpl/protocol/STLedgerEntry.h | 4 +- include/xrpl/protocol/STNumber.h | 2 +- include/xrpl/protocol/STObject.h | 72 +- include/xrpl/protocol/STParsedJSON.h | 4 +- include/xrpl/protocol/STPathSet.h | 184 +- include/xrpl/protocol/STTx.h | 20 +- include/xrpl/protocol/STValidation.h | 26 +- include/xrpl/protocol/STVector256.h | 48 +- include/xrpl/protocol/STXChainBridge.h | 26 +- include/xrpl/protocol/SecretKey.h | 8 +- include/xrpl/protocol/SeqProxy.h | 8 +- include/xrpl/protocol/Serializer.h | 104 +- include/xrpl/protocol/SystemParameters.h | 28 +- include/xrpl/protocol/TER.h | 22 +- include/xrpl/protocol/TxFlags.h | 4 + include/xrpl/protocol/TxFormats.h | 8 +- include/xrpl/protocol/TxMeta.h | 2 +- include/xrpl/protocol/UintTypes.h | 16 +- include/xrpl/protocol/Units.h | 42 +- include/xrpl/protocol/XChainAttestations.h | 156 +- include/xrpl/protocol/XRPAmount.h | 20 +- include/xrpl/protocol/detail/STVar.h | 32 +- include/xrpl/protocol/detail/b58_utils.h | 80 +- include/xrpl/protocol/detail/features.macro | 110 +- .../xrpl/protocol/detail/ledger_entries.macro | 624 +- include/xrpl/protocol/detail/secp256k1.h | 10 +- include/xrpl/protocol/detail/sfields.macro | 56 +- include/xrpl/protocol/detail/token_errors.h | 46 +- .../xrpl/protocol/detail/transactions.macro | 872 +-- include/xrpl/protocol/digest.h | 42 +- include/xrpl/protocol/json_get_or_throw.h | 34 +- include/xrpl/protocol/jss.h | 11 +- include/xrpl/protocol/nft.h | 12 +- include/xrpl/protocol/nftPageMask.h | 2 +- include/xrpl/protocol/tokens.h | 8 +- .../protocol_autogen/STObjectValidation.h | 4 +- .../protocol_autogen/TransactionBuilderBase.h | 4 +- .../protocol_autogen/ledger_entries/AMM.h | 42 +- .../ledger_entries/AccountRoot.h | 94 +- .../ledger_entries/Amendments.h | 18 +- .../protocol_autogen/ledger_entries/Bridge.h | 42 +- .../protocol_autogen/ledger_entries/Check.h | 50 +- .../ledger_entries/Credential.h | 38 +- .../protocol_autogen/ledger_entries/DID.h | 30 +- .../ledger_entries/Delegate.h | 30 +- .../ledger_entries/DepositPreauth.h | 26 +- .../ledger_entries/DirectoryNode.h | 66 +- .../protocol_autogen/ledger_entries/Escrow.h | 62 +- .../ledger_entries/FeeSettings.h | 38 +- .../ledger_entries/LedgerHashes.h | 14 +- .../protocol_autogen/ledger_entries/Loan.h | 110 +- .../ledger_entries/LoanBroker.h | 70 +- .../protocol_autogen/ledger_entries/MPToken.h | 30 +- .../ledger_entries/MPTokenIssuance.h | 54 +- .../ledger_entries/NFTokenOffer.h | 38 +- .../ledger_entries/NFTokenPage.h | 22 +- .../ledger_entries/NegativeUNL.h | 22 +- .../protocol_autogen/ledger_entries/Offer.h | 50 +- .../protocol_autogen/ledger_entries/Oracle.h | 42 +- .../ledger_entries/PayChannel.h | 62 +- .../ledger_entries/PermissionedDomain.h | 26 +- .../ledger_entries/RippleState.h | 46 +- .../ledger_entries/SignerList.h | 30 +- .../protocol_autogen/ledger_entries/Ticket.h | 22 +- .../protocol_autogen/ledger_entries/Vault.h | 62 +- .../ledger_entries/XChainOwnedClaimID.h | 38 +- .../XChainOwnedCreateAccountClaimID.h | 30 +- .../protocol_autogen/transactions/AMMBid.h | 26 +- .../transactions/AMMClawback.h | 22 +- .../protocol_autogen/transactions/AMMCreate.h | 18 +- .../protocol_autogen/transactions/AMMDelete.h | 14 +- .../transactions/AMMDeposit.h | 34 +- .../protocol_autogen/transactions/AMMVote.h | 18 +- .../transactions/AMMWithdraw.h | 30 +- .../transactions/AccountDelete.h | 18 +- .../transactions/AccountSet.h | 46 +- .../protocol_autogen/transactions/Batch.h | 14 +- .../transactions/CheckCancel.h | 10 +- .../protocol_autogen/transactions/CheckCash.h | 18 +- .../transactions/CheckCreate.h | 26 +- .../protocol_autogen/transactions/Clawback.h | 14 +- .../transactions/CredentialAccept.h | 14 +- .../transactions/CredentialCreate.h | 22 +- .../transactions/CredentialDelete.h | 18 +- .../protocol_autogen/transactions/DIDDelete.h | 6 +- .../protocol_autogen/transactions/DIDSet.h | 18 +- .../transactions/DelegateSet.h | 14 +- .../transactions/DepositPreauth.h | 22 +- .../transactions/EnableAmendment.h | 14 +- .../transactions/EscrowCancel.h | 14 +- .../transactions/EscrowCreate.h | 30 +- .../transactions/EscrowFinish.h | 26 +- .../transactions/LedgerStateFix.h | 14 +- .../transactions/LoanBrokerCoverClawback.h | 14 +- .../transactions/LoanBrokerCoverDeposit.h | 14 +- .../transactions/LoanBrokerCoverWithdraw.h | 22 +- .../transactions/LoanBrokerDelete.h | 10 +- .../transactions/LoanBrokerSet.h | 34 +- .../transactions/LoanDelete.h | 10 +- .../transactions/LoanManage.h | 10 +- .../protocol_autogen/transactions/LoanPay.h | 14 +- .../protocol_autogen/transactions/LoanSet.h | 74 +- .../transactions/MPTokenAuthorize.h | 14 +- .../transactions/MPTokenIssuanceCreate.h | 30 +- .../transactions/MPTokenIssuanceDestroy.h | 10 +- .../transactions/MPTokenIssuanceSet.h | 30 +- .../transactions/NFTokenAcceptOffer.h | 18 +- .../transactions/NFTokenBurn.h | 14 +- .../transactions/NFTokenCancelOffer.h | 10 +- .../transactions/NFTokenCreateOffer.h | 26 +- .../transactions/NFTokenMint.h | 34 +- .../transactions/NFTokenModify.h | 18 +- .../transactions/OfferCancel.h | 10 +- .../transactions/OfferCreate.h | 26 +- .../transactions/OracleDelete.h | 10 +- .../protocol_autogen/transactions/OracleSet.h | 30 +- .../protocol_autogen/transactions/Payment.h | 42 +- .../transactions/PaymentChannelClaim.h | 30 +- .../transactions/PaymentChannelCreate.h | 30 +- .../transactions/PaymentChannelFund.h | 18 +- .../transactions/PermissionedDomainDelete.h | 10 +- .../transactions/PermissionedDomainSet.h | 14 +- .../protocol_autogen/transactions/SetFee.h | 38 +- .../transactions/SetRegularKey.h | 10 +- .../transactions/SignerListSet.h | 14 +- .../transactions/TicketCreate.h | 10 +- .../protocol_autogen/transactions/TrustSet.h | 18 +- .../protocol_autogen/transactions/UNLModify.h | 18 +- .../transactions/VaultClawback.h | 18 +- .../transactions/VaultCreate.h | 34 +- .../transactions/VaultDelete.h | 10 +- .../transactions/VaultDeposit.h | 14 +- .../protocol_autogen/transactions/VaultSet.h | 22 +- .../transactions/VaultWithdraw.h | 22 +- .../transactions/XChainAccountCreateCommit.h | 22 +- .../XChainAddAccountCreateAttestation.h | 50 +- .../transactions/XChainAddClaimAttestation.h | 46 +- .../transactions/XChainClaim.h | 26 +- .../transactions/XChainCommit.h | 22 +- .../transactions/XChainCreateBridge.h | 18 +- .../transactions/XChainCreateClaimID.h | 18 +- .../transactions/XChainModifyBridge.h | 18 +- include/xrpl/rdb/DBInit.h | 20 +- include/xrpl/rdb/RelationalDatabase.h | 2 +- include/xrpl/resource/Charge.h | 6 +- include/xrpl/resource/Consumer.h | 6 +- include/xrpl/resource/Disposition.h | 6 +- include/xrpl/resource/Fees.h | 31 +- include/xrpl/resource/ResourceManager.h | 6 +- include/xrpl/resource/detail/Entry.h | 10 +- include/xrpl/resource/detail/Key.h | 10 +- include/xrpl/resource/detail/Kind.h | 2 +- include/xrpl/resource/detail/Logic.h | 170 +- include/xrpl/resource/detail/Tuning.h | 12 +- include/xrpl/server/InfoSub.h | 30 +- include/xrpl/server/LoadFeeTrack.h | 22 +- include/xrpl/server/Manifest.h | 40 +- include/xrpl/server/NetworkOPs.h | 20 +- include/xrpl/server/Port.h | 4 +- include/xrpl/server/Server.h | 4 +- include/xrpl/server/Session.h | 2 +- include/xrpl/server/SimpleWriter.h | 4 +- include/xrpl/server/WSSession.h | 2 +- include/xrpl/server/Wallet.h | 12 +- include/xrpl/server/detail/BaseHTTPPeer.h | 124 +- include/xrpl/server/detail/BasePeer.h | 14 +- include/xrpl/server/detail/BaseWSPeer.h | 116 +- include/xrpl/server/detail/Door.h | 100 +- include/xrpl/server/detail/JSONRPCUtil.h | 2 +- include/xrpl/server/detail/LowestLayer.h | 2 +- include/xrpl/server/detail/PlainHTTPPeer.h | 22 +- include/xrpl/server/detail/PlainWSPeer.h | 6 +- include/xrpl/server/detail/SSLHTTPPeer.h | 42 +- include/xrpl/server/detail/SSLWSPeer.h | 16 +- include/xrpl/server/detail/ServerImpl.h | 18 +- include/xrpl/server/detail/io_list.h | 42 +- include/xrpl/shamap/FullBelowCache.h | 34 +- include/xrpl/shamap/SHAMap.h | 112 +- .../xrpl/shamap/SHAMapAccountStateLeafNode.h | 10 +- include/xrpl/shamap/SHAMapAddNode.h | 44 +- include/xrpl/shamap/SHAMapInnerNode.h | 6 +- include/xrpl/shamap/SHAMapItem.h | 16 +- include/xrpl/shamap/SHAMapLeafNode.h | 2 +- include/xrpl/shamap/SHAMapMissingNode.h | 2 +- include/xrpl/shamap/SHAMapTreeNode.h | 20 +- include/xrpl/shamap/SHAMapTxLeafNode.h | 10 +- .../xrpl/shamap/SHAMapTxPlusMetaLeafNode.h | 10 +- include/xrpl/shamap/detail/TaggedPointer.h | 4 +- include/xrpl/shamap/detail/TaggedPointer.ipp | 147 +- include/xrpl/tx/ApplyContext.h | 2 +- include/xrpl/tx/Transactor.h | 86 +- include/xrpl/tx/applySteps.h | 32 +- include/xrpl/tx/invariants/InvariantCheck.h | 4 +- .../tx/invariants/InvariantCheckPrivilege.h | 36 +- include/xrpl/tx/invariants/NFTInvariant.h | 8 +- .../invariants/PermissionedDomainInvariant.h | 8 +- include/xrpl/tx/invariants/VaultInvariant.h | 8 +- include/xrpl/tx/paths/AMMLiquidity.h | 2 +- include/xrpl/tx/paths/AMMOffer.h | 2 +- include/xrpl/tx/paths/BookTip.h | 22 +- include/xrpl/tx/paths/Offer.h | 64 +- include/xrpl/tx/paths/RippleCalc.h | 2 +- include/xrpl/tx/paths/detail/FlatSets.h | 2 +- include/xrpl/tx/paths/detail/FlowDebugInfo.h | 32 +- include/xrpl/tx/paths/detail/Steps.h | 64 +- include/xrpl/tx/paths/detail/StrandFlow.h | 127 +- .../tx/transactors/account/AccountDelete.h | 2 +- .../xrpl/tx/transactors/account/AccountSet.h | 2 +- .../tx/transactors/account/SetRegularKey.h | 2 +- .../tx/transactors/account/SignerListSet.h | 6 +- .../xrpl/tx/transactors/bridge/XChainBridge.h | 18 +- .../xrpl/tx/transactors/check/CheckCancel.h | 2 +- include/xrpl/tx/transactors/check/CheckCash.h | 2 +- .../xrpl/tx/transactors/check/CheckCreate.h | 2 +- .../credentials/CredentialAccept.h | 2 +- .../credentials/CredentialCreate.h | 2 +- .../credentials/CredentialDelete.h | 2 +- .../tx/transactors/delegate/DelegateSet.h | 2 +- include/xrpl/tx/transactors/dex/AMMBid.h | 2 +- include/xrpl/tx/transactors/dex/AMMClawback.h | 2 +- include/xrpl/tx/transactors/dex/AMMContext.h | 4 +- include/xrpl/tx/transactors/dex/AMMCreate.h | 2 +- include/xrpl/tx/transactors/dex/AMMDelete.h | 2 +- include/xrpl/tx/transactors/dex/AMMDeposit.h | 2 +- include/xrpl/tx/transactors/dex/AMMVote.h | 2 +- include/xrpl/tx/transactors/dex/AMMWithdraw.h | 2 +- include/xrpl/tx/transactors/dex/OfferCancel.h | 2 +- include/xrpl/tx/transactors/dex/OfferCreate.h | 8 +- include/xrpl/tx/transactors/did/DIDDelete.h | 2 +- include/xrpl/tx/transactors/did/DIDSet.h | 2 +- .../xrpl/tx/transactors/escrow/EscrowCancel.h | 2 +- .../xrpl/tx/transactors/escrow/EscrowCreate.h | 2 +- .../xrpl/tx/transactors/escrow/EscrowFinish.h | 2 +- .../lending/LoanBrokerCoverClawback.h | 2 +- .../lending/LoanBrokerCoverDeposit.h | 2 +- .../lending/LoanBrokerCoverWithdraw.h | 2 +- .../tx/transactors/lending/LoanBrokerDelete.h | 2 +- .../tx/transactors/lending/LoanBrokerSet.h | 2 +- .../xrpl/tx/transactors/lending/LoanDelete.h | 2 +- .../xrpl/tx/transactors/lending/LoanManage.h | 2 +- include/xrpl/tx/transactors/lending/LoanPay.h | 2 +- include/xrpl/tx/transactors/lending/LoanSet.h | 18 +- .../tx/transactors/nft/NFTokenAcceptOffer.h | 2 +- include/xrpl/tx/transactors/nft/NFTokenBurn.h | 2 +- .../tx/transactors/nft/NFTokenCancelOffer.h | 2 +- .../tx/transactors/nft/NFTokenCreateOffer.h | 2 +- include/xrpl/tx/transactors/nft/NFTokenMint.h | 2 +- .../xrpl/tx/transactors/nft/NFTokenModify.h | 2 +- .../xrpl/tx/transactors/oracle/OracleDelete.h | 2 +- .../xrpl/tx/transactors/oracle/OracleSet.h | 2 +- .../tx/transactors/payment/DepositPreauth.h | 2 +- include/xrpl/tx/transactors/payment/Payment.h | 6 +- .../payment_channel/PaymentChannelClaim.h | 2 +- .../payment_channel/PaymentChannelCreate.h | 2 +- .../payment_channel/PaymentChannelFund.h | 2 +- .../PermissionedDomainDelete.h | 2 +- .../PermissionedDomainSet.h | 2 +- include/xrpl/tx/transactors/system/Batch.h | 4 +- include/xrpl/tx/transactors/system/Change.h | 2 +- .../tx/transactors/system/LedgerStateFix.h | 4 +- .../xrpl/tx/transactors/system/TicketCreate.h | 8 +- include/xrpl/tx/transactors/token/Clawback.h | 2 +- .../tx/transactors/token/MPTokenAuthorize.h | 2 +- .../transactors/token/MPTokenIssuanceCreate.h | 2 +- .../token/MPTokenIssuanceDestroy.h | 2 +- .../tx/transactors/token/MPTokenIssuanceSet.h | 2 +- include/xrpl/tx/transactors/token/TrustSet.h | 2 +- .../xrpl/tx/transactors/vault/VaultClawback.h | 2 +- .../xrpl/tx/transactors/vault/VaultCreate.h | 2 +- .../xrpl/tx/transactors/vault/VaultDelete.h | 2 +- .../xrpl/tx/transactors/vault/VaultDeposit.h | 2 +- include/xrpl/tx/transactors/vault/VaultSet.h | 2 +- .../xrpl/tx/transactors/vault/VaultWithdraw.h | 2 +- src/libxrpl/basics/BasicConfig.cpp | 22 +- src/libxrpl/basics/CountedObject.cpp | 10 +- src/libxrpl/basics/Log.cpp | 128 +- src/libxrpl/basics/MallocTrim.cpp | 14 +- src/libxrpl/basics/Number.cpp | 278 +- src/libxrpl/basics/ResolverAsio.cpp | 200 +- src/libxrpl/basics/StringUtilities.cpp | 16 +- src/libxrpl/basics/UptimeClock.cpp | 25 +- src/libxrpl/basics/base64.cpp | 28 +- src/libxrpl/basics/contract.cpp | 4 +- src/libxrpl/basics/make_SSLContext.cpp | 106 +- src/libxrpl/basics/mulDiv.cpp | 2 +- .../beast/clock/basic_seconds_clock.cpp | 28 +- src/libxrpl/beast/core/CurrentThreadName.cpp | 16 +- src/libxrpl/beast/core/SemanticVersion.cpp | 30 +- src/libxrpl/beast/insight/Groups.cpp | 50 +- src/libxrpl/beast/insight/NullCollector.cpp | 12 +- src/libxrpl/beast/insight/StatsDCollector.cpp | 316 +- src/libxrpl/beast/net/IPAddressConversion.cpp | 8 +- src/libxrpl/beast/net/IPAddressV4.cpp | 12 +- src/libxrpl/beast/net/IPAddressV6.cpp | 8 +- src/libxrpl/beast/net/IPEndpoint.cpp | 12 +- src/libxrpl/beast/utility/beast_Journal.cpp | 28 +- .../beast/utility/beast_PropertyStream.cpp | 154 +- src/libxrpl/conditions/Condition.cpp | 46 +- src/libxrpl/conditions/Fulfillment.cpp | 34 +- src/libxrpl/conditions/error.cpp | 51 +- src/libxrpl/core/HashRouter.cpp | 4 +- src/libxrpl/core/detail/Job.cpp | 48 +- src/libxrpl/core/detail/JobQueue.cpp | 164 +- src/libxrpl/core/detail/LoadMonitor.cpp | 70 +- src/libxrpl/core/detail/Workers.cpp | 96 +- src/libxrpl/crypto/RFC1751.cpp | 14 +- src/libxrpl/crypto/csprng.cpp | 20 +- src/libxrpl/crypto/secure_erase.cpp | 2 +- src/libxrpl/json/JsonPropertyStream.cpp | 82 +- src/libxrpl/json/Output.cpp | 30 +- src/libxrpl/json/Writer.cpp | 60 +- src/libxrpl/json/json_reader.cpp | 176 +- src/libxrpl/json/json_value.cpp | 668 +-- src/libxrpl/json/json_valueiterator.cpp | 14 +- src/libxrpl/json/json_writer.cpp | 66 +- src/libxrpl/json/to_string.cpp | 4 +- src/libxrpl/ledger/AcceptedLedgerTx.cpp | 40 +- src/libxrpl/ledger/ApplyStateTable.cpp | 150 +- src/libxrpl/ledger/ApplyView.cpp | 67 +- src/libxrpl/ledger/ApplyViewBase.cpp | 10 +- src/libxrpl/ledger/BookDirs.cpp | 26 +- src/libxrpl/ledger/BookListeners.cpp | 18 +- src/libxrpl/ledger/CachedView.cpp | 12 +- src/libxrpl/ledger/CanonicalTXSet.cpp | 4 +- src/libxrpl/ledger/Dir.cpp | 30 +- src/libxrpl/ledger/Ledger.cpp | 143 +- src/libxrpl/ledger/OpenView.cpp | 34 +- src/libxrpl/ledger/PaymentSandbox.cpp | 2 +- src/libxrpl/ledger/RawStateTable.cpp | 76 +- src/libxrpl/ledger/ReadView.cpp | 28 +- src/libxrpl/ledger/View.cpp | 12 +- src/libxrpl/ledger/helpers/AMMHelpers.cpp | 32 +- .../ledger/helpers/AccountRootHelpers.cpp | 22 +- .../ledger/helpers/CredentialHelpers.cpp | 6 +- src/libxrpl/ledger/helpers/LendingHelpers.cpp | 142 +- src/libxrpl/ledger/helpers/MPTokenHelpers.cpp | 18 +- src/libxrpl/ledger/helpers/NFTokenHelpers.cpp | 55 +- src/libxrpl/ledger/helpers/OfferHelpers.cpp | 1 + .../ledger/helpers/RippleStateHelpers.cpp | 52 +- src/libxrpl/ledger/helpers/TokenHelpers.cpp | 100 +- src/libxrpl/ledger/helpers/VaultHelpers.cpp | 2 +- src/libxrpl/net/HTTPClient.cpp | 262 +- src/libxrpl/nodestore/BatchWriter.cpp | 46 +- src/libxrpl/nodestore/Database.cpp | 16 +- src/libxrpl/nodestore/DatabaseNodeImp.cpp | 10 +- src/libxrpl/nodestore/DatabaseRotatingImp.cpp | 16 +- src/libxrpl/nodestore/DecodedBlob.cpp | 34 +- src/libxrpl/nodestore/ManagerImp.cpp | 19 +- src/libxrpl/nodestore/NodeObject.cpp | 8 +- .../nodestore/backend/MemoryFactory.cpp | 20 +- src/libxrpl/nodestore/backend/NuDBFactory.cpp | 150 +- src/libxrpl/nodestore/backend/NullFactory.cpp | 6 +- .../nodestore/backend/RocksDBFactory.cpp | 181 +- src/libxrpl/protocol/AMMCore.cpp | 18 +- src/libxrpl/protocol/AccountID.cpp | 32 +- src/libxrpl/protocol/Asset.cpp | 6 +- src/libxrpl/protocol/BuildInfo.cpp | 24 +- src/libxrpl/protocol/ErrorCodes.cpp | 202 +- src/libxrpl/protocol/Feature.cpp | 141 +- src/libxrpl/protocol/IOUAmount.cpp | 78 +- src/libxrpl/protocol/Indexes.cpp | 193 +- src/libxrpl/protocol/InnerObjectFormats.cpp | 144 +- src/libxrpl/protocol/Issue.cpp | 26 +- src/libxrpl/protocol/LedgerFormats.cpp | 14 +- src/libxrpl/protocol/LedgerHeader.cpp | 2 +- src/libxrpl/protocol/MPTIssue.cpp | 16 +- .../protocol/NFTSyntheticSerializer.cpp | 2 +- src/libxrpl/protocol/NFTokenID.cpp | 4 +- src/libxrpl/protocol/NFTokenOfferID.cpp | 2 +- src/libxrpl/protocol/Permissions.cpp | 6 +- src/libxrpl/protocol/Protocol.cpp | 4 +- src/libxrpl/protocol/PublicKey.cpp | 82 +- src/libxrpl/protocol/Quality.cpp | 65 +- src/libxrpl/protocol/QualityFunction.cpp | 6 +- src/libxrpl/protocol/RPCErr.cpp | 10 +- src/libxrpl/protocol/Rate2.cpp | 28 +- src/libxrpl/protocol/Rules.cpp | 24 +- src/libxrpl/protocol/SField.cpp | 49 +- src/libxrpl/protocol/STAccount.cpp | 10 +- src/libxrpl/protocol/STAmount.cpp | 503 +- src/libxrpl/protocol/STArray.cpp | 6 +- src/libxrpl/protocol/STBase.cpp | 26 +- src/libxrpl/protocol/STCurrency.cpp | 6 +- src/libxrpl/protocol/STInteger.cpp | 21 +- src/libxrpl/protocol/STIssue.cpp | 6 +- src/libxrpl/protocol/STLedgerEntry.cpp | 13 +- src/libxrpl/protocol/STNumber.cpp | 15 +- src/libxrpl/protocol/STObject.cpp | 78 +- src/libxrpl/protocol/STParsedJSON.cpp | 464 +- src/libxrpl/protocol/STPathSet.cpp | 94 +- src/libxrpl/protocol/STTakesAsset.cpp | 8 +- src/libxrpl/protocol/STTx.cpp | 86 +- src/libxrpl/protocol/STValidation.cpp | 51 +- src/libxrpl/protocol/STVar.cpp | 27 +- src/libxrpl/protocol/STVector256.cpp | 16 +- src/libxrpl/protocol/STXChainBridge.cpp | 22 +- src/libxrpl/protocol/SecretKey.cpp | 102 +- src/libxrpl/protocol/Seed.cpp | 10 +- src/libxrpl/protocol/Serializer.cpp | 61 +- src/libxrpl/protocol/Sign.cpp | 2 +- src/libxrpl/protocol/TER.cpp | 10 +- src/libxrpl/protocol/TxFormats.cpp | 42 +- src/libxrpl/protocol/TxMeta.cpp | 6 +- src/libxrpl/protocol/UintTypes.cpp | 46 +- src/libxrpl/protocol/XChainAttestations.cpp | 346 +- src/libxrpl/protocol/digest.cpp | 24 +- src/libxrpl/protocol/tokens.cpp | 246 +- src/libxrpl/rdb/DatabaseCon.cpp | 8 +- src/libxrpl/rdb/SociDB.cpp | 6 +- src/libxrpl/resource/Charge.cpp | 18 +- src/libxrpl/resource/Consumer.cpp | 72 +- src/libxrpl/resource/Fees.cpp | 30 +- src/libxrpl/resource/ResourceManager.cpp | 10 +- src/libxrpl/server/InfoSub.cpp | 38 +- src/libxrpl/server/JSONRPCUtil.cpp | 10 +- src/libxrpl/server/LoadFeeTrack.cpp | 10 +- src/libxrpl/server/Manifest.cpp | 68 +- src/libxrpl/server/Port.cpp | 40 +- src/libxrpl/server/Vacuum.cpp | 6 +- src/libxrpl/server/Wallet.cpp | 38 +- src/libxrpl/shamap/SHAMap.cpp | 142 +- src/libxrpl/shamap/SHAMapDelta.cpp | 30 +- src/libxrpl/shamap/SHAMapInnerNode.cpp | 65 +- src/libxrpl/shamap/SHAMapLeafNode.cpp | 6 +- src/libxrpl/shamap/SHAMapNodeID.cpp | 28 +- src/libxrpl/shamap/SHAMapSync.cpp | 166 +- src/libxrpl/shamap/SHAMapTreeNode.cpp | 61 +- src/libxrpl/tx/ApplyContext.cpp | 28 +- src/libxrpl/tx/SignerEntries.cpp | 2 +- src/libxrpl/tx/Transactor.cpp | 84 +- src/libxrpl/tx/apply.cpp | 40 +- src/libxrpl/tx/applySteps.cpp | 62 +- src/libxrpl/tx/invariants/AMMInvariant.cpp | 20 +- src/libxrpl/tx/invariants/FreezeInvariant.cpp | 2 +- src/libxrpl/tx/invariants/InvariantCheck.cpp | 124 +- .../tx/invariants/LoanBrokerInvariant.cpp | 4 +- src/libxrpl/tx/invariants/LoanInvariant.cpp | 12 +- src/libxrpl/tx/invariants/MPTInvariant.cpp | 37 +- src/libxrpl/tx/invariants/NFTInvariant.cpp | 52 +- .../PermissionedDomainInvariant.cpp | 28 +- src/libxrpl/tx/invariants/VaultInvariant.cpp | 56 +- src/libxrpl/tx/paths/AMMLiquidity.cpp | 34 +- src/libxrpl/tx/paths/AMMOffer.cpp | 6 +- src/libxrpl/tx/paths/BookStep.cpp | 132 +- src/libxrpl/tx/paths/BookTip.cpp | 30 +- src/libxrpl/tx/paths/DirectStep.cpp | 61 +- src/libxrpl/tx/paths/Flow.cpp | 4 +- src/libxrpl/tx/paths/MPTEndpointStep.cpp | 67 +- src/libxrpl/tx/paths/OfferStream.cpp | 32 +- src/libxrpl/tx/paths/PaySteps.cpp | 144 +- src/libxrpl/tx/paths/RippleCalc.cpp | 6 +- src/libxrpl/tx/paths/XRPEndpointStep.cpp | 14 +- .../tx/transactors/account/AccountDelete.cpp | 16 +- .../tx/transactors/account/AccountSet.cpp | 16 +- .../tx/transactors/account/SignerListSet.cpp | 34 +- .../tx/transactors/bridge/XChainBridge.cpp | 112 +- .../tx/transactors/check/CheckCash.cpp | 24 +- .../credentials/CredentialAccept.cpp | 2 +- .../credentials/CredentialCreate.cpp | 4 +- .../credentials/CredentialDelete.cpp | 2 +- .../tx/transactors/delegate/DelegateSet.cpp | 2 +- src/libxrpl/tx/transactors/dex/AMMBid.cpp | 66 +- .../tx/transactors/dex/AMMClawback.cpp | 28 +- src/libxrpl/tx/transactors/dex/AMMCreate.cpp | 50 +- src/libxrpl/tx/transactors/dex/AMMDelete.cpp | 2 +- src/libxrpl/tx/transactors/dex/AMMDeposit.cpp | 66 +- src/libxrpl/tx/transactors/dex/AMMVote.cpp | 53 +- .../tx/transactors/dex/AMMWithdraw.cpp | 66 +- .../tx/transactors/dex/OfferCreate.cpp | 116 +- src/libxrpl/tx/transactors/did/DIDSet.cpp | 5 +- .../tx/transactors/escrow/EscrowCancel.cpp | 2 +- .../tx/transactors/escrow/EscrowCreate.cpp | 24 +- .../tx/transactors/escrow/EscrowFinish.cpp | 20 +- .../lending/LoanBrokerCoverClawback.cpp | 18 +- .../lending/LoanBrokerCoverDeposit.cpp | 10 +- .../lending/LoanBrokerCoverWithdraw.cpp | 12 +- .../transactors/lending/LoanBrokerDelete.cpp | 10 +- .../tx/transactors/lending/LoanBrokerSet.cpp | 18 +- .../tx/transactors/lending/LoanDelete.cpp | 6 +- .../tx/transactors/lending/LoanManage.cpp | 8 +- .../tx/transactors/lending/LoanPay.cpp | 110 +- .../tx/transactors/lending/LoanSet.cpp | 48 +- .../tx/transactors/nft/NFTokenAcceptOffer.cpp | 26 +- .../tx/transactors/nft/NFTokenBurn.cpp | 12 +- .../tx/transactors/nft/NFTokenCancelOffer.cpp | 2 +- .../tx/transactors/nft/NFTokenMint.cpp | 6 +- .../tx/transactors/nft/NFTokenModify.cpp | 4 +- .../tx/transactors/oracle/OracleSet.cpp | 25 +- .../tx/transactors/payment/DepositPreauth.cpp | 4 +- .../tx/transactors/payment/Payment.cpp | 46 +- .../payment_channel/PaymentChannelClaim.cpp | 6 +- .../payment_channel/PaymentChannelCreate.cpp | 2 +- .../payment_channel/PaymentChannelFund.cpp | 2 +- .../PermissionedDomainDelete.cpp | 2 +- .../PermissionedDomainSet.cpp | 6 +- src/libxrpl/tx/transactors/system/Batch.cpp | 30 +- src/libxrpl/tx/transactors/system/Change.cpp | 12 +- .../tx/transactors/system/LedgerStateFix.cpp | 6 +- .../tx/transactors/system/TicketCreate.cpp | 8 +- src/libxrpl/tx/transactors/token/Clawback.cpp | 24 +- .../token/MPTokenIssuanceCreate.cpp | 8 +- .../transactors/token/MPTokenIssuanceSet.cpp | 23 +- src/libxrpl/tx/transactors/token/TrustSet.cpp | 13 +- .../tx/transactors/vault/VaultClawback.cpp | 47 +- .../tx/transactors/vault/VaultCreate.cpp | 18 +- .../tx/transactors/vault/VaultDelete.cpp | 2 +- .../tx/transactors/vault/VaultDeposit.cpp | 18 +- src/libxrpl/tx/transactors/vault/VaultSet.cpp | 10 +- .../tx/transactors/vault/VaultWithdraw.cpp | 18 +- src/test/app/AMMCalc_test.cpp | 26 +- src/test/app/AMMClawbackMPT_test.cpp | 1188 ++-- src/test/app/AMMClawback_test.cpp | 1142 ++-- src/test/app/AMMExtendedMPT_test.cpp | 2947 +++++----- src/test/app/AMMExtended_test.cpp | 2372 ++++---- src/test/app/AMMMPT_test.cpp | 5021 +++++++++-------- src/test/app/AMM_test.cpp | 2983 +++++----- src/test/app/AccountDelete_test.cpp | 200 +- src/test/app/AccountSet_test.cpp | 128 +- src/test/app/AccountTxPaging_test.cpp | 72 +- src/test/app/AmendmentTable_test.cpp | 34 +- src/test/app/Batch_test.cpp | 1168 ++-- src/test/app/CheckMPT_test.cpp | 909 ++- src/test/app/Check_test.cpp | 941 +-- src/test/app/Clawback_test.cpp | 318 +- src/test/app/Credentials_test.cpp | 118 +- src/test/app/CrossingLimitsMPT_test.cpp | 216 +- src/test/app/CrossingLimits_test.cpp | 226 +- src/test/app/DID_test.cpp | 62 +- src/test/app/DNS_test.cpp | 4 +- src/test/app/Delegate_test.cpp | 530 +- src/test/app/DeliverMin_test.cpp | 150 +- src/test/app/DepositAuth_test.cpp | 336 +- src/test/app/Discrepancy_test.cpp | 82 +- src/test/app/EscrowToken_test.cpp | 2210 ++++---- src/test/app/Escrow_test.cpp | 950 ++-- src/test/app/FeeVote_test.cpp | 74 +- src/test/app/FixNFTokenPageLinks_test.cpp | 120 +- src/test/app/FlowMPT_test.cpp | 1060 ++-- src/test/app/Flow_test.cpp | 754 +-- src/test/app/Freeze_test.cpp | 1142 ++-- src/test/app/GRPCServerTLS_test.cpp | 2 +- src/test/app/HashRouter_test.cpp | 16 +- src/test/app/Invariants_test.cpp | 1467 ++--- src/test/app/LPTokenTransfer_test.cpp | 350 +- src/test/app/LedgerHistory_test.cpp | 18 +- src/test/app/LedgerLoad_test.cpp | 32 +- src/test/app/LedgerMaster_test.cpp | 4 +- src/test/app/LedgerReplay_test.cpp | 109 +- src/test/app/LendingHelpers_test.cpp | 10 +- src/test/app/LoadFeeTrack_test.cpp | 14 +- src/test/app/LoanBroker_test.cpp | 520 +- src/test/app/Loan_test.cpp | 1693 +++--- src/test/app/MPToken_test.cpp | 3024 +++++----- src/test/app/Manifest_test.cpp | 215 +- src/test/app/MultiSign_test.cpp | 796 +-- src/test/app/NFTokenAuth_test.cpp | 410 +- src/test/app/NFTokenBurn_test.cpp | 206 +- src/test/app/NFTokenDir_test.cpp | 162 +- src/test/app/NFToken_test.cpp | 1414 ++--- src/test/app/NetworkID_test.cpp | 18 +- src/test/app/NetworkOPs_test.cpp | 8 +- src/test/app/OfferMPT_test.cpp | 2175 +++---- src/test/app/OfferStream_test.cpp | 2 +- src/test/app/Offer_test.cpp | 2437 ++++---- src/test/app/Oracle_test.cpp | 162 +- src/test/app/OversizeMeta_test.cpp | 44 +- src/test/app/PathMPT_test.cpp | 220 +- src/test/app/Path_test.cpp | 1284 ++--- src/test/app/PayChan_test.cpp | 239 +- src/test/app/PayStrandMPT_test.cpp | 284 +- src/test/app/PayStrand_test.cpp | 438 +- src/test/app/PermissionedDEX_test.cpp | 810 +-- src/test/app/PermissionedDomains_test.cpp | 91 +- src/test/app/PseudoTx_test.cpp | 6 +- src/test/app/RCLValidations_test.cpp | 54 +- src/test/app/ReducedOffer_test.cpp | 139 +- src/test/app/Regression_test.cpp | 65 +- src/test/app/SHAMapStore_test.cpp | 86 +- src/test/app/SetAuth_test.cpp | 28 +- src/test/app/SetRegularKey_test.cpp | 58 +- src/test/app/TheoreticalQuality_test.cpp | 92 +- src/test/app/Ticket_test.cpp | 248 +- src/test/app/Transaction_ordering_test.cpp | 16 +- src/test/app/TrustAndBalance_test.cpp | 140 +- src/test/app/TrustSet_test.cpp | 114 +- src/test/app/TxQ_test.cpp | 1429 +++-- src/test/app/ValidatorKeys_test.cpp | 39 +- src/test/app/ValidatorList_test.cpp | 316 +- src/test/app/ValidatorSite_test.cpp | 72 +- src/test/app/Vault_test.cpp | 984 ++-- src/test/app/XChain_test.cpp | 2312 ++++---- src/test/app/tx/apply_test.cpp | 10 +- src/test/basics/Buffer_test.cpp | 2 +- src/test/basics/DetectCrash_test.cpp | 2 +- src/test/basics/Expected_test.cpp | 2 +- src/test/basics/FileUtilities_test.cpp | 10 +- src/test/basics/IOUAmount_test.cpp | 100 +- src/test/basics/IntrusiveShared_test.cpp | 334 +- src/test/basics/KeyCache_test.cpp | 8 +- src/test/basics/Number_test.cpp | 450 +- src/test/basics/PerfLog_test.cpp | 196 +- src/test/basics/StringUtilities_test.cpp | 44 +- src/test/basics/TaggedCache_test.cpp | 6 +- src/test/basics/Units_test.cpp | 46 +- src/test/basics/XRPAmount_test.cpp | 85 +- src/test/basics/base58_test.cpp | 50 +- src/test/basics/base_uint_test.cpp | 75 +- src/test/basics/hardened_hash_test.cpp | 102 +- src/test/basics/join_test.cpp | 6 +- src/test/beast/IPEndpointCommon.h | 42 +- src/test/beast/IPEndpoint_test.cpp | 136 +- src/test/beast/LexicalCast_test.cpp | 2 +- src/test/beast/SemanticVersion_test.cpp | 2 +- .../beast/aged_associative_container_test.cpp | 252 +- .../beast/beast_CurrentThreadName_test.cpp | 4 +- src/test/beast/beast_Journal_test.cpp | 18 +- src/test/beast/beast_PropertyStream_test.cpp | 149 +- src/test/beast/beast_Zero_test.cpp | 68 +- src/test/beast/beast_abstract_clock_test.cpp | 16 +- .../beast/beast_basic_seconds_clock_test.cpp | 6 +- .../beast/beast_io_latency_probe_test.cpp | 95 +- src/test/beast/define_print.cpp | 10 +- src/test/beast/xxhasher_test.cpp | 50 +- src/test/conditions/PreimageSha256_test.cpp | 4 +- .../consensus/ByzantineFailureSim_test.cpp | 2 +- src/test/consensus/Consensus_test.cpp | 16 +- .../DistributedValidatorsSim_test.cpp | 2 +- src/test/consensus/LedgerTiming_test.cpp | 14 +- src/test/consensus/LedgerTrie_test.cpp | 2 +- src/test/consensus/NegativeUNL_test.cpp | 439 +- .../consensus/RCLCensorshipDetector_test.cpp | 2 +- src/test/consensus/ScaleFreeSim_test.cpp | 8 +- src/test/consensus/Validations_test.cpp | 181 +- src/test/core/ClosureCounter_test.cpp | 12 +- src/test/core/Config_test.cpp | 159 +- src/test/core/Coroutine_test.cpp | 56 +- src/test/core/JobQueue_test.cpp | 12 +- src/test/core/Workers_test.cpp | 10 +- src/test/csf/BasicNetwork.h | 30 +- src/test/csf/BasicNetwork_test.cpp | 10 +- src/test/csf/Digraph.h | 6 +- src/test/csf/Digraph_test.cpp | 2 +- src/test/csf/Histogram.h | 12 +- src/test/csf/Histogram_test.cpp | 2 +- src/test/csf/Peer.h | 19 +- src/test/csf/PeerGroup.h | 2 +- src/test/csf/Scheduler.h | 122 +- src/test/csf/Scheduler_test.cpp | 12 +- src/test/csf/Sim.h | 16 +- src/test/csf/SimTime.h | 2 +- src/test/csf/Tx.h | 16 +- src/test/csf/Validation.h | 2 +- src/test/csf/collectors.h | 28 +- src/test/csf/impl/Sim.cpp | 10 +- src/test/csf/impl/ledgers.cpp | 8 +- src/test/csf/ledgers.h | 16 +- src/test/csf/random.h | 4 +- src/test/json/TestOutputSuite.h | 4 +- src/test/jtx/AMM.h | 102 +- src/test/jtx/AMMTest.h | 44 +- src/test/jtx/AbstractClient.h | 6 +- src/test/jtx/Account.h | 16 +- src/test/jtx/CaptureLogs.h | 2 +- src/test/jtx/CheckMessageLogs.h | 2 +- src/test/jtx/Env.h | 112 +- src/test/jtx/Env_ss.h | 16 +- src/test/jtx/Env_test.cpp | 324 +- src/test/jtx/JSONRPCClient.h | 2 +- src/test/jtx/JTx.h | 46 +- src/test/jtx/Oracle.h | 47 +- src/test/jtx/PathSet.h | 86 +- src/test/jtx/SignerUtils.h | 4 +- src/test/jtx/TestHelpers.h | 235 +- src/test/jtx/TestSuite.h | 2 +- src/test/jtx/TrustedPublisherServer.h | 110 +- src/test/jtx/WSClient.h | 8 +- src/test/jtx/WSClient_test.cpp | 6 +- src/test/jtx/account_txn_id.h | 4 +- src/test/jtx/acctdelete.h | 2 +- src/test/jtx/amount.h | 75 +- src/test/jtx/attester.h | 4 +- src/test/jtx/balance.h | 8 +- src/test/jtx/basic_prop.h | 20 +- src/test/jtx/batch.h | 32 +- src/test/jtx/check.h | 8 +- src/test/jtx/credentials.h | 20 +- src/test/jtx/delegate.h | 8 +- src/test/jtx/delivermin.h | 4 +- src/test/jtx/deposit.h | 16 +- src/test/jtx/did.h | 18 +- src/test/jtx/directory.h | 2 +- src/test/jtx/domain.h | 4 +- src/test/jtx/envconfig.h | 18 +- src/test/jtx/escrow.h | 38 +- src/test/jtx/fee.h | 12 +- src/test/jtx/flags.h | 26 +- src/test/jtx/impl/AMM.cpp | 156 +- src/test/jtx/impl/AMMTest.cpp | 41 +- src/test/jtx/impl/Account.cpp | 30 +- src/test/jtx/impl/Env.cpp | 124 +- src/test/jtx/impl/JSONRPCClient.cpp | 28 +- src/test/jtx/impl/Oracle.cpp | 52 +- src/test/jtx/impl/TestHelpers.cpp | 225 +- src/test/jtx/impl/WSClient.cpp | 60 +- src/test/jtx/impl/account_txn_id.cpp | 2 +- src/test/jtx/impl/acctdelete.cpp | 4 +- src/test/jtx/impl/amount.cpp | 19 +- src/test/jtx/impl/attester.cpp | 4 +- src/test/jtx/impl/balance.cpp | 12 +- src/test/jtx/impl/batch.cpp | 24 +- src/test/jtx/impl/check.cpp | 16 +- src/test/jtx/impl/creds.cpp | 20 +- src/test/jtx/impl/delegate.cpp | 14 +- src/test/jtx/impl/delivermin.cpp | 4 +- src/test/jtx/impl/deposit.cpp | 24 +- src/test/jtx/impl/dids.cpp | 12 +- src/test/jtx/impl/directory.cpp | 4 +- src/test/jtx/impl/domain.cpp | 2 +- src/test/jtx/impl/envconfig.cpp | 24 +- src/test/jtx/impl/escrow.cpp | 14 +- src/test/jtx/impl/fee.cpp | 6 +- src/test/jtx/impl/flags.cpp | 8 +- src/test/jtx/impl/invoice_id.cpp | 2 +- src/test/jtx/impl/jtx_json.cpp | 12 +- src/test/jtx/impl/last_ledger_sequence.cpp | 2 +- src/test/jtx/impl/ledgerStateFixes.cpp | 7 +- src/test/jtx/impl/memo.cpp | 8 +- src/test/jtx/impl/mpt.cpp | 90 +- src/test/jtx/impl/multisign.cpp | 20 +- src/test/jtx/impl/offer.cpp | 14 +- src/test/jtx/impl/owners.cpp | 8 +- src/test/jtx/impl/paths.cpp | 26 +- src/test/jtx/impl/pay.cpp | 8 +- src/test/jtx/impl/permissioned_domains.cpp | 32 +- src/test/jtx/impl/quality2.cpp | 14 +- src/test/jtx/impl/rate.cpp | 4 +- src/test/jtx/impl/regkey.cpp | 10 +- src/test/jtx/impl/sendmax.cpp | 4 +- src/test/jtx/impl/seq.cpp | 4 +- src/test/jtx/impl/sig.cpp | 4 +- src/test/jtx/impl/tag.cpp | 4 +- src/test/jtx/impl/ticket.cpp | 8 +- src/test/jtx/impl/token.cpp | 68 +- src/test/jtx/impl/trust.cpp | 18 +- src/test/jtx/impl/txflags.cpp | 2 +- src/test/jtx/impl/utility.cpp | 24 +- src/test/jtx/impl/vault.cpp | 32 +- src/test/jtx/impl/xchain_bridge.cpp | 187 +- src/test/jtx/invoice_id.h | 4 +- src/test/jtx/jtx_json.h | 14 +- src/test/jtx/last_ledger_sequence.h | 4 +- src/test/jtx/ledgerStateFix.h | 2 +- src/test/jtx/memo.h | 16 +- src/test/jtx/mpt.h | 36 +- src/test/jtx/multisign.h | 48 +- src/test/jtx/noop.h | 2 +- src/test/jtx/offer.h | 6 +- src/test/jtx/owners.h | 20 +- src/test/jtx/paths.h | 34 +- src/test/jtx/pay.h | 4 +- src/test/jtx/permissioned_domains.h | 8 +- src/test/jtx/prop.h | 10 +- src/test/jtx/quality.h | 16 +- src/test/jtx/rate.h | 2 +- src/test/jtx/regkey.h | 6 +- src/test/jtx/require.h | 10 +- src/test/jtx/rpc.h | 14 +- src/test/jtx/sendmax.h | 4 +- src/test/jtx/seq.h | 8 +- src/test/jtx/sig.h | 16 +- src/test/jtx/tag.h | 8 +- src/test/jtx/tags.h | 26 +- src/test/jtx/ter.h | 6 +- src/test/jtx/ticket.h | 8 +- src/test/jtx/token.h | 58 +- src/test/jtx/trust.h | 6 +- src/test/jtx/txflags.h | 4 +- src/test/jtx/utility.h | 16 +- src/test/jtx/vault.h | 12 +- src/test/jtx/xchain_bridge.h | 112 +- src/test/ledger/BookDirs_test.cpp | 26 +- src/test/ledger/Directory_test.cpp | 118 +- src/test/ledger/PaymentSandbox_test.cpp | 179 +- src/test/ledger/PendingSaves_test.cpp | 2 +- src/test/ledger/SkipList_test.cpp | 4 +- src/test/ledger/View_test.cpp | 350 +- src/test/nodestore/Backend_test.cpp | 6 +- src/test/nodestore/Basics_test.cpp | 8 +- src/test/nodestore/Database_test.cpp | 80 +- src/test/nodestore/NuDBFactory_test.cpp | 64 +- src/test/nodestore/TestBase.h | 28 +- src/test/nodestore/Timing_test.cpp | 147 +- src/test/nodestore/import_test.cpp | 84 +- src/test/nodestore/varint_test.cpp | 14 +- src/test/overlay/ProtocolVersion_test.cpp | 16 +- src/test/overlay/TMGetObjectByHash_test.cpp | 28 +- src/test/overlay/cluster_test.cpp | 2 +- src/test/overlay/compression_test.cpp | 72 +- src/test/overlay/handshake_test.cpp | 2 +- src/test/overlay/reduce_relay_test.cpp | 261 +- src/test/overlay/short_read_test.cpp | 302 +- src/test/overlay/traffic_count_test.cpp | 20 +- src/test/overlay/tx_reduce_relay_test.cpp | 40 +- src/test/peerfinder/Livecache_test.cpp | 38 +- src/test/peerfinder/PeerFinder_test.cpp | 190 +- src/test/protocol/ApiVersion_test.cpp | 27 +- src/test/protocol/BuildInfo_test.cpp | 2 +- src/test/protocol/Hooks_test.cpp | 14 +- src/test/protocol/InnerObjectFormats_test.cpp | 14 +- src/test/protocol/Issue_test.cpp | 42 +- src/test/protocol/Memo_test.cpp | 14 +- src/test/protocol/MultiApiJson_test.cpp | 383 +- src/test/protocol/PublicKey_test.cpp | 58 +- src/test/protocol/Quality_test.cpp | 96 +- src/test/protocol/STAccount_test.cpp | 2 +- src/test/protocol/STAmount_test.cpp | 76 +- src/test/protocol/STInteger_test.cpp | 36 +- src/test/protocol/STIssue_test.cpp | 20 +- src/test/protocol/STNumber_test.cpp | 44 +- src/test/protocol/STObject_test.cpp | 72 +- src/test/protocol/STParsedJSON_test.cpp | 638 +-- src/test/protocol/STTx_test.cpp | 64 +- src/test/protocol/STValidation_test.cpp | 38 +- src/test/protocol/SecretKey_test.cpp | 36 +- src/test/protocol/Seed_test.cpp | 38 +- src/test/protocol/SeqProxy_test.cpp | 270 +- src/test/protocol/Serializer_test.cpp | 2 +- src/test/protocol/TER_test.cpp | 24 +- src/test/resource/Logic_test.cpp | 32 +- src/test/rpc/AMMInfo_test.cpp | 48 +- src/test/rpc/AccountCurrencies_test.cpp | 30 +- src/test/rpc/AccountInfo_test.cpp | 78 +- src/test/rpc/AccountLines_test.cpp | 318 +- src/test/rpc/AccountObjects_test.cpp | 329 +- src/test/rpc/AccountOffers_test.cpp | 115 +- src/test/rpc/AccountTx_test.cpp | 224 +- src/test/rpc/AmendmentBlocked_test.cpp | 102 +- src/test/rpc/BookChanges_test.cpp | 18 +- src/test/rpc/Book_test.cpp | 528 +- src/test/rpc/Connect_test.cpp | 2 +- src/test/rpc/DeliveredAmount_test.cpp | 68 +- src/test/rpc/DepositAuthorized_test.cpp | 79 +- src/test/rpc/Feature_test.cpp | 62 +- src/test/rpc/GRPCTestClientBase.h | 4 +- src/test/rpc/GatewayBalances_test.cpp | 58 +- src/test/rpc/GetAggregatePrice_test.cpp | 31 +- src/test/rpc/GetCounts_test.cpp | 4 +- src/test/rpc/Handler_test.cpp | 14 +- src/test/rpc/JSONRPC_test.cpp | 246 +- src/test/rpc/KeyGeneration_test.cpp | 366 +- src/test/rpc/LedgerClosed_test.cpp | 26 +- src/test/rpc/LedgerData_test.cpp | 98 +- src/test/rpc/LedgerEntry_test.cpp | 742 ++- src/test/rpc/LedgerHeader_test.cpp | 14 +- src/test/rpc/LedgerRPC_test.cpp | 62 +- src/test/rpc/LedgerRequest_test.cpp | 96 +- src/test/rpc/ManifestRPC_test.cpp | 2 +- src/test/rpc/NoRippleCheck_test.cpp | 62 +- src/test/rpc/NoRipple_test.cpp | 70 +- src/test/rpc/OwnerInfo_test.cpp | 68 +- src/test/rpc/Peers_test.cpp | 4 +- src/test/rpc/RPCCall_test.cpp | 755 ++- src/test/rpc/RPCHelpers_test.cpp | 20 +- src/test/rpc/RPCOverload_test.cpp | 6 +- src/test/rpc/RobustTransaction_test.cpp | 46 +- src/test/rpc/Roles_test.cpp | 16 +- src/test/rpc/ServerDefinitions_test.cpp | 130 +- src/test/rpc/ServerInfo_test.cpp | 31 +- src/test/rpc/Simulate_test.cpp | 374 +- src/test/rpc/Status_test.cpp | 40 +- src/test/rpc/Submit_test.cpp | 14 +- src/test/rpc/Subscribe_test.cpp | 338 +- src/test/rpc/TransactionEntry_test.cpp | 120 +- src/test/rpc/TransactionHistory_test.cpp | 26 +- src/test/rpc/Transaction_test.cpp | 182 +- src/test/rpc/ValidatorInfo_test.cpp | 14 +- src/test/rpc/ValidatorRPC_test.cpp | 26 +- src/test/rpc/Version_test.cpp | 95 +- src/test/server/ServerStatus_test.cpp | 194 +- src/test/server/Server_test.cpp | 42 +- src/test/shamap/FetchPack_test.cpp | 36 +- src/test/shamap/SHAMapSync_test.cpp | 16 +- src/test/shamap/SHAMap_test.cpp | 80 +- src/test/shamap/common.h | 4 +- src/test/unit_test/FileDirGuard.h | 10 +- src/test/unit_test/SuiteJournal.h | 26 +- src/test/unit_test/multi_runner.cpp | 262 +- src/test/unit_test/multi_runner.h | 158 +- src/test/unit_test/utils.h | 4 +- src/tests/libxrpl/basics/MallocTrim.cpp | 2 +- src/tests/libxrpl/basics/Mutex.cpp | 10 +- src/tests/libxrpl/basics/RangeSet.cpp | 22 +- src/tests/libxrpl/basics/Slice.cpp | 34 +- src/tests/libxrpl/basics/base64.cpp | 6 +- src/tests/libxrpl/basics/contract.cpp | 2 +- src/tests/libxrpl/basics/scope.cpp | 48 +- src/tests/libxrpl/basics/tagged_integer.cpp | 8 +- src/tests/libxrpl/crypto/csprng.cpp | 8 +- src/tests/libxrpl/helpers/Account.h | 2 +- src/tests/libxrpl/helpers/IOU.h | 2 +- src/tests/libxrpl/helpers/TestFamily.h | 2 +- .../libxrpl/helpers/TestServiceRegistry.h | 4 +- src/tests/libxrpl/helpers/TestSink.cpp | 32 +- src/tests/libxrpl/helpers/TestSink.h | 2 +- src/tests/libxrpl/helpers/TxTest.cpp | 14 +- src/tests/libxrpl/helpers/TxTest.h | 8 +- src/tests/libxrpl/json/Output.cpp | 8 +- src/tests/libxrpl/json/Value.cpp | 586 +- src/tests/libxrpl/json/Writer.cpp | 112 +- .../libxrpl/protocol_autogen/TestHelpers.h | 4 +- .../transactions/AMMBidTests.cpp | 10 +- .../transactions/AMMClawbackTests.cpp | 10 +- .../transactions/AMMCreateTests.cpp | 8 +- .../transactions/AMMDeleteTests.cpp | 8 +- .../transactions/AMMDepositTests.cpp | 10 +- .../transactions/AMMVoteTests.cpp | 8 +- .../transactions/AMMWithdrawTests.cpp | 10 +- .../transactions/AccountDeleteTests.cpp | 10 +- .../transactions/AccountSetTests.cpp | 10 +- .../transactions/BatchTests.cpp | 10 +- .../transactions/CheckCancelTests.cpp | 8 +- .../transactions/CheckCashTests.cpp | 10 +- .../transactions/CheckCreateTests.cpp | 10 +- .../transactions/ClawbackTests.cpp | 10 +- .../transactions/CredentialAcceptTests.cpp | 8 +- .../transactions/CredentialCreateTests.cpp | 10 +- .../transactions/CredentialDeleteTests.cpp | 10 +- .../transactions/DIDDeleteTests.cpp | 8 +- .../transactions/DIDSetTests.cpp | 10 +- .../transactions/DelegateSetTests.cpp | 8 +- .../transactions/DepositPreauthTests.cpp | 10 +- .../transactions/EnableAmendmentTests.cpp | 8 +- .../transactions/EscrowCancelTests.cpp | 8 +- .../transactions/EscrowCreateTests.cpp | 10 +- .../transactions/EscrowFinishTests.cpp | 10 +- .../transactions/LedgerStateFixTests.cpp | 10 +- .../LoanBrokerCoverClawbackTests.cpp | 10 +- .../LoanBrokerCoverDepositTests.cpp | 8 +- .../LoanBrokerCoverWithdrawTests.cpp | 10 +- .../transactions/LoanBrokerDeleteTests.cpp | 8 +- .../transactions/LoanBrokerSetTests.cpp | 10 +- .../transactions/LoanDeleteTests.cpp | 8 +- .../transactions/LoanManageTests.cpp | 8 +- .../transactions/LoanPayTests.cpp | 8 +- .../transactions/LoanSetTests.cpp | 10 +- .../transactions/MPTokenAuthorizeTests.cpp | 10 +- .../MPTokenIssuanceCreateTests.cpp | 10 +- .../MPTokenIssuanceDestroyTests.cpp | 8 +- .../transactions/MPTokenIssuanceSetTests.cpp | 10 +- .../transactions/NFTokenAcceptOfferTests.cpp | 10 +- .../transactions/NFTokenBurnTests.cpp | 10 +- .../transactions/NFTokenCancelOfferTests.cpp | 8 +- .../transactions/NFTokenCreateOfferTests.cpp | 10 +- .../transactions/NFTokenMintTests.cpp | 10 +- .../transactions/NFTokenModifyTests.cpp | 10 +- .../transactions/OfferCancelTests.cpp | 8 +- .../transactions/OfferCreateTests.cpp | 10 +- .../transactions/OracleDeleteTests.cpp | 8 +- .../transactions/OracleSetTests.cpp | 10 +- .../transactions/PaymentChannelClaimTests.cpp | 10 +- .../PaymentChannelCreateTests.cpp | 10 +- .../transactions/PaymentChannelFundTests.cpp | 10 +- .../transactions/PaymentTests.cpp | 10 +- .../PermissionedDomainDeleteTests.cpp | 8 +- .../PermissionedDomainSetTests.cpp | 10 +- .../transactions/SetFeeTests.cpp | 10 +- .../transactions/SetRegularKeyTests.cpp | 10 +- .../transactions/SignerListSetTests.cpp | 10 +- .../transactions/TicketCreateTests.cpp | 8 +- .../transactions/TrustSetTests.cpp | 10 +- .../transactions/UNLModifyTests.cpp | 8 +- .../transactions/VaultClawbackTests.cpp | 10 +- .../transactions/VaultCreateTests.cpp | 10 +- .../transactions/VaultDeleteTests.cpp | 8 +- .../transactions/VaultDepositTests.cpp | 8 +- .../transactions/VaultSetTests.cpp | 10 +- .../transactions/VaultWithdrawTests.cpp | 10 +- .../XChainAccountCreateCommitTests.cpp | 8 +- ...XChainAddAccountCreateAttestationTests.cpp | 8 +- .../XChainAddClaimAttestationTests.cpp | 10 +- .../transactions/XChainClaimTests.cpp | 10 +- .../transactions/XChainCommitTests.cpp | 10 +- .../transactions/XChainCreateBridgeTests.cpp | 10 +- .../transactions/XChainCreateClaimIDTests.cpp | 8 +- .../transactions/XChainModifyBridgeTests.cpp | 10 +- src/tests/libxrpl/tx/AccountSet.cpp | 65 +- .../app/consensus/RCLCensorshipDetector.h | 6 +- src/xrpld/app/consensus/RCLConsensus.cpp | 102 +- src/xrpld/app/consensus/RCLConsensus.h | 12 +- src/xrpld/app/consensus/RCLCxLedger.h | 22 +- src/xrpld/app/consensus/RCLCxPeerPos.cpp | 2 +- src/xrpld/app/consensus/RCLCxPeerPos.h | 6 +- src/xrpld/app/consensus/RCLCxTx.h | 28 +- src/xrpld/app/consensus/RCLValidations.cpp | 10 +- src/xrpld/app/consensus/RCLValidations.h | 4 +- src/xrpld/app/ledger/AcceptedLedger.cpp | 2 +- src/xrpld/app/ledger/AcceptedLedger.h | 4 +- src/xrpld/app/ledger/AccountStateSF.cpp | 5 +- src/xrpld/app/ledger/ConsensusTransSetSF.cpp | 18 +- src/xrpld/app/ledger/ConsensusTransSetSF.h | 2 +- src/xrpld/app/ledger/InboundLedger.h | 48 +- src/xrpld/app/ledger/InboundLedgers.h | 6 +- src/xrpld/app/ledger/InboundTransactions.h | 4 +- src/xrpld/app/ledger/LedgerCleaner.h | 4 +- src/xrpld/app/ledger/LedgerHistory.cpp | 124 +- src/xrpld/app/ledger/LedgerHistory.h | 22 +- src/xrpld/app/ledger/LedgerHolder.h | 20 +- src/xrpld/app/ledger/LedgerMaster.h | 74 +- src/xrpld/app/ledger/LedgerReplayTask.h | 16 +- src/xrpld/app/ledger/LedgerReplayer.h | 24 +- src/xrpld/app/ledger/LedgerToJson.h | 24 +- src/xrpld/app/ledger/LocalTxs.h | 6 +- src/xrpld/app/ledger/OpenLedger.h | 16 +- src/xrpld/app/ledger/OrderBookDBImpl.cpp | 26 +- src/xrpld/app/ledger/OrderBookDBImpl.h | 6 +- src/xrpld/app/ledger/TransactionMaster.h | 10 +- src/xrpld/app/ledger/TransactionStateSF.cpp | 7 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 12 +- src/xrpld/app/ledger/detail/InboundLedger.cpp | 409 +- .../app/ledger/detail/InboundLedgers.cpp | 122 +- .../app/ledger/detail/InboundTransactions.cpp | 120 +- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 20 +- .../app/ledger/detail/LedgerDeltaAcquire.cpp | 18 +- .../app/ledger/detail/LedgerDeltaAcquire.h | 2 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 624 +- .../app/ledger/detail/LedgerPersistence.cpp | 6 +- .../ledger/detail/LedgerReplayMsgHandler.cpp | 8 +- .../app/ledger/detail/LedgerReplayTask.cpp | 59 +- .../app/ledger/detail/LedgerReplayer.cpp | 34 +- src/xrpld/app/ledger/detail/LedgerToJson.cpp | 74 +- src/xrpld/app/ledger/detail/LocalTxs.cpp | 58 +- src/xrpld/app/ledger/detail/OpenLedger.cpp | 13 +- .../app/ledger/detail/SkipListAcquire.cpp | 14 +- src/xrpld/app/ledger/detail/TimeoutCounter.h | 12 +- .../app/ledger/detail/TransactionAcquire.cpp | 50 +- .../app/ledger/detail/TransactionAcquire.h | 6 +- .../app/ledger/detail/TransactionMaster.cpp | 42 +- src/xrpld/app/main/Application.cpp | 664 +-- src/xrpld/app/main/Application.h | 2 +- src/xrpld/app/main/BasicApp.h | 4 +- src/xrpld/app/main/CollectorManager.cpp | 24 +- src/xrpld/app/main/CollectorManager.h | 2 +- src/xrpld/app/main/GRPCServer.cpp | 42 +- src/xrpld/app/main/GRPCServer.h | 2 +- src/xrpld/app/main/LoadManager.cpp | 18 +- src/xrpld/app/main/LoadManager.h | 4 +- src/xrpld/app/main/Main.cpp | 88 +- src/xrpld/app/main/NodeIdentity.cpp | 4 +- src/xrpld/app/main/NodeStoreScheduler.cpp | 6 +- src/xrpld/app/main/Tuning.h | 6 +- src/xrpld/app/misc/DeliverMax.h | 6 +- src/xrpld/app/misc/FeeVote.h | 2 +- src/xrpld/app/misc/FeeVoteImpl.cpp | 11 +- src/xrpld/app/misc/NegativeUNLVote.cpp | 35 +- src/xrpld/app/misc/NegativeUNLVote.h | 10 +- src/xrpld/app/misc/NetworkOPs.cpp | 1274 +++-- src/xrpld/app/misc/SHAMapStore.h | 4 +- src/xrpld/app/misc/SHAMapStoreImp.cpp | 104 +- src/xrpld/app/misc/SHAMapStoreImp.h | 26 +- src/xrpld/app/misc/Transaction.h | 58 +- src/xrpld/app/misc/TxQ.h | 56 +- src/xrpld/app/misc/ValidatorKeys.h | 4 +- src/xrpld/app/misc/ValidatorList.h | 72 +- src/xrpld/app/misc/ValidatorSite.h | 6 +- src/xrpld/app/misc/detail/AccountTxPaging.cpp | 8 +- src/xrpld/app/misc/detail/AccountTxPaging.h | 2 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 108 +- src/xrpld/app/misc/detail/DeliverMax.cpp | 8 +- src/xrpld/app/misc/detail/Transaction.cpp | 60 +- src/xrpld/app/misc/detail/TxQ.cpp | 97 +- src/xrpld/app/misc/detail/ValidatorKeys.cpp | 8 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 270 +- src/xrpld/app/misc/detail/ValidatorSite.cpp | 100 +- .../app/misc/detail/setup_HashRouter.cpp | 2 +- src/xrpld/app/misc/make_NetworkOPs.h | 4 +- src/xrpld/app/misc/setup_HashRouter.h | 2 +- src/xrpld/app/rdb/backend/SQLiteDatabase.h | 6 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 114 +- src/xrpld/app/rdb/backend/detail/Node.h | 12 +- .../app/rdb/backend/detail/SQLiteDatabase.cpp | 36 +- src/xrpld/app/rdb/detail/PeerFinder.cpp | 10 +- src/xrpld/consensus/Consensus.cpp | 6 +- src/xrpld/consensus/Consensus.h | 118 +- src/xrpld/consensus/ConsensusParms.h | 18 +- src/xrpld/consensus/ConsensusProposal.h | 58 +- src/xrpld/consensus/ConsensusTypes.h | 28 +- src/xrpld/consensus/DisputedTx.h | 54 +- src/xrpld/consensus/LedgerTrie.h | 60 +- src/xrpld/consensus/Validations.h | 56 +- src/xrpld/core/Config.h | 70 +- src/xrpld/core/TimeKeeper.h | 4 +- src/xrpld/core/detail/Config.cpp | 236 +- src/xrpld/overlay/Cluster.h | 2 +- src/xrpld/overlay/ClusterNode.h | 10 +- src/xrpld/overlay/Compression.h | 4 +- src/xrpld/overlay/Message.h | 2 +- src/xrpld/overlay/Overlay.h | 10 +- src/xrpld/overlay/Peer.h | 2 +- src/xrpld/overlay/PeerSet.h | 4 +- src/xrpld/overlay/ReduceRelayCommon.h | 24 +- src/xrpld/overlay/Slot.h | 148 +- src/xrpld/overlay/Squelch.h | 22 +- src/xrpld/overlay/detail/Cluster.cpp | 8 +- src/xrpld/overlay/detail/ConnectAttempt.cpp | 78 +- src/xrpld/overlay/detail/ConnectAttempt.h | 30 +- src/xrpld/overlay/detail/Handshake.cpp | 79 +- src/xrpld/overlay/detail/Handshake.h | 34 +- src/xrpld/overlay/detail/Message.cpp | 18 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 380 +- src/xrpld/overlay/detail/OverlayImpl.h | 94 +- src/xrpld/overlay/detail/PeerImp.cpp | 815 ++- src/xrpld/overlay/detail/PeerImp.h | 82 +- .../overlay/detail/PeerReservationTable.cpp | 8 +- src/xrpld/overlay/detail/PeerSet.cpp | 8 +- src/xrpld/overlay/detail/ProtocolMessage.h | 8 +- src/xrpld/overlay/detail/ProtocolVersion.cpp | 26 +- src/xrpld/overlay/detail/ProtocolVersion.h | 2 +- src/xrpld/overlay/detail/TrafficCount.cpp | 104 +- src/xrpld/overlay/detail/TrafficCount.h | 363 +- src/xrpld/overlay/detail/Tuning.h | 22 +- src/xrpld/overlay/detail/TxMetrics.cpp | 4 +- src/xrpld/overlay/detail/TxMetrics.h | 2 +- src/xrpld/overlay/make_Overlay.h | 6 +- src/xrpld/overlay/predicates.h | 38 +- src/xrpld/peerfinder/PeerfinderManager.h | 38 +- src/xrpld/peerfinder/Slot.h | 10 +- src/xrpld/peerfinder/detail/Bootcache.cpp | 102 +- src/xrpld/peerfinder/detail/Bootcache.h | 26 +- src/xrpld/peerfinder/detail/Checker.h | 63 +- src/xrpld/peerfinder/detail/Counts.h | 135 +- src/xrpld/peerfinder/detail/Endpoint.cpp | 4 +- src/xrpld/peerfinder/detail/Fixed.h | 16 +- src/xrpld/peerfinder/detail/Handouts.h | 74 +- src/xrpld/peerfinder/detail/Livecache.h | 156 +- src/xrpld/peerfinder/detail/Logic.h | 518 +- .../peerfinder/detail/PeerfinderConfig.cpp | 8 +- .../peerfinder/detail/PeerfinderManager.cpp | 112 +- src/xrpld/peerfinder/detail/SlotImp.cpp | 68 +- src/xrpld/peerfinder/detail/SlotImp.h | 80 +- src/xrpld/peerfinder/detail/SourceStrings.cpp | 22 +- src/xrpld/peerfinder/detail/SourceStrings.h | 2 +- src/xrpld/peerfinder/detail/StoreSqdb.h | 22 +- src/xrpld/peerfinder/detail/Tuning.h | 36 +- src/xrpld/peerfinder/detail/iosformat.h | 46 +- src/xrpld/peerfinder/make_Manager.h | 4 +- src/xrpld/perflog/detail/PerfLogImp.cpp | 118 +- src/xrpld/perflog/detail/PerfLogImp.h | 22 +- src/xrpld/rpc/BookChanges.h | 20 +- src/xrpld/rpc/CTID.h | 18 +- src/xrpld/rpc/Context.h | 2 +- src/xrpld/rpc/DeliveredAmount.h | 10 +- src/xrpld/rpc/MPTokenIssuanceID.h | 2 +- src/xrpld/rpc/RPCCall.h | 14 +- src/xrpld/rpc/RPCHandler.h | 4 +- src/xrpld/rpc/RPCSub.h | 6 +- src/xrpld/rpc/Request.h | 53 - src/xrpld/rpc/Role.h | 4 +- src/xrpld/rpc/ServerHandler.h | 36 +- src/xrpld/rpc/Status.h | 37 +- src/xrpld/rpc/detail/AccountAssets.cpp | 6 +- src/xrpld/rpc/detail/AssetCache.cpp | 17 +- src/xrpld/rpc/detail/AssetCache.h | 22 +- src/xrpld/rpc/detail/DeliveredAmount.cpp | 14 +- src/xrpld/rpc/detail/Handler.cpp | 599 +- src/xrpld/rpc/detail/Handler.h | 70 +- src/xrpld/rpc/detail/LegacyPathFind.cpp | 12 +- src/xrpld/rpc/detail/LegacyPathFind.h | 4 +- src/xrpld/rpc/detail/MPTokenIssuanceID.cpp | 2 +- src/xrpld/rpc/detail/PathRequest.cpp | 436 +- src/xrpld/rpc/detail/PathRequest.h | 58 +- src/xrpld/rpc/detail/PathRequestManager.cpp | 48 +- src/xrpld/rpc/detail/PathRequestManager.h | 32 +- src/xrpld/rpc/detail/Pathfinder.cpp | 415 +- src/xrpld/rpc/detail/Pathfinder.h | 72 +- src/xrpld/rpc/detail/PathfinderUtils.h | 6 +- src/xrpld/rpc/detail/RPCCall.cpp | 494 +- src/xrpld/rpc/detail/RPCHandler.cpp | 56 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 120 +- src/xrpld/rpc/detail/RPCHelpers.h | 22 +- src/xrpld/rpc/detail/RPCLedgerHelpers.cpp | 112 +- src/xrpld/rpc/detail/RPCLedgerHelpers.h | 24 +- src/xrpld/rpc/detail/RPCSub.cpp | 108 +- src/xrpld/rpc/detail/Role.cpp | 20 +- src/xrpld/rpc/detail/ServerHandler.cpp | 361 +- src/xrpld/rpc/detail/Status.cpp | 10 +- src/xrpld/rpc/detail/TransactionSign.cpp | 471 +- src/xrpld/rpc/detail/TransactionSign.h | 36 +- src/xrpld/rpc/detail/TrustLine.cpp | 26 +- src/xrpld/rpc/detail/TrustLine.h | 48 +- src/xrpld/rpc/detail/Tuning.h | 42 +- src/xrpld/rpc/detail/WSInfoSub.h | 10 +- src/xrpld/rpc/handlers/ChannelVerify.cpp | 18 +- src/xrpld/rpc/handlers/Handlers.h | 144 +- src/xrpld/rpc/handlers/VaultInfo.cpp | 26 +- .../rpc/handlers/account/AccountChannels.cpp | 42 +- .../handlers/account/AccountCurrencies.cpp | 16 +- .../rpc/handlers/account/AccountInfo.cpp | 60 +- .../rpc/handlers/account/AccountLines.cpp | 40 +- .../rpc/handlers/account/AccountNFTs.cpp | 34 +- .../rpc/handlers/account/AccountObjects.cpp | 58 +- .../rpc/handlers/account/AccountOffers.cpp | 38 +- src/xrpld/rpc/handlers/account/AccountTx.cpp | 90 +- .../rpc/handlers/account/GatewayBalances.cpp | 39 +- .../rpc/handlers/account/NoRippleCheck.cpp | 36 +- src/xrpld/rpc/handlers/account/OwnerInfo.cpp | 10 +- src/xrpld/rpc/handlers/admin/BlackList.cpp | 2 +- src/xrpld/rpc/handlers/admin/UnlList.cpp | 8 +- .../rpc/handlers/admin/data/CanDelete.cpp | 14 +- .../rpc/handlers/admin/data/LedgerCleaner.cpp | 2 +- .../rpc/handlers/admin/data/LedgerRequest.cpp | 6 +- .../admin/keygen/ValidationCreate.cpp | 14 +- .../handlers/admin/keygen/WalletPropose.cpp | 26 +- .../rpc/handlers/admin/keygen/WalletPropose.h | 4 +- src/xrpld/rpc/handlers/admin/log/LogLevel.cpp | 18 +- .../rpc/handlers/admin/log/LogRotate.cpp | 2 +- src/xrpld/rpc/handlers/admin/peer/Connect.cpp | 22 +- .../admin/peer/PeerReservationsAdd.cpp | 14 +- .../admin/peer/PeerReservationsDel.cpp | 10 +- .../admin/peer/PeerReservationsList.cpp | 8 +- src/xrpld/rpc/handlers/admin/peer/Peers.cpp | 10 +- .../admin/server_control/LedgerAccept.cpp | 4 +- .../handlers/admin/server_control/Stop.cpp | 2 +- .../admin/signing/ChannelAuthorize.cpp | 24 +- src/xrpld/rpc/handlers/admin/signing/Sign.cpp | 6 +- .../rpc/handlers/admin/signing/SignFor.cpp | 6 +- .../handlers/admin/status/ConsensusInfo.cpp | 4 +- .../rpc/handlers/admin/status/FetchInfo.cpp | 4 +- .../rpc/handlers/admin/status/GetCounts.cpp | 10 +- .../rpc/handlers/admin/status/GetCounts.h | 2 +- src/xrpld/rpc/handlers/admin/status/Print.cpp | 2 +- .../handlers/admin/status/ValidatorInfo.cpp | 8 +- .../admin/status/ValidatorListSites.cpp | 2 +- .../rpc/handlers/admin/status/Validators.cpp | 2 +- src/xrpld/rpc/handlers/ledger/Ledger.cpp | 55 +- src/xrpld/rpc/handlers/ledger/Ledger.h | 16 +- .../rpc/handlers/ledger/LedgerClosed.cpp | 4 +- .../rpc/handlers/ledger/LedgerCurrent.cpp | 4 +- src/xrpld/rpc/handlers/ledger/LedgerData.cpp | 32 +- src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp | 277 +- .../rpc/handlers/ledger/LedgerEntryHelpers.h | 90 +- .../rpc/handlers/ledger/LedgerHeader.cpp | 2 +- src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp | 61 +- .../rpc/handlers/orderbook/BookChanges.cpp | 4 +- .../rpc/handlers/orderbook/BookOffers.cpp | 119 +- .../handlers/orderbook/DepositAuthorized.cpp | 62 +- .../handlers/orderbook/GetAggregatePrice.cpp | 82 +- .../rpc/handlers/orderbook/NFTBuyOffers.cpp | 8 +- .../rpc/handlers/orderbook/NFTOffersHelpers.h | 26 +- .../rpc/handlers/orderbook/NFTSellOffers.cpp | 8 +- src/xrpld/rpc/handlers/orderbook/PathFind.cpp | 16 +- .../rpc/handlers/orderbook/RipplePathFind.cpp | 16 +- .../rpc/handlers/server_info/Feature.cpp | 14 +- src/xrpld/rpc/handlers/server_info/Fee.cpp | 6 +- .../rpc/handlers/server_info/Manifest.cpp | 12 +- .../server_info/ServerDefinitions.cpp | 94 +- .../handlers/server_info/ServerDefinitions.h | 2 +- .../rpc/handlers/server_info/ServerInfo.cpp | 4 +- .../rpc/handlers/server_info/ServerState.cpp | 4 +- src/xrpld/rpc/handlers/server_info/Version.h | 12 +- .../rpc/handlers/subscribe/Subscribe.cpp | 68 +- .../rpc/handlers/subscribe/Unsubscribe.cpp | 40 +- .../rpc/handlers/transaction/Simulate.cpp | 124 +- src/xrpld/rpc/handlers/transaction/Submit.cpp | 22 +- .../transaction/SubmitMultiSigned.cpp | 4 +- .../handlers/transaction/TransactionEntry.cpp | 16 +- src/xrpld/rpc/handlers/transaction/Tx.cpp | 66 +- .../rpc/handlers/transaction/TxHistory.cpp | 20 +- .../handlers/transaction/TxReduceRelay.cpp | 2 +- src/xrpld/rpc/handlers/utility/Ping.cpp | 4 +- src/xrpld/rpc/handlers/utility/Random.cpp | 8 +- src/xrpld/rpc/json_body.h | 18 +- src/xrpld/shamap/NodeFamily.cpp | 8 +- 1498 files changed, 58858 insertions(+), 58914 deletions(-) delete mode 100644 src/xrpld/rpc/Request.h diff --git a/.clang-tidy b/.clang-tidy index 6a7005b464..daacf4f00e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,4 @@ --- -# This entire group of checks was applied to all cpp files but not all header files. -# --- Checks: "-*, bugprone-argument-comment, bugprone-assert-side-effect, @@ -137,6 +135,7 @@ Checks: "-*, readability-duplicate-include, readability-else-after-return, readability-enum-initial-value, + readability-identifier-naming, readability-implicit-bool-conversion, readability-make-member-function-const, readability-math-missing-parentheses, @@ -154,52 +153,47 @@ Checks: "-*, readability-use-std-min-max " # --- -# other checks that have issues that need to be resolved: -# # readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names # readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable -# readability-identifier-naming, # https://github.com/XRPLF/rippled/pull/6571 # --- -# CheckOptions: readability-braces-around-statements.ShortStatementLines: 2 - # readability-identifier-naming.MacroDefinitionCase: UPPER_CASE - # readability-identifier-naming.ClassCase: CamelCase - # readability-identifier-naming.StructCase: CamelCase - # readability-identifier-naming.UnionCase: CamelCase - # readability-identifier-naming.EnumCase: CamelCase - # readability-identifier-naming.EnumConstantCase: CamelCase - # readability-identifier-naming.ScopedEnumConstantCase: CamelCase - # readability-identifier-naming.GlobalConstantCase: UPPER_CASE - # readability-identifier-naming.GlobalConstantPrefix: "k" - # readability-identifier-naming.GlobalVariableCase: CamelCase - # readability-identifier-naming.GlobalVariablePrefix: "g" - # readability-identifier-naming.ConstexprFunctionCase: camelBack - # readability-identifier-naming.ConstexprMethodCase: camelBack - # readability-identifier-naming.ClassMethodCase: camelBack - # readability-identifier-naming.ClassMemberCase: camelBack - # readability-identifier-naming.ClassConstantCase: UPPER_CASE - # readability-identifier-naming.ClassConstantPrefix: "k" - # readability-identifier-naming.StaticConstantCase: UPPER_CASE - # readability-identifier-naming.StaticConstantPrefix: "k" - # readability-identifier-naming.StaticVariableCase: UPPER_CASE - # readability-identifier-naming.StaticVariablePrefix: "k" - # readability-identifier-naming.ConstexprVariableCase: UPPER_CASE - # readability-identifier-naming.ConstexprVariablePrefix: "k" - # readability-identifier-naming.LocalConstantCase: camelBack - # readability-identifier-naming.LocalVariableCase: camelBack - # readability-identifier-naming.TemplateParameterCase: CamelCase - # readability-identifier-naming.ParameterCase: camelBack - # readability-identifier-naming.FunctionCase: camelBack - # readability-identifier-naming.MemberCase: camelBack - # readability-identifier-naming.PrivateMemberSuffix: _ - # readability-identifier-naming.ProtectedMemberSuffix: _ - # readability-identifier-naming.PublicMemberSuffix: "" - # readability-identifier-naming.FunctionIgnoredRegexp: ".*tag_invoke.*" + readability-identifier-naming.MacroDefinitionCase: UPPER_CASE + readability-identifier-naming.ClassCase: CamelCase + readability-identifier-naming.StructCase: CamelCase + readability-identifier-naming.UnionCase: CamelCase + readability-identifier-naming.EnumCase: CamelCase + readability-identifier-naming.EnumConstantCase: CamelCase + readability-identifier-naming.ScopedEnumConstantCase: CamelCase + readability-identifier-naming.GlobalConstantCase: UPPER_CASE + readability-identifier-naming.GlobalConstantPrefix: "k" + readability-identifier-naming.GlobalVariableCase: CamelCase + readability-identifier-naming.GlobalVariablePrefix: "g" + readability-identifier-naming.ConstexprFunctionCase: camelBack + readability-identifier-naming.ConstexprMethodCase: camelBack + readability-identifier-naming.ClassMethodCase: camelBack + readability-identifier-naming.ClassMemberCase: camelBack + readability-identifier-naming.ClassConstantCase: UPPER_CASE + readability-identifier-naming.ClassConstantPrefix: "k" + readability-identifier-naming.StaticConstantCase: UPPER_CASE + readability-identifier-naming.StaticConstantPrefix: "k" + readability-identifier-naming.StaticVariableCase: UPPER_CASE + readability-identifier-naming.StaticVariablePrefix: "k" + readability-identifier-naming.ConstexprVariableCase: UPPER_CASE + readability-identifier-naming.ConstexprVariablePrefix: "k" + readability-identifier-naming.LocalConstantCase: camelBack + readability-identifier-naming.LocalVariableCase: camelBack + readability-identifier-naming.TemplateParameterCase: CamelCase + readability-identifier-naming.ParameterCase: camelBack + readability-identifier-naming.FunctionCase: camelBack + readability-identifier-naming.MemberCase: camelBack + readability-identifier-naming.PrivateMemberSuffix: _ + readability-identifier-naming.ProtectedMemberSuffix: _ + readability-identifier-naming.PublicMemberSuffix: "" + readability-identifier-naming.GlobalFunctionIgnoredRegexp: "^(to_string|hash_append|tuple_hash)$" bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc misc-include-cleaner.IgnoreHeaders: ".*/(detail|impl)/.*;.*fwd\\.h(pp)?;time.h;stdlib.h;sqlite3.h;netinet/in\\.h;sys/resource\\.h;sys/sysinfo\\.h;linux/sysinfo\\.h;__chrono/.*;bits/.*;_abort\\.h;boost/uuid/uuid_hash.hpp;boost/beast/core/flat_buffer\\.hpp;boost/beast/http/field\\.hpp;boost/beast/http/dynamic_body\\.hpp;boost/beast/http/message\\.hpp;boost/beast/http/read\\.hpp;boost/beast/http/write\\.hpp;openssl/obj_mac\\.h" -# -HeaderFilterRegex: '^.*/(test|xrpl|xrpld)/.*\.(h|hpp)$' +HeaderFilterRegex: '^.*/(test|xrpl|xrpld)/.*\.(h|hpp|ipp)$' ExcludeHeaderFilterRegex: '^.*/protocol_autogen/.*\.(h|hpp)$' WarningsAsErrors: "*" diff --git a/.github/scripts/rename/config.sh b/.github/scripts/rename/config.sh index b7aff82cdf..a27d0823a9 100755 --- a/.github/scripts/rename/config.sh +++ b/.github/scripts/rename/config.sh @@ -62,7 +62,7 @@ ${SED_COMMAND} -i 's@ripple/@xrpld/@g' src/test/core/Config_test.cpp ${SED_COMMAND} -i 's/Rippled/File/g' src/test/core/Config_test.cpp # Restore the old config file name in the code that maintains support for now. -${SED_COMMAND} -i 's/configLegacyName = "xrpld.cfg"/configLegacyName = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp +${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp # Restore an URL. ${SED_COMMAND} -i 's/connect-your-xrpld-to-the-xrp-test-net.html/connect-your-rippled-to-the-xrp-test-net.html/g' cfg/xrpld-example.cfg diff --git a/.github/scripts/rename/docs.sh b/.github/scripts/rename/docs.sh index 59cc5665bf..23ff76bc05 100755 --- a/.github/scripts/rename/docs.sh +++ b/.github/scripts/rename/docs.sh @@ -90,7 +90,7 @@ ${SED_COMMAND} -i 's/www.ripple.com/www.xrpl.org/g' src/test/protocol/Seed_test. # Restore specific changes. ${SED_COMMAND} -i 's@b5efcc/src/xrpld@b5efcc/src/ripple@' include/xrpl/protocol/README.md ${SED_COMMAND} -i 's/dbPrefix_ = "xrpldb"/dbPrefix_ = "rippledb"/' src/xrpld/app/misc/SHAMapStoreImp.h # cspell: disable-line -${SED_COMMAND} -i 's/configLegacyName = "xrpld.cfg"/configLegacyName = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp +${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp popd echo "Renaming complete." diff --git a/.github/workflows/reusable-clang-tidy-files.yml b/.github/workflows/reusable-clang-tidy-files.yml index 3c71c510b3..7b35b2d968 100644 --- a/.github/workflows/reusable-clang-tidy-files.yml +++ b/.github/workflows/reusable-clang-tidy-files.yml @@ -20,7 +20,7 @@ env: # Conan installs the generators in the build/generators directory, see the # layout() method in conanfile.py. We then run CMake from the build directory. BUILD_DIR: build - BUILD_TYPE: Release + BUILD_TYPE: Debug # Debug so that ASSERTS and such participate in clang-tidy check jobs: run-clang-tidy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56d3b48057..25dd7ac059 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -348,8 +348,8 @@ For this reason: - Contract description for `UNREACHABLE` should describe the _unexpected_ situation which caused the line to have been reached. - Example good name for an - `UNREACHABLE` macro `"Json::operator==(Value, Value) : invalid type"`; example - good name for an `XRPL_ASSERT` macro `"Json::Value::asCString : valid type"`. + `UNREACHABLE` macro `"json::operator==(Value, Value) : invalid type"`; example + good name for an `XRPL_ASSERT` macro `"json::Value::asCString : valid type"`. - Example **bad** name `"RFC1751::insert(char* s, int x, int start, int length) : length is greater than or equal zero"` (missing namespace, unnecessary full function signature, description too verbose). diff --git a/cmake/scripts/codegen/macro_parser_common.py b/cmake/scripts/codegen/macro_parser_common.py index eae4df39db..40cd9f50c5 100644 --- a/cmake/scripts/codegen/macro_parser_common.py +++ b/cmake/scripts/codegen/macro_parser_common.py @@ -152,10 +152,10 @@ def parse_sfields_macro(sfields_path): def create_field_list_parser(): """Create a pyparsing parser for field lists like '({...})'.""" - # A field identifier (e.g., sfDestination, soeREQUIRED, soeMPTSupported) + # A field identifier (e.g., sfDestination, SoeRequired, SoeMptSupported) field_identifier = pp.Word(pp.alphas + "_", pp.alphanums + "_") - # A single field definition: {sfName, soeREQUIRED, ...} + # A single field definition: {sfName, SoeRequired, ...} # Allow optional trailing comma inside the braces field_def = ( pp.Suppress("{") @@ -185,8 +185,8 @@ def parse_field_list(fields_str): Args: fields_str: A string like '({ - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported} + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported} })' Returns: @@ -205,7 +205,7 @@ def parse_field_list(fields_str): field_name = field_parts[0] requirement = field_parts[1] flags = list(field_parts[2:]) if len(field_parts) > 2 else [] - supports_mpt = "soeMPTSupported" in flags + supports_mpt = "SoeMptSupported" in flags fields.append( { diff --git a/cmake/scripts/codegen/templates/LedgerEntry.h.mako b/cmake/scripts/codegen/templates/LedgerEntry.h.mako index fdb55a973a..31029cd311 100644 --- a/cmake/scripts/codegen/templates/LedgerEntry.h.mako +++ b/cmake/scripts/codegen/templates/LedgerEntry.h.mako @@ -52,13 +52,13 @@ public: % if field.get('mpt_support'): * MPT Support: ${field['mpt_support']} % endif -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': * @return The field value. % else: * @return The field value, or std::nullopt if not present. % endif */ -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': [[nodiscard]] ${field['typeData']['return_type']} get${field['name'][2:]}() const @@ -94,13 +94,13 @@ public: * MPT Support: ${field['mpt_support']} % endif * @note This is an untyped field (${field.get('cppType', 'unknown')}). -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': * @return The field value. % else: * @return The field value, or std::nullopt if not present. % endif */ -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': [[nodiscard]] ${field['typeData']['return_type']} get${field['name'][2:]}() const @@ -133,13 +133,13 @@ public: }; <% - required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED'] + required_fields = [f for f in fields if f['requirement'] == 'SoeRequired'] %>\ /** * @brief Builder for ${name} ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class ${name}Builder : public LedgerEntryBuilderBase<${name}Builder> diff --git a/cmake/scripts/codegen/templates/LedgerEntryTests.cpp.mako b/cmake/scripts/codegen/templates/LedgerEntryTests.cpp.mako index 35ce57f17b..011cf933dd 100644 --- a/cmake/scripts/codegen/templates/LedgerEntryTests.cpp.mako +++ b/cmake/scripts/codegen/templates/LedgerEntryTests.cpp.mako @@ -1,7 +1,7 @@ // Auto-generated unit tests for ledger entry ${name} <% - required_fields = [f for f in fields if f["requirement"] == "soeREQUIRED"] - optional_fields = [f for f in fields if f["requirement"] != "soeREQUIRED"] + required_fields = [f for f in fields if f["requirement"] == "SoeRequired"] + optional_fields = [f for f in fields if f["requirement"] != "SoeRequired"] def canonical_expr(field): return f"canonical_{field['stiSuffix']}()" diff --git a/cmake/scripts/codegen/templates/Transaction.h.mako b/cmake/scripts/codegen/templates/Transaction.h.mako index 62c51a5c97..d3b303d9d6 100644 --- a/cmake/scripts/codegen/templates/Transaction.h.mako +++ b/cmake/scripts/codegen/templates/Transaction.h.mako @@ -54,13 +54,13 @@ public: % if field.get('supports_mpt'): * @note This field supports MPT (Multi-Purpose Token) amounts. % endif -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': * @return The field value. % else: * @return The field value, or std::nullopt if not present. % endif */ -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': [[nodiscard]] ${field['typeData']['return_type']} get${field['name'][2:]}() const @@ -97,13 +97,13 @@ public: * @note This field supports MPT (Multi-Purpose Token) amounts. % endif * @note This is an untyped field. -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': * @return The field value. % else: * @return The field value, or std::nullopt if not present. % endif */ -% if field['requirement'] == 'soeREQUIRED': +% if field['requirement'] == 'SoeRequired': [[nodiscard]] ${field['typeData']['return_type']} get${field['name'][2:]}() const @@ -136,13 +136,13 @@ public: }; <% - required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED'] + required_fields = [f for f in fields if f['requirement'] == 'SoeRequired'] %>\ /** * @brief Builder for ${name} transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class ${name}Builder : public TransactionBuilderBase<${name}Builder> diff --git a/cmake/scripts/codegen/templates/TransactionTests.cpp.mako b/cmake/scripts/codegen/templates/TransactionTests.cpp.mako index b6bd5cd831..14ceaffd09 100644 --- a/cmake/scripts/codegen/templates/TransactionTests.cpp.mako +++ b/cmake/scripts/codegen/templates/TransactionTests.cpp.mako @@ -1,7 +1,7 @@ // Auto-generated unit tests for transaction ${name} <% - required_fields = [f for f in fields if f["requirement"] == "soeREQUIRED"] - optional_fields = [f for f in fields if f["requirement"] != "soeREQUIRED"] + required_fields = [f for f in fields if f["requirement"] == "SoeRequired"] + optional_fields = [f for f in fields if f["requirement"] != "SoeRequired"] def canonical_expr(field): return f"canonical_{field['stiSuffix']}()" @@ -33,7 +33,7 @@ TEST(Transactions${name}Tests, BuilderSettersRoundTrip) { // Generate a deterministic keypair for signing auto const [publicKey, secretKey] = - generateKeyPair(KeyType::secp256k1, generateSeed("test${name}")); + generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}")); // Common transaction fields auto const accountValue = calcAccountID(publicKey); @@ -101,7 +101,7 @@ TEST(Transactions${name}Tests, BuilderFromStTxRoundTrip) { // Generate a deterministic keypair for signing auto const [publicKey, secretKey] = - generateKeyPair(KeyType::secp256k1, generateSeed("test${name}FromTx")); + generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}FromTx")); // Common transaction fields auto const accountValue = calcAccountID(publicKey); @@ -168,7 +168,7 @@ TEST(Transactions${name}Tests, WrapperThrowsOnWrongTxType) { // Build a valid transaction of a different type auto const [pk, sk] = - generateKeyPair(KeyType::secp256k1, generateSeed("testWrongType")); + generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongType")); auto const account = calcAccountID(pk); % if wrong_tx_include == "AccountSet": @@ -186,7 +186,7 @@ TEST(Transactions${name}Tests, BuilderThrowsOnWrongTxType) { // Build a valid transaction of a different type auto const [pk, sk] = - generateKeyPair(KeyType::secp256k1, generateSeed("testWrongTypeBuilder")); + generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongTypeBuilder")); auto const account = calcAccountID(pk); % if wrong_tx_include == "AccountSet": @@ -205,7 +205,7 @@ TEST(Transactions${name}Tests, OptionalFieldsReturnNullopt) { // Generate a deterministic keypair for signing auto const [publicKey, secretKey] = - generateKeyPair(KeyType::secp256k1, generateSeed("test${name}Nullopt")); + generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}Nullopt")); // Common transaction fields auto const accountValue = calcAccountID(publicKey); diff --git a/docs/build/sanitizers.md b/docs/build/sanitizers.md index 7677775a3d..e4949bcf86 100644 --- a/docs/build/sanitizers.md +++ b/docs/build/sanitizers.md @@ -98,7 +98,7 @@ export LSAN_OPTIONS="include=sanitizers/suppressions/runtime-lsan-options.txt:su **Why `detect_container_overflow=0`?** -- Boost intrusive containers (used in `aged_unordered_container`) trigger false positives +- Boost intrusive containers (used in `AgedUnorderedContainer`) trigger false positives - Boost context switching (used in `Workers.cpp`) confuses ASAN's stack tracking - Since we usually don't build Boost (because we don't want to instrument Boost and detect issues in Boost code) with ASAN but use Boost containers in ASAN instrumented xrpld code, it generates false positives. - Building dependencies with ASAN instrumentation reduces false positives. But we don't want to instrument dependencies like Boost with ASAN because it is slow (to compile as well as run tests) and not necessary. diff --git a/docs/consensus.md b/docs/consensus.md index 0da23b708a..2850cf784e 100644 --- a/docs/consensus.md +++ b/docs/consensus.md @@ -477,7 +477,7 @@ struct Ledger // The parent ledger's close time NetClock::time_point parentCloseTime() const; - Json::Value getJson() const; + json::Value getJson() const; //... implementation specific }; diff --git a/include/xrpl/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h index 0639fb6c4d..5a82f7d081 100644 --- a/include/xrpl/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -27,7 +27,7 @@ private: std::unordered_map lookup_; std::vector lines_; std::vector values_; - bool had_trailing_comments_ = false; + bool hadTrailingComments_ = false; using const_iterator = decltype(lookup_)::const_iterator; @@ -133,7 +133,7 @@ public: /// Returns a value if present, else another value. template [[nodiscard]] T - value_or(std::string const& name, T const& other) const + valueOr(std::string const& name, T const& other) const { auto const v = get(name); return v.has_value() ? *v : other; @@ -142,9 +142,9 @@ public: // indicates if trailing comments were seen // during the appending of any lines/values [[nodiscard]] bool - had_trailing_comments() const + hadTrailingComments() const { - return had_trailing_comments_; + return hadTrailingComments_; } friend std::ostream& @@ -273,9 +273,9 @@ public: // indicates if trailing comments were seen // in any loaded Sections [[nodiscard]] bool - had_trailing_comments() const + hadTrailingComments() const { - return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); }); + return std::ranges::any_of(map_, [](auto s) { return s.second.hadTrailingComments(); }); } protected: @@ -294,17 +294,17 @@ template bool set(T& target, std::string const& name, Section const& section) { - bool found_and_valid = false; + bool foundAndValid = false; try { auto const val = section.get(name); - if ((found_and_valid = val.has_value())) + if ((foundAndValid = val.has_value())) target = *val; } catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch) { } - return found_and_valid; + return foundAndValid; } /** Set a value from a configuration Section @@ -316,10 +316,10 @@ template bool set(T& target, T const& defaultValue, std::string const& name, Section const& section) { - bool const found_and_valid = set(target, name, section); - if (!found_and_valid) + bool const foundAndValid = set(target, name, section); + if (!foundAndValid) target = defaultValue; - return found_and_valid; + return foundAndValid; } /** Retrieve a key/value pair from a section. @@ -333,7 +333,7 @@ get(Section const& section, std::string const& name, T const& defaultValue = T{} { try { - return section.value_or(name, defaultValue); + return section.valueOr(name, defaultValue); } catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch) { @@ -358,17 +358,17 @@ get(Section const& section, std::string const& name, char const* defaultValue) template bool -get_if_exists(Section const& section, std::string const& name, T& v) +getIfExists(Section const& section, std::string const& name, T& v) { return set(v, name, section); } template <> inline bool -get_if_exists(Section const& section, std::string const& name, bool& v) +getIfExists(Section const& section, std::string const& name, bool& v) { int intVal = 0; - auto stat = get_if_exists(section, name, intVal); + auto stat = getIfExists(section, name, intVal); if (stat) v = bool(intVal); return stat; diff --git a/include/xrpl/basics/CountedObject.h b/include/xrpl/basics/CountedObject.h index 379fd49837..275894673e 100644 --- a/include/xrpl/basics/CountedObject.h +++ b/include/xrpl/basics/CountedObject.h @@ -38,11 +38,11 @@ public: do { - head = instance.m_head.load(); + head = instance.head_.load(); next_ = head; - } while (instance.m_head.exchange(this) != head); + } while (instance.head_.exchange(this) != head); - ++instance.m_count; + ++instance.count_; } ~Counter() noexcept = default; @@ -88,8 +88,8 @@ private: ~CountedObjects() noexcept = default; private: - std::atomic m_count; - std::atomic m_head; + std::atomic count_; + std::atomic head_; }; //------------------------------------------------------------------------------ @@ -108,8 +108,8 @@ private: static auto& getCounter() noexcept { - static CountedObjects::Counter c{beast::type_name()}; - return c; + static CountedObjects::Counter kC{beast::typeName()}; + return kC; } CountedObject() noexcept diff --git a/include/xrpl/basics/DecayingSample.h b/include/xrpl/basics/DecayingSample.h index 8f6e729acf..d1861ebc4a 100644 --- a/include/xrpl/basics/DecayingSample.h +++ b/include/xrpl/basics/DecayingSample.h @@ -20,7 +20,7 @@ public: /** @param now Start time of DecayingSample. */ - explicit DecayingSample(time_point now) : m_value(value_type()), m_when(now) + explicit DecayingSample(time_point now) : value_(value_type()), when_(now) { } @@ -31,8 +31,8 @@ public: add(value_type value, time_point now) { decay(now); - m_value += value; - return m_value / Window; + value_ += value; + return value_ / Window; } /** Retrieve the current value in normalized units. @@ -42,7 +42,7 @@ public: value(time_point now) { decay(now); - return m_value / Window; + return value_ / Window; } private: @@ -50,38 +50,38 @@ private: void decay(time_point now) { - if (now == m_when) + if (now == when_) return; - if (m_value != value_type()) + if (value_ != value_type()) { std::size_t elapsed = - std::chrono::duration_cast(now - m_when).count(); + std::chrono::duration_cast(now - when_).count(); // A span larger than four times the window decays the // value to an insignificant amount so just reset it. // if (elapsed > 4 * Window) { - m_value = value_type(); + value_ = value_type(); } else { for (; elapsed > 0; --elapsed) { - m_value -= (m_value + Window - 1) / Window; + value_ -= (value_ + Window - 1) / Window; } } } - m_when = now; + when_ = now; } // Current value in exponential units - value_type m_value; + value_type value_; // Last time the aging function was applied - time_point m_when; + time_point when_; }; //------------------------------------------------------------------------------ diff --git a/include/xrpl/basics/Expected.h b/include/xrpl/basics/Expected.h index f4d8e5019a..74a0e76eef 100644 --- a/include/xrpl/basics/Expected.h +++ b/include/xrpl/basics/Expected.h @@ -16,9 +16,9 @@ namespace xrpl { */ // Exception thrown by an invalid access to Expected. -struct bad_expected_access : public std::runtime_error +struct BadExpectedAccess : public std::runtime_error { - bad_expected_access() : runtime_error("bad expected access") + BadExpectedAccess() : runtime_error("bad expected access") { } }; @@ -26,30 +26,33 @@ struct bad_expected_access : public std::runtime_error namespace detail { // Custom policy for Expected. Always throw on an invalid access. -struct throw_policy : public boost::outcome_v2::policy::base +struct ThrowPolicy : public boost::outcome_v2::policy::base { template static constexpr void + // NOLINTNEXTLINE(readability-identifier-naming) wide_value_check(Impl&& self) { if (!base::_has_value(std::forward(self))) - Throw(); + Throw(); } template static constexpr void + // NOLINTNEXTLINE(readability-identifier-naming) wide_error_check(Impl&& self) { if (!base::_has_error(std::forward(self))) - Throw(); + Throw(); } template static constexpr void + // NOLINTNEXTLINE(readability-identifier-naming) wide_exception_check(Impl&& self) { if (!base::_has_exception(std::forward(self))) - Throw(); + Throw(); } }; @@ -107,9 +110,9 @@ Unexpected(E (&)[N]) -> Unexpected; // Definition of Expected. All of the machinery comes from boost::result. template -class [[nodiscard]] Expected : private boost::outcome_v2::result +class [[nodiscard]] Expected : private boost::outcome_v2::result { - using Base = boost::outcome_v2::result; + using Base = boost::outcome_v2::result; public: template @@ -126,6 +129,7 @@ public: } [[nodiscard]] constexpr bool + // NOLINTNEXTLINE(readability-identifier-naming) has_value() const { return Base::has_value(); @@ -193,9 +197,9 @@ public: // (without a value) or the reason for the failure. template class [[nodiscard]] -Expected : private boost::outcome_v2::result +Expected : private boost::outcome_v2::result { - using Base = boost::outcome_v2::result; + using Base = boost::outcome_v2::result; public: // The default constructor makes a successful Expected. diff --git a/include/xrpl/basics/IntrusivePointer.h b/include/xrpl/basics/IntrusivePointer.h index 019e71a727..06ee3e5bb4 100644 --- a/include/xrpl/basics/IntrusivePointer.h +++ b/include/xrpl/basics/IntrusivePointer.h @@ -164,11 +164,11 @@ public: /** Return the strong count */ [[nodiscard]] std::size_t - use_count() const; + useCount() const; template friend SharedIntrusive - make_SharedIntrusive(Args&&... args); + makeSharedIntrusive(Args&&... args); template friend class SharedIntrusive; @@ -364,7 +364,7 @@ public: * return 0 */ [[nodiscard]] std::size_t - use_count() const; + useCount() const; /** Return true if there is a non-zero strong count. */ [[nodiscard]] bool @@ -406,8 +406,8 @@ private: // pointer. The low bit must be masked to zero when converting back to a // pointer. If the low bit is '1', this is a weak pointer. std::uintptr_t tp_{0}; - static constexpr std::uintptr_t tagMask = 1; - static constexpr std::uintptr_t ptrMask = ~tagMask; + static constexpr std::uintptr_t kTAG_MASK = 1; + static constexpr std::uintptr_t kPTR_MASK = ~kTAG_MASK; private: /** Return the raw pointer held by this object. @@ -415,7 +415,7 @@ private: [[nodiscard]] T* unsafeGetRawPtr() const; - enum class RefStrength { strong, weak }; + enum class RefStrength { Strong, Weak }; /** Set the raw pointer and tag bit directly. */ void @@ -442,7 +442,7 @@ private: */ template SharedIntrusive -make_SharedIntrusive(Args&&... args) +makeSharedIntrusive(Args&&... args) { auto p = new TT(std::forward(args)...); @@ -469,21 +469,21 @@ using SharedWeakUnionPtr = SharedWeakUnion; template SharedPtr -make_shared(A&&... args) +makeShared(A&&... args) { - return make_SharedIntrusive(std::forward(args)...); + return makeSharedIntrusive(std::forward(args)...); } template SharedPtr -static_pointer_cast(TT const& v) +staticPointerCast(TT const& v) { return SharedPtr(StaticCastTagSharedIntrusive{}, v); } template SharedPtr -dynamic_pointer_cast(TT const& v) +dynamicPointerCast(TT const& v) { return SharedPtr(DynamicCastTagSharedIntrusive{}, v); } diff --git a/include/xrpl/basics/IntrusivePointer.ipp b/include/xrpl/basics/IntrusivePointer.ipp index 59caf5a931..f229df8b27 100644 --- a/include/xrpl/basics/IntrusivePointer.ipp +++ b/include/xrpl/basics/IntrusivePointer.ipp @@ -43,14 +43,16 @@ SharedIntrusive::SharedIntrusive(SharedIntrusive const& rhs) } template -SharedIntrusive::SharedIntrusive(SharedIntrusive&& rhs) : ptr_{rhs.unsafeExchange(nullptr)} +SharedIntrusive::SharedIntrusive(SharedIntrusive&& rhs) + : ptr_{std::move(rhs).unsafeExchange(nullptr)} { } template template requires std::convertible_to -SharedIntrusive::SharedIntrusive(SharedIntrusive&& rhs) : ptr_{rhs.unsafeExchange(nullptr)} +SharedIntrusive::SharedIntrusive(SharedIntrusive&& rhs) + : ptr_{std::move(rhs).unsafeExchange(nullptr)} { } template @@ -93,7 +95,7 @@ SharedIntrusive::operator=(SharedIntrusive&& rhs) if (this == &rhs) return *this; - unsafeReleaseAndStore(rhs.unsafeExchange(nullptr)); + unsafeReleaseAndStore(std::move(rhs).unsafeExchange(nullptr)); return *this; } @@ -105,7 +107,7 @@ SharedIntrusive::operator=(SharedIntrusive&& rhs) { static_assert(!std::is_same_v, "This overload should not be instantiated for T == TT"); - unsafeReleaseAndStore(rhs.unsafeExchange(nullptr)); + unsafeReleaseAndStore(std::move(rhs).unsafeExchange(nullptr)); return *this; } @@ -157,7 +159,7 @@ SharedIntrusive::SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusiv template template SharedIntrusive::SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusive&& rhs) - : ptr_{static_cast(rhs.unsafeExchange(nullptr))} + : ptr_{static_cast(std::move(rhs).unsafeExchange(nullptr))} { } @@ -184,8 +186,10 @@ SharedIntrusive::SharedIntrusive(DynamicCastTagSharedIntrusive, SharedIntrusi { ptr_ = dynamic_cast(toSet); if (!ptr_) + { // need to set the pointer back or will leak - rhs.unsafeExchange(toSet); + std::move(rhs).unsafeExchange(toSet); + } } } @@ -226,10 +230,10 @@ SharedIntrusive::get() const template std::size_t -SharedIntrusive::use_count() const +SharedIntrusive::useCount() const { if (auto p = unsafeGetRawPtr()) - return p->use_count(); + return p->useCount(); return 0; } @@ -266,12 +270,12 @@ SharedIntrusive::unsafeReleaseAndStore(T* next) auto action = prev->releaseStrongRef(); switch (action) { - case noop: + case NoOp: break; - case destroy: + case Destroy: delete prev; break; - case partialDestroy: + case PartialDestroy: prev->partialDestructor(); partialDestructorFinished(&prev); // prev is null and may no longer be used @@ -345,7 +349,7 @@ template bool WeakIntrusive::expired() const { - return (!ptr_ || ptr_->expired()); + return ((ptr_ == nullptr) || ptr_->expired()); } template @@ -360,16 +364,16 @@ template void WeakIntrusive::unsafeReleaseNoStore() { - if (!ptr_) + if (ptr_ == nullptr) return; using enum ReleaseWeakRefAction; auto action = ptr_->releaseWeakRef(); switch (action) { - case noop: + case NoOp: break; - case destroy: + case Destroy: delete ptr_; break; } @@ -385,9 +389,13 @@ SharedWeakUnion::SharedWeakUnion(SharedWeakUnion const& rhs) : tp_{rhs.tp_} return; if (rhs.isStrong()) + { p->addStrongRef(); + } else + { p->addWeakRef(); + } } template @@ -398,7 +406,7 @@ SharedWeakUnion::SharedWeakUnion(SharedIntrusive const& rhs) auto p = rhs.unsafeGetRawPtr(); if (p) p->addStrongRef(); - unsafeSetRawPtr(p, RefStrength::strong); + unsafeSetRawPtr(p, RefStrength::Strong); } template @@ -414,8 +422,8 @@ SharedWeakUnion::SharedWeakUnion(SharedIntrusive&& rhs) { auto p = rhs.unsafeGetRawPtr(); if (p) - unsafeSetRawPtr(p, RefStrength::strong); - rhs.unsafeSetRawPtr(nullptr); + unsafeSetRawPtr(p, RefStrength::Strong); + std::move(rhs).unsafeSetRawPtr(nullptr); } template @@ -431,12 +439,12 @@ SharedWeakUnion::operator=(SharedWeakUnion const& rhs) if (rhs.isStrong()) { p->addStrongRef(); - unsafeSetRawPtr(p, RefStrength::strong); + unsafeSetRawPtr(p, RefStrength::Strong); } else { p->addWeakRef(); - unsafeSetRawPtr(p, RefStrength::weak); + unsafeSetRawPtr(p, RefStrength::Weak); } } else @@ -456,7 +464,7 @@ SharedWeakUnion::operator=(SharedIntrusive const& rhs) auto p = rhs.unsafeGetRawPtr(); if (p) p->addStrongRef(); - unsafeSetRawPtr(p, RefStrength::strong); + unsafeSetRawPtr(p, RefStrength::Strong); return *this; } @@ -467,8 +475,8 @@ SharedWeakUnion& SharedWeakUnion::operator=(SharedIntrusive&& rhs) { unsafeReleaseNoStore(); - unsafeSetRawPtr(rhs.unsafeGetRawPtr(), RefStrength::strong); - rhs.unsafeSetRawPtr(nullptr); + unsafeSetRawPtr(rhs.unsafeGetRawPtr(), RefStrength::Strong); + std::move(rhs).unsafeSetRawPtr(nullptr); return *this; } @@ -517,10 +525,10 @@ SharedWeakUnion::get() const template std::size_t -SharedWeakUnion::use_count() const +SharedWeakUnion::useCount() const { if (auto p = get()) - return p->use_count(); + return p->useCount(); return 0; } @@ -559,14 +567,14 @@ template bool SharedWeakUnion::isStrong() const { - return !(tp_ & tagMask); + return (tp_ & kTAG_MASK) == 0u; } template bool SharedWeakUnion::isWeak() const { - return tp_ & tagMask; + return (tp_ & kTAG_MASK) != 0u; } template @@ -581,10 +589,10 @@ SharedWeakUnion::convertToStrong() { [[maybe_unused]] auto action = p->releaseWeakRef(); XRPL_ASSERT( - (action == ReleaseWeakRefAction::noop), + (action == ReleaseWeakRefAction::NoOp), "xrpl::SharedWeakUnion::convertToStrong : " "action is noop"); - unsafeSetRawPtr(p, RefStrength::strong); + unsafeSetRawPtr(p, RefStrength::Strong); return true; } return false; @@ -605,9 +613,9 @@ SharedWeakUnion::convertToWeak() auto action = p->addWeakReleaseStrongRef(); switch (action) { - case noop: + case NoOp: break; - case destroy: + case Destroy: // We just added a weak ref. How could we destroy? // LCOV_EXCL_START UNREACHABLE( @@ -617,7 +625,7 @@ SharedWeakUnion::convertToWeak() unsafeSetRawPtr(nullptr); return true; // Should never happen // LCOV_EXCL_STOP - case partialDestroy: + case PartialDestroy: // This is a weird case. We just converted the last strong // pointer to a weak pointer. p->partialDestructor(); @@ -625,7 +633,7 @@ SharedWeakUnion::convertToWeak() // p is null and may no longer be used break; } - unsafeSetRawPtr(p, RefStrength::weak); + unsafeSetRawPtr(p, RefStrength::Weak); return true; } @@ -633,7 +641,7 @@ template T* SharedWeakUnion::unsafeGetRawPtr() const { - return reinterpret_cast(tp_ & ptrMask); + return reinterpret_cast(tp_ & kPTR_MASK); } template @@ -641,8 +649,8 @@ void SharedWeakUnion::unsafeSetRawPtr(T* p, RefStrength rs) { tp_ = reinterpret_cast(p); - if (tp_ && rs == RefStrength::weak) - tp_ |= tagMask; + if (tp_ && rs == RefStrength::Weak) + tp_ |= kTAG_MASK; } template @@ -666,12 +674,12 @@ SharedWeakUnion::unsafeReleaseNoStore() auto strongAction = p->releaseStrongRef(); switch (strongAction) { - case noop: + case NoOp: break; - case destroy: + case Destroy: delete p; break; - case partialDestroy: + case PartialDestroy: p->partialDestructor(); partialDestructorFinished(&p); // p is null and may no longer be used @@ -684,9 +692,9 @@ SharedWeakUnion::unsafeReleaseNoStore() auto weakAction = p->releaseWeakRef(); switch (weakAction) { - case noop: + case NoOp: break; - case destroy: + case Destroy: delete p; break; } diff --git a/include/xrpl/basics/IntrusiveRefCounts.h b/include/xrpl/basics/IntrusiveRefCounts.h index e7c31bde93..f0689197d7 100644 --- a/include/xrpl/basics/IntrusiveRefCounts.h +++ b/include/xrpl/basics/IntrusiveRefCounts.h @@ -18,7 +18,7 @@ namespace xrpl { destroy: Run the destructor. This action will occur when either the strong count or weak count is decremented and the other count is also zero. */ -enum class ReleaseStrongRefAction { noop, partialDestroy, destroy }; +enum class ReleaseStrongRefAction { NoOp, PartialDestroy, Destroy }; /** Action to perform when releasing a weak pointer. @@ -28,7 +28,7 @@ enum class ReleaseStrongRefAction { noop, partialDestroy, destroy }; destroy: Run the destructor. This action will occur when either the strong count or weak count is decremented and the other count is also zero. */ -enum class ReleaseWeakRefAction { noop, destroy }; +enum class ReleaseWeakRefAction { NoOp, Destroy }; /** Implement the strong count, weak count, and bit flags for an intrusive pointer. @@ -71,7 +71,7 @@ struct IntrusiveRefCounts expired() const noexcept; std::size_t - use_count() const noexcept; + useCount() const noexcept; // This function MUST be called after a partial destructor finishes running. // Calling this function may cause other threads to delete the object @@ -98,11 +98,11 @@ private: // enough for strong pointers and 14 bit counts are enough for weak // pointers. Use type aliases to make it easy to switch types. using CountType = std::uint16_t; - static constexpr size_t StrongCountNumBits = sizeof(CountType) * 8; - static constexpr size_t WeakCountNumBits = StrongCountNumBits - 2; + static constexpr size_t kSTRONG_COUNT_NUM_BITS = sizeof(CountType) * 8; + static constexpr size_t kWEAK_COUNT_NUM_BITS = kSTRONG_COUNT_NUM_BITS - 2; using FieldType = std::uint32_t; - static constexpr size_t FieldTypeBits = sizeof(FieldType) * 8; - static constexpr FieldType one = 1; + static constexpr size_t kFIELD_TYPE_BITS = sizeof(FieldType) * 8; + static constexpr FieldType kONE = 1; /** `refCounts` consists of four fields that are treated atomically: @@ -137,21 +137,21 @@ private: */ - mutable std::atomic refCounts{strongDelta}; + mutable std::atomic refCounts_{kSTRONG_DELTA}; /** Amount to change the strong count when adding or releasing a reference Note: The strong count is stored in the low `StrongCountNumBits` bits of refCounts */ - static constexpr FieldType strongDelta = 1; + static constexpr FieldType kSTRONG_DELTA = 1; /** Amount to change the weak count when adding or releasing a reference Note: The weak count is stored in the high `WeakCountNumBits` bits of refCounts */ - static constexpr FieldType weakDelta = (one << StrongCountNumBits); + static constexpr FieldType kWEAK_DELTA = (kONE << kSTRONG_COUNT_NUM_BITS); /** Flag that is set when the partialDestroy function has started running (or is about to start running). @@ -159,33 +159,34 @@ private: See description of the `refCounts` field for a fuller description of this field. */ - static constexpr FieldType partialDestroyStartedMask = (one << (FieldTypeBits - 1)); + static constexpr FieldType kPARTIAL_DESTROY_STARTED_MASK = (kONE << (kFIELD_TYPE_BITS - 1)); /** Flag that is set when the partialDestroy function has finished running See description of the `refCounts` field for a fuller description of this field. */ - static constexpr FieldType partialDestroyFinishedMask = (one << (FieldTypeBits - 2)); + static constexpr FieldType kPARTIAL_DESTROY_FINISHED_MASK = (kONE << (kFIELD_TYPE_BITS - 2)); /** Mask that will zero out all the `count` bits and leave the tag bits unchanged. */ - static constexpr FieldType tagMask = partialDestroyStartedMask | partialDestroyFinishedMask; + static constexpr FieldType kTAG_MASK = + kPARTIAL_DESTROY_STARTED_MASK | kPARTIAL_DESTROY_FINISHED_MASK; /** Mask that will zero out the `tag` bits and leave the count bits unchanged. */ - static constexpr FieldType valueMask = ~tagMask; + static constexpr FieldType kVALUE_MASK = ~kTAG_MASK; /** Mask that will zero out everything except the strong count. */ - static constexpr FieldType strongMask = ((one << StrongCountNumBits) - 1) & valueMask; + static constexpr FieldType kSTRONG_MASK = ((kONE << kSTRONG_COUNT_NUM_BITS) - 1) & kVALUE_MASK; /** Mask that will zero out everything except the weak count. */ - static constexpr FieldType weakMask = - (((one << WeakCountNumBits) - 1) << StrongCountNumBits) & valueMask; + static constexpr FieldType kWEAK_MASK = + (((kONE << kWEAK_COUNT_NUM_BITS) - 1) << kSTRONG_COUNT_NUM_BITS) & kVALUE_MASK; /** Unpack the count and tag fields from the packed atomic integer form. */ struct RefCountPair @@ -210,29 +211,29 @@ private: [[nodiscard]] FieldType combinedValue() const noexcept; - static constexpr CountType maxStrongValue = - static_cast((one << StrongCountNumBits) - 1); - static constexpr CountType maxWeakValue = - static_cast((one << WeakCountNumBits) - 1); + static constexpr CountType kMAX_STRONG_VALUE = + static_cast((kONE << kSTRONG_COUNT_NUM_BITS) - 1); + static constexpr CountType kMAX_WEAK_VALUE = + static_cast((kONE << kWEAK_COUNT_NUM_BITS) - 1); /** Put an extra margin to detect when running up against limits. This is only used in debug code, and is useful if we reduce the number of bits in the strong and weak counts (to 16 and 14 bits). */ - static constexpr CountType checkStrongMaxValue = maxStrongValue - 32; - static constexpr CountType checkWeakMaxValue = maxWeakValue - 32; + static constexpr CountType kCHECK_STRONG_MAX_VALUE = kMAX_STRONG_VALUE - 32; + static constexpr CountType kCHECK_WEAK_MAX_VALUE = kMAX_WEAK_VALUE - 32; }; }; inline void IntrusiveRefCounts::addStrongRef() const noexcept { - refCounts.fetch_add(strongDelta, std::memory_order_acq_rel); + refCounts_.fetch_add(kSTRONG_DELTA, std::memory_order_acq_rel); } inline void IntrusiveRefCounts::addWeakRef() const noexcept { - refCounts.fetch_add(weakDelta, std::memory_order_acq_rel); + refCounts_.fetch_add(kWEAK_DELTA, std::memory_order_acq_rel); } inline ReleaseStrongRefAction @@ -246,36 +247,36 @@ IntrusiveRefCounts::releaseStrongRef() const // conditional `fetch_or`. This loop will almost always run once. using enum ReleaseStrongRefAction; - auto prevIntVal = refCounts.load(std::memory_order_acquire); + auto prevIntVal = refCounts_.load(std::memory_order_acquire); while (true) { RefCountPair const prevVal{prevIntVal}; XRPL_ASSERT( - (prevVal.strong >= strongDelta), + (prevVal.strong >= kSTRONG_DELTA), "xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref " "higher than new"); - auto nextIntVal = prevIntVal - strongDelta; - ReleaseStrongRefAction action = noop; + auto nextIntVal = prevIntVal - kSTRONG_DELTA; + ReleaseStrongRefAction action = NoOp; if (prevVal.strong == 1) { if (prevVal.weak == 0) { - action = destroy; + action = Destroy; } else { - nextIntVal |= partialDestroyStartedMask; - action = partialDestroy; + nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK; + action = PartialDestroy; } } - if (refCounts.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel)) + if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel)) { // Can't be in partial destroy because only decrementing the strong // count to zero can start a partial destroy, and that can't happen // twice. XRPL_ASSERT( - (action == noop) || !(prevIntVal & partialDestroyStartedMask), + (action == NoOp) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK), "xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial " "destroy"); return action; @@ -288,9 +289,9 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const { using enum ReleaseStrongRefAction; - static_assert(weakDelta > strongDelta); - auto constexpr delta = weakDelta - strongDelta; - auto prevIntVal = refCounts.load(std::memory_order_acquire); + static_assert(kWEAK_DELTA > kSTRONG_DELTA); + auto constexpr kDELTA = kWEAK_DELTA - kSTRONG_DELTA; + auto prevIntVal = refCounts_.load(std::memory_order_acquire); // This loop will almost always run once. The loop is needed to atomically // change the counts and flags (the count could be atomically changed, but // the flags depend on the current value of the counts). @@ -311,24 +312,24 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const "xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not in " "partial destroy"); - auto nextIntVal = prevIntVal + delta; - ReleaseStrongRefAction action = noop; + auto nextIntVal = prevIntVal + kDELTA; + ReleaseStrongRefAction action = NoOp; if (prevVal.strong == 1) { if (prevVal.weak == 0) { - action = noop; + action = NoOp; } else { - nextIntVal |= partialDestroyStartedMask; - action = partialDestroy; + nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK; + action = PartialDestroy; } } - if (refCounts.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel)) + if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel)) { XRPL_ASSERT( - (!(prevIntVal & partialDestroyStartedMask)), + (!(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK)), "xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not " "started partial destroy"); return action; @@ -339,7 +340,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const inline ReleaseWeakRefAction IntrusiveRefCounts::releaseWeakRef() const { - auto prevIntVal = refCounts.fetch_sub(weakDelta, std::memory_order_acq_rel); + auto prevIntVal = refCounts_.fetch_sub(kWEAK_DELTA, std::memory_order_acq_rel); RefCountPair prev = prevIntVal; if (prev.weak == 1 && prev.strong == 0) { @@ -348,19 +349,19 @@ IntrusiveRefCounts::releaseWeakRef() const // This case should only be hit if the partialDestroyStartedBit is // set non-atomically (and even then very rarely). The code is kept // in case we need to set the flag non-atomically for perf reasons. - refCounts.wait(prevIntVal, std::memory_order_acquire); - prevIntVal = refCounts.load(std::memory_order_acquire); + refCounts_.wait(prevIntVal, std::memory_order_acquire); + prevIntVal = refCounts_.load(std::memory_order_acquire); prev = RefCountPair{prevIntVal}; } if (prev.partialDestroyFinishedBit == 0u) { // partial destroy MUST finish before running a full destroy (when // using weak pointers) - refCounts.wait(prevIntVal - weakDelta, std::memory_order_acquire); + refCounts_.wait(prevIntVal - kWEAK_DELTA, std::memory_order_acquire); } - return ReleaseWeakRefAction::destroy; + return ReleaseWeakRefAction::Destroy; } - return ReleaseWeakRefAction::noop; + return ReleaseWeakRefAction::NoOp; } inline bool @@ -369,13 +370,13 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept auto curValue = RefCountPair{1, 1}.combinedValue(); auto desiredValue = RefCountPair{2, 1}.combinedValue(); - while (!refCounts.compare_exchange_weak(curValue, desiredValue, std::memory_order_acq_rel)) + while (!refCounts_.compare_exchange_weak(curValue, desiredValue, std::memory_order_acq_rel)) { RefCountPair const prev{curValue}; if (prev.strong == 0u) return false; - desiredValue = curValue + strongDelta; + desiredValue = curValue + kSTRONG_DELTA; } return true; } @@ -383,38 +384,39 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept inline bool IntrusiveRefCounts::expired() const noexcept { - RefCountPair const val = refCounts.load(std::memory_order_acquire); + RefCountPair const val = refCounts_.load(std::memory_order_acquire); return val.strong == 0; } inline std::size_t -IntrusiveRefCounts::use_count() const noexcept +IntrusiveRefCounts::useCount() const noexcept { - RefCountPair const val = refCounts.load(std::memory_order_acquire); + RefCountPair const val = refCounts_.load(std::memory_order_acquire); return val.strong; } inline IntrusiveRefCounts::~IntrusiveRefCounts() noexcept { #ifndef NDEBUG - auto v = refCounts.load(std::memory_order_acquire); + auto v = refCounts_.load(std::memory_order_acquire); XRPL_ASSERT( - (!(v & valueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero"); - auto t = v & tagMask; - XRPL_ASSERT((!t || t == tagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag"); + (!(v & kVALUE_MASK)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero"); + auto t = v & kTAG_MASK; + XRPL_ASSERT( + (!t || t == kTAG_MASK), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag"); #endif } //------------------------------------------------------------------------------ inline IntrusiveRefCounts::RefCountPair::RefCountPair(IntrusiveRefCounts::FieldType v) noexcept - : strong{static_cast(v & strongMask)} - , weak{static_cast((v & weakMask) >> StrongCountNumBits)} - , partialDestroyStartedBit{v & partialDestroyStartedMask} - , partialDestroyFinishedBit{v & partialDestroyFinishedMask} + : strong{static_cast(v & kSTRONG_MASK)} + , weak{static_cast((v & kWEAK_MASK) >> kSTRONG_COUNT_NUM_BITS)} + , partialDestroyStartedBit{v & kPARTIAL_DESTROY_STARTED_MASK} + , partialDestroyFinishedBit{v & kPARTIAL_DESTROY_FINISHED_MASK} { XRPL_ASSERT( - (strong < checkStrongMaxValue && weak < checkWeakMaxValue), + (strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), "xrpl::IntrusiveRefCounts::RefCountPair(FieldType) : inputs inside " "range"); } @@ -425,7 +427,7 @@ inline IntrusiveRefCounts::RefCountPair::RefCountPair( : strong{s}, weak{w} { XRPL_ASSERT( - (strong < checkStrongMaxValue && weak < checkWeakMaxValue), + (strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), "xrpl::IntrusiveRefCounts::RefCountPair(CountType, CountType) : " "inputs inside range"); } @@ -434,11 +436,11 @@ inline IntrusiveRefCounts::FieldType IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept { XRPL_ASSERT( - (strong < checkStrongMaxValue && weak < checkWeakMaxValue), + (strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE), "xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs " "inside range"); return (static_cast(weak) - << IntrusiveRefCounts::StrongCountNumBits) | + << IntrusiveRefCounts::kSTRONG_COUNT_NUM_BITS) | static_cast(strong) | partialDestroyStartedBit | partialDestroyFinishedBit; } @@ -449,7 +451,7 @@ partialDestructorFinished(T** o) { T& self = **o; IntrusiveRefCounts::RefCountPair const p = - self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask); + self.refCounts_.fetch_or(IntrusiveRefCounts::kPARTIAL_DESTROY_FINISHED_MASK); XRPL_ASSERT( (!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong), "xrpl::partialDestructorFinished : not a weak ref"); @@ -458,7 +460,7 @@ partialDestructorFinished(T** o) // There was a weak count before the partial destructor ran (or we would // have run the full destructor) and now there isn't a weak count. Some // thread is waiting to run the destructor. - self.refCounts.notify_one(); + self.refCounts_.notify_one(); } // Set the pointer to null to emphasize that the object shouldn't be used // after calling this function as it may be destroyed in another thread. diff --git a/include/xrpl/basics/LocalValue.h b/include/xrpl/basics/LocalValue.h index 421ea7af23..f39df425a6 100644 --- a/include/xrpl/basics/LocalValue.h +++ b/include/xrpl/basics/LocalValue.h @@ -26,17 +26,17 @@ struct LocalValues template struct Value : BasicValue { - T t_; + T t; Value() = default; - explicit Value(T t) : t_(std::move(t)) + explicit Value(T t) : t(std::move(t)) { } void* get() override { - return &t_; + return &t; } }; @@ -55,8 +55,8 @@ template boost::thread_specific_ptr& getLocalValues() { - static boost::thread_specific_ptr tsp(&detail::LocalValues::cleanup); - return tsp; + static boost::thread_specific_ptr kTSP(&detail::LocalValues::cleanup); + return kTSP; } } // namespace detail diff --git a/include/xrpl/basics/Log.h b/include/xrpl/basics/Log.h index 5c63166d93..8e6532f7c0 100644 --- a/include/xrpl/basics/Log.h +++ b/include/xrpl/basics/Log.h @@ -17,15 +17,15 @@ namespace xrpl { // DEPRECATED use beast::severities::Severity instead // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum LogSeverity { - lsINVALID = -1, // used to indicate an invalid severity - lsTRACE = 0, // Very low-level progress information, details inside + LSInvalid = -1, // used to indicate an invalid severity + LSTrace = 0, // Very low-level progress information, details inside // an operation - lsDEBUG = 1, // Function-level progress information, operations - lsINFO = 2, // Server-level progress information, major operations - lsWARNING = 3, // Conditions that warrant human attention, may indicate + LSDebug = 1, // Function-level progress information, operations + LSInfo = 2, // Server-level progress information, major operations + LSWarning = 3, // Conditions that warrant human attention, may indicate // a problem - lsERROR = 4, // A condition that indicates a problem - lsFATAL = 5 // A severe condition that indicates a server problem + LSError = 4, // A condition that indicates a problem + LSFatal = 5 // A severe condition that indicates a server problem }; /** Manages partitions for logging. */ @@ -130,8 +130,8 @@ private: /** @} */ private: - std::unique_ptr m_stream; - boost::filesystem::path m_path; + std::unique_ptr stream_; + boost::filesystem::path path_; }; std::mutex mutable mutex_; @@ -168,7 +168,7 @@ public: threshold(beast::severities::Severity thresh); std::vector> - partition_severities() const; + partitionSeverities() const; void write( @@ -214,7 +214,7 @@ private: // Maximum line length for log messages. // If the message exceeds this length it will be truncated with // ellipses. - maximumMessageCharacters = 12 * 1024 + MaximumMessageCharacters = 12 * 1024 }; static void diff --git a/include/xrpl/basics/Number.h b/include/xrpl/basics/Number.h index b82cb628b9..cdb9014a87 100644 --- a/include/xrpl/basics/Number.h +++ b/include/xrpl/basics/Number.h @@ -70,27 +70,27 @@ isPowerOfTen(T value) struct MantissaRange { using rep = std::uint64_t; - enum class mantissa_scale { small, large }; + enum class MantissaScale { Small, Large }; - explicit constexpr MantissaRange(mantissa_scale scale_) - : min(getMin(scale_)), log(logTen(min).value_or(-1)), scale(scale_) + explicit constexpr MantissaRange(MantissaScale scale) + : min(getMin(scale)), log(logTen(min).value_or(-1)), scale(scale) { } rep min; rep max{(min * 10) - 1}; int log; - mantissa_scale scale; + MantissaScale scale; private: static constexpr rep - getMin(mantissa_scale scale_) + getMin(MantissaScale scale) { - switch (scale_) + switch (scale) { - case mantissa_scale::small: + case MantissaScale::Small: return 1'000'000'000'000'000ULL; - case mantissa_scale::large: + case MantissaScale::Large: return 1'000'000'000'000'000'000ULL; default: // Since this can never be called outside a non-constexpr @@ -214,26 +214,26 @@ class Number public: // The range for the exponent when normalized - constexpr static int minExponent = -32768; - constexpr static int maxExponent = 32768; + constexpr static int kMIN_EXPONENT = -32768; + constexpr static int kMAX_EXPONENT = 32768; - constexpr static internalrep maxRep = std::numeric_limits::max(); - static_assert(maxRep == 9'223'372'036'854'775'807); - static_assert(-maxRep == std::numeric_limits::min() + 1); + constexpr static internalrep kMAX_REP = std::numeric_limits::max(); + static_assert(kMAX_REP == 9'223'372'036'854'775'807); + static_assert(-kMAX_REP == std::numeric_limits::min() + 1); // May need to make unchecked private - struct unchecked + struct Unchecked { - explicit unchecked() = default; + explicit Unchecked() = default; }; // Like unchecked, normalized is used with the ctors that take an // internalrep mantissa. Unlike unchecked, those ctors will normalize the // value. // Only unit tests are expected to use this class - struct normalized + struct Normalized { - explicit normalized() = default; + explicit Normalized() = default; }; explicit constexpr Number() = default; @@ -244,13 +244,13 @@ public: bool negative, internalrep mantissa, int exponent, - unchecked) noexcept; + Unchecked) noexcept; // Assume unsigned values are... unsigned. i.e. positive - explicit constexpr Number(internalrep mantissa, int exponent, unchecked) noexcept; + explicit constexpr Number(internalrep mantissa, int exponent, Unchecked) noexcept; // Only unit tests are expected to use this ctor - explicit Number(bool negative, internalrep mantissa, int exponent, normalized); + explicit Number(bool negative, internalrep mantissa, int exponent, Normalized); // Assume unsigned values are... unsigned. i.e. positive - explicit Number(internalrep mantissa, int exponent, normalized); + explicit Number(internalrep mantissa, int exponent, Normalized); [[nodiscard]] constexpr rep mantissa() const noexcept; @@ -384,42 +384,44 @@ public: root2(Number f); // Thread local rounding control. Default is to_nearest - enum class rounding_mode { to_nearest, towards_zero, downward, upward }; - static rounding_mode + enum class RoundingMode { ToNearest, TowardsZero, Downward, Upward }; + + static RoundingMode getround(); - // Returns previously set mode - static rounding_mode - setround(rounding_mode mode); + + static RoundingMode + setround(RoundingMode inMode); /** Returns which mantissa scale is currently in use for normalization. * * If you think you need to call this outside of unit tests, no you don't. */ - static MantissaRange::mantissa_scale + static MantissaRange::MantissaScale getMantissaScale(); + /** Changes which mantissa scale is used for normalization. * * If you think you need to call this outside of unit tests, no you don't. */ static void - setMantissaScale(MantissaRange::mantissa_scale scale); + setMantissaScale(MantissaRange::MantissaScale scale); static internalrep minMantissa() { - return range_.get().min; + return kRANGE.get().min; } static internalrep maxMantissa() { - return range_.get().max; + return kRANGE.get().max; } static int mantissaLog() { - return range_.get().log; + return kRANGE.get().log; } /// oneSmall is needed because the ranges are private @@ -440,28 +442,28 @@ public: normalizeToRange(T minMantissa, T maxMantissa) const; private: - static thread_local rounding_mode mode_; + static thread_local RoundingMode mode; // The available ranges for mantissa - constexpr static MantissaRange smallRange{MantissaRange::mantissa_scale::small}; - static_assert(isPowerOfTen(smallRange.min)); - static_assert(smallRange.min == 1'000'000'000'000'000LL); - static_assert(smallRange.max == 9'999'999'999'999'999LL); - static_assert(smallRange.log == 15); - static_assert(smallRange.min < maxRep); - static_assert(smallRange.max < maxRep); - constexpr static MantissaRange largeRange{MantissaRange::mantissa_scale::large}; - static_assert(isPowerOfTen(largeRange.min)); - static_assert(largeRange.min == 1'000'000'000'000'000'000ULL); - static_assert(largeRange.max == internalrep(9'999'999'999'999'999'999ULL)); - static_assert(largeRange.log == 18); - static_assert(largeRange.min < maxRep); - static_assert(largeRange.max > maxRep); + constexpr static MantissaRange kSMALL_RANGE{MantissaRange::MantissaScale::Small}; + static_assert(isPowerOfTen(kSMALL_RANGE.min)); + static_assert(kSMALL_RANGE.min == 1'000'000'000'000'000LL); + static_assert(kSMALL_RANGE.max == 9'999'999'999'999'999LL); + static_assert(kSMALL_RANGE.log == 15); + static_assert(kSMALL_RANGE.min < kMAX_REP); + static_assert(kSMALL_RANGE.max < kMAX_REP); + constexpr static MantissaRange kLARGE_RANGE{MantissaRange::MantissaScale::Large}; + static_assert(isPowerOfTen(kLARGE_RANGE.min)); + static_assert(kLARGE_RANGE.min == 1'000'000'000'000'000'000ULL); + static_assert(kLARGE_RANGE.max == internalrep(9'999'999'999'999'999'999ULL)); + static_assert(kLARGE_RANGE.log == 18); + static_assert(kLARGE_RANGE.min < kMAX_REP); + static_assert(kLARGE_RANGE.max > kMAX_REP); // The range for the mantissa when normalized. // Use reference_wrapper to avoid making copies, and prevent accidentally // changing the values inside the range. - static thread_local std::reference_wrapper range_; + static thread_local std::reference_wrapper kRANGE; void normalize(); @@ -469,7 +471,7 @@ private: /** Normalize Number components to an arbitrary range. * * min/maxMantissa are parameters because this function is used by both - * normalize(), which reads from range_, and by normalizeToRange, + * normalize(), which reads from kRANGE, and by normalizeToRange, * which is public and can accept an arbitrary range from the caller. */ template @@ -485,8 +487,8 @@ private: friend void doNormalize( bool& negative, - T& mantissa_, - int& exponent_, + T& mantissa, + int& exponent, MantissaRange::rep const& minMantissa, MantissaRange::rep const& maxMantissa); @@ -509,31 +511,31 @@ private: class Guard; }; -constexpr Number::Number(bool negative, internalrep mantissa, int exponent, unchecked) noexcept +constexpr Number::Number(bool negative, internalrep mantissa, int exponent, Unchecked) noexcept : negative_(negative), mantissa_{mantissa}, exponent_{exponent} { } -constexpr Number::Number(internalrep mantissa, int exponent, unchecked) noexcept - : Number(false, mantissa, exponent, unchecked{}) +constexpr Number::Number(internalrep mantissa, int exponent, Unchecked) noexcept + : Number(false, mantissa, exponent, Unchecked{}) { } -constexpr static Number numZero{}; +constexpr static Number kNUM_ZERO{}; -inline Number::Number(bool negative, internalrep mantissa, int exponent, normalized) - : Number(negative, mantissa, exponent, unchecked{}) +inline Number::Number(bool negative, internalrep mantissa, int exponent, Normalized) + : Number(negative, mantissa, exponent, Unchecked{}) { normalize(); } -inline Number::Number(internalrep mantissa, int exponent, normalized) - : Number(false, mantissa, exponent, normalized{}) +inline Number::Number(internalrep mantissa, int exponent, Normalized) + : Number(false, mantissa, exponent, Normalized{}) { } inline Number::Number(rep mantissa, int exponent) - : Number(mantissa < 0, externalToInternal(mantissa), exponent, normalized{}) + : Number(mantissa < 0, externalToInternal(mantissa), exponent, Normalized{}) { } @@ -550,10 +552,10 @@ constexpr Number::rep Number::mantissa() const noexcept { auto m = mantissa_; - if (m > maxRep) + if (m > kMAX_REP) { XRPL_ASSERT_PARTS( - !isnormal() || (m % 10 == 0 && m / 10 <= maxRep), + !isnormal() || (m % 10 == 0 && m / 10 <= kMAX_REP), "xrpl::Number::mantissa", "large normalized mantissa has no remainder"); m /= 10; @@ -571,10 +573,10 @@ constexpr int Number::exponent() const noexcept { auto e = exponent_; - if (mantissa_ > maxRep) + if (mantissa_ > kMAX_REP) { XRPL_ASSERT_PARTS( - !isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= maxRep), + !isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMAX_REP), "xrpl::Number::exponent", "large normalized mantissa has no remainder"); ++e; @@ -669,29 +671,29 @@ operator/(Number const& x, Number const& y) inline Number Number::min() noexcept { - return Number{false, range_.get().min, minExponent, unchecked{}}; + return Number{false, kRANGE.get().min, kMIN_EXPONENT, Unchecked{}}; } inline Number Number::max() noexcept { - return Number{false, std::min(range_.get().max, maxRep), maxExponent, unchecked{}}; + return Number{false, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}}; } inline Number Number::lowest() noexcept { - return Number{true, std::min(range_.get().max, maxRep), maxExponent, unchecked{}}; + return Number{true, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}}; } inline bool Number::isnormal() const noexcept { - MantissaRange const& range = range_; - auto const abs_m = mantissa_; + MantissaRange const& range = kRANGE; + auto const absM = mantissa_; return *this == Number{} || - (range.min <= abs_m && abs_m <= range.max && (abs_m <= maxRep || abs_m % 10 == 0) && - minExponent <= exponent_ && exponent_ <= maxExponent); + (range.min <= absM && absM <= range.max && (absM <= kMAX_REP || absM % 10 == 0) && + kMIN_EXPONENT <= exponent_ && exponent_ <= kMAX_EXPONENT); } template @@ -755,34 +757,34 @@ squelch(Number const& x, Number const& limit) noexcept } inline std::string -to_string(MantissaRange::mantissa_scale const& scale) +to_string(MantissaRange::MantissaScale const& scale) { switch (scale) { - case MantissaRange::mantissa_scale::small: + case MantissaRange::MantissaScale::Small: return "small"; - case MantissaRange::mantissa_scale::large: + case MantissaRange::MantissaScale::Large: return "large"; default: throw std::runtime_error("Bad scale"); } } -class saveNumberRoundMode +class SaveNumberRoundMode { - Number::rounding_mode mode_; + Number::RoundingMode mode_; public: - ~saveNumberRoundMode() + ~SaveNumberRoundMode() { Number::setround(mode_); } - explicit saveNumberRoundMode(Number::rounding_mode mode) noexcept : mode_{mode} + explicit SaveNumberRoundMode(Number::RoundingMode mode) noexcept : mode_{mode} { } - saveNumberRoundMode(saveNumberRoundMode const&) = delete; - saveNumberRoundMode& - operator=(saveNumberRoundMode const&) = delete; + SaveNumberRoundMode(SaveNumberRoundMode const&) = delete; + SaveNumberRoundMode& + operator=(SaveNumberRoundMode const&) = delete; }; // saveNumberRoundMode doesn't do quite enough for us. What we want is a @@ -791,10 +793,10 @@ public: // build it here. class NumberRoundModeGuard { - saveNumberRoundMode saved_; + SaveNumberRoundMode saved_; public: - explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept + explicit NumberRoundModeGuard(Number::RoundingMode mode) noexcept : saved_{Number::setround(mode)} { } @@ -812,10 +814,10 @@ public: */ class NumberMantissaScaleGuard { - MantissaRange::mantissa_scale const saved_; + MantissaRange::MantissaScale const saved_; public: - explicit NumberMantissaScaleGuard(MantissaRange::mantissa_scale scale) noexcept + explicit NumberMantissaScaleGuard(MantissaRange::MantissaScale scale) noexcept : saved_{Number::getMantissaScale()} { Number::setMantissaScale(scale); diff --git a/include/xrpl/basics/RangeSet.h b/include/xrpl/basics/RangeSet.h index 4e54624056..e1cee8b6c4 100644 --- a/include/xrpl/basics/RangeSet.h +++ b/include/xrpl/basics/RangeSet.h @@ -101,7 +101,7 @@ to_string(RangeSet const& rs) */ template [[nodiscard]] bool -from_string(RangeSet& rs, std::string const& s) +fromString(RangeSet& rs, std::string const& s) { std::vector intervals; std::vector tokens; diff --git a/include/xrpl/basics/Resolver.h b/include/xrpl/basics/Resolver.h index 5bfa6796d2..3b6a950247 100644 --- a/include/xrpl/basics/Resolver.h +++ b/include/xrpl/basics/Resolver.h @@ -16,7 +16,7 @@ public: /** Issue an asynchronous stop request. */ virtual void - stop_async() = 0; + stopAsync() = 0; /** Issue a synchronous stop request. */ virtual void diff --git a/include/xrpl/basics/ResolverAsio.h b/include/xrpl/basics/ResolverAsio.h index d0dcc9f185..2764777327 100644 --- a/include/xrpl/basics/ResolverAsio.h +++ b/include/xrpl/basics/ResolverAsio.h @@ -13,7 +13,7 @@ public: explicit ResolverAsio() = default; static std::unique_ptr - New(boost::asio::io_context&, beast::Journal); + make(boost::asio::io_context&, beast::Journal); }; } // namespace xrpl diff --git a/include/xrpl/basics/SHAMapHash.h b/include/xrpl/basics/SHAMapHash.h index bf688be7da..3b93d1f151 100644 --- a/include/xrpl/basics/SHAMapHash.h +++ b/include/xrpl/basics/SHAMapHash.h @@ -21,12 +21,12 @@ public: } [[nodiscard]] uint256 const& - as_uint256() const + asUint256() const { return hash_; } uint256& - as_uint256() + asUint256() { return hash_; } @@ -93,7 +93,7 @@ template <> inline std::size_t extract(SHAMapHash const& key) { - return *reinterpret_cast(key.as_uint256().data()); + return *reinterpret_cast(key.asUint256().data()); } } // namespace xrpl diff --git a/include/xrpl/basics/SharedWeakCachePointer.h b/include/xrpl/basics/SharedWeakCachePointer.h index 05d3891e5f..c2c3239eea 100644 --- a/include/xrpl/basics/SharedWeakCachePointer.h +++ b/include/xrpl/basics/SharedWeakCachePointer.h @@ -73,7 +73,7 @@ public: /** If this is a strong pointer, return the strong count. Otherwise return 0 */ [[nodiscard]] std::size_t - use_count() const; + useCount() const; /** Return true if there is a non-zero strong count. */ [[nodiscard]] bool diff --git a/include/xrpl/basics/SharedWeakCachePointer.ipp b/include/xrpl/basics/SharedWeakCachePointer.ipp index bb1e201ca8..2f8345e645 100644 --- a/include/xrpl/basics/SharedWeakCachePointer.ipp +++ b/include/xrpl/basics/SharedWeakCachePointer.ipp @@ -57,10 +57,10 @@ template std::shared_ptr const& SharedWeakCachePointer::getStrong() const { - static std::shared_ptr const empty; + static std::shared_ptr const kEMPTY; if (auto p = std::get_if>(&combo_)) return *p; - return empty; + return kEMPTY; } template @@ -86,7 +86,7 @@ SharedWeakCachePointer::get() const template std::size_t -SharedWeakCachePointer::use_count() const +SharedWeakCachePointer::useCount() const { if (auto p = std::get_if>(&combo_)) return p->use_count(); diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index ddcc89d2da..0172b1ade2 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -36,32 +36,32 @@ class SlabAllocator struct SlabBlock { // A mutex to protect the freelist for this block: - std::mutex m_; + std::mutex m; // A linked list of appropriately sized free buffers: - std::uint8_t* l_ = nullptr; + std::uint8_t* l = nullptr; // The next memory block - SlabBlock* next_; + SlabBlock* next; // The underlying memory block: - std::uint8_t const* const p_ = nullptr; + std::uint8_t const* const p = nullptr; // The extent of the underlying memory block: - std::size_t const size_; + std::size_t const size; SlabBlock(SlabBlock* next, std::uint8_t* data, std::size_t size, std::size_t item) - : next_(next), p_(data), size_(size) + : next(next), p(data), size(size) { // We don't need to grab the mutex here, since we're the only // ones with access at this moment. - while (data + item <= p_ + size_) + while (data + item <= p + size) { // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(data, static_cast(&l_), sizeof(std::uint8_t*)); - l_ = data; + std::memcpy(data, static_cast(&l), sizeof(std::uint8_t*)); + l = data; data += item; } } @@ -81,9 +81,9 @@ class SlabAllocator /** Determines whether the given pointer belongs to this allocator */ bool - own(std::uint8_t const* p) const noexcept + own(std::uint8_t const* pIn) const noexcept { - return (p >= p_) && (p < p_ + size_); + return (pIn >= p) && (pIn < p + size); } std::uint8_t* @@ -92,15 +92,14 @@ class SlabAllocator std::uint8_t* ret = nullptr; // NOLINT(misc-const-correctness) { - std::scoped_lock const l(m_); - - ret = l_; + std::scoped_lock const lock(m); + ret = l; if (ret != nullptr) { // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(static_cast(&l_), ret, sizeof(std::uint8_t*)); + std::memcpy(static_cast(&l), ret, sizeof(std::uint8_t*)); } } @@ -121,12 +120,12 @@ class SlabAllocator { XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input"); - std::scoped_lock const l(m_); + std::scoped_lock const lock(m); // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) - std::memcpy(ptr, static_cast(&l_), sizeof(std::uint8_t*)); - l_ = ptr; + std::memcpy(ptr, static_cast(&l), sizeof(std::uint8_t*)); + l = ptr; } }; @@ -201,7 +200,7 @@ public: if (auto ret = slab->allocate()) return ret; - slab = slab->next_; + slab = slab->next; } // No slab can satisfy our request, so we attempt to allocate a new @@ -242,7 +241,7 @@ public: // Link the new slab while (!slabs_.compare_exchange_weak( - slab->next_, slab, std::memory_order_release, std::memory_order_relaxed)) + slab->next, slab, std::memory_order_release, std::memory_order_relaxed)) { ; // Nothing to do } @@ -265,7 +264,7 @@ public: "xrpl::SlabAllocator::SlabAllocator::deallocate : non-null " "input"); - for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) + for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next) { if (slab->own(ptr)) { @@ -294,16 +293,16 @@ public: friend class SlabAllocatorSet; private: - std::size_t extra; - std::size_t alloc; - std::size_t align; + std::size_t extra_; + std::size_t alloc_; + std::size_t align_; public: constexpr SlabConfig( - std::size_t extra_, - std::size_t alloc_ = 0, - std::size_t align_ = alignof(Type)) - : extra(extra_), alloc(alloc_), align(align_) + std::size_t extra, + std::size_t alloc = 0, + std::size_t align = alignof(Type)) + : extra_(extra), alloc_(alloc), align_(align) { } }; @@ -313,22 +312,22 @@ public: // Ensure that the specified allocators are sorted from smallest to // largest by size: std::sort(std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) { - return a.extra < b.extra; + return a.extra_ < b.extra_; }); // We should never have two slabs of the same size if (std::adjacent_find( std::begin(cfg), std::end(cfg), [](SlabConfig const& a, SlabConfig const& b) { - return a.extra == b.extra; + return a.extra_ == b.extra_; }) != cfg.end()) { throw std::runtime_error( - "SlabAllocatorSet<" + beast::type_name() + ">: duplicate slab size"); + "SlabAllocatorSet<" + beast::typeName() + ">: duplicate slab size"); } for (auto const& c : cfg) { - auto& a = allocators_.emplace_back(c.extra, c.alloc, c.align); + auto& a = allocators_.emplace_back(c.extra_, c.alloc_, c.align_); if (a.size() > maxSize_) maxSize_ = a.size(); diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 4be7d9d0bb..948d012958 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -110,7 +110,7 @@ public: /** Shrinks the slice by moving its start forward by n characters. */ void - remove_prefix(std::size_t n) + removePrefix(std::size_t n) { data_ += n; size_ -= n; @@ -118,7 +118,7 @@ public: /** Shrinks the slice by moving its end backward by n characters. */ void - remove_suffix(std::size_t n) + removeSuffix(std::size_t n) { size_ -= n; } diff --git a/include/xrpl/basics/StringUtilities.h b/include/xrpl/basics/StringUtilities.h index 592eee6d53..c9f26026be 100644 --- a/include/xrpl/basics/StringUtilities.h +++ b/include/xrpl/basics/StringUtilities.h @@ -30,7 +30,7 @@ template std::optional strUnHex(std::size_t strSize, Iterator begin, Iterator end) { - static constexpr std::array const digitLookupTable = []() { + static constexpr std::array const kDIGIT_LOOKUP_TABLE = []() { std::array t{}; for (auto& x : t) @@ -56,7 +56,7 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end) if (strSize & 1) { - int c = digitLookupTable[*iter++]; + int c = kDIGIT_LOOKUP_TABLE[*iter++]; if (c < 0) return {}; @@ -66,12 +66,12 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end) while (iter != end) { - int const cHigh = digitLookupTable[*iter++]; + int const cHigh = kDIGIT_LOOKUP_TABLE[*iter++]; if (cHigh < 0) return {}; - int const cLow = digitLookupTable[*iter++]; + int const cLow = kDIGIT_LOOKUP_TABLE[*iter++]; if (cLow < 0) return {}; @@ -94,9 +94,9 @@ strViewUnHex(std::string_view strSrc) return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend()); } -struct parsedURL +struct ParsedUrl { - explicit parsedURL() = default; + explicit ParsedUrl() = default; std::string scheme; std::string username; @@ -106,7 +106,7 @@ struct parsedURL std::string path; bool - operator==(parsedURL const& other) const + operator==(ParsedUrl const& other) const { return scheme == other.scheme && domain == other.domain && port == other.port && path == other.path; @@ -114,13 +114,13 @@ struct parsedURL }; bool -parseUrl(parsedURL& pUrl, std::string const& strUrl); +parseUrl(ParsedUrl& pUrl, std::string const& strUrl); std::string -trim_whitespace(std::string str); +trimWhitespace(std::string str); std::optional -to_uint64(std::string const& s); +toUint64(std::string const& s); /** Determines if the given string looks like a TOML-file hosting domain. diff --git a/include/xrpl/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h index 95703f0633..52b866cdad 100644 --- a/include/xrpl/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -35,7 +35,7 @@ template < bool IsKeyCache = false, class SharedWeakUnionPointerType = SharedWeakCachePointer, class SharedPointerType = std::shared_ptr, - class Hash = hardened_hash<>, + class Hash = HardenedHash<>, class KeyEqual = std::equal_to, class Mutex = std::recursive_mutex> class TaggedCache @@ -44,7 +44,7 @@ public: using mutex_type = Mutex; using key_type = Key; using mapped_type = T; - using clock_type = beast::abstract_clock; + using clock_type = beast::AbstractClock; using shared_weak_combo_pointer_type = SharedWeakUnionPointerType; using shared_pointer_type = SharedPointerType; @@ -55,7 +55,7 @@ public: clock_type::duration expiration, clock_type& clock, beast::Journal journal, - beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::New()); + beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::make()); public: /** Return the clock associated with the cache. */ @@ -86,7 +86,7 @@ public: */ template bool - touch_if_exists(KeyComparable const& key); + touchIfExists(KeyComparable const& key); using SweptPointersVector = std::vector; @@ -115,10 +115,10 @@ public: canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback); bool - canonicalize_replace_cache(key_type const& key, SharedPointerType const& data); + canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data); bool - canonicalize_replace_client(key_type const& key, SharedPointerType& data); + canonicalizeReplaceClient(key_type const& key, SharedPointerType& data); SharedPointerType fetch(key_type const& key); @@ -169,7 +169,7 @@ private: initialFetch(key_type const& key, std::scoped_lock const& l); void - collect_metrics(); + collectMetrics(); private: struct Stats @@ -179,9 +179,9 @@ private: std::string const& prefix, Handler const& handler, beast::insight::Collector::ptr const& collector) - : hook(collector->make_hook(handler)) - , size(collector->make_gauge(prefix, "size")) - , hit_rate(collector->make_gauge(prefix, "hit_rate")) + : hook(collector->makeHook(handler)) + , size(collector->makeGauge(prefix, "size")) + , hit_rate(collector->makeGauge(prefix, "hit_rate")) { } @@ -199,8 +199,7 @@ private: public: clock_type::time_point last_access; - explicit KeyOnlyEntry(clock_type::time_point const& last_access_) - : last_access(last_access_) + explicit KeyOnlyEntry(clock_type::time_point const& lastAccess) : last_access(lastAccess) { } @@ -217,8 +216,8 @@ private: shared_weak_combo_pointer_type ptr; clock_type::time_point last_access; - ValueEntry(clock_type::time_point const& last_access_, shared_pointer_type const& ptr_) - : ptr(ptr_), last_access(last_access_) + ValueEntry(clock_type::time_point const& lastAccess, shared_pointer_type const& ptr) + : ptr(ptr), last_access(lastAccess) { } @@ -261,7 +260,7 @@ private: [[nodiscard]] std::thread sweepHelper( - clock_type::time_point const& when_expire, + clock_type::time_point const& whenExpire, [[maybe_unused]] clock_type::time_point const& now, typename KeyValueCacheType::map_type& partition, SweptPointersVector& stuffToSweep, @@ -270,33 +269,33 @@ private: [[nodiscard]] std::thread sweepHelper( - clock_type::time_point const& when_expire, + clock_type::time_point const& whenExpire, clock_type::time_point const& now, typename KeyOnlyCacheType::map_type& partition, SweptPointersVector&, std::atomic& allRemovals, std::scoped_lock const&); - beast::Journal m_journal; - clock_type& m_clock; - Stats m_stats; + beast::Journal journal_; + clock_type& clock_; + Stats stats_; - mutex_type mutable m_mutex; + mutex_type mutable mutex_; // Used for logging - std::string m_name; + std::string name_; // Desired number of cache entries (0 = ignore) - int const m_target_size; + int const target_size_; // Desired maximum cache age - clock_type::duration const m_target_age; + clock_type::duration const target_age_; // Number of items cached - int m_cache_count{0}; - cache_type m_cache; // Hold strong reference to recent objects - std::uint64_t m_hits{0}; - std::uint64_t m_misses{0}; + int cache_count_{0}; + cache_type cache_; // Hold strong reference to recent objects + std::uint64_t hits_{0}; + std::uint64_t misses_{0}; }; } // namespace xrpl diff --git a/include/xrpl/basics/TaggedCache.ipp b/include/xrpl/basics/TaggedCache.ipp index 67c80b554e..8ef9e16570 100644 --- a/include/xrpl/basics/TaggedCache.ipp +++ b/include/xrpl/basics/TaggedCache.ipp @@ -30,13 +30,12 @@ inline TaggedCache< clock_type& clock, beast::Journal journal, beast::insight::Collector::ptr const& collector) - : m_journal(journal) - , m_clock(clock) - , m_stats(name, std::bind(&TaggedCache::collect_metrics, this), collector) - , m_name(name) - , m_target_size(size) - , m_target_age(expiration) - + : journal_(journal) + , clock_(clock) + , stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector) + , name_(name) + , target_size_(size) + , target_age_(expiration) { } @@ -53,7 +52,7 @@ inline auto TaggedCache:: clock() -> clock_type& { - return m_clock; + return clock_; } template < @@ -69,8 +68,8 @@ inline std::size_t TaggedCache:: size() const { - std::scoped_lock lock(m_mutex); - return m_cache.size(); + std::scoped_lock const lock(mutex_); + return cache_.size(); } template < @@ -86,8 +85,8 @@ inline int TaggedCache:: getCacheSize() const { - std::scoped_lock lock(m_mutex); - return m_cache_count; + std::scoped_lock const lock(mutex_); + return cache_count_; } template < @@ -103,8 +102,8 @@ inline int TaggedCache:: getTrackSize() const { - std::scoped_lock lock(m_mutex); - return m_cache.size(); + std::scoped_lock const lock(mutex_); + return cache_.size(); } template < @@ -120,9 +119,9 @@ inline float TaggedCache:: getHitRate() { - std::scoped_lock lock(m_mutex); - auto const total = static_cast(m_hits + m_misses); - return m_hits * (100.0f / std::max(1.0f, total)); + std::scoped_lock const lock(mutex_); + auto const total = static_cast(hits_ + misses_); + return hits_ * (100.0f / std::max(1.0f, total)); } template < @@ -138,9 +137,9 @@ inline void TaggedCache:: clear() { - std::scoped_lock lock(m_mutex); - m_cache.clear(); - m_cache_count = 0; + std::scoped_lock const lock(mutex_); + cache_.clear(); + cache_count_ = 0; } template < @@ -156,11 +155,11 @@ inline void TaggedCache:: reset() { - std::scoped_lock lock(m_mutex); - m_cache.clear(); - m_cache_count = 0; - m_hits = 0; - m_misses = 0; + std::scoped_lock const lock(mutex_); + cache_.clear(); + cache_count_ = 0; + hits_ = 0; + misses_ = 0; } template < @@ -175,17 +174,17 @@ template < template inline bool TaggedCache:: - touch_if_exists(KeyComparable const& key) + touchIfExists(KeyComparable const& key) { - std::scoped_lock lock(m_mutex); - auto const iter(m_cache.find(key)); - if (iter == m_cache.end()) + std::scoped_lock const lock(mutex_); + auto const iter(cache_.find(key)); + if (iter == cache_.end()) { - ++m_stats.misses; + ++stats_.misses; return false; } - iter->second.touch(m_clock.now()); - ++m_stats.hits; + iter->second.touch(clock_.now()); + ++stats_.hits; return true; } @@ -205,53 +204,53 @@ TaggedCache allStuffToSweep(m_cache.partitions()); + std::vector allStuffToSweep(cache_.partitions()); - clock_type::time_point const now(m_clock.now()); - clock_type::time_point when_expire; + clock_type::time_point const now(clock_.now()); + clock_type::time_point whenExpire; auto const start = std::chrono::steady_clock::now(); { - std::scoped_lock lock(m_mutex); + std::scoped_lock const lock(mutex_); - if (m_target_size == 0 || (static_cast(m_cache.size()) <= m_target_size)) + if (target_size_ == 0 || (static_cast(cache_.size()) <= target_size_)) { - when_expire = now - m_target_age; + whenExpire = now - target_age_; } else { - when_expire = now - m_target_age * m_target_size / m_cache.size(); + whenExpire = now - (target_age_ * target_size_ / cache_.size()); clock_type::duration const minimumAge(std::chrono::seconds(1)); - if (when_expire > (now - minimumAge)) - when_expire = now - minimumAge; + if (whenExpire > (now - minimumAge)) + whenExpire = now - minimumAge; - JLOG(m_journal.trace()) - << m_name << " is growing fast " << m_cache.size() << " of " << m_target_size - << " aging at " << (now - when_expire).count() << " of " << m_target_age.count(); + JLOG(journal_.trace()) + << name_ << " is growing fast " << cache_.size() << " of " << target_size_ + << " aging at " << (now - whenExpire).count() << " of " << target_age_.count(); } std::vector workers; - workers.reserve(m_cache.partitions()); + workers.reserve(cache_.partitions()); std::atomic allRemovals = 0; - for (std::size_t p = 0; p < m_cache.partitions(); ++p) + for (std::size_t p = 0; p < cache_.partitions(); ++p) { workers.push_back(sweepHelper( - when_expire, now, m_cache.map()[p], allStuffToSweep[p], allRemovals, lock)); + whenExpire, now, cache_.map()[p], allStuffToSweep[p], allRemovals, lock)); } for (std::thread& worker : workers) worker.join(); - m_cache_count -= allRemovals; + cache_count_ -= allRemovals; } // At this point allStuffToSweep will go out of scope outside the lock // and decrement the reference count on each strong pointer. - JLOG(m_journal.debug()) << m_name << " TaggedCache sweep lock duration " - << std::chrono::duration_cast( - std::chrono::steady_clock::now() - start) - .count() - << "ms"; + JLOG(journal_.debug()) << name_ << " TaggedCache sweep lock duration " + << std::chrono::duration_cast( + std::chrono::steady_clock::now() - start) + .count() + << "ms"; } template < @@ -267,13 +266,12 @@ inline bool TaggedCache:: del(key_type const& key, bool valid) { - // Remove from cache, if !valid, remove from map too. Returns true if - // removed from cache - std::scoped_lock lock(m_mutex); + // Remove from cache, if !valid, remove from map too. Returns true if removed from cache + std::scoped_lock const lock(mutex_); - auto cit = m_cache.find(key); + auto cit = cache_.find(key); - if (cit == m_cache.end()) + if (cit == cache_.end()) return false; Entry& entry = cit->second; @@ -282,13 +280,13 @@ TaggedCachesecond; - entry.touch(m_clock.now()); + entry.touch(clock_.now()); auto shouldReplace = [&] { if constexpr (std::is_invocable_r_v) @@ -368,12 +366,12 @@ TaggedCache inline bool TaggedCache:: - canonicalize_replace_cache(key_type const& key, SharedPointerType const& data) + canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data) { return canonicalize(key, const_cast(data), []() { return true; }); } @@ -405,7 +403,7 @@ template < class Mutex> inline bool TaggedCache:: - canonicalize_replace_client(key_type const& key, SharedPointerType& data) + canonicalizeReplaceClient(key_type const& key, SharedPointerType& data) { return canonicalize(key, data, []() { return false; }); } @@ -423,10 +421,10 @@ inline SharedPointerType TaggedCache:: fetch(key_type const& key) { - std::scoped_lock l(m_mutex); + std::scoped_lock const l(mutex_); auto ret = initialFetch(key, l); if (!ret) - ++m_misses; + ++misses_; return ret; } @@ -451,12 +449,12 @@ TaggedCache, SharedPointerType>) { auto p = std::make_shared(std::cref(value)); - return canonicalize_replace_client(key, p); + return canonicalizeReplaceClient(key, p); } if constexpr (std::is_same_v, SharedPointerType>) { - auto p = intr_ptr::make_shared(std::cref(value)); - return canonicalize_replace_client(key, p); + auto p = intr_ptr::makeShared(std::cref(value)); + return canonicalizeReplaceClient(key, p); } } @@ -474,9 +472,9 @@ inline auto TaggedCache:: insert(key_type const& key) -> std::enable_if_t { - std::scoped_lock lock(m_mutex); - clock_type::time_point const now(m_clock.now()); - auto [it, inserted] = m_cache.emplace( + std::scoped_lock const lock(mutex_); + clock_type::time_point const now(clock_.now()); + auto [it, inserted] = cache_.emplace( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now)); if (!inserted) it->second.last_access = now; @@ -519,7 +517,7 @@ inline auto TaggedCache:: peekMutex() -> mutex_type& { - return m_mutex; + return mutex_; } template < @@ -538,9 +536,9 @@ TaggedCache v; { - std::scoped_lock lock(m_mutex); - v.reserve(m_cache.size()); - for (auto const& _ : m_cache) + std::scoped_lock const lock(mutex_); + v.reserve(cache_.size()); + for (auto const& _ : cache_) v.push_back(_.first); } @@ -560,11 +558,11 @@ inline double TaggedCache:: rate() const { - std::scoped_lock lock(m_mutex); - auto const tot = m_hits + m_misses; + std::scoped_lock const lock(mutex_); + auto const tot = hits_ + misses_; if (tot == 0) return 0; - return double(m_hits) / tot; + return double(hits_) / tot; } template < @@ -582,7 +580,7 @@ TaggedCachesecond.touch(m_clock.now()); + it->second.touch(clock_.now()); return it->second.ptr.getStrong(); } // End CachedSLEs functions. @@ -613,27 +611,27 @@ inline SharedPointerType TaggedCache:: initialFetch(key_type const& key, std::scoped_lock const& l) { - auto cit = m_cache.find(key); - if (cit == m_cache.end()) + auto cit = cache_.find(key); + if (cit == cache_.end()) return {}; Entry& entry = cit->second; if (entry.isCached()) { - ++m_hits; - entry.touch(m_clock.now()); + ++hits_; + entry.touch(clock_.now()); return entry.ptr.getStrong(); } entry.ptr = entry.lock(); if (entry.isCached()) { // independent of cache size, so not counted as a hit - ++m_cache_count; - entry.touch(m_clock.now()); + ++cache_count_; + entry.touch(clock_.now()); return entry.ptr.getStrong(); } - m_cache.erase(cit); + cache_.erase(cit); return {}; } @@ -648,19 +646,19 @@ template < class Mutex> inline void TaggedCache:: - collect_metrics() + collectMetrics() { - m_stats.size.set(getCacheSize()); + stats_.size.set(getCacheSize()); { - beast::insight::Gauge::value_type hit_rate(0); + beast::insight::Gauge::value_type hitRate(0); { - std::scoped_lock lock(m_mutex); - auto const total(m_hits + m_misses); + std::scoped_lock const lock(mutex_); + auto const total(hits_ + misses_); if (total != 0) - hit_rate = (m_hits * 100) / total; + hitRate = (hits_ * 100) / total; } - m_stats.hit_rate.set(hit_rate); + stats_.hit_rate.set(hitRate); } } @@ -676,7 +674,7 @@ template < inline std::thread TaggedCache:: sweepHelper( - clock_type::time_point const& when_expire, + clock_type::time_point const& whenExpire, [[maybe_unused]] clock_type::time_point const& now, typename KeyValueCacheType::map_type& partition, SweptPointersVector& stuffToSweep, @@ -708,11 +706,11 @@ TaggedCachesecond.last_access <= when_expire) + else if (cit->second.last_access <= whenExpire) { // strong, expired ++cacheRemovals; - if (cit->second.ptr.use_count() == 1) + if (cit->second.ptr.useCount() == 1) { stuffToSweep.emplace_back(std::move(cit->second.ptr)); ++mapRemovals; @@ -735,8 +733,8 @@ TaggedCache, + class Hash = beast::Uhash<>, class Pred = std::equal_to, class Allocator = std::allocator>> using hash_map = std::unordered_map; @@ -36,33 +36,33 @@ using hash_map = std::unordered_map; template < class Key, class Value, - class Hash = beast::uhash<>, + class Hash = beast::Uhash<>, class Pred = std::equal_to, class Allocator = std::allocator>> using hash_multimap = std::unordered_multimap; template < class Value, - class Hash = beast::uhash<>, + class Hash = beast::Uhash<>, class Pred = std::equal_to, class Allocator = std::allocator> using hash_set = std::unordered_set; template < class Value, - class Hash = beast::uhash<>, + class Hash = beast::Uhash<>, class Pred = std::equal_to, class Allocator = std::allocator> using hash_multiset = std::unordered_multiset; // hardened_hash containers -using strong_hash = beast::xxhasher; +using strong_hash = beast::Xxhasher; template < class Key, class Value, - class Hash = hardened_hash, + class Hash = HardenedHash, class Pred = std::equal_to, class Allocator = std::allocator>> using hardened_hash_map = std::unordered_map; @@ -70,29 +70,29 @@ using hardened_hash_map = std::unordered_map; template < class Key, class Value, - class Hash = hardened_hash, + class Hash = HardenedHash, class Pred = std::equal_to, class Allocator = std::allocator>> -using hardened_partitioned_hash_map = partitioned_unordered_map; +using hardened_partitioned_hash_map = PartitionedUnorderedMap; template < class Key, class Value, - class Hash = hardened_hash, + class Hash = HardenedHash, class Pred = std::equal_to, class Allocator = std::allocator>> using hardened_hash_multimap = std::unordered_multimap; template < class Value, - class Hash = hardened_hash, + class Hash = HardenedHash, class Pred = std::equal_to, class Allocator = std::allocator> using hardened_hash_set = std::unordered_set; template < class Value, - class Hash = hardened_hash, + class Hash = HardenedHash, class Pred = std::equal_to, class Allocator = std::allocator> using hardened_hash_multiset = std::unordered_multiset; diff --git a/include/xrpl/basics/UptimeClock.h b/include/xrpl/basics/UptimeClock.h index 3f2e09bbe3..bb7d4fd77a 100644 --- a/include/xrpl/basics/UptimeClock.h +++ b/include/xrpl/basics/UptimeClock.h @@ -21,7 +21,8 @@ public: using period = std::ratio<1>; using duration = std::chrono::duration; using time_point = std::chrono::time_point; - static constexpr bool is_steady = std::chrono::system_clock::is_steady; + static constexpr bool is_steady = // NOLINT(readability-identifier-naming) + std::chrono::system_clock::is_steady; explicit UptimeClock() = default; @@ -29,19 +30,19 @@ public: now(); // seconds since xrpld program start private: - static std::atomic now_; - static std::atomic stop_; + static std::atomic kNOW; + static std::atomic kSTOP; - struct update_thread : private std::thread + struct UpdateThread : private std::thread { - ~update_thread(); - update_thread(update_thread&&) = default; + ~UpdateThread(); + UpdateThread(UpdateThread&&) = default; using std::thread::thread; }; - static update_thread - start_clock(); + static UpdateThread + startClock(); }; } // namespace xrpl diff --git a/include/xrpl/basics/algorithm.h b/include/xrpl/basics/algorithm.h index 9dae731a89..6efd8fbe8d 100644 --- a/include/xrpl/basics/algorithm.h +++ b/include/xrpl/basics/algorithm.h @@ -13,7 +13,7 @@ namespace xrpl { // Note: This algorithm is evolved from std::set_intersection. template void -generalized_set_intersection( +generalizedSetIntersection( InputIter1 first1, InputIter1 last1, InputIter2 first2, @@ -53,7 +53,7 @@ generalized_set_intersection( // std::set_intersection. template FwdIter1 -remove_if_intersect_or_match( +removeIfIntersectOrMatch( FwdIter1 first1, FwdIter1 last1, InputIter2 first2, diff --git a/include/xrpl/basics/base64.h b/include/xrpl/basics/base64.h index 1725ee42f6..ed30e40a36 100644 --- a/include/xrpl/basics/base64.h +++ b/include/xrpl/basics/base64.h @@ -40,15 +40,15 @@ namespace xrpl { std::string -base64_encode(std::uint8_t const* data, std::size_t len); +base64Encode(std::uint8_t const* data, std::size_t len); inline std::string -base64_encode(std::string const& s) +base64Encode(std::string const& s) { - return base64_encode(reinterpret_cast(s.data()), s.size()); + return base64Encode(reinterpret_cast(s.data()), s.size()); } std::string -base64_decode(std::string_view data); +base64Decode(std::string_view data); } // namespace xrpl diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index b6ff5ea9c0..15fc4f6966 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -27,12 +27,12 @@ namespace xrpl { namespace detail { template > -struct is_contiguous_container : std::false_type +struct IsContiguousContainer : std::false_type { }; template -struct is_contiguous_container< +struct IsContiguousContainer< Container, std::void_t< decltype(std::declval().size()), @@ -42,7 +42,7 @@ struct is_contiguous_container< }; template <> -struct is_contiguous_container : std::true_type +struct IsContiguousContainer : std::true_type { }; @@ -62,18 +62,18 @@ struct is_contiguous_container : std::true_type number of bits. */ template -class base_uint +class BaseUint { static_assert((Bits % 32) == 0, "The length of a base_uint in bits must be a multiple of 32."); static_assert(Bits >= 64, "The length of a base_uint in bits must be at least 64."); - static constexpr std::size_t WIDTH = Bits / 32; + static constexpr std::size_t kWIDTH = Bits / 32; // This is really big-endian in byte order. // We sometimes use std::uint32_t for speed. - std::array data_; + std::array data_; public: //-------------------------------------------------------------------------- @@ -81,8 +81,8 @@ public: // STL Container Interface // - static std::size_t constexpr bytes = Bits / 8; - static_assert(sizeof(data_) == bytes, ""); + static std::size_t constexpr kBYTES = Bits / 8; + static_assert(sizeof(data_) == kBYTES, ""); using size_type = std::size_t; using difference_type = std::ptrdiff_t; @@ -116,7 +116,7 @@ public: iterator end() { - return data() + bytes; + return data() + kBYTES; } [[nodiscard]] const_iterator begin() const @@ -126,7 +126,7 @@ public: [[nodiscard]] const_iterator end() const { - return data() + bytes; + return data() + kBYTES; } [[nodiscard]] const_iterator cbegin() const @@ -136,14 +136,14 @@ public: [[nodiscard]] const_iterator cend() const { - return data() + bytes; + return data() + kBYTES; } /** Value hashing function. The seed prevents crafted inputs from causing degenerate parent containers. */ - using hasher = hardened_hash<>; + using hasher = HardenedHash<>; //-------------------------------------------------------------------------- @@ -160,16 +160,16 @@ private: explicit VoidHelper() = default; }; - explicit base_uint(void const* data, VoidHelper) + explicit BaseUint(void const* data, VoidHelper) { - memcpy(data_.data(), data, bytes); + memcpy(data_.data(), data, kBYTES); } // Helper function to initialize a base_uint from a std::string_view. enum class ParseResult { - okay, - badLength, - badChar, + Okay, + BadLength, + BadChar, }; constexpr Expected @@ -180,7 +180,7 @@ private: auto hexCharToUInt = [](char c, std::uint32_t shift, std::uint32_t& accum) -> ParseResult { std::uint32_t nibble = 0xFFu; if (c < '0' || c > 'f') - return ParseResult::badChar; + return ParseResult::BadChar; if (c >= 'a') { @@ -196,11 +196,11 @@ private: } if (nibble > 0xFu) - return ParseResult::badChar; + return ParseResult::BadChar; accum |= (nibble << shift); - return ParseResult::okay; + return ParseResult::Okay; }; decltype(data_) ret{}; @@ -211,7 +211,7 @@ private: } if (sv.size() != size() * 2) - return Unexpected(ParseResult::badLength); + return Unexpected(ParseResult::BadLength); std::size_t i = 0u; auto in = sv.begin(); @@ -221,7 +221,7 @@ private: for (std::uint32_t const shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u}) { if (auto const result = hexCharToUInt(*in++, shift, accum); - result != ParseResult::okay) + result != ParseResult::Okay) return Unexpected(result); } ret[i++] = accum; @@ -235,7 +235,7 @@ private: auto const result = parseFromStringView(sv); if (!result) { - if (result.error() == ParseResult::badLength) + if (result.error() == ParseResult::BadLength) Throw("invalid length for hex string"); Throw("invalid hex character"); @@ -244,15 +244,15 @@ private: } public: - constexpr base_uint() : data_{} + constexpr BaseUint() : data_{} { } - constexpr base_uint(beast::Zero) : data_{} + constexpr BaseUint(beast::Zero) : data_{} { } - explicit base_uint(std::uint64_t b) + explicit BaseUint(std::uint64_t b) { *this = b; } @@ -260,7 +260,7 @@ public: // This constructor is intended to be used at compile time since it might // throw at runtime. Consider declaring this constructor consteval once // we get to C++23. - explicit constexpr base_uint(std::string_view sv) noexcept(false) + explicit constexpr BaseUint(std::string_view sv) noexcept(false) : data_(parseFromStringViewThrows(sv)) { } @@ -268,9 +268,9 @@ public: template < class Container, class = std::enable_if_t< - detail::is_contiguous_container::value && + detail::IsContiguousContainer::value && std::is_trivially_copyable_v>> - explicit base_uint(Container const& c) + explicit BaseUint(Container const& c) { XRPL_ASSERT( c.size() * sizeof(typename Container::value_type) == size(), @@ -280,9 +280,9 @@ public: template std::enable_if_t< - detail::is_contiguous_container::value && + detail::IsContiguousContainer::value && std::is_trivially_copyable_v, - base_uint&> + BaseUint&> operator=(Container const& c) { XRPL_ASSERT( @@ -295,14 +295,14 @@ public: /* Construct from a raw pointer. The buffer pointed to by `data` must be at least Bits/8 bytes. */ - static base_uint + static BaseUint fromVoid(void const* data) { - return base_uint(data, VoidHelper()); + return BaseUint(data, VoidHelper()); } template - static std::optional + static std::optional fromVoidChecked(T const& from) { if (from.size() != size()) @@ -313,7 +313,7 @@ public: [[nodiscard]] constexpr int signum() const { - for (int i = 0; i < WIDTH; i++) + for (int i = 0; i < kWIDTH; i++) { if (data_[i] != 0) return 1; @@ -325,24 +325,24 @@ public: bool operator!() const { - return *this == beast::zero; + return *this == beast::kZERO; } - constexpr base_uint + constexpr BaseUint operator~() const { - base_uint ret; + BaseUint ret; - for (int i = 0; i < WIDTH; i++) + for (int i = 0; i < kWIDTH; i++) ret.data_[i] = ~data_[i]; return ret; } - base_uint& + BaseUint& operator=(std::uint64_t uHost) { - *this = beast::zero; + *this = beast::kZERO; // NOLINTBEGIN(cppcoreguidelines-pro-type-member-init) union { @@ -352,43 +352,43 @@ public: // NOLINTEND(cppcoreguidelines-pro-type-member-init) // Put in least significant bits. ul = boost::endian::native_to_big(uHost); - data_[WIDTH - 2] = u[0]; - data_[WIDTH - 1] = u[1]; + data_[kWIDTH - 2] = u[0]; + data_[kWIDTH - 1] = u[1]; return *this; } - base_uint& - operator^=(base_uint const& b) + BaseUint& + operator^=(BaseUint const& b) { - for (int i = 0; i < WIDTH; i++) + for (int i = 0; i < kWIDTH; i++) data_[i] ^= b.data_[i]; return *this; } - base_uint& - operator&=(base_uint const& b) + BaseUint& + operator&=(BaseUint const& b) { - for (int i = 0; i < WIDTH; i++) + for (int i = 0; i < kWIDTH; i++) data_[i] &= b.data_[i]; return *this; } - base_uint& - operator|=(base_uint const& b) + BaseUint& + operator|=(BaseUint const& b) { - for (int i = 0; i < WIDTH; i++) + for (int i = 0; i < kWIDTH; i++) data_[i] |= b.data_[i]; return *this; } - base_uint& + BaseUint& operator++() { // prefix operator - for (int i = WIDTH - 1; i >= 0; --i) + for (int i = kWIDTH - 1; i >= 0; --i) { data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) + 1); if (data_[i] != 0) @@ -398,20 +398,20 @@ public: return *this; } - base_uint + BaseUint operator++(int) { // postfix operator - base_uint const ret = *this; + BaseUint const ret = *this; ++(*this); return ret; } - base_uint& + BaseUint& operator--() { - for (int i = WIDTH - 1; i >= 0; --i) + for (int i = kWIDTH - 1; i >= 0; --i) { auto prev = data_[i]; data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) - 1); @@ -423,36 +423,36 @@ public: return *this; } - base_uint + BaseUint operator--(int) { // postfix operator - base_uint const ret = *this; + BaseUint const ret = *this; --(*this); return ret; } - [[nodiscard]] base_uint + [[nodiscard]] BaseUint next() const { auto ret = *this; return ++ret; } - [[nodiscard]] base_uint + [[nodiscard]] BaseUint prev() const { auto ret = *this; return --ret; } - base_uint& - operator+=(base_uint const& b) + BaseUint& + operator+=(BaseUint const& b) { std::uint64_t carry = 0; - for (int i = WIDTH - 1; i >= 0; i--) + for (int i = kWIDTH - 1; i >= 0; i--) { std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) + boost::endian::big_to_native(b.data_[i]); @@ -466,7 +466,7 @@ public: template friend void - hash_append(Hasher& h, base_uint const& a) noexcept + hash_append(Hasher& h, BaseUint const& a) noexcept { // Do not allow any endian transformations on this memory h(a.data_.data(), sizeof(a.data_)); @@ -506,10 +506,10 @@ public: constexpr static std::size_t size() { - return bytes; + return kBYTES; } - base_uint& + BaseUint& operator=(beast::Zero) { data_.fill(0); @@ -520,28 +520,28 @@ public: [[nodiscard]] bool isZero() const { - return *this == beast::zero; + return *this == beast::kZERO; } [[nodiscard]] bool isNonZero() const { - return *this != beast::zero; + return *this != beast::kZERO; } void zero() { - *this = beast::zero; + *this = beast::kZERO; } }; -using uint128 = base_uint<128>; -using uint160 = base_uint<160>; -using uint256 = base_uint<256>; -using uint192 = base_uint<192>; +using uint128 = BaseUint<128>; +using uint160 = BaseUint<160>; +using uint256 = BaseUint<256>; +using uint192 = BaseUint<192>; template [[nodiscard]] constexpr std::strong_ordering -operator<=>(base_uint const& lhs, base_uint const& rhs) +operator<=>(BaseUint const& lhs, BaseUint const& rhs) { // This comparison might seem wrong on a casual inspection because it // compares data internally stored as std::uint32_t byte-by-byte. But @@ -562,7 +562,7 @@ operator<=>(base_uint const& lhs, base_uint const& rhs) template [[nodiscard]] constexpr bool -operator==(base_uint const& lhs, base_uint const& rhs) +operator==(BaseUint const& lhs, BaseUint const& rhs) { return (lhs <=> rhs) == 0; } @@ -570,59 +570,59 @@ operator==(base_uint const& lhs, base_uint const& rhs) //------------------------------------------------------------------------------ template constexpr bool -operator==(base_uint const& a, std::uint64_t b) +operator==(BaseUint const& a, std::uint64_t b) { - return a == base_uint(b); + return a == BaseUint(b); } //------------------------------------------------------------------------------ template -constexpr base_uint -operator^(base_uint const& a, base_uint const& b) +constexpr BaseUint +operator^(BaseUint const& a, BaseUint const& b) { - return base_uint(a) ^= b; + return BaseUint(a) ^= b; } template -constexpr base_uint -operator&(base_uint const& a, base_uint const& b) +constexpr BaseUint +operator&(BaseUint const& a, BaseUint const& b) { - return base_uint(a) &= b; + return BaseUint(a) &= b; } template -constexpr base_uint -operator|(base_uint const& a, base_uint const& b) +constexpr BaseUint +operator|(BaseUint const& a, BaseUint const& b) { - return base_uint(a) |= b; + return BaseUint(a) |= b; } template -constexpr base_uint -operator+(base_uint const& a, base_uint const& b) +constexpr BaseUint +operator+(BaseUint const& a, BaseUint const& b) { - return base_uint(a) += b; + return BaseUint(a) += b; } //------------------------------------------------------------------------------ template inline std::string -to_string(base_uint const& a) +to_string(BaseUint const& a) { return strHex(a.cbegin(), a.cend()); } template inline std::string -to_short_string(base_uint const& a) +toShortString(BaseUint const& a) { - static_assert(base_uint::bytes > 4, "For 4 bytes or less, use a native type"); + static_assert(BaseUint::kBYTES > 4, "For 4 bytes or less, use a native type"); return strHex(a.cbegin(), a.cbegin() + 4) + "..."; } template inline std::ostream& -operator<<(std::ostream& out, base_uint const& u) +operator<<(std::ostream& out, BaseUint const& u) { return out << to_string(u); } @@ -650,9 +650,9 @@ static_assert(sizeof(uint256) == 256 / 8, "There should be no padding bytes"); namespace beast { template -struct is_uniquely_represented> : public std::true_type +struct IsUniquelyRepresented> : public std::true_type { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; } // namespace beast diff --git a/include/xrpl/basics/chrono.h b/include/xrpl/basics/chrono.h index a9f12b041c..8b71be04b4 100644 --- a/include/xrpl/basics/chrono.h +++ b/include/xrpl/basics/chrono.h @@ -30,10 +30,10 @@ using weeks = std::chrono::duration; using time_point = std::chrono::time_point; - static bool const is_steady = false; + static bool const is_steady = false; // NOLINT(readability-identifier-naming) }; template @@ -60,42 +60,42 @@ to_string(NetClock::time_point tp) { // 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC using namespace std::chrono; - return to_string(system_clock::time_point{tp.time_since_epoch() + epoch_offset}); + return to_string(system_clock::time_point{tp.time_since_epoch() + kEPOCH_OFFSET}); } template std::string -to_string_iso(date::sys_time tp) +toStringIso(date::sys_time tp) { using namespace std::chrono; return date::format("%FT%TZ", tp); } inline std::string -to_string_iso(NetClock::time_point tp) +toStringIso(NetClock::time_point tp) { // 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC // Note, NetClock::duration is seconds, as checked by static_assert static_assert(std::is_same_v>); - return to_string_iso(date::sys_time{tp.time_since_epoch() + epoch_offset}); + return toStringIso(date::sys_time{tp.time_since_epoch() + kEPOCH_OFFSET}); } /** A clock for measuring elapsed time. The epoch is unspecified. */ -using Stopwatch = beast::abstract_clock; +using Stopwatch = beast::AbstractClock; /** A manual Stopwatch for unit tests. */ -using TestStopwatch = beast::manual_clock; +using TestStopwatch = beast::ManualClock; /** Returns an instance of a wall clock. */ inline Stopwatch& stopwatch() { - using Clock = beast::basic_seconds_clock; + using Clock = beast::BasicSecondsClock; using Facade = Clock::Clock; - return beast::get_abstract_clock(); + return beast::getAbstractClock(); } } // namespace xrpl diff --git a/include/xrpl/basics/contract.h b/include/xrpl/basics/contract.h index 0d9f567416..0e90687de3 100644 --- a/include/xrpl/basics/contract.h +++ b/include/xrpl/basics/contract.h @@ -17,7 +17,7 @@ namespace xrpl { /** Generates and logs a call stack */ void -LogThrow(std::string const& title); +logThrow(std::string const& title); /** Rethrow the exception currently being handled. @@ -30,9 +30,9 @@ LogThrow(std::string const& title); triggering false positives, since it throws. */ [[noreturn]] XRPL_NO_SANITIZE_ADDRESS inline void -Rethrow() +rethrow() { - LogThrow("Re-throwing exception"); + logThrow("Re-throwing exception"); throw; } @@ -52,12 +52,12 @@ Throw(Args&&... args) std::is_convertible_v, "Exception must derive from std::exception."); E e(std::forward(args)...); - LogThrow(std::string("Throwing exception of type " + beast::type_name() + ": ") + e.what()); + logThrow(std::string("Throwing exception of type " + beast::typeName() + ": ") + e.what()); throw std::move(e); } /** Called when faulty logic causes a broken invariant. */ [[noreturn]] void -LogicError(std::string const& how) noexcept; +logicError(std::string const& how) noexcept; } // namespace xrpl diff --git a/include/xrpl/basics/hardened_hash.h b/include/xrpl/basics/hardened_hash.h index 2722a5a4a7..07f5aded4c 100644 --- a/include/xrpl/basics/hardened_hash.h +++ b/include/xrpl/basics/hardened_hash.h @@ -16,24 +16,24 @@ using seed_pair = std::pair; template seed_pair -make_seed_pair() noexcept +makeSeedPair() noexcept { - struct state_t + struct StateT { std::mutex mutex; std::random_device rng; std::mt19937_64 gen; std::uniform_int_distribution dist; - state_t() : gen(rng()) + StateT() : gen(rng()) { } // state_t(state_t const&) = delete; // state_t& operator=(state_t const&) = delete; }; - static state_t state; - std::scoped_lock const lock(state.mutex); - return {state.dist(state.gen), state.dist(state.gen)}; + static StateT kSTATE; + std::scoped_lock const lock(kSTATE.mutex); + return {kSTATE.dist(kSTATE.gen), kSTATE.dist(kSTATE.gen)}; } } // namespace detail @@ -68,22 +68,22 @@ make_seed_pair() noexcept see https://131002.net/siphash/#at */ -template -class hardened_hash +template +class HardenedHash { private: - detail::seed_pair m_seeds{detail::make_seed_pair<>()}; + detail::seed_pair seeds_{detail::makeSeedPair<>()}; public: using result_type = typename HashAlgorithm::result_type; - hardened_hash() = default; + HardenedHash() = default; template result_type operator()(T const& t) const noexcept { - HashAlgorithm h(m_seeds.first, m_seeds.second); + HashAlgorithm h(seeds_.first, seeds_.second); hash_append(h, t); return static_cast(h); } diff --git a/include/xrpl/basics/make_SSLContext.h b/include/xrpl/basics/make_SSLContext.h index 1714d3e58c..46f6a15e84 100644 --- a/include/xrpl/basics/make_SSLContext.h +++ b/include/xrpl/basics/make_SSLContext.h @@ -8,11 +8,11 @@ namespace xrpl { /** Create a self-signed SSL context that allows anonymous Diffie Hellman. */ std::shared_ptr -make_SSLContext(std::string const& cipherList); +makeSslContext(std::string const& cipherList); /** Create an authenticated SSL context using the specified files. */ std::shared_ptr -make_SSLContextAuthed( +makeSslContextAuthed( std::string const& keyFile, std::string const& certFile, std::string const& chainFile, diff --git a/include/xrpl/basics/mulDiv.h b/include/xrpl/basics/mulDiv.h index 2495f07728..8a9bc4f5dc 100644 --- a/include/xrpl/basics/mulDiv.h +++ b/include/xrpl/basics/mulDiv.h @@ -5,7 +5,7 @@ #include namespace xrpl { -auto constexpr muldiv_max = std::numeric_limits::max(); +auto constexpr kMULDIV_MAX = std::numeric_limits::max(); /** Return value*mul/div accurately. Computes the result of the multiplication and division in diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index 33fe63e91b..5f32cca8af 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -24,7 +24,7 @@ template <> inline std::size_t extract(std::string const& key) { - return ::beast::uhash<>{}(key); + return ::beast::Uhash<>{}(key); } template < @@ -33,7 +33,7 @@ template < typename Hash, typename Pred = std::equal_to, typename Alloc = std::allocator>> -class partitioned_unordered_map +class PartitionedUnorderedMap { std::size_t partitions_; @@ -53,46 +53,46 @@ public: using map_type = std::unordered_map; using partition_map_type = std::vector; - struct iterator + struct Iterator { using iterator_category = std::forward_iterator_tag; - partition_map_type* map_{nullptr}; - typename partition_map_type::iterator ait_{}; - typename map_type::iterator mit_; + partition_map_type* map{nullptr}; + typename partition_map_type::iterator ait{}; + typename map_type::iterator mit; - iterator() = default; + Iterator() = default; - iterator(partition_map_type* map) : map_(map) + Iterator(partition_map_type* m) : map(m) { } reference operator*() const { - return *mit_; + return *mit; } pointer operator->() const { - return &(*mit_); + return &(*mit); } void inc() { - ++mit_; - while (mit_ == ait_->end()) + ++mit; + while (mit == ait->end()) { - ++ait_; - if (ait_ == map_->end()) + ++ait; + if (ait == map->end()) return; - mit_ = ait_->begin(); + mit = ait->begin(); } } // ++it - iterator& + Iterator& operator++() { inc(); @@ -100,75 +100,75 @@ public: } // it++ - iterator + Iterator operator++(int) { - iterator tmp(*this); + Iterator tmp(*this); inc(); return tmp; } friend bool - operator==(iterator const& lhs, iterator const& rhs) + operator==(Iterator const& lhs, Iterator const& rhs) { - return lhs.map_ == rhs.map_ && lhs.ait_ == rhs.ait_ && lhs.mit_ == rhs.mit_; + return lhs.map == rhs.map && lhs.ait == rhs.ait && lhs.mit == rhs.mit; } friend bool - operator!=(iterator const& lhs, iterator const& rhs) + operator!=(Iterator const& lhs, Iterator const& rhs) { return !(lhs == rhs); } }; - struct const_iterator + struct ConstIterator { using iterator_category = std::forward_iterator_tag; - partition_map_type* map_{nullptr}; - typename partition_map_type::iterator ait_{}; - typename map_type::iterator mit_; + partition_map_type* map{nullptr}; + typename partition_map_type::iterator ait{}; + typename map_type::iterator mit; - const_iterator() = default; + ConstIterator() = default; - const_iterator(partition_map_type* map) : map_(map) + ConstIterator(partition_map_type* m) : map(m) { } - const_iterator(iterator const& orig) + ConstIterator(Iterator const& orig) { - map_ = orig.map_; - ait_ = orig.ait_; - mit_ = orig.mit_; + map = orig.map; + ait = orig.ait; + mit = orig.mit; } const_reference operator*() const { - return *mit_; + return *mit; } const_pointer operator->() const { - return &(*mit_); + return &(*mit); } void inc() { - ++mit_; - while (mit_ == ait_->end()) + ++mit; + while (mit == ait->end()) { - ++ait_; - if (ait_ == map_->end()) + ++ait; + if (ait == map->end()) return; - mit_ = ait_->begin(); + mit = ait->begin(); } } // ++it - const_iterator& + ConstIterator& operator++() { inc(); @@ -176,22 +176,22 @@ public: } // it++ - const_iterator + ConstIterator operator++(int) { - const_iterator tmp(*this); + ConstIterator tmp(*this); inc(); return tmp; } friend bool - operator==(const_iterator const& lhs, const_iterator const& rhs) + operator==(ConstIterator const& lhs, ConstIterator const& rhs) { - return lhs.map_ == rhs.map_ && lhs.ait_ == rhs.ait_ && lhs.mit_ == rhs.mit_; + return lhs.map == rhs.map && lhs.ait == rhs.ait && lhs.mit == rhs.mit; } friend bool - operator!=(const_iterator const& lhs, const_iterator const& rhs) + operator!=(ConstIterator const& lhs, ConstIterator const& rhs) { return !(lhs == rhs); } @@ -208,26 +208,26 @@ private: static void end(T& it) { - it.ait_ = it.map_->end(); - it.mit_ = it.map_->back().end(); + it.ait = it.map->end(); + it.mit = it.map->back().end(); } template static void begin(T& it) { - for (it.ait_ = it.map_->begin(); it.ait_ != it.map_->end(); ++it.ait_) + for (it.ait = it.map->begin(); it.ait != it.map->end(); ++it.ait) { - if (it.ait_->begin() == it.ait_->end()) + if (it.ait->begin() == it.ait->end()) continue; - it.mit_ = it.ait_->begin(); + it.mit = it.ait->begin(); return; } end(it); } public: - partitioned_unordered_map(std::optional partitions = std::nullopt) + PartitionedUnorderedMap(std::optional partitions = std::nullopt) { // Set partitions to the number of hardware threads if the parameter // is either empty or set to 0. @@ -252,45 +252,45 @@ public: return map_; } - iterator + Iterator begin() { - iterator it(&map_); + Iterator it(&map_); begin(it); return it; } - const_iterator + ConstIterator cbegin() const { - const_iterator it(&map_); + ConstIterator it(&map_); begin(it); return it; } - const_iterator + ConstIterator begin() const { return cbegin(); } - iterator + Iterator end() { - iterator it(&map_); + Iterator it(&map_); end(it); return it; } - const_iterator + ConstIterator cend() const { - const_iterator it(&map_); + ConstIterator it(&map_); end(it); return it; } - const_iterator + ConstIterator end() const { return cend(); @@ -301,50 +301,50 @@ private: void find(key_type const& key, T& it) const { - it.ait_ = it.map_->begin() + partitioner(key); - it.mit_ = it.ait_->find(key); - if (it.mit_ == it.ait_->end()) + it.ait = it.map->begin() + partitioner(key); + it.mit = it.ait->find(key); + if (it.mit == it.ait->end()) end(it); } public: - iterator + Iterator find(key_type const& key) { - iterator it(&map_); + Iterator it(&map_); find(key, it); return it; } - const_iterator + ConstIterator find(key_type const& key) const { - const_iterator it(&map_); + ConstIterator it(&map_); find(key, it); return it; } template - std::pair + std::pair emplace(std::piecewise_construct_t const&, T&& keyTuple, U&& valueTuple) { auto const& key = std::get<0>(keyTuple); - iterator it(&map_); - it.ait_ = it.map_->begin() + partitioner(key); - auto [eit, inserted] = it.ait_->emplace( + Iterator it(&map_); + it.ait = it.map->begin() + partitioner(key); + auto [eit, inserted] = it.ait->emplace( std::piecewise_construct, std::forward(keyTuple), std::forward(valueTuple)); - it.mit_ = eit; + it.mit = eit; return {it, inserted}; } template - std::pair + std::pair emplace(T&& key, U&& val) { - iterator it(&map_); - it.ait_ = it.map_->begin() + partitioner(key); - auto [eit, inserted] = it.ait_->emplace(std::forward(key), std::forward(val)); - it.mit_ = eit; + Iterator it(&map_); + it.ait = it.map->begin() + partitioner(key); + auto [eit, inserted] = it.ait->emplace(std::forward(key), std::forward(val)); + it.mit = eit; return {it, inserted}; } @@ -355,19 +355,19 @@ public: p.clear(); } - iterator - erase(const_iterator position) + Iterator + erase(ConstIterator position) { - iterator it(&map_); - it.ait_ = position.ait_; - it.mit_ = position.ait_->erase(position.mit_); + Iterator it(&map_); + it.ait = position.ait; + it.mit = position.ait->erase(position.mit); - while (it.mit_ == it.ait_->end()) + while (it.mit == it.ait->end()) { - ++it.ait_; - if (it.ait_ == it.map_->end()) + ++it.ait; + if (it.ait == it.map->end()) break; - it.mit_ = it.ait_->begin(); + it.mit = it.ait->begin(); } return it; diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index a4018b7e5f..ca51ef9364 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -44,30 +44,30 @@ using is_engine = std::is_invocable_r; will be randomly seeded. */ inline beast::xor_shift_engine& -default_prng() +defaultPrng() { // This is used to seed the thread-specific PRNGs on demand - static beast::xor_shift_engine seeder = [] { + static beast::xor_shift_engine kSEEDER = [] { std::random_device rng; std::uniform_int_distribution distribution{1}; return beast::xor_shift_engine(distribution(rng)); }(); // This protects the seeder - static std::mutex m; + static std::mutex kM; // The thread-specific PRNGs: - thread_local beast::xor_shift_engine engine = [] { + thread_local beast::xor_shift_engine kENGINE = [] { std::uint64_t seed = 0; { - std::scoped_lock const lk(m); + std::scoped_lock const lk(kM); std::uniform_int_distribution distribution{1}; - seed = distribution(seeder); + seed = distribution(kSEEDER); } return beast::xor_shift_engine{seed}; }(); - return engine; + return kENGINE; } /** Return a uniformly distributed random integer. @@ -92,7 +92,7 @@ default_prng() /** @{ */ template std::enable_if_t && detail::is_engine::value, Integral> -rand_int(Engine& engine, Integral min, Integral max) +randInt(Engine& engine, Integral min, Integral max) { XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs"); @@ -104,37 +104,37 @@ rand_int(Engine& engine, Integral min, Integral max) template std::enable_if_t, Integral> -rand_int(Integral min, Integral max) +randInt(Integral min, Integral max) { - return rand_int(default_prng(), min, max); + return randInt(defaultPrng(), min, max); } template std::enable_if_t && detail::is_engine::value, Integral> -rand_int(Engine& engine, Integral max) +randInt(Engine& engine, Integral max) { - return rand_int(engine, Integral(0), max); + return randInt(engine, Integral(0), max); } template std::enable_if_t, Integral> -rand_int(Integral max) +randInt(Integral max) { - return rand_int(default_prng(), max); + return randInt(defaultPrng(), max); } template std::enable_if_t && detail::is_engine::value, Integral> -rand_int(Engine& engine) +randInt(Engine& engine) { - return rand_int(engine, std::numeric_limits::max()); + return randInt(engine, std::numeric_limits::max()); } template std::enable_if_t, Integral> -rand_int() +randInt() { - return rand_int(default_prng(), std::numeric_limits::max()); + return randInt(defaultPrng(), std::numeric_limits::max()); } /** @} */ @@ -145,17 +145,17 @@ std::enable_if_t< (std::is_same_v || std::is_same_v) && detail::is_engine::value, Byte> -rand_byte(Engine& engine) +randByte(Engine& engine) { - return static_cast(rand_int( + return static_cast(randInt( engine, std::numeric_limits::min(), std::numeric_limits::max())); } template std::enable_if_t<(std::is_same_v || std::is_same_v), Byte> -rand_byte() +randByte() { - return rand_byte(default_prng()); + return randByte(defaultPrng()); } /** @} */ @@ -163,15 +163,15 @@ rand_byte() /** @{ */ template inline bool -rand_bool(Engine& engine) +randBool(Engine& engine) { - return rand_int(engine, 1) == 1; + return randInt(engine, 1) == 1; } inline bool -rand_bool() +randBool() { - return rand_bool(default_prng()); + return randBool(defaultPrng()); } /** @} */ diff --git a/include/xrpl/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h index c167e660ce..b9a7aa1fa0 100644 --- a/include/xrpl/basics/safe_cast.h +++ b/include/xrpl/basics/safe_cast.h @@ -18,29 +18,29 @@ concept SafeToCast = (std::is_integral_v && std::is_integral_v) && template constexpr std::enable_if_t && std::is_integral_v, Dest> -safe_cast(Src s) noexcept +safeCast(Src s) noexcept { static_assert( std::is_signed_v || std::is_unsigned_v, "Cannot cast signed to unsigned"); - constexpr unsigned not_same = std::is_signed_v != std::is_signed_v; + constexpr unsigned kNOT_SAME = std::is_signed_v != std::is_signed_v; static_assert( - sizeof(Dest) >= sizeof(Src) + not_same, + sizeof(Dest) >= sizeof(Src) + kNOT_SAME, "Destination is too small to hold all values of source"); return static_cast(s); } template constexpr std::enable_if_t && std::is_integral_v, Dest> -safe_cast(Src s) noexcept +safeCast(Src s) noexcept { - return static_cast(safe_cast>(s)); + return static_cast(safeCast>(s)); } template constexpr std::enable_if_t && std::is_enum_v, Dest> -safe_cast(Src s) noexcept +safeCast(Src s) noexcept { - return safe_cast(static_cast>(s)); + return safeCast(static_cast>(s)); } // unsafe_cast explicitly flags a static_cast as not necessarily able to hold @@ -49,7 +49,7 @@ safe_cast(Src s) noexcept template constexpr std::enable_if_t && std::is_integral_v, Dest> -unsafe_cast(Src s) noexcept +unsafeCast(Src s) noexcept { static_assert( !SafeToCast, @@ -60,22 +60,22 @@ unsafe_cast(Src s) noexcept template constexpr std::enable_if_t && std::is_integral_v, Dest> -unsafe_cast(Src s) noexcept +unsafeCast(Src s) noexcept { - return static_cast(unsafe_cast>(s)); + return static_cast(unsafeCast>(s)); } template constexpr std::enable_if_t && std::is_enum_v, Dest> -unsafe_cast(Src s) noexcept +unsafeCast(Src s) noexcept { - return unsafe_cast(static_cast>(s)); + return unsafeCast(static_cast>(s)); } template requires std::is_pointer_v inline Dest -safe_downcast(Src* s) noexcept +safeDowncast(Src* s) noexcept { #ifdef NDEBUG return static_cast(s); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) @@ -89,7 +89,7 @@ safe_downcast(Src* s) noexcept template requires std::is_lvalue_reference_v inline Dest -safe_downcast(Src& s) noexcept +safeDowncast(Src& s) noexcept { #ifndef NDEBUG XRPL_ASSERT( diff --git a/include/xrpl/basics/scope.h b/include/xrpl/basics/scope.h index 1d5524ba35..64f91727fa 100644 --- a/include/xrpl/basics/scope.h +++ b/include/xrpl/basics/scope.h @@ -22,19 +22,19 @@ namespace xrpl { // to enforce this restriction. template -class scope_exit +class ScopeExit { EF exit_function_; bool execute_on_destruction_{true}; public: - ~scope_exit() + ~ScopeExit() { if (execute_on_destruction_) exit_function_(); } - scope_exit(scope_exit&& rhs) noexcept( + ScopeExit(ScopeExit&& rhs) noexcept( std::is_nothrow_move_constructible_v || std::is_nothrow_copy_constructible_v) : exit_function_{std::forward(rhs.exit_function_)} , execute_on_destruction_{rhs.execute_on_destruction_} @@ -42,14 +42,14 @@ public: rhs.release(); } - scope_exit& - operator=(scope_exit&&) = delete; + ScopeExit& + operator=(ScopeExit&&) = delete; template - explicit scope_exit( + explicit ScopeExit( EFP&& f, std::enable_if_t< - !std::is_same_v, scope_exit> && + !std::is_same_v, ScopeExit> && std::is_constructible_v>* = 0) noexcept : exit_function_{std::forward(f)} { @@ -64,23 +64,23 @@ public: }; template -scope_exit(EF) -> scope_exit; +ScopeExit(EF) -> ScopeExit; template -class scope_fail +class ScopeFail { EF exit_function_; bool execute_on_destruction_{true}; int uncaught_on_creation_{std::uncaught_exceptions()}; public: - ~scope_fail() + ~ScopeFail() { if (execute_on_destruction_ && std::uncaught_exceptions() > uncaught_on_creation_) exit_function_(); } - scope_fail(scope_fail&& rhs) noexcept( + ScopeFail(ScopeFail&& rhs) noexcept( std::is_nothrow_move_constructible_v || std::is_nothrow_copy_constructible_v) : exit_function_{std::forward(rhs.exit_function_)} , execute_on_destruction_{rhs.execute_on_destruction_} @@ -89,14 +89,14 @@ public: rhs.release(); } - scope_fail& - operator=(scope_fail&&) = delete; + ScopeFail& + operator=(ScopeFail&&) = delete; template - explicit scope_fail( + explicit ScopeFail( EFP&& f, std::enable_if_t< - !std::is_same_v, scope_fail> && + !std::is_same_v, ScopeFail> && std::is_constructible_v>* = 0) noexcept : exit_function_{std::forward(f)} { @@ -111,23 +111,23 @@ public: }; template -scope_fail(EF) -> scope_fail; +ScopeFail(EF) -> ScopeFail; template -class scope_success +class ScopeSuccess { EF exit_function_; bool execute_on_destruction_{true}; int uncaught_on_creation_{std::uncaught_exceptions()}; public: - ~scope_success() noexcept(noexcept(exit_function_())) + ~ScopeSuccess() noexcept(noexcept(exit_function_())) { if (execute_on_destruction_ && std::uncaught_exceptions() <= uncaught_on_creation_) exit_function_(); } - scope_success(scope_success&& rhs) noexcept( + ScopeSuccess(ScopeSuccess&& rhs) noexcept( std::is_nothrow_move_constructible_v || std::is_nothrow_copy_constructible_v) : exit_function_{std::forward(rhs.exit_function_)} , execute_on_destruction_{rhs.execute_on_destruction_} @@ -136,14 +136,14 @@ public: rhs.release(); } - scope_success& - operator=(scope_success&&) = delete; + ScopeSuccess& + operator=(ScopeSuccess&&) = delete; template - explicit scope_success( + explicit ScopeSuccess( EFP&& f, std::enable_if_t< - !std::is_same_v, scope_success> && + !std::is_same_v, ScopeSuccess> && std::is_constructible_v>* = 0) noexcept(std::is_nothrow_constructible_v || std::is_nothrow_constructible_v) : exit_function_{std::forward(f)} @@ -158,7 +158,7 @@ public: }; template -scope_success(EF) -> scope_success; +ScopeSuccess(EF) -> ScopeSuccess; /** Automatically unlocks and re-locks a unique_lock object. @@ -198,29 +198,29 @@ scope_success(EF) -> scope_success; */ template -class scope_unlock +class ScopeUnlock { - std::unique_lock* plock; + std::unique_lock* plock_; public: - explicit scope_unlock(std::unique_lock& lock) noexcept(true) : plock(&lock) + explicit ScopeUnlock(std::unique_lock& lock) noexcept(true) : plock_(&lock) { - XRPL_ASSERT(plock->owns_lock(), "xrpl::scope_unlock::scope_unlock : mutex must be locked"); - plock->unlock(); + XRPL_ASSERT(plock_->owns_lock(), "xrpl::scope_unlock::scope_unlock : mutex must be locked"); + plock_->unlock(); } // Immovable type - scope_unlock(scope_unlock const&) = delete; - scope_unlock& - operator=(scope_unlock const&) = delete; + ScopeUnlock(ScopeUnlock const&) = delete; + ScopeUnlock& + operator=(ScopeUnlock const&) = delete; - ~scope_unlock() noexcept(true) + ~ScopeUnlock() noexcept(true) { - plock->lock(); + plock_->lock(); } }; template -scope_unlock(std::unique_lock&) -> scope_unlock; +ScopeUnlock(std::unique_lock&) -> ScopeUnlock; } // namespace xrpl diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index eb60e85962..3518b94680 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -26,7 +26,7 @@ namespace detail { specific amount of time, to prevent this. */ inline void -spin_pause() noexcept +spinPause() noexcept { #ifdef __aarch64__ asm volatile("yield"); @@ -71,7 +71,7 @@ spin_pause() noexcept https://en.cppreference.com/w/cpp/named_req/Lockable */ template -class packed_spinlock +class PackedSpinlock { // clang-format off static_assert(std::is_unsigned_v); @@ -87,9 +87,9 @@ private: T const mask_; public: - packed_spinlock(packed_spinlock const&) = delete; - packed_spinlock& - operator=(packed_spinlock const&) = delete; + PackedSpinlock(PackedSpinlock const&) = delete; + PackedSpinlock& + operator=(PackedSpinlock const&) = delete; /** A single spinlock packed inside the specified atomic @@ -99,8 +99,7 @@ public: @note For performance reasons, you should strive to have `lock` be on a cacheline by itself. */ - packed_spinlock(std::atomic& lock, int index) - : bits_(lock), mask_(static_cast(1) << index) + PackedSpinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { XRPL_ASSERT( index >= 0 && (mask_ != 0), @@ -108,7 +107,7 @@ public: } [[nodiscard]] bool - try_lock() + try_lock() // NOLINT(readability-identifier-naming) { return (bits_.fetch_or(mask_, std::memory_order_acquire) & mask_) == 0; } @@ -123,7 +122,7 @@ public: // of contention by avoiding writes that would definitely not // result in the lock being acquired. while ((bits_.load(std::memory_order_relaxed) & mask_) != 0) - detail::spin_pause(); + detail::spinPause(); } } @@ -147,7 +146,7 @@ public: https://en.cppreference.com/w/cpp/named_req/Lockable */ template -class spinlock +class Spinlock { static_assert(std::is_unsigned_v); static_assert(std::atomic::is_always_lock_free); @@ -156,9 +155,9 @@ private: std::atomic& lock_; public: - spinlock(spinlock const&) = delete; - spinlock& - operator=(spinlock const&) = delete; + Spinlock(Spinlock const&) = delete; + Spinlock& + operator=(Spinlock const&) = delete; /** Grabs the @@ -167,12 +166,12 @@ public: @note For performance reasons, you should strive to have `lock` be on a cacheline by itself. */ - spinlock(std::atomic& lock) : lock_(lock) + Spinlock(std::atomic& lock) : lock_(lock) { } [[nodiscard]] bool - try_lock() + try_lock() // NOLINT(readability-identifier-naming) { T expected = 0; @@ -193,7 +192,7 @@ public: // of contention by avoiding writes that would definitely not // result in the lock being acquired. while (lock_.load(std::memory_order_relaxed) != 0) - detail::spin_pause(); + detail::spinPause(); } } diff --git a/include/xrpl/basics/tagged_integer.h b/include/xrpl/basics/tagged_integer.h index 129c586126..ddcde479f3 100644 --- a/include/xrpl/basics/tagged_integer.h +++ b/include/xrpl/basics/tagged_integer.h @@ -23,171 +23,171 @@ namespace xrpl { allowed arithmetic operations. */ template -class tagged_integer : boost::totally_ordered< - tagged_integer, - boost::integer_arithmetic< - tagged_integer, - boost::bitwise< - tagged_integer, - boost::unit_steppable< - tagged_integer, - boost::shiftable>>>>> +class TaggedInteger : boost::totally_ordered< + TaggedInteger, + boost::integer_arithmetic< + TaggedInteger, + boost::bitwise< + TaggedInteger, + boost::unit_steppable< + TaggedInteger, + boost::shiftable>>>>> { private: - Int m_value; + Int value_; public: using value_type = Int; using tag_type = Tag; - tagged_integer() = default; + TaggedInteger() = default; template < class OtherInt, class = std::enable_if_t && sizeof(OtherInt) <= sizeof(Int)>> - explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value) + explicit constexpr TaggedInteger(OtherInt value) noexcept : value_(value) { - static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding"); + static_assert(sizeof(TaggedInteger) == sizeof(Int), "tagged_integer is adding padding"); } bool - operator<(tagged_integer const& rhs) const noexcept + operator<(TaggedInteger const& rhs) const noexcept { - return m_value < rhs.m_value; + return value_ < rhs.value_; } bool - operator==(tagged_integer const& rhs) const noexcept + operator==(TaggedInteger const& rhs) const noexcept { - return m_value == rhs.m_value; + return value_ == rhs.value_; } - tagged_integer& - operator+=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator+=(TaggedInteger const& rhs) noexcept { - m_value += rhs.m_value; + value_ += rhs.value_; return *this; } - tagged_integer& - operator-=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator-=(TaggedInteger const& rhs) noexcept { - m_value -= rhs.m_value; + value_ -= rhs.value_; return *this; } - tagged_integer& - operator*=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator*=(TaggedInteger const& rhs) noexcept { - m_value *= rhs.m_value; + value_ *= rhs.value_; return *this; } - tagged_integer& - operator/=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator/=(TaggedInteger const& rhs) noexcept { - m_value /= rhs.m_value; + value_ /= rhs.value_; return *this; } - tagged_integer& - operator%=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator%=(TaggedInteger const& rhs) noexcept { - m_value %= rhs.m_value; + value_ %= rhs.value_; return *this; } - tagged_integer& - operator|=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator|=(TaggedInteger const& rhs) noexcept { - m_value |= rhs.m_value; + value_ |= rhs.value_; return *this; } - tagged_integer& - operator&=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator&=(TaggedInteger const& rhs) noexcept { - m_value &= rhs.m_value; + value_ &= rhs.value_; return *this; } - tagged_integer& - operator^=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator^=(TaggedInteger const& rhs) noexcept { - m_value ^= rhs.m_value; + value_ ^= rhs.value_; return *this; } - tagged_integer& - operator<<=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator<<=(TaggedInteger const& rhs) noexcept { - m_value <<= rhs.m_value; + value_ <<= rhs.value_; return *this; } - tagged_integer& - operator>>=(tagged_integer const& rhs) noexcept + TaggedInteger& + operator>>=(TaggedInteger const& rhs) noexcept { - m_value >>= rhs.m_value; + value_ >>= rhs.value_; return *this; } - tagged_integer + TaggedInteger operator~() const noexcept { - return tagged_integer{~m_value}; + return TaggedInteger{~value_}; } - tagged_integer + TaggedInteger operator+() const noexcept { return *this; } - tagged_integer + TaggedInteger operator-() const noexcept { - return tagged_integer{-m_value}; + return TaggedInteger{-value_}; } - tagged_integer& + TaggedInteger& operator++() noexcept { - ++m_value; + ++value_; return *this; } - tagged_integer& + TaggedInteger& operator--() noexcept { - --m_value; + --value_; return *this; } explicit operator Int() const noexcept { - return m_value; + return value_; } friend std::ostream& - operator<<(std::ostream& s, tagged_integer const& t) + operator<<(std::ostream& s, TaggedInteger const& t) { - s << t.m_value; + s << t.value_; return s; } friend std::istream& - operator>>(std::istream& s, tagged_integer& t) + operator>>(std::istream& s, TaggedInteger& t) { - s >> t.m_value; + s >> t.value_; return s; } friend std::string - to_string(tagged_integer const& t) + to_string(TaggedInteger const& t) { - return std::to_string(t.m_value); + return std::to_string(t.value_); } }; @@ -195,10 +195,10 @@ public: namespace beast { template -struct is_contiguously_hashable, HashAlgorithm> - : public is_contiguously_hashable +struct IsContiguouslyHashable, HashAlgorithm> + : public IsContiguouslyHashable { - explicit is_contiguously_hashable() = default; + explicit IsContiguouslyHashable() = default; }; } // namespace beast diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index f85f399196..4ba985e579 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -15,44 +15,44 @@ namespace beast { /** Measures handler latency on an io_context queue. */ template -class io_latency_probe +class IoLatencyProbe { private: using duration = typename Clock::duration; using time_point = typename Clock::time_point; - std::recursive_mutex m_mutex; - std::condition_variable_any m_cond; - std::size_t m_count{1}; - duration const m_period; - boost::asio::io_context& m_ios; - boost::asio::basic_waitable_timer m_timer; - bool m_cancel{false}; + std::recursive_mutex mutex_; + std::condition_variable_any cond_; + std::size_t count_{1}; + duration const period_; + boost::asio::io_context& ios_; + boost::asio::basic_waitable_timer timer_; + bool cancel_{false}; public: - io_latency_probe(duration const& period, boost::asio::io_context& ios) - : m_period(period), m_ios(ios), m_timer(m_ios) + IoLatencyProbe(duration const& period, boost::asio::io_context& ios) + : period_(period), ios_(ios), timer_(ios_) { } - ~io_latency_probe() + ~IoLatencyProbe() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(mutex_); cancel(lock, true); } /** Return the io_context associated with the latency probe. */ /** @{ */ boost::asio::io_context& - get_io_context() + getIoContext() { - return m_ios; + return ios_; } [[nodiscard]] boost::asio::io_context const& - get_io_context() const + getIoContext() const { - return m_ios; + return ios_; } /** @} */ @@ -63,14 +63,14 @@ public: void cancel() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(mutex_); cancel(lock, true); } void - cancel_async() + cancelAsync() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(mutex_); cancel(lock, false); } /** @} */ @@ -81,13 +81,13 @@ public: */ template void - sample_one(Handler&& handler) + sampleOne(Handler&& handler) { - std::scoped_lock const lock(m_mutex); - if (m_cancel) + std::scoped_lock const lock(mutex_); + if (cancel_) throw std::logic_error("io_latency_probe is canceled"); boost::asio::post( - m_ios, sample_op(std::forward(handler), Clock::now(), false, this)); + ios_, SampleOp(std::forward(handler), Clock::now(), false, this)); } /** Initiate continuous i/o latency sampling. @@ -98,125 +98,123 @@ public: void sample(Handler&& handler) { - std::scoped_lock const lock(m_mutex); - if (m_cancel) + std::scoped_lock const lock(mutex_); + if (cancel_) throw std::logic_error("io_latency_probe is canceled"); boost::asio::post( - m_ios, sample_op(std::forward(handler), Clock::now(), true, this)); + ios_, SampleOp(std::forward(handler), Clock::now(), true, this)); } private: void - cancel(std::unique_lock& lock, bool wait) + cancel(std::unique_lock& lock, bool wait) { - if (!m_cancel) + if (!cancel_) { - --m_count; - m_cancel = true; + --count_; + cancel_ = true; } if (wait) - m_cond.wait(lock, [this] { return this->m_count == 0; }); + cond_.wait(lock, [this] { return this->count_ == 0; }); } void addref() { - std::scoped_lock const lock(m_mutex); - ++m_count; + std::scoped_lock const lock(mutex_); + ++count_; } void release() { - std::scoped_lock const lock(m_mutex); - if (--m_count == 0) - m_cond.notify_all(); + std::scoped_lock const lock(mutex_); + if (--count_ == 0) + cond_.notify_all(); } template - struct sample_op + struct SampleOp { - Handler m_handler; - time_point m_start; - bool m_repeat; - io_latency_probe* m_probe; + Handler handler; + time_point start; + bool repeat; + IoLatencyProbe* probe; - sample_op( + SampleOp( Handler const& handler, time_point const& start, bool repeat, - io_latency_probe* probe) - : m_handler(handler), m_start(start), m_repeat(repeat), m_probe(probe) + IoLatencyProbe* probe) + : handler(handler), start(start), repeat(repeat), probe(probe) { XRPL_ASSERT( - m_probe, + probe, "beast::io_latency_probe::sample_op::sample_op : non-null " "probe input"); - m_probe->addref(); + probe->addref(); } - sample_op(sample_op&& from) noexcept - : m_handler(std::move(from.m_handler)) - , m_start(from.m_start) - , m_repeat(from.m_repeat) - , m_probe(from.m_probe) + SampleOp(SampleOp&& from) noexcept + : handler(std::move(from.handler)) + , start(from.start) + , repeat(from.repeat) + , probe(from.probe) { XRPL_ASSERT( - m_probe, + probe, "beast::io_latency_probe::sample_op::sample_op(sample_op&&) : " "non-null probe input"); - from.m_probe = nullptr; + from.probe = nullptr; } - sample_op(sample_op const&) = delete; - sample_op - operator=(sample_op const&) = delete; - sample_op& - operator=(sample_op&&) = delete; + SampleOp(SampleOp const&) = delete; + SampleOp + operator=(SampleOp const&) = delete; + SampleOp& + operator=(SampleOp&&) = delete; - ~sample_op() + ~SampleOp() { - if (m_probe) - m_probe->release(); + if (probe) + probe->release(); } void operator()() const { - if (m_probe == nullptr) + if (probe == nullptr) return; typename Clock::time_point const now(Clock::now()); - typename Clock::duration const elapsed(now - m_start); + typename Clock::duration const elapsed(now - start); - m_handler(elapsed); + handler(elapsed); { - std::scoped_lock const lock(m_probe->m_mutex); - if (m_probe->m_cancel) + std::scoped_lock const lock(probe->mutex_); + if (probe->cancel_) return; } - if (m_repeat) + if (repeat) { // Calculate when we want to sample again, and // adjust for the expected latency. // - typename Clock::time_point const when(now + m_probe->m_period - (2 * elapsed)); + typename Clock::time_point const when(now + probe->period_ - (2 * elapsed)); if (when <= now) { // The latency is too high to maintain the desired // period so don't bother with a timer. // - boost::asio::post( - m_probe->m_ios, sample_op(m_handler, now, m_repeat, m_probe)); + boost::asio::post(probe->ios_, SampleOp(handler, now, repeat, probe)); } else { - m_probe->m_timer.expires_after(when - now); - m_probe->m_timer.async_wait( - sample_op(m_handler, now, m_repeat, m_probe)); + probe->timer_.expires_after(when - now); + probe->timer_.async_wait(SampleOp(handler, now, repeat, probe)); } } } @@ -224,11 +222,10 @@ private: void operator()(boost::system::error_code const& ec) { - if (m_probe == nullptr) + if (probe == nullptr) return; typename Clock::time_point const now(Clock::now()); - boost::asio::post( - m_probe->m_ios, sample_op(m_handler, now, m_repeat, m_probe)); + boost::asio::post(probe->ios_, SampleOp(handler, now, repeat, probe)); } }; }; diff --git a/include/xrpl/beast/clock/abstract_clock.h b/include/xrpl/beast/clock/abstract_clock.h index 09de3f891d..67320ceabc 100644 --- a/include/xrpl/beast/clock/abstract_clock.h +++ b/include/xrpl/beast/clock/abstract_clock.h @@ -31,7 +31,7 @@ namespace beast { http://en.cppreference.com/w/cpp/concept/Clock */ template -class abstract_clock +class AbstractClock { public: using rep = typename Clock::rep; @@ -40,11 +40,11 @@ public: using time_point = typename Clock::time_point; using clock_type = Clock; - static bool const is_steady = Clock::is_steady; + static bool const is_steady = Clock::is_steady; // NOLINT(readability-identifier-naming) - virtual ~abstract_clock() = default; - abstract_clock() = default; - abstract_clock(abstract_clock const&) = default; + virtual ~AbstractClock() = default; + AbstractClock() = default; + AbstractClock(AbstractClock const&) = default; /** Returns the current time. */ [[nodiscard]] virtual time_point @@ -56,12 +56,12 @@ public: namespace detail { template -struct abstract_clock_wrapper : public abstract_clock +struct AbstractClockWrapper : public AbstractClock { - explicit abstract_clock_wrapper() = default; + explicit AbstractClockWrapper() = default; - using typename abstract_clock::duration; - using typename abstract_clock::time_point; + using typename AbstractClock::duration; + using typename AbstractClock::time_point; [[nodiscard]] time_point now() const override @@ -80,11 +80,11 @@ struct abstract_clock_wrapper : public abstract_clock @tparam Clock The actual concrete clock to use. */ template -abstract_clock& -get_abstract_clock() +AbstractClock& +getAbstractClock() { - static detail::abstract_clock_wrapper clock; - return clock; + static detail::AbstractClockWrapper kCLOCK; + return kCLOCK; } } // namespace beast diff --git a/include/xrpl/beast/clock/basic_seconds_clock.h b/include/xrpl/beast/clock/basic_seconds_clock.h index 5205d92fef..8460dbe26b 100644 --- a/include/xrpl/beast/clock/basic_seconds_clock.h +++ b/include/xrpl/beast/clock/basic_seconds_clock.h @@ -13,19 +13,20 @@ namespace beast { @tparam Clock A type meeting these requirements: http://en.cppreference.com/w/cpp/concept/Clock */ -class basic_seconds_clock +class BasicSecondsClock { public: using Clock = std::chrono::steady_clock; - explicit basic_seconds_clock() = default; + explicit BasicSecondsClock() = default; using rep = typename Clock::rep; using period = typename Clock::period; using duration = typename Clock::duration; using time_point = typename Clock::time_point; - static bool const is_steady = Clock::is_steady; + static bool const is_steady = // NOLINT(readability-identifier-naming) + Clock::is_steady; static time_point now(); diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index 3cabdc0ea8..8b3e4e63c6 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -17,18 +17,18 @@ namespace beast { http://en.cppreference.com/w/cpp/concept/Clock */ template -class manual_clock : public abstract_clock +class ManualClock : public AbstractClock { public: - using typename abstract_clock::rep; - using typename abstract_clock::duration; - using typename abstract_clock::time_point; + using typename AbstractClock::rep; + using typename AbstractClock::duration; + using typename AbstractClock::time_point; private: time_point now_; public: - explicit manual_clock(time_point const& now = time_point(duration(0))) : now_(now) + explicit ManualClock(time_point const& now = time_point(duration(0))) : now_(now) { } @@ -44,16 +44,16 @@ public: { XRPL_ASSERT( !Clock::is_steady || when >= now_, - "beast::manual_clock::set(time_point) : forward input"); + "beast::ManualClock::set(time_point) : forward input"); now_ = when; } /** Convenience for setting the time in seconds from epoch. */ template void - set(Integer seconds_from_epoch) + set(Integer secondsFromEpoch) { - set(time_point(duration(std::chrono::seconds(seconds_from_epoch)))); + set(time_point(duration(std::chrono::seconds(secondsFromEpoch)))); } /** Advance the clock by a duration. */ @@ -63,12 +63,12 @@ public: { XRPL_ASSERT( !Clock::is_steady || (now_ + elapsed) >= now_, - "beast::manual_clock::advance(duration) : forward input"); + "beast::ManualClock::advance(duration) : forward input"); now_ += elapsed; } /** Convenience for advancing the clock by one second. */ - manual_clock& + ManualClock& operator++() { advance(std::chrono::seconds(1)); diff --git a/include/xrpl/beast/container/aged_container.h b/include/xrpl/beast/container/aged_container.h index dd622fcd9a..4b486440c9 100644 --- a/include/xrpl/beast/container/aged_container.h +++ b/include/xrpl/beast/container/aged_container.h @@ -5,9 +5,9 @@ namespace beast { template -struct is_aged_container : std::false_type +struct IsAgedContainer : std::false_type { - explicit is_aged_container() = default; + explicit IsAgedContainer() = default; }; } // namespace beast diff --git a/include/xrpl/beast/container/aged_container_utility.h b/include/xrpl/beast/container/aged_container_utility.h index 47aa8a5e66..879672e9cf 100644 --- a/include/xrpl/beast/container/aged_container_utility.h +++ b/include/xrpl/beast/container/aged_container_utility.h @@ -9,7 +9,7 @@ namespace beast { /** Expire aged container items past the specified age. */ template -std::enable_if_t::value, std::size_t> +std::enable_if_t::value, std::size_t> expire(AgedContainer& c, std::chrono::duration const& age) { std::size_t n(0); diff --git a/include/xrpl/beast/container/aged_map.h b/include/xrpl/beast/container/aged_map.h index 3815f44329..c1f6943451 100644 --- a/include/xrpl/beast/container/aged_map.h +++ b/include/xrpl/beast/container/aged_map.h @@ -14,6 +14,6 @@ template < class Clock = std::chrono::steady_clock, class Compare = std::less, class Allocator = std::allocator>> -using aged_map = detail::aged_ordered_container; +using aged_map = detail::AgedOrderedContainer; } // namespace beast diff --git a/include/xrpl/beast/container/aged_multimap.h b/include/xrpl/beast/container/aged_multimap.h index bb098b63b2..65efd1bbf9 100644 --- a/include/xrpl/beast/container/aged_multimap.h +++ b/include/xrpl/beast/container/aged_multimap.h @@ -14,6 +14,6 @@ template < class Clock = std::chrono::steady_clock, class Compare = std::less, class Allocator = std::allocator>> -using aged_multimap = detail::aged_ordered_container; +using aged_multimap = detail::AgedOrderedContainer; } // namespace beast diff --git a/include/xrpl/beast/container/aged_multiset.h b/include/xrpl/beast/container/aged_multiset.h index 60682db0ca..c31afb8c26 100644 --- a/include/xrpl/beast/container/aged_multiset.h +++ b/include/xrpl/beast/container/aged_multiset.h @@ -14,5 +14,6 @@ template < class Compare = std::less, class Allocator = std::allocator> using aged_multiset = - detail::aged_ordered_container; + detail::AgedOrderedContainer; + } // namespace beast diff --git a/include/xrpl/beast/container/aged_set.h b/include/xrpl/beast/container/aged_set.h index 76ff40b63a..280572be79 100644 --- a/include/xrpl/beast/container/aged_set.h +++ b/include/xrpl/beast/container/aged_set.h @@ -13,6 +13,6 @@ template < class Clock = std::chrono::steady_clock, class Compare = std::less, class Allocator = std::allocator> -using aged_set = detail::aged_ordered_container; +using aged_set = detail::AgedOrderedContainer; } // namespace beast diff --git a/include/xrpl/beast/container/aged_unordered_map.h b/include/xrpl/beast/container/aged_unordered_map.h index ea53320e91..a2189e2409 100644 --- a/include/xrpl/beast/container/aged_unordered_map.h +++ b/include/xrpl/beast/container/aged_unordered_map.h @@ -16,5 +16,6 @@ template < class KeyEqual = std::equal_to, class Allocator = std::allocator>> using aged_unordered_map = - detail::aged_unordered_container; + detail::AgedUnorderedContainer; + } // namespace beast diff --git a/include/xrpl/beast/container/aged_unordered_multimap.h b/include/xrpl/beast/container/aged_unordered_multimap.h index 9cb1443cad..f1348ed39f 100644 --- a/include/xrpl/beast/container/aged_unordered_multimap.h +++ b/include/xrpl/beast/container/aged_unordered_multimap.h @@ -16,5 +16,6 @@ template < class KeyEqual = std::equal_to, class Allocator = std::allocator>> using aged_unordered_multimap = - detail::aged_unordered_container; + detail::AgedUnorderedContainer; + } // namespace beast diff --git a/include/xrpl/beast/container/aged_unordered_multiset.h b/include/xrpl/beast/container/aged_unordered_multiset.h index ced01987aa..a178c62544 100644 --- a/include/xrpl/beast/container/aged_unordered_multiset.h +++ b/include/xrpl/beast/container/aged_unordered_multiset.h @@ -15,6 +15,6 @@ template < class KeyEqual = std::equal_to, class Allocator = std::allocator> using aged_unordered_multiset = - detail::aged_unordered_container; + detail::AgedUnorderedContainer; } // namespace beast diff --git a/include/xrpl/beast/container/aged_unordered_set.h b/include/xrpl/beast/container/aged_unordered_set.h index 3f4575f6bc..b37ec23e90 100644 --- a/include/xrpl/beast/container/aged_unordered_set.h +++ b/include/xrpl/beast/container/aged_unordered_set.h @@ -15,5 +15,6 @@ template < class KeyEqual = std::equal_to, class Allocator = std::allocator> using aged_unordered_set = - detail::aged_unordered_container; + detail::AgedUnorderedContainer; + } // namespace beast diff --git a/include/xrpl/beast/container/detail/aged_associative_container.h b/include/xrpl/beast/container/detail/aged_associative_container.h index 5d3534004c..54246c8e39 100644 --- a/include/xrpl/beast/container/detail/aged_associative_container.h +++ b/include/xrpl/beast/container/detail/aged_associative_container.h @@ -3,10 +3,10 @@ namespace beast::detail { // Extracts the key portion of value -template -struct aged_associative_container_extract_t +template +struct AgedAssociativeContainerExtractT { - explicit aged_associative_container_extract_t() = default; + explicit AgedAssociativeContainerExtractT() = default; template decltype(Value::first) const& @@ -17,9 +17,9 @@ struct aged_associative_container_extract_t }; template <> -struct aged_associative_container_extract_t +struct AgedAssociativeContainerExtractT { - explicit aged_associative_container_extract_t() = default; + explicit AgedAssociativeContainerExtractT() = default; template Value const& diff --git a/include/xrpl/beast/container/detail/aged_container_iterator.h b/include/xrpl/beast/container/detail/aged_container_iterator.h index ffa251b7a6..8d44646cd4 100644 --- a/include/xrpl/beast/container/detail/aged_container_iterator.h +++ b/include/xrpl/beast/container/detail/aged_container_iterator.h @@ -12,137 +12,136 @@ class aged_ordered_container; namespace detail { // If Iterator is SCARY then this iterator will be as well. -template -class aged_container_iterator +template +class AgedContainerIterator { public: using iterator_category = typename std::iterator_traits::iterator_category; using value_type = std::conditional_t< - is_const, - typename Iterator::value_type::stashed::value_type const, - typename Iterator::value_type::stashed::value_type>; + IsConst, + typename Iterator::value_type::Stashed::value_type const, + typename Iterator::value_type::Stashed::value_type>; using difference_type = typename std::iterator_traits::difference_type; using pointer = value_type*; using reference = value_type&; - using time_point = typename Iterator::value_type::stashed::time_point; + using time_point = typename Iterator::value_type::Stashed::time_point; - aged_container_iterator() = default; + AgedContainerIterator() = default; // Disable constructing a const_iterator from a non-const_iterator. // Converting between reverse and non-reverse iterators should be explicit. template < - bool other_is_const, + bool OtherIsConst, class OtherIterator, class = std::enable_if_t< - (!other_is_const || is_const) && + (!OtherIsConst || IsConst) && !static_cast(std::is_same_v)>> - explicit aged_container_iterator( - aged_container_iterator const& other) - : m_iter(other.m_iter) + explicit AgedContainerIterator(AgedContainerIterator const& other) + : iter_(other.iter_) { } // Disable constructing a const_iterator from a non-const_iterator. - template > - aged_container_iterator(aged_container_iterator const& other) - : m_iter(other.m_iter) + template > + AgedContainerIterator(AgedContainerIterator const& other) + : iter_(other.iter_) { } // Disable assigning a const_iterator to a non-const iterator - template + template auto - operator=(aged_container_iterator const& other) - -> std::enable_if_t + operator=(AgedContainerIterator const& other) + -> std::enable_if_t { - m_iter = other.m_iter; + iter_ = other.iter_; return *this; } - template + template bool - operator==(aged_container_iterator const& other) const + operator==(AgedContainerIterator const& other) const { - return m_iter == other.m_iter; + return iter_ == other.iter_; } - template + template bool - operator!=(aged_container_iterator const& other) const + operator!=(AgedContainerIterator const& other) const { - return m_iter != other.m_iter; + return iter_ != other.iter_; } - aged_container_iterator& + AgedContainerIterator& operator++() { - ++m_iter; + ++iter_; return *this; } - aged_container_iterator + AgedContainerIterator operator++(int) { - aged_container_iterator const prev(*this); - ++m_iter; + AgedContainerIterator const prev(*this); + ++iter_; return prev; } - aged_container_iterator& + AgedContainerIterator& operator--() { - --m_iter; + --iter_; return *this; } - aged_container_iterator + AgedContainerIterator operator--(int) { - aged_container_iterator const prev(*this); - --m_iter; + AgedContainerIterator const prev(*this); + --iter_; return prev; } reference operator*() const { - return m_iter->value; + return iter_->value; } pointer operator->() const { - return &m_iter->value; + return &iter_->value; } [[nodiscard]] time_point const& when() const { - return m_iter->when; + return iter_->when; } private: template - friend class aged_ordered_container; + friend class AgedOrderedContainer; template - friend class aged_unordered_container; + friend class AgedUnorderedContainer; template - friend class aged_container_iterator; + friend class AgedContainerIterator; template - aged_container_iterator(OtherIterator iter) : m_iter(std::move(iter)) + AgedContainerIterator(OtherIterator iter) : iter_(std::move(iter)) { } [[nodiscard]] Iterator const& iterator() const { - return m_iter; + return iter_; } - Iterator m_iter; + Iterator iter_; }; } // namespace detail diff --git a/include/xrpl/beast/container/detail/aged_ordered_container.h b/include/xrpl/beast/container/detail/aged_ordered_container.h index 83a2882746..ad368f2754 100644 --- a/include/xrpl/beast/container/detail/aged_ordered_container.h +++ b/include/xrpl/beast/container/detail/aged_ordered_container.h @@ -23,15 +23,15 @@ namespace detail { // Traits templates used to discern reverse_iterators, which are disallowed // for mutating operations. template -struct is_boost_reverse_iterator : std::false_type +struct IsBoostReverseIterator : std::false_type { - explicit is_boost_reverse_iterator() = default; + explicit IsBoostReverseIterator() = default; }; template -struct is_boost_reverse_iterator> : std::true_type +struct IsBoostReverseIterator> : std::true_type { - explicit is_boost_reverse_iterator() = default; + explicit IsBoostReverseIterator() = default; }; /** Associative container where each element is also indexed by time. @@ -58,10 +58,10 @@ template < class Clock = std::chrono::steady_clock, class Compare = std::less, class Allocator = std::allocator, Key>>> -class aged_ordered_container +class AgedOrderedContainer { public: - using clock_type = abstract_clock; + using clock_type = AbstractClock; using time_point = typename clock_type::time_point; using duration = typename clock_type::duration; using key_type = Key; @@ -79,39 +79,38 @@ private: static Key const& extract(value_type const& value) { - return aged_associative_container_extract_t()(value); + return AgedAssociativeContainerExtractT()(value); } // VFALCO TODO hoist to remove template argument dependencies - struct element : boost::intrusive::set_base_hook< + struct Element : boost::intrusive::set_base_hook< boost::intrusive::link_mode>, boost::intrusive::list_base_hook< boost::intrusive::link_mode> { // Stash types here so the iterator doesn't // need to see the container declaration. - struct stashed + struct Stashed { - explicit stashed() = default; + explicit Stashed() = default; - using value_type = typename aged_ordered_container::value_type; - using time_point = typename aged_ordered_container::time_point; + using value_type = typename AgedOrderedContainer::value_type; + using time_point = typename AgedOrderedContainer::time_point; }; - element(time_point const& when_, value_type const& value_) : value(value_), when(when_) + Element(time_point const& when, value_type const& value) : value(value), when(when) { } - element(time_point const& when_, value_type&& value_) - : value(std::move(value_)), when(when_) + Element(time_point const& when, value_type&& value) : value(std::move(value)), when(when) { } template < class... Args, class = std::enable_if_t>> - element(time_point const& when_, Args&&... args) - : value(std::forward(args)...), when(when_) + Element(time_point const& when, Args&&... args) + : value(std::forward(args)...), when(when) { } @@ -120,7 +119,7 @@ private: }; // VFALCO TODO This should only be enabled for maps. - class pair_value_compare : public Compare + class PairValueCompare : public Compare { public: using first_argument = value_type; @@ -133,16 +132,16 @@ private: return Compare::operator()(lhs.first, rhs.first); } - pair_value_compare() = default; + PairValueCompare() = default; - pair_value_compare(pair_value_compare const& other) : Compare(other) + PairValueCompare(PairValueCompare const& other) : Compare(other) { } private: - friend aged_ordered_container; + friend AgedOrderedContainer; - pair_value_compare(Compare const& compare) : Compare(compare) + PairValueCompare(Compare const& compare) : Compare(compare) { } }; @@ -153,7 +152,7 @@ private: { public: using first_argument = Key; - using second_argument = element; + using second_argument = Element; using result_type = bool; KeyValueCompare() = default; @@ -163,19 +162,19 @@ private: } bool - operator()(Key const& k, element const& e) const + operator()(Key const& k, Element const& e) const { return Compare::operator()(k, extract(e.value)); } bool - operator()(element const& e, Key const& k) const + operator()(Element const& e, Key const& k) const { return Compare::operator()(extract(e.value), k); } bool - operator()(element const& x, element const& y) const + operator()(Element const& x, Element const& y) const { return Compare::operator()(extract(x.value), extract(y.value)); } @@ -194,82 +193,82 @@ private: }; using list_type = typename boost::intrusive:: - make_list>::type; + make_list>::type; using cont_type = std::conditional_t< IsMulti, typename boost::intrusive::make_multiset< - element, + Element, boost::intrusive::constant_time_size, boost::intrusive::compare>::type, typename boost::intrusive::make_set< - element, + Element, boost::intrusive::constant_time_size, boost::intrusive::compare>::type>; using ElementAllocator = - typename std::allocator_traits::template rebind_alloc; + typename std::allocator_traits::template rebind_alloc; using ElementAllocatorTraits = std::allocator_traits; - class config_t : private KeyValueCompare, - public beast::detail::empty_base_optimization + class ConfigT : private KeyValueCompare, + public beast::detail::EmptyBaseOptimization { public: - explicit config_t(clock_type& clock_) : clock(clock_) + explicit ConfigT(clock_type& clock) : clock(clock) { } - config_t(clock_type& clock_, Compare const& comp) : KeyValueCompare(comp), clock(clock_) + ConfigT(clock_type& clock, Compare const& comp) : KeyValueCompare(comp), clock(clock) { } - config_t(clock_type& clock_, Allocator const& alloc_) - : beast::detail::empty_base_optimization(alloc_), clock(clock_) + ConfigT(clock_type& clock, Allocator const& alloc) + : beast::detail::EmptyBaseOptimization(alloc), clock(clock) { } - config_t(clock_type& clock_, Compare const& comp, Allocator const& alloc_) + ConfigT(clock_type& clock, Compare const& comp, Allocator const& alloc) : KeyValueCompare(comp) - , beast::detail::empty_base_optimization(alloc_) - , clock(clock_) + , beast::detail::EmptyBaseOptimization(alloc) + , clock(clock) { } - config_t(config_t const& other) - : KeyValueCompare(other.key_compare()) - , beast::detail::empty_base_optimization( + ConfigT(ConfigT const& other) + : KeyValueCompare(other.keyCompare()) + , beast::detail::EmptyBaseOptimization( ElementAllocatorTraits::select_on_container_copy_construction(other.alloc())) , clock(other.clock) { } - config_t(config_t const& other, Allocator const& alloc) - : KeyValueCompare(other.key_compare()) - , beast::detail::empty_base_optimization(alloc) + ConfigT(ConfigT const& other, Allocator const& alloc) + : KeyValueCompare(other.keyCompare()) + , beast::detail::EmptyBaseOptimization(alloc) , clock(other.clock) { } - config_t(config_t&& other) - : KeyValueCompare(std::move(other.key_compare())) - , beast::detail::empty_base_optimization(std::move( - static_cast&>(other))) + ConfigT(ConfigT&& other) + : KeyValueCompare(std::move(other.keyCompare())) + , beast::detail::EmptyBaseOptimization(std::move( + static_cast&>(other))) , clock(other.clock) { } - config_t( - config_t&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) + ConfigT( + ConfigT&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) Allocator const& alloc) - : KeyValueCompare(std::move(other.key_compare())) - , beast::detail::empty_base_optimization(alloc) + : KeyValueCompare(std::move(other.keyCompare())) + , beast::detail::EmptyBaseOptimization(alloc) , clock(other.clock) { } - config_t& - operator=(config_t const& other) + ConfigT& + operator=(ConfigT const& other) { if (this != &other) { @@ -280,8 +279,8 @@ private: return *this; } - config_t& - operator=(config_t&& other) + ConfigT& + operator=(ConfigT&& other) { compare() = std::move(other.compare()); alloc() = std::move(other.alloc()); @@ -302,13 +301,13 @@ private: } KeyValueCompare& - key_compare() + keyCompare() { return *this; } [[nodiscard]] KeyValueCompare const& - key_compare() const + keyCompare() const { return *this; } @@ -316,61 +315,61 @@ private: ElementAllocator& alloc() { - return beast::detail::empty_base_optimization::member(); + return beast::detail::EmptyBaseOptimization::member(); } [[nodiscard]] ElementAllocator const& alloc() const { - return beast::detail::empty_base_optimization::member(); + return beast::detail::EmptyBaseOptimization::member(); } std::reference_wrapper clock; }; template - element* - new_element(Args&&... args) + Element* + newElement(Args&&... args) { struct Deleter { - std::reference_wrapper a_; - Deleter(ElementAllocator& a) : a_(a) + std::reference_wrapper a; + Deleter(ElementAllocator& a) : a(a) { } void - operator()(element* p) + operator()(Element* p) { - ElementAllocatorTraits::deallocate(a_.get(), p, 1); + ElementAllocatorTraits::deallocate(a.get(), p, 1); } }; - std::unique_ptr p( - ElementAllocatorTraits::allocate(m_config.alloc(), 1), Deleter(m_config.alloc())); + std::unique_ptr p( + ElementAllocatorTraits::allocate(config_.alloc(), 1), Deleter(config_.alloc())); ElementAllocatorTraits::construct( - m_config.alloc(), p.get(), clock().now(), std::forward(args)...); + config_.alloc(), p.get(), clock().now(), std::forward(args)...); return p.release(); } void - delete_element(element const* p) + deleteElement(Element const* p) { - ElementAllocatorTraits::destroy(m_config.alloc(), p); - ElementAllocatorTraits::deallocate(m_config.alloc(), const_cast(p), 1); + ElementAllocatorTraits::destroy(config_.alloc(), p); + ElementAllocatorTraits::deallocate(config_.alloc(), const_cast(p), 1); } void - unlink_and_delete_element(element const* p) + unlinkAndDeleteElement(Element const* p) { - chronological.list.erase(chronological.list.iterator_to(*p)); - m_cont.erase(m_cont.iterator_to(*p)); - delete_element(p); + chronological.list_.erase(chronological.list_.iterator_to(*p)); + cont_.erase(cont_.iterator_to(*p)); + deleteElement(p); } public: using key_compare = Compare; - using value_compare = std::conditional_t; + using value_compare = std::conditional_t; using allocator_type = Allocator; using reference = value_type&; using const_reference = value_type const&; @@ -379,13 +378,12 @@ public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = beast::detail::aged_container_iterator; - using const_iterator = - beast::detail::aged_container_iterator; + using iterator = beast::detail::AgedContainerIterator; + using const_iterator = beast::detail::AgedContainerIterator; using reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using const_reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; //-------------------------------------------------------------------------- // @@ -396,118 +394,117 @@ public: // //-------------------------------------------------------------------------- - class chronological_t + class ChronologicalT { - chronological_t() = default; + ChronologicalT() = default; public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = - beast::detail::aged_container_iterator; + using iterator = beast::detail::AgedContainerIterator; using const_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using const_reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; iterator begin() { - return iterator(list.begin()); + return iterator(list_.begin()); } const_iterator begin() const { - return const_iterator(list.begin()); + return const_iterator(list_.begin()); } const_iterator cbegin() const { - return const_iterator(list.begin()); + return const_iterator(list_.begin()); } iterator end() { - return iterator(list.end()); + return iterator(list_.end()); } const_iterator end() const { - return const_iterator(list.end()); + return const_iterator(list_.end()); } const_iterator cend() const { - return const_iterator(list.end()); + return const_iterator(list_.end()); } reverse_iterator rbegin() { - return reverse_iterator(list.rbegin()); + return reverse_iterator(list_.rbegin()); } const_reverse_iterator rbegin() const { - return const_reverse_iterator(list.rbegin()); + return const_reverse_iterator(list_.rbegin()); } const_reverse_iterator crbegin() const { - return const_reverse_iterator(list.rbegin()); + return const_reverse_iterator(list_.rbegin()); } reverse_iterator rend() { - return reverse_iterator(list.rend()); + return reverse_iterator(list_.rend()); } const_reverse_iterator rend() const { - return const_reverse_iterator(list.rend()); + return const_reverse_iterator(list_.rend()); } const_reverse_iterator crend() const { - return const_reverse_iterator(list.rend()); + return const_reverse_iterator(list_.rend()); } iterator - iterator_to(value_type& value) + iteratorTo(value_type& value) { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return list.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return list_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } const_iterator - iterator_to(value_type const& value) const + iteratorTo(value_type const& value) const { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return list.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return list_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } - chronological_t(chronological_t const&) = delete; - chronological_t(chronological_t&&) = delete; + ChronologicalT(ChronologicalT const&) = delete; + ChronologicalT(ChronologicalT&&) = delete; private: - friend class aged_ordered_container; - list_type mutable list; + friend class AgedOrderedContainer; + list_type mutable list_; } chronological; //-------------------------------------------------------------------------- @@ -516,89 +513,89 @@ public: // //-------------------------------------------------------------------------- - aged_ordered_container() = delete; + AgedOrderedContainer() = delete; - explicit aged_ordered_container(clock_type& clock); + explicit AgedOrderedContainer(clock_type& clock); - aged_ordered_container(clock_type& clock, Compare const& comp); + AgedOrderedContainer(clock_type& clock, Compare const& comp); - aged_ordered_container(clock_type& clock, Allocator const& alloc); + AgedOrderedContainer(clock_type& clock, Allocator const& alloc); - aged_ordered_container(clock_type& clock, Compare const& comp, Allocator const& alloc); + AgedOrderedContainer(clock_type& clock, Compare const& comp, Allocator const& alloc); template - aged_ordered_container(InputIt first, InputIt last, clock_type& clock); + AgedOrderedContainer(InputIt first, InputIt last, clock_type& clock); template - aged_ordered_container(InputIt first, InputIt last, clock_type& clock, Compare const& comp); + AgedOrderedContainer(InputIt first, InputIt last, clock_type& clock, Compare const& comp); template - aged_ordered_container(InputIt first, InputIt last, clock_type& clock, Allocator const& alloc); + AgedOrderedContainer(InputIt first, InputIt last, clock_type& clock, Allocator const& alloc); template - aged_ordered_container( + AgedOrderedContainer( InputIt first, InputIt last, clock_type& clock, Compare const& comp, Allocator const& alloc); - aged_ordered_container(aged_ordered_container const& other); + AgedOrderedContainer(AgedOrderedContainer const& other); - aged_ordered_container(aged_ordered_container const& other, Allocator const& alloc); + AgedOrderedContainer(AgedOrderedContainer const& other, Allocator const& alloc); - aged_ordered_container(aged_ordered_container&& other); + AgedOrderedContainer(AgedOrderedContainer&& other); - aged_ordered_container( + AgedOrderedContainer( // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) - aged_ordered_container&& other, + AgedOrderedContainer&& other, Allocator const& alloc); - aged_ordered_container(std::initializer_list init, clock_type& clock); + AgedOrderedContainer(std::initializer_list init, clock_type& clock); - aged_ordered_container( + AgedOrderedContainer( std::initializer_list init, clock_type& clock, Compare const& comp); - aged_ordered_container( + AgedOrderedContainer( std::initializer_list init, clock_type& clock, Allocator const& alloc); - aged_ordered_container( + AgedOrderedContainer( std::initializer_list init, clock_type& clock, Compare const& comp, Allocator const& alloc); - ~aged_ordered_container(); + ~AgedOrderedContainer(); - aged_ordered_container& - operator=(aged_ordered_container const& other); + AgedOrderedContainer& + operator=(AgedOrderedContainer const& other); - aged_ordered_container& - operator=(aged_ordered_container&& other); + AgedOrderedContainer& + operator=(AgedOrderedContainer&& other); - aged_ordered_container& + AgedOrderedContainer& operator=(std::initializer_list init); allocator_type - get_allocator() const + getAllocator() const { - return m_config.alloc(); + return config_.alloc(); } clock_type& clock() { - return m_config.clock; + return config_.clock; } clock_type const& clock() const { - return m_config.clock; + return config_.clock; } //-------------------------------------------------------------------------- @@ -609,31 +606,31 @@ public: template < class K, - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& at(K const& k); template < class K, - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> typename std::conditional::type const& at(K const& k) const; template < - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& operator[](Key const& key); template < - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& operator[](Key&& key); @@ -646,91 +643,91 @@ public: iterator begin() { - return iterator(m_cont.begin()); + return iterator(cont_.begin()); } const_iterator begin() const { - return const_iterator(m_cont.begin()); + return const_iterator(cont_.begin()); } const_iterator cbegin() const { - return const_iterator(m_cont.begin()); + return const_iterator(cont_.begin()); } iterator end() { - return iterator(m_cont.end()); + return iterator(cont_.end()); } const_iterator end() const { - return const_iterator(m_cont.end()); + return const_iterator(cont_.end()); } const_iterator cend() const { - return const_iterator(m_cont.end()); + return const_iterator(cont_.end()); } reverse_iterator rbegin() { - return reverse_iterator(m_cont.rbegin()); + return reverse_iterator(cont_.rbegin()); } const_reverse_iterator rbegin() const { - return const_reverse_iterator(m_cont.rbegin()); + return const_reverse_iterator(cont_.rbegin()); } const_reverse_iterator crbegin() const { - return const_reverse_iterator(m_cont.rbegin()); + return const_reverse_iterator(cont_.rbegin()); } reverse_iterator rend() { - return reverse_iterator(m_cont.rend()); + return reverse_iterator(cont_.rend()); } const_reverse_iterator rend() const { - return const_reverse_iterator(m_cont.rend()); + return const_reverse_iterator(cont_.rend()); } const_reverse_iterator crend() const { - return const_reverse_iterator(m_cont.rend()); + return const_reverse_iterator(cont_.rend()); } iterator - iterator_to(value_type& value) + iteratorTo(value_type& value) { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return m_cont.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return cont_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } const_iterator - iterator_to(value_type const& value) const + iteratorTo(value_type const& value) const { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return m_cont.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return cont_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } //-------------------------------------------------------------------------- @@ -742,19 +739,19 @@ public: bool empty() const noexcept { - return m_cont.empty(); + return cont_.empty(); } size_type size() const noexcept { - return m_cont.size(); + return cont_.size(); } size_type - max_size() const noexcept + maxSize() const noexcept { - return m_config.max_size(); + return config_.max_size(); } //-------------------------------------------------------------------------- @@ -767,37 +764,36 @@ public: clear(); // map, set - template + template auto - insert(value_type const& value) -> std::enable_if_t>; + insert(value_type const& value) -> std::enable_if_t>; // multimap, multiset - template + template auto - insert(value_type const& value) -> std::enable_if_t; + insert(value_type const& value) -> std::enable_if_t; // set - template + template auto insert(value_type&& value) - -> std::enable_if_t>; + -> std::enable_if_t>; // multiset - template + template auto - insert(value_type&& value) -> std::enable_if_t; + insert(value_type&& value) -> std::enable_if_t; //--- // map, set - template + template auto - insert(const_iterator hint, value_type const& value) - -> std::enable_if_t; + insert(const_iterator hint, value_type const& value) -> std::enable_if_t; // multimap, multiset - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type const& value) { // VFALCO TODO Figure out how to utilize 'hint' @@ -805,13 +801,13 @@ public: } // map, set - template + template auto - insert(const_iterator hint, value_type&& value) -> std::enable_if_t; + insert(const_iterator hint, value_type&& value) -> std::enable_if_t; // multimap, multiset - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type&& value) { // VFALCO TODO Figure out how to utilize 'hint' @@ -819,9 +815,9 @@ public: } // map, multimap - template + template std::enable_if_t< - maybe_map && std::is_constructible_v, + MaybeMap && std::is_constructible_v, std::conditional_t>> insert(P&& value) { @@ -829,13 +825,13 @@ public: } // map, multimap - template + template std::enable_if_t< - maybe_map && std::is_constructible_v, + MaybeMap && std::is_constructible_v, std::conditional_t>> insert(const_iterator hint, P&& value) { - return emplace_hint(hint, std::forward

(value)); + return emplaceHint(hint, std::forward

(value)); } template @@ -853,65 +849,65 @@ public: } // map, set - template + template auto - emplace(Args&&... args) -> std::enable_if_t>; + emplace(Args&&... args) -> std::enable_if_t>; // multiset, multimap - template + template auto - emplace(Args&&... args) -> std::enable_if_t; + emplace(Args&&... args) -> std::enable_if_t; // map, set - template + template auto - emplace_hint(const_iterator hint, Args&&... args) - -> std::enable_if_t>; + emplaceHint(const_iterator hint, Args&&... args) + -> std::enable_if_t>; // multiset, multimap - template - std::enable_if_t - emplace_hint(const_iterator /*hint*/, Args&&... args) + template + std::enable_if_t + emplaceHint(const_iterator /*hint*/, Args&&... args) { // VFALCO TODO Figure out how to utilize 'hint' - return emplace(std::forward(args)...); + return emplace(std::forward(args)...); } // enable_if prevents erase (reverse_iterator pos) from compiling template < - bool is_const, + bool IsConst, class Iterator, - class = std::enable_if_t::value>> - beast::detail::aged_container_iterator - erase(beast::detail::aged_container_iterator pos); + class = std::enable_if_t::value>> + beast::detail::AgedContainerIterator + erase(beast::detail::AgedContainerIterator pos); // enable_if prevents erase (reverse_iterator first, reverse_iterator last) // from compiling template < - bool is_const, + bool IsConst, class Iterator, - class = std::enable_if_t::value>> - beast::detail::aged_container_iterator + class = std::enable_if_t::value>> + beast::detail::AgedContainerIterator erase( - beast::detail::aged_container_iterator first, - beast::detail::aged_container_iterator last); + beast::detail::AgedContainerIterator first, + beast::detail::AgedContainerIterator last); template auto erase(K const& k) -> size_type; void - swap(aged_ordered_container& other) noexcept; + swap(AgedOrderedContainer& other) noexcept; //-------------------------------------------------------------------------- // enable_if prevents touch (reverse_iterator pos) from compiling template < - bool is_const, + bool IsConst, class Iterator, - class = std::enable_if_t::value>> + class = std::enable_if_t::value>> void - touch(beast::detail::aged_container_iterator pos) + touch(beast::detail::AgedContainerIterator pos) { touch(pos, clock().now()); } @@ -931,7 +927,7 @@ public: size_type count(K const& k) const { - return m_cont.count(k, std::cref(m_config.key_compare())); + return cont_.count(k, std::cref(config_.keyCompare())); } // VFALCO TODO Respect is_transparent (c++14) @@ -939,7 +935,7 @@ public: iterator find(K const& k) { - return iterator(m_cont.find(k, std::cref(m_config.key_compare()))); + return iterator(cont_.find(k, std::cref(config_.keyCompare()))); } // VFALCO TODO Respect is_transparent (c++14) @@ -947,57 +943,57 @@ public: const_iterator find(K const& k) const { - return const_iterator(m_cont.find(k, std::cref(m_config.key_compare()))); + return const_iterator(cont_.find(k, std::cref(config_.keyCompare()))); } // VFALCO TODO Respect is_transparent (c++14) template std::pair - equal_range(K const& k) + equalRange(K const& k) { - auto const r(m_cont.equal_range(k, std::cref(m_config.key_compare()))); + auto const r(cont_.equal_range(k, std::cref(config_.keyCompare()))); return std::make_pair(iterator(r.first), iterator(r.second)); } // VFALCO TODO Respect is_transparent (c++14) template std::pair - equal_range(K const& k) const + equalRange(K const& k) const { - auto const r(m_cont.equal_range(k, std::cref(m_config.key_compare()))); + auto const r(cont_.equal_range(k, std::cref(config_.keyCompare()))); return std::make_pair(const_iterator(r.first), const_iterator(r.second)); } // VFALCO TODO Respect is_transparent (c++14) template iterator - lower_bound(K const& k) + lowerBound(K const& k) { - return iterator(m_cont.lower_bound(k, std::cref(m_config.key_compare()))); + return iterator(cont_.lower_bound(k, std::cref(config_.keyCompare()))); } // VFALCO TODO Respect is_transparent (c++14) template const_iterator - lower_bound(K const& k) const + lowerBound(K const& k) const { - return const_iterator(m_cont.lower_bound(k, std::cref(m_config.key_compare()))); + return const_iterator(cont_.lower_bound(k, std::cref(config_.keyCompare()))); } // VFALCO TODO Respect is_transparent (c++14) template iterator - upper_bound(K const& k) + upperBound(K const& k) { - return iterator(m_cont.upper_bound(k, std::cref(m_config.key_compare()))); + return iterator(cont_.upper_bound(k, std::cref(config_.keyCompare()))); } // VFALCO TODO Respect is_transparent (c++14) template const_iterator - upper_bound(K const& k) const + upperBound(K const& k) const { - return const_iterator(m_cont.upper_bound(k, std::cref(m_config.key_compare()))); + return const_iterator(cont_.upper_bound(k, std::cref(config_.keyCompare()))); } //-------------------------------------------------------------------------- @@ -1007,16 +1003,16 @@ public: //-------------------------------------------------------------------------- key_compare - key_comp() const + keyComp() const { - return m_config.compare(); + return config_.compare(); } // VFALCO TODO Should this return const reference for set? value_compare - value_comp() const + valueComp() const { - return value_compare(m_config.compare()); + return value_compare(config_.compare()); } //-------------------------------------------------------------------------- @@ -1036,7 +1032,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator==(aged_ordered_container< + operator==(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1052,7 +1048,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator!=(aged_ordered_container< + operator!=(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1071,7 +1067,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator<(aged_ordered_container< + operator<(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1080,7 +1076,7 @@ public: Compare, OtherAllocator> const& other) const { - value_compare const comp(value_comp()); + value_compare const comp(valueComp()); return std::lexicographical_compare(cbegin(), cend(), other.cbegin(), other.cend(), comp); } @@ -1091,7 +1087,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator<=(aged_ordered_container< + operator<=(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1110,7 +1106,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator>(aged_ordered_container< + operator>(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1129,7 +1125,7 @@ public: class OtherDuration, class OtherAllocator> bool - operator>=(aged_ordered_container< + operator>=(AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1144,155 +1140,155 @@ public: private: // enable_if prevents erase (reverse_iterator pos, now) from compiling template < - bool is_const, + bool IsConst, class Iterator, - class = std::enable_if_t::value>> + class = std::enable_if_t::value>> void touch( - beast::detail::aged_container_iterator pos, + beast::detail::AgedContainerIterator pos, typename clock_type::time_point const& now); template < - bool maybe_propagate = std::allocator_traits::propagate_on_container_swap::value> - std::enable_if_t - swap_data(aged_ordered_container& other) noexcept; + bool MaybePropagate = std::allocator_traits::propagate_on_container_swap::value> + std::enable_if_t + swapData(AgedOrderedContainer& other) noexcept; template < - bool maybe_propagate = std::allocator_traits::propagate_on_container_swap::value> - std::enable_if_t - swap_data(aged_ordered_container& other) noexcept; + bool MaybePropagate = std::allocator_traits::propagate_on_container_swap::value> + std::enable_if_t + swapData(AgedOrderedContainer& other) noexcept; private: - config_t m_config; - cont_type mutable m_cont; + ConfigT config_; + cont_type mutable cont_; }; //------------------------------------------------------------------------------ template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( clock_type& clock) - : m_config(clock) + : config_(clock) { } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( clock_type& clock, Compare const& comp) - : m_config(clock, comp), m_cont(comp) + : config_(clock, comp), cont_(comp) { } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) + : config_(clock, alloc) { } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( clock_type& clock, Compare const& comp, Allocator const& alloc) - : m_config(clock, comp, alloc), m_cont(comp) + : config_(clock, comp, alloc), cont_(comp) { } template template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( InputIt first, InputIt last, clock_type& clock) - : m_config(clock) + : config_(clock) { insert(first, last); } template template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( InputIt first, InputIt last, clock_type& clock, Compare const& comp) - : m_config(clock, comp), m_cont(comp) + : config_(clock, comp), cont_(comp) { insert(first, last); } template template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( InputIt first, InputIt last, clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) + : config_(clock, alloc) { insert(first, last); } template template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( InputIt first, InputIt last, clock_type& clock, Compare const& comp, Allocator const& alloc) - : m_config(clock, comp, alloc), m_cont(comp) + : config_(clock, comp, alloc), cont_(comp) { insert(first, last); } template -aged_ordered_container::aged_ordered_container( - aged_ordered_container const& other) - : m_config(other.m_config) +AgedOrderedContainer::AgedOrderedContainer( + AgedOrderedContainer const& other) + : config_(other.config_) #if BOOST_VERSION >= 108000 - , m_cont(other.m_cont.get_comp()) + , cont_(other.cont_.get_comp()) #else - , m_cont(other.m_cont.comp()) + , cont_(other.cont_.comp()) #endif { insert(other.cbegin(), other.cend()); } template -aged_ordered_container::aged_ordered_container( - aged_ordered_container const& other, +AgedOrderedContainer::AgedOrderedContainer( + AgedOrderedContainer const& other, Allocator const& alloc) - : m_config(other.m_config, alloc) + : config_(other.config_, alloc) #if BOOST_VERSION >= 108000 - , m_cont(other.m_cont.get_comp()) + , cont_(other.cont_.get_comp()) #else - , m_cont(other.m_cont.comp()) + , cont_(other.cont_.comp()) #endif { insert(other.cbegin(), other.cend()); } template -aged_ordered_container::aged_ordered_container( - aged_ordered_container&& other) - : m_config(std::move(other.m_config)), m_cont(std::move(other.m_cont)) +AgedOrderedContainer::AgedOrderedContainer( + AgedOrderedContainer&& other) + : config_(std::move(other.config_)), cont_(std::move(other.cont_)) { - chronological.list = std::move(other.chronological.list); + chronological.list_ = std::move(other.chronological.list_); } template -aged_ordered_container::aged_ordered_container( - aged_ordered_container&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) +AgedOrderedContainer::AgedOrderedContainer( + AgedOrderedContainer&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) Allocator const& alloc) - : m_config(std::move(other.m_config), alloc) + : config_(std::move(other.config_), alloc) #if BOOST_VERSION >= 108000 - , m_cont(std::move(other.m_cont.get_comp())) + , cont_(std::move(other.cont_.get_comp())) #else - , m_cont(std::move(other.m_cont.comp())) + , cont_(std::move(other.cont_.comp())) #endif { @@ -1301,60 +1297,60 @@ aged_ordered_container::aged_ } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( std::initializer_list init, clock_type& clock) - : m_config(clock) + : config_(clock) { insert(init.begin(), init.end()); } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( std::initializer_list init, clock_type& clock, Compare const& comp) - : m_config(clock, comp), m_cont(comp) + : config_(clock, comp), cont_(comp) { insert(init.begin(), init.end()); } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( std::initializer_list init, clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) + : config_(clock, alloc) { insert(init.begin(), init.end()); } template -aged_ordered_container::aged_ordered_container( +AgedOrderedContainer::AgedOrderedContainer( std::initializer_list init, clock_type& clock, Compare const& comp, Allocator const& alloc) - : m_config(clock, comp, alloc), m_cont(comp) + : config_(clock, comp, alloc), cont_(comp) { insert(init.begin(), init.end()); } template -aged_ordered_container::~aged_ordered_container() +AgedOrderedContainer::~AgedOrderedContainer() { clear(); } template auto -aged_ordered_container::operator=( - aged_ordered_container const& other) -> aged_ordered_container& +AgedOrderedContainer::operator=( + AgedOrderedContainer const& other) -> AgedOrderedContainer& { if (this != &other) { clear(); - this->m_config = other.m_config; + this->config_ = other.config_; insert(other.begin(), other.end()); } return *this; @@ -1362,11 +1358,11 @@ aged_ordered_container::opera template auto -aged_ordered_container::operator=( - aged_ordered_container&& other) -> aged_ordered_container& +AgedOrderedContainer::operator=( + AgedOrderedContainer&& other) -> AgedOrderedContainer& { clear(); - this->m_config = std::move(other.m_config); + this->config_ = std::move(other.config_); insert(other.begin(), other.end()); other.clear(); return *this; @@ -1374,8 +1370,8 @@ aged_ordered_container::opera template auto -aged_ordered_container::operator=( - std::initializer_list init) -> aged_ordered_container& +AgedOrderedContainer::operator=( + std::initializer_list init) -> AgedOrderedContainer& { clear(); insert(init); @@ -1385,61 +1381,60 @@ aged_ordered_container::opera //------------------------------------------------------------------------------ template -template +template std::conditional_t& -aged_ordered_container::at(K const& k) +AgedOrderedContainer::at(K const& k) { - auto const iter(m_cont.find(k, std::cref(m_config.key_compare()))); - if (iter == m_cont.end()) + auto const iter(cont_.find(k, std::cref(config_.keyCompare()))); + if (iter == cont_.end()) throw std::out_of_range("key not found"); return iter->value.second; } template -template +template typename std::conditional::type const& -aged_ordered_container::at(K const& k) const +AgedOrderedContainer::at(K const& k) const { - auto const iter(m_cont.find(k, std::cref(m_config.key_compare()))); - if (iter == m_cont.end()) + auto const iter(cont_.find(k, std::cref(config_.keyCompare()))); + if (iter == cont_.end()) throw std::out_of_range("key not found"); return iter->value.second; } template -template +template std::conditional_t& -aged_ordered_container::operator[]( - Key const& key) +AgedOrderedContainer::operator[](Key const& key) { typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check(key, std::cref(m_config.key_compare()), d)); + auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element( + Element* const p(newElement( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple())); - m_cont.insert_commit(*p, d); - chronological.list.push_back(*p); + cont_.insert_commit(*p, d); + chronological.list_.push_back(*p); return p->value.second; } return result.first->value.second; } template -template +template std::conditional_t& -aged_ordered_container::operator[](Key&& key) +AgedOrderedContainer::operator[](Key&& key) { typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check(key, std::cref(m_config.key_compare()), d)); + auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element( + Element* const p(newElement( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple())); - m_cont.insert_commit(*p, d); - chronological.list.push_back(*p); + cont_.insert_commit(*p, d); + chronological.list_.push_back(*p); return p->value.second; } return result.first->value.second; @@ -1449,28 +1444,28 @@ aged_ordered_container::opera template void -aged_ordered_container::clear() +AgedOrderedContainer::clear() { - for (auto iter(chronological.list.begin()); iter != chronological.list.end();) - delete_element(&*iter++); - chronological.list.clear(); - m_cont.clear(); + for (auto iter(chronological.list_.begin()); iter != chronological.list_.end();) + deleteElement(&*iter++); + chronological.list_.clear(); + cont_.clear(); } // map, set template -template +template auto -aged_ordered_container::insert( - value_type const& value) -> std::enable_if_t> +AgedOrderedContainer::insert( + value_type const& value) -> std::enable_if_t> { typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d)); + auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element(value)); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(value)); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } return std::make_pair(iterator(result.first), false); @@ -1478,32 +1473,32 @@ aged_ordered_container::inser // multimap, multiset template -template +template auto -aged_ordered_container::insert( - value_type const& value) -> std::enable_if_t +AgedOrderedContainer::insert( + value_type const& value) -> std::enable_if_t { - auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare()))); - element* const p(new_element(value)); - chronological.list.push_back(*p); - auto const iter(m_cont.insert_before(before, *p)); + auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare()))); + Element* const p(newElement(value)); + chronological.list_.push_back(*p); + auto const iter(cont_.insert_before(before, *p)); return iterator(iter); } // set template -template +template auto -aged_ordered_container::insert( - value_type&& value) -> std::enable_if_t> +AgedOrderedContainer::insert(value_type&& value) + -> std::enable_if_t> { typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d)); + auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element(std::move(value))); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(std::move(value))); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } return std::make_pair(iterator(result.first), false); @@ -1511,15 +1506,15 @@ aged_ordered_container::inser // multiset template -template +template auto -aged_ordered_container::insert( - value_type&& value) -> std::enable_if_t +AgedOrderedContainer::insert(value_type&& value) + -> std::enable_if_t { - auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare()))); - element* const p(new_element(std::move(value))); - chronological.list.push_back(*p); - auto const iter(m_cont.insert_before(before, *p)); + auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare()))); + Element* const p(newElement(std::move(value))); + chronological.list_.push_back(*p); + auto const iter(cont_.insert_before(before, *p)); return iterator(iter); } @@ -1527,20 +1522,20 @@ aged_ordered_container::inser // map, set template -template +template auto -aged_ordered_container::insert( +AgedOrderedContainer::insert( const_iterator hint, - value_type const& value) -> std::enable_if_t + value_type const& value) -> std::enable_if_t { typename cont_type::insert_commit_data d; auto const result( - m_cont.insert_check(hint.iterator(), extract(value), std::cref(m_config.key_compare()), d)); + cont_.insert_check(hint.iterator(), extract(value), std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element(value)); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(value)); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return iterator(iter); } return iterator(result.first); @@ -1548,20 +1543,20 @@ aged_ordered_container::inser // map, set template -template +template auto -aged_ordered_container::insert( +AgedOrderedContainer::insert( const_iterator hint, - value_type&& value) -> std::enable_if_t + value_type&& value) -> std::enable_if_t { typename cont_type::insert_commit_data d; auto const result( - m_cont.insert_check(hint.iterator(), extract(value), std::cref(m_config.key_compare()), d)); + cont_.insert_check(hint.iterator(), extract(value), std::cref(config_.keyCompare()), d)); if (result.second) { - element* const p(new_element(std::move(value))); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(std::move(value))); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return iterator(iter); } return iterator(result.first); @@ -1569,102 +1564,102 @@ aged_ordered_container::inser // map, set template -template +template auto -aged_ordered_container::emplace(Args&&... args) - -> std::enable_if_t> +AgedOrderedContainer::emplace(Args&&... args) + -> std::enable_if_t> { // VFALCO NOTE Its unfortunate that we need to // construct element here - element* const p(new_element(std::forward(args)...)); + Element* const p(newElement(std::forward(args)...)); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check(extract(p->value), std::cref(m_config.key_compare()), d)); + auto const result(cont_.insert_check(extract(p->value), std::cref(config_.keyCompare()), d)); if (result.second) { - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } - delete_element(p); + deleteElement(p); return std::make_pair(iterator(result.first), false); } // multiset, multimap template -template +template auto -aged_ordered_container::emplace(Args&&... args) - -> std::enable_if_t +AgedOrderedContainer::emplace(Args&&... args) + -> std::enable_if_t { - element* const p(new_element(std::forward(args)...)); - auto const before(m_cont.upper_bound(extract(p->value), std::cref(m_config.key_compare()))); - chronological.list.push_back(*p); - auto const iter(m_cont.insert_before(before, *p)); + Element* const p(newElement(std::forward(args)...)); + auto const before(cont_.upper_bound(extract(p->value), std::cref(config_.keyCompare()))); + chronological.list_.push_back(*p); + auto const iter(cont_.insert_before(before, *p)); return iterator(iter); } // map, set template -template +template auto -aged_ordered_container::emplace_hint( +AgedOrderedContainer::emplaceHint( const_iterator hint, - Args&&... args) -> std::enable_if_t> + Args&&... args) -> std::enable_if_t> { // VFALCO NOTE Its unfortunate that we need to // construct element here - element* const p(new_element(std::forward(args)...)); + Element* const p(newElement(std::forward(args)...)); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - hint.iterator(), extract(p->value), std::cref(m_config.key_compare()), d)); + auto const result( + cont_.insert_check(hint.iterator(), extract(p->value), std::cref(config_.keyCompare()), d)); if (result.second) { - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } - delete_element(p); + deleteElement(p); return std::make_pair(iterator(result.first), false); } template -template -beast::detail::aged_container_iterator -aged_ordered_container::erase( - beast::detail::aged_container_iterator pos) +template +beast::detail::AgedContainerIterator +AgedOrderedContainer::erase( + beast::detail::AgedContainerIterator pos) { - unlink_and_delete_element(&*((pos++).iterator())); - return beast::detail::aged_container_iterator(pos.iterator()); + unlinkAndDeleteElement(&*((pos++).iterator())); + return beast::detail::AgedContainerIterator(pos.iterator()); } template -template -beast::detail::aged_container_iterator -aged_ordered_container::erase( - beast::detail::aged_container_iterator first, - beast::detail::aged_container_iterator last) +template +beast::detail::AgedContainerIterator +AgedOrderedContainer::erase( + beast::detail::AgedContainerIterator first, + beast::detail::AgedContainerIterator last) { for (; first != last;) - unlink_and_delete_element(&*((first++).iterator())); + unlinkAndDeleteElement(&*((first++).iterator())); - return beast::detail::aged_container_iterator(first.iterator()); + return beast::detail::AgedContainerIterator(first.iterator()); } template template auto -aged_ordered_container::erase(K const& k) +AgedOrderedContainer::erase(K const& k) -> size_type { - auto iter(m_cont.find(k, std::cref(m_config.key_compare()))); - if (iter == m_cont.end()) + auto iter(cont_.find(k, std::cref(config_.keyCompare()))); + if (iter == cont_.end()) return 0; size_type n(0); for (;;) { auto p(&*iter++); - bool const done(m_config(*p, extract(iter->value))); - unlink_and_delete_element(p); + bool const done(config_(*p, extract(iter->value))); + unlinkAndDeleteElement(p); ++n; if (done) break; @@ -1674,12 +1669,12 @@ aged_ordered_container::erase template void -aged_ordered_container::swap( - aged_ordered_container& other) noexcept +AgedOrderedContainer::swap( + AgedOrderedContainer& other) noexcept { - swap_data(other); + swapData(other); std::swap(chronological, other.chronological); - std::swap(m_cont, other.m_cont); + std::swap(cont_, other.cont_); } //------------------------------------------------------------------------------ @@ -1687,12 +1682,12 @@ aged_ordered_container::swap( template template auto -aged_ordered_container::touch(K const& k) +AgedOrderedContainer::touch(K const& k) -> size_type { auto const now(clock().now()); size_type n(0); - auto const range(equal_range(k)); + auto const range(equalRange(k)); for (auto iter : range) { touch(iter, now); @@ -1711,8 +1706,8 @@ template < class OtherDuration, class OtherAllocator> bool -aged_ordered_container::operator==( - aged_ordered_container< +AgedOrderedContainer::operator==( + AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1721,7 +1716,7 @@ aged_ordered_container::opera Compare, OtherAllocator> const& other) const { - using Other = aged_ordered_container< + using Other = AgedOrderedContainer< OtherIsMulti, OtherIsMap, Key, @@ -1745,37 +1740,37 @@ aged_ordered_container::opera //------------------------------------------------------------------------------ template -template +template void -aged_ordered_container::touch( - beast::detail::aged_container_iterator pos, +AgedOrderedContainer::touch( + beast::detail::AgedContainerIterator pos, typename clock_type::time_point const& now) { auto& e(*pos.iterator()); e.when = now; - chronological.list.erase(chronological.list.iterator_to(e)); - chronological.list.push_back(e); + chronological.list_.erase(chronological.list_.iterator_to(e)); + chronological.list_.push_back(e); } template -template -std::enable_if_t -aged_ordered_container::swap_data( - aged_ordered_container& other) noexcept +template +std::enable_if_t +AgedOrderedContainer::swapData( + AgedOrderedContainer& other) noexcept { - std::swap(m_config.key_compare(), other.m_config.key_compare()); - std::swap(m_config.alloc(), other.m_config.alloc()); - std::swap(m_config.clock, other.m_config.clock); + std::swap(config_.keyCompare(), other.config_.keyCompare()); + std::swap(config_.alloc(), other.config_.alloc()); + std::swap(config_.clock, other.config_.clock); } template -template -std::enable_if_t -aged_ordered_container::swap_data( - aged_ordered_container& other) noexcept +template +std::enable_if_t +AgedOrderedContainer::swapData( + AgedOrderedContainer& other) noexcept { - std::swap(m_config.key_compare(), other.m_config.key_compare()); - std::swap(m_config.clock, other.m_config.clock); + std::swap(config_.keyCompare(), other.config_.keyCompare()); + std::swap(config_.clock, other.config_.clock); } } // namespace detail @@ -1783,11 +1778,11 @@ aged_ordered_container::swap_ //------------------------------------------------------------------------------ template -struct is_aged_container< - beast::detail::aged_ordered_container> +struct IsAgedContainer< + beast::detail::AgedOrderedContainer> : std::true_type { - explicit is_aged_container() = default; + explicit IsAgedContainer() = default; }; // Free functions @@ -1795,8 +1790,8 @@ struct is_aged_container< template void swap( - beast::detail::aged_ordered_container& lhs, - beast::detail::aged_ordered_container& + beast::detail::AgedOrderedContainer& lhs, + beast::detail::AgedOrderedContainer& rhs) noexcept { lhs.swap(rhs); @@ -1815,7 +1810,7 @@ template < class Period> std::size_t expire( - detail::aged_ordered_container& c, + detail::AgedOrderedContainer& c, std::chrono::duration const& age) { std::size_t n(0); diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 7fe3a8b38a..78a2a5a32d 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -63,10 +63,10 @@ template < class Hash = std::hash, class KeyEqual = std::equal_to, class Allocator = std::allocator, Key>>> -class aged_unordered_container +class AgedUnorderedContainer { public: - using clock_type = abstract_clock; + using clock_type = AbstractClock; using time_point = typename clock_type::time_point; using duration = typename clock_type::duration; using key_type = Key; @@ -84,39 +84,38 @@ private: static Key const& extract(value_type const& value) { - return aged_associative_container_extract_t()(value); + return AgedAssociativeContainerExtractT()(value); } // VFALCO TODO hoist to remove template argument dependencies - struct element : boost::intrusive::unordered_set_base_hook< + struct Element : boost::intrusive::unordered_set_base_hook< boost::intrusive::link_mode>, boost::intrusive::list_base_hook< boost::intrusive::link_mode> { // Stash types here so the iterator doesn't // need to see the container declaration. - struct stashed + struct Stashed { - explicit stashed() = default; + explicit Stashed() = default; - using value_type = typename aged_unordered_container::value_type; - using time_point = typename aged_unordered_container::time_point; + using value_type = typename AgedUnorderedContainer::value_type; + using time_point = typename AgedUnorderedContainer::time_point; }; - element(time_point const& when_, value_type const& value_) : value(value_), when(when_) + Element(time_point const& when, value_type const& value) : value(value), when(when) { } - element(time_point const& when_, value_type&& value_) - : value(std::move(value_)), when(when_) + Element(time_point const& when, value_type&& value) : value(std::move(value)), when(when) { } template < class... Args, class = std::enable_if_t>> - element(time_point const& when_, Args&&... args) - : value(std::forward(args)...), when(when_) + Element(time_point const& when, Args&&... args) + : value(std::forward(args)...), when(when) { } @@ -128,7 +127,7 @@ private: class ValueHash : public Hash { public: - using argument_type = element; + using argument_type = Element; using result_type = size_t; ValueHash() = default; @@ -138,19 +137,19 @@ private: } std::size_t - operator()(element const& e) const + operator()(Element const& e) const { return Hash::operator()(extract(e.value)); } Hash& - hash_function() + hashFunction() { return *this; } [[nodiscard]] Hash const& - hash_function() const + hashFunction() const { return *this; } @@ -162,7 +161,7 @@ private: { public: using first_argument_type = Key; - using second_argument_type = element; + using second_argument_type = Element; using result_type = bool; KeyValueEqual() = default; @@ -172,49 +171,49 @@ private: } bool - operator()(Key const& k, element const& e) const + operator()(Key const& k, Element const& e) const { return KeyEqual::operator()(k, extract(e.value)); } bool - operator()(element const& e, Key const& k) const + operator()(Element const& e, Key const& k) const { return KeyEqual::operator()(extract(e.value), k); } bool - operator()(element const& lhs, element const& rhs) const + operator()(Element const& lhs, Element const& rhs) const { return KeyEqual::operator()(extract(lhs.value), extract(rhs.value)); } KeyEqual& - key_eq() + keyEq() { return *this; } [[nodiscard]] KeyEqual const& - key_eq() const + keyEq() const { return *this; } }; using list_type = typename boost::intrusive:: - make_list>::type; + make_list>::type; using cont_type = std::conditional_t< IsMulti, typename boost::intrusive::make_unordered_multiset< - element, + Element, boost::intrusive::constant_time_size, boost::intrusive::hash, boost::intrusive::equal, boost::intrusive::cache_begin>::type, typename boost::intrusive::make_unordered_set< - element, + Element, boost::intrusive::constant_time_size, boost::intrusive::hash, boost::intrusive::equal, @@ -224,182 +223,181 @@ private: using bucket_traits = typename cont_type::bucket_traits; using ElementAllocator = - typename std::allocator_traits::template rebind_alloc; + typename std::allocator_traits::template rebind_alloc; using ElementAllocatorTraits = std::allocator_traits; using BucketAllocator = - typename std::allocator_traits::template rebind_alloc; + typename std::allocator_traits::template rebind_alloc; using BucketAllocatorTraits = std::allocator_traits; - class config_t : private ValueHash, - private KeyValueEqual, - private beast::detail::empty_base_optimization + class ConfigT : private ValueHash, + private KeyValueEqual, + private beast::detail::EmptyBaseOptimization { public: - explicit config_t(clock_type& clock_) : clock(clock_) + explicit ConfigT(clock_type& clock) : clock(clock) { } - config_t(clock_type& clock_, Hash const& hash) : ValueHash(hash), clock(clock_) + ConfigT(clock_type& clock, Hash const& hash) : ValueHash(hash), clock(clock) { } - config_t(clock_type& clock_, KeyEqual const& keyEqual) - : KeyValueEqual(keyEqual), clock(clock_) + ConfigT(clock_type& clock, KeyEqual const& keyEqual) : KeyValueEqual(keyEqual), clock(clock) { } - config_t(clock_type& clock_, Allocator const& alloc_) - : beast::detail::empty_base_optimization(alloc_), clock(clock_) + ConfigT(clock_type& clock, Allocator const& alloc) + : beast::detail::EmptyBaseOptimization(alloc), clock(clock) { } - config_t(clock_type& clock_, Hash const& hash, KeyEqual const& keyEqual) - : ValueHash(hash), KeyValueEqual(keyEqual), clock(clock_) + ConfigT(clock_type& clock, Hash const& hash, KeyEqual const& keyEqual) + : ValueHash(hash), KeyValueEqual(keyEqual), clock(clock) { } - config_t(clock_type& clock_, Hash const& hash, Allocator const& alloc_) + ConfigT(clock_type& clock, Hash const& hash, Allocator const& alloc) : ValueHash(hash) - , beast::detail::empty_base_optimization(alloc_) - , clock(clock_) + , beast::detail::EmptyBaseOptimization(alloc) + , clock(clock) { } - config_t(clock_type& clock_, KeyEqual const& keyEqual, Allocator const& alloc_) + ConfigT(clock_type& clock, KeyEqual const& keyEqual, Allocator const& alloc) : KeyValueEqual(keyEqual) - , beast::detail::empty_base_optimization(alloc_) - , clock(clock_) + , beast::detail::EmptyBaseOptimization(alloc) + , clock(clock) { } - config_t( - clock_type& clock_, + ConfigT( + clock_type& clock, Hash const& hash, KeyEqual const& keyEqual, - Allocator const& alloc_) + Allocator const& alloc) : ValueHash(hash) , KeyValueEqual(keyEqual) - , beast::detail::empty_base_optimization(alloc_) - , clock(clock_) + , beast::detail::EmptyBaseOptimization(alloc) + , clock(clock) { } - config_t(config_t const& other) - : ValueHash(other.hash_function()) - , KeyValueEqual(other.key_eq()) - , beast::detail::empty_base_optimization( + ConfigT(ConfigT const& other) + : ValueHash(other.hashFunction()) + , KeyValueEqual(other.keyEq()) + , beast::detail::EmptyBaseOptimization( ElementAllocatorTraits::select_on_container_copy_construction(other.alloc())) , clock(other.clock) { } - config_t(config_t const& other, Allocator const& alloc) - : ValueHash(other.hash_function()) - , KeyValueEqual(other.key_eq()) - , beast::detail::empty_base_optimization(alloc) + ConfigT(ConfigT const& other, Allocator const& alloc) + : ValueHash(other.hashFunction()) + , KeyValueEqual(other.keyEq()) + , beast::detail::EmptyBaseOptimization(alloc) , clock(other.clock) { } - config_t(config_t&& other) - : ValueHash(std::move(other.hash_function())) - , KeyValueEqual(std::move(other.key_eq())) - , beast::detail::empty_base_optimization(std::move(other.alloc())) + ConfigT(ConfigT&& other) + : ValueHash(std::move(other.hashFunction())) + , KeyValueEqual(std::move(other.keyEq())) + , beast::detail::EmptyBaseOptimization(std::move(other.alloc())) , clock(other.clock) { } - config_t( - config_t&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) + ConfigT( + ConfigT&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) Allocator const& alloc) - : ValueHash(std::move(other.hash_function())) - , KeyValueEqual(std::move(other.key_eq())) - , beast::detail::empty_base_optimization(alloc) + : ValueHash(std::move(other.hashFunction())) + , KeyValueEqual(std::move(other.keyEq())) + , beast::detail::EmptyBaseOptimization(alloc) , clock(other.clock) { } - config_t& - operator=(config_t const& other) + ConfigT& + operator=(ConfigT const& other) { - hash_function() = other.hash_function(); - key_eq() = other.key_eq(); + hashFunction() = other.hashFunction(); + keyEq() = other.keyEq(); alloc() = other.alloc(); clock = other.clock; return *this; } - config_t& - operator=(config_t&& other) + ConfigT& + operator=(ConfigT&& other) { - hash_function() = std::move(other.hash_function()); - key_eq() = std::move(other.key_eq()); + hashFunction() = std::move(other.hashFunction()); + keyEq() = std::move(other.keyEq()); alloc() = std::move(other.alloc()); clock = other.clock; return *this; } ValueHash& - value_hash() + valueHash() { return *this; } [[nodiscard]] ValueHash const& - value_hash() const + valueHash() const { return *this; } Hash& - hash_function() + hashFunction() { - return ValueHash::hash_function(); + return ValueHash::hashFunction(); } [[nodiscard]] Hash const& - hash_function() const + hashFunction() const { - return ValueHash::hash_function(); + return ValueHash::hashFunction(); } KeyValueEqual& - key_value_equal() + keyValueEqual() { return *this; } [[nodiscard]] KeyValueEqual const& - key_value_equal() const + keyValueEqual() const { return *this; } KeyEqual& - key_eq() + keyEq() { - return key_value_equal().key_eq(); + return keyValueEqual().keyEq(); } [[nodiscard]] KeyEqual const& - key_eq() const + keyEq() const { - return key_value_equal().key_eq(); + return keyValueEqual().keyEq(); } ElementAllocator& alloc() { - return beast::detail::empty_base_optimization::member(); + return beast::detail::EmptyBaseOptimization::member(); } [[nodiscard]] ElementAllocator const& alloc() const { - return beast::detail::empty_base_optimization::member(); + return beast::detail::EmptyBaseOptimization::member(); } std::reference_wrapper clock; @@ -412,43 +410,43 @@ private: bucket_type, typename std::allocator_traits::template rebind_alloc>; - Buckets() : m_max_load_factor(1.f), m_vec() + Buckets() : maxLoadFactor_(1.f), vec_() { - m_vec.resize(cont_type::suggested_upper_bucket_count(0)); + vec_.resize(cont_type::suggested_upper_bucket_count(0)); } - Buckets(Allocator const& alloc) : m_max_load_factor(1.f), m_vec(alloc) + Buckets(Allocator const& alloc) : maxLoadFactor_(1.f), vec_(alloc) { - m_vec.resize(cont_type::suggested_upper_bucket_count(0)); + vec_.resize(cont_type::suggested_upper_bucket_count(0)); } operator bucket_traits() { - return bucket_traits(&m_vec[0], m_vec.size()); + return bucket_traits(&vec_[0], vec_.size()); } void clear() { - m_vec.clear(); + vec_.clear(); } [[nodiscard]] size_type - max_bucket_count() const + maxBucketCount() const { - return m_vec.max_size(); + return vec_.max_size(); } float& - max_load_factor() + maxLoadFactor() { - return m_max_load_factor; + return maxLoadFactor_; } [[nodiscard]] float const& - max_load_factor() const + maxLoadFactor() const { - return m_max_load_factor; + return maxLoadFactor_; } // count is the number of buckets @@ -456,17 +454,17 @@ private: void rehash(size_type count, Container& c) { - size_type const size(m_vec.size()); + size_type const size(vec_.size()); if (count == size) return; - if (count > m_vec.capacity()) + if (count > vec_.capacity()) { // Need two vectors otherwise we // will destroy non-empty buckets. - vec_type vec(m_vec.get_allocator()); - std::swap(m_vec, vec); - m_vec.resize(count); - c.rehash(bucket_traits(&m_vec[0], m_vec.size())); + vec_type vec(vec_.get_allocator()); + std::swap(vec_, vec); + vec_.resize(count); + c.rehash(bucket_traits(&vec_[0], vec_.size())); return; } // Rehash in place. @@ -474,14 +472,14 @@ private: { // This should not reallocate since // we checked capacity earlier. - m_vec.resize(count); - c.rehash(bucket_traits(&m_vec[0], count)); + vec_.resize(count); + c.rehash(bucket_traits(&vec_[0], count)); return; } // Resize must happen after rehash otherwise // we might destroy non-empty buckets. - c.rehash(bucket_traits(&m_vec[0], count)); - m_vec.resize(count); + c.rehash(bucket_traits(&vec_[0], count)); + vec_.resize(count); } // Resize the buckets to accommodate at least n items. @@ -494,48 +492,48 @@ private: } private: - float m_max_load_factor; - vec_type m_vec; + float maxLoadFactor_; + vec_type vec_; }; template - element* - new_element(Args&&... args) + Element* + newElement(Args&&... args) { struct Deleter { - std::reference_wrapper a_; - Deleter(ElementAllocator& a) : a_(a) + std::reference_wrapper a; + Deleter(ElementAllocator& a) : a(a) { } void - operator()(element* p) + operator()(Element* p) { - ElementAllocatorTraits::deallocate(a_.get(), p, 1); + ElementAllocatorTraits::deallocate(a.get(), p, 1); } }; - std::unique_ptr p( - ElementAllocatorTraits::allocate(m_config.alloc(), 1), Deleter(m_config.alloc())); + std::unique_ptr p( + ElementAllocatorTraits::allocate(config_.alloc(), 1), Deleter(config_.alloc())); ElementAllocatorTraits::construct( - m_config.alloc(), p.get(), clock().now(), std::forward(args)...); + config_.alloc(), p.get(), clock().now(), std::forward(args)...); return p.release(); } void - delete_element(element const* p) + deleteElement(Element const* p) { - ElementAllocatorTraits::destroy(m_config.alloc(), p); - ElementAllocatorTraits::deallocate(m_config.alloc(), const_cast(p), 1); + ElementAllocatorTraits::destroy(config_.alloc(), p); + ElementAllocatorTraits::deallocate(config_.alloc(), const_cast(p), 1); } void - unlink_and_delete_element(element const* p) + unlinkAndDeleteElement(Element const* p) { - chronological.list.erase(chronological.list.iterator_to(*p)); - m_cont.erase(m_cont.iterator_to(*p)); - delete_element(p); + chronological.list_.erase(chronological.list_.iterator_to(*p)); + cont_.erase(cont_.iterator_to(*p)); + deleteElement(p); } public: @@ -549,14 +547,13 @@ public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = beast::detail::aged_container_iterator; - using const_iterator = - beast::detail::aged_container_iterator; + using iterator = beast::detail::AgedContainerIterator; + using const_iterator = beast::detail::AgedContainerIterator; using local_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using const_local_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; //-------------------------------------------------------------------------- // @@ -567,117 +564,116 @@ public: // //-------------------------------------------------------------------------- - class chronological_t + class ChronologicalT { public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = - beast::detail::aged_container_iterator; + using iterator = beast::detail::AgedContainerIterator; using const_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; using const_reverse_iterator = - beast::detail::aged_container_iterator; + beast::detail::AgedContainerIterator; iterator begin() { - return iterator(list.begin()); + return iterator(list_.begin()); } const_iterator begin() const { - return const_iterator(list.begin()); + return const_iterator(list_.begin()); } const_iterator cbegin() const { - return const_iterator(list.begin()); + return const_iterator(list_.begin()); } iterator end() { - return iterator(list.end()); + return iterator(list_.end()); } const_iterator end() const { - return const_iterator(list.end()); + return const_iterator(list_.end()); } const_iterator cend() const { - return const_iterator(list.end()); + return const_iterator(list_.end()); } reverse_iterator rbegin() { - return reverse_iterator(list.rbegin()); + return reverse_iterator(list_.rbegin()); } const_reverse_iterator rbegin() const { - return const_reverse_iterator(list.rbegin()); + return const_reverse_iterator(list_.rbegin()); } const_reverse_iterator crbegin() const { - return const_reverse_iterator(list.rbegin()); + return const_reverse_iterator(list_.rbegin()); } reverse_iterator rend() { - return reverse_iterator(list.rend()); + return reverse_iterator(list_.rend()); } const_reverse_iterator rend() const { - return const_reverse_iterator(list.rend()); + return const_reverse_iterator(list_.rend()); } const_reverse_iterator crend() const { - return const_reverse_iterator(list.rend()); + return const_reverse_iterator(list_.rend()); } iterator - iterator_to(value_type& value) + iteratorTo(value_type& value) { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return list.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return list_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } const_iterator - iterator_to(value_type const& value) const + iteratorTo(value_type const& value) const { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return list.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return list_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } - chronological_t(chronological_t const&) = delete; - chronological_t(chronological_t&&) = delete; - chronological_t() = default; + ChronologicalT(ChronologicalT const&) = delete; + ChronologicalT(ChronologicalT&&) = delete; + ChronologicalT() = default; private: - friend class aged_unordered_container; - list_type mutable list; + friend class AgedUnorderedContainer; + list_type mutable list_; } chronological; //-------------------------------------------------------------------------- @@ -686,58 +682,50 @@ public: // //-------------------------------------------------------------------------- - aged_unordered_container() = delete; + AgedUnorderedContainer() = delete; - explicit aged_unordered_container(clock_type& clock); + explicit AgedUnorderedContainer(clock_type& clock); - aged_unordered_container(clock_type& clock, Hash const& hash); + AgedUnorderedContainer(clock_type& clock, Hash const& hash); - aged_unordered_container(clock_type& clock, KeyEqual const& key_eq); + AgedUnorderedContainer(clock_type& clock, KeyEqual const& keyEq); - aged_unordered_container(clock_type& clock, Allocator const& alloc); + AgedUnorderedContainer(clock_type& clock, Allocator const& alloc); - aged_unordered_container(clock_type& clock, Hash const& hash, KeyEqual const& key_eq); + AgedUnorderedContainer(clock_type& clock, Hash const& hash, KeyEqual const& keyEq); - aged_unordered_container(clock_type& clock, Hash const& hash, Allocator const& alloc); + AgedUnorderedContainer(clock_type& clock, Hash const& hash, Allocator const& alloc); - aged_unordered_container(clock_type& clock, KeyEqual const& key_eq, Allocator const& alloc); + AgedUnorderedContainer(clock_type& clock, KeyEqual const& keyEq, Allocator const& alloc); - aged_unordered_container( + AgedUnorderedContainer( clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc); template - aged_unordered_container(InputIt first, InputIt last, clock_type& clock); + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock); template - aged_unordered_container(InputIt first, InputIt last, clock_type& clock, Hash const& hash); + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, Hash const& hash); template - aged_unordered_container( - InputIt first, - InputIt last, - clock_type& clock, - KeyEqual const& key_eq); + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, KeyEqual const& keyEq); template - aged_unordered_container( - InputIt first, - InputIt last, - clock_type& clock, - Allocator const& alloc); + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, Allocator const& alloc); template - aged_unordered_container( + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq); + KeyEqual const& keyEq); template - aged_unordered_container( + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, @@ -745,102 +733,102 @@ public: Allocator const& alloc); template - aged_unordered_container( + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc); template - aged_unordered_container( + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc); - aged_unordered_container(aged_unordered_container const& other); + AgedUnorderedContainer(AgedUnorderedContainer const& other); - aged_unordered_container(aged_unordered_container const& other, Allocator const& alloc); + AgedUnorderedContainer(AgedUnorderedContainer const& other, Allocator const& alloc); - aged_unordered_container(aged_unordered_container&& other); + AgedUnorderedContainer(AgedUnorderedContainer&& other); - aged_unordered_container( + AgedUnorderedContainer( // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) - aged_unordered_container&& other, + AgedUnorderedContainer&& other, Allocator const& alloc); - aged_unordered_container(std::initializer_list init, clock_type& clock); + AgedUnorderedContainer(std::initializer_list init, clock_type& clock); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, - KeyEqual const& key_eq); + KeyEqual const& keyEq); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Allocator const& alloc); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq); + KeyEqual const& keyEq); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, Allocator const& alloc); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc); - aged_unordered_container( + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc); - ~aged_unordered_container(); + ~AgedUnorderedContainer(); - aged_unordered_container& - operator=(aged_unordered_container const& other); + AgedUnorderedContainer& + operator=(AgedUnorderedContainer const& other); - aged_unordered_container& - operator=(aged_unordered_container&& other); + AgedUnorderedContainer& + operator=(AgedUnorderedContainer&& other); - aged_unordered_container& + AgedUnorderedContainer& operator=(std::initializer_list init); allocator_type - get_allocator() const + getAllocator() const { - return m_config.alloc(); + return config_.alloc(); } clock_type& clock() { - return m_config.clock; + return config_.clock; } clock_type const& clock() const { - return m_config.clock; + return config_.clock; } //-------------------------------------------------------------------------- @@ -851,31 +839,31 @@ public: template < class K, - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& at(K const& k); template < class K, - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> typename std::conditional::type const& at(K const& k) const; template < - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& operator[](Key const& key); template < - bool maybe_multi = IsMulti, - bool maybe_map = IsMap, - class = std::enable_if_t> + bool MaybeMulti = IsMulti, + bool MaybeMap = IsMap, + class = std::enable_if_t> std::conditional_t& operator[](Key&& key); @@ -888,55 +876,55 @@ public: iterator begin() { - return iterator(m_cont.begin()); + return iterator(cont_.begin()); } const_iterator begin() const { - return const_iterator(m_cont.begin()); + return const_iterator(cont_.begin()); } const_iterator cbegin() const { - return const_iterator(m_cont.begin()); + return const_iterator(cont_.begin()); } iterator end() { - return iterator(m_cont.end()); + return iterator(cont_.end()); } const_iterator end() const { - return const_iterator(m_cont.end()); + return const_iterator(cont_.end()); } const_iterator cend() const { - return const_iterator(m_cont.end()); + return const_iterator(cont_.end()); } iterator - iterator_to(value_type& value) + iteratorTo(value_type& value) { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return m_cont.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return cont_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } const_iterator - iterator_to(value_type const& value) const + iteratorTo(value_type const& value) const { - static_assert(std::is_standard_layout_v, "must be standard layout"); - return m_cont.iterator_to(*reinterpret_cast( + static_assert(std::is_standard_layout_v, "must be standard layout"); + return cont_.iterator_to(*reinterpret_cast( reinterpret_cast(&value) - - ((std::size_t)std::addressof(((element*)0)->member)))); + ((std::size_t)std::addressof(((Element*)0)->member)))); } //-------------------------------------------------------------------------- @@ -948,19 +936,19 @@ public: bool empty() const noexcept { - return m_cont.empty(); + return cont_.empty(); } size_type size() const noexcept { - return m_cont.size(); + return cont_.size(); } size_type - max_size() const noexcept + maxSize() const noexcept { - return m_config.max_size(); + return config_.max_size(); } //-------------------------------------------------------------------------- @@ -973,29 +961,29 @@ public: clear(); // map, set - template + template auto - insert(value_type const& value) -> std::enable_if_t>; + insert(value_type const& value) -> std::enable_if_t>; // multimap, multiset - template + template auto - insert(value_type const& value) -> std::enable_if_t; + insert(value_type const& value) -> std::enable_if_t; // map, set - template + template auto insert(value_type&& value) - -> std::enable_if_t>; + -> std::enable_if_t>; // multimap, multiset - template + template auto - insert(value_type&& value) -> std::enable_if_t; + insert(value_type&& value) -> std::enable_if_t; // map, set - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type const& value) { // Hint is ignored but we provide the interface so @@ -1004,8 +992,8 @@ public: } // multimap, multiset - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type const& value) { // VFALCO TODO The hint could be used to let @@ -1014,8 +1002,8 @@ public: } // map, set - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type&& value) { // Hint is ignored but we provide the interface so @@ -1024,8 +1012,8 @@ public: } // multimap, multiset - template - std::enable_if_t + template + std::enable_if_t insert(const_iterator /*hint*/, value_type&& value) { // VFALCO TODO The hint could be used to let @@ -1034,9 +1022,9 @@ public: } // map, multimap - template + template std::enable_if_t< - maybe_map && std::is_constructible_v, + MaybeMap && std::is_constructible_v, std::conditional_t>> insert(P&& value) { @@ -1044,13 +1032,13 @@ public: } // map, multimap - template + template std::enable_if_t< - maybe_map && std::is_constructible_v, + MaybeMap && std::is_constructible_v, std::conditional_t>> insert(const_iterator hint, P&& value) { - return emplace_hint(hint, std::forward

(value)); + return emplaceHint(hint, std::forward

(value)); } template @@ -1067,51 +1055,51 @@ public: } // set, map - template + template auto - emplace(Args&&... args) -> std::enable_if_t>; + emplace(Args&&... args) -> std::enable_if_t>; // multiset, multimap - template + template auto - emplace(Args&&... args) -> std::enable_if_t; + emplace(Args&&... args) -> std::enable_if_t; // set, map - template + template auto - emplace_hint(const_iterator /*hint*/, Args&&... args) - -> std::enable_if_t>; + emplaceHint(const_iterator /*hint*/, Args&&... args) + -> std::enable_if_t>; // multiset, multimap - template - std::enable_if_t - emplace_hint(const_iterator /*hint*/, Args&&... args) + template + std::enable_if_t + emplaceHint(const_iterator /*hint*/, Args&&... args) { // VFALCO TODO The hint could be used for multi, to let // the client order equal ranges - return emplace(std::forward(args)...); + return emplace(std::forward(args)...); } - template - beast::detail::aged_container_iterator - erase(beast::detail::aged_container_iterator pos); + template + beast::detail::AgedContainerIterator + erase(beast::detail::AgedContainerIterator pos); - template - beast::detail::aged_container_iterator + template + beast::detail::AgedContainerIterator erase( - beast::detail::aged_container_iterator first, - beast::detail::aged_container_iterator last); + beast::detail::AgedContainerIterator first, + beast::detail::AgedContainerIterator last); template auto erase(K const& k) -> size_type; void - swap(aged_unordered_container& other) noexcept; + swap(AgedUnorderedContainer& other) noexcept; - template + template void - touch(beast::detail::aged_container_iterator pos) + touch(beast::detail::AgedContainerIterator pos) { touch(pos, clock().now()); } @@ -1131,8 +1119,8 @@ public: size_type count(K const& k) const { - return m_cont.count( - k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal())); + return cont_.count( + k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual())); } // VFALCO TODO Respect is_transparent (c++14) @@ -1140,8 +1128,8 @@ public: iterator find(K const& k) { - return iterator(m_cont.find( - k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); + return iterator( + cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); } // VFALCO TODO Respect is_transparent (c++14) @@ -1149,27 +1137,27 @@ public: const_iterator find(K const& k) const { - return const_iterator(m_cont.find( - k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); + return const_iterator( + cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); } // VFALCO TODO Respect is_transparent (c++14) template std::pair - equal_range(K const& k) + equalRange(K const& k) { - auto const r(m_cont.equal_range( - k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); + auto const r(cont_.equal_range( + k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); return std::make_pair(iterator(r.first), iterator(r.second)); } // VFALCO TODO Respect is_transparent (c++14) template std::pair - equal_range(K const& k) const + equalRange(K const& k) const { - auto const r(m_cont.equal_range( - k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); + auto const r(cont_.equal_range( + k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); return std::make_pair(const_iterator(r.first), const_iterator(r.second)); } @@ -1182,65 +1170,65 @@ public: local_iterator begin(size_type n) { - return local_iterator(m_cont.begin(n)); + return local_iterator(cont_.begin(n)); } const_local_iterator begin(size_type n) const { - return const_local_iterator(m_cont.begin(n)); + return const_local_iterator(cont_.begin(n)); } const_local_iterator cbegin(size_type n) const { - return const_local_iterator(m_cont.begin(n)); + return const_local_iterator(cont_.begin(n)); } local_iterator end(size_type n) { - return local_iterator(m_cont.end(n)); + return local_iterator(cont_.end(n)); } const_local_iterator end(size_type n) const { - return const_local_iterator(m_cont.end(n)); + return const_local_iterator(cont_.end(n)); } const_local_iterator cend(size_type n) const { - return const_local_iterator(m_cont.end(n)); + return const_local_iterator(cont_.end(n)); } size_type - bucket_count() const + bucketCount() const { - return m_cont.bucket_count(); + return cont_.bucket_count(); } size_type - max_bucket_count() const + maxBucketCount() const { - return m_buck.max_bucket_count(); + return buck_.maxBucketCount(); } size_type - bucket_size(size_type n) const + bucketSize(size_type n) const { - return m_cont.bucket_size(n); + return cont_.bucket_size(n); } size_type bucket(Key const& k) const { XRPL_ASSERT( - bucket_count() != 0, - "beast::detail::aged_unordered_container::bucket : nonzero bucket " + bucketCount() != 0, + "beast::detail::AgedUnorderedContainer::bucket : nonzero bucket " "count"); - return m_cont.bucket(k, std::cref(m_config.hash_function())); + return cont_.bucket(k, std::cref(config_.hashFunction())); } //-------------------------------------------------------------------------- @@ -1250,34 +1238,34 @@ public: //-------------------------------------------------------------------------- float - load_factor() const + loadFactor() const { - return size() / static_cast(m_cont.bucket_count()); + return size() / static_cast(cont_.bucket_count()); } float - max_load_factor() const + maxLoadFactor() const { - return m_buck.max_load_factor(); + return buck_.maxLoadFactor(); } void - max_load_factor(float ml) + maxLoadFactor(float ml) { - m_buck.max_load_factor() = std::max(ml, m_buck.max_load_factor()); + buck_.maxLoadFactor() = std::max(ml, buck_.maxLoadFactor()); } void rehash(size_type count) { - count = std::max(count, size_type(size() / max_load_factor())); - m_buck.rehash(count, m_cont); + count = std::max(count, size_type(size() / maxLoadFactor())); + buck_.rehash(count, cont_); } void reserve(size_type count) { - rehash(std::ceil(count / max_load_factor())); + rehash(std::ceil(count / maxLoadFactor())); } //-------------------------------------------------------------------------- @@ -1287,15 +1275,15 @@ public: //-------------------------------------------------------------------------- hasher const& - hash_function() const + hashFunction() const { - return m_config.hash_function(); + return config_.hashFunction(); } key_equal const& - key_eq() const + keyEq() const { - return m_config.key_eq(); + return config_.keyEq(); } //-------------------------------------------------------------------------- @@ -1315,9 +1303,9 @@ public: class OtherDuration, class OtherHash, class OtherAllocator, - bool maybe_multi = IsMulti> - std::enable_if_t - operator==(aged_unordered_container< + bool MaybeMulti = IsMulti> + std::enable_if_t + operator==(AgedUnorderedContainer< false, OtherIsMap, OtherKey, @@ -1334,9 +1322,9 @@ public: class OtherDuration, class OtherHash, class OtherAllocator, - bool maybe_multi = IsMulti> - std::enable_if_t - operator==(aged_unordered_container< + bool MaybeMulti = IsMulti> + std::enable_if_t + operator==(AgedUnorderedContainer< true, OtherIsMap, OtherKey, @@ -1355,7 +1343,7 @@ public: class OtherHash, class OtherAllocator> bool - operator!=(aged_unordered_container< + operator!=(AgedUnorderedContainer< OtherIsMulti, OtherIsMap, OtherKey, @@ -1370,39 +1358,39 @@ public: private: bool - would_exceed(size_type additional) const + wouldExceed(size_type additional) const { - return size() + additional > bucket_count() * max_load_factor(); + return size() + additional > bucketCount() * maxLoadFactor(); } void - maybe_rehash(size_type additional) + maybeRehash(size_type additional) { - if (would_exceed(additional)) - m_buck.resize(size() + additional, m_cont); + if (wouldExceed(additional)) + buck_.resize(size() + additional, cont_); XRPL_ASSERT( - load_factor() <= max_load_factor(), - "beast::detail::aged_unordered_container::maybe_rehash : maximum " + loadFactor() <= maxLoadFactor(), + "beast::detail::AgedUnorderedContainer::maybe_rehash : maximum " "load factor"); } // map, set - template + template auto - insert_unchecked(value_type const& value) - -> std::enable_if_t>; + insertUnchecked(value_type const& value) + -> std::enable_if_t>; // multimap, multiset - template + template auto - insert_unchecked(value_type const& value) -> std::enable_if_t; + insertUnchecked(value_type const& value) -> std::enable_if_t; template void - insert_unchecked(InputIt first, InputIt last) + insertUnchecked(InputIt first, InputIt last) { for (; first != last; ++first) - insert_unchecked(*first); + insertUnchecked(*first); } template @@ -1418,45 +1406,47 @@ private: insert(InputIt first, InputIt last, std::random_access_iterator_tag) { auto const n(std::distance(first, last)); - maybe_rehash(n); - insert_unchecked(first, last); + maybeRehash(n); + insertUnchecked(first, last); } - template + template void touch( - beast::detail::aged_container_iterator pos, + beast::detail::AgedContainerIterator pos, typename clock_type::time_point const& now) { auto& e(*pos.iterator()); e.when = now; - chronological.list.erase(chronological.list.iterator_to(e)); - chronological.list.push_back(e); + chronological.list_.erase(chronological.list_.iterator_to(e)); + chronological.list_.push_back(e); } template < - bool maybe_propagate = std::allocator_traits::propagate_on_container_swap::value> - std::enable_if_t - swap_data(aged_unordered_container& other) noexcept + bool MaybePropagate = std::allocator_traits::propagate_on_container_swap::value> + std::enable_if_t + swapData(AgedUnorderedContainer& other) noexcept { - std::swap(m_config.key_compare(), other.m_config.key_compare()); - std::swap(m_config.alloc(), other.m_config.alloc()); - std::swap(m_config.clock, other.m_config.clock); + std::swap(config_.hashFunction(), other.config_.hashFunction()); + std::swap(config_.keyEq(), other.config_.keyEq()); + std::swap(config_.alloc(), other.config_.alloc()); + std::swap(config_.clock, other.config_.clock); } template < - bool maybe_propagate = std::allocator_traits::propagate_on_container_swap::value> - std::enable_if_t - swap_data(aged_unordered_container& other) noexcept + bool MaybePropagate = std::allocator_traits::propagate_on_container_swap::value> + std::enable_if_t + swapData(AgedUnorderedContainer& other) noexcept { - std::swap(m_config.key_compare(), other.m_config.key_compare()); - std::swap(m_config.clock, other.m_config.clock); + std::swap(config_.hashFunction(), other.config_.hashFunction()); + std::swap(config_.keyEq(), other.config_.keyEq()); + std::swap(config_.clock, other.config_.clock); } private: - config_t m_config; - Buckets m_buck; - cont_type mutable m_cont; + ConfigT config_; + Buckets buck_; + cont_type mutable cont_; }; //------------------------------------------------------------------------------ @@ -1470,10 +1460,10 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock) - : m_config(clock) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock) + : config_(clock) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1486,10 +1476,10 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, Hash const& hash) - : m_config(clock, hash) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, Hash const& hash) + : config_(clock, hash) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1502,10 +1492,10 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, KeyEqual const& key_eq) - : m_config(clock, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, KeyEqual const& keyEq) + : config_(clock, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1518,11 +1508,11 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, Allocator const& alloc) + : config_(clock, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1535,10 +1525,10 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, Hash const& hash, KeyEqual const& key_eq) - : m_config(clock, hash, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, Hash const& hash, KeyEqual const& keyEq) + : config_(clock, hash, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1551,11 +1541,11 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, Hash const& hash, Allocator const& alloc) - : m_config(clock, hash, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, Hash const& hash, Allocator const& alloc) + : config_(clock, hash, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1568,11 +1558,11 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(clock_type& clock, KeyEqual const& key_eq, Allocator const& alloc) - : m_config(clock, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(clock_type& clock, KeyEqual const& keyEq, Allocator const& alloc) + : config_(clock, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1585,15 +1575,15 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc) - : m_config(clock, hash, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { } @@ -1607,10 +1597,10 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container(InputIt first, InputIt last, clock_type& clock) - : m_config(clock) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock) + : config_(clock) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1625,10 +1615,10 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container(InputIt first, InputIt last, clock_type& clock, Hash const& hash) - : m_config(clock, hash) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, Hash const& hash) + : config_(clock, hash) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1643,10 +1633,10 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container(InputIt first, InputIt last, clock_type& clock, KeyEqual const& key_eq) - : m_config(clock, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, KeyEqual const& keyEq) + : config_(clock, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1661,11 +1651,11 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container(InputIt first, InputIt last, clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(InputIt first, InputIt last, clock_type& clock, Allocator const& alloc) + : config_(clock, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1680,15 +1670,15 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq) - : m_config(clock, hash, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + KeyEqual const& keyEq) + : config_(clock, hash, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1703,16 +1693,16 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, Hash const& hash, Allocator const& alloc) - : m_config(clock, hash, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1727,16 +1717,16 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc) - : m_config(clock, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1751,17 +1741,17 @@ template < class KeyEqual, class Allocator> template -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( InputIt first, InputIt last, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc) - : m_config(clock, hash, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(first, last); } @@ -1775,11 +1765,11 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(aged_unordered_container const& other) - : m_config(other.m_config) - , m_buck(m_config.alloc()) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(AgedUnorderedContainer const& other) + : config_(other.config_) + , buck_(config_.alloc()) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(other.cbegin(), other.cend()); } @@ -1793,11 +1783,11 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(aged_unordered_container const& other, Allocator const& alloc) - : m_config(other.m_config, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(AgedUnorderedContainer const& other, Allocator const& alloc) + : config_(other.config_, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(other.cbegin(), other.cend()); } @@ -1811,13 +1801,13 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(aged_unordered_container&& other) - : m_config(std::move(other.m_config)) - , m_buck(std::move(other.m_buck)) - , m_cont(std::move(other.m_cont)) +AgedUnorderedContainer:: + AgedUnorderedContainer(AgedUnorderedContainer&& other) + : config_(std::move(other.config_)) + , buck_(std::move(other.buck_)) + , cont_(std::move(other.cont_)) { - chronological.list = std::move(other.chronological.list); + chronological.list_ = std::move(other.chronological.list_); } template < @@ -1829,14 +1819,14 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) - aged_unordered_container&& other, + AgedUnorderedContainer&& other, Allocator const& alloc) - : m_config(std::move(other.m_config), alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(std::move(other.config_), alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(other.cbegin(), other.cend()); other.clear(); @@ -1851,10 +1841,10 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container(std::initializer_list init, clock_type& clock) - : m_config(clock) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) +AgedUnorderedContainer:: + AgedUnorderedContainer(std::initializer_list init, clock_type& clock) + : config_(clock) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1868,13 +1858,13 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash) - : m_config(clock, hash) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1888,13 +1878,13 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, - KeyEqual const& key_eq) - : m_config(clock, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + KeyEqual const& keyEq) + : config_(clock, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1908,14 +1898,14 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Allocator const& alloc) - : m_config(clock, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1929,14 +1919,14 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq) - : m_config(clock, hash, key_eq) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + KeyEqual const& keyEq) + : config_(clock, hash, keyEq) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1950,15 +1940,15 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, Allocator const& alloc) - : m_config(clock, hash, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1972,15 +1962,15 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc) - : m_config(clock, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -1994,16 +1984,16 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - aged_unordered_container( +AgedUnorderedContainer:: + AgedUnorderedContainer( std::initializer_list init, clock_type& clock, Hash const& hash, - KeyEqual const& key_eq, + KeyEqual const& keyEq, Allocator const& alloc) - : m_config(clock, hash, key_eq, alloc) - , m_buck(alloc) - , m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal())) + : config_(clock, hash, keyEq, alloc) + , buck_(alloc) + , cont_(buck_, std::cref(config_.valueHash()), std::cref(config_.keyValueEqual())) { insert(init.begin(), init.end()); } @@ -2017,8 +2007,8 @@ template < class Hash, class KeyEqual, class Allocator> -aged_unordered_container:: - ~aged_unordered_container() +AgedUnorderedContainer:: + ~AgedUnorderedContainer() { clear(); } @@ -2033,17 +2023,17 @@ template < class KeyEqual, class Allocator> auto -aged_unordered_container::operator=( - aged_unordered_container const& other) -> aged_unordered_container& +AgedUnorderedContainer::operator=( + AgedUnorderedContainer const& other) -> AgedUnorderedContainer& { if (this != &other) { size_type const n(other.size()); clear(); - m_config = other.m_config; - m_buck = Buckets(m_config.alloc()); - maybe_rehash(n); - insert_unchecked(other.begin(), other.end()); + config_ = other.config_; + buck_ = Buckets(config_.alloc()); + maybeRehash(n); + insertUnchecked(other.begin(), other.end()); } return *this; } @@ -2058,15 +2048,15 @@ template < class KeyEqual, class Allocator> auto -aged_unordered_container::operator=( - aged_unordered_container&& other) -> aged_unordered_container& +AgedUnorderedContainer::operator=( + AgedUnorderedContainer&& other) -> AgedUnorderedContainer& { size_type const n(other.size()); clear(); - m_config = std::move(other.m_config); - m_buck = Buckets(m_config.alloc()); - maybe_rehash(n); - insert_unchecked(other.begin(), other.end()); + config_ = std::move(other.config_); + buck_ = Buckets(config_.alloc()); + maybeRehash(n); + insertUnchecked(other.begin(), other.end()); other.clear(); return *this; } @@ -2081,8 +2071,8 @@ template < class KeyEqual, class Allocator> auto -aged_unordered_container::operator=( - std::initializer_list init) -> aged_unordered_container& +AgedUnorderedContainer::operator=( + std::initializer_list init) -> AgedUnorderedContainer& { clear(); insert(init); @@ -2100,13 +2090,13 @@ template < class Hash, class KeyEqual, class Allocator> -template +template std::conditional_t& -aged_unordered_container::at(K const& k) +AgedUnorderedContainer::at(K const& k) { auto const iter( - m_cont.find(k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); - if (iter == m_cont.end()) + cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); + if (iter == cont_.end()) throw std::out_of_range("key not found"); return iter->value.second; } @@ -2120,14 +2110,14 @@ template < class Hash, class KeyEqual, class Allocator> -template +template typename std::conditional::type const& -aged_unordered_container::at( +AgedUnorderedContainer::at( K const& k) const { auto const iter( - m_cont.find(k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); - if (iter == m_cont.end()) + cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); + if (iter == cont_.end()) throw std::out_of_range("key not found"); return iter->value.second; } @@ -2141,21 +2131,21 @@ template < class Hash, class KeyEqual, class Allocator> -template +template std::conditional_t& -aged_unordered_container::operator[]( +AgedUnorderedContainer::operator[]( Key const& key) { - maybe_rehash(1); + maybeRehash(1); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - key, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()), d)); + auto const result(cont_.insert_check( + key, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()), d)); if (result.second) { - element* const p(new_element( + Element* const p(newElement( std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple())); - m_cont.insert_commit(*p, d); - chronological.list.push_back(*p); + cont_.insert_commit(*p, d); + chronological.list_.push_back(*p); return p->value.second; } return result.first->value.second; @@ -2170,23 +2160,23 @@ template < class Hash, class KeyEqual, class Allocator> -template +template std::conditional_t& -aged_unordered_container::operator[]( +AgedUnorderedContainer::operator[]( Key&& key) { - maybe_rehash(1); + maybeRehash(1); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - key, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()), d)); + auto const result(cont_.insert_check( + key, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()), d)); if (result.second) { - element* const p(new_element( + Element* const p(newElement( std::piecewise_construct, std::forward_as_tuple(std::move(key)), std::forward_as_tuple())); - m_cont.insert_commit(*p, d); - chronological.list.push_back(*p); + cont_.insert_commit(*p, d); + chronological.list_.push_back(*p); return p->value.second; } return result.first->value.second; @@ -2204,13 +2194,13 @@ template < class KeyEqual, class Allocator> void -aged_unordered_container::clear() +AgedUnorderedContainer::clear() { - for (auto iter(chronological.list.begin()); iter != chronological.list.end();) - unlink_and_delete_element(&*iter++); - chronological.list.clear(); - m_cont.clear(); - m_buck.clear(); + for (auto iter(chronological.list_.begin()); iter != chronological.list_.end();) + unlinkAndDeleteElement(&*iter++); + chronological.list_.clear(); + cont_.clear(); + buck_.clear(); } // map, set @@ -2223,23 +2213,20 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::insert( - value_type const& value) -> std::enable_if_t> +AgedUnorderedContainer::insert( + value_type const& value) -> std::enable_if_t> { - maybe_rehash(1); + maybeRehash(1); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - extract(value), - std::cref(m_config.hash_function()), - std::cref(m_config.key_value_equal()), - d)); + auto const result(cont_.insert_check( + extract(value), std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()), d)); if (result.second) { - element* const p(new_element(value)); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(value)); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } return std::make_pair(iterator(result.first), false); @@ -2255,15 +2242,15 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::insert( - value_type const& value) -> std::enable_if_t +AgedUnorderedContainer::insert( + value_type const& value) -> std::enable_if_t { - maybe_rehash(1); - element* const p(new_element(value)); - chronological.list.push_back(*p); - auto const iter(m_cont.insert(*p)); + maybeRehash(1); + Element* const p(newElement(value)); + chronological.list_.push_back(*p); + auto const iter(cont_.insert(*p)); return iterator(iter); } @@ -2277,23 +2264,20 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::insert( - value_type&& value) -> std::enable_if_t> +AgedUnorderedContainer::insert( + value_type&& value) -> std::enable_if_t> { - maybe_rehash(1); + maybeRehash(1); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - extract(value), - std::cref(m_config.hash_function()), - std::cref(m_config.key_value_equal()), - d)); + auto const result(cont_.insert_check( + extract(value), std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()), d)); if (result.second) { - element* const p(new_element(std::move(value))); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(std::move(value))); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } return std::make_pair(iterator(result.first), false); @@ -2309,15 +2293,15 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::insert( - value_type&& value) -> std::enable_if_t +AgedUnorderedContainer::insert( + value_type&& value) -> std::enable_if_t { - maybe_rehash(1); - element* const p(new_element(std::move(value))); - chronological.list.push_back(*p); - auto const iter(m_cont.insert(*p)); + maybeRehash(1); + Element* const p(newElement(std::move(value))); + chronological.list_.push_back(*p); + auto const iter(cont_.insert(*p)); return iterator(iter); } @@ -2332,22 +2316,22 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::emplace( - Args&&... args) -> std::enable_if_t> +AgedUnorderedContainer::emplace( + Args&&... args) -> std::enable_if_t> { - maybe_rehash(1); + maybeRehash(1); // VFALCO NOTE Its unfortunate that we need to // construct element here - element* const p(new_element(std::forward(args)...)); - auto const result(m_cont.insert(*p)); + Element* const p(newElement(std::forward(args)...)); + auto const result(cont_.insert(*p)); if (result.second) { - chronological.list.push_back(*p); + chronological.list_.push_back(*p); return std::make_pair(iterator(result.first), true); } - delete_element(p); + deleteElement(p); return std::make_pair(iterator(result.first), false); } #else // As original, use insert_check() / insert_commit () pair. @@ -2363,7 +2347,7 @@ template < class Allocator> template auto -aged_unordered_container::emplace( +AgedUnorderedContainer::emplace( Args&&... args) -> typename std::enable_if>::type { maybe_rehash(1); @@ -2373,8 +2357,8 @@ aged_unordered_containervalue), - std::cref(m_config.hash_function()), - std::cref(m_config.key_value_equal()), + std::cref(m_config.hashFunction()), + std::cref(m_config.keyValueEqual()), d)); if (result.second) { @@ -2397,15 +2381,15 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::emplace( - Args&&... args) -> std::enable_if_t +AgedUnorderedContainer::emplace( + Args&&... args) -> std::enable_if_t { - maybe_rehash(1); - element* const p(new_element(std::forward(args)...)); - chronological.list.push_back(*p); - auto const iter(m_cont.insert(*p)); + maybeRehash(1); + Element* const p(newElement(std::forward(args)...)); + chronological.list_.push_back(*p); + auto const iter(cont_.insert(*p)); return iterator(iter); } @@ -2419,29 +2403,29 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container::emplace_hint( +AgedUnorderedContainer::emplaceHint( const_iterator /*hint*/, - Args&&... args) -> std::enable_if_t> + Args&&... args) -> std::enable_if_t> { - maybe_rehash(1); + maybeRehash(1); // VFALCO NOTE Its unfortunate that we need to // construct element here - element* const p(new_element(std::forward(args)...)); + Element* const p(newElement(std::forward(args)...)); typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( + auto const result(cont_.insert_check( extract(p->value), - std::cref(m_config.hash_function()), - std::cref(m_config.key_value_equal()), + std::cref(config_.hashFunction()), + std::cref(config_.keyValueEqual()), d)); if (result.second) { - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } - delete_element(p); + deleteElement(p); return std::make_pair(iterator(result.first), false); } @@ -2454,13 +2438,13 @@ template < class Hash, class KeyEqual, class Allocator> -template -beast::detail::aged_container_iterator -aged_unordered_container::erase( - beast::detail::aged_container_iterator pos) +template +beast::detail::AgedContainerIterator +AgedUnorderedContainer::erase( + beast::detail::AgedContainerIterator pos) { - unlink_and_delete_element(&*((pos++).iterator())); - return beast::detail::aged_container_iterator(pos.iterator()); + unlinkAndDeleteElement(&*((pos++).iterator())); + return beast::detail::AgedContainerIterator(pos.iterator()); } template < @@ -2472,16 +2456,16 @@ template < class Hash, class KeyEqual, class Allocator> -template -beast::detail::aged_container_iterator -aged_unordered_container::erase( - beast::detail::aged_container_iterator first, - beast::detail::aged_container_iterator last) +template +beast::detail::AgedContainerIterator +AgedUnorderedContainer::erase( + beast::detail::AgedContainerIterator first, + beast::detail::AgedContainerIterator last) { for (; first != last;) - unlink_and_delete_element(&*((first++).iterator())); + unlinkAndDeleteElement(&*((first++).iterator())); - return beast::detail::aged_container_iterator(first.iterator()); + return beast::detail::AgedContainerIterator(first.iterator()); } template < @@ -2495,19 +2479,18 @@ template < class Allocator> template auto -aged_unordered_container::erase( - K const& k) -> size_type +AgedUnorderedContainer::erase(K const& k) + -> size_type { - auto iter( - m_cont.find(k, std::cref(m_config.hash_function()), std::cref(m_config.key_value_equal()))); - if (iter == m_cont.end()) + auto iter(cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()))); + if (iter == cont_.end()) return 0; size_type n(0); for (;;) { auto p(&*iter++); - bool const done(m_config(*p, extract(iter->value))); - unlink_and_delete_element(p); + bool const done(config_(*p, extract(iter->value))); + unlinkAndDeleteElement(p); ++n; if (done) break; @@ -2525,12 +2508,12 @@ template < class KeyEqual, class Allocator> void -aged_unordered_container::swap( - aged_unordered_container& other) noexcept +AgedUnorderedContainer::swap( + AgedUnorderedContainer& other) noexcept { - swap_data(other); + swapData(other); std::swap(chronological, other.chronological); - std::swap(m_cont, other.m_cont); + std::swap(cont_, other.cont_); } template < @@ -2544,8 +2527,8 @@ template < class Allocator> template auto -aged_unordered_container::touch( - K const& k) -> size_type +AgedUnorderedContainer::touch(K const& k) + -> size_type { auto const now(clock().now()); size_type n(0); @@ -2574,10 +2557,10 @@ template < class OtherDuration, class OtherHash, class OtherAllocator, - bool maybe_multi> -std::enable_if_t -aged_unordered_container::operator==( - aged_unordered_container< + bool MaybeMulti> +std::enable_if_t +AgedUnorderedContainer::operator==( + AgedUnorderedContainer< false, OtherIsMap, OtherKey, @@ -2614,10 +2597,10 @@ template < class OtherDuration, class OtherHash, class OtherAllocator, - bool maybe_multi> -std::enable_if_t -aged_unordered_container::operator==( - aged_unordered_container< + bool MaybeMulti> +std::enable_if_t +AgedUnorderedContainer::operator==( + AgedUnorderedContainer< true, OtherIsMap, OtherKey, @@ -2632,8 +2615,8 @@ aged_unordered_container -template +template auto -aged_unordered_container:: - insert_unchecked(value_type const& value) - -> std::enable_if_t> +AgedUnorderedContainer::insertUnchecked( + value_type const& value) -> std::enable_if_t> { typename cont_type::insert_commit_data d; - auto const result(m_cont.insert_check( - extract(value), - std::cref(m_config.hash_function()), - std::cref(m_config.key_value_equal()), - d)); + auto const result(cont_.insert_check( + extract(value), std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual()), d)); if (result.second) { - element* const p(new_element(value)); - auto const iter(m_cont.insert_commit(*p, d)); - chronological.list.push_back(*p); + Element* const p(newElement(value)); + auto const iter(cont_.insert_commit(*p, d)); + chronological.list_.push_back(*p); return std::make_pair(iterator(iter), true); } return std::make_pair(iterator(result.first), false); @@ -2691,14 +2670,14 @@ template < class Hash, class KeyEqual, class Allocator> -template +template auto -aged_unordered_container:: - insert_unchecked(value_type const& value) -> std::enable_if_t +AgedUnorderedContainer::insertUnchecked( + value_type const& value) -> std::enable_if_t { - element* const p(new_element(value)); - chronological.list.push_back(*p); - auto const iter(m_cont.insert(*p)); + Element* const p(newElement(value)); + chronological.list_.push_back(*p); + auto const iter(cont_.insert(*p)); return iterator(iter); } @@ -2717,12 +2696,11 @@ template < class Hash, class KeyEqual, class Allocator> -struct is_aged_container< - beast::detail:: - aged_unordered_container> +struct IsAgedContainer< + beast::detail::AgedUnorderedContainer> : std::true_type { - explicit is_aged_container() = default; + explicit IsAgedContainer() = default; }; // Free functions @@ -2738,11 +2716,10 @@ template < class Allocator> void swap( - beast::detail:: - aged_unordered_container& lhs, - beast::detail:: - aged_unordered_container& - rhs) noexcept + beast::detail::AgedUnorderedContainer& + lhs, + beast::detail::AgedUnorderedContainer& + rhs) noexcept { lhs.swap(rhs); } @@ -2761,8 +2738,8 @@ template < class Period> std::size_t expire( - beast::detail:: - aged_unordered_container& c, + beast::detail::AgedUnorderedContainer& + c, std::chrono::duration const& age) noexcept { std::size_t n(0); diff --git a/include/xrpl/beast/container/detail/empty_base_optimization.h b/include/xrpl/beast/container/detail/empty_base_optimization.h index 230845102d..64809fdb77 100644 --- a/include/xrpl/beast/container/detail/empty_base_optimization.h +++ b/include/xrpl/beast/container/detail/empty_base_optimization.h @@ -14,25 +14,25 @@ namespace beast::detail { template -struct is_empty_base_optimization_derived +struct IsEmptyBaseOptimizationDerived : std::integral_constant && !boost::is_final::value> { }; -template ::value> -class empty_base_optimization : private T +template ::value> +class EmptyBaseOptimization : private T { public: - empty_base_optimization() = default; - empty_base_optimization(empty_base_optimization&&) = default; - empty_base_optimization(empty_base_optimization const&) = default; - empty_base_optimization& - operator=(empty_base_optimization&&) = default; - empty_base_optimization& - operator=(empty_base_optimization const&) = default; + EmptyBaseOptimization() = default; + EmptyBaseOptimization(EmptyBaseOptimization&&) = default; + EmptyBaseOptimization(EmptyBaseOptimization const&) = default; + EmptyBaseOptimization& + operator=(EmptyBaseOptimization&&) = default; + EmptyBaseOptimization& + operator=(EmptyBaseOptimization const&) = default; template - explicit empty_base_optimization(Arg1&& arg1, ArgN&&... argn) + explicit EmptyBaseOptimization(Arg1&& arg1, ArgN&&... argn) : T(std::forward(arg1), std::forward(argn)...) { } @@ -53,21 +53,21 @@ public: //------------------------------------------------------------------------------ template -class empty_base_optimization +class EmptyBaseOptimization { T t_; public: - empty_base_optimization() = default; - empty_base_optimization(empty_base_optimization&&) = default; - empty_base_optimization(empty_base_optimization const&) = default; - empty_base_optimization& - operator=(empty_base_optimization&&) = default; - empty_base_optimization& - operator=(empty_base_optimization const&) = default; + EmptyBaseOptimization() = default; + EmptyBaseOptimization(EmptyBaseOptimization&&) = default; + EmptyBaseOptimization(EmptyBaseOptimization const&) = default; + EmptyBaseOptimization& + operator=(EmptyBaseOptimization&&) = default; + EmptyBaseOptimization& + operator=(EmptyBaseOptimization const&) = default; template - explicit empty_base_optimization(Arg1&& arg1, ArgN&&... argn) + explicit EmptyBaseOptimization(Arg1&& arg1, ArgN&&... argn) : t_(std::forward(arg1), std::forward(argn)...) { } diff --git a/include/xrpl/beast/core/CurrentThreadName.h b/include/xrpl/beast/core/CurrentThreadName.h index 8e99ee90da..9bf062a885 100644 --- a/include/xrpl/beast/core/CurrentThreadName.h +++ b/include/xrpl/beast/core/CurrentThreadName.h @@ -21,7 +21,7 @@ setCurrentThreadName(std::string_view newThreadName); // On Linux, thread names are limited to 16 bytes including the null terminator. // Maximum number of characters is therefore 15. -constexpr std::size_t maxThreadNameLength = 15; +constexpr std::size_t kMAX_THREAD_NAME_LENGTH = 15; /** Sets the name of the caller thread with compile-time size checking. @tparam N The size of the string literal including null terminator @@ -34,7 +34,7 @@ template void setCurrentThreadName(char const (&newThreadName)[N]) { - static_assert(N <= maxThreadNameLength + 1, "Thread name cannot exceed 15 characters"); + static_assert(N <= kMAX_THREAD_NAME_LENGTH + 1, "Thread name cannot exceed 15 characters"); setCurrentThreadName(std::string_view(newThreadName, N - 1)); } diff --git a/include/xrpl/beast/core/List.h b/include/xrpl/beast/core/List.h index 30a5166c62..946126a004 100644 --- a/include/xrpl/beast/core/List.h +++ b/include/xrpl/beast/core/List.h @@ -45,8 +45,8 @@ class ListNode template friend class ListIterator; - ListNode* m_next = nullptr; - ListNode* m_prev = nullptr; + ListNode* next_ = nullptr; + ListNode* prev_ = nullptr; }; //------------------------------------------------------------------------------ @@ -62,12 +62,12 @@ public: using reference = value_type&; using size_type = std::size_t; - ListIterator(N* node = nullptr) noexcept : m_node(node) + ListIterator(N* node = nullptr) noexcept : node_(node) { } template - ListIterator(ListIterator const& other) noexcept : m_node(other.m_node) + ListIterator(ListIterator const& other) noexcept : node_(other.node_) { } @@ -75,7 +75,7 @@ public: bool operator==(ListIterator const& other) const noexcept { - return m_node == other.m_node; + return node_ == other.node_; } template @@ -131,22 +131,22 @@ private: [[nodiscard]] reference dereference() const noexcept { - return static_cast(*m_node); + return static_cast(*node_); } void increment() noexcept { - m_node = m_node->m_next; + node_ = node_->next_; } void decrement() noexcept { - m_node = m_node->m_prev; + node_ = node_->prev_; } - N* m_node; + N* node_; }; } // namespace detail @@ -161,11 +161,11 @@ private: struct Object : List ::Node { - explicit Object (int value) : m_value (value) + explicit Object (int value) : value_ (value) { } - int m_value; + int value_; }; @endcode @@ -190,7 +190,7 @@ private: @code for (List ::iterator iter = list.begin(); iter != list.end; ++iter) - std::cout << iter->m_value; + std::cout << iter->value_; @endcode @@ -199,10 +199,10 @@ private: @code BOOST_FOREACH (Object& object, list) // boost only - std::cout << object.m_value; + std::cout << object.value_; for (Object& object : list) // C++11 only - std::cout << object.m_value; + std::cout << object.value_; @endcode @@ -275,8 +275,8 @@ public: /** Create an empty list. */ List() { - m_head.m_prev = nullptr; // identifies the head - m_tail.m_next = nullptr; // identifies the tail + head_.prev_ = nullptr; // identifies the head + tail_.next_ = nullptr; // identifies the tail clear(); } @@ -297,7 +297,7 @@ public: [[nodiscard]] size_type size() const noexcept { - return m_size; + return size_; } /** Obtain a reference to the first element. @@ -307,7 +307,7 @@ public: reference front() noexcept { - return element_from(m_head.m_next); + return element_from(head_.next_); } /** Obtain a const reference to the first element. @@ -317,7 +317,7 @@ public: [[nodiscard]] const_reference front() const noexcept { - return element_from(m_head.m_next); + return element_from(head_.next_); } /** Obtain a reference to the last element. @@ -327,7 +327,7 @@ public: reference back() noexcept { - return element_from(m_tail.m_prev); + return element_from(tail_.prev_); } /** Obtain a const reference to the last element. @@ -337,7 +337,7 @@ public: [[nodiscard]] const_reference back() const noexcept { - return element_from(m_tail.m_prev); + return element_from(tail_.prev_); } /** Obtain an iterator to the beginning of the list. @@ -346,7 +346,7 @@ public: iterator begin() noexcept { - return iterator(m_head.m_next); + return iterator(head_.next_); } /** Obtain a const iterator to the beginning of the list. @@ -355,7 +355,7 @@ public: [[nodiscard]] const_iterator begin() const noexcept { - return const_iterator(m_head.m_next); + return const_iterator(head_.next_); } /** Obtain a const iterator to the beginning of the list. @@ -364,7 +364,7 @@ public: [[nodiscard]] const_iterator cbegin() const noexcept { - return const_iterator(m_head.m_next); + return const_iterator(head_.next_); } /** Obtain a iterator to the end of the list. @@ -373,7 +373,7 @@ public: iterator end() noexcept { - return iterator(&m_tail); + return iterator(&tail_); } /** Obtain a const iterator to the end of the list. @@ -382,7 +382,7 @@ public: [[nodiscard]] const_iterator end() const noexcept { - return const_iterator(&m_tail); + return const_iterator(&tail_); } /** Obtain a const iterator to the end of the list @@ -391,7 +391,7 @@ public: [[nodiscard]] const_iterator cend() const noexcept { - return const_iterator(&m_tail); + return const_iterator(&tail_); } /** Clear the list. @@ -400,9 +400,9 @@ public: void clear() noexcept { - m_head.m_next = &m_tail; - m_tail.m_prev = &m_head; - m_size = 0; + head_.next_ = &tail_; + tail_.prev_ = &head_; + size_ = 0; } /** Insert an element. @@ -415,11 +415,11 @@ public: insert(iterator pos, T& element) noexcept { Node* node = static_cast(&element); - node->m_next = &*pos; - node->m_prev = node->m_next->m_prev; - node->m_next->m_prev = node; - node->m_prev->m_next = node; - ++m_size; + node->next_ = &*pos; + node->prev_ = node->next_->prev_; + node->next_->prev_ = node; + node->prev_->next_ = node; + ++size_; return iterator(node); } @@ -434,11 +434,11 @@ public: if (!other.empty()) { Node* before = &*pos; - other.m_head.m_next->m_prev = before->m_prev; - before->m_prev->m_next = other.m_head.m_next; - other.m_tail.m_prev->m_next = before; - before->m_prev = other.m_tail.m_prev; - m_size += other.m_size; + other.head_.next_->prev_ = before->prev_; + before->prev_->next_ = other.head_.next_; + other.tail_.prev_->next_ = before; + before->prev_ = other.tail_.prev_; + size_ += other.size_; other.clear(); } } @@ -453,9 +453,9 @@ public: { Node const* node = &*pos; ++pos; - node->m_next->m_prev = node->m_prev; - node->m_prev->m_next = node->m_next; - --m_size; + node->next_->prev_ = node->prev_; + node->prev_->next_ = node->next_; + --size_; return pos; } @@ -464,7 +464,7 @@ public: @param element The element to insert. */ iterator - push_front(T& element) noexcept + pushFront(T& element) noexcept { return insert(begin(), element); } @@ -474,7 +474,7 @@ public: @return A reference to the popped element. */ T& - pop_front() noexcept + popFront() noexcept { T& element(front()); erase(begin()); @@ -486,7 +486,7 @@ public: @param element The element to append. */ iterator - push_back(T& element) noexcept + pushBack(T& element) noexcept { return insert(end(), element); } @@ -496,7 +496,7 @@ public: @return A reference to the popped element. */ T& - pop_back() noexcept + popBack() noexcept { T& element(back()); erase(--end()); @@ -539,7 +539,7 @@ public: @return An iterator to the element. */ iterator - iterator_to(T& element) const noexcept + iteratorTo(T& element) const noexcept { return iterator(static_cast(&element)); } @@ -550,28 +550,28 @@ public: @return A const iterator to the element. */ [[nodiscard]] const_iterator - const_iterator_to(T const& element) const noexcept + constIteratorTo(T const& element) const noexcept { return const_iterator(static_cast(&element)); } private: reference - element_from(Node* node) noexcept + elementFrom(Node* node) noexcept { return *(static_cast(node)); } const_reference - element_from(Node const* node) const noexcept + elementFrom(Node const* node) const noexcept { return *(static_cast(node)); } private: - size_type m_size = 0u; - Node m_head; - Node m_tail; + size_type size_ = 0u; + Node head_; + Node tail_; }; } // namespace beast diff --git a/include/xrpl/beast/core/LockFreeStack.h b/include/xrpl/beast/core/LockFreeStack.h index 03598915df..6b8f686246 100644 --- a/include/xrpl/beast/core/LockFreeStack.h +++ b/include/xrpl/beast/core/LockFreeStack.h @@ -26,27 +26,27 @@ public: LockFreeStackIterator() = default; - LockFreeStackIterator(NodePtr node) : m_node(node) + LockFreeStackIterator(NodePtr node) : node_(node) { } template explicit LockFreeStackIterator(LockFreeStackIterator const& other) - : m_node(other.m_node) + : node_(other.node_) { } LockFreeStackIterator& operator=(NodePtr node) { - m_node = node; + node_ = node; return static_cast(*this); } LockFreeStackIterator& operator++() { - m_node = m_node->m_next.load(); + node_ = node_->next_.load(); return static_cast(*this); } @@ -54,14 +54,14 @@ public: operator++(int) { LockFreeStackIterator result(*this); - m_node = m_node->m_next; + node_ = node_->next_; return result; } NodePtr node() const { - return m_node; + return node_; } reference @@ -73,11 +73,11 @@ public: pointer operator->() const { - return static_cast(m_node); + return static_cast(node_); } private: - NodePtr m_node{}; + NodePtr node_{}; }; //------------------------------------------------------------------------------ @@ -121,11 +121,11 @@ public: class Node { public: - Node() : m_next(nullptr) + Node() : next_(nullptr) { } - explicit Node(Node* next) : m_next(next) + explicit Node(Node* next) : next_(next) { } @@ -139,7 +139,7 @@ public: template friend class LockFreeStackIterator; - std::atomic m_next; + std::atomic next_; }; public: @@ -153,7 +153,7 @@ public: using iterator = LockFreeStackIterator, false>; using const_iterator = LockFreeStackIterator, true>; - LockFreeStack() : m_end(nullptr), m_head(&m_end) + LockFreeStack() : end_(nullptr), head_(&end_) { } @@ -165,7 +165,7 @@ public: [[nodiscard]] bool empty() const { - return m_head.load() == &m_end; + return head_.load() == &end_; } /** Push a node onto the stack. @@ -181,16 +181,16 @@ public: */ // VFALCO NOTE Fix this, shouldn't it be a reference like intrusive list? bool - push_front(Node* node) + pushFront(Node* node) { bool first = false; - Node* old_head = m_head.load(std::memory_order_relaxed); + Node* oldHead = head_.load(std::memory_order_relaxed); do { - first = (old_head == &m_end); - node->m_next = old_head; - } while (!m_head.compare_exchange_strong( - old_head, node, std::memory_order_release, std::memory_order_relaxed)); + first = (oldHead == &end_); + node->next_ = oldHead; + } while (!head_.compare_exchange_strong( + oldHead, node, std::memory_order_release, std::memory_order_relaxed)); return first; } @@ -204,17 +204,17 @@ public: was empty. */ Element* - pop_front() + popFront() { - Node* node = m_head.load(); - Node* new_head = nullptr; + Node* node = head_.load(); + Node* newHead = nullptr; do { - if (node == &m_end) + if (node == &end_) return nullptr; - new_head = node->m_next.load(); - } while (!m_head.compare_exchange_strong( - node, new_head, std::memory_order_release, std::memory_order_relaxed)); + newHead = node->next_.load(); + } while (!head_.compare_exchange_strong( + node, newHead, std::memory_order_release, std::memory_order_relaxed)); return static_cast(node); } @@ -228,43 +228,43 @@ public: iterator begin() { - return iterator(m_head.load()); + return iterator(head_.load()); } iterator end() { - return iterator(&m_end); + return iterator(&end_); } [[nodiscard]] const_iterator begin() const { - return const_iterator(m_head.load()); + return const_iterator(head_.load()); } [[nodiscard]] const_iterator end() const { - return const_iterator(&m_end); + return const_iterator(&end_); } [[nodiscard]] const_iterator cbegin() const { - return const_iterator(m_head.load()); + return const_iterator(head_.load()); } [[nodiscard]] const_iterator cend() const { - return const_iterator(&m_end); + return const_iterator(&end_); } /** @} */ private: - Node m_end; - std::atomic m_head; + Node end_; + std::atomic head_; }; } // namespace beast diff --git a/include/xrpl/beast/hash/hash_append.h b/include/xrpl/beast/hash/hash_append.h index 3161ab3ce2..25ce668166 100644 --- a/include/xrpl/beast/hash/hash_append.h +++ b/include/xrpl/beast/hash/hash_append.h @@ -24,7 +24,7 @@ namespace detail { template /*constexpr*/ inline void -reverse_bytes(T& t) +reverseBytes(T& t) { unsigned char* bytes = static_cast(std::memmove(std::addressof(t), std::addressof(t), sizeof(T))); @@ -35,14 +35,14 @@ reverse_bytes(T& t) template /*constexpr*/ inline void -maybe_reverse_bytes(T& t, std::false_type) +maybeReverseBytes(T& t, std::false_type) { } template /*constexpr*/ inline void -maybe_reverse_bytes(T& t, std::true_type) +maybeReverseBytes(T& t, std::true_type) { reverse_bytes(t); } @@ -50,15 +50,15 @@ maybe_reverse_bytes(T& t, std::true_type) template /*constexpr*/ inline void -maybe_reverse_bytes(T& t, Hasher&) +maybeReverseBytes(T& t, Hasher&) { - maybe_reverse_bytes( - t, std::integral_constant{}); + maybeReverseBytes( + t, std::integral_constant{}); } } // namespace detail -// is_uniquely_represented +// IsUniquelyRepresented // A type T is contiguously hashable if for all combinations of two values of // a type, say x and y, if x == y, then it must also be true that @@ -66,78 +66,78 @@ maybe_reverse_bytes(T& t, Hasher&) // then x and y have the same bit pattern representation. template -struct is_uniquely_represented +struct IsUniquelyRepresented : public std::integral_constant< bool, std::is_integral_v || std::is_enum_v || std::is_pointer_v> { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; template -struct is_uniquely_represented : public is_uniquely_represented +struct IsUniquelyRepresented : public IsUniquelyRepresented { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; template -struct is_uniquely_represented : public is_uniquely_represented +struct IsUniquelyRepresented : public IsUniquelyRepresented { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; template -struct is_uniquely_represented : public is_uniquely_represented +struct IsUniquelyRepresented : public IsUniquelyRepresented { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; -// is_uniquely_represented> +// IsUniquelyRepresented> template -struct is_uniquely_represented> +struct IsUniquelyRepresented> : public std::integral_constant< bool, - is_uniquely_represented::value && is_uniquely_represented::value && + IsUniquelyRepresented::value && IsUniquelyRepresented::value && sizeof(T) + sizeof(U) == sizeof(std::pair)> { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; -// is_uniquely_represented> +// IsUniquelyRepresented> template -struct is_uniquely_represented> +struct IsUniquelyRepresented> : public std::integral_constant< bool, - std::conjunction_v...> && + std::conjunction_v...> && sizeof(std::tuple) == (sizeof(T) + ...)> { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; -// is_uniquely_represented +// IsUniquelyRepresented template -struct is_uniquely_represented : public is_uniquely_represented +struct IsUniquelyRepresented : public IsUniquelyRepresented { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; -// is_uniquely_represented> +// IsUniquelyRepresented> template -struct is_uniquely_represented> +struct IsUniquelyRepresented> : public std::integral_constant< bool, - is_uniquely_represented::value && sizeof(T) * N == sizeof(std::array)> + IsUniquelyRepresented::value && sizeof(T) * N == sizeof(std::array)> { - explicit is_uniquely_represented() = default; + explicit IsUniquelyRepresented() = default; }; /** Metafunction returning `true` if the type can be hashed in one call. - For `is_contiguously_hashable::value` to be true, then for every + For `IsContiguouslyHashable::value` to be true, then for every combination of possible values of `T` held in `x` and `y`, if `x == y`, then it must be true that `memcmp(&x, &y, sizeof(T))` return 0; i.e. that `x` and `y` are represented by the same bit pattern. @@ -150,23 +150,23 @@ struct is_uniquely_represented> */ /** @{ */ template -struct is_contiguously_hashable +struct IsContiguouslyHashable : public std::integral_constant< bool, - is_uniquely_represented::value && - (sizeof(T) == 1 || HashAlgorithm::endian == boost::endian::order::native)> + IsUniquelyRepresented::value && + (sizeof(T) == 1 || HashAlgorithm::kENDIAN == boost::endian::order::native)> { - explicit is_contiguously_hashable() = default; + explicit IsContiguouslyHashable() = default; }; template -struct is_contiguously_hashable +struct IsContiguouslyHashable : public std::integral_constant< bool, - is_uniquely_represented::value && + IsUniquelyRepresented::value && (sizeof(T) == 1 || HashAlgorithm::endian == boost::endian::order::native)> { - explicit is_contiguously_hashable() = default; + explicit IsContiguouslyHashable() = default; }; /** @} */ @@ -200,7 +200,7 @@ struct is_contiguously_hashable // scalars template -inline std::enable_if_t::value> +inline std::enable_if_t::value> hash_append(Hasher& h, T const& t) noexcept { // NOLINTNEXTLINE(bugprone-sizeof-expression) @@ -209,11 +209,11 @@ hash_append(Hasher& h, T const& t) noexcept template inline std::enable_if_t< - !is_contiguously_hashable::value && + !IsContiguouslyHashable::value && (std::is_integral_v || std::is_pointer_v || std::is_enum_v)> hash_append(Hasher& h, T t) noexcept { - detail::reverse_bytes(t); + detail::reverseBytes(t); h(std::addressof(t), sizeof(t)); } @@ -223,7 +223,7 @@ hash_append(Hasher& h, T t) noexcept { if (t == 0) t = 0; - detail::maybe_reverse_bytes(t, h); + detail::maybeReverseBytes(t, h); h(&t, sizeof(t)); } @@ -232,42 +232,42 @@ inline void hash_append(Hasher& h, std::nullptr_t) noexcept { void const* p = nullptr; - detail::maybe_reverse_bytes(p, h); + detail::maybeReverseBytes(p, h); h(&p, sizeof(p)); } // Forward declarations for ADL purposes template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, T (&a)[N]) noexcept; template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, std::basic_string const& s) noexcept; template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, std::basic_string const& s) noexcept; template -std::enable_if_t, Hasher>::value> +std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::pair const& p) noexcept; template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, std::vector const& v) noexcept; template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, std::vector const& v) noexcept; template -std::enable_if_t, Hasher>::value> +std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::array const& a) noexcept; template -std::enable_if_t, Hasher>::value> +std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::tuple const& t) noexcept; template @@ -279,10 +279,10 @@ void hash_append(Hasher& h, std::unordered_set const& s); template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, boost::container::flat_set const& v) noexcept; template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, boost::container::flat_set const& v) noexcept; template void @@ -291,7 +291,7 @@ hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept; // c-array template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, T (&a)[N]) noexcept { for (auto const& t : a) @@ -301,7 +301,7 @@ hash_append(Hasher& h, T (&a)[N]) noexcept // basic_string template -inline std::enable_if_t::value> +inline std::enable_if_t::value> hash_append(Hasher& h, std::basic_string const& s) noexcept { for (auto c : s) @@ -310,7 +310,7 @@ hash_append(Hasher& h, std::basic_string const& s) noexcep } template -inline std::enable_if_t::value> +inline std::enable_if_t::value> hash_append(Hasher& h, std::basic_string const& s) noexcept { h(s.data(), s.size() * sizeof(CharT)); @@ -320,7 +320,7 @@ hash_append(Hasher& h, std::basic_string const& s) noexcep // pair template -inline std::enable_if_t, Hasher>::value> +inline std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::pair const& p) noexcept { hash_append(h, p.first, p.second); @@ -329,7 +329,7 @@ hash_append(Hasher& h, std::pair const& p) noexcept // vector template -inline std::enable_if_t::value> +inline std::enable_if_t::value> hash_append(Hasher& h, std::vector const& v) noexcept { for (auto const& t : v) @@ -338,7 +338,7 @@ hash_append(Hasher& h, std::vector const& v) noexcept } template -inline std::enable_if_t::value> +inline std::enable_if_t::value> hash_append(Hasher& h, std::vector const& v) noexcept { h(v.data(), v.size() * sizeof(T)); @@ -348,7 +348,7 @@ hash_append(Hasher& h, std::vector const& v) noexcept // array template -std::enable_if_t, Hasher>::value> +std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::array const& a) noexcept { for (auto const& t : a) @@ -356,14 +356,14 @@ hash_append(Hasher& h, std::array const& a) noexcept } template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, boost::container::flat_set const& v) noexcept { for (auto const& t : v) hash_append(h, t); } template -std::enable_if_t::value> +std::enable_if_t::value> hash_append(Hasher& h, boost::container::flat_set const& v) noexcept { h(&(v.begin()), v.size() * sizeof(Key)); @@ -373,13 +373,13 @@ hash_append(Hasher& h, boost::container::flat_set const& v) namespace detail { inline void -for_each_item(...) noexcept +forEachItem(...) noexcept { } template inline int -hash_one(Hasher& h, T const& t) noexcept +hashOne(Hasher& h, T const& t) noexcept { hash_append(h, t); return 0; @@ -395,7 +395,7 @@ tuple_hash(Hasher& h, std::tuple const& t, std::index_sequence) noex } // namespace detail template -inline std::enable_if_t, Hasher>::value> +inline std::enable_if_t, Hasher>::value> hash_append(Hasher& h, std::tuple const& t) noexcept { detail::tuple_hash(h, t, std::index_sequence_for{}); diff --git a/include/xrpl/beast/hash/uhash.h b/include/xrpl/beast/hash/uhash.h index 4f66f058a8..97461f67c7 100644 --- a/include/xrpl/beast/hash/uhash.h +++ b/include/xrpl/beast/hash/uhash.h @@ -6,10 +6,10 @@ namespace beast { // Universal hash function -template -struct uhash +template +struct Uhash { - uhash() = default; + Uhash() = default; using result_type = typename Hasher::result_type; diff --git a/include/xrpl/beast/hash/xxhasher.h b/include/xrpl/beast/hash/xxhasher.h index 5cd060e465..01485e1e85 100644 --- a/include/xrpl/beast/hash/xxhasher.h +++ b/include/xrpl/beast/hash/xxhasher.h @@ -12,7 +12,7 @@ namespace beast { -class xxhasher +class Xxhasher { public: using result_type = std::size_t; @@ -21,9 +21,9 @@ private: static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t"); // Have an internal buffer to avoid the streaming API // A 64-byte buffer should to be big enough for us - static constexpr std::size_t INTERNAL_BUFFER_SIZE = 64; + static constexpr std::size_t kINTERNAL_BUFFER_SIZE = 64; - alignas(64) std::array buffer_{}; + alignas(64) std::array buffer_{}; std::span readBuffer_; std::span writeBuffer_; @@ -102,18 +102,18 @@ private: } public: - static constexpr auto const endian = boost::endian::order::native; + static constexpr auto const kENDIAN = boost::endian::order::native; - xxhasher(xxhasher const&) = delete; - xxhasher& - operator=(xxhasher const&) = delete; + Xxhasher(Xxhasher const&) = delete; + Xxhasher& + operator=(Xxhasher const&) = delete; - xxhasher() + Xxhasher() { resetBuffers(); } - ~xxhasher() noexcept + ~Xxhasher() noexcept { if (state_ != nullptr) { @@ -122,13 +122,13 @@ public: } template >* = nullptr> - explicit xxhasher(Seed seed) : seed_(seed) + explicit Xxhasher(Seed seed) : seed_(seed) { resetBuffers(); } template >* = nullptr> - xxhasher(Seed seed, Seed) : seed_(seed) + Xxhasher(Seed seed, Seed) : seed_(seed) { resetBuffers(); } diff --git a/include/xrpl/beast/insight/Collector.h b/include/xrpl/beast/insight/Collector.h index 1d18c7e15c..2e73d60400 100644 --- a/include/xrpl/beast/insight/Collector.h +++ b/include/xrpl/beast/insight/Collector.h @@ -42,13 +42,13 @@ public: /** @{ */ template Hook - make_hook(Handler handler) + makeHook(Handler handler) { - return make_hook(HookImpl::HandlerType(handler)); + return makeHook(HookImpl::HandlerType(handler)); } virtual Hook - make_hook(HookImpl::HandlerType const& handler) = 0; + makeHook(HookImpl::HandlerType const& handler) = 0; /** @} */ /** Create a counter with the specified name. @@ -56,14 +56,14 @@ public: */ /** @{ */ virtual Counter - make_counter(std::string const& name) = 0; + makeCounter(std::string const& name) = 0; Counter - make_counter(std::string const& prefix, std::string const& name) + makeCounter(std::string const& prefix, std::string const& name) { if (prefix.empty()) - return make_counter(name); - return make_counter(prefix + "." + name); + return makeCounter(name); + return makeCounter(prefix + "." + name); } /** @} */ @@ -72,14 +72,14 @@ public: */ /** @{ */ virtual Event - make_event(std::string const& name) = 0; + makeEvent(std::string const& name) = 0; Event - make_event(std::string const& prefix, std::string const& name) + makeEvent(std::string const& prefix, std::string const& name) { if (prefix.empty()) - return make_event(name); - return make_event(prefix + "." + name); + return makeEvent(name); + return makeEvent(prefix + "." + name); } /** @} */ @@ -88,14 +88,14 @@ public: */ /** @{ */ virtual Gauge - make_gauge(std::string const& name) = 0; + makeGauge(std::string const& name) = 0; Gauge - make_gauge(std::string const& prefix, std::string const& name) + makeGauge(std::string const& prefix, std::string const& name) { if (prefix.empty()) - return make_gauge(name); - return make_gauge(prefix + "." + name); + return makeGauge(name); + return makeGauge(prefix + "." + name); } /** @} */ @@ -104,14 +104,14 @@ public: */ /** @{ */ virtual Meter - make_meter(std::string const& name) = 0; + makeMeter(std::string const& name) = 0; Meter - make_meter(std::string const& prefix, std::string const& name) + makeMeter(std::string const& prefix, std::string const& name) { if (prefix.empty()) - return make_meter(name); - return make_meter(prefix + "." + name); + return makeMeter(name); + return makeMeter(prefix + "." + name); } /** @} */ }; diff --git a/include/xrpl/beast/insight/Counter.h b/include/xrpl/beast/insight/Counter.h index c5b8178c2d..71ace4bb4e 100644 --- a/include/xrpl/beast/insight/Counter.h +++ b/include/xrpl/beast/insight/Counter.h @@ -29,7 +29,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Counter(std::shared_ptr const& impl) : m_impl(impl) + explicit Counter(std::shared_ptr const& impl) : impl_(impl) { } @@ -38,8 +38,8 @@ public: void increment(value_type amount) const { - if (m_impl) - m_impl->increment(amount); + if (impl_) + impl_->increment(amount); } Counter const& @@ -85,7 +85,7 @@ public: } private: - std::shared_ptr m_impl; + std::shared_ptr impl_; }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/Event.h b/include/xrpl/beast/insight/Event.h index 28994db956..5e424a0f9b 100644 --- a/include/xrpl/beast/insight/Event.h +++ b/include/xrpl/beast/insight/Event.h @@ -31,7 +31,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Event(std::shared_ptr const& impl) : m_impl(impl) + explicit Event(std::shared_ptr const& impl) : impl_(impl) { } @@ -41,18 +41,18 @@ public: notify(std::chrono::duration const& value) const { using namespace std::chrono; - if (m_impl) - m_impl->notify(ceil(value)); + if (impl_) + impl_->notify(ceil(value)); } [[nodiscard]] std::shared_ptr const& impl() const { - return m_impl; + return impl_; } private: - std::shared_ptr m_impl; + std::shared_ptr impl_; }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/Gauge.h b/include/xrpl/beast/insight/Gauge.h index 8a7de33e2e..dd2c4bc6b6 100644 --- a/include/xrpl/beast/insight/Gauge.h +++ b/include/xrpl/beast/insight/Gauge.h @@ -31,7 +31,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Gauge(std::shared_ptr const& impl) : m_impl(impl) + explicit Gauge(std::shared_ptr const& impl) : impl_(impl) { } @@ -44,8 +44,8 @@ public: void set(value_type value) const { - if (m_impl) - m_impl->set(value); + if (impl_) + impl_->set(value); } Gauge const& @@ -61,8 +61,8 @@ public: void increment(difference_type amount) const { - if (m_impl) - m_impl->increment(amount); + if (impl_) + impl_->increment(amount); } Gauge const& @@ -111,11 +111,11 @@ public: [[nodiscard]] std::shared_ptr const& impl() const { - return m_impl; + return impl_; } private: - std::shared_ptr m_impl; + std::shared_ptr impl_; }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/Groups.h b/include/xrpl/beast/insight/Groups.h index abc1aa004b..cfe4d99bdc 100644 --- a/include/xrpl/beast/insight/Groups.h +++ b/include/xrpl/beast/insight/Groups.h @@ -29,6 +29,6 @@ public: /** Create a group container that uses the specified collector. */ std::unique_ptr -make_Groups(Collector::ptr const& collector); +makeGroups(Collector::ptr const& collector); } // namespace beast::insight diff --git a/include/xrpl/beast/insight/Hook.h b/include/xrpl/beast/insight/Hook.h index d873411390..1cb6cae5d9 100644 --- a/include/xrpl/beast/insight/Hook.h +++ b/include/xrpl/beast/insight/Hook.h @@ -20,18 +20,18 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Hook(std::shared_ptr const& impl) : m_impl(impl) + explicit Hook(std::shared_ptr const& impl) : impl_(impl) { } [[nodiscard]] std::shared_ptr const& impl() const { - return m_impl; + return impl_; } private: - std::shared_ptr m_impl; + std::shared_ptr impl_; }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/Meter.h b/include/xrpl/beast/insight/Meter.h index 93ae237956..03aa17c313 100644 --- a/include/xrpl/beast/insight/Meter.h +++ b/include/xrpl/beast/insight/Meter.h @@ -28,7 +28,7 @@ public: factory function in the Collector interface. @see Collector. */ - explicit Meter(std::shared_ptr const& impl) : m_impl(impl) + explicit Meter(std::shared_ptr const& impl) : impl_(impl) { } @@ -37,8 +37,8 @@ public: void increment(value_type amount) const { - if (m_impl) - m_impl->increment(amount); + if (impl_) + impl_->increment(amount); } Meter const& @@ -66,11 +66,11 @@ public: [[nodiscard]] std::shared_ptr const& impl() const { - return m_impl; + return impl_; } private: - std::shared_ptr m_impl; + std::shared_ptr impl_; }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/NullCollector.h b/include/xrpl/beast/insight/NullCollector.h index e6404c8f2c..b865526ade 100644 --- a/include/xrpl/beast/insight/NullCollector.h +++ b/include/xrpl/beast/insight/NullCollector.h @@ -11,7 +11,7 @@ public: explicit NullCollector() = default; static std::shared_ptr - New(); + make(); }; } // namespace beast::insight diff --git a/include/xrpl/beast/insight/StatsDCollector.h b/include/xrpl/beast/insight/StatsDCollector.h index 161f351763..ad436dc626 100644 --- a/include/xrpl/beast/insight/StatsDCollector.h +++ b/include/xrpl/beast/insight/StatsDCollector.h @@ -21,7 +21,7 @@ public: @param journal Destination for logging output. */ static std::shared_ptr - New(IP::Endpoint const& address, std::string const& prefix, Journal journal); + make(IP::Endpoint const& address, std::string const& prefix, Journal journal); }; } // namespace beast::insight diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 277a43e5d8..67deaaa787 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -27,37 +27,37 @@ to_string(Address const& addr) /** Returns `true` if this is a loopback address. */ inline bool -is_loopback(Address const& addr) +isLoopback(Address const& addr) { return addr.is_loopback(); } /** Returns `true` if the address is unspecified. */ inline bool -is_unspecified(Address const& addr) +isUnspecified(Address const& addr) { return addr.is_unspecified(); } /** Returns `true` if the address is a multicast address. */ inline bool -is_multicast(Address const& addr) +isMulticast(Address const& addr) { return addr.is_multicast(); } /** Returns `true` if the address is a private unroutable address. */ inline bool -is_private(Address const& addr) +isPrivate(Address const& addr) { - return (addr.is_v4()) ? is_private(addr.to_v4()) : is_private(addr.to_v6()); + return (addr.is_v4()) ? isPrivate(addr.to_v4()) : isPrivate(addr.to_v6()); } /** Returns `true` if the address is a public routable address. */ inline bool -is_public(Address const& addr) +isPublic(Address const& addr) { - return (addr.is_v4()) ? is_public(addr.to_v4()) : is_public(addr.to_v6()); + return (addr.is_v4()) ? isPublic(addr.to_v4()) : isPublic(addr.to_v6()); } } // namespace IP @@ -95,7 +95,7 @@ struct hash<::beast::IP::Address> std::size_t operator()(::beast::IP::Address const& addr) const { - return ::beast::uhash<>{}(addr); + return ::beast::Uhash<>{}(addr); } }; } // namespace boost diff --git a/include/xrpl/beast/net/IPAddressConversion.h b/include/xrpl/beast/net/IPAddressConversion.h index 4e0328c113..b5fb697233 100644 --- a/include/xrpl/beast/net/IPAddressConversion.h +++ b/include/xrpl/beast/net/IPAddressConversion.h @@ -10,21 +10,21 @@ namespace beast::IP { The port is set to zero. */ Endpoint -from_asio(boost::asio::ip::address const& address); +fromAsio(boost::asio::ip::address const& address); /** Convert to Endpoint. */ Endpoint -from_asio(boost::asio::ip::tcp::endpoint const& endpoint); +fromAsio(boost::asio::ip::tcp::endpoint const& endpoint); /** Convert to asio::ip::address. The port is ignored. */ boost::asio::ip::address -to_asio_address(Endpoint const& endpoint); +toAsioAddress(Endpoint const& endpoint); /** Convert to asio::ip::tcp::endpoint. */ boost::asio::ip::tcp::endpoint -to_asio_endpoint(Endpoint const& endpoint); +toAsioEndpoint(Endpoint const& endpoint); } // namespace beast::IP @@ -36,24 +36,24 @@ struct IPAddressConversion explicit IPAddressConversion() = default; static IP::Endpoint - from_asio(boost::asio::ip::address const& address) + fromAsio(boost::asio::ip::address const& address) { - return IP::from_asio(address); + return IP::fromAsio(address); } static IP::Endpoint - from_asio(boost::asio::ip::tcp::endpoint const& endpoint) + fromAsio(boost::asio::ip::tcp::endpoint const& endpoint) { - return IP::from_asio(endpoint); + return IP::fromAsio(endpoint); } static boost::asio::ip::address - to_asio_address(IP::Endpoint const& address) + toAsioAddress(IP::Endpoint const& address) { - return IP::to_asio_address(address); + return IP::toAsioAddress(address); } static boost::asio::ip::tcp::endpoint - to_asio_endpoint(IP::Endpoint const& address) + toAsioEndpoint(IP::Endpoint const& address) { - return IP::to_asio_endpoint(address); + return IP::toAsioEndpoint(address); } }; diff --git a/include/xrpl/beast/net/IPAddressV4.h b/include/xrpl/beast/net/IPAddressV4.h index 15bb959f49..dbe5a6095f 100644 --- a/include/xrpl/beast/net/IPAddressV4.h +++ b/include/xrpl/beast/net/IPAddressV4.h @@ -10,16 +10,16 @@ using AddressV4 = boost::asio::ip::address_v4; /** Returns `true` if the address is a private unroutable address. */ bool -is_private(AddressV4 const& addr); +isPrivate(AddressV4 const& addr); /** Returns `true` if the address is a public routable address. */ bool -is_public(AddressV4 const& addr); +isPublic(AddressV4 const& addr); /** Returns the address class for the given address. @note Class 'D' represents multicast addresses (224.*.*.*). */ char -get_class(AddressV4 const& address); +getClass(AddressV4 const& address); } // namespace beast::IP diff --git a/include/xrpl/beast/net/IPAddressV6.h b/include/xrpl/beast/net/IPAddressV6.h index 83ac6d4dab..10f806417d 100644 --- a/include/xrpl/beast/net/IPAddressV6.h +++ b/include/xrpl/beast/net/IPAddressV6.h @@ -10,10 +10,10 @@ using AddressV6 = boost::asio::ip::address_v6; /** Returns `true` if the address is a private unroutable address. */ bool -is_private(AddressV6 const& addr); +isPrivate(AddressV6 const& addr); /** Returns `true` if the address is a public routable address. */ bool -is_public(AddressV6 const& addr); +isPublic(AddressV6 const& addr); } // namespace beast::IP diff --git a/include/xrpl/beast/net/IPEndpoint.h b/include/xrpl/beast/net/IPEndpoint.h index 15d86d75fe..fec6e1556f 100644 --- a/include/xrpl/beast/net/IPEndpoint.h +++ b/include/xrpl/beast/net/IPEndpoint.h @@ -27,56 +27,56 @@ public: @return An optional endpoint; will be `std::nullopt` on failure */ static std::optional - from_string_checked(std::string const& s); + fromStringChecked(std::string const& s); static Endpoint - from_string(std::string const& s); + fromString(std::string const& s); /** Returns a string representing the endpoint. */ [[nodiscard]] std::string - to_string() const; + toString() const; /** Returns the port number on the endpoint. */ [[nodiscard]] Port port() const { - return m_port; + return port_; } /** Returns a new Endpoint with a different port. */ [[nodiscard]] Endpoint - at_port(Port port) const + atPort(Port port) const { - return Endpoint(m_addr, port); + return Endpoint(addr_, port); } /** Returns the address portion of this endpoint. */ [[nodiscard]] Address const& address() const { - return m_addr; + return addr_; } /** Convenience accessors for the address part. */ /** @{ */ [[nodiscard]] bool - is_v4() const + isV4() const { - return m_addr.is_v4(); + return addr_.is_v4(); } [[nodiscard]] bool - is_v6() const + isV6() const { - return m_addr.is_v6(); + return addr_.is_v6(); } [[nodiscard]] AddressV4 - to_v4() const + toV4() const { - return m_addr.to_v4(); + return addr_.to_v4(); } [[nodiscard]] AddressV6 - to_v6() const + toV6() const { - return m_addr.to_v6(); + return addr_.to_v6(); } /** @} */ @@ -114,12 +114,12 @@ public: hash_append(Hasher& h, Endpoint const& endpoint) { using ::beast::hash_append; - hash_append(h, endpoint.m_addr, endpoint.m_port); + hash_append(h, endpoint.addr_, endpoint.port_); } private: - Address m_addr; - Port m_port; + Address addr_; + Port port_; }; //------------------------------------------------------------------------------ @@ -128,37 +128,37 @@ private: /** Returns `true` if the endpoint is a loopback address. */ inline bool -is_loopback(Endpoint const& endpoint) +isLoopback(Endpoint const& endpoint) { - return is_loopback(endpoint.address()); + return isLoopback(endpoint.address()); } /** Returns `true` if the endpoint is unspecified. */ inline bool -is_unspecified(Endpoint const& endpoint) +isUnspecified(Endpoint const& endpoint) { - return is_unspecified(endpoint.address()); + return isUnspecified(endpoint.address()); } /** Returns `true` if the endpoint is a multicast address. */ inline bool -is_multicast(Endpoint const& endpoint) +isMulticast(Endpoint const& endpoint) { - return is_multicast(endpoint.address()); + return isMulticast(endpoint.address()); } /** Returns `true` if the endpoint is a private unroutable address. */ inline bool -is_private(Endpoint const& endpoint) +isPrivate(Endpoint const& endpoint) { - return is_private(endpoint.address()); + return isPrivate(endpoint.address()); } /** Returns `true` if the endpoint is a public routable address. */ inline bool -is_public(Endpoint const& endpoint) +isPublic(Endpoint const& endpoint) { - return is_public(endpoint.address()); + return isPublic(endpoint.address()); } //------------------------------------------------------------------------------ @@ -167,7 +167,7 @@ is_public(Endpoint const& endpoint) inline std::string to_string(Endpoint const& endpoint) { - return endpoint.to_string(); + return endpoint.toString(); } /** Output stream conversion. */ @@ -197,7 +197,7 @@ struct hash<::beast::IP::Endpoint> std::size_t operator()(::beast::IP::Endpoint const& endpoint) const { - return ::beast::uhash<>{}(endpoint); + return ::beast::Uhash<>{}(endpoint); } }; } // namespace std @@ -212,7 +212,7 @@ struct hash<::beast::IP::Endpoint> std::size_t operator()(::beast::IP::Endpoint const& endpoint) const { - return ::beast::uhash<>{}(endpoint); + return ::beast::Uhash<>{}(endpoint); } }; } // namespace boost diff --git a/include/xrpl/beast/rfc2616.h b/include/xrpl/beast/rfc2616.h index 7278119c3b..cf80bd26c0 100644 --- a/include/xrpl/beast/rfc2616.h +++ b/include/xrpl/beast/rfc2616.h @@ -16,9 +16,9 @@ namespace beast::rfc2616 { namespace detail { -struct ci_equal_pred +struct CiEqualPred { - explicit ci_equal_pred() = default; + explicit CiEqualPred() = default; bool operator()(char c1, char c2) @@ -34,14 +34,14 @@ struct ci_equal_pred This excludes the CRLF sequence allowed for line continuations. */ inline bool -is_lws(char c) +isLws(char c) { return c == ' ' || c == '\t'; } /** Returns `true` if `c` is any whitespace character. */ inline bool -is_white(char c) +isWhite(char c) { switch (c) { @@ -59,14 +59,14 @@ is_white(char c) template FwdIter -trim_right(FwdIter first, FwdIter last) +trimRight(FwdIter first, FwdIter last) { if (first == last) return last; do { --last; - if (!is_white(*last)) + if (!isWhite(*last)) return ++last; } while (last != first); return first; @@ -74,13 +74,13 @@ trim_right(FwdIter first, FwdIter last) template String -trim_right(String const& s) +trimRight(String const& s) { using std::begin; using std::end; auto first(begin(s)); auto last(end(s)); - last = trim_right(first, last); + last = trimRight(first, last); return {first, last}; } @@ -143,7 +143,7 @@ split(FwdIt first, FwdIt last, Char delim) } else if (*iter == delim) { - e = trim_right(e); + e = trimRight(e); if (!e.empty()) { result.emplace_back(std::move(e)); @@ -151,7 +151,7 @@ split(FwdIt first, FwdIt last, Char delim) } ++iter; } - else if (is_lws(*iter)) + else if (isLws(*iter)) { ++iter; } @@ -163,7 +163,7 @@ split(FwdIt first, FwdIt last, Char delim) if (!e.empty()) { - e = trim_right(e); + e = trimRight(e); if (!e.empty()) result.emplace_back(std::move(e)); } @@ -174,16 +174,16 @@ template < class FwdIt, class Result = std::vector::value_type>>> Result -split_commas(FwdIt first, FwdIt last) +splitCommas(FwdIt first, FwdIt last) { return split(first, last, ','); } template > Result -split_commas(boost::beast::string_view const& s) +splitCommas(boost::beast::string_view const& s) { - return split_commas(s.begin(), s.end()); + return splitCommas(s.begin(), s.end()); } //------------------------------------------------------------------------------ @@ -196,7 +196,7 @@ split_commas(boost::beast::string_view const& s) @note Values returned may contain backslash escapes. */ -class list_iterator +class ListIterator { using iter_type = boost::string_ref::const_iterator; @@ -211,20 +211,20 @@ public: using difference_type = std::ptrdiff_t; using iterator_category = std::forward_iterator_tag; - list_iterator(iter_type begin, iter_type end) : it_(begin), end_(end) + ListIterator(iter_type begin, iter_type end) : it_(begin), end_(end) { if (it_ != end_) increment(); } bool - operator==(list_iterator const& other) const + operator==(ListIterator const& other) const { return other.it_ == it_ && other.end_ == end_ && other.value_.size() == value_.size(); } bool - operator!=(list_iterator const& other) const + operator!=(ListIterator const& other) const { return !(*this == other); } @@ -241,14 +241,14 @@ public: return &*(*this); } - list_iterator& + ListIterator& operator++() { increment(); return *this; } - list_iterator + ListIterator operator++(int) { auto temp = *this; @@ -264,7 +264,7 @@ private: template void -list_iterator::increment() +ListIterator::increment() { using namespace detail; value_.clear(); @@ -302,7 +302,7 @@ list_iterator::increment() it_++; continue; } - else if (is_lws(*it_)) + else if (isLws(*it_)) { ++it_; continue; @@ -313,7 +313,7 @@ list_iterator::increment() for (;;) { ++it_; - if (it_ == end_ || *it_ == ',' || is_lws(*it_)) + if (it_ == end_ || *it_ == ',' || isLws(*it_)) { value_ = boost::string_ref(&*start, std::distance(start, it_)); return; @@ -327,17 +327,17 @@ list_iterator::increment() A case-insensitive comparison is used. */ inline bool -ci_equal(boost::string_ref s1, boost::string_ref s2) +ciEqual(boost::string_ref s1, boost::string_ref s2) { - return boost::range::equal(s1, s2, detail::ci_equal_pred{}); + return boost::range::equal(s1, s2, detail::CiEqualPred{}); } /** Returns a range representing the list. */ -inline boost::iterator_range -make_list(boost::string_ref const& field) +inline boost::iterator_range +makeList(boost::string_ref const& field) { - return boost::iterator_range{ - list_iterator{field.begin(), field.end()}, list_iterator{field.end(), field.end()}}; + return boost::iterator_range{ + ListIterator{field.begin(), field.end()}, ListIterator{field.end(), field.end()}}; } /** Returns true if the specified token exists in the list. @@ -346,19 +346,19 @@ make_list(boost::string_ref const& field) */ template bool -token_in_list(boost::string_ref const& value, boost::string_ref const& token) +tokenInList(boost::string_ref const& value, boost::string_ref const& token) { - for (auto const& item : make_list(value)) + for (auto const& item : makeList(value)) { - if (ci_equal(item, token)) + if (ciEqual(item, token)) return true; } return false; } -template +template bool -is_keep_alive(boost::beast::http::message const& m) +isKeepAlive(boost::beast::http::message const& m) { if (m.version() <= 10) { diff --git a/include/xrpl/beast/test/yield_to.h b/include/xrpl/beast/test/yield_to.h index 6c7f293122..84d7d8846d 100644 --- a/include/xrpl/beast/test/yield_to.h +++ b/include/xrpl/beast/test/yield_to.h @@ -23,7 +23,7 @@ namespace beast::test { functions inside coroutines. This is handy for testing asynchronous asio code. */ -class enable_yield_to +class EnableYieldTo { protected: boost::asio::io_context ios_; @@ -39,8 +39,7 @@ public: /// The type of yield context passed to functions. using yield_context = boost::asio::yield_context; - explicit enable_yield_to(std::size_t concurrency = 1) - : work_(boost::asio::make_work_guard(ios_)) + explicit EnableYieldTo(std::size_t concurrency = 1) : work_(boost::asio::make_work_guard(ios_)) { threads_.reserve(concurrency); for (std::size_t i = 0; i < concurrency; ++i) @@ -49,7 +48,7 @@ public: } } - ~enable_yield_to() + ~EnableYieldTo() { work_ = boost::none; for (auto& t : threads_) @@ -58,7 +57,7 @@ public: /// Return the `io_context` associated with the object boost::asio::io_context& - get_io_context() + getIoContext() { return ios_; } @@ -81,7 +80,7 @@ public: #else template void - yield_to(F0&& f0, FN&&... fn); + yieldTo(F0&& f0, FN&&... fn); #endif private: @@ -97,7 +96,7 @@ private: template void -enable_yield_to::yield_to(F0&& f0, FN&&... fn) +EnableYieldTo::yieldTo(F0&& f0, FN&&... fn) { running_ = 1 + sizeof...(FN); spawn(f0, fn...); @@ -107,7 +106,7 @@ enable_yield_to::yield_to(F0&& f0, FN&&... fn) template inline void -enable_yield_to::spawn(F0&& f, FN&&... fn) +EnableYieldTo::spawn(F0&& f, FN&&... fn) { boost::asio::spawn( ios_, diff --git a/include/xrpl/beast/type_name.h b/include/xrpl/beast/type_name.h index d12f9c4b90..ae7b681af9 100644 --- a/include/xrpl/beast/type_name.h +++ b/include/xrpl/beast/type_name.h @@ -13,7 +13,7 @@ namespace beast { template std::string -type_name() +typeName() { using TR = std::remove_reference_t; diff --git a/include/xrpl/beast/unit_test/amount.h b/include/xrpl/beast/unit_test/amount.h index ae1dd8fe31..3a392f393f 100644 --- a/include/xrpl/beast/unit_test/amount.h +++ b/include/xrpl/beast/unit_test/amount.h @@ -11,31 +11,31 @@ namespace beast::unit_test { /** Utility for producing nicely composed output of amounts with units. */ -class amount +class Amount { private: std::size_t n_; std::string const& what_; public: - amount(amount const&) = default; - amount& - operator=(amount const&) = delete; + Amount(Amount const&) = default; + Amount& + operator=(Amount const&) = delete; template - amount(std::size_t n, std::string const& what); + Amount(std::size_t n, std::string const& what); friend std::ostream& - operator<<(std::ostream& s, amount const& t); + operator<<(std::ostream& s, Amount const& t); }; template -amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what) +Amount::Amount(std::size_t n, std::string const& what) : n_(n), what_(what) { } inline std::ostream& -operator<<(std::ostream& s, amount const& t) +operator<<(std::ostream& s, Amount const& t) { s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : ""); return s; diff --git a/include/xrpl/beast/unit_test/detail/const_container.h b/include/xrpl/beast/unit_test/detail/const_container.h index a36423f0ef..c171771e45 100644 --- a/include/xrpl/beast/unit_test/detail/const_container.h +++ b/include/xrpl/beast/unit_test/detail/const_container.h @@ -11,24 +11,24 @@ namespace beast::unit_test::detail { provide additional behavior. */ template -class const_container +class ConstContainer { private: using cont_type = Container; - cont_type m_cont; + cont_type cont_; protected: cont_type& cont() { - return m_cont; + return cont_; } [[nodiscard]] cont_type const& cont() const { - return m_cont; + return cont_; } public: @@ -42,14 +42,14 @@ public: [[nodiscard]] bool empty() const { - return m_cont.empty(); + return cont_.empty(); } /** Returns the number of items in the container. */ [[nodiscard]] size_type size() const { - return m_cont.size(); + return cont_.size(); } /** Returns forward iterators for traversal. */ @@ -57,25 +57,25 @@ public: [[nodiscard]] const_iterator begin() const { - return m_cont.cbegin(); + return cont_.cbegin(); } [[nodiscard]] const_iterator cbegin() const { - return m_cont.cbegin(); + return cont_.cbegin(); } [[nodiscard]] const_iterator end() const { - return m_cont.cend(); + return cont_.cend(); } [[nodiscard]] const_iterator cend() const { - return m_cont.cend(); + return cont_.cend(); } /** @} */ }; diff --git a/include/xrpl/beast/unit_test/global_suites.h b/include/xrpl/beast/unit_test/global_suites.h index ca33ddb11c..72ed738bdb 100644 --- a/include/xrpl/beast/unit_test/global_suites.h +++ b/include/xrpl/beast/unit_test/global_suites.h @@ -11,34 +11,34 @@ namespace beast::unit_test { namespace detail { /// Holds test suites registered during static initialization. -inline suite_list& -global_suites() +inline SuiteList& +globalSuites() { - static suite_list s; - return s; + static SuiteList kS; + return kS; } template -struct insert_suite +struct InsertSuite { - insert_suite( + InsertSuite( char const* name, char const* module, char const* library, bool manual, int priority) { - global_suites().insert(name, module, library, manual, priority); + globalSuites().insert(name, module, library, manual, priority); } }; } // namespace detail /// Holds test suites registered during static initialization. -inline suite_list const& -global_suites() +inline SuiteList const& +globalSuites() { - return detail::global_suites(); + return detail::globalSuites(); } } // namespace beast::unit_test diff --git a/include/xrpl/beast/unit_test/match.h b/include/xrpl/beast/unit_test/match.h index dbafd67da5..222c4ea656 100644 --- a/include/xrpl/beast/unit_test/match.h +++ b/include/xrpl/beast/unit_test/match.h @@ -11,70 +11,70 @@ namespace beast::unit_test { // Predicate for implementing matches -class selector +class Selector { public: - enum class mode_t { + enum class ModeT { // Run all tests except manual ones - all, + All, // Run tests that match in any field - automatch, + Automatch, // Match on suite - suite, + Suite, // Match on library - library, + Library, // Match on module (used internally) - module, + Module, // Match nothing (used internally) - none + None }; private: - mode_t mode_; + ModeT mode_; std::string pat_; std::string library_; public: template - explicit selector(mode_t mode, std::string const& pattern = ""); + explicit Selector(ModeT mode, std::string const& pattern = ""); template bool - operator()(suite_info const& s); + operator()(SuiteInfo const& s); }; //------------------------------------------------------------------------------ template -selector::selector(mode_t mode, std::string const& pattern) : mode_(mode), pat_(pattern) +Selector::Selector(ModeT mode, std::string const& pattern) : mode_(mode), pat_(pattern) { - if (mode_ == mode_t::automatch && pattern.empty()) - mode_ = mode_t::all; + if (mode_ == ModeT::Automatch && pattern.empty()) + mode_ = ModeT::All; } template bool -selector::operator()(suite_info const& s) +Selector::operator()(SuiteInfo const& s) { switch (mode_) { - case mode_t::automatch: + case ModeT::Automatch: // suite or full name - if (s.name() == pat_ || s.full_name() == pat_) + if (s.name() == pat_ || s.fullName() == pat_) { - mode_ = mode_t::none; + mode_ = ModeT::None; return true; } // check module if (pat_ == s.module()) { - mode_ = mode_t::module; + mode_ = ModeT::Module; library_ = s.library(); return !s.manual(); } @@ -82,12 +82,12 @@ selector::operator()(suite_info const& s) // check library if (pat_ == s.library()) { - mode_ = mode_t::library; + mode_ = ModeT::Library; return !s.manual(); } // check start of name - if (s.name().starts_with(pat_) || s.full_name().starts_with(pat_)) + if (s.name().starts_with(pat_) || s.fullName().starts_with(pat_)) { // Don't change the mode so that the partial pattern can match // more than once @@ -96,19 +96,19 @@ selector::operator()(suite_info const& s) return false; - case mode_t::suite: + case ModeT::Suite: return pat_ == s.name(); - case mode_t::module: + case ModeT::Module: return pat_ == s.module() && !s.manual(); - case mode_t::library: + case ModeT::Library: return pat_ == s.library() && !s.manual(); - case mode_t::none: + case ModeT::None: return false; - case mode_t::all: + case ModeT::All: default: break; }; @@ -122,7 +122,7 @@ selector::operator()(suite_info const& s) /** Returns a predicate that implements a smart matching rule. The predicate checks the suite, module, and library fields of the - suite_info in that order. When it finds a match, it changes modes + SuiteInfo in that order. When it finds a match, it changes modes depending on what was found: If a suite is matched first, then only the suite is selected. The @@ -135,31 +135,31 @@ selector::operator()(suite_info const& s) not marked manual are selected from then on. */ -inline selector -match_auto(std::string const& name) +inline Selector +matchAuto(std::string const& name) { - return selector(selector::mode_t::automatch, name); + return Selector(Selector::ModeT::Automatch, name); } /** Return a predicate that matches all suites not marked manual. */ -inline selector -match_all() +inline Selector +matchAll() { - return selector(selector::mode_t::all); + return Selector(Selector::ModeT::All); } /** Returns a predicate that matches a specific suite. */ -inline selector -match_suite(std::string const& name) +inline Selector +matchSuite(std::string const& name) { - return selector(selector::mode_t::suite, name); + return Selector(Selector::ModeT::Suite, name); } /** Returns a predicate that matches all suites in a library. */ -inline selector -match_library(std::string const& name) +inline Selector +matchLibrary(std::string const& name) { - return selector(selector::mode_t::library, name); + return Selector(Selector::ModeT::Library, name); } } // namespace beast::unit_test diff --git a/include/xrpl/beast/unit_test/recorder.h b/include/xrpl/beast/unit_test/recorder.h index 55305a4b70..2ed88d4a46 100644 --- a/include/xrpl/beast/unit_test/recorder.h +++ b/include/xrpl/beast/unit_test/recorder.h @@ -10,65 +10,65 @@ namespace beast::unit_test { /** A test runner that stores the results. */ -class recorder : public runner +class Recorder : public Runner { private: - results m_results; - suite_results m_suite; - case_results m_case; + Results results_; + SuiteResults suite_; + CaseResults case_; public: - recorder() = default; + Recorder() = default; /** Returns a report with the results of all completed suites. */ - [[nodiscard]] results const& + [[nodiscard]] Results const& report() const { - return m_results; + return results_; } private: void - on_suite_begin(suite_info const& info) override + onSuiteBegin(SuiteInfo const& info) override { - m_suite = suite_results(info.full_name()); + suite_ = SuiteResults(info.fullName()); } void - on_suite_end() override + onSuiteEnd() override { - m_results.insert(std::move(m_suite)); + results_.insert(std::move(suite_)); } void - on_case_begin(std::string const& name) override + onCaseBegin(std::string const& name) override { - m_case = case_results(name); + case_ = CaseResults(name); } void - on_case_end() override + onCaseEnd() override { - if (!m_case.tests.empty()) - m_suite.insert(std::move(m_case)); + if (!case_.tests.empty()) + suite_.insert(std::move(case_)); } void - on_pass() override + onPass() override { - m_case.tests.pass(); + case_.tests.pass(); } void - on_fail(std::string const& reason) override + onFail(std::string const& reason) override { - m_case.tests.fail(reason); + case_.tests.fail(reason); } void - on_log(std::string const& s) override + onLog(std::string const& s) override { - m_case.log.insert(s); + case_.log.insert(s); } }; diff --git a/include/xrpl/beast/unit_test/reporter.h b/include/xrpl/beast/unit_test/reporter.h index 58bea93b2f..d2ba624f4a 100644 --- a/include/xrpl/beast/unit_test/reporter.h +++ b/include/xrpl/beast/unit_test/reporter.h @@ -26,23 +26,23 @@ namespace detail { The totals are output when the object is destroyed. */ template -class reporter : public runner +class Reporter : public Runner { private: using clock_type = std::chrono::steady_clock; - struct case_results + struct CaseResults { std::string name; std::size_t total = 0; std::size_t failed = 0; - explicit case_results(std::string name_ = "") : name(std::move(name_)) + explicit CaseResults(std::string name = "") : name(std::move(name)) { } }; - struct suite_results + struct SuiteResults { std::string name; std::size_t cases = 0; @@ -50,21 +50,21 @@ private: std::size_t failed = 0; typename clock_type::time_point start = clock_type::now(); - explicit suite_results(std::string name_ = "") : name(std::move(name_)) + explicit SuiteResults(std::string name = "") : name(std::move(name)) { } void - add(case_results const& r); + add(CaseResults const& r); }; - struct results + struct Results { using run_time = std::pair; // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum { max_top = 10 }; + enum { MaxTop = 10 }; std::size_t suites = 0; std::size_t cases = 0; @@ -74,54 +74,54 @@ private: typename clock_type::time_point start = clock_type::now(); void - add(suite_results const& r); + add(SuiteResults const& r); }; std::ostream& os_; - results results_; - suite_results suite_results_; - case_results case_results_; + Results results_; + SuiteResults suite_results_; + CaseResults case_results_; public: - reporter(reporter const&) = delete; - reporter& - operator=(reporter const&) = delete; + Reporter(Reporter const&) = delete; + Reporter& + operator=(Reporter const&) = delete; - ~reporter() override; + ~Reporter() override; - explicit reporter(std::ostream& os = std::cout); + explicit Reporter(std::ostream& os = std::cout); private: static std::string fmtdur(typename clock_type::duration const& d); void - on_suite_begin(suite_info const& info) override; + onSuiteBegin(SuiteInfo const& info) override; void - on_suite_end() override; + onSuiteEnd() override; void - on_case_begin(std::string const& name) override; + onCaseBegin(std::string const& name) override; void - on_case_end() override; + onCaseEnd() override; void - on_pass() override; + onPass() override; void - on_fail(std::string const& reason) override; + onFail(std::string const& reason) override; void - on_log(std::string const& s) override; + onLog(std::string const& s) override; }; //------------------------------------------------------------------------------ template void -reporter::suite_results::add(case_results const& r) +Reporter::SuiteResults::add(CaseResults const& r) { ++cases; total += r.total; @@ -130,7 +130,7 @@ reporter::suite_results::add(case_results const& r) template void -reporter::results::add(suite_results const& r) +Reporter::Results::add(SuiteResults const& r) { ++suites; total += r.total; @@ -148,11 +148,11 @@ reporter::results::add(suite_results const& r) }); if (iter != top.end()) { - if (top.size() == max_top) + if (top.size() == MaxTop) top.resize(top.size() - 1); top.emplace(iter, r.name, elapsed); } - else if (top.size() < max_top) + else if (top.size() < MaxTop) { top.emplace_back(r.name, elapsed); } @@ -162,12 +162,12 @@ reporter::results::add(suite_results const& r) //------------------------------------------------------------------------------ template -reporter::reporter(std::ostream& os) : os_(os) +Reporter::Reporter(std::ostream& os) : os_(os) { } template -reporter::~reporter() +Reporter::~Reporter() { if (results_.top.size() > 0) { @@ -176,14 +176,14 @@ reporter::~reporter() os_ << std::setw(8) << fmtdur(i.second) << " " << i.first << '\n'; } auto const elapsed = clock_type::now() - results_.start; - os_ << fmtdur(elapsed) << ", " << amount{results_.suites, "suite"} << ", " - << amount{results_.cases, "case"} << ", " << amount{results_.total, "test"} << " total, " - << amount{results_.failed, "failure"} << std::endl; + os_ << fmtdur(elapsed) << ", " << Amount{results_.suites, "suite"} << ", " + << Amount{results_.cases, "case"} << ", " << Amount{results_.total, "test"} << " total, " + << Amount{results_.failed, "failure"} << std::endl; } template std::string -reporter::fmtdur(typename clock_type::duration const& d) +Reporter::fmtdur(typename clock_type::duration const& d) { using namespace std::chrono; auto const ms = duration_cast(d); @@ -196,44 +196,44 @@ reporter::fmtdur(typename clock_type::duration const& d) template void -reporter::on_suite_begin(suite_info const& info) +Reporter::onSuiteBegin(SuiteInfo const& info) { - suite_results_ = suite_results{info.full_name()}; + suite_results_ = SuiteResults{info.fullName()}; } template void -reporter::on_suite_end() +Reporter::onSuiteEnd() { results_.add(suite_results_); } template void -reporter::on_case_begin(std::string const& name) +Reporter::onCaseBegin(std::string const& name) { - case_results_ = case_results(name); + case_results_ = CaseResults(name); os_ << suite_results_.name << (case_results_.name.empty() ? "" : (" " + case_results_.name)) << std::endl; } template void -reporter::on_case_end() +Reporter::onCaseEnd() { suite_results_.add(case_results_); } template void -reporter::on_pass() +Reporter::onPass() { ++case_results_.total; } template void -reporter::on_fail(std::string const& reason) +Reporter::onFail(std::string const& reason) { ++case_results_.failed; ++case_results_.total; @@ -243,13 +243,13 @@ reporter::on_fail(std::string const& reason) template void -reporter::on_log(std::string const& s) +Reporter::onLog(std::string const& s) { os_ << s; } } // namespace detail -using reporter = detail::reporter<>; +using reporter = detail::Reporter<>; } // namespace beast::unit_test diff --git a/include/xrpl/beast/unit_test/results.h b/include/xrpl/beast/unit_test/results.h index 71c9aff47f..02aa9730d1 100644 --- a/include/xrpl/beast/unit_test/results.h +++ b/include/xrpl/beast/unit_test/results.h @@ -13,17 +13,17 @@ namespace beast::unit_test { /** Holds a set of test condition outcomes in a testcase. */ -class case_results +class CaseResults { public: /** Holds the result of evaluating one test condition. */ - struct test + struct Test { - explicit test(bool pass_) : pass(pass_) + explicit Test(bool pass) : pass(pass) { } - test(bool pass_, std::string reason_) : pass(pass_), reason(std::move(reason_)) + Test(bool pass, std::string reason) : pass(pass), reason(std::move(reason)) { } @@ -32,13 +32,13 @@ public: }; private: - class tests_t : public detail::const_container> + class TestsT : public detail::ConstContainer> { private: std::size_t failed_{0}; public: - tests_t() = default; + TestsT() = default; /** Returns the total number of test conditions. */ [[nodiscard]] std::size_t @@ -70,7 +70,7 @@ private: } }; - class log_t : public detail::const_container> + class LogT : public detail::ConstContainer> { public: /** Insert a string into the log. */ @@ -84,7 +84,7 @@ private: std::string name_; public: - explicit case_results(std::string name = "") : name_(std::move(name)) + explicit CaseResults(std::string name = "") : name_(std::move(name)) { } @@ -96,16 +96,16 @@ public: } /** Memberspace for a container of test condition outcomes. */ - tests_t tests; + TestsT tests; /** Memberspace for a container of testcase log messages. */ - log_t log; + LogT log; }; //-------------------------------------------------------------------------- /** Holds the set of testcase results in a suite. */ -class suite_results : public detail::const_container> +class SuiteResults : public detail::ConstContainer> { private: std::string name_; @@ -113,7 +113,7 @@ private: std::size_t failed_ = 0; public: - explicit suite_results(std::string name = "") : name_(std::move(name)) + explicit SuiteResults(std::string name = "") : name_(std::move(name)) { } @@ -141,7 +141,7 @@ public: /** Insert a set of testcase results. */ /** @{ */ void - insert(case_results&& r) + insert(CaseResults&& r) { total_ += r.tests.total(); failed_ += r.tests.failed(); @@ -149,7 +149,7 @@ public: } void - insert(case_results const& r) + insert(CaseResults const& r) { cont().push_back(r); total_ += r.tests.total(); @@ -162,21 +162,21 @@ public: // VFALCO TODO Make this a template class using scoped allocators /** Holds the results of running a set of testsuites. */ -class results : public detail::const_container> +class Results : public detail::ConstContainer> { private: - std::size_t m_cases{0}; + std::size_t cases_{0}; std::size_t total_{0}; std::size_t failed_{0}; public: - results() = default; + Results() = default; /** Returns the total number of test cases. */ [[nodiscard]] std::size_t cases() const { - return m_cases; + return cases_; } /** Returns the total number of test conditions. */ @@ -196,18 +196,18 @@ public: /** Insert a set of suite results. */ /** @{ */ void - insert(suite_results&& r) + insert(SuiteResults&& r) { - m_cases += r.size(); + cases_ += r.size(); total_ += r.total(); failed_ += r.failed(); cont().emplace_back(std::move(r)); } void - insert(suite_results const& r) + insert(SuiteResults const& r) { - m_cases += r.size(); + cases_ += r.size(); total_ += r.total(); failed_ += r.failed(); cont().push_back(r); diff --git a/include/xrpl/beast/unit_test/runner.h b/include/xrpl/beast/unit_test/runner.h index 5601a8725f..b88bfc5fe1 100644 --- a/include/xrpl/beast/unit_test/runner.h +++ b/include/xrpl/beast/unit_test/runner.h @@ -18,7 +18,7 @@ namespace beast::unit_test { Derived classes can customize the reporting behavior. This interface is injected into the unit_test class to receive the results of the tests. */ -class runner +class Runner { std::string arg_; bool default_ = false; @@ -27,11 +27,11 @@ class runner std::recursive_mutex mutex_; public: - runner() = default; - virtual ~runner() = default; - runner(runner const&) = delete; - runner& - operator=(runner const&) = delete; + Runner() = default; + virtual ~Runner() = default; + Runner(Runner const&) = delete; + Runner& + operator=(Runner const&) = delete; /** Set the argument string. @@ -58,12 +58,12 @@ public: */ template bool - run(suite_info const& s); + run(SuiteInfo const& s); /** Run a sequence of suites. The expression `FwdIter::value_type` - must be convertible to `suite_info`. + must be convertible to `SuiteInfo`. @return `true` if any conditions failed. */ template @@ -73,77 +73,77 @@ public: /** Conditionally run a sequence of suites. pred will be called as: @code - bool pred(suite_info const&); + bool pred(SuiteInfo const&); @endcode @return `true` if any conditions failed. */ template bool - run_if(FwdIter first, FwdIter last, Pred pred = Pred{}); + runIf(FwdIter first, FwdIter last, Pred pred = Pred{}); /** Run all suites in a container. @return `true` if any conditions failed. */ template bool - run_each(SequenceContainer const& c); + runEach(SequenceContainer const& c); /** Conditionally run suites in a container. pred will be called as: @code - bool pred(suite_info const&); + bool pred(SuiteInfo const&); @endcode @return `true` if any conditions failed. */ template bool - run_each_if(SequenceContainer const& c, Pred pred = Pred{}); + runEachIf(SequenceContainer const& c, Pred pred = Pred{}); protected: /// Called when a new suite starts. virtual void - on_suite_begin(suite_info const&) + onSuiteBegin(SuiteInfo const&) { } /// Called when a suite ends. virtual void - on_suite_end() + onSuiteEnd() { } /// Called when a new case starts. virtual void - on_case_begin(std::string const&) + onCaseBegin(std::string const&) { } /// Called when a new case ends. virtual void - on_case_end() + onCaseEnd() { } /// Called for each passing condition. virtual void - on_pass() + onPass() { } /// Called for each failing condition. virtual void - on_fail(std::string const&) + onFail(std::string const&) { } /// Called when a test logs output. virtual void - on_log(std::string const&) + onLog(std::string const&) { } private: - friend class suite; + friend class Suite; // Start a new testcase. template @@ -167,23 +167,23 @@ private: template bool -runner::run(suite_info const& s) +Runner::run(SuiteInfo const& s) { // Enable 'default' testcase default_ = true; failed_ = false; - on_suite_begin(s); + onSuiteBegin(s); s.run(*this); // Forgot to call pass or fail. BOOST_ASSERT(cond_); - on_case_end(); - on_suite_end(); + onCaseEnd(); + onSuiteEnd(); return failed_; } template bool -runner::run(FwdIter first, FwdIter last) +Runner::run(FwdIter first, FwdIter last) { bool failed(false); for (; first != last; ++first) @@ -193,7 +193,7 @@ runner::run(FwdIter first, FwdIter last) template bool -runner::run_if(FwdIter first, FwdIter last, Pred pred) +Runner::runIf(FwdIter first, FwdIter last, Pred pred) { bool failed(false); for (; first != last; ++first) @@ -206,7 +206,7 @@ runner::run_if(FwdIter first, FwdIter last, Pred pred) template bool -runner::run_each(SequenceContainer const& c) +Runner::runEach(SequenceContainer const& c) { bool failed(false); for (auto const& s : c) @@ -216,7 +216,7 @@ runner::run_each(SequenceContainer const& c) template bool -runner::run_each_if(SequenceContainer const& c, Pred pred) +Runner::runEachIf(SequenceContainer const& c, Pred pred) { bool failed(false); for (auto const& s : c) @@ -229,7 +229,7 @@ runner::run_each_if(SequenceContainer const& c, Pred pred) template void -runner::testcase(std::string const& name) +Runner::testcase(std::string const& name) { std::scoped_lock const lock(mutex_); // Name may not be empty @@ -237,43 +237,43 @@ runner::testcase(std::string const& name) // Forgot to call pass or fail BOOST_ASSERT(default_ || cond_); if (!default_) - on_case_end(); + onCaseEnd(); default_ = false; cond_ = false; - on_case_begin(name); + onCaseBegin(name); } template void -runner::pass() +Runner::pass() { std::scoped_lock const lock(mutex_); if (default_) testcase(""); - on_pass(); + onPass(); cond_ = true; } template void -runner::fail(std::string const& reason) +Runner::fail(std::string const& reason) { std::scoped_lock const lock(mutex_); if (default_) testcase(""); - on_fail(reason); + onFail(reason); failed_ = true; cond_ = true; } template void -runner::log(std::string const& s) +Runner::log(std::string const& s) { std::scoped_lock const lock(mutex_); if (default_) testcase(""); - on_log(s); + onLog(s); } } // namespace beast::unit_test diff --git a/include/xrpl/beast/unit_test/suite.h b/include/xrpl/beast/unit_test/suite.h index c6967ecfe3..999058b7f1 100644 --- a/include/xrpl/beast/unit_test/suite.h +++ b/include/xrpl/beast/unit_test/suite.h @@ -20,7 +20,7 @@ namespace detail { template static std::string -make_reason(String const& reason, char const* file, int line) +makeReason(String const& reason, char const* file, int line) { std::string s(reason); if (!s.empty()) @@ -37,7 +37,7 @@ make_reason(String const& reason, char const* file, int line) class Thread; -enum class abort_t { no_abort_on_fail, abort_on_fail }; +enum class AbortT { NoAbortOnFail, AbortOnFail }; /** A testsuite class. @@ -46,16 +46,16 @@ enum class abort_t { no_abort_on_fail, abort_on_fail }; derive from it and use the BEAST_DEFINE_UNIT_TEST macro in a translation unit. */ -class suite +class Suite { private: bool abort_ = false; bool aborted_ = false; - runner* runner_ = nullptr; + Runner* runner_ = nullptr; // This exception is thrown internally to stop the current suite // in the event of a failure, if the option to stop is set. - struct abort_exception : public std::exception + struct AbortException : public std::exception { [[nodiscard]] char const* what() const noexcept override @@ -65,16 +65,16 @@ private: }; template - class log_buf : public std::basic_stringbuf + class LogBuf : public std::basic_stringbuf { - suite& suite_; + Suite& suite_; public: - explicit log_buf(suite& self) : suite_(self) + explicit LogBuf(Suite& self) : suite_(self) { } - ~log_buf() override + ~LogBuf() override { sync(); } @@ -94,25 +94,25 @@ private: class CharT, class Traits = std::char_traits, class Allocator = std::allocator> - class log_os : public std::basic_ostream + class LogOs : public std::basic_ostream { - log_buf buf_; + LogBuf buf_; public: - explicit log_os(suite& self) : std::basic_ostream(&buf_), buf_(self) + explicit LogOs(Suite& self) : std::basic_ostream(&buf_), buf_(self) { } }; - class scoped_testcase; + class ScopedTestcase; - class testcase_t + class TestcaseT { - suite& suite_; + Suite& suite_; std::stringstream ss_; public: - explicit testcase_t(suite& self) : suite_(self) + explicit TestcaseT(Suite& self) : suite_(self) { } @@ -127,13 +127,13 @@ private: @param abort Determines if suite continues running after a failure. */ void - operator()(std::string const& name, abort_t abort = abort_t::no_abort_on_fail); + operator()(std::string const& name, AbortT abort = AbortT::NoAbortOnFail); - scoped_testcase - operator()(abort_t abort); + ScopedTestcase + operator()(AbortT abort); template - scoped_testcase + ScopedTestcase operator<<(T const& t); }; @@ -143,28 +143,28 @@ public: Text sent to the log output stream will be forwarded to the output stream associated with the runner. */ - log_os log; + LogOs log; /** Memberspace for declaring test cases. */ - testcase_t testcase; + TestcaseT testcase; /** Returns the "current" running suite. If no suite is running, nullptr is returned. */ - static suite* - this_suite() + static Suite* + thisSuite() { - return *p_this_suite(); + return *pThisSuite(); } - suite() : log(*this), testcase(*this) + Suite() : log(*this), testcase(*this) { } - virtual ~suite() = default; - suite(suite const&) = delete; - suite& - operator=(suite const&) = delete; + virtual ~Suite() = default; + Suite(Suite const&) = delete; + Suite& + operator=(Suite const&) = delete; /** Invokes the test using the specified runner. @@ -175,7 +175,7 @@ public: */ template void - operator()(runner& r); + operator()(Runner& r); /** Record a successful test condition. */ template @@ -296,11 +296,11 @@ public: private: friend class Thread; - static suite** - p_this_suite() + static Suite** + pThisSuite() { - static suite* pts = nullptr; // NOLINT(misc-const-correctness) - return &pts; + static Suite* kP_TS = nullptr; // NOLINT TODO + return &kP_TS; } /** Runs the suite. */ @@ -308,41 +308,41 @@ private: run() = 0; void - propagate_abort() const; + propagateAbort() const; template void - run(runner& r); + run(Runner& r); }; //------------------------------------------------------------------------------ // Helper for streaming testcase names -class suite::scoped_testcase +class Suite::ScopedTestcase { private: - suite& suite_; + Suite& suite_; std::stringstream& ss_; public: - scoped_testcase& - operator=(scoped_testcase const&) = delete; + ScopedTestcase& + operator=(ScopedTestcase const&) = delete; - ~scoped_testcase() + ~ScopedTestcase() { auto const& name = ss_.str(); if (!name.empty()) suite_.runner_->testcase(name); } - scoped_testcase(suite& self, std::stringstream& ss) : suite_(self), ss_(ss) + ScopedTestcase(Suite& self, std::stringstream& ss) : suite_(self), ss_(ss) { ss_.clear(); ss_.str({}); } template - scoped_testcase(suite& self, std::stringstream& ss, T const& t) : suite_(self), ss_(ss) + ScopedTestcase(Suite& self, std::stringstream& ss, T const& t) : suite_(self), ss_(ss) { ss_.clear(); ss_.str({}); @@ -350,7 +350,7 @@ public: } template - scoped_testcase& + ScopedTestcase& operator<<(T const& t) { ss_ << t; @@ -361,22 +361,22 @@ public: //------------------------------------------------------------------------------ inline void -suite::testcase_t::operator()(std::string const& name, abort_t abort) +Suite::TestcaseT::operator()(std::string const& name, AbortT abort) { - suite_.abort_ = abort == abort_t::abort_on_fail; + suite_.abort_ = abort == AbortT::AbortOnFail; suite_.runner_->testcase(name); } -inline suite::scoped_testcase -suite::testcase_t::operator()(abort_t abort) +inline Suite::ScopedTestcase +Suite::TestcaseT::operator()(AbortT abort) { - suite_.abort_ = abort == abort_t::abort_on_fail; + suite_.abort_ = abort == AbortT::AbortOnFail; return {suite_, ss_}; } template -inline suite::scoped_testcase -suite::testcase_t::operator<<(T const& t) +inline Suite::ScopedTestcase +Suite::TestcaseT::operator<<(T const& t) { return {suite_, ss_, t}; } @@ -385,24 +385,24 @@ suite::testcase_t::operator<<(T const& t) template void -suite::operator()(runner& r) +Suite::operator()(Runner& r) { - *p_this_suite() = this; + *pThisSuite() = this; try { run(r); - *p_this_suite() = nullptr; + *pThisSuite() = nullptr; } catch (...) { - *p_this_suite() = nullptr; + *pThisSuite() = nullptr; throw; } } template bool -suite::expect(Condition const& shouldBeTrue, String const& reason) +Suite::expect(Condition const& shouldBeTrue, String const& reason) { if (shouldBeTrue) { @@ -415,14 +415,14 @@ suite::expect(Condition const& shouldBeTrue, String const& reason) template bool -suite::expect(Condition const& shouldBeTrue, String const& reason, char const* file, int line) +Suite::expect(Condition const& shouldBeTrue, String const& reason, char const* file, int line) { if (shouldBeTrue) { pass(); return true; } - fail(detail::make_reason(reason, file, line)); + fail(detail::makeReason(reason, file, line)); return false; } @@ -430,7 +430,7 @@ suite::expect(Condition const& shouldBeTrue, String const& reason, char const* f template bool -suite::except(F&& f, String const& reason) +Suite::except(F&& f, String const& reason) { try { @@ -447,7 +447,7 @@ suite::except(F&& f, String const& reason) template bool -suite::except(F&& f, String const& reason) +Suite::except(F&& f, String const& reason) { try { @@ -464,7 +464,7 @@ suite::except(F&& f, String const& reason) template bool -suite::unexcept(F&& f, String const& reason) +Suite::unexcept(F&& f, String const& reason) { try { @@ -481,7 +481,7 @@ suite::unexcept(F&& f, String const& reason) template bool -suite::unexpected(Condition shouldBeFalse, String const& reason) +Suite::unexpected(Condition shouldBeFalse, String const& reason) { bool const b = static_cast(shouldBeFalse); if (!b) @@ -497,43 +497,43 @@ suite::unexpected(Condition shouldBeFalse, String const& reason) template void -suite::pass() +Suite::pass() { - propagate_abort(); + propagateAbort(); runner_->pass(); } // ::fail template void -suite::fail(std::string const& reason) +Suite::fail(std::string const& reason) { - propagate_abort(); + propagateAbort(); runner_->fail(reason); if (abort_) { aborted_ = true; - BOOST_THROW_EXCEPTION(abort_exception()); + BOOST_THROW_EXCEPTION(AbortException()); } } template void -suite::fail(String const& reason, char const* file, int line) +Suite::fail(String const& reason, char const* file, int line) { - fail(detail::make_reason(reason, file, line)); + fail(detail::makeReason(reason, file, line)); } inline void -suite::propagate_abort() const +Suite::propagateAbort() const { if (abort_ && aborted_) - BOOST_THROW_EXCEPTION(abort_exception()); + BOOST_THROW_EXCEPTION(AbortException()); } template void -suite::run(runner& r) +Suite::run(Runner& r) { runner_ = &r; @@ -541,7 +541,7 @@ suite::run(runner& r) { run(); } - catch (abort_exception const&) // NOLINT(bugprone-empty-catch) + catch (AbortException const&) // NOLINT(bugprone-empty-catch) { // ends the suite } @@ -579,7 +579,7 @@ suite::run(runner& r) // detail: // This inserts the suite with the given manual flag #define BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, manual, priority) \ - static beast::unit_test::detail::insert_suite \ + static beast::unit_test::detail::InsertSuite \ Library##Module##Class##_test_instance(#Class, #Module, #Library, manual, priority) //------------------------------------------------------------------------------ diff --git a/include/xrpl/beast/unit_test/suite_info.h b/include/xrpl/beast/unit_test/suite_info.h index e814d518cb..c09a0c2257 100644 --- a/include/xrpl/beast/unit_test/suite_info.h +++ b/include/xrpl/beast/unit_test/suite_info.h @@ -11,12 +11,12 @@ namespace beast::unit_test { -class runner; +class Runner; /** Associates a unit test type with metadata. */ -class suite_info +class SuiteInfo { - using run_type = std::function; + using run_type = std::function; std::string name_; std::string module_; @@ -26,7 +26,7 @@ class suite_info run_type run_; public: - suite_info( + SuiteInfo( std::string name, std::string module, std::string library, @@ -69,20 +69,20 @@ public: /// Return the canonical suite name as a string. [[nodiscard]] std::string - full_name() const + fullName() const { return library_ + "." + module_ + "." + name_; } /// Run a new instance of the associated test suite. void - run(runner& r) const + run(Runner& r) const { run_(r); } friend bool - operator<(suite_info const& lhs, suite_info const& rhs) + operator<(SuiteInfo const& lhs, SuiteInfo const& rhs) { // we want higher priority suites sorted first, thus the negation // of priority value here @@ -93,18 +93,13 @@ public: //------------------------------------------------------------------------------ -/// Convenience for producing suite_info for a given test type. +/// Convenience for producing SuiteInfo for a given test type. template -suite_info -make_suite_info( - std::string name, - std::string module, - std::string library, - bool manual, - int priority) +SuiteInfo +makeSuiteInfo(std::string name, std::string module, std::string library, bool manual, int priority) { - return suite_info( - std::move(name), std::move(module), std::move(library), manual, priority, [](runner& r) { + return SuiteInfo( + std::move(name), std::move(module), std::move(library), manual, priority, [](Runner& r) { Suite{}(r); }); } diff --git a/include/xrpl/beast/unit_test/suite_list.h b/include/xrpl/beast/unit_test/suite_list.h index deffbdfe84..748f994602 100644 --- a/include/xrpl/beast/unit_test/suite_list.h +++ b/include/xrpl/beast/unit_test/suite_list.h @@ -16,7 +16,7 @@ namespace beast::unit_test { /// A container of test suites. -class suite_list : public detail::const_container> +class SuiteList : public detail::ConstContainer> { private: #ifndef NDEBUG @@ -38,7 +38,7 @@ public: template void -suite_list::insert( +SuiteList::insert( char const* name, char const* module, char const* library, @@ -58,7 +58,7 @@ suite_list::insert( BOOST_ASSERT(result.second); // Duplicate type } #endif - cont().emplace(make_suite_info(name, module, library, manual, priority)); + cont().emplace(makeSuiteInfo(name, module, library, manual, priority)); } } // namespace beast::unit_test diff --git a/include/xrpl/beast/unit_test/thread.h b/include/xrpl/beast/unit_test/thread.h index aa9ff3b0d9..7ae093eb85 100644 --- a/include/xrpl/beast/unit_test/thread.h +++ b/include/xrpl/beast/unit_test/thread.h @@ -16,7 +16,7 @@ namespace beast::unit_test { class Thread { private: - suite* s_ = nullptr; + Suite* s_ = nullptr; std::thread t_; public: @@ -41,7 +41,7 @@ public: } template - explicit Thread(suite& s, F&& f, Args&&... args) : s_(&s) + explicit Thread(Suite& s, F&& f, Args&&... args) : s_(&s) { std::function b = std::bind(std::forward(f), std::forward(args)...); t_ = std::thread(&Thread::run, this, std::move(b)); @@ -54,13 +54,13 @@ public: } [[nodiscard]] std::thread::id - get_id() const + getId() const { return t_.get_id(); } static unsigned - hardware_concurrency() noexcept + hardwareConcurrency() noexcept { return std::thread::hardware_concurrency(); } @@ -69,7 +69,7 @@ public: join() { t_.join(); - s_->propagate_abort(); + s_->propagateAbort(); } void @@ -93,7 +93,7 @@ private: { f(); } - catch (suite::abort_exception const&) // NOLINT(bugprone-empty-catch) + catch (Suite::AbortException const&) // NOLINT(bugprone-empty-catch) { } catch (std::exception const& e) diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 45b7b671cb..0fd0019235 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -12,17 +12,17 @@ namespace severities { // Hundreds of usages via logging macros // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum Severity { - kAll = 0, + KAll = 0, - kTrace = kAll, - kDebug = 1, - kInfo = 2, - kWarning = 3, - kError = 4, - kFatal = 5, + KTrace = KAll, + KDebug = 1, + KInfo = 2, + KWarning = 3, + KError = 4, + KFatal = 5, - kDisabled = 6, - kNone = kDisabled + KDisabled = 6, + KNone = KDisabled }; } // namespace severities @@ -47,8 +47,8 @@ private: // Severity level / threshold of a Journal message. using Severity = severities::Severity; - // Invariant: m_sink always points to a valid Sink - Sink* m_sink; + // Invariant: sink_ always points to a valid Sink + Sink* sink_; public: //-------------------------------------------------------------------------- @@ -108,7 +108,7 @@ public: private: Severity thresh_; - bool m_console; + bool console_; }; #ifndef __INTELLISENSE__ @@ -132,7 +132,7 @@ public: class ScopedStream { public: - ScopedStream(ScopedStream const& other) : ScopedStream(other.m_sink, other.m_level) + ScopedStream(ScopedStream const& other) : ScopedStream(other.sink_, other.level_) { } @@ -151,7 +151,7 @@ public: std::ostringstream& ostream() const { - return m_ostream; + return ostream_; } std::ostream& @@ -162,9 +162,9 @@ public: operator<<(T const& t) const; private: - Sink& m_sink; - Severity const m_level; - std::ostringstream mutable m_ostream; + Sink& sink_; + Severity const level_; + std::ostringstream mutable ostream_; }; #ifndef __INTELLISENSE__ @@ -183,7 +183,7 @@ public: { public: /** Create a stream which produces no output. */ - explicit Stream() : m_sink(getNullSink()), m_level(severities::kDisabled) + explicit Stream() : sink_(getNullSink()), level_(severities::KDisabled) { } @@ -191,14 +191,14 @@ public: Constructor is inlined so checking active() very inexpensive. */ - Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) + Stream(Sink& sink, Severity level) : sink_(sink), level_(level) { XRPL_ASSERT( - m_level < severities::kDisabled, "beast::Journal::Stream::Stream : maximum level"); + level_ < severities::KDisabled, "beast::Journal::Stream::Stream : maximum level"); } /** Construct or copy another Stream. */ - Stream(Stream const& other) : Stream(other.m_sink, other.m_level) + Stream(Stream const& other) : Stream(other.sink_, other.level_) { } @@ -209,14 +209,14 @@ public: [[nodiscard]] Sink& sink() const { - return m_sink; + return sink_; } /** Returns the Severity level of messages this Stream reports. */ [[nodiscard]] Severity level() const { - return m_level; + return level_; } /** Returns `true` if sink logs anything at this stream's level. */ @@ -224,7 +224,7 @@ public: [[nodiscard]] bool active() const { - return m_sink.active(m_level); + return sink_.active(level_); } explicit @@ -245,8 +245,8 @@ public: /** @} */ private: - Sink& m_sink; - Severity m_level; + Sink& sink_; + Severity level_; }; #ifndef __INTELLISENSE__ @@ -264,7 +264,7 @@ public: Journal() = delete; /** Create a journal that writes to the specified sink. */ - explicit Journal(Sink& sink) : m_sink(&sink) + explicit Journal(Sink& sink) : sink_(&sink) { } @@ -272,14 +272,14 @@ public: [[nodiscard]] Sink& sink() const { - return *m_sink; + return *sink_; } /** Returns a stream for this sink, with the specified severity level. */ [[nodiscard]] Stream stream(Severity level) const { - return Stream(*m_sink, level); + return Stream(*sink_, level); } /** Returns `true` if any message would be logged at this severity level. @@ -289,7 +289,7 @@ public: [[nodiscard]] bool active(Severity level) const { - return m_sink->active(level); + return sink_->active(level); } /** Severity stream access functions. */ @@ -297,37 +297,37 @@ public: [[nodiscard]] Stream trace() const { - return {*m_sink, severities::kTrace}; + return {*sink_, severities::KTrace}; } [[nodiscard]] Stream debug() const { - return {*m_sink, severities::kDebug}; + return {*sink_, severities::KDebug}; } [[nodiscard]] Stream info() const { - return {*m_sink, severities::kInfo}; + return {*sink_, severities::KInfo}; } [[nodiscard]] Stream warn() const { - return {*m_sink, severities::kWarning}; + return {*sink_, severities::KWarning}; } [[nodiscard]] Stream error() const { - return {*m_sink, severities::kError}; + return {*sink_, severities::KError}; } [[nodiscard]] Stream fatal() const { - return {*m_sink, severities::kFatal}; + return {*sink_, severities::KFatal}; } /** @} */ }; @@ -347,15 +347,15 @@ template Journal::ScopedStream::ScopedStream(Journal::Stream const& stream, T const& t) : ScopedStream(stream.sink(), stream.level()) { - m_ostream << t; + ostream_ << t; } template std::ostream& Journal::ScopedStream::operator<<(T const& t) const { - m_ostream << t; - return m_ostream; + ostream_ << t; + return ostream_; } //------------------------------------------------------------------------------ @@ -370,7 +370,7 @@ Journal::Stream::operator<<(T const& t) const namespace detail { template > -class logstream_buf : public std::basic_stringbuf +class LogStreamBuf : public std::basic_stringbuf { beast::Journal::Stream strm_; @@ -389,11 +389,11 @@ class logstream_buf : public std::basic_stringbuf } public: - explicit logstream_buf(beast::Journal::Stream const& strm) : strm_(strm) + explicit LogStreamBuf(beast::Journal::Stream const& strm) : strm_(strm) { } - ~logstream_buf() override + ~LogStreamBuf() override { sync(); } @@ -414,7 +414,7 @@ public: } // namespace detail template > -class basic_logstream : public std::basic_ostream +class BasicLogstream : public std::basic_ostream { using char_type = CharT; using traits_type = Traits; @@ -422,16 +422,16 @@ class basic_logstream : public std::basic_ostream using pos_type = typename traits_type::pos_type; using off_type = typename traits_type::off_type; - detail::logstream_buf buf_; + detail::LogStreamBuf buf_; public: - explicit basic_logstream(beast::Journal::Stream const& strm) + explicit BasicLogstream(beast::Journal::Stream const& strm) : std::basic_ostream(&buf_), buf_(strm) { } }; -using logstream = basic_logstream; -using logwstream = basic_logstream; +using logstream = BasicLogstream; +using logwstream = BasicLogstream; } // namespace beast diff --git a/include/xrpl/beast/utility/PropertyStream.h b/include/xrpl/beast/utility/PropertyStream.h index 39e354cc31..62de019edd 100644 --- a/include/xrpl/beast/utility/PropertyStream.h +++ b/include/xrpl/beast/utility/PropertyStream.h @@ -23,11 +23,11 @@ public: protected: virtual void - map_begin() = 0; + mapBegin() = 0; virtual void - map_begin(std::string const& key) = 0; + mapBegin(std::string const& key) = 0; virtual void - map_end() = 0; + mapEnd() = 0; virtual void add(std::string const& key, std::string const& value) = 0; @@ -40,7 +40,7 @@ protected: template void - lexical_add(std::string const& key, Value value) + lexicalAdd(std::string const& key, Value value) { std::stringstream ss; ss << value; @@ -79,11 +79,11 @@ protected: add(std::string const& key, long double value); virtual void - array_begin() = 0; + arrayBegin() = 0; virtual void - array_begin(std::string const& key) = 0; + arrayBegin(std::string const& key) = 0; virtual void - array_end() = 0; + arrayEnd() = 0; virtual void add(std::string const& value) = 0; @@ -96,7 +96,7 @@ protected: template void - lexical_add(Value value) + lexicalAdd(Value value) { std::stringstream ss; ss << value; @@ -157,7 +157,7 @@ public: operator*() const; private: - Source* m_source; + Source* source_; }; //------------------------------------------------------------------------------ @@ -169,9 +169,9 @@ private: class PropertyStream::Proxy { private: - Map const* m_map; - std::string m_key; - std::ostringstream mutable m_ostream; + Map const* map_; + std::string key_; + std::ostringstream mutable ostream_; public: Proxy(Map const& map, std::string key); @@ -189,7 +189,7 @@ public: std::ostream& operator<<(T const& t) const { - return m_ostream << t; + return ostream_ << t; } }; @@ -202,7 +202,7 @@ public: class PropertyStream::Map { private: - PropertyStream& m_stream; + PropertyStream& stream_; public: explicit Map(PropertyStream& stream); @@ -224,7 +224,7 @@ public: void add(std::string const& key, Value value) const { - m_stream.add(key, value); + stream_.add(key, value); } template @@ -261,7 +261,7 @@ template PropertyStream::Proxy& PropertyStream::Proxy::operator=(Value value) { - m_map->add(m_key, value); + map_->add(key_, value); return *this; } @@ -274,7 +274,7 @@ PropertyStream::Proxy::operator=(Value value) class PropertyStream::Set { private: - PropertyStream& m_stream; + PropertyStream& stream_; public: Set(std::string const& key, Map& map); @@ -294,7 +294,7 @@ public: void add(Value value) const { - m_stream.add(value); + stream_.add(value); } }; @@ -308,7 +308,7 @@ public: class PropertyStream::Source { private: - std::string const m_name; + std::string const name_; std::recursive_mutex lock_; Item item_; Source* parent_{nullptr}; @@ -351,7 +351,7 @@ public: /** Write only this Source to the stream. */ void - write_one(PropertyStream& stream); + writeOne(PropertyStream& stream); /** write this source and all its children recursively to the stream. */ void @@ -384,18 +384,18 @@ public: find(std::string path); Source* - find_one_deep(std::string const& name); + findOneDeep(std::string const& name); PropertyStream::Source* - find_path(std::string path); + findPath(std::string path); PropertyStream::Source* - find_one(std::string const& name); + findOne(std::string const& name); static bool - peel_leading_slash(std::string* path); + peelLeadingSlash(std::string* path); static bool - peel_trailing_slashstar(std::string* path); + peelTrailingSlashstar(std::string* path); static std::string - peel_name(std::string* path); + peelName(std::string* path); //-------------------------------------------------------------------------- diff --git a/include/xrpl/beast/utility/Zero.h b/include/xrpl/beast/utility/Zero.h index ff212b9c98..7825bb96e0 100644 --- a/include/xrpl/beast/utility/Zero.h +++ b/include/xrpl/beast/utility/Zero.h @@ -27,7 +27,7 @@ struct Zero }; namespace { -constexpr Zero zero{}; +constexpr Zero kZERO{}; } // namespace /** Default implementation of signum calls the method on the class. */ @@ -44,7 +44,7 @@ namespace detail::zero_helper { // be made from a namespace that does not include overloads of the function.. template auto -call_signum(T const& t) +callSignum(T const& t) { return signum(t); } @@ -57,42 +57,42 @@ template bool operator==(T const& t, Zero) { - return detail::zero_helper::call_signum(t) == 0; + return detail::zero_helper::callSignum(t) == 0; } template bool operator!=(T const& t, Zero) { - return detail::zero_helper::call_signum(t) != 0; + return detail::zero_helper::callSignum(t) != 0; } template bool operator<(T const& t, Zero) { - return detail::zero_helper::call_signum(t) < 0; + return detail::zero_helper::callSignum(t) < 0; } template bool operator>(T const& t, Zero) { - return detail::zero_helper::call_signum(t) > 0; + return detail::zero_helper::callSignum(t) > 0; } template bool operator>=(T const& t, Zero) { - return detail::zero_helper::call_signum(t) >= 0; + return detail::zero_helper::callSignum(t) >= 0; } template bool operator<=(T const& t, Zero) { - return detail::zero_helper::call_signum(t) <= 0; + return detail::zero_helper::callSignum(t) <= 0; } // Handle operators where T is on the right side by @@ -102,42 +102,42 @@ template bool operator==(Zero, T const& t) { - return t == zero; + return t == kZERO; } template bool operator!=(Zero, T const& t) { - return t != zero; + return t != kZERO; } template bool operator<(Zero, T const& t) { - return t > zero; + return t > kZERO; } template bool operator>(Zero, T const& t) { - return t < zero; + return t < kZERO; } template bool operator>=(Zero, T const& t) { - return t <= zero; + return t <= kZERO; } template bool operator<=(Zero, T const& t) { - return t >= zero; + return t >= kZERO; } } // namespace beast diff --git a/include/xrpl/beast/utility/maybe_const.h b/include/xrpl/beast/utility/maybe_const.h index bcfd7a7532..40904471be 100644 --- a/include/xrpl/beast/utility/maybe_const.h +++ b/include/xrpl/beast/utility/maybe_const.h @@ -6,15 +6,15 @@ namespace beast { /** Makes T const or non const depending on a bool. */ template -struct maybe_const +struct MaybeConst { - explicit maybe_const() = default; + explicit MaybeConst() = default; using type = std:: conditional_t::type const, std::remove_const_t>; }; /** Alias for omitting `typename`. */ template -using maybe_const_t = typename maybe_const::type; +using maybe_const_t = typename MaybeConst::type; } // namespace beast diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index f6ac46476d..1bc8350d4f 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -14,24 +14,24 @@ void rngfill(void* const buffer, std::size_t const bytes, Generator& g) { using result_type = typename Generator::result_type; - constexpr std::size_t result_size = sizeof(result_type); + constexpr std::size_t kRESULT_SIZE = sizeof(result_type); - std::uint8_t* const buffer_start = static_cast(buffer); - std::size_t const complete_iterations = bytes / result_size; - std::size_t const bytes_remaining = bytes % result_size; + std::uint8_t* const bufferStart = static_cast(buffer); + std::size_t const completeIterations = bytes / kRESULT_SIZE; + std::size_t const bytesRemaining = bytes % kRESULT_SIZE; - for (std::size_t count = 0; count < complete_iterations; ++count) + for (std::size_t count = 0; count < completeIterations; ++count) { result_type const v = g(); - std::size_t const offset = count * result_size; - std::memcpy(buffer_start + offset, &v, result_size); + std::size_t const offset = count * kRESULT_SIZE; + std::memcpy(bufferStart + offset, &v, kRESULT_SIZE); } - if (bytes_remaining > 0) + if (bytesRemaining > 0) { result_type const v = g(); - std::size_t const offset = complete_iterations * result_size; - std::memcpy(buffer_start + offset, &v, bytes_remaining); + std::size_t const offset = completeIterations * kRESULT_SIZE; + std::memcpy(bufferStart + offset, &v, bytesRemaining); } } diff --git a/include/xrpl/beast/utility/temp_dir.h b/include/xrpl/beast/utility/temp_dir.h index 09e68c4e6b..ec661b51c4 100644 --- a/include/xrpl/beast/utility/temp_dir.h +++ b/include/xrpl/beast/utility/temp_dir.h @@ -11,19 +11,19 @@ namespace beast { The directory and all its contents are deleted when the instance of `temp_dir` is destroyed. */ -class temp_dir +class TempDir { boost::filesystem::path path_; public: #if !GENERATING_DOCS - temp_dir(temp_dir const&) = delete; - temp_dir& - operator=(temp_dir const&) = delete; + TempDir(TempDir const&) = delete; + TempDir& + operator=(TempDir const&) = delete; #endif /// Construct a temporary directory. - temp_dir() + TempDir() { auto const dir = boost::filesystem::temp_directory_path(); do @@ -34,7 +34,7 @@ public: } /// Destroy a temporary directory. - ~temp_dir() + ~TempDir() { // use non-throwing calls in the destructor boost::system::error_code ec; diff --git a/include/xrpl/beast/xor_shift_engine.h b/include/xrpl/beast/xor_shift_engine.h index 85504f51aa..3a5345934e 100644 --- a/include/xrpl/beast/xor_shift_engine.h +++ b/include/xrpl/beast/xor_shift_engine.h @@ -9,16 +9,16 @@ namespace beast { namespace detail { template -class xor_shift_engine +class XorShiftEngine { public: using result_type = std::uint64_t; - xor_shift_engine(xor_shift_engine const&) = default; - xor_shift_engine& - operator=(xor_shift_engine const&) = default; + XorShiftEngine(XorShiftEngine const&) = default; + XorShiftEngine& + operator=(XorShiftEngine const&) = default; - explicit xor_shift_engine(result_type val = 1977u); + explicit XorShiftEngine(result_type val = 1977u); void seed(result_type seed); @@ -44,14 +44,14 @@ private: }; template -xor_shift_engine::xor_shift_engine(result_type val) +XorShiftEngine::XorShiftEngine(result_type val) { seed(val); } template void -xor_shift_engine::seed(result_type seed) +XorShiftEngine::seed(result_type seed) { if (seed == 0) throw std::domain_error("invalid seed"); @@ -61,7 +61,7 @@ xor_shift_engine::seed(result_type seed) template auto -xor_shift_engine::operator()() -> result_type +XorShiftEngine::operator()() -> result_type { result_type s1 = s_[0]; result_type const s0 = s_[1]; @@ -72,7 +72,7 @@ xor_shift_engine::operator()() -> result_type template auto -xor_shift_engine::murmurhash3(result_type x) -> result_type +XorShiftEngine::murmurhash3(result_type x) -> result_type { x ^= x >> 33; x *= 0xff51afd7ed558ccdULL; @@ -91,6 +91,6 @@ xor_shift_engine::murmurhash3(result_type x) -> result_type http://xorshift.di.unimi.it/xorshift128plus.c does not accept seed==0 */ -using xor_shift_engine = detail::xor_shift_engine<>; +using xor_shift_engine = detail::XorShiftEngine<>; } // namespace beast diff --git a/include/xrpl/conditions/Condition.h b/include/xrpl/conditions/Condition.h index 4b24c5a289..0d45245585 100644 --- a/include/xrpl/conditions/Condition.h +++ b/include/xrpl/conditions/Condition.h @@ -10,11 +10,11 @@ namespace xrpl::cryptoconditions { enum class Type : std::uint8_t { - preimageSha256 = 0, - prefixSha256 = 1, - thresholdSha256 = 2, - rsaSha256 = 3, - ed25519Sha256 = 4 + PreimageSha256 = 0, + PrefixSha256 = 1, + ThresholdSha256 = 2, + RsaSha256 = 3, + Ed25519Sha256 = 4 }; class Condition @@ -27,7 +27,7 @@ public: that were previously considered valid to no longer be allowed. */ - static constexpr std::size_t maxSerializedCondition = 128; + static constexpr std::size_t kMAX_SERIALIZED_CONDITION = 128; /** Load a condition from its binary form diff --git a/include/xrpl/conditions/Fulfillment.h b/include/xrpl/conditions/Fulfillment.h index cf28e29185..8b315297d7 100644 --- a/include/xrpl/conditions/Fulfillment.h +++ b/include/xrpl/conditions/Fulfillment.h @@ -16,7 +16,7 @@ public: that were previously considered valid to no longer be allowed. */ - static constexpr std::size_t maxSerializedFulfillment = 256; + static constexpr std::size_t kMAX_SERIALIZED_FULFILLMENT = 256; /** Load a fulfillment from its binary form diff --git a/include/xrpl/conditions/detail/PreimageSha256.h b/include/xrpl/conditions/detail/PreimageSha256.h index 1e5e93eb89..e3018f754c 100644 --- a/include/xrpl/conditions/detail/PreimageSha256.h +++ b/include/xrpl/conditions/detail/PreimageSha256.h @@ -23,7 +23,7 @@ public: While future versions of this code will never lower this limit, they may opt to raise it. */ - static constexpr std::size_t maxPreimageLength = 128; + static constexpr std::size_t kMAX_PREIMAGE_LENGTH = 128; /** Parse the payload for a PreimageSha256 condition @@ -49,25 +49,25 @@ public: if (!isPrimitive(p) || !isContextSpecific(p)) { - ec = error::incorrect_encoding; + ec = Error::IncorrectEncoding; return {}; } if (p.tag != 0) { - ec = error::unexpected_tag; + ec = Error::UnexpectedTag; return {}; } if (s.size() != p.length) { - ec = error::trailing_garbage; + ec = Error::TrailingGarbage; return {}; } - if (s.size() > maxPreimageLength) + if (s.size() > kMAX_PREIMAGE_LENGTH) { - ec = error::preimage_too_long; + ec = Error::PreimageTooLong; return {}; } @@ -93,7 +93,7 @@ public: [[nodiscard]] Type type() const override { - return Type::preimageSha256; + return Type::PreimageSha256; } [[nodiscard]] Buffer diff --git a/include/xrpl/conditions/detail/error.h b/include/xrpl/conditions/detail/error.h index 73cee4c9f3..578add1705 100644 --- a/include/xrpl/conditions/detail/error.h +++ b/include/xrpl/conditions/detail/error.h @@ -4,39 +4,39 @@ namespace xrpl::cryptoconditions { -enum class error { - generic = 1, - unsupported_type, - unsupported_subtype, - unknown_type, - unknown_subtype, - fingerprint_size, - incorrect_encoding, - trailing_garbage, - buffer_empty, - buffer_overfull, - buffer_underfull, - malformed_encoding, - short_preamble, - unexpected_tag, - long_tag, - large_size, - preimage_too_long +enum class Error { + Generic = 1, + UnsupportedType, + UnsupportedSubtype, + UnknownType, + UnknownSubtype, + FingerprintSize, + IncorrectEncoding, + TrailingGarbage, + BufferEmpty, + BufferOverfull, + BufferUnderfull, + MalformedEncoding, + ShortPreamble, + UnexpectedTag, + LongTag, + LargeSize, + PreimageTooLong }; std::error_code -make_error_code(error ev); +make_error_code(Error ev); } // namespace xrpl::cryptoconditions namespace std { template <> -struct is_error_code_enum +struct is_error_code_enum { explicit is_error_code_enum() = default; - static bool const value = true; + static bool const value = true; // NOLINT(readability-identifier-naming) }; } // namespace std diff --git a/include/xrpl/conditions/detail/utils.h b/include/xrpl/conditions/detail/utils.h index 8629987b8b..87f2265034 100644 --- a/include/xrpl/conditions/detail/utils.h +++ b/include/xrpl/conditions/detail/utils.h @@ -68,7 +68,7 @@ parsePreamble(Slice& s, std::error_code& ec) if (s.size() < 2) { - ec = error::short_preamble; + ec = Error::ShortPreamble; return p; } @@ -79,7 +79,7 @@ parsePreamble(Slice& s, std::error_code& ec) if (p.tag == 0x1F) { // Long tag form, which we do not support: - ec = error::long_tag; + ec = Error::LongTag; return p; } @@ -92,19 +92,19 @@ parsePreamble(Slice& s, std::error_code& ec) if (cnt == 0) { - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return p; } if (cnt > sizeof(std::size_t)) { - ec = error::large_size; + ec = Error::LargeSize; return p; } if (cnt > s.size()) { - ec = error::short_preamble; + ec = Error::ShortPreamble; return p; } @@ -117,7 +117,7 @@ parsePreamble(Slice& s, std::error_code& ec) if (p.length == 0) { - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return p; } } @@ -130,13 +130,13 @@ parseOctetString(Slice& s, std::uint32_t count, std::error_code& ec) { if (count > s.size()) { - ec = error::buffer_underfull; + ec = Error::BufferUnderfull; return {}; } if (count > 65535) { - ec = error::large_size; + ec = Error::LargeSize; return {}; } @@ -154,13 +154,13 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec) if (s.empty()) { // can never have zero sized integers - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return v; } if (count > s.size()) { - ec = error::buffer_underfull; + ec = Error::BufferUnderfull; return v; } @@ -169,14 +169,14 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec) size_t const maxLength = isSigned ? sizeof(Integer) : sizeof(Integer) + 1; if (count > maxLength) { - ec = error::large_size; + ec = Error::LargeSize; return v; } if (!isSigned && (s[0] & (1 << 7))) { // trying to decode a negative number into a positive value - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return v; } @@ -184,7 +184,7 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec) { // since integers are coded as two's complement, the first byte may // be zero for unsigned reps - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return v; } diff --git a/include/xrpl/core/ClosureCounter.h b/include/xrpl/core/ClosureCounter.h index 76e52cb3cd..fb13047f40 100644 --- a/include/xrpl/core/ClosureCounter.h +++ b/include/xrpl/core/ClosureCounter.h @@ -27,10 +27,10 @@ namespace xrpl { * the caller that they should drop the closure and cancel their operation. * `join` blocks until all existing closure substitutes are destroyed. * - * \tparam Ret_t The return type of the closure. - * \tparam Args_t The argument types of the closure. + * \tparam Ret The return type of the closure. + * \tparam Args The argument types of the closure. */ -template +template class ClosureCounter { private: @@ -75,8 +75,8 @@ private: std::remove_reference_t closure_{}; static_assert( - std::is_same_v()...)), Ret_t>, - "Closure arguments don't match ClosureCounter Ret_t or Args_t"); + std::is_same_v()...)), Ret>, + "Closure arguments don't match ClosureCounter Ret or Args"); public: Substitute() = delete; @@ -110,13 +110,13 @@ private: --counter_; } - // Note that Args_t is not deduced, it is explicit. So Args_t&& + // Note that Args is not deduced, it is explicit. So Args&& // would be an rvalue reference, not a forwarding reference. We // want to forward exactly what the user declared. - Ret_t - operator()(Args_t... args) + Ret + operator()(Args... args) { - return closure_(std::forward(args)...); + return closure_(std::forward(args)...); } }; @@ -159,7 +159,7 @@ public: /** Wrap the passed closure with a reference counter. - @param closure Closure that accepts Args_t parameters and returns Ret_t. + @param closure Closure that accepts Args parameters and returns Ret. @return If join() has been called returns std::nullopt. Otherwise returns a std::optional that wraps closure with a reference counter. diff --git a/include/xrpl/core/Coro.ipp b/include/xrpl/core/Coro.ipp index e7461b1b85..4b876dc68d 100644 --- a/include/xrpl/core/Coro.ipp +++ b/include/xrpl/core/Coro.ipp @@ -1,21 +1,22 @@ #pragma once +#include + namespace xrpl { /// Coroutine stack size (1.5 MB). Increased from 1 MB because /// ASAN-instrumented deep call stacks exceeded the original limit. -constexpr std::size_t coroStackSize = 1536 * 1024; +constexpr std::size_t kCORO_STACK_SIZE = 1536 * 1024; template -JobQueue::Coro::Coro(Coro_create_t, JobQueue& jq, JobType type, std::string const& name, F&& f) +JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name, F&& f) : jq_(jq) , type_(type) - , name_(name) + , name_(std::move(name)) , coro_( - boost::context::protected_fixedsize_stack(coroStackSize), - [this, - fn = std::forward(f)](boost::coroutines2::coroutine::push_type& do_yield) { - yield_ = &do_yield; + boost::context::protected_fixedsize_stack(kCORO_STACK_SIZE), + [this, fn = std::forward(f)](boost::coroutines2::coroutine::push_type& doYield) { + yield_ = &doYield; yield(); fn(shared_from_this()); #ifndef NDEBUG @@ -36,7 +37,7 @@ inline void JobQueue::Coro::yield() const { { - std::scoped_lock lock(jq_.m_mutex); + std::scoped_lock const lock(jq_.mutex_); ++jq_.nSuspend_; } (*yield_)(); @@ -46,7 +47,7 @@ inline bool JobQueue::Coro::post() { { - std::scoped_lock lk(mutex_run_); + std::scoped_lock const lk(mutex_run_); running_ = true; } @@ -57,7 +58,7 @@ JobQueue::Coro::post() } // The coroutine will not run. Clean up running_. - std::scoped_lock lk(mutex_run_); + std::scoped_lock const lk(mutex_run_); running_ = false; cv_.notify_all(); return false; @@ -67,16 +68,16 @@ inline void JobQueue::Coro::resume() { { - std::scoped_lock lk(mutex_run_); + std::scoped_lock const lk(mutex_run_); running_ = true; } { - std::scoped_lock lk(jq_.m_mutex); + std::scoped_lock const lk(jq_.mutex_); --jq_.nSuspend_; } auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); - std::scoped_lock lock(mutex_); + std::scoped_lock const lock(mutex_); // A late resume() can arrive after the coroutine has already completed. // This is an expected (if rare) outcome of the race condition documented // in JobQueue.h:354-377 where post() schedules a resume job before the @@ -91,7 +92,7 @@ JobQueue::Coro::resume() } detail::getLocalValues().release(); detail::getLocalValues().reset(saved); - std::scoped_lock lk(mutex_run_); + std::scoped_lock const lk(mutex_run_); running_ = false; cv_.notify_all(); } @@ -115,7 +116,7 @@ JobQueue::Coro::expectEarlyExit() // // That said, since we're outside the Coro's stack, we need to // decrement the nSuspend that the Coro's call to yield caused. - std::scoped_lock lock(jq_.m_mutex); + std::scoped_lock const lock(jq_.mutex_); --jq_.nSuspend_; #ifndef NDEBUG finished_ = true; @@ -127,7 +128,7 @@ inline void JobQueue::Coro::join() { std::unique_lock lk(mutex_run_); - cv_.wait(lk, [this]() { return running_ == false; }); + cv_.wait(lk, [this]() { return !running_; }); } } // namespace xrpl diff --git a/include/xrpl/core/HashRouter.h b/include/xrpl/core/HashRouter.h index 230fc06dbc..d36b8aee6e 100644 --- a/include/xrpl/core/HashRouter.h +++ b/include/xrpl/core/HashRouter.h @@ -212,7 +212,7 @@ public: uint256 const& key, PeerShortID peer, HashRouterFlags& flags, - std::chrono::seconds tx_interval); + std::chrono::seconds txInterval); /** Set the flags on a hash. @@ -250,7 +250,7 @@ private: Setup const setup_; // Stores all suppressed hashes and their expiration time - beast::aged_unordered_map> + beast::aged_unordered_map> suppressionMap_; }; diff --git a/include/xrpl/core/Job.h b/include/xrpl/core/Job.h index 2fe5ab263c..b62488dec6 100644 --- a/include/xrpl/core/Job.h +++ b/include/xrpl/core/Job.h @@ -15,62 +15,62 @@ namespace xrpl { // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum JobType { // Special type indicating an invalid job - will go away soon. - jtINVALID = -1, + JtInvalid = -1, // Job types - the position in this enum indicates the job priority with // earlier jobs having lower priority than later jobs. If you wish to // insert a job at a specific priority, simply add it at the right location. - jtPACK, // Make a fetch pack for a peer - jtPUBOLDLEDGER, // An old ledger has been accepted - jtCLIENT, // A placeholder for the priority of all jtCLIENT jobs - jtCLIENT_SUBSCRIBE, // A websocket subscription by a client - jtCLIENT_FEE_CHANGE, // Subscription for fee change by a client - jtCLIENT_CONSENSUS, // Subscription for consensus state change by a client - jtCLIENT_ACCT_HIST, // Subscription for account history by a client - jtCLIENT_RPC, // Client RPC request - jtCLIENT_WEBSOCKET, // Client websocket request - jtRPC, // A websocket command from the client - jtSWEEP, // Sweep for stale structures - jtVALIDATION_ut, // A validation from an untrusted source - jtMANIFEST, // A validator's manifest - jtUPDATE_PF, // Update pathfinding requests - jtTRANSACTION_l, // A local transaction - jtREPLAY_REQ, // Peer request a ledger delta or a skip list - jtLEDGER_REQ, // Peer request ledger/txnset data - jtPROPOSAL_ut, // A proposal from an untrusted source - jtREPLAY_TASK, // A Ledger replay task/subtask - jtTRANSACTION, // A transaction received from the network - jtMISSING_TXN, // Request missing transactions - jtREQUESTED_TXN, // Reply with requested transactions - jtBATCH, // Apply batched transactions - jtLEDGER_DATA, // Received data for a ledger we're acquiring - jtADVANCE, // Advance validated/acquired ledgers - jtPUBLEDGER, // Publish a fully-accepted ledger - jtTXN_DATA, // Fetch a proposed set - jtWAL, // Write-ahead logging - jtVALIDATION_t, // A validation from a trusted source - jtWRITE, // Write out hashed objects - jtACCEPT, // Accept a consensus ledger - jtPROPOSAL_t, // A proposal from a trusted source - jtNETOP_CLUSTER, // NetworkOPs cluster peer report - jtNETOP_TIMER, // NetworkOPs net timer processing - jtADMIN, // An administrative operation + JtPack, // Make a fetch pack for a peer + JtPuboldledger, // An old ledger has been accepted + JtClient, // A placeholder for the priority of all jtCLIENT jobs + JtClientSubscribe, // A websocket subscription by a client + JtClientFeeChange, // Subscription for fee change by a client + JtClientConsensus, // Subscription for consensus state change by a client + JtClientAcctHist, // Subscription for account history by a client + JtClientRpc, // Client RPC request + JtClientWebsocket, // Client websocket request + JtRpc, // A websocket command from the client + JtSweep, // Sweep for stale structures + JtValidationUt, // A validation from an untrusted source + JtManifest, // A validator's manifest + JtUpdatePf, // Update pathfinding requests + JtTransactionL, // A local transaction + JtReplayReq, // Peer request a ledger delta or a skip list + JtLedgerReq, // Peer request ledger/txnset data + JtProposalUt, // A proposal from an untrusted source + JtReplayTask, // A Ledger replay task/subtask + JtTransaction, // A transaction received from the network + JtMissingTxn, // Request missing transactions + JtRequestedTxn, // Reply with requested transactions + JtBatch, // Apply batched transactions + JtLedgerData, // Received data for a ledger we're acquiring + JtAdvance, // Advance validated/acquired ledgers + JtPubledger, // Publish a fully-accepted ledger + JtTxnData, // Fetch a proposed set + JtWal, // Write-ahead logging + JtValidationT, // A validation from a trusted source + JtWrite, // Write out hashed objects + JtAccept, // Accept a consensus ledger + JtProposalT, // A proposal from a trusted source + JtNetopCluster, // NetworkOPs cluster peer report + JtNetopTimer, // NetworkOPs net timer processing + JtAdmin, // An administrative operation // Special job types which are not dispatched by the job pool - jtPEER, - jtDISK, - jtTXN_PROC, - jtOB_SETUP, - jtPATH_FIND, - jtHO_READ, - jtHO_WRITE, - jtGENERIC, // Used just to measure time + JtPeer, + JtDisk, + JtTxnProc, + JtObSetup, + JtPathFind, + JtHoRead, + JtHoWrite, + JtGeneric, // Used just to measure time // Node store monitoring - jtNS_SYNC_READ, - jtNS_ASYNC_READ, - jtNS_WRITE, + JtNsSyncRead, + JtNsAsyncRead, + JtNsWrite, }; class Job : public CountedObject @@ -105,7 +105,7 @@ public: /** Returns the time when the job was queued. */ [[nodiscard]] clock_type::time_point const& - queue_time() const; + queueTime() const; void doJob(); @@ -122,12 +122,12 @@ public: operator>=(Job const& j) const; private: - JobType mType; - std::uint64_t mJobIndex; - std::function mJob; - std::shared_ptr m_loadEvent; - std::string mName; - clock_type::time_point m_queue_time; + JobType type_; + std::uint64_t jobIndex_; + std::function job_; + std::shared_ptr loadEvent_; + std::string name_; + clock_type::time_point queue_time_; }; using JobCounter = ClosureCounter; diff --git a/include/xrpl/core/JobQueue.h b/include/xrpl/core/JobQueue.h index bac616470a..2a96ea45fa 100644 --- a/include/xrpl/core/JobQueue.h +++ b/include/xrpl/core/JobQueue.h @@ -24,9 +24,9 @@ class PerfLog; } // namespace perf class Logs; -struct Coro_create_t +struct CoroCreateT { - explicit Coro_create_t() = default; + explicit CoroCreateT() = default; }; /** A pool of threads to perform work. @@ -54,16 +54,15 @@ public: std::mutex mutex_; std::mutex mutex_run_; std::condition_variable cv_; + boost::coroutines2::coroutine::push_type* yield_{}; boost::coroutines2::coroutine::pull_type coro_; - boost::coroutines2::coroutine::push_type* yield_; #ifndef NDEBUG bool finished_ = false; #endif public: - // Private: Used in the implementation template - Coro(Coro_create_t, JobQueue&, JobType, std::string const&, F&&); + Coro(CoroCreateT, JobQueue&, JobType, std::string, F&&); // Not copy-constructible or assignable Coro(Coro const&) = delete; @@ -200,7 +199,7 @@ public: isOverloaded(); // Cannot be const because LoadMonitor has no const methods. - Json::Value + json::Value getJson(int c = 0); /** Block until no jobs running. */ @@ -226,29 +225,29 @@ private: using JobDataMap = std::map; - beast::Journal m_journal; - mutable std::mutex m_mutex; - std::uint64_t m_lastJob{0}; - std::set m_jobSet; + beast::Journal journal_; + mutable std::mutex mutex_; + std::uint64_t lastJob_{0}; + std::set jobSet_; JobCounter jobCounter_; std::atomic_bool stopping_{false}; std::atomic_bool stopped_{false}; - JobDataMap m_jobData; - JobTypeData m_invalidJobData; + JobDataMap jobData_; + JobTypeData invalidJobData_; // The number of jobs currently in processTask() - int m_processCount{0}; + int processCount_{0}; // The number of suspended coroutines int nSuspend_ = 0; - Workers m_workers; + Workers workers_; // Statistics tracking perf::PerfLog& perfLog_; - beast::insight::Collector::ptr m_collector; - beast::insight::Gauge job_count; - beast::insight::Hook hook; + beast::insight::Collector::ptr collector_; + beast::insight::Gauge job_count_; + beast::insight::Hook hook_; std::condition_variable cv_; @@ -274,12 +273,12 @@ private: // A Job in the JobSet whose slots count for its type is greater than zero. // // Pre-conditions: - // mJobSet must not be empty. - // mJobSet holds at least one RunnableJob + // jobSet_ must not be empty. + // jobSet_ holds at least one RunnableJob // // Post-conditions: // job is a valid Job object. - // job is removed from mJobQueue. + // job is removed from jobQueue_. // Waiting job count of its type is decremented // Running job count of its type is incremented // @@ -291,7 +290,7 @@ private: // Indicates that a running Job has completed its task. // // Pre-conditions: - // Job must not exist in mJobSet. + // Job must not exist in jobSet_. // The JobType must not be invalid. // // Post-conditions: @@ -397,7 +396,7 @@ JobQueue::postCoro(JobType t, std::string const& name, F&& f) Last param is the function the coroutine runs. Signature of void(std::shared_ptr). */ - auto coro = std::make_shared(Coro_create_t{}, *this, t, name, std::forward(f)); + auto coro = std::make_shared(CoroCreateT{}, *this, t, name, std::forward(f)); if (!coro->post()) { // The Coro was not successfully posted. Disable it so it's destructor diff --git a/include/xrpl/core/JobTypeData.h b/include/xrpl/core/JobTypeData.h index 20a85e04c1..4e9f95dc04 100644 --- a/include/xrpl/core/JobTypeData.h +++ b/include/xrpl/core/JobTypeData.h @@ -11,10 +11,10 @@ namespace xrpl { struct JobTypeData { private: - LoadMonitor m_load; + LoadMonitor load_; /* Support for insight */ - beast::insight::Collector::ptr m_collector; + beast::insight::Collector::ptr collector_; public: /* The job category which we represent */ @@ -34,18 +34,18 @@ public: beast::insight::Event execute; JobTypeData( - JobTypeInfo const& info_, + JobTypeInfo const& info, beast::insight::Collector::ptr collector, Logs& logs) noexcept - : m_load(logs.journal("LoadMonitor")), m_collector(std::move(collector)), info(info_) + : load_(logs.journal("LoadMonitor")), collector_(std::move(collector)), info(info) { - m_load.setTargetLatency(info.getAverageLatency(), info.getPeakLatency()); + load_.setTargetLatency(info.getAverageLatency(), info.getPeakLatency()); if (!info.special()) { - dequeue = m_collector->make_event(info.name() + "_q"); - execute = m_collector->make_event(info.name()); + dequeue = collector_->makeEvent(info.name() + "_q"); + execute = collector_->makeEvent(info.name()); } } @@ -69,13 +69,13 @@ public: LoadMonitor& load() { - return m_load; + return load_; } LoadMonitor::Stats stats() { - return m_load.getStats(); + return load_.getStats(); } }; diff --git a/include/xrpl/core/JobTypeInfo.h b/include/xrpl/core/JobTypeInfo.h index 81c4557be2..430e80b388 100644 --- a/include/xrpl/core/JobTypeInfo.h +++ b/include/xrpl/core/JobTypeInfo.h @@ -8,19 +8,19 @@ namespace xrpl { class JobTypeInfo { private: - JobType const m_type; - std::string const m_name; + JobType const type_; + std::string const name_; /** The limit on the number of running jobs for this job type. A limit of 0 marks this as a "special job" which is not dispatched via the job queue. */ - int const m_limit; + int const limit_; /** Average and peak latencies for this job type. 0 is none specified */ - std::chrono::milliseconds const m_avgLatency; - std::chrono::milliseconds const m_peakLatency; + std::chrono::milliseconds const avgLatency_; + std::chrono::milliseconds const peakLatency_; public: // Not default constructible @@ -32,48 +32,48 @@ public: int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) - : m_type(type) - , m_name(std::move(name)) - , m_limit(limit) - , m_avgLatency(avgLatency) - , m_peakLatency(peakLatency) + : type_(type) + , name_(std::move(name)) + , limit_(limit) + , avgLatency_(avgLatency) + , peakLatency_(peakLatency) { } [[nodiscard]] JobType type() const { - return m_type; + return type_; } [[nodiscard]] std::string const& name() const { - return m_name; + return name_; } [[nodiscard]] int limit() const { - return m_limit; + return limit_; } [[nodiscard]] bool special() const { - return m_limit == 0; + return limit_ == 0; } [[nodiscard]] std::chrono::milliseconds getAverageLatency() const { - return m_avgLatency; + return avgLatency_; } [[nodiscard]] std::chrono::milliseconds getPeakLatency() const { - return m_peakLatency; + return peakLatency_; } }; diff --git a/include/xrpl/core/JobTypes.h b/include/xrpl/core/JobTypes.h index cc5b54fea7..32a793c9dc 100644 --- a/include/xrpl/core/JobTypes.h +++ b/include/xrpl/core/JobTypes.h @@ -16,8 +16,8 @@ public: private: JobTypes() - : m_unknown( - jtINVALID, + : unknown( + JtInvalid, "invalid", 0, std::chrono::milliseconds{0}, @@ -32,15 +32,13 @@ private: int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) { - XRPL_ASSERT( - !m_map.contains(jt), "xrpl::JobTypes::JobTypes::add : unique job type input"); + XRPL_ASSERT(!map.contains(jt), "xrpl::JobTypes::JobTypes::add : unique job type input"); [[maybe_unused]] auto const inserted = - m_map - .emplace( - std::piecewise_construct, - std::forward_as_tuple(jt), - std::forward_as_tuple(jt, name, limit, avgLatency, peakLatency)) + map.emplace( + std::piecewise_construct, + std::forward_as_tuple(jt), + std::forward_as_tuple(jt, name, limit, avgLatency, peakLatency)) .second; XRPL_ASSERT(inserted == true, "xrpl::JobTypes::JobTypes::add : input is inserted"); @@ -49,53 +47,53 @@ private: // clang-format off // avg peak // JobType name limit latency latency - add(jtPACK, "makeFetchPack", 1, 0ms, 0ms); - add(jtPUBOLDLEDGER, "publishAcqLedger", 2, 10000ms, 15000ms); - add(jtVALIDATION_ut, "untrustedValidation", maxLimit, 2000ms, 5000ms); - add(jtMANIFEST, "manifest", maxLimit, 2000ms, 5000ms); - add(jtTRANSACTION_l, "localTransaction", maxLimit, 100ms, 500ms); - add(jtREPLAY_REQ, "ledgerReplayRequest", 10, 250ms, 1000ms); - add(jtLEDGER_REQ, "ledgerRequest", 3, 0ms, 0ms); - add(jtPROPOSAL_ut, "untrustedProposal", maxLimit, 500ms, 1250ms); - add(jtREPLAY_TASK, "ledgerReplayTask", maxLimit, 0ms, 0ms); - add(jtLEDGER_DATA, "ledgerData", 3, 0ms, 0ms); - add(jtCLIENT, "clientCommand", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_SUBSCRIBE, "clientSubscribe", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_FEE_CHANGE, "clientFeeChange", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_CONSENSUS, "clientConsensus", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_ACCT_HIST, "clientAccountHistory", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_RPC, "clientRPC", maxLimit, 2000ms, 5000ms); - add(jtCLIENT_WEBSOCKET, "clientWebsocket", maxLimit, 2000ms, 5000ms); - add(jtRPC, "RPC", maxLimit, 0ms, 0ms); - add(jtUPDATE_PF, "updatePaths", 1, 0ms, 0ms); - add(jtTRANSACTION, "transaction", maxLimit, 250ms, 1000ms); - add(jtBATCH, "batch", maxLimit, 250ms, 1000ms); - add(jtADVANCE, "advanceLedger", maxLimit, 0ms, 0ms); - add(jtPUBLEDGER, "publishNewLedger", maxLimit, 3000ms, 4500ms); - add(jtTXN_DATA, "fetchTxnData", 5, 0ms, 0ms); - add(jtWAL, "writeAhead", maxLimit, 1000ms, 2500ms); - add(jtVALIDATION_t, "trustedValidation", maxLimit, 500ms, 1500ms); - add(jtWRITE, "writeObjects", maxLimit, 1750ms, 2500ms); - add(jtACCEPT, "acceptLedger", maxLimit, 0ms, 0ms); - add(jtPROPOSAL_t, "trustedProposal", maxLimit, 100ms, 500ms); - add(jtSWEEP, "sweep", 1, 0ms, 0ms); - add(jtNETOP_CLUSTER, "clusterReport", 1, 9999ms, 9999ms); - add(jtNETOP_TIMER, "heartbeat", 1, 999ms, 999ms); - add(jtADMIN, "administration", maxLimit, 0ms, 0ms); - add(jtMISSING_TXN, "handleHaveTransactions", 1200, 0ms, 0ms); - add(jtREQUESTED_TXN, "doTransactions", 1200, 0ms, 0ms); + add(JtPack, "makeFetchPack", 1, 0ms, 0ms); + add(JtPuboldledger, "publishAcqLedger", 2, 10000ms, 15000ms); + add(JtValidationUt, "untrustedValidation", maxLimit, 2000ms, 5000ms); + add(JtManifest, "manifest", maxLimit, 2000ms, 5000ms); + add(JtTransactionL, "localTransaction", maxLimit, 100ms, 500ms); + add(JtReplayReq, "ledgerReplayRequest", 10, 250ms, 1000ms); + add(JtLedgerReq, "ledgerRequest", 3, 0ms, 0ms); + add(JtProposalUt, "untrustedProposal", maxLimit, 500ms, 1250ms); + add(JtReplayTask, "ledgerReplayTask", maxLimit, 0ms, 0ms); + add(JtLedgerData, "ledgerData", 3, 0ms, 0ms); + add(JtClient, "clientCommand", maxLimit, 2000ms, 5000ms); + add(JtClientSubscribe, "clientSubscribe", maxLimit, 2000ms, 5000ms); + add(JtClientFeeChange, "clientFeeChange", maxLimit, 2000ms, 5000ms); + add(JtClientConsensus, "clientConsensus", maxLimit, 2000ms, 5000ms); + add(JtClientAcctHist, "clientAccountHistory", maxLimit, 2000ms, 5000ms); + add(JtClientRpc, "clientRPC", maxLimit, 2000ms, 5000ms); + add(JtClientWebsocket, "clientWebsocket", maxLimit, 2000ms, 5000ms); + add(JtRpc, "RPC", maxLimit, 0ms, 0ms); + add(JtUpdatePf, "updatePaths", 1, 0ms, 0ms); + add(JtTransaction, "transaction", maxLimit, 250ms, 1000ms); + add(JtBatch, "batch", maxLimit, 250ms, 1000ms); + add(JtAdvance, "advanceLedger", maxLimit, 0ms, 0ms); + add(JtPubledger, "publishNewLedger", maxLimit, 3000ms, 4500ms); + add(JtTxnData, "fetchTxnData", 5, 0ms, 0ms); + add(JtWal, "writeAhead", maxLimit, 1000ms, 2500ms); + add(JtValidationT, "trustedValidation", maxLimit, 500ms, 1500ms); + add(JtWrite, "writeObjects", maxLimit, 1750ms, 2500ms); + add(JtAccept, "acceptLedger", maxLimit, 0ms, 0ms); + add(JtProposalT, "trustedProposal", maxLimit, 100ms, 500ms); + add(JtSweep, "sweep", 1, 0ms, 0ms); + add(JtNetopCluster, "clusterReport", 1, 9999ms, 9999ms); + add(JtNetopTimer, "heartbeat", 1, 999ms, 999ms); + add(JtAdmin, "administration", maxLimit, 0ms, 0ms); + add(JtMissingTxn, "handleHaveTransactions", 1200, 0ms, 0ms); + add(JtRequestedTxn, "doTransactions", 1200, 0ms, 0ms); - add(jtPEER, "peerCommand", 0, 200ms, 2500ms); - add(jtDISK, "diskAccess", 0, 500ms, 1000ms); - add(jtTXN_PROC, "processTransaction", 0, 0ms, 0ms); - add(jtOB_SETUP, "orderBookSetup", 0, 0ms, 0ms); - add(jtPATH_FIND, "pathFind", 0, 0ms, 0ms); - add(jtHO_READ, "nodeRead", 0, 0ms, 0ms); - add(jtHO_WRITE, "nodeWrite", 0, 0ms, 0ms); - add(jtGENERIC, "generic", 0, 0ms, 0ms); - add(jtNS_SYNC_READ, "SyncReadNode", 0, 0ms, 0ms); - add(jtNS_ASYNC_READ, "AsyncReadNode", 0, 0ms, 0ms); - add(jtNS_WRITE, "WriteNode", 0, 0ms, 0ms); + add(JtPeer, "peerCommand", 0, 200ms, 2500ms); + add(JtDisk, "diskAccess", 0, 500ms, 1000ms); + add(JtTxnProc, "processTransaction", 0, 0ms, 0ms); + add(JtObSetup, "orderBookSetup", 0, 0ms, 0ms); + add(JtPathFind, "pathFind", 0, 0ms, 0ms); + add(JtHoRead, "nodeRead", 0, 0ms, 0ms); + add(JtHoWrite, "nodeWrite", 0, 0ms, 0ms); + add(JtGeneric, "generic", 0, 0ms, 0ms); + add(JtNsSyncRead, "SyncReadNode", 0, 0ms, 0ms); + add(JtNsAsyncRead, "AsyncReadNode", 0, 0ms, 0ms); + add(JtNsWrite, "WriteNode", 0, 0ms, 0ms); // clang-format on } @@ -103,8 +101,8 @@ public: static JobTypes const& instance() { - static JobTypes const types; - return types; + static JobTypes const kTYPES; + return kTYPES; } static std::string const& @@ -116,53 +114,53 @@ public: [[nodiscard]] JobTypeInfo const& get(JobType jt) const { - Map::const_iterator const iter(m_map.find(jt)); - XRPL_ASSERT(iter != m_map.end(), "xrpl::JobTypes::get : valid input"); + Map::const_iterator const iter(map.find(jt)); + XRPL_ASSERT(iter != map.end(), "xrpl::JobTypes::get : valid input"); - if (iter != m_map.end()) + if (iter != map.end()) return iter->second; - return m_unknown; + return unknown; } [[nodiscard]] JobTypeInfo const& getInvalid() const { - return m_unknown; + return unknown; } [[nodiscard]] Map::size_type size() const { - return m_map.size(); + return map.size(); } [[nodiscard]] const_iterator begin() const { - return m_map.cbegin(); + return map.cbegin(); } [[nodiscard]] const_iterator cbegin() const { - return m_map.cbegin(); + return map.cbegin(); } [[nodiscard]] const_iterator end() const { - return m_map.cend(); + return map.cend(); } [[nodiscard]] const_iterator cend() const { - return m_map.cend(); + return map.cend(); } - JobTypeInfo m_unknown; - Map m_map; + JobTypeInfo unknown; + Map map; }; } // namespace xrpl diff --git a/include/xrpl/core/LoadMonitor.h b/include/xrpl/core/LoadMonitor.h index b8777a7056..32a813baa7 100644 --- a/include/xrpl/core/LoadMonitor.h +++ b/include/xrpl/core/LoadMonitor.h @@ -54,13 +54,13 @@ private: std::mutex mutex_; - std::uint64_t mCounts{0}; - int mLatencyEvents{0}; - std::chrono::milliseconds mLatencyMSAvg; - std::chrono::milliseconds mLatencyMSPeak; - std::chrono::milliseconds mTargetLatencyAvg; - std::chrono::milliseconds mTargetLatencyPk; - UptimeClock::time_point mLastUpdate; + std::uint64_t counts_{0}; + int latencyEvents_{0}; + std::chrono::milliseconds latencyMSAvg_; + std::chrono::milliseconds latencyMSPeak_; + std::chrono::milliseconds targetLatencyAvg_; + std::chrono::milliseconds targetLatencyPk_; + UptimeClock::time_point lastUpdate_; beast::Journal const j_; }; diff --git a/include/xrpl/core/PeerReservationTable.h b/include/xrpl/core/PeerReservationTable.h index 80ad7196c3..a9ab894124 100644 --- a/include/xrpl/core/PeerReservationTable.h +++ b/include/xrpl/core/PeerReservationTable.h @@ -23,11 +23,13 @@ public: std::string description = {}; // NOLINT(readability-redundant-member-init) [[nodiscard]] auto - toJson() const -> Json::Value; + toJson() const -> json::Value; template friend void - hash_append(Hasher& h, PeerReservation const& x) noexcept + hash_append( + Hasher& h, + PeerReservation const& x) noexcept // NOLINT(readability-identifier-naming) { using beast::hash_append; hash_append(h, x.nodeId); @@ -81,7 +83,7 @@ public: * @throw soci::soci_error */ std::optional - insert_or_assign(PeerReservation const& reservation); + insertOrAssign(PeerReservation const& reservation); /** * @return the erased reservation if it existed @@ -93,7 +95,7 @@ private: beast::Journal mutable journal_; std::mutex mutable mutex_; DatabaseCon* connection_{}; - std::unordered_set, KeyEqual> table_; + std::unordered_set, KeyEqual> table_; }; } // namespace xrpl diff --git a/include/xrpl/core/PerfLog.h b/include/xrpl/core/PerfLog.h index 7151d09b08..38318c745d 100644 --- a/include/xrpl/core/PerfLog.h +++ b/include/xrpl/core/PerfLog.h @@ -121,7 +121,7 @@ public: * * @return Counters Json object */ - [[nodiscard]] virtual Json::Value + [[nodiscard]] virtual json::Value countersJson() const = 0; /** @@ -129,7 +129,7 @@ public: * * @return Current executing jobs and RPC calls and durations */ - [[nodiscard]] virtual Json::Value + [[nodiscard]] virtual json::Value currentJson() const = 0; /** @@ -148,10 +148,10 @@ public: }; PerfLog::Setup -setup_PerfLog(Section const& section, boost::filesystem::path const& configDir); +setupPerfLog(Section const& section, boost::filesystem::path const& configDir); std::unique_ptr -make_PerfLog( +makePerfLog( PerfLog::Setup const& setup, Application& app, beast::Journal journal, @@ -165,12 +165,12 @@ measureDurationAndLog( std::chrono::duration maxDelay, beast::Journal const& journal) { - auto start_time = std::chrono::high_resolution_clock::now(); + auto startTime = std::chrono::high_resolution_clock::now(); auto result = func(); - auto end_time = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast(end_time - start_time); + auto endTime = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(endTime - startTime); if (duration > maxDelay) { JLOG(journal.warn()) << actionDescription << " took " << duration.count() << " ms"; diff --git a/include/xrpl/core/detail/Workers.h b/include/xrpl/core/detail/Workers.h index fb9004a9b6..d20ebf7a64 100644 --- a/include/xrpl/core/detail/Workers.h +++ b/include/xrpl/core/detail/Workers.h @@ -176,7 +176,7 @@ private: run(); private: - Workers& m_workers; + Workers& workers_; std::string const threadName_; int const instance_; @@ -192,19 +192,19 @@ private: deleteWorkers(beast::LockFreeStack& stack); private: - Callback& m_callback; + Callback& callback_; perf::PerfLog* perfLog_; - std::string m_threadNames; // The name to give each thread - std::condition_variable m_cv; // signaled when all threads paused - std::mutex m_mut; - bool m_allPaused{true}; - semaphore m_semaphore; // each pending task is 1 resource - int m_numberOfThreads{0}; // how many we want active now - std::atomic m_activeCount; // to know when all are paused - std::atomic m_pauseCount; // how many threads need to pause now - std::atomic m_runningTaskCount; // how many calls to processTask() active - beast::LockFreeStack m_everyone; // holds all created workers - beast::LockFreeStack m_paused; // holds just paused workers + std::string threadNames_; // The name to give each thread + std::condition_variable cv_; // signaled when all threads paused + std::mutex mut_; + bool allPaused_{true}; + semaphore semaphore_; // each pending task is 1 resource + int numberOfThreads_{0}; // how many we want active now + std::atomic activeCount_; // to know when all are paused + std::atomic pauseCount_; // how many threads need to pause now + std::atomic runningTaskCount_; // how many calls to processTask() active + beast::LockFreeStack everyone_; // holds all created workers + beast::LockFreeStack paused_; // holds just paused workers }; } // namespace xrpl diff --git a/include/xrpl/core/detail/semaphore.h b/include/xrpl/core/detail/semaphore.h index 38b7329ab1..7bc83f86f5 100644 --- a/include/xrpl/core/detail/semaphore.h +++ b/include/xrpl/core/detail/semaphore.h @@ -34,12 +34,12 @@ namespace xrpl { template -class basic_semaphore +class BasicSemaphore { private: - Mutex m_mutex; - CondVar m_cond; - std::size_t m_count; + Mutex mutex_; + CondVar cond_; + std::size_t count_; public: using size_type = std::size_t; @@ -47,7 +47,7 @@ public: /** Create the semaphore, with an optional initial count. If unspecified, the initial count is zero. */ - explicit basic_semaphore(size_type count = 0) : m_count(count) + explicit BasicSemaphore(size_type count = 0) : count_(count) { } @@ -55,35 +55,35 @@ public: void notify() { - std::scoped_lock const lock{m_mutex}; - ++m_count; - m_cond.notify_one(); + std::scoped_lock const lock{mutex_}; + ++count_; + cond_.notify_one(); } /** Block until notify is called. */ void wait() { - std::unique_lock lock{m_mutex}; - while (m_count == 0) - m_cond.wait(lock); - --m_count; + std::unique_lock lock{mutex_}; + while (count_ == 0) + cond_.wait(lock); + --count_; } /** Perform a non-blocking wait. @return `true` If the wait would be satisfied. */ bool - try_wait() + tryWait() { - std::scoped_lock lock{m_mutex}; - if (m_count == 0) + std::scoped_lock lock{mutex_}; + if (count_ == 0) return false; - --m_count; + --count_; return true; } }; -using semaphore = basic_semaphore; +using semaphore = BasicSemaphore; } // namespace xrpl diff --git a/include/xrpl/crypto/RFC1751.h b/include/xrpl/crypto/RFC1751.h index 64b3e08813..c99c691ba0 100644 --- a/include/xrpl/crypto/RFC1751.h +++ b/include/xrpl/crypto/RFC1751.h @@ -38,7 +38,7 @@ private: static int etob(std::string& strData, std::vector vsHuman); - static char const* s_dictionary[]; + static char const* dictionary[]; }; } // namespace xrpl diff --git a/include/xrpl/crypto/csprng.h b/include/xrpl/crypto/csprng.h index e5135c96d7..e386d9d11e 100644 --- a/include/xrpl/crypto/csprng.h +++ b/include/xrpl/crypto/csprng.h @@ -12,7 +12,7 @@ namespace xrpl { Meets the requirements of UniformRandomNumberEngine */ -class csprng_engine +class CsprngEngine { private: std::mutex mutex_; @@ -20,20 +20,20 @@ private: public: using result_type = std::uint64_t; - csprng_engine(csprng_engine const&) = delete; - csprng_engine& - operator=(csprng_engine const&) = delete; + CsprngEngine(CsprngEngine const&) = delete; + CsprngEngine& + operator=(CsprngEngine const&) = delete; - csprng_engine(csprng_engine&&) = delete; - csprng_engine& - operator=(csprng_engine&&) = delete; + CsprngEngine(CsprngEngine&&) = delete; + CsprngEngine& + operator=(CsprngEngine&&) = delete; - csprng_engine(); - ~csprng_engine(); + CsprngEngine(); + ~CsprngEngine(); /** Mix entropy into the pool */ void - mix_entropy(void* buffer = nullptr, std::size_t count = 0); + mixEntropy(void* buffer = nullptr, std::size_t count = 0); /** Generate a random integer */ result_type @@ -66,7 +66,7 @@ public: This meets the requirements of UniformRandomNumberEngine */ -csprng_engine& -crypto_prng(); +CsprngEngine& +cryptoPrng(); } // namespace xrpl diff --git a/include/xrpl/crypto/secure_erase.h b/include/xrpl/crypto/secure_erase.h index 2815a8531a..74284b03f7 100644 --- a/include/xrpl/crypto/secure_erase.h +++ b/include/xrpl/crypto/secure_erase.h @@ -19,6 +19,6 @@ namespace xrpl { http://www.daemonology.net/blog/2014-09-06-zeroing-buffers-is-insufficient.html */ void -secure_erase(void* dest, std::size_t bytes); +secureErase(void* dest, std::size_t bytes); } // namespace xrpl diff --git a/include/xrpl/json/JsonPropertyStream.h b/include/xrpl/json/JsonPropertyStream.h index e0a13c4001..47d3c9fdfa 100644 --- a/include/xrpl/json/JsonPropertyStream.h +++ b/include/xrpl/json/JsonPropertyStream.h @@ -5,25 +5,25 @@ namespace xrpl { -/** A PropertyStream::Sink which produces a Json::Value of type objectValue. */ +/** A PropertyStream::Sink which produces a json::Value of type objectValue. */ class JsonPropertyStream : public beast::PropertyStream { public: - Json::Value m_top; - std::vector m_stack; + json::Value topValue; // TODO: rename: clashes with top() method + std::vector stack; public: JsonPropertyStream(); - [[nodiscard]] Json::Value const& + [[nodiscard]] json::Value const& top() const; protected: void - map_begin() override; + mapBegin() override; void - map_begin(std::string const& key) override; + mapBegin(std::string const& key) override; void - map_end() override; + mapEnd() override; void add(std::string const& key, short value) override; void @@ -41,11 +41,11 @@ protected: void add(std::string const& key, std::string const& v) override; void - array_begin() override; + arrayBegin() override; void - array_begin(std::string const& key) override; + arrayBegin(std::string const& key) override; void - array_end() override; + arrayEnd() override; void add(short value) override; diff --git a/include/xrpl/json/Output.h b/include/xrpl/json/Output.h index b0ba3fa6d4..c01253f713 100644 --- a/include/xrpl/json/Output.h +++ b/include/xrpl/json/Output.h @@ -5,7 +5,7 @@ #include #include -namespace Json { +namespace json { class Value; @@ -20,17 +20,17 @@ stringOutput(std::string& s) /** Writes a minimal representation of a Json value to an Output in O(n) time. Data is streamed right to the output, so only a marginal amount of memory is - used. This can be very important for a very large Json::Value. + used. This can be very important for a very large json::Value. */ void -outputJson(Json::Value const&, Output const&); +outputJson(json::Value const&, Output const&); -/** Return the minimal string representation of a Json::Value in O(n) time. +/** Return the minimal string representation of a json::Value in O(n) time. This requires a memory allocation for the full size of the output. If possible, use outputJson(). */ std::string -jsonAsString(Json::Value const&); +jsonAsString(json::Value const&); -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/Writer.h b/include/xrpl/json/Writer.h index 34c4e8458a..664a2a75c1 100644 --- a/include/xrpl/json/Writer.h +++ b/include/xrpl/json/Writer.h @@ -7,7 +7,7 @@ #include -namespace Json { +namespace json { /** * Writer implements an O(1)-space, O(1)-granular output JSON writer. @@ -107,7 +107,7 @@ namespace Json { class Writer { public: - enum class CollectionType { array, object }; + enum class CollectionType { Array, Object }; explicit Writer(Output const& output); Writer(Writer&&) noexcept; @@ -138,7 +138,7 @@ public: /** Append a value to an array. * * Scalar must be a scalar - that is, a number, boolean, string, string - * literal, nullptr or Json::Value + * literal, nullptr or json::Value */ template void @@ -188,9 +188,9 @@ public: void output(char const*); - /*** Output a Json::Value. */ + /*** Output a json::Value. */ void - output(Json::Value const&); + output(json::Value const&); /** Output a null. */ void output(std::nullptr_t); @@ -216,9 +216,9 @@ public: } void - output(Json::StaticString const& t) + output(json::StaticString const& t) { - output(t.c_str()); + output(t.cStr()); } private: @@ -236,4 +236,4 @@ check(bool condition, std::string const& message) xrpl::Throw(message); } -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/detail/json_assert.h b/include/xrpl/json/detail/json_assert.h index e9a66ccef1..8e33f45b65 100644 --- a/include/xrpl/json/detail/json_assert.h +++ b/include/xrpl/json/detail/json_assert.h @@ -5,4 +5,4 @@ #define JSON_ASSERT_MESSAGE(condition, message) \ if (!(condition)) \ - xrpl::Throw(message); + xrpl::Throw(message); diff --git a/include/xrpl/json/json_errors.h b/include/xrpl/json/json_errors.h index 5cbf3bd2a5..9cf94e76c1 100644 --- a/include/xrpl/json/json_errors.h +++ b/include/xrpl/json/json_errors.h @@ -2,11 +2,11 @@ #include -namespace Json { +namespace json { -struct error : std::runtime_error +struct Error : std::runtime_error { using std::runtime_error::runtime_error; }; -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/json_forwards.h b/include/xrpl/json/json_forwards.h index 612648a5f4..7da8dba418 100644 --- a/include/xrpl/json/json_forwards.h +++ b/include/xrpl/json/json_forwards.h @@ -1,6 +1,6 @@ #pragma once -namespace Json { +namespace json { // value.h using Int = int; @@ -11,4 +11,4 @@ class ValueIteratorBase; class ValueIterator; class ValueConstIterator; -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/json_reader.h b/include/xrpl/json/json_reader.h index 543f0cfb9c..8ce565dbbc 100644 --- a/include/xrpl/json/json_reader.h +++ b/include/xrpl/json/json_reader.h @@ -7,7 +7,7 @@ #include -namespace Json { +namespace json { /** \brief Unserialize a JSON document into a * Value. @@ -45,7 +45,7 @@ public: parse(char const* beginDoc, char const* endDoc, Value& root); /// \brief Parse from input stream. - /// \see Json::operator>>(std::istream&, Json::Value&). + /// \see json::operator>>(std::istream&, json::Value&). bool parse(std::istream& is, Value& root); @@ -67,27 +67,27 @@ public: [[nodiscard]] std::string getFormattedErrorMessages() const; - static constexpr unsigned nest_limit{25}; + static constexpr unsigned kNEST_LIMIT{25}; private: // 53 files, protocol-wide // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum TokenType { - tokenEndOfStream = 0, - tokenObjectBegin, - tokenObjectEnd, - tokenArrayBegin, - tokenArrayEnd, - tokenString, - tokenInteger, - tokenDouble, - tokenTrue, - tokenFalse, - tokenNull, - tokenArraySeparator, - tokenMemberSeparator, - tokenComment, - tokenError + TokenEndOfStream = 0, + TokenObjectBegin, + TokenObjectEnd, + TokenArrayBegin, + TokenArrayEnd, + TokenString, + TokenInteger, + TokenDouble, + TokenTrue, + TokenFalse, + TokenNull, + TokenArraySeparator, + TokenMemberSeparator, + TokenComment, + TokenError }; class Token @@ -95,9 +95,9 @@ private: public: explicit Token() = default; - TokenType type_; - Location start_; - Location end_; + TokenType type; + Location start; + Location end; }; class ErrorInfo @@ -105,9 +105,9 @@ private: public: explicit ErrorInfo() = default; - Token token_{}; - std::string message_; - Location extra_{}; + Token token{}; + std::string message; + Location extra{}; }; using Errors = std::deque; @@ -201,7 +201,7 @@ Reader::parse(Value& root, BufferSequence const& bs) This can be used to read a file into a particular sub-object. For example: \code - Json::Value root; + json::Value root; cin >> root["dir"]["file"]; cout << root; \endcode @@ -216,9 +216,9 @@ Reader::parse(Value& root, BufferSequence const& bs) } \endverbatim \throw std::exception on parse error. - \see Json::operator<<() + \see json::operator<<() */ std::istream& operator>>(std::istream&, Value&); -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/json_value.h b/include/xrpl/json/json_value.h index def2696c5c..2344da3788 100644 --- a/include/xrpl/json/json_value.h +++ b/include/xrpl/json/json_value.h @@ -11,21 +11,21 @@ /** \brief JSON (JavaScript Object Notation). */ -namespace Json { +namespace json { /** \brief Type of the value held by a Value object. */ // Used throughout JSON layer // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum ValueType { - nullValue = 0, ///< 'null' value - intValue, ///< signed integer value - uintValue, ///< unsigned integer value - realValue, ///< double value - stringValue, ///< UTF-8 string value - booleanValue, ///< bool value - arrayValue, ///< array value (ordered list) - objectValue ///< object value (collection of name/value pairs). + NullValue = 0, ///< 'null' value + IntValue, ///< signed integer value + UintValue, ///< unsigned integer value + RealValue, ///< double value + StringValue, ///< UTF-8 string value + BooleanValue, ///< bool value + ArrayValue, ///< array value (ordered list) + ObjectValue ///< object value (collection of name/value pairs). }; /** \brief Lightweight wrapper to tag static string. @@ -36,8 +36,8 @@ enum ValueType { * * Example of usage: * \code - * Json::Value aValue( StaticString("some text") ); - * Json::Value object; + * json::Value aValue( StaticString("some text") ); + * json::Value object; * static const StaticString code("code"); * object[code] = 1234; * \endcode @@ -56,7 +56,7 @@ public: } [[nodiscard]] constexpr char const* - c_str() const + cStr() const { return str_; } @@ -68,7 +68,7 @@ private: inline bool operator==(StaticString x, StaticString y) { - return strcmp(x.c_str(), y.c_str()) == 0; + return strcmp(x.cStr(), y.cStr()) == 0; } inline bool @@ -80,7 +80,7 @@ operator!=(StaticString x, StaticString y) inline bool operator==(std::string const& x, StaticString y) { - return strcmp(x.c_str(), y.c_str()) == 0; + return strcmp(x.c_str(), y.cStr()) == 0; } inline bool @@ -136,14 +136,14 @@ public: using Members = std::vector; using iterator = ValueIterator; using const_iterator = ValueConstIterator; - using UInt = Json::UInt; - using Int = Json::Int; + using UInt = json::UInt; + using Int = json::Int; using ArrayIndex = UInt; - static Value const null; - static constexpr Int minInt = std::numeric_limits::min(); - static constexpr Int maxInt = std::numeric_limits::max(); - static constexpr UInt maxUInt = std::numeric_limits::max(); + static Value const kNULL; + static constexpr Int kMIN_INT = std::numeric_limits::min(); + static constexpr Int kMAX_INT = std::numeric_limits::max(); + static constexpr UInt kMAX_U_INT = std::numeric_limits::max(); private: class CZString @@ -151,7 +151,8 @@ private: public: // Stored as int field, implicit conversion // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy }; + enum DuplicationPolicy { NoDuplication = 0, Duplicate, DuplicateOnCopy }; + CZString(int index); CZString(char const* cstr, DuplicationPolicy allocate); CZString(CZString const& other); @@ -165,7 +166,7 @@ private: [[nodiscard]] int index() const; [[nodiscard]] char const* - c_str() const; + cStr() const; [[nodiscard]] bool isStaticString() const; @@ -188,12 +189,12 @@ public: Examples: \code - Json::Value null_value; // null - Json::Value arr_value(Json::arrayValue); // [] - Json::Value obj_value(Json::objectValue); // {} + json::Value null_value; // null + json::Value arr_value(json::arrayValue); // [] + json::Value obj_value(json::objectValue); // {} \endcode */ - Value(ValueType type = nullValue); + Value(ValueType type = NullValue); Value(Int value); Value(UInt value); Value(double value); @@ -207,7 +208,7 @@ public: * constructor. * Example of usage: * \code - * Json::Value aValue( StaticString("some text") ); + * json::Value aValue( StaticString("some text") ); * \endcode */ Value(StaticString const& value); @@ -345,7 +346,7 @@ public: * the new entry is not duplicated. * Example of use: * \code - * Json::Value object; + * json::Value object; * static const StaticString code("code"); * object[code] = 1234; * \endcode @@ -417,19 +418,19 @@ private: private: union ValueHolder { - Int int_; - UInt uint_; - double real_; - bool bool_; - char* string_; - ObjectValues* map_{nullptr}; + Int intVal; + UInt uintVal; + double realVal; + bool boolVal; + char* stringVal; + ObjectValues* mapVal{nullptr}; } value_; ValueType type_ : 8; int allocated_ : 1 {}; // Notes: if declared as bool, bitfield is useless. }; inline Value -to_json(xrpl::Number const& number) +toJson(xrpl::Number const& number) { return to_string(number); } @@ -468,16 +469,16 @@ operator>=(Value const& x, Value const& y) * string value memory management done by Value. * * - makeMemberName() and releaseMemberName() are called to respectively - * duplicate and free an Json::objectValue member name. + * duplicate and free an json::objectValue member name. * - duplicateStringValue() and releaseStringValue() are called similarly to - * duplicate and free a Json::stringValue value. + * duplicate and free a json::stringValue value. */ class ValueAllocator { public: // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum { unknown = (unsigned)-1 }; + enum { Unknown = (unsigned)-1 }; virtual ~ValueAllocator() = default; @@ -486,7 +487,7 @@ public: virtual void releaseMemberName(char* memberName) = 0; virtual char* - duplicateStringValue(char const* value, unsigned int length = unknown) = 0; + duplicateStringValue(char const* value, unsigned int length = Unknown) = 0; virtual void releaseStringValue(char* value) = 0; }; @@ -681,4 +682,4 @@ public: } }; -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/json_writer.h b/include/xrpl/json/json_writer.h index 45961fe030..8e5e819b10 100644 --- a/include/xrpl/json/json_writer.h +++ b/include/xrpl/json/json_writer.h @@ -6,7 +6,7 @@ #include #include -namespace Json { +namespace json { class Value; @@ -182,7 +182,7 @@ std::string valueToQuotedString(char const* value); /// \brief Output using the StyledStreamWriter. -/// \see Json::operator>>() +/// \see json::operator>>() std::ostream& operator<<(std::ostream&, Value const& root); @@ -193,55 +193,55 @@ namespace detail { template void -write_string(Write const& write, std::string const& s) +writeString(Write const& write, std::string const& s) { write(s.data(), s.size()); } template void -write_value(Write const& write, Value const& value) +writeValue(Write const& write, Value const& value) { switch (value.type()) { - case nullValue: + case NullValue: write("null", 4); break; - case intValue: - write_string(write, valueToString(value.asInt())); + case IntValue: + writeString(write, valueToString(value.asInt())); break; - case uintValue: - write_string(write, valueToString(value.asUInt())); + case UintValue: + writeString(write, valueToString(value.asUInt())); break; - case realValue: - write_string(write, valueToString(value.asDouble())); + case RealValue: + writeString(write, valueToString(value.asDouble())); break; - case stringValue: - write_string(write, valueToQuotedString(value.asCString())); + case StringValue: + writeString(write, valueToQuotedString(value.asCString())); break; - case booleanValue: - write_string(write, valueToString(value.asBool())); + case BooleanValue: + writeString(write, valueToString(value.asBool())); break; - case arrayValue: { + case ArrayValue: { write("[", 1); int const size = value.size(); for (int index = 0; index < size; ++index) { if (index > 0) write(",", 1); - write_value(write, value[index]); + writeValue(write, value[index]); } write("]", 1); break; } - case objectValue: { + case ObjectValue: { Value::Members const members = value.getMemberNames(); write("{", 1); for (auto it = members.begin(); it != members.end(); ++it) @@ -250,9 +250,9 @@ write_value(Write const& write, Value const& value) if (it != members.begin()) write(",", 1); - write_string(write, valueToQuotedString(name.c_str())); + writeString(write, valueToQuotedString(name.c_str())); write(":", 1); - write_value(write, value[name]); + writeValue(write, value[name]); } write("}", 1); break; @@ -264,15 +264,15 @@ write_value(Write const& write, Value const& value) /** Stream compact JSON to the specified function. - @param jv The Json::Value to write + @param jv The json::Value to write @param write Invocable with signature void(void const*, std::size_t) that is called when output should be written to the stream. */ template void -stream(Json::Value const& jv, Write const& write) +stream(json::Value const& jv, Write const& write) { - detail::write_value(write, jv); + detail::writeValue(write, jv); write("\n", 1); } @@ -280,37 +280,37 @@ stream(Json::Value const& jv, Write const& write) Use - Json::Value jv; - out << Json::Compact{jv} + json::Value jv; + out << json::Compact{jv} to write a single-line, compact version of `jv` to the stream, rather than the styled format that comes from undecorated streaming. */ class Compact { - Json::Value jv_; + json::Value jv_; public: - /** Wrap a Json::Value for compact streaming + /** Wrap a json::Value for compact streaming - @param jv The Json::Value to stream + @param jv The json::Value to stream @note For now, we do not support wrapping lvalues to avoid potentially costly copies. If we find a need, we can consider adding support for compact lvalue streaming in the future. */ - Compact(Json::Value&& jv) : jv_{std::move(jv)} + Compact(json::Value&& jv) : jv_{std::move(jv)} { } friend std::ostream& operator<<(std::ostream& o, Compact const& cJv) { - detail::write_value( + detail::writeValue( [&o](void const* data, std::size_t n) { o.write(static_cast(data), n); }, cJv.jv_); return o; } }; -} // namespace Json +} // namespace json diff --git a/include/xrpl/json/to_string.h b/include/xrpl/json/to_string.h index c9820e2e55..1d7b4c785a 100644 --- a/include/xrpl/json/to_string.h +++ b/include/xrpl/json/to_string.h @@ -4,14 +4,14 @@ #include -namespace Json { +namespace json { -/** Writes a Json::Value to an std::string. */ +/** Writes a json::Value to an std::string. */ std::string to_string(Value const&); -/** Writes a Json::Value to an std::string. */ +/** Writes a json::Value to an std::string. */ std::string pretty(Value const&); -} // namespace Json +} // namespace json diff --git a/include/xrpl/ledger/AcceptedLedgerTx.h b/include/xrpl/ledger/AcceptedLedgerTx.h index 5d6d471ba0..0a1592f6e1 100644 --- a/include/xrpl/ledger/AcceptedLedgerTx.h +++ b/include/xrpl/ledger/AcceptedLedgerTx.h @@ -33,55 +33,55 @@ public: [[nodiscard]] std::shared_ptr const& getTxn() const { - return mTxn; + return txn_; } [[nodiscard]] TxMeta const& getMeta() const { - return mMeta; + return meta_; } [[nodiscard]] boost::container::flat_set const& getAffected() const { - return mAffected; + return affected_; } [[nodiscard]] TxID getTransactionID() const { - return mTxn->getTransactionID(); + return txn_->getTransactionID(); } [[nodiscard]] TxType getTxnType() const { - return mTxn->getTxnType(); + return txn_->getTxnType(); } [[nodiscard]] TER getResult() const { - return mMeta.getResultTER(); + return meta_.getResultTER(); } [[nodiscard]] std::uint32_t getTxnSeq() const { - return mMeta.getIndex(); + return meta_.getIndex(); } [[nodiscard]] std::string getEscMeta() const; - [[nodiscard]] Json::Value const& + [[nodiscard]] json::Value const& getJson() const { - return mJson; + return json_; } private: - std::shared_ptr mTxn; - TxMeta mMeta; - boost::container::flat_set mAffected; - Blob mRawMeta; - Json::Value mJson; + std::shared_ptr txn_; + TxMeta meta_; + boost::container::flat_set affected_; + Blob rawMeta_; + json::Value json_; }; } // namespace xrpl diff --git a/include/xrpl/ledger/AmendmentTable.h b/include/xrpl/ledger/AmendmentTable.h index 8f40ccb413..a15433813d 100644 --- a/include/xrpl/ledger/AmendmentTable.h +++ b/include/xrpl/ledger/AmendmentTable.h @@ -64,11 +64,11 @@ public: [[nodiscard]] virtual std::optional firstUnsupportedExpected() const = 0; - [[nodiscard]] virtual Json::Value + [[nodiscard]] virtual json::Value getJson(bool isAdmin) const = 0; - /** Returns a Json::objectValue. */ - [[nodiscard]] virtual Json::Value + /** Returns a json::objectValue. */ + [[nodiscard]] virtual json::Value getJson(uint256 const& amendment, bool isAdmin) const = 0; /** Called when a new fully-validated ledger is accepted. */ @@ -163,14 +163,14 @@ public: << amendTx; initialPosition->addGiveItem( - SHAMapNodeType::tnTRANSACTION_NM, - make_shamapitem(amendTx.getTransactionID(), s.slice())); + SHAMapNodeType::TnTransactionNm, + makeShamapitem(amendTx.getTransactionID(), s.slice())); } } }; std::unique_ptr -make_AmendmentTable( +makeAmendmentTable( ServiceRegistry& registry, std::chrono::seconds majorityTime, std::vector const& supported, diff --git a/include/xrpl/ledger/ApplyView.h b/include/xrpl/ledger/ApplyView.h index 0aea9813b9..f825311e1d 100644 --- a/include/xrpl/ledger/ApplyView.h +++ b/include/xrpl/ledger/ApplyView.h @@ -10,56 +10,56 @@ namespace xrpl { // Bitwise flag enum with existing operator overloads // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum ApplyFlags : std::uint32_t { - tapNONE = 0x00, + TapNone = 0x00, // This is a local transaction with the // fail_hard flag set. - tapFAIL_HARD = 0x10, + TapFailHard = 0x10, // This is not the transaction's last pass // Transaction can be retried, soft failures allowed - tapRETRY = 0x20, + TapRetry = 0x20, // Transaction came from a privileged source - tapUNLIMITED = 0x400, + TapUnlimited = 0x400, // Transaction is executing as part of a batch - tapBATCH = 0x800, + TapBatch = 0x800, // Transaction shouldn't be applied // Signatures shouldn't be checked - tapDRY_RUN = 0x1000 + TapDryRun = 0x1000 }; constexpr ApplyFlags operator|(ApplyFlags const& lhs, ApplyFlags const& rhs) { - return safe_cast( - safe_cast>(lhs) | - safe_cast>(rhs)); + return safeCast( + safeCast>(lhs) | + safeCast>(rhs)); } -static_assert((tapFAIL_HARD | tapRETRY) == safe_cast(0x30u), "ApplyFlags operator |"); -static_assert((tapRETRY | tapFAIL_HARD) == safe_cast(0x30u), "ApplyFlags operator |"); +static_assert((TapFailHard | TapRetry) == safeCast(0x30u), "ApplyFlags operator |"); +static_assert((TapRetry | TapFailHard) == safeCast(0x30u), "ApplyFlags operator |"); constexpr ApplyFlags operator&(ApplyFlags const& lhs, ApplyFlags const& rhs) { - return safe_cast( - safe_cast>(lhs) & - safe_cast>(rhs)); + return safeCast( + safeCast>(lhs) & + safeCast>(rhs)); } -static_assert((tapFAIL_HARD & tapRETRY) == tapNONE, "ApplyFlags operator &"); -static_assert((tapRETRY & tapFAIL_HARD) == tapNONE, "ApplyFlags operator &"); +static_assert((TapFailHard & TapRetry) == TapNone, "ApplyFlags operator &"); +static_assert((TapRetry & TapFailHard) == TapNone, "ApplyFlags operator &"); constexpr ApplyFlags operator~(ApplyFlags const& flags) { - return safe_cast(~safe_cast>(flags)); + return safeCast(~safeCast>(flags)); } -static_assert(~tapRETRY == safe_cast(0xFFFFFFDFu), "ApplyFlags operator ~"); +static_assert(~TapRetry == safeCast(0xFFFFFFDFu), "ApplyFlags operator ~"); inline ApplyFlags operator|=(ApplyFlags& lhs, ApplyFlags const& rhs) diff --git a/include/xrpl/ledger/BookDirs.h b/include/xrpl/ledger/BookDirs.h index 4cbbbd78ce..afde6ee7b3 100644 --- a/include/xrpl/ledger/BookDirs.h +++ b/include/xrpl/ledger/BookDirs.h @@ -1,6 +1,5 @@ #pragma once -#include #include namespace xrpl { @@ -17,7 +16,7 @@ private: uint256 index_; public: - class const_iterator; + class const_iterator; // NOLINT(readability-identifier-naming) using value_type = std::shared_ptr; BookDirs(ReadView const&, Book const&); @@ -29,7 +28,7 @@ public: end() const; }; -class BookDirs::const_iterator +class BookDirs::const_iterator // NOLINT(readability-identifier-naming) { public: using value_type = BookDirs::value_type; @@ -67,8 +66,8 @@ public: private: friend class BookDirs; - const_iterator(ReadView const& view, uint256 const& root, uint256 const& dir_key) - : view_(&view), root_(root), key_(dir_key), cur_key_(dir_key) + const_iterator(ReadView const& view, uint256 const& root, uint256 const& dirKey) + : view_(&view), root_(root), key_(dirKey), cur_key_(dirKey) { } @@ -81,8 +80,6 @@ private: unsigned int entry_ = 0; uint256 index_; std::optional mutable cache_; - - static beast::Journal j_; }; } // namespace xrpl diff --git a/include/xrpl/ledger/BookListeners.h b/include/xrpl/ledger/BookListeners.h index c77271b20e..3b96aca680 100644 --- a/include/xrpl/ledger/BookListeners.h +++ b/include/xrpl/ledger/BookListeners.h @@ -41,9 +41,9 @@ public: publish(MultiApiJson const& jvObj, hash_set& havePublished); private: - std::recursive_mutex mLock; + std::recursive_mutex lock_; - hash_map mListeners; + hash_map listeners_; }; } // namespace xrpl diff --git a/include/xrpl/ledger/CachedView.h b/include/xrpl/ledger/CachedView.h index 5dad2598f4..34a75e4c07 100644 --- a/include/xrpl/ledger/CachedView.h +++ b/include/xrpl/ledger/CachedView.h @@ -17,7 +17,7 @@ private: DigestAwareReadView const& base_; CachedSLEs& cache_; std::mutex mutable mutex_; - std::unordered_map> mutable map_; + std::unordered_map> mutable map_; public: CachedViewImpl() = delete; @@ -69,31 +69,31 @@ public: return base_.succ(key, last); } - std::unique_ptr + std::unique_ptr slesBegin() const override { return base_.slesBegin(); } - std::unique_ptr + std::unique_ptr slesEnd() const override { return base_.slesEnd(); } - std::unique_ptr + std::unique_ptr slesUpperBound(uint256 const& key) const override { return base_.slesUpperBound(key); } - std::unique_ptr + std::unique_ptr txsBegin() const override { return base_.txsBegin(); } - std::unique_ptr + std::unique_ptr txsEnd() const override { return base_.txsEnd(); diff --git a/include/xrpl/ledger/Dir.h b/include/xrpl/ledger/Dir.h index 940107bf93..cfbef357b1 100644 --- a/include/xrpl/ledger/Dir.h +++ b/include/xrpl/ledger/Dir.h @@ -26,19 +26,19 @@ private: STVector256 const* indexes_ = nullptr; public: - class const_iterator; + class ConstIterator; using value_type = std::shared_ptr; Dir(ReadView const&, Keylet const&); - [[nodiscard]] const_iterator + [[nodiscard]] ConstIterator begin() const; - [[nodiscard]] const_iterator + [[nodiscard]] ConstIterator end() const; }; -class Dir::const_iterator +class Dir::ConstIterator { public: using value_type = Dir::value_type; @@ -48,10 +48,10 @@ public: using iterator_category = std::forward_iterator_tag; bool - operator==(const_iterator const& other) const; + operator==(ConstIterator const& other) const; bool - operator!=(const_iterator const& other) const + operator!=(ConstIterator const& other) const { return !(*this == other); } @@ -65,17 +65,17 @@ public: return &**this; } - const_iterator& + ConstIterator& operator++(); - const_iterator + ConstIterator operator++(int); - const_iterator& - next_page(); + ConstIterator& + nextPage(); std::size_t - page_size(); + pageSize(); Keylet const& page() const @@ -92,7 +92,7 @@ public: private: friend class Dir; - const_iterator(ReadView const& view, Keylet const& root, Keylet const& page) + ConstIterator(ReadView const& view, Keylet const& root, Keylet const& page) : view_(&view), root_(root), page_(page) { } diff --git a/include/xrpl/ledger/Ledger.h b/include/xrpl/ledger/Ledger.h index 62303ba3d2..2d6f48db2d 100644 --- a/include/xrpl/ledger/Ledger.h +++ b/include/xrpl/ledger/Ledger.h @@ -20,11 +20,11 @@ class TransactionMaster; class SqliteStatement; -struct create_genesis_t +struct CreateGenesisT { - explicit create_genesis_t() = default; + explicit CreateGenesisT() = default; }; -extern create_genesis_t const create_genesis; +extern CreateGenesisT const kCREATE_GENESIS; /** Holds a ledger. @@ -81,7 +81,7 @@ public: Amendments specified are enabled in the genesis ledger */ Ledger( - create_genesis_t, + CreateGenesisT, Rules rules, Fees const& fees, std::vector const& amendments, @@ -169,19 +169,19 @@ public: std::shared_ptr read(Keylet const& k) const override; - std::unique_ptr + std::unique_ptr slesBegin() const override; - std::unique_ptr + std::unique_ptr slesEnd() const override; - std::unique_ptr + std::unique_ptr slesUpperBound(uint256 const& key) const override; - std::unique_ptr + std::unique_ptr txsBegin() const override; - std::unique_ptr + std::unique_ptr txsEnd() const override; bool @@ -249,7 +249,7 @@ public: bool isImmutable() const { - return mImmutable; + return immutable_; } /* Mark this ledger as "should be full". @@ -365,8 +365,8 @@ public: peek(Keylet const& k) const; private: - class sles_iter_impl; - class txs_iter_impl; + class SlesIterImpl; + class TxsIterImpl; bool setup(); @@ -392,7 +392,7 @@ private: static std::pair, std::shared_ptr> deserializeTxPlusMeta(SHAMapItem const& item); - bool mImmutable; + bool immutable_; // A SHAMap containing the transactions associated with this ledger. SHAMap mutable txMap_; diff --git a/include/xrpl/ledger/LedgerTiming.h b/include/xrpl/ledger/LedgerTiming.h index 8171beed3c..dce28bd44b 100644 --- a/include/xrpl/ledger/LedgerTiming.h +++ b/include/xrpl/ledger/LedgerTiming.h @@ -12,7 +12,7 @@ namespace xrpl { Values should not be duplicated. @see getNextLedgerTimeResolution */ -std::chrono::seconds constexpr ledgerPossibleTimeResolutions[] = { +std::chrono::seconds constexpr kLEDGER_POSSIBLE_TIME_RESOLUTIONS[] = { std::chrono::seconds{10}, std::chrono::seconds{20}, std::chrono::seconds{30}, @@ -21,16 +21,16 @@ std::chrono::seconds constexpr ledgerPossibleTimeResolutions[] = { std::chrono::seconds{120}}; //! Initial resolution of ledger close time. -auto constexpr ledgerDefaultTimeResolution = ledgerPossibleTimeResolutions[2]; +auto constexpr kLEDGER_DEFAULT_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[2]; //! Close time resolution in genesis ledger -auto constexpr ledgerGenesisTimeResolution = ledgerPossibleTimeResolutions[0]; +auto constexpr kLEDGER_GENESIS_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[0]; //! How often we increase the close time resolution (in numbers of ledgers) -auto constexpr increaseLedgerTimeResolutionEvery = 8; +auto constexpr kINCREASE_LEDGER_TIME_RESOLUTION_EVERY = 8; //! How often we decrease the close time resolution (in numbers of ledgers) -auto constexpr decreaseLedgerTimeResolutionEvery = 1; +auto constexpr kDECREASE_LEDGER_TIME_RESOLUTION_EVERY = 1; /** Calculates the close time resolution for the specified ledger. @@ -46,7 +46,7 @@ auto constexpr decreaseLedgerTimeResolutionEvery = 1; @param ledgerSeq the sequence number of the new ledger @pre previousResolution must be a valid bin - from @ref ledgerPossibleTimeResolutions + from @ref kLEDGER_POSSIBLE_TIME_RESOLUTIONS @tparam Rep Type representing number of ticks in std::chrono::duration @tparam Period An std::ratio representing tick period in @@ -67,30 +67,30 @@ getNextLedgerTimeResolution( using namespace std::chrono; // Find the current resolution: auto iter = std::find( - std::begin(ledgerPossibleTimeResolutions), - std::end(ledgerPossibleTimeResolutions), + std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), + std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), previousResolution); XRPL_ASSERT( - iter != std::end(ledgerPossibleTimeResolutions), + iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS), "xrpl::getNextLedgerTimeResolution : found time resolution"); // This should never happen, but just as a precaution - if (iter == std::end(ledgerPossibleTimeResolutions)) + if (iter == std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) return previousResolution; // If we did not previously agree, we try to decrease the resolution to // improve the chance that we will agree now. - if (!previousAgree && (ledgerSeq % Seq{decreaseLedgerTimeResolutionEvery} == Seq{0})) + if (!previousAgree && (ledgerSeq % Seq{kDECREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0})) { - if (++iter != std::end(ledgerPossibleTimeResolutions)) + if (++iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) return *iter; } // If we previously agreed, we try to increase the resolution to determine // if we can continue to agree. - if (previousAgree && (ledgerSeq % Seq{increaseLedgerTimeResolutionEvery} == Seq{0})) + if (previousAgree && (ledgerSeq % Seq{kINCREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0})) { - if (iter-- != std::begin(ledgerPossibleTimeResolutions)) + if (iter-- != std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS)) return *iter; } diff --git a/include/xrpl/ledger/OpenView.h b/include/xrpl/ledger/OpenView.h index 3420aa1df0..59ab733211 100644 --- a/include/xrpl/ledger/OpenView.h +++ b/include/xrpl/ledger/OpenView.h @@ -20,20 +20,20 @@ namespace xrpl { rules of open ledgers applied during transaction processing. */ -inline constexpr struct open_ledger_t +inline constexpr struct OpenLedgerT { - explicit constexpr open_ledger_t() = default; -} open_ledger{}; + explicit constexpr OpenLedgerT() = default; +} kOPEN_LEDGER{}; /** Batch view construction tag. Views constructed with this tag are part of a stack of views used during batch transaction applied. */ -inline constexpr struct batch_view_t +inline constexpr struct BatchViewT { - explicit constexpr batch_view_t() = default; -} batch_view{}; + explicit constexpr BatchViewT() = default; +} kBATCH_VIEW{}; //------------------------------------------------------------------------------ @@ -47,20 +47,20 @@ private: // Initial size for the monotonic_buffer_resource used for allocations // The size was chosen from the old `qalloc` code (which this replaces). // It is unclear how the size initially chosen in qalloc. - static constexpr size_t initialBufferSize = kilobytes(256); + static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256); - class txs_iter_impl; + class TxsIterImpl; - struct txData + struct TxData { std::shared_ptr txn; std::shared_ptr meta; // Constructor needed for emplacement in std::map - txData( - std::shared_ptr const& txn_, - std::shared_ptr const& meta_) - : txn(txn_), meta(meta_) + TxData( + std::shared_ptr const& txn, + std::shared_ptr const& meta) + : txn(txn), meta(meta) { } }; @@ -70,9 +70,9 @@ private: // functions b/c clang does not support pmr yet (as-of 9/2020) using txs_map = std::map< key_type, - txData, + TxData, std::less, - boost::container::pmr::polymorphic_allocator>>; + boost::container::pmr::polymorphic_allocator>>; // monotonic_resource_ must outlive `items_`. Make a pointer so it may be // easily moved. @@ -133,17 +133,17 @@ public: all newly inserted tx. */ OpenView( - open_ledger_t, + OpenLedgerT, ReadView const* base, Rules rules, std::shared_ptr hold = nullptr); - OpenView(open_ledger_t, Rules const& rules, std::shared_ptr const& base) - : OpenView(open_ledger, &*base, rules, base) + OpenView(OpenLedgerT, Rules const& rules, std::shared_ptr const& base) + : OpenView(kOPEN_LEDGER, &*base, rules, base) { } - OpenView(batch_view_t, OpenView& base) : OpenView(std::addressof(base)) + OpenView(BatchViewT, OpenView& base) : OpenView(std::addressof(base)) { baseTxCount_ = base.txCount(); } @@ -200,19 +200,19 @@ public: std::shared_ptr read(Keylet const& k) const override; - std::unique_ptr + std::unique_ptr slesBegin() const override; - std::unique_ptr + std::unique_ptr slesEnd() const override; - std::unique_ptr + std::unique_ptr slesUpperBound(uint256 const& key) const override; - std::unique_ptr + std::unique_ptr txsBegin() const override; - std::unique_ptr + std::unique_ptr txsEnd() const override; bool diff --git a/include/xrpl/ledger/ReadView.h b/include/xrpl/ledger/ReadView.h index bb0aa56507..4f9bf9c31d 100644 --- a/include/xrpl/ledger/ReadView.h +++ b/include/xrpl/ledger/ReadView.h @@ -36,25 +36,25 @@ public: using mapped_type = std::shared_ptr; - struct sles_type : detail::ReadViewFwdRange> + struct SlesType : detail::ReadViewFwdRange> { - explicit sles_type(ReadView const& view); - [[nodiscard]] iterator + explicit SlesType(ReadView const& view); + [[nodiscard]] Iterator begin() const; - [[nodiscard]] iterator + [[nodiscard]] Iterator end() const; - [[nodiscard]] iterator - upper_bound(key_type const& key) const; + [[nodiscard]] Iterator + upperBound(key_type const& key) const; }; - struct txs_type : detail::ReadViewFwdRange + struct TxsType : detail::ReadViewFwdRange { - explicit txs_type(ReadView const& view); + explicit TxsType(ReadView const& view); [[nodiscard]] bool empty() const; - [[nodiscard]] iterator + [[nodiscard]] Iterator begin() const; - [[nodiscard]] iterator + [[nodiscard]] Iterator end() const; }; @@ -189,23 +189,23 @@ public: } // used by the implementation - [[nodiscard]] virtual std::unique_ptr + [[nodiscard]] virtual std::unique_ptr slesBegin() const = 0; // used by the implementation - [[nodiscard]] virtual std::unique_ptr + [[nodiscard]] virtual std::unique_ptr slesEnd() const = 0; // used by the implementation - [[nodiscard]] virtual std::unique_ptr + [[nodiscard]] virtual std::unique_ptr slesUpperBound(key_type const& key) const = 0; // used by the implementation - [[nodiscard]] virtual std::unique_ptr + [[nodiscard]] virtual std::unique_ptr txsBegin() const = 0; // used by the implementation - [[nodiscard]] virtual std::unique_ptr + [[nodiscard]] virtual std::unique_ptr txsEnd() const = 0; /** Returns `true` if a tx exists in the tx map. @@ -236,10 +236,10 @@ public: @note Visiting each state entry in the ledger can become quite expensive as the ledger grows. */ - sles_type sles; + SlesType sles; // The range of transactions - txs_type txs; + TxsType txs; }; //------------------------------------------------------------------------------ @@ -269,7 +269,7 @@ makeRulesGivenLedger(DigestAwareReadView const& ledger, Rules const& current); Rules makeRulesGivenLedger( DigestAwareReadView const& ledger, - std::unordered_set> const& presets); + std::unordered_set> const& presets); } // namespace xrpl diff --git a/include/xrpl/ledger/detail/ApplyStateTable.h b/include/xrpl/ledger/detail/ApplyStateTable.h index 93b639f54b..7b18f742b4 100644 --- a/include/xrpl/ledger/detail/ApplyStateTable.h +++ b/include/xrpl/ledger/detail/ApplyStateTable.h @@ -20,10 +20,10 @@ public: private: enum class Action { - cache, - erase, - insert, - modify, + Cache, + Erase, + Insert, + Modify, }; using items_t = std::map>>; diff --git a/include/xrpl/ledger/detail/ApplyViewBase.h b/include/xrpl/ledger/detail/ApplyViewBase.h index d6a293610a..558c9e5d4d 100644 --- a/include/xrpl/ledger/detail/ApplyViewBase.h +++ b/include/xrpl/ledger/detail/ApplyViewBase.h @@ -43,19 +43,19 @@ public: [[nodiscard]] std::shared_ptr read(Keylet const& k) const override; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesBegin() const override; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesEnd() const override; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesUpperBound(uint256 const& key) const override; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr txsBegin() const override; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr txsEnd() const override; [[nodiscard]] bool diff --git a/include/xrpl/ledger/detail/RawStateTable.h b/include/xrpl/ledger/detail/RawStateTable.h index ec5cb05981..169a7c505e 100644 --- a/include/xrpl/ledger/detail/RawStateTable.h +++ b/include/xrpl/ledger/detail/RawStateTable.h @@ -19,16 +19,16 @@ public: // Initial size for the monotonic_buffer_resource used for allocations // The size was chosen from the old `qalloc` code (which this replaces). // It is unclear how the size initially chosen in qalloc. - static constexpr size_t initialBufferSize = kilobytes(256); + static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256); RawStateTable() - : monotonic_resource_{ - std::make_unique(initialBufferSize)} + : monotonic_resource_{std::make_unique( + kINITIAL_BUFFER_SIZE)} , items_{monotonic_resource_.get()} {}; RawStateTable(RawStateTable const& rhs) - : monotonic_resource_{ - std::make_unique(initialBufferSize)} + : monotonic_resource_{std::make_unique( + kINITIAL_BUFFER_SIZE)} , items_{rhs.items_, monotonic_resource_.get()} , dropsDestroyed_{rhs.dropsDestroyed_} {}; @@ -63,31 +63,31 @@ public: void destroyXRP(XRPAmount const& fee); - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesBegin(ReadView const& base) const; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesEnd(ReadView const& base) const; - [[nodiscard]] std::unique_ptr + [[nodiscard]] std::unique_ptr slesUpperBound(ReadView const& base, uint256 const& key) const; private: enum class Action { - erase, - insert, - replace, + Erase, + Insert, + Replace, }; - class sles_iter_impl; + class SlesIterImpl; - struct sleAction + struct SleAction { Action action; std::shared_ptr sle; // Constructor needed for emplacement in std::map - sleAction(Action action_, std::shared_ptr const& sle_) : action(action_), sle(sle_) + SleAction(Action action, std::shared_ptr const& sle) : action(action), sle(sle) { } }; @@ -96,9 +96,9 @@ private: // functions b/c clang does not support pmr yet (as-of 9/2020) using items_t = std::map< key_type, - sleAction, + SleAction, std::less, - boost::container::pmr::polymorphic_allocator>>; + boost::container::pmr::polymorphic_allocator>>; // monotonic_resource_ must outlive `items_`. Make a pointer so it may be // easily moved. std::unique_ptr monotonic_resource_; diff --git a/include/xrpl/ledger/detail/ReadViewFwdRange.h b/include/xrpl/ledger/detail/ReadViewFwdRange.h index 74fe0447dc..c548ccb101 100644 --- a/include/xrpl/ledger/detail/ReadViewFwdRange.h +++ b/include/xrpl/ledger/detail/ReadViewFwdRange.h @@ -53,7 +53,7 @@ public: "ReadViewFwdRange move and move assign constructors should be " "noexcept"); - class iterator + class Iterator { public: using value_type = ValueType; @@ -66,25 +66,25 @@ public: using iterator_category = std::forward_iterator_tag; - iterator() = default; + Iterator() = default; - iterator(iterator const& other); - iterator(iterator&& other) noexcept; + Iterator(Iterator const& other); + Iterator(Iterator&& other) noexcept; // Used by the implementation - explicit iterator(ReadView const* view, std::unique_ptr impl); + explicit Iterator(ReadView const* view, std::unique_ptr impl); - iterator& - operator=(iterator const& other); + Iterator& + operator=(Iterator const& other); - iterator& - operator=(iterator&& other) noexcept; + Iterator& + operator=(Iterator&& other) noexcept; bool - operator==(iterator const& other) const; + operator==(Iterator const& other) const; bool - operator!=(iterator const& other) const; + operator!=(Iterator const& other) const; // Can throw reference @@ -94,10 +94,10 @@ public: pointer operator->() const; - iterator& + Iterator& operator++(); - iterator + Iterator operator++(int); private: @@ -106,10 +106,10 @@ public: std::optional mutable cache_; }; - static_assert(std::is_nothrow_move_constructible{}, ""); - static_assert(std::is_nothrow_move_assignable{}, ""); + static_assert(std::is_nothrow_move_constructible{}, ""); + static_assert(std::is_nothrow_move_assignable{}, ""); - using const_iterator = iterator; + using const_iterator = Iterator; using value_type = ValueType; diff --git a/include/xrpl/ledger/detail/ReadViewFwdRange.ipp b/include/xrpl/ledger/detail/ReadViewFwdRange.ipp index ce6754b39c..c7cbc5ee61 100644 --- a/include/xrpl/ledger/detail/ReadViewFwdRange.ipp +++ b/include/xrpl/ledger/detail/ReadViewFwdRange.ipp @@ -1,22 +1,21 @@ #pragma once -namespace xrpl { -namespace detail { +namespace xrpl::detail { template -ReadViewFwdRange::iterator::iterator(iterator const& other) +ReadViewFwdRange::Iterator::Iterator(Iterator const& other) : view_(other.view_), impl_(other.impl_ ? other.impl_->copy() : nullptr), cache_(other.cache_) { } template -ReadViewFwdRange::iterator::iterator(iterator&& other) noexcept +ReadViewFwdRange::Iterator::Iterator(Iterator&& other) noexcept : view_(other.view_), impl_(std::move(other.impl_)), cache_(std::move(other.cache_)) { } template -ReadViewFwdRange::iterator::iterator( +ReadViewFwdRange::Iterator::Iterator( ReadView const* view, std::unique_ptr impl) : view_(view), impl_(std::move(impl)) @@ -25,7 +24,7 @@ ReadViewFwdRange::iterator::iterator( template auto -ReadViewFwdRange::iterator::operator=(iterator const& other) -> iterator& +ReadViewFwdRange::Iterator::operator=(Iterator const& other) -> Iterator& { if (this != &other) { @@ -38,7 +37,7 @@ ReadViewFwdRange::iterator::operator=(iterator const& other) -> itera template auto -ReadViewFwdRange::iterator::operator=(iterator&& other) noexcept -> iterator& +ReadViewFwdRange::Iterator::operator=(Iterator&& other) noexcept -> Iterator& { if (this != &other) { @@ -52,7 +51,7 @@ ReadViewFwdRange::iterator::operator=(iterator&& other) noexcept -> i template bool -ReadViewFwdRange::iterator::operator==(iterator const& other) const +ReadViewFwdRange::Iterator::operator==(Iterator const& other) const { XRPL_ASSERT( view_ == other.view_, @@ -67,14 +66,14 @@ ReadViewFwdRange::iterator::operator==(iterator const& other) const template bool -ReadViewFwdRange::iterator::operator!=(iterator const& other) const +ReadViewFwdRange::Iterator::operator!=(Iterator const& other) const { return !(*this == other); } template auto -ReadViewFwdRange::iterator::operator*() const -> reference +ReadViewFwdRange::Iterator::operator*() const -> reference { if (!cache_) cache_ = impl_->dereference(); @@ -83,14 +82,14 @@ ReadViewFwdRange::iterator::operator*() const -> reference template auto -ReadViewFwdRange::iterator::operator->() const -> pointer +ReadViewFwdRange::Iterator::operator->() const -> pointer { return &**this; } template auto -ReadViewFwdRange::iterator::operator++() -> iterator& +ReadViewFwdRange::Iterator::operator++() -> Iterator& { impl_->increment(); cache_.reset(); @@ -99,13 +98,12 @@ ReadViewFwdRange::iterator::operator++() -> iterator& template auto -ReadViewFwdRange::iterator::operator++(int) -> iterator +ReadViewFwdRange::Iterator::operator++(int) -> Iterator { - iterator prev(view_, impl_->copy()); + Iterator prev(view_, impl_->copy()); prev.cache_ = std::move(cache_); ++(*this); return prev; } -} // namespace detail -} // namespace xrpl +} // namespace xrpl::detail diff --git a/include/xrpl/ledger/helpers/AMMHelpers.h b/include/xrpl/ledger/helpers/AMMHelpers.h index 9258d58fb6..c62437bf75 100644 --- a/include/xrpl/ledger/helpers/AMMHelpers.h +++ b/include/xrpl/ledger/helpers/AMMHelpers.h @@ -25,11 +25,11 @@ namespace detail { Number reduceOffer(auto const& amount) { - static Number const reducedOfferPct(9999, -4); + static Number const kREDUCED_OFFER_PCT(9999, -4); // Make sure the result is always less than amount or zero. - NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero); - return amount * reducedOfferPct; + NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); + return amount * kREDUCED_OFFER_PCT; } } // namespace detail @@ -177,10 +177,10 @@ getAMMOfferStartWithTakerGets( Quality const& targetQuality, std::uint16_t const& tfee) { - if (targetQuality.rate() == beast::zero) + if (targetQuality.rate() == beast::kZERO) return std::nullopt; - NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest); + NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest); auto const f = feeMult(tfee); auto const a = 1; auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out; @@ -202,7 +202,7 @@ getAMMOfferStartWithTakerGets( // Round downward to minimize the offer and to maximize the quality. // This has the most impact when takerGets is XRP. auto const takerGets = - toAmount(getAsset(pool.out), nTakerGetsProposed, Number::rounding_mode::downward); + toAmount(getAsset(pool.out), nTakerGetsProposed, Number::RoundingMode::Downward); return TAmounts{swapAssetOut(pool, takerGets, tfee), takerGets}; }; @@ -244,10 +244,10 @@ getAMMOfferStartWithTakerPays( Quality const& targetQuality, std::uint16_t tfee) { - if (targetQuality.rate() == beast::zero) + if (targetQuality.rate() == beast::kZERO) return std::nullopt; - NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest); + NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest); auto const f = feeMult(tfee); auto const& a = f; auto const b = pool.in * (1 + f); @@ -269,7 +269,7 @@ getAMMOfferStartWithTakerPays( // Round downward to minimize the offer and to maximize the quality. // This has the most impact when takerPays is XRP. auto const takerPays = - toAmount(getAsset(pool.in), nTakerPaysProposed, Number::rounding_mode::downward); + toAmount(getAsset(pool.in), nTakerPaysProposed, Number::RoundingMode::Downward); return TAmounts{takerPays, swapAssetIn(pool, takerPays, tfee)}; }; @@ -342,7 +342,7 @@ changeSpotPriceQuality( return std::nullopt; } auto const takerPays = - toAmount(getAsset(pool.in), nTakerPays, Number::rounding_mode::upward); + toAmount(getAsset(pool.in), nTakerPays, Number::RoundingMode::Upward); // should not fail if (auto amounts = TAmounts{takerPays, swapAssetIn(pool, takerPays, tfee)}; Quality{amounts} < quality && @@ -446,34 +446,34 @@ swapAssetIn(TAmounts const& pool, TIn const& assetIn, std::uint16_t t // 1-fee // maximize: // fee - saveNumberRoundMode const _{Number::getround()}; + SaveNumberRoundMode const _{Number::getround()}; - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const numerator = pool.in * pool.out; auto const fee = getFee(tfee); - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); auto const denom = pool.in + assetIn * (1 - fee); if (denom.signum() <= 0) return toAmount(getAsset(pool.out), 0); - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const ratio = numerator / denom; - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); auto const swapOut = pool.out - ratio; if (swapOut.signum() < 0) return toAmount(getAsset(pool.out), 0); - return toAmount(getAsset(pool.out), swapOut, Number::rounding_mode::downward); + return toAmount(getAsset(pool.out), swapOut, Number::RoundingMode::Downward); } return toAmount( getAsset(pool.out), pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - Number::rounding_mode::downward); + Number::RoundingMode::Downward); } /** Swap assetOut out of the pool and swap in a proportional amount @@ -508,38 +508,38 @@ swapAssetOut(TAmounts const& pool, TOut const& assetOut, std::uint16_ // maximize: // tfee/100000 - saveNumberRoundMode const _{Number::getround()}; + SaveNumberRoundMode const _{Number::getround()}; - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const numerator = pool.in * pool.out; - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); auto const denom = pool.out - assetOut; if (denom.signum() <= 0) { return toMaxAmount(getAsset(pool.in)); } - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const ratio = numerator / denom; auto const numerator2 = ratio - pool.in; auto const fee = getFee(tfee); - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); auto const feeMult = 1 - fee; - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const swapIn = numerator2 / feeMult; if (swapIn.signum() < 0) return toAmount(getAsset(pool.in), 0); - return toAmount(getAsset(pool.in), swapIn, Number::rounding_mode::upward); + return toAmount(getAsset(pool.in), swapIn, Number::RoundingMode::Upward); } return toAmount( getAsset(pool.in), ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee), - Number::rounding_mode::upward); + Number::RoundingMode::Upward); } /** Return square of n. @@ -589,26 +589,26 @@ Number solveQuadraticEq(Number const& a, Number const& b, Number const& c); STAmount -multiply(STAmount const& amount, Number const& frac, Number::rounding_mode rm); +multiply(STAmount const& amount, Number const& frac, Number::RoundingMode rm); namespace detail { -inline Number::rounding_mode +inline Number::RoundingMode getLPTokenRounding(IsDeposit isDeposit) { // Minimize on deposit, maximize on withdraw to ensure // AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance - return isDeposit == IsDeposit::Yes ? Number::rounding_mode::downward - : Number::rounding_mode::upward; + return isDeposit == IsDeposit::Yes ? Number::RoundingMode::Downward + : Number::RoundingMode::Upward; } -inline Number::rounding_mode +inline Number::RoundingMode getAssetRounding(IsDeposit isDeposit) { // Maximize on deposit, minimize on withdraw to ensure // AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance - return isDeposit == IsDeposit::Yes ? Number::rounding_mode::upward - : Number::rounding_mode::downward; + return isDeposit == IsDeposit::Yes ? Number::RoundingMode::Upward + : Number::RoundingMode::Downward; } } // namespace detail diff --git a/include/xrpl/ledger/helpers/EscrowHelpers.h b/include/xrpl/ledger/helpers/EscrowHelpers.h index b44601594d..5aa5214b1f 100644 --- a/include/xrpl/ledger/helpers/EscrowHelpers.h +++ b/include/xrpl/ledger/helpers/EscrowHelpers.h @@ -111,7 +111,7 @@ escrowUnlockApplyHelper( // whereas in a normal payment, the transfer fee is taken on top of the // sending amount. auto finalAmt = amount; - if ((!senderIssuer && !receiverIssuer) && lockedRate != parityRate) + if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE) { // compute transfer fee, if any auto const xferFee = @@ -211,7 +211,7 @@ escrowUnlockApplyHelper( // whereas in a normal payment, the transfer fee is taken on top of the // sending amount. auto finalAmt = amount; - if ((!senderIssuer && !receiverIssuer) && lockedRate != parityRate) + if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE) { // compute transfer fee, if any auto const xferFee = amount.value() - divideRound(amount, lockedRate, amount.asset(), true); diff --git a/include/xrpl/ledger/helpers/LendingHelpers.h b/include/xrpl/ledger/helpers/LendingHelpers.h index e1d8626b7c..83ce8e5efa 100644 --- a/include/xrpl/ledger/helpers/LendingHelpers.h +++ b/include/xrpl/ledger/helpers/LendingHelpers.h @@ -10,7 +10,7 @@ namespace xrpl { bool checkLendingProtocolDependencies(Rules const& rules, STTx const& tx); -static constexpr std::uint32_t secondsInYear = 365 * 24 * 60 * 60; +static constexpr std::uint32_t kSECONDS_IN_YEAR = 365 * 24 * 60 * 60; Number loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval); @@ -19,7 +19,7 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval); inline Number roundPeriodicPayment(Asset const& asset, Number const& periodicPayment, std::int32_t scale) { - return roundToAsset(asset, periodicPayment, scale, Number::rounding_mode::upward); + return roundToAsset(asset, periodicPayment, scale, Number::RoundingMode::Upward); } /* Represents the breakdown of amounts to be paid and changes applied to the @@ -42,14 +42,14 @@ struct LoanPaymentParts // The amount of principal paid that reduces the loan balance. // This amount is subtracted from sfPrincipalOutstanding in the Loan object // and paid to the Vault - Number principalPaid = numZero; + Number principalPaid = kNUM_ZERO; // The total amount of interest paid to the Vault. // This includes: // - Tracked interest from the amortization schedule // - Untracked interest (e.g., late payment penalty interest) // This value is always non-negative. - Number interestPaid = numZero; + Number interestPaid = kNUM_ZERO; // The change in the loan's total value outstanding. // - If valueChange < 0: Loan value decreased @@ -62,7 +62,7 @@ struct LoanPaymentParts // - Late payments add penalty interest to the loan value // - Early full payment may increase or decrease the loan value based on // terms - Number valueChange = numZero; + Number valueChange = kNUM_ZERO; /* The total amount of fees paid to the Broker. * This includes: @@ -70,7 +70,7 @@ struct LoanPaymentParts * - Untracked fees (e.g., late payment fees, service fees, origination * fees) This value is always non-negative. */ - Number feePaid = numZero; + Number feePaid = kNUM_ZERO; LoanPaymentParts& operator+=(LoanPaymentParts const& other); @@ -161,7 +161,7 @@ adjustImpreciseNumber( { value = roundToAsset(asset, value + adjustment, vaultScale); - if (*value < beast::zero) + if (*value < beast::kZERO) value = 0; } @@ -169,7 +169,7 @@ inline int getAssetsTotalScale(SLE::const_ref vaultSle) { if (!vaultSle) - return Number::minExponent - 1; // LCOV_EXCL_LINE + return Number::kMIN_EXPONENT - 1; // LCOV_EXCL_LINE return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset)); } @@ -222,7 +222,7 @@ namespace detail { // These classes and functions should only be accessed by LendingHelper // functions and unit tests -enum class PaymentSpecialCase { none, final, extra }; +enum class PaymentSpecialCase { None, Final, Extra }; /* Represents a single loan payment component parts. @@ -258,7 +258,7 @@ struct PaymentComponents // - none: Regular scheduled payment // - final: The last payment that closes out the loan // - extra: An additional payment beyond the regular schedule (overpayment) - PaymentSpecialCase specialCase = PaymentSpecialCase::none; + PaymentSpecialCase specialCase = PaymentSpecialCase::None; // Calculates the tracked interest portion of this payment. // This is derived from the other components as: @@ -310,7 +310,7 @@ struct ExtendedPaymentComponents : public PaymentComponents // borrower is sufficient to cover all components of the payment. Number totalDue; - ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = numZero) + ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNUM_ZERO) : PaymentComponents(p) , untrackedManagementFee(fee) , untrackedInterest(interest) @@ -462,7 +462,7 @@ isRounded(Asset const& asset, Number const& value, std::int32_t scale); // regular, late, and full are mutually exclusive. // overpayment is an "add on" to a regular payment, and follows that path with // potential extra work at the end. -enum class LoanPaymentType { regular = 0, late, full, overpayment }; +enum class LoanPaymentType { Regular = 0, Late, Full, Overpayment }; Expected loanMakePayment( diff --git a/include/xrpl/ledger/helpers/NFTokenHelpers.h b/include/xrpl/ledger/helpers/NFTokenHelpers.h index 49fd520d51..4294e1ca13 100644 --- a/include/xrpl/ledger/helpers/NFTokenHelpers.h +++ b/include/xrpl/ledger/helpers/NFTokenHelpers.h @@ -30,8 +30,8 @@ struct TokenAndPage STObject token; std::shared_ptr page; - TokenAndPage(STObject token_, std::shared_ptr page_) - : token(std::move(token_)), page(std::move(page_)) + TokenAndPage(STObject token, std::shared_ptr page) + : token(std::move(token)), page(std::move(page)) { } }; diff --git a/include/xrpl/ledger/helpers/TokenHelpers.h b/include/xrpl/ledger/helpers/TokenHelpers.h index 8f83465da3..3d41ac47cd 100644 --- a/include/xrpl/ledger/helpers/TokenHelpers.h +++ b/include/xrpl/ledger/helpers/TokenHelpers.h @@ -21,13 +21,13 @@ namespace xrpl { //------------------------------------------------------------------------------ /** Controls the treatment of frozen account balances */ -enum class FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN }; +enum class FreezeHandling { IgnoreFreeze, ZeroIfFrozen }; /** Controls the treatment of unauthorized MPT balances */ -enum class AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED }; +enum class AuthHandling { IgnoreAuth, ZeroIfUnauthorized }; /** Controls whether to include the account's full spendable balance */ -enum class SpendableHandling { shSIMPLE_BALANCE, shFULL_BALANCE }; +enum class SpendableHandling { SimpleBalance, FullBalance }; enum class WaiveTransferFee : bool { No = false, Yes }; @@ -135,7 +135,7 @@ accountHolds( AccountID const& issuer, FreezeHandling zeroIfFrozen, beast::Journal j, - SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE); + SpendableHandling includeFullBalance = SpendableHandling::SimpleBalance); [[nodiscard]] STAmount accountHolds( @@ -144,7 +144,7 @@ accountHolds( Issue const& issue, FreezeHandling zeroIfFrozen, beast::Journal j, - SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE); + SpendableHandling includeFullBalance = SpendableHandling::SimpleBalance); [[nodiscard]] STAmount accountHolds( @@ -154,7 +154,7 @@ accountHolds( FreezeHandling zeroIfFrozen, AuthHandling zeroIfUnauthorized, beast::Journal j, - SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE); + SpendableHandling includeFullBalance = SpendableHandling::SimpleBalance); [[nodiscard]] STAmount accountHolds( @@ -164,7 +164,7 @@ accountHolds( FreezeHandling zeroIfFrozen, AuthHandling zeroIfUnauthorized, beast::Journal j, - SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE); + SpendableHandling includeFullBalance = SpendableHandling::SimpleBalance); // Returns the amount an account can spend of the currency type saDefault, or // returns saDefault if this account is the issuer of the currency in diff --git a/include/xrpl/ledger/helpers/VaultHelpers.h b/include/xrpl/ledger/helpers/VaultHelpers.h index 8aef30aa27..14b0c004cb 100644 --- a/include/xrpl/ledger/helpers/VaultHelpers.h +++ b/include/xrpl/ledger/helpers/VaultHelpers.h @@ -41,7 +41,7 @@ sharesToAssetsDeposit( STAmount const& shares); /** Controls whether to truncate shares instead of rounding. */ -enum class TruncateShares : bool { no = false, yes = true }; +enum class TruncateShares : bool { No = false, Yes = true }; /** From the perspective of a vault, return the number of shares to demand from the depositor when they ask to withdraw a fixed amount of assets. Since @@ -60,7 +60,7 @@ assetsToSharesWithdraw( std::shared_ptr const& vault, std::shared_ptr const& issuance, STAmount const& assets, - TruncateShares truncate = TruncateShares::no); + TruncateShares truncate = TruncateShares::No); /** From the perspective of a vault, return the number of assets to give the depositor when they redeem a fixed amount of shares. Note, since shares are diff --git a/include/xrpl/net/AutoSocket.h b/include/xrpl/net/AutoSocket.h index 4dc20ffc5c..16ed0d6ca9 100644 --- a/include/xrpl/net/AutoSocket.h +++ b/include/xrpl/net/AutoSocket.h @@ -31,11 +31,11 @@ public: boost::asio::ssl::context& c, bool secureOnly, bool plainOnly) - : mSecure(secureOnly) - , mBuffer((plainOnly || secureOnly) ? 0 : 4) + : secure_(secureOnly) + , buffer_((plainOnly || secureOnly) ? 0 : 4) , j_{beast::Journal::getNullSink()} { - mSocket = std::make_unique(s, c); + socket_ = std::make_unique(s, c); } AutoSocket(boost::asio::io_context& s, boost::asio::ssl::context& c) @@ -46,74 +46,74 @@ public: [[nodiscard]] bool isSecure() const { - return mSecure; + return secure_; } ssl_socket& - SSLSocket() + sslSocket() { - return *mSocket; + return *socket_; } plain_socket& - PlainSocket() + plainSocket() { - return mSocket->next_layer(); + return socket_->next_layer(); } beast::IP::Endpoint - local_endpoint() + localEndpoint() { - return beast::IP::from_asio(lowest_layer().local_endpoint()); + return beast::IP::fromAsio(lowestLayer().local_endpoint()); } beast::IP::Endpoint - remote_endpoint() + remoteEndpoint() { - return beast::IP::from_asio(lowest_layer().remote_endpoint()); + return beast::IP::fromAsio(lowestLayer().remote_endpoint()); } lowest_layer_type& - lowest_layer() + lowestLayer() { - return mSocket->lowest_layer(); + return socket_->lowest_layer(); } void swap(AutoSocket& s) noexcept { - mBuffer.swap(s.mBuffer); - mSocket.swap(s.mSocket); - std::swap(mSecure, s.mSecure); + buffer_.swap(s.buffer_); + socket_.swap(s.socket_); + std::swap(secure_, s.secure_); } boost::system::error_code cancel(boost::system::error_code& ec) { - return lowest_layer().cancel(ec); + return lowestLayer().cancel(ec); } void - async_handshake(handshake_type type, callback cbFunc) + asyncHandshake(handshake_type type, callback cbFunc) { - if ((type == ssl_socket::client) || (mSecure)) + if ((type == ssl_socket::client) || (secure_)) { // must be ssl - mSecure = true; - mSocket->async_handshake(type, cbFunc); + secure_ = true; + socket_->async_handshake(type, cbFunc); } - else if (mBuffer.empty()) + else if (buffer_.empty()) { // must be plain - mSecure = false; - post(mSocket->get_executor(), boost::beast::bind_handler(cbFunc, error_code())); + secure_ = false; + post(socket_->get_executor(), boost::beast::bind_handler(cbFunc, error_code())); } else { // autodetect - mSocket->next_layer().async_receive( - boost::asio::buffer(mBuffer), + socket_->next_layer().async_receive( + boost::asio::buffer(buffer_), boost::asio::socket_base::message_peek, std::bind( - &AutoSocket::handle_autodetect, + &AutoSocket::handleAutodetect, this, cbFunc, std::placeholders::_1, @@ -123,176 +123,176 @@ public: template void - async_shutdown(ShutdownHandler handler) + asyncShutdown(ShutdownHandler handler) { if (isSecure()) { - mSocket->async_shutdown(handler); + socket_->async_shutdown(handler); } else { error_code ec; try { - lowest_layer().shutdown(plain_socket::shutdown_both); + lowestLayer().shutdown(plain_socket::shutdown_both); } catch (boost::system::system_error const& e) { ec = e.code(); } - post(mSocket->get_executor(), boost::beast::bind_handler(handler, ec)); + post(socket_->get_executor(), boost::beast::bind_handler(handler, ec)); } } template void - async_read_some(Seq const& buffers, Handler handler) + asyncReadSome(Seq const& buffers, Handler handler) { if (isSecure()) { - mSocket->async_read_some(buffers, handler); + socket_->async_read_some(buffers, handler); } else { - PlainSocket().async_read_some(buffers, handler); + plainSocket().async_read_some(buffers, handler); } } template void - async_read_until(Seq const& buffers, Condition condition, Handler handler) + asyncReadUntil(Seq const& buffers, Condition condition, Handler handler) { if (isSecure()) { - boost::asio::async_read_until(*mSocket, buffers, condition, handler); + boost::asio::async_read_until(*socket_, buffers, condition, handler); } else { - boost::asio::async_read_until(PlainSocket(), buffers, condition, handler); + boost::asio::async_read_until(plainSocket(), buffers, condition, handler); } } template void - async_read_until( + asyncReadUntil( boost::asio::basic_streambuf& buffers, std::string const& delim, Handler handler) { if (isSecure()) { - boost::asio::async_read_until(*mSocket, buffers, delim, handler); + boost::asio::async_read_until(*socket_, buffers, delim, handler); } else { - boost::asio::async_read_until(PlainSocket(), buffers, delim, handler); + boost::asio::async_read_until(plainSocket(), buffers, delim, handler); } } template void - async_read_until( + asyncReadUntil( boost::asio::basic_streambuf& buffers, MatchCondition cond, Handler handler) { if (isSecure()) { - boost::asio::async_read_until(*mSocket, buffers, cond, handler); + boost::asio::async_read_until(*socket_, buffers, cond, handler); } else { - boost::asio::async_read_until(PlainSocket(), buffers, cond, handler); + boost::asio::async_read_until(plainSocket(), buffers, cond, handler); } } template void - async_write(Buf const& buffers, Handler handler) + asyncWrite(Buf const& buffers, Handler handler) { if (isSecure()) { - boost::asio::async_write(*mSocket, buffers, handler); + boost::asio::async_write(*socket_, buffers, handler); } else { - boost::asio::async_write(PlainSocket(), buffers, handler); + boost::asio::async_write(plainSocket(), buffers, handler); } } template void - async_write(boost::asio::basic_streambuf& buffers, Handler handler) + asyncWrite(boost::asio::basic_streambuf& buffers, Handler handler) { if (isSecure()) { - boost::asio::async_write(*mSocket, buffers, handler); + boost::asio::async_write(*socket_, buffers, handler); } else { - boost::asio::async_write(PlainSocket(), buffers, handler); + boost::asio::async_write(plainSocket(), buffers, handler); } } template void - async_read(Buf const& buffers, Condition cond, Handler handler) + asyncRead(Buf const& buffers, Condition cond, Handler handler) { if (isSecure()) { - boost::asio::async_read(*mSocket, buffers, cond, handler); + boost::asio::async_read(*socket_, buffers, cond, handler); } else { - boost::asio::async_read(PlainSocket(), buffers, cond, handler); + boost::asio::async_read(plainSocket(), buffers, cond, handler); } } template void - async_read(boost::asio::basic_streambuf& buffers, Condition cond, Handler handler) + asyncRead(boost::asio::basic_streambuf& buffers, Condition cond, Handler handler) { if (isSecure()) { - boost::asio::async_read(*mSocket, buffers, cond, handler); + boost::asio::async_read(*socket_, buffers, cond, handler); } else { - boost::asio::async_read(PlainSocket(), buffers, cond, handler); + boost::asio::async_read(plainSocket(), buffers, cond, handler); } } template void - async_read(Buf const& buffers, Handler handler) + asyncRead(Buf const& buffers, Handler handler) { if (isSecure()) { - boost::asio::async_read(*mSocket, buffers, handler); + boost::asio::async_read(*socket_, buffers, handler); } else { - boost::asio::async_read(PlainSocket(), buffers, handler); + boost::asio::async_read(plainSocket(), buffers, handler); } } template void - async_write_some(Seq const& buffers, Handler handler) + asyncWriteSome(Seq const& buffers, Handler handler) { if (isSecure()) { - mSocket->async_write_some(buffers, handler); + socket_->async_write_some(buffers, handler); } else { - PlainSocket().async_write_some(buffers, handler); + plainSocket().async_write_some(buffers, handler); } } protected: void - handle_autodetect(callback cbFunc, error_code const& ec, size_t bytesTransferred) + handleAutodetect(callback cbFunc, error_code const& ec, size_t bytesTransferred) { using namespace xrpl; @@ -302,28 +302,28 @@ protected: cbFunc(ec); } else if ( - (mBuffer[0] < 127) && (mBuffer[0] > 31) && - ((bytesTransferred < 2) || ((mBuffer[1] < 127) && (mBuffer[1] > 31))) && - ((bytesTransferred < 3) || ((mBuffer[2] < 127) && (mBuffer[2] > 31))) && - ((bytesTransferred < 4) || ((mBuffer[3] < 127) && (mBuffer[3] > 31)))) + (buffer_[0] < 127) && (buffer_[0] > 31) && + ((bytesTransferred < 2) || ((buffer_[1] < 127) && (buffer_[1] > 31))) && + ((bytesTransferred < 3) || ((buffer_[2] < 127) && (buffer_[2] > 31))) && + ((bytesTransferred < 4) || ((buffer_[3] < 127) && (buffer_[3] > 31)))) { // not ssl JLOG(j_.trace()) << "non-SSL"; - mSecure = false; + secure_ = false; cbFunc(ec); } else { // ssl JLOG(j_.trace()) << "SSL"; - mSecure = true; - mSocket->async_handshake(ssl_socket::server, cbFunc); + secure_ = true; + socket_->async_handshake(ssl_socket::server, cbFunc); } } private: - socket_ptr mSocket; - bool mSecure; - std::vector mBuffer; + socket_ptr socket_; + bool secure_; + std::vector buffer_; beast::Journal j_; }; diff --git a/include/xrpl/net/HTTPClient.h b/include/xrpl/net/HTTPClient.h index c176e2d2e8..ea0c5d72cd 100644 --- a/include/xrpl/net/HTTPClient.h +++ b/include/xrpl/net/HTTPClient.h @@ -20,7 +20,7 @@ class HTTPClient public: explicit HTTPClient() = default; - static constexpr auto maxClientHeaderBytes = kilobytes(32); + static constexpr auto kMAX_CLIENT_HEADER_BYTES = kilobytes(32); static void initializeSSLContext( @@ -43,7 +43,7 @@ public: static void get(bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::deque deqSites, unsigned short const port, std::string const& strPath, @@ -57,7 +57,7 @@ public: static void get(bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::string strSite, unsigned short const port, std::string const& strPath, @@ -72,7 +72,7 @@ public: static void request( bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::string strSite, unsigned short const port, std::function build, diff --git a/include/xrpl/net/HTTPClientSSLContext.h b/include/xrpl/net/HTTPClientSSLContext.h index 060746b7d8..d1744bbce4 100644 --- a/include/xrpl/net/HTTPClientSSLContext.h +++ b/include/xrpl/net/HTTPClientSSLContext.h @@ -120,7 +120,7 @@ public: { strm.set_verify_callback( std::bind( - &rfc6125_verify, host, std::placeholders::_1, std::placeholders::_2, j_), + &rfc6125Verify, host, std::placeholders::_1, std::placeholders::_2, j_), ec); } } @@ -138,7 +138,7 @@ public: * @param j journal for logging */ static bool - rfc6125_verify( + rfc6125Verify( std::string const& domain, bool preverified, boost::asio::ssl::verify_context& ctx, diff --git a/include/xrpl/nodestore/Backend.h b/include/xrpl/nodestore/Backend.h index 7f9dd172cc..124cd99db5 100644 --- a/include/xrpl/nodestore/Backend.h +++ b/include/xrpl/nodestore/Backend.h @@ -113,7 +113,7 @@ public: @see import */ virtual void - for_each(std::function)> f) = 0; + forEach(std::function)> f) = 0; /** Estimate the number of write operations pending. */ virtual int diff --git a/include/xrpl/nodestore/Database.h b/include/xrpl/nodestore/Database.h index c21c1e27dd..ca2dde560c 100644 --- a/include/xrpl/nodestore/Database.h +++ b/include/xrpl/nodestore/Database.h @@ -110,7 +110,7 @@ public: fetchNodeObject( uint256 const& hash, std::uint32_t ledgerSeq = 0, - FetchType fetchType = FetchType::synchronous, + FetchType fetchType = FetchType::Synchronous, bool duplicate = false); /** Fetch an object without waiting. @@ -166,7 +166,7 @@ public: } void - getCountsJson(Json::Value& obj); + getCountsJson(json::Value& obj); /** Returns the number of file descriptors the database expects to need */ int @@ -266,7 +266,7 @@ private: @see import */ virtual void - for_each(std::function)> f) = 0; + forEach(std::function)> f) = 0; void threadEntry(); diff --git a/include/xrpl/nodestore/Manager.h b/include/xrpl/nodestore/Manager.h index 7f718d7835..1c4e5b63cf 100644 --- a/include/xrpl/nodestore/Manager.h +++ b/include/xrpl/nodestore/Manager.h @@ -36,7 +36,7 @@ public: /** Create a backend. */ virtual std::unique_ptr - make_Backend( + makeBackend( Section const& parameters, std::size_t burstSize, Scheduler& scheduler, @@ -71,7 +71,7 @@ public: @return The opened database. */ virtual std::unique_ptr - make_Database( + makeDatabase( std::size_t burstSize, Scheduler& scheduler, int readThreads, diff --git a/include/xrpl/nodestore/NodeObject.h b/include/xrpl/nodestore/NodeObject.h index 8759f244d2..2a216606c4 100644 --- a/include/xrpl/nodestore/NodeObject.h +++ b/include/xrpl/nodestore/NodeObject.h @@ -10,11 +10,11 @@ namespace xrpl { /** The types of node objects. */ enum class NodeObjectType : std::uint32_t { - hotUNKNOWN = 0, - hotLEDGER = 1, - hotACCOUNT_NODE = 3, - hotTRANSACTION_NODE = 4, - hotDUMMY = 512 // an invalid or missing object + Unknown = 0, + Ledger = 1, + AccountNode = 3, + TransactionNode = 4, + Dummy = 512 // an invalid or missing object }; /** A simple object that the Ledger uses to store entries. @@ -29,7 +29,7 @@ enum class NodeObjectType : std::uint32_t { class NodeObject : public CountedObject { public: - static constexpr std::size_t keyBytes = 32; + static constexpr std::size_t kKEY_BYTES = 32; private: // This hack is used to make the constructor effectively private @@ -71,9 +71,9 @@ public: getData() const; private: - NodeObjectType const mType; - uint256 const mHash; - Blob const mData; + NodeObjectType const type_; + uint256 const hash_; + Blob const data_; }; } // namespace xrpl diff --git a/include/xrpl/nodestore/Scheduler.h b/include/xrpl/nodestore/Scheduler.h index bf256648aa..588ff19bdc 100644 --- a/include/xrpl/nodestore/Scheduler.h +++ b/include/xrpl/nodestore/Scheduler.h @@ -6,12 +6,12 @@ namespace xrpl::NodeStore { -enum class FetchType { synchronous, async }; +enum class FetchType { Synchronous, Async }; /** Contains information about a fetch operation. */ struct FetchReport { - explicit FetchReport(FetchType fetchType_) : fetchType(fetchType_) + explicit FetchReport(FetchType fetchType) : fetchType(fetchType) { } diff --git a/include/xrpl/nodestore/Types.h b/include/xrpl/nodestore/Types.h index cc7d345067..2b5d9ac770 100644 --- a/include/xrpl/nodestore/Types.h +++ b/include/xrpl/nodestore/Types.h @@ -12,24 +12,24 @@ enum { // This is only used to pre-allocate the array for // batch objects and does not affect the amount written. // - batchWritePreallocationSize = 256, + BatchWritePreallocationSize = 256, // This sets a limit on the maximum number of writes // in a batch. Actual usage can be twice this since // we have a new batch growing as we write the old. // - batchWriteLimitSize = 65536 + BatchWriteLimitSize = 65536 }; /** Return codes from Backend operations. */ enum class Status { - ok = 0, - notFound = 1, - dataCorrupt = 2, - unknown = 3, - backendError = 4, + Ok = 0, + NotFound = 1, + DataCorrupt = 2, + Unknown = 3, + BackendError = 4, - customCode = 100 + CustomCode = 100 }; /** A batch of NodeObjects to write at once. */ diff --git a/include/xrpl/nodestore/detail/BatchWriter.h b/include/xrpl/nodestore/detail/BatchWriter.h index 1112ccc324..b0383838dc 100644 --- a/include/xrpl/nodestore/detail/BatchWriter.h +++ b/include/xrpl/nodestore/detail/BatchWriter.h @@ -66,13 +66,13 @@ private: using LockType = std::recursive_mutex; using CondvarType = std::condition_variable_any; - Callback& m_callback; - Scheduler& m_scheduler; - LockType mWriteMutex; - CondvarType mWriteCondition; - int mWriteLoad{0}; - bool mWritePending{false}; - Batch mWriteSet; + Callback& callback_; + Scheduler& scheduler_; + LockType writeMutex_; + CondvarType writeCondition_; + int writeLoad_{0}; + bool writePending_{false}; + Batch writeSet_; }; } // namespace xrpl::NodeStore diff --git a/include/xrpl/nodestore/detail/DatabaseNodeImp.h b/include/xrpl/nodestore/detail/DatabaseNodeImp.h index 88fb994bee..add66c51a7 100644 --- a/include/xrpl/nodestore/detail/DatabaseNodeImp.h +++ b/include/xrpl/nodestore/detail/DatabaseNodeImp.h @@ -85,9 +85,9 @@ private: override; void - for_each(std::function)> f) override + forEach(std::function)> f) override { - backend_->for_each(f); + backend_->forEach(f); } }; diff --git a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h index 7010c87ebf..39441ef4d8 100644 --- a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h +++ b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h @@ -65,7 +65,7 @@ private: override; void - for_each(std::function)> f) override; + forEach(std::function)> f) override; }; } // namespace xrpl::NodeStore diff --git a/include/xrpl/nodestore/detail/DecodedBlob.h b/include/xrpl/nodestore/detail/DecodedBlob.h index 8c75e58d48..90a7b6c9cb 100644 --- a/include/xrpl/nodestore/detail/DecodedBlob.h +++ b/include/xrpl/nodestore/detail/DecodedBlob.h @@ -24,7 +24,7 @@ public: [[nodiscard]] bool wasOk() const noexcept { - return m_success; + return success_; } /** Create a NodeObject from this data. */ @@ -32,12 +32,12 @@ public: createObject(); private: - bool m_success; + bool success_; - void const* m_key; - NodeObjectType m_objectType; - unsigned char const* m_objectData; - int m_dataBytes; + void const* key_; + NodeObjectType objectType_; + unsigned char const* objectData_; + int dataBytes_; }; } // namespace xrpl::NodeStore diff --git a/include/xrpl/nodestore/detail/ManagerImp.h b/include/xrpl/nodestore/detail/ManagerImp.h index 46363f9dab..98aec6459b 100644 --- a/include/xrpl/nodestore/detail/ManagerImp.h +++ b/include/xrpl/nodestore/detail/ManagerImp.h @@ -15,7 +15,7 @@ public: instance(); static void - missing_backend(); + missingBackend(); ManagerImp(); @@ -31,14 +31,14 @@ public: erase(Factory& factory) override; std::unique_ptr - make_Backend( + makeBackend( Section const& parameters, std::size_t burstSize, Scheduler& scheduler, beast::Journal journal) override; std::unique_ptr - make_Database( + makeDatabase( std::size_t burstSize, Scheduler& scheduler, int readThreads, diff --git a/include/xrpl/nodestore/detail/codec.h b/include/xrpl/nodestore/detail/codec.h index e127062b80..4dedc54902 100644 --- a/include/xrpl/nodestore/detail/codec.h +++ b/include/xrpl/nodestore/detail/codec.h @@ -21,16 +21,16 @@ namespace xrpl::NodeStore { template std::pair -lz4_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) +lz4Decompress(void const* in, std::size_t inSize, BufferFactory&& bf) { - if (static_cast(in_size) < 0) + if (static_cast(inSize) < 0) Throw("lz4_decompress: integer overflow (input)"); std::size_t outSize = 0; - auto const n = read_varint(reinterpret_cast(in), in_size, outSize); + auto const n = readVarint(reinterpret_cast(in), inSize, outSize); - if (n == 0 || n >= in_size) + if (n == 0 || n >= inSize) Throw("lz4_decompress: invalid blob"); if (static_cast(outSize) <= 0) @@ -41,7 +41,7 @@ lz4_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) if (LZ4_decompress_safe( reinterpret_cast(in) + n, reinterpret_cast(out), - static_cast(in_size - n), + static_cast(inSize - n), static_cast(outSize)) != static_cast(outSize)) Throw("lz4_decompress: LZ4_decompress_safe"); @@ -50,22 +50,22 @@ lz4_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) template std::pair -lz4_compress(void const* in, std::size_t in_size, BufferFactory&& bf) +lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf) { using std::runtime_error; using namespace nudb::detail; std::pair result; - std::array::max> vi{}; - auto const n = write_varint(vi.data(), in_size); - auto const out_max = LZ4_compressBound(in_size); - std::uint8_t* out = reinterpret_cast(bf(n + out_max)); + std::array::kMAX> vi{}; + auto const n = writeVarint(vi.data(), inSize); + auto const outMax = LZ4_compressBound(inSize); + std::uint8_t* out = reinterpret_cast(bf(n + outMax)); result.first = out; std::memcpy(out, vi.data(), n); - auto const out_size = LZ4_compress_default( - reinterpret_cast(in), reinterpret_cast(out + n), in_size, out_max); - if (out_size == 0) + auto const outSize = LZ4_compress_default( + reinterpret_cast(in), reinterpret_cast(out + n), inSize, outMax); + if (outSize == 0) Throw("lz4 compress"); - result.second = n + out_size; + result.second = n + outSize; return result; } @@ -82,17 +82,17 @@ lz4_compress(void const* in, std::size_t in_size, BufferFactory&& bf) template std::pair -nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) +nodeobjectDecompress(void const* in, std::size_t inSize, BufferFactory&& bf) { using namespace nudb::detail; std::uint8_t const* p = reinterpret_cast(in); std::size_t type = 0; - auto const vn = read_varint(p, in_size, type); + auto const vn = readVarint(p, inSize, type); if (vn == 0) Throw("nodeobject decompress"); p += vn; - in_size -= vn; + inSize -= vn; std::pair result; switch (type) @@ -100,35 +100,35 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) case 0: // uncompressed { result.first = p; - result.second = in_size; + result.second = inSize; break; } case 1: // lz4 { - result = lz4_decompress(p, in_size, bf); + result = lz4Decompress(p, inSize, bf); break; } case 2: // compressed v1 inner node { auto const hs = field::size; // Mask - if (in_size < hs + 32) + if (inSize < hs + 32) { Throw( "nodeobject codec v1: short inner node size: " + std::string("in_size = ") + - std::to_string(in_size) + " hs = " + std::to_string(hs)); + std::to_string(inSize) + " hs = " + std::to_string(hs)); } - istream is(p, in_size); + istream is(p, inSize); std::uint16_t mask = 0; read(is, mask); // Mask - in_size -= hs; + inSize -= hs; result.second = 525; void* const out = bf(result.second); result.first = out; ostream os(out, result.second); write(os, 0); write(os, 0); - write(os, static_cast(NodeObjectType::hotUNKNOWN)); - write(os, static_cast(HashPrefix::innerNode)); + write(os, static_cast(NodeObjectType::Unknown)); + write(os, static_cast(HashPrefix::InnerNode)); if (mask == 0) Throw("nodeobject codec v1: empty inner node"); std::uint16_t bit = 0x8000; @@ -136,45 +136,45 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) { if (mask & bit) { - if (in_size < 32) + if (inSize < 32) { Throw( "nodeobject codec v1: short inner node subsize: " + - std::string("in_size = ") + std::to_string(in_size) + + std::string("in_size = ") + std::to_string(inSize) + " i = " + std::to_string(i)); } std::memcpy(os.data(32), is(32), 32); - in_size -= 32; + inSize -= 32; } else { std::memset(os.data(32), 0, 32); } } - if (in_size > 0) + if (inSize > 0) { Throw( - "nodeobject codec v1: long inner node, in_size = " + std::to_string(in_size)); + "nodeobject codec v1: long inner node, in_size = " + std::to_string(inSize)); } break; } case 3: // full v1 inner node { - if (in_size != 16 * 32) + if (inSize != 16 * 32) { // hashes Throw( "nodeobject codec v1: short full inner node, in_size = " + - std::to_string(in_size)); + std::to_string(inSize)); } - istream is(p, in_size); + istream is(p, inSize); result.second = 525; void* const out = bf(result.second); result.first = out; ostream os(out, result.second); write(os, 0); write(os, 0); - write(os, static_cast(NodeObjectType::hotUNKNOWN)); - write(os, static_cast(HashPrefix::innerNode)); + write(os, static_cast(NodeObjectType::Unknown)); + write(os, static_cast(HashPrefix::InnerNode)); write(os, is(512), 512); break; } @@ -188,21 +188,21 @@ template void const* zero32() { - static std::array v{}; - return v.data(); + static std::array kV{}; + return kV.data(); } template std::pair -nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) +nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf) { using std::runtime_error; using namespace nudb::detail; // Check for inner node v1 - if (in_size == 525) + if (inSize == 525) { - istream is(in, in_size); + istream is(in, inSize); std::uint32_t index = 0; std::uint32_t unused = 0; std::uint8_t kind = 0; @@ -211,7 +211,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) read(is, unused); read(is, kind); read(is, prefix); - if (safe_cast(prefix) == HashPrefix::innerNode) + if (safeCast(prefix) == HashPrefix::InnerNode) { std::size_t n = 0; std::uint16_t mask = 0; @@ -230,7 +230,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) { // 2 = v1 inner node compressed auto const type = 2U; - auto const vs = size_varint(type); + auto const vs = sizeVarint(type); result.second = vs + field::size + // mask (n * 32); // hashes std::uint8_t* out = reinterpret_cast(bf(result.second)); @@ -243,7 +243,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) } // 3 = full v1 inner node auto const type = 3U; - auto const vs = size_varint(type); + auto const vs = sizeVarint(type); result.second = vs + (n * 32); // hashes std::uint8_t* out = reinterpret_cast(bf(result.second)); result.first = out; @@ -254,18 +254,18 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) } } - std::array::max> vi{}; + std::array::kMAX> vi{}; - constexpr std::size_t codecType = 1; - auto const vn = write_varint(vi.data(), codecType); + constexpr std::size_t kCODEC_TYPE = 1; + auto const vn = writeVarint(vi.data(), kCODEC_TYPE); std::pair result; - switch (codecType) + switch (kCODEC_TYPE) { // case 0 was uncompressed data; we always compress now. case 1: // lz4 { std::uint8_t* p = nullptr; - auto const lzr = NodeStore::lz4_compress(in, in_size, [&p, &vn, &bf](std::size_t n) { + auto const lzr = NodeStore::lz4Compress(in, inSize, [&p, &vn, &bf](std::size_t n) { p = reinterpret_cast(bf(vn + n)); return p + vn; }); @@ -275,7 +275,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) break; } default: - Throw("nodeobject codec: unknown=" + std::to_string(codecType)); + Throw("nodeobject codec: unknown=" + std::to_string(kCODEC_TYPE)); }; return result; } @@ -286,14 +286,14 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) // template void -filter_inner(void* in, std::size_t in_size) +filterInner(void* in, std::size_t inSize) { using namespace nudb::detail; // Check for inner node - if (in_size == 525) + if (inSize == 525) { - istream is(in, in_size); + istream is(in, inSize); std::uint32_t index = 0; std::uint32_t unused = 0; std::uint8_t kind = 0; @@ -302,12 +302,12 @@ filter_inner(void* in, std::size_t in_size) read(is, unused); read(is, kind); read(is, prefix); - if (safe_cast(prefix) == HashPrefix::innerNode) + if (safeCast(prefix) == HashPrefix::InnerNode) { ostream os(in, 9); write(os, 0); write(os, 0); - write(os, static_cast(NodeObjectType::hotUNKNOWN)); + write(os, static_cast(NodeObjectType::Unknown)); } } } diff --git a/include/xrpl/nodestore/detail/varint.h b/include/xrpl/nodestore/detail/varint.h index 7c2a3756ff..c98b36e322 100644 --- a/include/xrpl/nodestore/detail/varint.h +++ b/include/xrpl/nodestore/detail/varint.h @@ -25,7 +25,7 @@ struct varint_traits { explicit varint_traits() = default; - static std::size_t constexpr max = (8 * sizeof(T) + 6) / 7; + static std::size_t constexpr kMAX = (8 * sizeof(T) + 6) / 7; }; // Returns: Number of bytes consumed or 0 on error, @@ -33,7 +33,7 @@ struct varint_traits // template std::size_t -read_varint(void const* buf, std::size_t buflen, std::size_t& t) +readVarint(void const* buf, std::size_t buflen, std::size_t& t) { if (buflen == 0) return 0; @@ -69,7 +69,7 @@ read_varint(void const* buf, std::size_t buflen, std::size_t& t) template >* = nullptr> std::size_t -size_varint(T v) +sizeVarint(T v) { std::size_t n = 0; do @@ -82,7 +82,7 @@ size_varint(T v) template std::size_t -write_varint(void* p0, std::size_t v) +writeVarint(void* p0, std::size_t v) { // NOLINTNEXTLINE(misc-const-correctness) std::uint8_t* p = reinterpret_cast(p0); @@ -107,7 +107,7 @@ read(nudb::detail::istream& is, std::size_t& u) auto p1 = p0; while (*p1++ & 0x80) is(1); - read_varint(p0, p1 - p0, u); + readVarint(p0, p1 - p0, u); } // output stream @@ -116,7 +116,7 @@ template >* = nullptr> void write(nudb::detail::ostream& os, std::size_t t) { - write_varint(os.data(size_varint(t)), t); + writeVarint(os.data(sizeVarint(t)), t); } } // namespace xrpl::NodeStore diff --git a/include/xrpl/protocol/AMMCore.h b/include/xrpl/protocol/AMMCore.h index 7a835b44cd..9d8f8c62b0 100644 --- a/include/xrpl/protocol/AMMCore.h +++ b/include/xrpl/protocol/AMMCore.h @@ -8,21 +8,21 @@ namespace xrpl { -std::uint16_t constexpr TRADING_FEE_THRESHOLD = 1000; // 1% +std::uint16_t constexpr kTRADING_FEE_THRESHOLD = 1000; // 1% // Auction slot -std::uint32_t constexpr TOTAL_TIME_SLOT_SECS = 24 * 3600; -std::uint16_t constexpr AUCTION_SLOT_TIME_INTERVALS = 20; -std::uint16_t constexpr AUCTION_SLOT_MAX_AUTH_ACCOUNTS = 4; -std::uint32_t constexpr AUCTION_SLOT_FEE_SCALE_FACTOR = 100000; -std::uint32_t constexpr AUCTION_SLOT_DISCOUNTED_FEE_FRACTION = 10; -std::uint32_t constexpr AUCTION_SLOT_MIN_FEE_FRACTION = 25; -std::uint32_t constexpr AUCTION_SLOT_INTERVAL_DURATION = - TOTAL_TIME_SLOT_SECS / AUCTION_SLOT_TIME_INTERVALS; +std::uint32_t constexpr kTOTAL_TIME_SLOT_SECS = 24 * 3600; +std::uint16_t constexpr kAUCTION_SLOT_TIME_INTERVALS = 20; +std::uint16_t constexpr kAUCTION_SLOT_MAX_AUTH_ACCOUNTS = 4; +std::uint32_t constexpr kAUCTION_SLOT_FEE_SCALE_FACTOR = 100000; +std::uint32_t constexpr kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION = 10; +std::uint32_t constexpr kAUCTION_SLOT_MIN_FEE_FRACTION = 25; +std::uint32_t constexpr kAUCTION_SLOT_INTERVAL_DURATION = + kTOTAL_TIME_SLOT_SECS / kAUCTION_SLOT_TIME_INTERVALS; // Votes -std::uint16_t constexpr VOTE_MAX_SLOTS = 8; -std::uint32_t constexpr VOTE_WEIGHT_SCALE_FACTOR = 100000; +std::uint16_t constexpr kVOTE_MAX_SLOTS = 8; +std::uint32_t constexpr kVOTE_WEIGHT_SCALE_FACTOR = 100000; class STObject; class STAmount; @@ -77,7 +77,7 @@ ammEnabled(Rules const&); inline Number getFee(std::uint16_t tfee) { - return Number{tfee} / AUCTION_SLOT_FEE_SCALE_FACTOR; + return Number{tfee} / kAUCTION_SLOT_FEE_SCALE_FACTOR; } /** Get fee multiplier (1 - tfee) diff --git a/include/xrpl/protocol/AccountID.h b/include/xrpl/protocol/AccountID.h index 641f2f15c1..e22c3b8edd 100644 --- a/include/xrpl/protocol/AccountID.h +++ b/include/xrpl/protocol/AccountID.h @@ -25,7 +25,7 @@ public: } // namespace detail /** A 160-bit unsigned that uniquely identifies an account. */ -using AccountID = base_uint<160, detail::AccountIDTag>; +using AccountID = BaseUint<160, detail::AccountIDTag>; /** Convert AccountID to base58 checked string */ std::string @@ -63,13 +63,13 @@ noAccount(); */ // DEPRECATED bool -to_issuer(AccountID&, std::string const&); +toIssuer(AccountID&, std::string const&); // DEPRECATED Should be checking the currency or native flag inline bool isXRP(AccountID const& c) { - return c == beast::zero; + return c == beast::kZERO; } // DEPRECATED @@ -105,10 +105,10 @@ initAccountIdCache(std::size_t count); } // namespace xrpl //------------------------------------------------------------------------------ -namespace Json { +namespace json { template <> inline xrpl::AccountID -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; @@ -117,7 +117,7 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) return *r; Throw(field.getJsonName(), "AccountID"); } -} // namespace Json +} // namespace json //------------------------------------------------------------------------------ diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index 9fb45e7bf8..53b7dace3c 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -15,7 +15,7 @@ toSTAmount(IOUAmount const& iou, Asset const& asset) XRPL_ASSERT(asset.holds(), "xrpl::toSTAmount : is Issue"); bool const isNeg = iou.signum() < 0; std::uint64_t const umant = isNeg ? -iou.mantissa() : iou.mantissa(); - return STAmount(asset, umant, iou.exponent(), isNeg, STAmount::unchecked()); + return STAmount(asset, umant, iou.exponent(), isNeg, STAmount::Unchecked()); } inline STAmount @@ -96,9 +96,9 @@ inline MPTAmount toAmount(STAmount const& amt) { XRPL_ASSERT( - amt.holds() && amt.mantissa() <= maxMPTokenAmount && amt.exponent() == 0, + amt.holds() && amt.mantissa() <= kMAX_MP_TOKEN_AMOUNT && amt.exponent() == 0, "xrpl::toAmount : maximum mantissa"); - if (amt.mantissa() > maxMPTokenAmount || amt.exponent() != 0) + if (amt.mantissa() > kMAX_MP_TOKEN_AMOUNT || amt.exponent() != 0) Throw("toAmount: invalid mantissa or exponent"); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); @@ -141,9 +141,9 @@ toAmount(MPTAmount const& amt) template T -toAmount(Asset const& asset, Number const& n, Number::rounding_mode mode = Number::getround()) +toAmount(Asset const& asset, Number const& n, Number::RoundingMode mode = Number::getround()) { - saveNumberRoundMode const rm(Number::getround()); + SaveNumberRoundMode const rm(Number::getround()); if (isXRP(asset)) Number::setround(mode); @@ -167,8 +167,8 @@ toAmount(Asset const& asset, Number const& n, Number::rounding_mode mode = Numbe } else { - constexpr bool alwaysFalse = !std::is_same_v; - static_assert(alwaysFalse, "Unsupported type for toAmount"); + constexpr bool kALWAYS_FALSE = !std::is_same_v; + static_assert(kALWAYS_FALSE, "Unsupported type for toAmount"); } } @@ -178,35 +178,35 @@ toMaxAmount(Asset const& asset) { if constexpr (std::is_same_v) { - return IOUAmount(STAmount::cMaxValue, STAmount::cMaxOffset); + return IOUAmount(STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET); } else if constexpr (std::is_same_v) { - return XRPAmount(static_cast(STAmount::cMaxNativeN)); + return XRPAmount(static_cast(STAmount::kMAX_NATIVE_N)); } else if constexpr (std::is_same_v) { - return MPTAmount(maxMPTokenAmount); + return MPTAmount(kMAX_MP_TOKEN_AMOUNT); } else if constexpr (std::is_same_v) { return asset.visit( [](Issue const& issue) { if (isXRP(issue)) - return STAmount(issue, static_cast(STAmount::cMaxNativeN)); - return STAmount(issue, STAmount::cMaxValue, STAmount::cMaxOffset); + return STAmount(issue, static_cast(STAmount::kMAX_NATIVE_N)); + return STAmount(issue, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET); }, - [](MPTIssue const& issue) { return STAmount(issue, maxMPTokenAmount); }); + [](MPTIssue const& issue) { return STAmount(issue, kMAX_MP_TOKEN_AMOUNT); }); } else { - constexpr bool alwaysFalse = !std::is_same_v; - static_assert(alwaysFalse, "Unsupported type for toMaxAmount"); + constexpr bool kALWAYS_FALSE = !std::is_same_v; + static_assert(kALWAYS_FALSE, "Unsupported type for toMaxAmount"); } } inline STAmount -toSTAmount(Asset const& asset, Number const& n, Number::rounding_mode mode = Number::getround()) +toSTAmount(Asset const& asset, Number const& n, Number::RoundingMode mode = Number::getround()) { return toAmount(asset, n, mode); } @@ -233,8 +233,8 @@ getAsset(T const& amt) } else { - constexpr bool alwaysFalse = !std::is_same_v; - static_assert(alwaysFalse, "Unsupported type for getIssue"); + constexpr bool kALWAYS_FALSE = !std::is_same_v; + static_assert(kALWAYS_FALSE, "Unsupported type for getIssue"); } } @@ -260,8 +260,8 @@ get(STAmount const& a) } else { - constexpr bool alwaysFalse = !std::is_same_v; - static_assert(alwaysFalse, "Unsupported type for get"); + constexpr bool kALWAYS_FALSE = !std::is_same_v; + static_assert(kALWAYS_FALSE, "Unsupported type for get"); } } diff --git a/include/xrpl/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h index 653b4830bf..3399152363 100644 --- a/include/xrpl/protocol/ApiVersion.h +++ b/include/xrpl/protocol/ApiVersion.h @@ -35,49 +35,49 @@ namespace xrpl { namespace RPC { template -constexpr static std::integral_constant apiVersion = {}; +constexpr static std::integral_constant kAPI_VERSION = {}; -constexpr static auto apiInvalidVersion = apiVersion<0>; -constexpr static auto apiMinimumSupportedVersion = apiVersion<1>; -constexpr static auto apiMaximumSupportedVersion = apiVersion<2>; -constexpr static auto apiVersionIfUnspecified = apiVersion<1>; -constexpr static auto apiCommandLineVersion = apiVersion<1>; // TODO Bump to 2 later -constexpr static auto apiBetaVersion = apiVersion<3>; -constexpr static auto apiMaximumValidVersion = apiBetaVersion; +constexpr static auto kAPI_INVALID_VERSION = kAPI_VERSION<0>; +constexpr static auto kAPI_MINIMUM_SUPPORTED_VERSION = kAPI_VERSION<1>; +constexpr static auto kAPI_MAXIMUM_SUPPORTED_VERSION = kAPI_VERSION<2>; +constexpr static auto kAPI_VERSION_IF_UNSPECIFIED = kAPI_VERSION<1>; +constexpr static auto kAPI_COMMAND_LINE_VERSION = kAPI_VERSION<1>; // TODO Bump to 2 later +constexpr static auto kAPI_BETA_VERSION = kAPI_VERSION<3>; +constexpr static auto kAPI_MAXIMUM_VALID_VERSION = kAPI_BETA_VERSION; -static_assert(apiInvalidVersion < apiMinimumSupportedVersion); +static_assert(kAPI_INVALID_VERSION < kAPI_MINIMUM_SUPPORTED_VERSION); static_assert( - apiVersionIfUnspecified >= apiMinimumSupportedVersion && - apiVersionIfUnspecified <= apiMaximumSupportedVersion); + kAPI_VERSION_IF_UNSPECIFIED >= kAPI_MINIMUM_SUPPORTED_VERSION && + kAPI_VERSION_IF_UNSPECIFIED <= kAPI_MAXIMUM_SUPPORTED_VERSION); static_assert( - apiCommandLineVersion >= apiMinimumSupportedVersion && - apiCommandLineVersion <= apiMaximumSupportedVersion); -static_assert(apiMaximumSupportedVersion >= apiMinimumSupportedVersion); -static_assert(apiBetaVersion >= apiMaximumSupportedVersion); -static_assert(apiMaximumValidVersion >= apiMaximumSupportedVersion); + kAPI_COMMAND_LINE_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION && + kAPI_COMMAND_LINE_VERSION <= kAPI_MAXIMUM_SUPPORTED_VERSION); +static_assert(kAPI_MAXIMUM_SUPPORTED_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION); +static_assert(kAPI_BETA_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION); +static_assert(kAPI_MAXIMUM_VALID_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION); inline void -setVersion(Json::Value& parent, unsigned int apiVersion, bool betaEnabled) +setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled) { - XRPL_ASSERT(apiVersion != apiInvalidVersion, "xrpl::RPC::setVersion : input is valid"); + XRPL_ASSERT(apiVersion != kAPI_INVALID_VERSION, "xrpl::RPC::setVersion : input is valid"); - auto& retObj = parent[jss::version] = Json::objectValue; + auto& retObj = parent[jss::version] = json::ObjectValue; - if (apiVersion == apiVersionIfUnspecified) + if (apiVersion == kAPI_VERSION_IF_UNSPECIFIED) { // API version numbers used in API version 1 - static beast::SemanticVersion const firstVersion{"1.0.0"}; - static beast::SemanticVersion const goodVersion{"1.0.0"}; - static beast::SemanticVersion const lastVersion{"1.0.0"}; + static beast::SemanticVersion const kFIRST_VERSION{"1.0.0"}; + static beast::SemanticVersion const kGOOD_VERSION{"1.0.0"}; + static beast::SemanticVersion const kLAST_VERSION{"1.0.0"}; - retObj[jss::first] = firstVersion.print(); - retObj[jss::good] = goodVersion.print(); - retObj[jss::last] = lastVersion.print(); + retObj[jss::first] = kFIRST_VERSION.print(); + retObj[jss::good] = kGOOD_VERSION.print(); + retObj[jss::last] = kLAST_VERSION.print(); } else { - retObj[jss::first] = apiMinimumSupportedVersion.value; - retObj[jss::last] = betaEnabled ? apiBetaVersion : apiMaximumSupportedVersion; + retObj[jss::first] = kAPI_MINIMUM_SUPPORTED_VERSION.value; + retObj[jss::last] = betaEnabled ? kAPI_BETA_VERSION : kAPI_MAXIMUM_SUPPORTED_VERSION; } } @@ -96,11 +96,11 @@ setVersion(Json::Value& parent, unsigned int apiVersion, bool betaEnabled) * @return the api version number */ inline unsigned int -getAPIVersionNumber(Json::Value const& jv, bool betaEnabled) +getAPIVersionNumber(json::Value const& jv, bool betaEnabled) { - static Json::Value const minVersion(RPC::apiMinimumSupportedVersion); - Json::Value const maxVersion( - betaEnabled ? RPC::apiBetaVersion : RPC::apiMaximumSupportedVersion); + static json::Value const kMIN_VERSION(RPC::kAPI_MINIMUM_SUPPORTED_VERSION); + json::Value const maxVersion( + betaEnabled ? RPC::kAPI_BETA_VERSION : RPC::kAPI_MAXIMUM_SUPPORTED_VERSION); if (jv.isObject()) { @@ -109,52 +109,52 @@ getAPIVersionNumber(Json::Value const& jv, bool betaEnabled) auto const specifiedVersion = jv[jss::api_version]; if (!specifiedVersion.isInt() && !specifiedVersion.isUInt()) { - return RPC::apiInvalidVersion; + return RPC::kAPI_INVALID_VERSION; } auto const specifiedVersionInt = specifiedVersion.asInt(); - if (specifiedVersionInt < minVersion || specifiedVersionInt > maxVersion) + if (specifiedVersionInt < kMIN_VERSION || specifiedVersionInt > maxVersion) { - return RPC::apiInvalidVersion; + return RPC::kAPI_INVALID_VERSION; } return specifiedVersionInt; } } - return RPC::apiVersionIfUnspecified; + return RPC::kAPI_VERSION_IF_UNSPECIFIED; } } // namespace RPC -template +template void forApiVersions(Fn const& fn, Args&&... args) - requires // - (maxVer >= minVer) && // - (minVer >= RPC::apiMinimumSupportedVersion) && // - (RPC::apiMaximumValidVersion >= maxVer) && requires { - fn(std::integral_constant{}, std::forward(args)...); - fn(std::integral_constant{}, std::forward(args)...); + requires // + (MaxVer >= MinVer) && // + (MinVer >= RPC::kAPI_MINIMUM_SUPPORTED_VERSION) && // + (RPC::kAPI_MAXIMUM_VALID_VERSION >= MaxVer) && requires { + fn(std::integral_constant{}, std::forward(args)...); + fn(std::integral_constant{}, std::forward(args)...); } { - constexpr auto size = maxVer + 1 - minVer; - [&](std::index_sequence) { + constexpr auto kSIZE = MaxVer + 1 - MinVer; + [&](std::index_sequence) { // NOLINTBEGIN(bugprone-use-after-move) (((void)fn( - std::integral_constant{}, std::forward(args)...)), + std::integral_constant{}, std::forward(args)...)), ...); // NOLINTEND(bugprone-use-after-move) - }(std::make_index_sequence{}); + }(std::make_index_sequence{}); } template void forAllApiVersions(Fn const& fn, Args&&... args) requires requires { - forApiVersions( + forApiVersions( fn, std::forward(args)...); } { - forApiVersions( + forApiVersions( fn, std::forward(args)...); } diff --git a/include/xrpl/protocol/Asset.h b/include/xrpl/protocol/Asset.h index 920e62f2c4..e0f4aa08a2 100644 --- a/include/xrpl/protocol/Asset.h +++ b/include/xrpl/protocol/Asset.h @@ -30,8 +30,8 @@ struct BadAsset inline BadAsset const& badAsset() { - static BadAsset const a; - return a; + static BadAsset const kA; + return kA; } /* Asset is an abstraction of three different issue types: XRP, IOU, MPT. @@ -93,7 +93,7 @@ public: token() const; void - setJson(Json::Value& jv) const; + setJson(json::Value& jv) const; STAmount operator()(Number const&) const; @@ -148,15 +148,15 @@ public: }; template -constexpr bool is_issue_v = std::is_same_v; +constexpr bool kIS_ISSUE_V = std::is_same_v; template -constexpr bool is_mptissue_v = std::is_same_v; +constexpr bool kIS_MPTISSUE_V = std::is_same_v; -inline Json::Value -to_json(Asset const& asset) +inline json::Value +toJson(Asset const& asset) { - Json::Value jv; + json::Value jv; asset.setJson(jv); return jv; } @@ -205,13 +205,13 @@ Asset::getAmountType() const { return visit( [&](Issue const& issue) -> Asset::AmtType { - constexpr AmountType xrp; - constexpr AmountType iou; - return native() ? AmtType(xrp) : AmtType(iou); + constexpr AmountType kXRP; + constexpr AmountType kIOU; + return native() ? AmtType(kXRP) : AmtType(kIOU); }, [&](MPTIssue const& issue) -> Asset::AmtType { - constexpr AmountType mpt; - return AmtType(mpt); + constexpr AmountType kMPT; + return AmtType(kMPT); }); } @@ -237,12 +237,12 @@ constexpr std::weak_ordering operator<=>(Asset const& lhs, Asset const& rhs) { return std::visit( - [](TLhs const& lhs_, TRhs const& rhs_) { + [](TLhs const& lhs, TRhs const& rhs) { if constexpr (std::is_same_v) { - return std::weak_ordering(lhs_ <=> rhs_); + return std::weak_ordering(lhs <=> rhs); } - else if constexpr (is_issue_v && is_mptissue_v) + else if constexpr (kIS_ISSUE_V && kIS_MPTISSUE_V) { return std::weak_ordering::greater; } @@ -303,10 +303,10 @@ std::string to_string(Asset const& asset); bool -validJSONAsset(Json::Value const& jv); +validJSONAsset(json::Value const& jv); Asset -assetFromJson(Json::Value const& jv); +assetFromJson(json::Value const& jv); inline bool isConsistent(Asset const& asset) diff --git a/include/xrpl/protocol/Batch.h b/include/xrpl/protocol/Batch.h index 91fb8e5a9d..fa7641af70 100644 --- a/include/xrpl/protocol/Batch.h +++ b/include/xrpl/protocol/Batch.h @@ -7,7 +7,7 @@ namespace xrpl { inline void serializeBatch(Serializer& msg, std::uint32_t const& flags, std::vector const& txids) { - msg.add32(HashPrefix::batch); + msg.add32(HashPrefix::Batch); msg.add32(flags); msg.add32(std::uint32_t(txids.size())); for (auto const& txid : txids) diff --git a/include/xrpl/protocol/Book.h b/include/xrpl/protocol/Book.h index cda4daf603..fc36abddc4 100644 --- a/include/xrpl/protocol/Book.h +++ b/include/xrpl/protocol/Book.h @@ -21,8 +21,8 @@ public: Book() = default; - Book(Asset const& in_, Asset const& out_, std::optional const& domain_) - : in(in_), out(out_), domain(domain_) + Book(Asset const& in, Asset const& out, std::optional const& domain) + : in(in), out(out), domain(domain) { } }; @@ -140,8 +140,8 @@ private: using issue_hasher = std::hash; using mptissue_hasher = std::hash; - issue_hasher m_issue_hasher; - mptissue_hasher m_mptissue_hasher; + issue_hasher m_issue_hasher_; + mptissue_hasher m_mptissue_hasher_; public: explicit hash() = default; @@ -151,11 +151,11 @@ public: { return asset.visit( [&](xrpl::Issue const& issue) { - value_type const result(m_issue_hasher(issue)); + value_type const result(m_issue_hasher_(issue)); return result; }, [&](xrpl::MPTIssue const& issue) { - value_type const result(m_mptissue_hasher(issue)); + value_type const result(m_mptissue_hasher_(issue)); return result; }); } @@ -170,8 +170,8 @@ private: using asset_hasher = std::hash; using uint256_hasher = xrpl::uint256::hasher; - asset_hasher m_asset_hasher; - uint256_hasher m_uint256_hasher; + asset_hasher issue_hasher_; + uint256_hasher uint256_hasher_; public: hash() = default; @@ -182,11 +182,11 @@ public: value_type operator()(argument_type const& value) const { - value_type result(m_asset_hasher(value.in)); - boost::hash_combine(result, m_asset_hasher(value.out)); + value_type result(issue_hasher_(value.in)); + boost::hash_combine(result, issue_hasher_(value.out)); if (value.domain) - boost::hash_combine(result, m_uint256_hasher(*value.domain)); + boost::hash_combine(result, uint256_hasher_(*value.domain)); return result; } diff --git a/include/xrpl/protocol/Concepts.h b/include/xrpl/protocol/Concepts.h index 5f2eb3c7c8..e909aff805 100644 --- a/include/xrpl/protocol/Concepts.h +++ b/include/xrpl/protocol/Concepts.h @@ -59,7 +59,7 @@ struct CombineVisitors : Ts... // robust than class template argument deduction (CTAD) via the deduction guide. template constexpr CombineVisitors...> -make_combine_visitors(Ts&&... ts) +makeCombineVisitors(Ts&&... ts) { // std::decay_t is used to remove references/constness from the lambda // types before they are passed as template arguments to the CombineVisitors @@ -74,11 +74,11 @@ constexpr auto visit(Variant&& v, Visitors&&... visitors) -> decltype(auto) { // Use the function template helper instead of raw CTAD. - auto visitor_set = make_combine_visitors(std::forward(visitors)...); + auto visitorSet = makeCombineVisitors(std::forward(visitors)...); // Delegate to std::visit, perfectly forwarding the variant and the visitor // set. - return std::visit(visitor_set, std::forward(v)); + return std::visit(visitorSet, std::forward(v)); } } // namespace detail diff --git a/include/xrpl/protocol/ErrorCodes.h b/include/xrpl/protocol/ErrorCodes.h index ed7f898312..a91adfc55a 100644 --- a/include/xrpl/protocol/ErrorCodes.h +++ b/include/xrpl/protocol/ErrorCodes.h @@ -19,131 +19,131 @@ namespace xrpl { // or repurpose error code values. // Protocol-wide, 50+ files // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) -enum error_code_i { +enum ErrorCodeI { // -1 represents codes not listed in this enumeration - rpcUNKNOWN = -1, + RpcUnknown = -1, - rpcSUCCESS = 0, + RpcSuccess = 0, - rpcBAD_SYNTAX = 1, - rpcJSON_RPC = 2, - rpcFORBIDDEN = 3, + RpcBadSyntax = 1, + RpcJsonRpc = 2, + RpcForbidden = 3, - rpcWRONG_NETWORK = 4, + RpcWrongNetwork = 4, // Misc failure // unused 5, - rpcNO_PERMISSION = 6, - rpcNO_EVENTS = 7, + RpcNoPermission = 6, + RpcNoEvents = 7, // unused 8, - rpcTOO_BUSY = 9, - rpcSLOW_DOWN = 10, - rpcHIGH_FEE = 11, - rpcNOT_ENABLED = 12, - rpcNOT_READY = 13, - rpcAMENDMENT_BLOCKED = 14, + RpcTooBusy = 9, + RpcSlowDown = 10, + RpcHighFee = 11, + RpcNotEnabled = 12, + RpcNotReady = 13, + RpcAmendmentBlocked = 14, // Networking - rpcNO_CLOSED = 15, - rpcNO_CURRENT = 16, - rpcNO_NETWORK = 17, - rpcNOT_SYNCED = 18, + RpcNoClosed = 15, + RpcNoCurrent = 16, + RpcNoNetwork = 17, + RpcNotSynced = 18, // Ledger state - rpcACT_NOT_FOUND = 19, + RpcActNotFound = 19, // unused 20, - rpcLGR_NOT_FOUND = 21, - rpcLGR_NOT_VALIDATED = 22, - rpcMASTER_DISABLED = 23, + RpcLgrNotFound = 21, + RpcLgrNotValidated = 22, + RpcMasterDisabled = 23, // unused 24, // unused 25, // unused 26, // unused 27, // unused 28, - rpcTXN_NOT_FOUND = 29, - rpcINVALID_HOTWALLET = 30, + RpcTxnNotFound = 29, + RpcInvalidHotwallet = 30, // Malformed command - rpcINVALID_PARAMS = 31, - rpcUNKNOWN_COMMAND = 32, - rpcNO_PF_REQUEST = 33, + RpcInvalidParams = 31, + RpcUnknownCommand = 32, + RpcNoPfRequest = 33, // Bad parameter // NOT USED DO NOT USE AGAIN rpcACT_BITCOIN = 34, - rpcACT_MALFORMED = 35, - rpcALREADY_MULTISIG = 36, - rpcALREADY_SINGLE_SIG = 37, + RpcActMalformed = 35, + RpcAlreadyMultisig = 36, + RpcAlreadySingleSig = 37, // unused 38, // unused 39, - rpcBAD_FEATURE = 40, - rpcBAD_ISSUER = 41, - rpcBAD_MARKET = 42, - rpcBAD_SECRET = 43, - rpcBAD_SEED = 44, - rpcCHANNEL_MALFORMED = 45, - rpcCHANNEL_AMT_MALFORMED = 46, - rpcCOMMAND_MISSING = 47, - rpcDST_ACT_MALFORMED = 48, - rpcDST_ACT_MISSING = 49, - rpcDST_ACT_NOT_FOUND = 50, - rpcDST_AMT_MALFORMED = 51, - rpcDST_AMT_MISSING = 52, - rpcDST_ISR_MALFORMED = 53, + RpcBadFeature = 40, + RpcBadIssuer = 41, + RpcBadMarket = 42, + RpcBadSecret = 43, + RpcBadSeed = 44, + RpcChannelMalformed = 45, + RpcChannelAmtMalformed = 46, + RpcCommandMissing = 47, + RpcDstActMalformed = 48, + RpcDstActMissing = 49, + RpcDstActNotFound = 50, + RpcDstAmtMalformed = 51, + RpcDstAmtMissing = 52, + RpcDstIsrMalformed = 53, // unused 54, // unused 55, // unused 56, - rpcLGR_IDXS_INVALID = 57, - rpcLGR_IDX_MALFORMED = 58, + RpcLgrIdxsInvalid = 57, + RpcLgrIdxMalformed = 58, // unused 59, // unused 60, // unused 61, - rpcPUBLIC_MALFORMED = 62, - rpcSIGNING_MALFORMED = 63, - rpcSENDMAX_MALFORMED = 64, - rpcSRC_ACT_MALFORMED = 65, - rpcSRC_ACT_MISSING = 66, - rpcSRC_ACT_NOT_FOUND = 67, - rpcDELEGATE_ACT_NOT_FOUND = 68, - rpcSRC_CUR_MALFORMED = 69, - rpcSRC_ISR_MALFORMED = 70, - rpcSTREAM_MALFORMED = 71, - rpcATX_DEPRECATED = 72, + RpcPublicMalformed = 62, + RpcSigningMalformed = 63, + RpcSendmaxMalformed = 64, + RpcSrcActMalformed = 65, + RpcSrcActMissing = 66, + RpcSrcActNotFound = 67, + RpcDelegateActNotFound = 68, + RpcSrcCurMalformed = 69, + RpcSrcIsrMalformed = 70, + RpcStreamMalformed = 71, + RpcAtxDeprecated = 72, // Internal error (should never happen) - rpcINTERNAL = 73, // Generic internal error. - rpcNOT_IMPL = 74, - rpcNOT_SUPPORTED = 75, - rpcBAD_KEY_TYPE = 76, - rpcDB_DESERIALIZATION = 77, - rpcEXCESSIVE_LGR_RANGE = 78, - rpcINVALID_LGR_RANGE = 79, - rpcEXPIRED_VALIDATOR_LIST = 80, + RpcInternal = 73, // Generic internal error. + RpcNotImpl = 74, + RpcNotSupported = 75, + RpcBadKeyType = 76, + RpcDbDeserialization = 77, + RpcExcessiveLgrRange = 78, + RpcInvalidLgrRange = 79, + RpcExpiredValidatorList = 80, // unused = 90, // DEPRECATED. New code must not use this value. - rpcREPORTING_UNSUPPORTED = 91, + RpcReportingUnsupported = 91, - rpcOBJECT_NOT_FOUND = 92, + RpcObjectNotFound = 92, // AMM - rpcISSUE_MALFORMED = 93, + RpcIssueMalformed = 93, // Oracle - rpcORACLE_MALFORMED = 94, + RpcOracleMalformed = 94, // deposit_authorized + credentials - rpcBAD_CREDENTIALS = 95, + RpcBadCredentials = 95, // Simulate - rpcTX_SIGNED = 96, + RpcTxSigned = 96, // Pathfinding - rpcDOMAIN_MALFORMED = 97, + RpcDomainMalformed = 97, // ledger_entry - rpcENTRY_NOT_FOUND = 98, - rpcUNEXPECTED_LEDGER_TYPE = 99, + RpcEntryNotFound = 98, + RpcUnexpectedLedgerType = 99, - rpcLAST = rpcUNEXPECTED_LEDGER_TYPE // rpcLAST should always equal the last code. + RpcLast = RpcUnexpectedLedgerType // rpcLAST should always equal the last code. }; /** Codes returned in the `warnings` array of certain RPC commands. @@ -152,13 +152,13 @@ enum error_code_i { */ // Protocol-wide, 50+ files // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) -enum warning_code_i { - warnRPC_UNSUPPORTED_MAJORITY = 1001, - warnRPC_AMENDMENT_BLOCKED = 1002, - warnRPC_EXPIRED_VALIDATOR_LIST = 1003, +enum WarningCodeI { + WarnRpcUnsupportedMajority = 1001, + WarnRpcAmendmentBlocked = 1002, + WarnRpcExpiredValidatorList = 1003, // unused = 1004 - warnRPC_FIELDS_DEPRECATED = 2004, // xrpld needs to maintain - // compatibility with Clio on this code. + WarnRpcFieldsDeprecated = 2004, // xrpld needs to maintain + // compatibility with Clio on this code. }; //------------------------------------------------------------------------------ @@ -172,163 +172,159 @@ struct ErrorInfo { // Default ctor needed to produce an empty std::array during constexpr eval. constexpr ErrorInfo() - : code(rpcUNKNOWN), token("unknown"), message("An unknown error code."), http_status(200) + : code(RpcUnknown), token("unknown"), message("An unknown error code."), http_status(200) { } - constexpr ErrorInfo(error_code_i code_, char const* token_, char const* message_) - : code(code_), token(token_), message(message_), http_status(200) + constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message) + : code(code), token(token), message(message), http_status(200) { } - constexpr ErrorInfo( - error_code_i code_, - char const* token_, - char const* message_, - int http_status_) - : code(code_), token(token_), message(message_), http_status(http_status_) + constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message, int httpStatus) + : code(code), token(token), message(message), http_status(httpStatus) { } - error_code_i code; - Json::StaticString token; - Json::StaticString message; + ErrorCodeI code; + json::StaticString token; + json::StaticString message; int http_status; }; /** Returns an ErrorInfo that reflects the error code. */ ErrorInfo const& -get_error_info(error_code_i code); +getErrorInfo(ErrorCodeI code); /** Add or update the json update to reflect the error code. */ /** @{ */ void -inject_error(error_code_i code, Json::Value& json); +injectError(ErrorCodeI code, json::Value& json); void -inject_error(error_code_i code, std::string const& message, Json::Value& json); +injectError(ErrorCodeI code, std::string const& message, json::Value& json); /** @} */ /** Returns a new json object that reflects the error code. */ /** @{ */ -Json::Value -make_error(error_code_i code); -Json::Value -make_error(error_code_i code, std::string const& message); +json::Value +makeError(ErrorCodeI code); +json::Value +makeError(ErrorCodeI code, std::string const& message); /** @} */ /** Returns a new json object that indicates invalid parameters. */ /** @{ */ -inline Json::Value -make_param_error(std::string const& message) +inline json::Value +makeParamError(std::string const& message) { - return make_error(rpcINVALID_PARAMS, message); + return makeError(RpcInvalidParams, message); } inline std::string -missing_field_message(std::string const& name) +missingFieldMessage(std::string const& name) { return "Missing field '" + name + "'."; } -inline Json::Value -missing_field_error(std::string const& name) +inline json::Value +missingFieldError(std::string const& name) { - return make_param_error(missing_field_message(name)); + return makeParamError(missingFieldMessage(name)); } -inline Json::Value -missing_field_error(Json::StaticString name) +inline json::Value +missingFieldError(json::StaticString name) { - return missing_field_error(std::string(name)); + return missingFieldError(std::string(name)); } inline std::string -object_field_message(std::string const& name) +objectFieldMessage(std::string const& name) { return "Invalid field '" + name + "', not object."; } -inline Json::Value -object_field_error(std::string const& name) +inline json::Value +objectFieldError(std::string const& name) { - return make_param_error(object_field_message(name)); + return makeParamError(objectFieldMessage(name)); } -inline Json::Value -object_field_error(Json::StaticString name) +inline json::Value +objectFieldError(json::StaticString name) { - return object_field_error(std::string(name)); + return objectFieldError(std::string(name)); } inline std::string -invalid_field_message(std::string const& name) +invalidFieldMessage(std::string const& name) { return "Invalid field '" + name + "'."; } inline std::string -invalid_field_message(Json::StaticString name) +invalidFieldMessage(json::StaticString name) { - return invalid_field_message(std::string(name)); + return invalidFieldMessage(std::string(name)); } -inline Json::Value -invalid_field_error(std::string const& name) +inline json::Value +invalidFieldError(std::string const& name) { - return make_param_error(invalid_field_message(name)); + return makeParamError(invalidFieldMessage(name)); } -inline Json::Value -invalid_field_error(Json::StaticString name) +inline json::Value +invalidFieldError(json::StaticString name) { - return invalid_field_error(std::string(name)); + return invalidFieldError(std::string(name)); } inline std::string -expected_field_message(std::string const& name, std::string const& type) +expectedFieldMessage(std::string const& name, std::string const& type) { return "Invalid field '" + name + "', not " + type + "."; } inline std::string -expected_field_message(Json::StaticString name, std::string const& type) +expectedFieldMessage(json::StaticString name, std::string const& type) { - return expected_field_message(std::string(name), type); + return expectedFieldMessage(std::string(name), type); } -inline Json::Value -expected_field_error(std::string const& name, std::string const& type) +inline json::Value +expectedFieldError(std::string const& name, std::string const& type) { - return make_param_error(expected_field_message(name, type)); + return makeParamError(expectedFieldMessage(name, type)); } -inline Json::Value -expected_field_error(Json::StaticString name, std::string const& type) +inline json::Value +expectedFieldError(json::StaticString name, std::string const& type) { - return expected_field_error(std::string(name), type); + return expectedFieldError(std::string(name), type); } -inline Json::Value -not_validator_error() +inline json::Value +notValidatorError() { - return make_param_error("not a validator"); + return makeParamError("not a validator"); } /** @} */ /** Returns `true` if the json contains an rpc error specification. */ bool -contains_error(Json::Value const& json); +containsError(json::Value const& json); /** Returns http status that corresponds to the error code. */ int -error_code_http_status(error_code_i code); +errorCodeHttpStatus(ErrorCodeI code); } // namespace RPC /** Returns a single string with the contents of an RPC error. */ std::string -rpcErrorString(Json::Value const& jv); +rpcErrorString(json::Value const& jv); } // namespace xrpl diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 8f96935ca1..281e598bf7 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -65,11 +65,11 @@ namespace xrpl { // Feature names must not exceed this length (in characters, excluding the null terminator). -static constexpr std::size_t maxFeatureNameSize = 63; +static constexpr std::size_t kMAX_FEATURE_NAME_SIZE = 63; // Reserve this exact feature-name length (in characters/bytes, excluding the null terminator) // so that a 32-byte uint256 (for example, in WASM or other interop contexts) can be used // as a compact, fixed-size feature selector without conflicting with human-readable names. -static constexpr std::size_t reservedFeatureNameSize = 32; +static constexpr std::size_t kRESERVED_FEATURE_NAME_SIZE = 32; // Both validFeatureNameSize and validFeatureName are consteval functions that can be used in // static_asserts to validate feature names at compile time. They are only used inside @@ -79,27 +79,27 @@ static constexpr std::size_t reservedFeatureNameSize = 32; consteval auto validFeatureNameSize(auto fn) -> bool { - constexpr char const* n = fn(); + constexpr char const* kN = fn(); // Note, std::strlen is not constexpr, we need to implement our own here. - constexpr std::size_t N = [](auto n) { + constexpr std::size_t kLEN = [](auto n) { std::size_t ret = 0; for (auto ptr = n; *ptr != '\0'; ret++, ++ptr) ; return ret; - }(n); - return N != reservedFeatureNameSize && // - N <= maxFeatureNameSize; + }(kN); + return kLEN != kRESERVED_FEATURE_NAME_SIZE && // + kLEN <= kMAX_FEATURE_NAME_SIZE; } consteval auto validFeatureName(auto fn) -> bool { - constexpr char const* n = fn(); + constexpr char const* kN = fn(); // Prevent the use of visually confusable characters and enforce that feature names // are always valid ASCII. This is needed because C++ allows Unicode identifiers. // Characters below 0x20 are nonprintable control characters, and characters with the 0x80 bit // set are non-ASCII (e.g. UTF-8 encoding of Unicode), so both are disallowed. - for (auto ptr = n; *ptr != '\0'; ++ptr) + for (auto ptr = kN; *ptr != '\0'; ++ptr) { if (*ptr & 0x80 || *ptr < 0x20) return false; @@ -136,7 +136,7 @@ namespace detail { // Feature.cpp. Because it's only used to reserve storage, and determine how // large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than // the actual number of amendments. A LogicError on startup will verify this. -static constexpr std::size_t numFeatures = +static constexpr std::size_t kNUM_FEATURES = (0 + #include ); @@ -184,9 +184,9 @@ bitsetIndexToFeature(size_t i); std::string featureToName(uint256 const& f); -class FeatureBitset : private std::bitset +class FeatureBitset : private std::bitset { - using base = std::bitset; + using base = std::bitset; template void diff --git a/include/xrpl/protocol/Fees.h b/include/xrpl/protocol/Fees.h index 6c398735ad..c94ba31b8a 100644 --- a/include/xrpl/protocol/Fees.h +++ b/include/xrpl/protocol/Fees.h @@ -6,7 +6,7 @@ namespace xrpl { // Deprecated constant for backwards compatibility with pre-XRPFees amendment. // This was the reference fee units used in the old fee calculation. -inline constexpr std::uint32_t FEE_UNITS_DEPRECATED = 10; +inline constexpr std::uint32_t kFEE_UNITS_DEPRECATED = 10; /** Reflects the fee settings for a particular ledger. @@ -29,8 +29,8 @@ struct Fees Fees& operator=(Fees const&) = default; - Fees(XRPAmount base_, XRPAmount reserve_, XRPAmount increment_) - : base(base_), reserve(reserve_), increment(increment_) + Fees(XRPAmount base, XRPAmount reserve, XRPAmount increment) + : base(base), reserve(reserve), increment(increment) { } diff --git a/include/xrpl/protocol/HashPrefix.h b/include/xrpl/protocol/HashPrefix.h index 305b4bfd49..1b05d450a1 100644 --- a/include/xrpl/protocol/HashPrefix.h +++ b/include/xrpl/protocol/HashPrefix.h @@ -9,7 +9,7 @@ namespace xrpl { namespace detail { constexpr std::uint32_t -make_hash_prefix(char a, char b, char c) +makeHashPrefix(char a, char b, char c) { return (static_cast(a) << 24) + (static_cast(b) << 16) + (static_cast(c) << 8); @@ -33,40 +33,40 @@ make_hash_prefix(char a, char b, char c) */ enum class HashPrefix : std::uint32_t { /** transaction plus signature to give transaction ID */ - transactionID = detail::make_hash_prefix('T', 'X', 'N'), + TransactionId = detail::makeHashPrefix('T', 'X', 'N'), /** transaction plus metadata */ - txNode = detail::make_hash_prefix('S', 'N', 'D'), + TxNode = detail::makeHashPrefix('S', 'N', 'D'), /** account state */ - leafNode = detail::make_hash_prefix('M', 'L', 'N'), + LeafNode = detail::makeHashPrefix('M', 'L', 'N'), /** inner node in V1 tree */ - innerNode = detail::make_hash_prefix('M', 'I', 'N'), + InnerNode = detail::makeHashPrefix('M', 'I', 'N'), /** ledger master data for signing */ - ledgerMaster = detail::make_hash_prefix('L', 'W', 'R'), + LedgerMaster = detail::makeHashPrefix('L', 'W', 'R'), /** inner transaction to sign */ - txSign = detail::make_hash_prefix('S', 'T', 'X'), + TxSign = detail::makeHashPrefix('S', 'T', 'X'), /** inner transaction to multi-sign */ - txMultiSign = detail::make_hash_prefix('S', 'M', 'T'), + TxMultiSign = detail::makeHashPrefix('S', 'M', 'T'), /** validation for signing */ - validation = detail::make_hash_prefix('V', 'A', 'L'), + Validation = detail::makeHashPrefix('V', 'A', 'L'), /** proposal for signing */ - proposal = detail::make_hash_prefix('P', 'R', 'P'), + Proposal = detail::makeHashPrefix('P', 'R', 'P'), /** Manifest */ - manifest = detail::make_hash_prefix('M', 'A', 'N'), + Manifest = detail::makeHashPrefix('M', 'A', 'N'), /** Payment Channel Claim */ - paymentChannelClaim = detail::make_hash_prefix('C', 'L', 'M'), + PaymentChannelClaim = detail::makeHashPrefix('C', 'L', 'M'), /** Batch */ - batch = detail::make_hash_prefix('B', 'C', 'H'), + Batch = detail::makeHashPrefix('B', 'C', 'H'), }; template diff --git a/include/xrpl/protocol/IOUAmount.h b/include/xrpl/protocol/IOUAmount.h index 1654a357f1..6ce773fabd 100644 --- a/include/xrpl/protocol/IOUAmount.h +++ b/include/xrpl/protocol/IOUAmount.h @@ -92,7 +92,7 @@ public: inline IOUAmount::IOUAmount(beast::Zero) { - *this = beast::zero; + *this = beast::kZERO; } inline IOUAmount::IOUAmount(mantissa_type mantissa, exponent_type exponent) diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index f4dd5e6816..14e7d95e23 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -75,14 +75,14 @@ Keylet const& negativeUNL() noexcept; /** The beginning of an order book */ -struct book_t +struct BookT { - explicit book_t() = default; + explicit BookT() = default; Keylet operator()(Book const& b) const; }; -static book_t const book{}; +static BookT const kBOOK{}; /** The index of a trust line for a given currency @@ -119,19 +119,19 @@ Keylet quality(Keylet const& k, std::uint64_t q) noexcept; /** The directory for the next lower quality */ -struct next_t +struct NextT { - explicit next_t() = default; + explicit NextT() = default; Keylet operator()(Keylet const& k) const; }; -static next_t const next{}; +static NextT const kNEXT{}; /** A ticket belonging to an account */ -struct ticket_t +struct TicketT { - explicit ticket_t() = default; + explicit TicketT() = default; Keylet operator()(AccountID const& id, std::uint32_t ticketSeq) const; @@ -145,7 +145,7 @@ struct ticket_t return {ltTICKET, key}; } }; -static ticket_t const ticket{}; +static TicketT const kTICKET{}; /** A SignerList */ Keylet @@ -221,11 +221,11 @@ payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept; /** @{ */ /** A keylet for the owner's first possible NFT page. */ Keylet -nftpage_min(AccountID const& owner); +nftpageMin(AccountID const& owner); /** A keylet for the owner's last possible NFT page. */ Keylet -nftpage_max(AccountID const& owner); +nftpageMax(AccountID const& owner); Keylet nftpage(Keylet const& k, uint256 const& token); @@ -243,11 +243,11 @@ nftoffer(uint256 const& offer) /** The directory of buy offers for the specified NFT */ Keylet -nft_buys(uint256 const& id) noexcept; +nftBuys(uint256 const& id) noexcept; /** The directory of sell offers for the specified NFT */ Keylet -nft_sells(uint256 const& id) noexcept; +nftSells(uint256 const& id) noexcept; /** AMM entry */ Keylet @@ -362,25 +362,25 @@ getTicketIndex(AccountID const& account, std::uint32_t uSequence); uint256 getTicketIndex(AccountID const& account, SeqProxy ticketSeq); -template +template // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) -struct keyletDesc +struct KeyletDesc { - std::function function; - Json::StaticString expectedLEName; + std::function function; + json::StaticString expectedLEName; bool includeInTests{}; }; // This list should include all of the keylet functions that take a single // AccountID parameter. -std::array, 6> const directAccountKeylets{ +std::array, 6> const kDIRECT_ACCOUNT_KEYLETS{ {{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false}, {.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true}, {.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true}, // It's normally impossible to create an item at nftpage_min, but // test it anyway, since the invariant checks for it. - {.function = &keylet::nftpage_min, .expectedLEName = jss::NFTokenPage, .includeInTests = true}, - {.function = &keylet::nftpage_max, .expectedLEName = jss::NFTokenPage, .includeInTests = true}, + {.function = &keylet::nftpageMin, .expectedLEName = jss::NFTokenPage, .includeInTests = true}, + {.function = &keylet::nftpageMax, .expectedLEName = jss::NFTokenPage, .includeInTests = true}, {.function = &keylet::did, .expectedLEName = jss::DID, .includeInTests = true}}}; MPTID diff --git a/include/xrpl/protocol/Issue.h b/include/xrpl/protocol/Issue.h index fa9c4ebd1f..3b74b9132a 100644 --- a/include/xrpl/protocol/Issue.h +++ b/include/xrpl/protocol/Issue.h @@ -31,7 +31,7 @@ public: getText() const; void - setJson(Json::Value& jv) const; + setJson(json::Value& jv) const; [[nodiscard]] bool native() const; @@ -49,11 +49,11 @@ isConsistent(Issue const& ac); std::string to_string(Issue const& ac); -Json::Value -to_json(Issue const& is); +json::Value +toJson(Issue const& is); Issue -issueFromJson(Json::Value const& v); +issueFromJson(json::Value const& v); std::ostream& operator<<(std::ostream& os, Issue const& x); @@ -96,16 +96,16 @@ operator<=>(Issue const& lhs, Issue const& rhs) inline Issue const& xrpIssue() { - static Issue const issue{xrpCurrency(), xrpAccount()}; - return issue; + static Issue const kISSUE{xrpCurrency(), xrpAccount()}; + return kISSUE; } /** Returns an asset specifier that represents no account and currency. */ inline Issue const& noIssue() { - static Issue const issue{noCurrency(), noAccount()}; - return issue; + static Issue const kISSUE{noCurrency(), noAccount()}; + return kISSUE; } inline bool diff --git a/include/xrpl/protocol/KeyType.h b/include/xrpl/protocol/KeyType.h index d05e421e4b..c709eb897a 100644 --- a/include/xrpl/protocol/KeyType.h +++ b/include/xrpl/protocol/KeyType.h @@ -6,18 +6,18 @@ namespace xrpl { enum class KeyType { - secp256k1 = 0, - ed25519 = 1, + Secp256k1 = 0, + Ed25519 = 1, }; inline std::optional keyTypeFromString(std::string const& s) { if (s == "secp256k1") - return KeyType::secp256k1; + return KeyType::Secp256k1; if (s == "ed25519") - return KeyType::ed25519; + return KeyType::Ed25519; return {}; } @@ -25,10 +25,10 @@ keyTypeFromString(std::string const& s) inline char const* to_string(KeyType type) { - if (type == KeyType::secp256k1) + if (type == KeyType::Secp256k1) return "secp256k1"; - if (type == KeyType::ed25519) + if (type == KeyType::Ed25519) return "ed25519"; return "INVALID"; diff --git a/include/xrpl/protocol/Keylet.h b/include/xrpl/protocol/Keylet.h index 6795516795..19704e2a11 100644 --- a/include/xrpl/protocol/Keylet.h +++ b/include/xrpl/protocol/Keylet.h @@ -20,7 +20,7 @@ struct Keylet uint256 key; LedgerEntryType type; - Keylet(LedgerEntryType type_, uint256 const& key_) : key(key_), type(type_) + Keylet(LedgerEntryType type, uint256 const& key) : key(key), type(type) { } diff --git a/include/xrpl/protocol/KnownFormats.h b/include/xrpl/protocol/KnownFormats.h index 12d900572f..9aa914ba97 100644 --- a/include/xrpl/protocol/KnownFormats.h +++ b/include/xrpl/protocol/KnownFormats.h @@ -75,7 +75,7 @@ public: Derived classes will load the object with all the known formats. */ private: - KnownFormats() : name_(beast::type_name()) + KnownFormats() : name_(beast::typeName()) { } @@ -159,7 +159,7 @@ protected: { if (auto const item = findByType(type)) { - LogicError( + logicError( std::string("Duplicate key for item '") + name + "': already maps to " + item->getName()); } diff --git a/include/xrpl/protocol/LedgerFormats.h b/include/xrpl/protocol/LedgerFormats.h index 77ef9fcf1d..99d5d818f1 100644 --- a/include/xrpl/protocol/LedgerFormats.h +++ b/include/xrpl/protocol/LedgerFormats.h @@ -1,5 +1,7 @@ #pragma once +// NOLINTBEGIN(readability-identifier-naming) + #include #include @@ -298,3 +300,5 @@ public: }; } // namespace xrpl + +// NOLINTEND(readability-identifier-naming) diff --git a/include/xrpl/protocol/LedgerHeader.h b/include/xrpl/protocol/LedgerHeader.h index 1035e5e892..68dd5e24b9 100644 --- a/include/xrpl/protocol/LedgerHeader.h +++ b/include/xrpl/protocol/LedgerHeader.h @@ -26,12 +26,12 @@ struct LedgerHeader // // Closed means "tx set already determined" - uint256 hash = beast::zero; - uint256 txHash = beast::zero; - uint256 accountHash = beast::zero; - uint256 parentHash = beast::zero; + uint256 hash = beast::kZERO; + uint256 txHash = beast::kZERO; + uint256 accountHash = beast::kZERO; + uint256 parentHash = beast::kZERO; - XRPAmount drops = beast::zero; + XRPAmount drops = beast::kZERO; // If validated is false, it means "not yet validated." // Once validated is true, it will never be set false at a later time. @@ -53,12 +53,12 @@ struct LedgerHeader }; // ledger close flags -static std::uint32_t const sLCF_NoConsensusTime = 0x01; +static std::uint32_t const kS_LCF_NO_CONSENSUS_TIME = 0x01; inline bool getCloseAgree(LedgerHeader const& info) { - return (info.closeFlags & sLCF_NoConsensusTime) == 0; + return (info.closeFlags & kS_LCF_NO_CONSENSUS_TIME) == 0; } void diff --git a/include/xrpl/protocol/MPTAmount.h b/include/xrpl/protocol/MPTAmount.h index 9d0e0901bf..b4907774d2 100644 --- a/include/xrpl/protocol/MPTAmount.h +++ b/include/xrpl/protocol/MPTAmount.h @@ -88,7 +88,7 @@ constexpr MPTAmount::MPTAmount(value_type value) : value_(value) constexpr MPTAmount::MPTAmount(beast::Zero) { - *this = beast::zero; + *this = beast::kZERO; } constexpr MPTAmount& diff --git a/include/xrpl/protocol/MPTIssue.h b/include/xrpl/protocol/MPTIssue.h index c467382f07..f55029f50d 100644 --- a/include/xrpl/protocol/MPTIssue.h +++ b/include/xrpl/protocol/MPTIssue.h @@ -39,7 +39,7 @@ public: getText() const; void - setJson(Json::Value& jv) const; + setJson(json::Value& jv) const; friend constexpr bool operator==(MPTIssue const& lhs, MPTIssue const& rhs); @@ -102,15 +102,15 @@ getMPTIssuer(MPTID&&) = delete; inline MPTID noMPT() { - static MPTIssue const mpt{0, noAccount()}; - return mpt.getMptID(); + static MPTIssue const kMPT{0, noAccount()}; + return kMPT.getMptID(); } inline MPTID badMPT() { - static MPTIssue const mpt{0, xrpAccount()}; - return mpt.getMptID(); + static MPTIssue const kMPT{0, xrpAccount()}; + return kMPT.getMptID(); } template @@ -121,14 +121,14 @@ hash_append(Hasher& h, MPTIssue const& r) hash_append(h, r.getMptID()); } -Json::Value -to_json(MPTIssue const& mptIssue); +json::Value +toJson(MPTIssue const& mptIssue); std::string to_string(MPTIssue const& mptIssue); MPTIssue -mptIssueFromJson(Json::Value const& jv); +mptIssueFromJson(json::Value const& jv); std::ostream& operator<<(std::ostream& os, MPTIssue const& x); diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 6b0c799a56..5a7dfcd731 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -15,16 +15,16 @@ namespace xrpl { namespace detail { template -constexpr bool is_integral_constant = false; +constexpr bool kIS_INTEGRAL_CONSTANT = false; template -constexpr bool is_integral_constant&> = true; +constexpr bool kIS_INTEGRAL_CONSTANT&> = true; template -constexpr bool is_integral_constant const&> = true; +constexpr bool kIS_INTEGRAL_CONSTANT const&> = true; template -concept some_integral_constant = detail::is_integral_constant; +concept some_integral_constant = detail::kIS_INTEGRAL_CONSTANT; -// This class is designed to wrap a collection of _almost_ identical Json::Value +// This class is designed to wrap a collection of _almost_ identical json::Value // objects, indexed by version (i.e. there is some mapping of version to object // index). It is used e.g. when we need to publish JSON data to users supporting // different API versions. We allow manipulation and inspection of all objects @@ -47,12 +47,12 @@ struct MultiApiJson return (v < MinVer) ? 0 : static_cast(v - MinVer); } - constexpr static std::size_t size = MaxVer + 1 - MinVer; - std::array val = {}; + constexpr static std::size_t kSIZE = MaxVer + 1 - MinVer; + std::array val = {}; - explicit MultiApiJson(Json::Value const& init = {}) + explicit MultiApiJson(json::Value const& init = {}) { - if (init == Json::Value{}) + if (init == json::Value{}) return; // All elements are already default-initialized for (auto& v : val) v = init; @@ -60,13 +60,13 @@ struct MultiApiJson void set(char const* key, auto const& v) - requires std::constructible_from + requires std::constructible_from { for (auto& a : this->val) a[key] = v; } - enum class IsMemberResult : int { none = 0, some, all }; + enum class IsMemberResult : int { None = 0, Some, All }; [[nodiscard]] IsMemberResult isMember(char const* key) const @@ -79,11 +79,11 @@ struct MultiApiJson } if (count == 0) - return IsMemberResult::none; - return count < size ? IsMemberResult::some : IsMemberResult::all; + return IsMemberResult::None; + return count < kSIZE ? IsMemberResult::Some : IsMemberResult::All; } - static constexpr struct visitor_t final + static constexpr struct VisitorT final { // integral_constant version, extra arguments template @@ -100,7 +100,7 @@ struct MultiApiJson std::integral_constant, Args&&...> { - static_assert(valid(Version) && index(Version) >= 0 && index(Version) < size); + static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE); return std::invoke(fn, json.val[index(Version)], version, std::forward(args)...); } @@ -111,7 +111,7 @@ struct MultiApiJson operator()(Json& json, std::integral_constant const, Fn fn) const -> std::invoke_result_t { - static_assert(valid(Version) && index(Version) >= 0 && index(Version) < size); + static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE); return std::invoke(fn, json.val[index(Version)]); } @@ -124,8 +124,8 @@ struct MultiApiJson -> std::invoke_result_t { XRPL_ASSERT( - valid(version) && index(version) >= 0 && index(version) < size, - "xrpl::detail::MultiApiJson::operator() : valid " + valid(version) && index(version) >= 0 && index(version) < kSIZE, + "xrpl::detail::MultiApijson::operator() : valid " "version"); return std::invoke(fn, json.val[index(version)], version, std::forward(args)...); } @@ -139,20 +139,20 @@ struct MultiApiJson -> std::invoke_result_t { XRPL_ASSERT( - valid(version) && index(version) >= 0 && index(version) < size, - "xrpl::detail::MultiApiJson::operator() : valid version"); + valid(version) && index(version) >= 0 && index(version) < kSIZE, + "xrpl::detail::MultiApijson::operator() : valid version"); return std::invoke(fn, json.val[index(version)]); } - } visitor = {}; + } kVISITOR = {}; auto visit() { return [self = this](auto... args) requires requires { - visitor(std::declval(), std::declval()...); + kVISITOR(std::declval(), std::declval()...); } - { return visitor(*self, std::forward(args)...); }; + { return kVISITOR(*self, std::forward(args)...); }; } [[nodiscard]] auto @@ -160,27 +160,27 @@ struct MultiApiJson { return [self = this](auto... args) requires requires { - visitor(std::declval(), std::declval()...); + kVISITOR(std::declval(), std::declval()...); } - { return visitor(*self, std::forward(args)...); }; + { return kVISITOR(*self, std::forward(args)...); }; } template auto - visit(Args... args) -> std::invoke_result_t + visit(Args... args) -> std::invoke_result_t requires(sizeof...(args) > 0) && - requires { visitor(*this, std::forward(args)...); } + requires { kVISITOR(*this, std::forward(args)...); } { - return visitor(*this, std::forward(args)...); + return kVISITOR(*this, std::forward(args)...); } template [[nodiscard]] auto - visit(Args... args) const -> std::invoke_result_t + visit(Args... args) const -> std::invoke_result_t requires(sizeof...(args) > 0) && - requires { visitor(*this, std::forward(args)...); } + requires { kVISITOR(*this, std::forward(args)...); } { - return visitor(*this, std::forward(args)...); + return kVISITOR(*this, std::forward(args)...); } }; @@ -188,6 +188,6 @@ struct MultiApiJson // Wrapper for Json for all supported API versions. using MultiApiJson = - detail::MultiApiJson; + detail::MultiApiJson; } // namespace xrpl diff --git a/include/xrpl/protocol/NFTSyntheticSerializer.h b/include/xrpl/protocol/NFTSyntheticSerializer.h index dcfd132ed8..a1d8bce985 100644 --- a/include/xrpl/protocol/NFTSyntheticSerializer.h +++ b/include/xrpl/protocol/NFTSyntheticSerializer.h @@ -14,7 +14,7 @@ namespace xrpl::RPC { @{ */ void -insertNFTSyntheticInJson(Json::Value&, std::shared_ptr const&, TxMeta const&); +insertNFTSyntheticInJson(json::Value&, std::shared_ptr const&, TxMeta const&); /** @} */ } // namespace xrpl::RPC diff --git a/include/xrpl/protocol/NFTokenID.h b/include/xrpl/protocol/NFTokenID.h index 4bdacc1095..f61c6bd5cb 100644 --- a/include/xrpl/protocol/NFTokenID.h +++ b/include/xrpl/protocol/NFTokenID.h @@ -30,7 +30,7 @@ getNFTokenIDFromDeletedOffer(TxMeta const& transactionMeta); void insertNFTokenID( - Json::Value& response, + json::Value& response, std::shared_ptr const& transaction, TxMeta const& transactionMeta); /** @} */ diff --git a/include/xrpl/protocol/NFTokenOfferID.h b/include/xrpl/protocol/NFTokenOfferID.h index 01b0ced638..c4a80356bf 100644 --- a/include/xrpl/protocol/NFTokenOfferID.h +++ b/include/xrpl/protocol/NFTokenOfferID.h @@ -27,7 +27,7 @@ getOfferIDFromCreatedOffer(TxMeta const& transactionMeta); void insertNFTokenOfferID( - Json::Value& response, + json::Value& response, std::shared_ptr const& transaction, TxMeta const& transactionMeta); /** @} */ diff --git a/include/xrpl/protocol/PathAsset.h b/include/xrpl/protocol/PathAsset.h index 67b78f2191..4c4a3f7af4 100644 --- a/include/xrpl/protocol/PathAsset.h +++ b/include/xrpl/protocol/PathAsset.h @@ -52,10 +52,10 @@ public: }; template -constexpr bool is_currency_v = std::is_same_v; +constexpr bool kIS_CURRENCY_V = std::is_same_v; template -constexpr bool is_mptid_v = std::is_same_v; +constexpr bool kIS_MPTID_V = std::is_same_v; inline PathAsset::PathAsset(Asset const& asset) { @@ -72,7 +72,7 @@ PathAsset::holds() const } template -T const& +[[nodiscard]] [[nodiscard]] T const& PathAsset::get() const { if (!holds()) @@ -98,10 +98,10 @@ constexpr bool operator==(PathAsset const& lhs, PathAsset const& rhs) { return std::visit( - [](TLhs const& lhs_, TRhs const& rhs_) { + [](TLhs const& lhs, TRhs const& rhs) { if constexpr (std::is_same_v) { - return lhs_ == rhs_; + return lhs == rhs; } else { diff --git a/include/xrpl/protocol/PayChan.h b/include/xrpl/protocol/PayChan.h index 0a1496ca8e..d8f4e0f527 100644 --- a/include/xrpl/protocol/PayChan.h +++ b/include/xrpl/protocol/PayChan.h @@ -10,7 +10,7 @@ namespace xrpl { inline void serializePayChanAuthorization(Serializer& msg, uint256 const& key, XRPAmount const& amt) { - msg.add32(HashPrefix::paymentChannelClaim); + msg.add32(HashPrefix::PaymentChannelClaim); msg.addBitString(key); msg.add64(amt.drops()); } diff --git a/include/xrpl/protocol/Permissions.h b/include/xrpl/protocol/Permissions.h index 3ce8918a16..5d56fa4461 100644 --- a/include/xrpl/protocol/Permissions.h +++ b/include/xrpl/protocol/Permissions.h @@ -33,7 +33,7 @@ enum GranularPermissionType : std::uint32_t { // Injected bare enumerators (xrpl::delegable / xrpl::notDelegable) are required by preprocessor // tricks in tests and macro-generated code; enum class would break that. // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) -enum Delegation { delegable, notDelegable }; +enum Delegation { Delegable, NotDelegable }; class Permission { diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index 0db7b217f0..50b2425016 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -19,40 +19,40 @@ namespace xrpl { @ingroup protocol */ /** Smallest legal byte size of a transaction. */ -std::size_t constexpr txMinSizeBytes = 32; +std::size_t constexpr kTX_MIN_SIZE_BYTES = 32; /** Largest legal byte size of a transaction. */ -std::size_t constexpr txMaxSizeBytes = megabytes(1); +std::size_t constexpr kTX_MAX_SIZE_BYTES = megabytes(1); /** The maximum number of unfunded offers to delete at once */ -std::size_t constexpr unfundedOfferRemoveLimit = 1000; +std::size_t constexpr kUNFUNDED_OFFER_REMOVE_LIMIT = 1000; /** The maximum number of expired offers to delete at once */ -std::size_t constexpr expiredOfferRemoveLimit = 256; +std::size_t constexpr kEXPIRED_OFFER_REMOVE_LIMIT = 256; /** The maximum number of metadata entries allowed in one transaction */ -std::size_t constexpr oversizeMetaDataCap = 5200; +std::size_t constexpr kOVERSIZE_META_DATA_CAP = 5200; /** The maximum number of entries per directory page */ -std::size_t constexpr dirNodeMaxEntries = 32; +std::size_t constexpr kDIR_NODE_MAX_ENTRIES = 32; /** The maximum number of pages allowed in a directory Made obsolete by fixDirectoryLimit amendment. */ -std::uint64_t constexpr dirNodeMaxPages = 262144; +std::uint64_t constexpr kDIR_NODE_MAX_PAGES = 262144; /** The maximum number of items in an NFT page */ -std::size_t constexpr dirMaxTokensPerPage = 32; +std::size_t constexpr kDIR_MAX_TOKENS_PER_PAGE = 32; /** The maximum number of owner directory entries for account to be deletable */ -std::size_t constexpr maxDeletableDirEntries = 1000; +std::size_t constexpr kMAX_DELETABLE_DIR_ENTRIES = 1000; /** The maximum number of token offers that can be canceled at once */ -std::size_t constexpr maxTokenOfferCancelCount = 500; +std::size_t constexpr kMAX_TOKEN_OFFER_CANCEL_COUNT = 500; /** The maximum number of offers in an offer directory for NFT to be burnable */ -std::size_t constexpr maxDeletableTokenOfferEntries = 500; +std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500; /** The maximum token transfer fee allowed. @@ -63,7 +63,7 @@ std::size_t constexpr maxDeletableTokenOfferEntries = 500; Note that for extremely low transfer fees values, it is possible that the calculated fee will be 0. */ -std::uint16_t constexpr maxTransferFee = 50000; +std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000; /** There are 10,000 basis points (bips) in 100%. * @@ -81,32 +81,32 @@ std::uint16_t constexpr maxTransferFee = 50000; * * Example: 50% is 0.50 * bipsPerUnity = 5,000 bps. */ -Bips32 constexpr bipsPerUnity(100 * 100); -static_assert(bipsPerUnity == Bips32{10'000}); -TenthBips32 constexpr tenthBipsPerUnity(bipsPerUnity.value() * 10); -static_assert(tenthBipsPerUnity == TenthBips32(100'000)); +Bips32 constexpr kBIPS_PER_UNITY(100 * 100); +static_assert(kBIPS_PER_UNITY == Bips32{10'000}); +TenthBips32 constexpr kTENTH_BIPS_PER_UNITY(kBIPS_PER_UNITY.value() * 10); +static_assert(kTENTH_BIPS_PER_UNITY == TenthBips32(100'000)); constexpr Bips32 percentageToBips(std::uint32_t percentage) { - return Bips32(percentage * bipsPerUnity.value() / 100); + return Bips32(percentage * kBIPS_PER_UNITY.value() / 100); } constexpr TenthBips32 percentageToTenthBips(std::uint32_t percentage) { - return TenthBips32(percentage * tenthBipsPerUnity.value() / 100); + return TenthBips32(percentage * kTENTH_BIPS_PER_UNITY.value() / 100); } template constexpr T bipsOfValue(T value, Bips bips) { - return value * bips.value() / bipsPerUnity.value(); + return value * bips.value() / kBIPS_PER_UNITY.value(); } template constexpr T tenthBipsOfValue(T value, TenthBips bips) { - return value * bips.value() / tenthBipsPerUnity.value(); + return value * bips.value() / kTENTH_BIPS_PER_UNITY.value(); } namespace Lending { @@ -114,54 +114,54 @@ namespace Lending { Valid values are between 0 and 10% inclusive. */ -TenthBips16 constexpr maxManagementFeeRate( - unsafe_cast(percentageToTenthBips(10).value())); -static_assert(maxManagementFeeRate == TenthBips16(std::uint16_t(10'000u))); +TenthBips16 constexpr kMAX_MANAGEMENT_FEE_RATE( + unsafeCast(percentageToTenthBips(10).value())); +static_assert(kMAX_MANAGEMENT_FEE_RATE == TenthBips16(std::uint16_t(10'000u))); /** The maximum coverage rate required of a loan broker in 1/10 bips. Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxCoverRate = percentageToTenthBips(100); -static_assert(maxCoverRate == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_COVER_RATE = percentageToTenthBips(100); +static_assert(kMAX_COVER_RATE == TenthBips32(100'000u)); /** The maximum overpayment fee on a loan in 1/10 bips. * Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxOverpaymentFee = percentageToTenthBips(100); -static_assert(maxOverpaymentFee == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_OVERPAYMENT_FEE = percentageToTenthBips(100); +static_assert(kMAX_OVERPAYMENT_FEE == TenthBips32(100'000u)); /** Annualized interest rate of the Loan in 1/10 bips. * * Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxInterestRate = percentageToTenthBips(100); -static_assert(maxInterestRate == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_INTEREST_RATE = percentageToTenthBips(100); +static_assert(kMAX_INTEREST_RATE == TenthBips32(100'000u)); /** The maximum premium added to the interest rate for late payments on a loan * in 1/10 bips. * * Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxLateInterestRate = percentageToTenthBips(100); -static_assert(maxLateInterestRate == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_LATE_INTEREST_RATE = percentageToTenthBips(100); +static_assert(kMAX_LATE_INTEREST_RATE == TenthBips32(100'000u)); /** The maximum close interest rate charged for repaying a loan early in 1/10 * bips. * * Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxCloseInterestRate = percentageToTenthBips(100); -static_assert(maxCloseInterestRate == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_CLOSE_INTEREST_RATE = percentageToTenthBips(100); +static_assert(kMAX_CLOSE_INTEREST_RATE == TenthBips32(100'000u)); /** The maximum overpayment interest rate charged on loan overpayments in 1/10 * bips. * * Valid values are between 0 and 100% inclusive. */ -TenthBips32 constexpr maxOverpaymentInterestRate = percentageToTenthBips(100); -static_assert(maxOverpaymentInterestRate == TenthBips32(100'000u)); +TenthBips32 constexpr kMAX_OVERPAYMENT_INTEREST_RATE = percentageToTenthBips(100); +static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u)); /** LoanPay transaction cost will be one base fee per X combined payments * @@ -172,7 +172,7 @@ static_assert(maxOverpaymentInterestRate == TenthBips32(100'000u)); * This number was chosen arbitrarily, but should not be changed once released * without an amendment */ -static constexpr int loanPaymentsPerFeeIncrement = 5; +static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5; /** Maximum number of combined payments that a LoanPay transaction will process * @@ -196,65 +196,65 @@ static constexpr int loanPaymentsPerFeeIncrement = 5; * This number was chosen arbitrarily, but should not be changed once released * without an amendment */ -static constexpr int loanMaximumPaymentsPerTransaction = 100; +static constexpr int kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION = 100; } // namespace Lending /** The maximum length of a URI inside an NFT */ -std::size_t constexpr maxTokenURILength = 256; +std::size_t constexpr kMAX_TOKEN_URI_LENGTH = 256; /** The maximum length of a Data element inside a DID */ -std::size_t constexpr maxDIDDocumentLength = 256; +std::size_t constexpr kMAX_DID_DOCUMENT_LENGTH = 256; /** The maximum length of a URI inside a DID */ -std::size_t constexpr maxDIDURILength = 256; +std::size_t constexpr kMAX_DIDURI_LENGTH = 256; /** The maximum length of an Attestation inside a DID */ -std::size_t constexpr maxDIDDataLength = 256; +std::size_t constexpr kMAX_DID_DATA_LENGTH = 256; /** The maximum length of a domain */ -std::size_t constexpr maxDomainLength = 256; +std::size_t constexpr kMAX_DOMAIN_LENGTH = 256; /** The maximum length of a URI inside a Credential */ -std::size_t constexpr maxCredentialURILength = 256; +std::size_t constexpr kMAX_CREDENTIAL_URI_LENGTH = 256; /** The maximum length of a CredentialType inside a Credential */ -std::size_t constexpr maxCredentialTypeLength = 64; +std::size_t constexpr kMAX_CREDENTIAL_TYPE_LENGTH = 64; /** The maximum number of credentials can be passed in array */ -std::size_t constexpr maxCredentialsArraySize = 8; +std::size_t constexpr kMAX_CREDENTIALS_ARRAY_SIZE = 8; /** The maximum number of credentials can be passed in array for permissioned * domain */ -std::size_t constexpr maxPermissionedDomainCredentialsArraySize = 10; +std::size_t constexpr kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE = 10; /** The maximum length of MPTokenMetadata */ -std::size_t constexpr maxMPTokenMetadataLength = 1024; +std::size_t constexpr kMAX_MP_TOKEN_METADATA_LENGTH = 1024; /** The maximum amount of MPTokenIssuance */ -std::uint64_t constexpr maxMPTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull; -static_assert(Number::maxRep >= maxMPTokenAmount); +std::uint64_t constexpr kMAX_MP_TOKEN_AMOUNT = 0x7FFF'FFFF'FFFF'FFFFull; +static_assert(Number::kMAX_REP >= kMAX_MP_TOKEN_AMOUNT); /** The maximum length of Data payload */ -std::size_t constexpr maxDataPayloadLength = 256; +std::size_t constexpr kMAX_DATA_PAYLOAD_LENGTH = 256; /** Vault withdrawal policies */ -std::uint8_t constexpr vaultStrategyFirstComeFirstServe = 1; +std::uint8_t constexpr kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE = 1; /** Default IOU scale factor for a Vault */ -std::uint8_t constexpr vaultDefaultIOUScale = 6; +std::uint8_t constexpr kVAULT_DEFAULT_IOU_SCALE = 6; /** Maximum scale factor for a Vault. The number is chosen to ensure that 1 IOU can be always converted to shares. 10^19 > maxMPTokenAmount (2^64-1) > 10^18 */ -std::uint8_t constexpr vaultMaximumIOUScale = 18; +std::uint8_t constexpr kVAULT_MAXIMUM_IOU_SCALE = 18; /** Maximum recursion depth for vault shares being put as an asset inside * another vault; counted from 0 */ -std::uint8_t constexpr maxAssetCheckDepth = 5; +std::uint8_t constexpr kMAX_ASSET_CHECK_DEPTH = 5; /** A ledger index. */ using LedgerIndex = std::uint32_t; -std::uint32_t constexpr FLAG_LEDGER_INTERVAL = 256; +std::uint32_t constexpr kFLAG_LEDGER_INTERVAL = 256; /** Returns true if the given ledgerIndex is a voting ledgerIndex */ bool @@ -273,38 +273,38 @@ using TxID = uint256; /** The maximum number of trustlines to delete as part of AMM account * deletion cleanup. */ -std::uint16_t constexpr maxDeletableAMMTrustLines = 512; +std::uint16_t constexpr kMAX_DELETABLE_AMM_TRUST_LINES = 512; /** The maximum length of a URI inside an Oracle */ -std::size_t constexpr maxOracleURI = 256; +std::size_t constexpr kMAX_ORACLE_URI = 256; /** The maximum length of a Provider inside an Oracle */ -std::size_t constexpr maxOracleProvider = 256; +std::size_t constexpr kMAX_ORACLE_PROVIDER = 256; /** The maximum size of a data series array inside an Oracle */ -std::size_t constexpr maxOracleDataSeries = 10; +std::size_t constexpr kMAX_ORACLE_DATA_SERIES = 10; /** The maximum length of a SymbolClass inside an Oracle */ -std::size_t constexpr maxOracleSymbolClass = 16; +std::size_t constexpr kMAX_ORACLE_SYMBOL_CLASS = 16; /** The maximum allowed time difference between lastUpdateTime and the time of the last closed ledger */ -std::size_t constexpr maxLastUpdateTimeDelta = 300; +std::size_t constexpr kMAX_LAST_UPDATE_TIME_DELTA = 300; /** The maximum price scaling factor */ -std::size_t constexpr maxPriceScale = 20; +std::size_t constexpr kMAX_PRICE_SCALE = 20; /** The maximum percentage of outliers to trim */ -std::size_t constexpr maxTrim = 25; +std::size_t constexpr kMAX_TRIM = 25; /** The maximum number of delegate permissions an account can grant */ -std::size_t constexpr permissionMaxSize = 10; +std::size_t constexpr kPERMISSION_MAX_SIZE = 10; /** The maximum number of transactions that can be in a batch. */ -std::size_t constexpr maxBatchTxCount = 8; +std::size_t constexpr kMAX_BATCH_TX_COUNT = 8; } // namespace xrpl diff --git a/include/xrpl/protocol/PublicKey.h b/include/xrpl/protocol/PublicKey.h index 9ec82dde97..75b898a71c 100644 --- a/include/xrpl/protocol/PublicKey.h +++ b/include/xrpl/protocol/PublicKey.h @@ -43,8 +43,8 @@ class PublicKey protected: // All the constructed public keys are valid, non-empty and contain 33 // bytes of data. - static constexpr std::size_t size_ = 33; - std::uint8_t buf_[size_]{}; // should be large enough + static constexpr std::size_t kSIZE = 33; + std::uint8_t buf_[kSIZE]{}; // should be large enough public: using const_iterator = std::uint8_t const*; @@ -72,7 +72,7 @@ public: static std::size_t size() noexcept { - return size_; + return kSIZE; } [[nodiscard]] const_iterator @@ -90,19 +90,19 @@ public: [[nodiscard]] const_iterator end() const noexcept { - return buf_ + size_; + return buf_ + kSIZE; } [[nodiscard]] const_iterator cend() const noexcept { - return buf_ + size_; + return buf_ + kSIZE; } [[nodiscard]] Slice slice() const noexcept { - return {buf_, size_}; + return {buf_, kSIZE}; } operator Slice() const noexcept @@ -168,7 +168,7 @@ template <> std::optional parseBase58(TokenType type, std::string const& s); -enum class ECDSACanonicality { canonical, fullyCanonical }; +enum class ECDSACanonicality { Canonical, FullyCanonical }; /** Determines the canonicality of a signature. @@ -260,10 +260,10 @@ getFingerprint( //------------------------------------------------------------------------------ -namespace Json { +namespace json { template <> inline xrpl::PublicKey -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; std::string const b58 = getOrThrow(v, field); @@ -279,4 +279,4 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) } Throw(field.getJsonName(), "PublicKey"); } -} // namespace Json +} // namespace json diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 2d4ea2f652..115e4498df 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -26,11 +26,11 @@ struct TAmounts { TAmounts() = default; - TAmounts(beast::Zero, beast::Zero) : in(beast::zero), out(beast::zero) + TAmounts(beast::Zero, beast::Zero) : in(beast::kZERO), out(beast::kZERO) { } - TAmounts(In in_, Out out_) : in(std::move(in_)), out(std::move(out_)) + TAmounts(In in, Out out) : in(std::move(in)), out(std::move(out)) { } @@ -38,7 +38,7 @@ struct TAmounts [[nodiscard]] bool empty() const noexcept { - return in <= beast::zero || out <= beast::zero; + return in <= beast::kZERO || out <= beast::kZERO; } TAmounts& @@ -94,15 +94,15 @@ public: // have lower unsigned integer representations. using value_type = std::uint64_t; - static int const minTickSize = 3; - static int const maxTickSize = 16; + static int const kMIN_TICK_SIZE = 3; + static int const kMAX_TICK_SIZE = 16; private: // This has the same representation as STAmount, see the comment on the // STAmount. However, this class does not always use the canonical // representation. In particular, the increment and decrement operators may // cause a non-canonical representation. - value_type m_value; + value_type value_; public: Quality() = default; @@ -148,7 +148,7 @@ public: [[nodiscard]] STAmount rate() const { - return amountFromQuality(m_value); + return amountFromQuality(value_); } /** Returns the quality rounded up to the specified number @@ -162,42 +162,42 @@ public: to prevent money creation. */ [[nodiscard]] Amounts - ceil_in(Amounts const& amount, STAmount const& limit) const; + ceilIn(Amounts const& amount, STAmount const& limit) const; template [[nodiscard]] TAmounts - ceil_in(TAmounts const& amount, In const& limit) const; + ceilIn(TAmounts const& amount, In const& limit) const; // Some of the underlying rounding functions called by ceil_in() ignored // low order bits that could influence rounding decisions. This "strict" // method uses underlying functions that pay attention to all the bits. [[nodiscard]] Amounts - ceil_in_strict(Amounts const& amount, STAmount const& limit, bool roundUp) const; + ceilInStrict(Amounts const& amount, STAmount const& limit, bool roundUp) const; template [[nodiscard]] TAmounts - ceil_in_strict(TAmounts const& amount, In const& limit, bool roundUp) const; + ceilInStrict(TAmounts const& amount, In const& limit, bool roundUp) const; /** Returns the scaled amount with out capped. Math is avoided if the result is exact. The input is clamped to prevent money creation. */ [[nodiscard]] Amounts - ceil_out(Amounts const& amount, STAmount const& limit) const; + ceilOut(Amounts const& amount, STAmount const& limit) const; template [[nodiscard]] TAmounts - ceil_out(TAmounts const& amount, Out const& limit) const; + ceilOut(TAmounts const& amount, Out const& limit) const; // Some of the underlying rounding functions called by ceil_out() ignored // low order bits that could influence rounding decisions. This "strict" // method uses underlying functions that pay attention to all the bits. [[nodiscard]] Amounts - ceil_out_strict(Amounts const& amount, STAmount const& limit, bool roundUp) const; + ceilOutStrict(Amounts const& amount, STAmount const& limit, bool roundUp) const; template [[nodiscard]] TAmounts - ceil_out_strict(TAmounts const& amount, Out const& limit, bool roundUp) const; + ceilOutStrict(TAmounts const& amount, Out const& limit, bool roundUp) const; private: // The ceil_in and ceil_out methods that deal in TAmount all convert @@ -205,11 +205,11 @@ private: // This helper function takes care of all the conversion operations. template ... Round> [[nodiscard]] TAmounts - ceil_TAmounts_helper( + ceilTAmountsHelper( TAmounts const& amount, Lim const& limit, - Lim const& limit_cmp, - FnPtr ceil_function, + Lim const& limitCmp, + FnPtr ceilFunction, Round... round) const; public: @@ -220,13 +220,13 @@ public: friend bool operator<(Quality const& lhs, Quality const& rhs) noexcept { - return lhs.m_value > rhs.m_value; + return lhs.value_ > rhs.value_; } friend bool operator>(Quality const& lhs, Quality const& rhs) noexcept { - return lhs.m_value < rhs.m_value; + return lhs.value_ < rhs.value_; } friend bool @@ -244,7 +244,7 @@ public: friend bool operator==(Quality const& lhs, Quality const& rhs) noexcept { - return lhs.m_value == rhs.m_value; + return lhs.value_ == rhs.value_; } friend bool @@ -256,7 +256,7 @@ public: friend std::ostream& operator<<(std::ostream& os, Quality const& quality) { - os << quality.m_value; + os << quality.value_; return os; } @@ -266,12 +266,12 @@ public: relativeDistance(Quality const& q1, Quality const& q2) { XRPL_ASSERT( - q1.m_value > 0 && q2.m_value > 0, "xrpl::Quality::relativeDistance : minimum inputs"); + q1.value_ > 0 && q2.value_ > 0, "xrpl::Quality::relativeDistance : minimum inputs"); - if (q1.m_value == q2.m_value) // make expected common case fast + if (q1.value_ == q2.value_) // make expected common case fast return 0; - auto const [minV, maxV] = std::minmax(q1.m_value, q2.m_value); + auto const [minV, maxV] = std::minmax(q1.value_, q2.value_); auto mantissa = [](std::uint64_t rate) { return rate & ~(255ull << (64 - 8)); }; auto exponent = [](std::uint64_t rate) { return static_cast(rate >> (64 - 8)) - 100; }; @@ -293,66 +293,66 @@ public: template ... Round> TAmounts -Quality::ceil_TAmounts_helper( +Quality::ceilTAmountsHelper( TAmounts const& amount, Lim const& limit, - Lim const& limit_cmp, - FnPtr ceil_function, + Lim const& limitCmp, + FnPtr ceilFunction, Round... roundUp) const { - if (limit_cmp <= limit) + if (limitCmp <= limit) return amount; // Use the existing STAmount implementation for now, but consider // replacing with code specific to IOUAMount and XRPAmount Amounts const stAmt(toSTAmount(amount.in), toSTAmount(amount.out)); STAmount const stLim(toSTAmount(limit)); - Amounts const stRes = ((*this).*ceil_function)(stAmt, stLim, roundUp...); + Amounts const stRes = ((*this).*ceilFunction)(stAmt, stLim, roundUp...); return TAmounts(toAmount(stRes.in), toAmount(stRes.out)); } template TAmounts -Quality::ceil_in(TAmounts const& amount, In const& limit) const +Quality::ceilIn(TAmounts const& amount, In const& limit) const { // Construct a function pointer to the function we want to call. - static constexpr Amounts (Quality::*ceil_in_fn_ptr)(Amounts const&, STAmount const&) const = - &Quality::ceil_in; + static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&) const = + &Quality::ceilIn; - return ceil_TAmounts_helper(amount, limit, amount.in, ceil_in_fn_ptr); + return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR); } template TAmounts -Quality::ceil_in_strict(TAmounts const& amount, In const& limit, bool roundUp) const +Quality::ceilInStrict(TAmounts const& amount, In const& limit, bool roundUp) const { // Construct a function pointer to the function we want to call. - static constexpr Amounts (Quality::*ceil_in_fn_ptr)(Amounts const&, STAmount const&, bool) - const = &Quality::ceil_in_strict; + static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&, bool) + const = &Quality::ceilInStrict; - return ceil_TAmounts_helper(amount, limit, amount.in, ceil_in_fn_ptr, roundUp); + return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR, roundUp); } template TAmounts -Quality::ceil_out(TAmounts const& amount, Out const& limit) const +Quality::ceilOut(TAmounts const& amount, Out const& limit) const { // Construct a function pointer to the function we want to call. - static constexpr Amounts (Quality::*ceil_out_fn_ptr)(Amounts const&, STAmount const&) const = - &Quality::ceil_out; + static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&) const = + &Quality::ceilOut; - return ceil_TAmounts_helper(amount, limit, amount.out, ceil_out_fn_ptr); + return ceil_TAmounts_helper(amount, limit, amount.out, kCEIL_OUT_FN_PTR); } template TAmounts -Quality::ceil_out_strict(TAmounts const& amount, Out const& limit, bool roundUp) const +Quality::ceilOutStrict(TAmounts const& amount, Out const& limit, bool roundUp) const { // Construct a function pointer to the function we want to call. - static constexpr Amounts (Quality::*ceil_out_fn_ptr)(Amounts const&, STAmount const&, bool) - const = &Quality::ceil_out_strict; + static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&, bool) + const = &Quality::ceilOutStrict; - return ceil_TAmounts_helper(amount, limit, amount.out, ceil_out_fn_ptr, roundUp); + return ceilTAmountsHelper(amount, limit, amount.out, kCEIL_OUT_FN_PTR, roundUp); } /** Calculate the quality of a two-hop path given the two hops. @@ -360,6 +360,6 @@ Quality::ceil_out_strict(TAmounts const& amount, Out const& limit, bool @param rhs The second leg of the path: intermediate to output. */ Quality -composed_quality(Quality const& lhs, Quality const& rhs); +composedQuality(Quality const& lhs, Quality const& rhs); } // namespace xrpl diff --git a/include/xrpl/protocol/QualityFunction.h b/include/xrpl/protocol/QualityFunction.h index 672c529c38..f7f92e50da 100644 --- a/include/xrpl/protocol/QualityFunction.h +++ b/include/xrpl/protocol/QualityFunction.h @@ -72,7 +72,7 @@ QualityFunction::QualityFunction( std::uint32_t tfee, QualityFunction::AMMTag) { - if (amounts.in <= beast::zero || amounts.out <= beast::zero) + if (amounts.in <= beast::kZERO || amounts.out <= beast::kZERO) Throw("QualityFunction amounts are 0."); Number const cfee = feeMult(tfee); m_ = -cfee / amounts.in; diff --git a/include/xrpl/protocol/RPCErr.h b/include/xrpl/protocol/RPCErr.h index e42bf5e637..1439146e0e 100644 --- a/include/xrpl/protocol/RPCErr.h +++ b/include/xrpl/protocol/RPCErr.h @@ -7,8 +7,8 @@ namespace xrpl { // VFALCO NOTE these are deprecated bool -isRpcError(Json::Value jvResult); -Json::Value -rpcError(error_code_i iError); +isRpcError(json::Value jvResult); +json::Value +rpcError(ErrorCodeI iError); } // namespace xrpl diff --git a/include/xrpl/protocol/Rate.h b/include/xrpl/protocol/Rate.h index e57d7e3a99..5dcd62a295 100644 --- a/include/xrpl/protocol/Rate.h +++ b/include/xrpl/protocol/Rate.h @@ -72,6 +72,6 @@ transferFeeAsRate(std::uint16_t fee); } // namespace nft /** A transfer rate signifying a 1:1 exchange */ -extern Rate const parityRate; +extern Rate const kPARITY_RATE; } // namespace xrpl diff --git a/include/xrpl/protocol/Rules.h b/include/xrpl/protocol/Rules.h index 604bb24700..fbbd3d8805 100644 --- a/include/xrpl/protocol/Rules.h +++ b/include/xrpl/protocol/Rules.h @@ -56,7 +56,7 @@ public: These are the rules reflected by the genesis ledger. */ - explicit Rules(std::unordered_set> const& presets); + explicit Rules(std::unordered_set> const& presets); private: // Allow a friend function to construct Rules. @@ -66,14 +66,14 @@ private: friend Rules makeRulesGivenLedger( DigestAwareReadView const& ledger, - std::unordered_set> const& presets); + std::unordered_set> const& presets); Rules( - std::unordered_set> const& presets, + std::unordered_set> const& presets, std::optional const& digest, STVector256 const& amendments); - [[nodiscard]] std::unordered_set> const& + [[nodiscard]] std::unordered_set> const& presets() const; public: diff --git a/include/xrpl/protocol/SField.h b/include/xrpl/protocol/SField.h index 784de5511e..45e4d8932e 100644 --- a/include/xrpl/protocol/SField.h +++ b/include/xrpl/protocol/SField.h @@ -34,6 +34,7 @@ class STXChainBridge; class STVector256; class STCurrency; +// NOLINTBEGIN(readability-identifier-naming) #pragma push_macro("XMACRO") #undef XMACRO @@ -91,7 +92,7 @@ class STCurrency; // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum SerializedTypeID { XMACRO(TO_ENUM) }; -static std::map const sTypeMap = {XMACRO(TO_MAP)}; +static std::map const kS_TYPE_MAP = {XMACRO(TO_MAP)}; #undef XMACRO #undef TO_ENUM @@ -99,17 +100,18 @@ static std::map const sTypeMap = {XMACRO(TO_MAP)}; #pragma pop_macro("XMACRO") #pragma pop_macro("TO_ENUM") #pragma pop_macro("TO_MAP") +// NOLINTEND(readability-identifier-naming) // constexpr inline int -field_code(SerializedTypeID id, int index) +fieldCode(SerializedTypeID id, int index) { - return (safe_cast(id) << 16) | index; + return (safeCast(id) << 16) | index; } // constexpr inline int -field_code(int id, int index) +fieldCode(int id, int index) { return (id << 16) | index; } @@ -130,32 +132,32 @@ public: // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum { - sMD_Never = 0x00, - sMD_ChangeOrig = 0x01, // original value when it changes - sMD_ChangeNew = 0x02, // new value when it changes - sMD_DeleteFinal = 0x04, // final value when it is deleted - sMD_Create = 0x08, // value when it's created - sMD_Always = 0x10, // value when node containing it is affected at all - sMD_BaseTen = 0x20, // value is treated as base 10, overriding behavior - sMD_PseudoAccount = 0x40, // if this field is set in an ACCOUNT_ROOT - // _only_, then it is a pseudo-account - sMD_NeedsAsset = 0x80, // This field needs to be associated with an - // asset before it is serialized as a ledger - // object. Intended for STNumber. - sMD_Default = sMD_ChangeOrig | sMD_ChangeNew | sMD_DeleteFinal | sMD_Create + SMdNever = 0x00, + SMdChangeOrig = 0x01, // original value when it changes + SMdChangeNew = 0x02, // new value when it changes + SMdDeleteFinal = 0x04, // final value when it is deleted + SMdCreate = 0x08, // value when it's created + SMdAlways = 0x10, // value when node containing it is affected at all + SMdBaseTen = 0x20, // value is treated as base 10, overriding behavior + SMdPseudoAccount = 0x40, // if this field is set in an ACCOUNT_ROOT + // _only_, then it is a pseudo-account + SMdNeedsAsset = 0x80, // This field needs to be associated with an + // asset before it is serialized as a ledger + // object. Intended for STNumber. + SMdDefault = SMdChangeOrig | SMdChangeNew | SMdDeleteFinal | SMdCreate }; - enum class IsSigning : unsigned char { no, yes }; - static IsSigning const notSigning = IsSigning::no; + enum class IsSigning : unsigned char { No, Yes }; + static IsSigning const kNOT_SIGNING = IsSigning::No; - int const fieldCode; // (type<<16)|index + int const fieldCodeMem; // (type<<16)|index // TODO: rename, clashes with function SerializedTypeID const fieldType; // STI_* int const fieldValue; // Code number for protocol std::string const fieldName; int const fieldMeta; int const fieldNum; IsSigning const signingField; - Json::StaticString const jsonName; + json::StaticString const jsonName; SField(SField const&) = delete; SField& @@ -165,17 +167,17 @@ public: operator=(SField&&) = delete; public: - struct private_access_tag_t; // public, but still an implementation detail + struct PrivateAccessTagT; // public, but still an implementation detail // These constructors can only be called from SField.cpp SField( - private_access_tag_t, + PrivateAccessTagT, SerializedTypeID tid, int fv, char const* fn, - int meta = sMD_Default, - IsSigning signing = IsSigning::yes); - explicit SField(private_access_tag_t, int fc, char const* fn); + int meta = SMdDefault, + IsSigning signing = IsSigning::Yes); + explicit SField(PrivateAccessTagT, int fc, char const* fn); static SField const& getField(int fieldCode); @@ -184,13 +186,13 @@ public: static SField const& getField(int type, int value) { - return getField(field_code(type, value)); + return getField(fieldCode(type, value)); } static SField const& getField(SerializedTypeID type, int value) { - return getField(field_code(type, value)); + return getField(fieldCode(type, value)); } [[nodiscard]] std::string const& @@ -202,16 +204,16 @@ public: [[nodiscard]] bool hasName() const { - return fieldCode > 0; + return fieldCodeMem > 0; } - [[nodiscard]] Json::StaticString const& + [[nodiscard]] json::StaticString const& getJsonName() const { return jsonName; } - operator Json::StaticString const&() const + operator json::StaticString const&() const { return jsonName; } @@ -219,13 +221,13 @@ public: [[nodiscard]] bool isInvalid() const { - return fieldCode == -1; + return fieldCodeMem == -1; } [[nodiscard]] bool isUseful() const { - return fieldCode > 0; + return fieldCodeMem > 0; } [[nodiscard]] bool @@ -247,7 +249,7 @@ public: [[nodiscard]] int getCode() const { - return fieldCode; + return fieldCodeMem; } [[nodiscard]] int getNum() const @@ -269,19 +271,19 @@ public: [[nodiscard]] bool shouldInclude(bool withSigningField) const { - return (fieldValue < 256) && (withSigningField || (signingField == IsSigning::yes)); + return (fieldValue < 256) && (withSigningField || (signingField == IsSigning::Yes)); } bool operator==(SField const& f) const { - return fieldCode == f.fieldCode; + return fieldCodeMem == f.fieldCodeMem; } bool operator!=(SField const& f) const { - return fieldCode != f.fieldCode; + return fieldCodeMem != f.fieldCodeMem; } static int @@ -306,7 +308,7 @@ struct TypedField : SField using type = T; template - explicit TypedField(private_access_tag_t pat, Args&&... args); + explicit TypedField(PrivateAccessTagT pat, Args&&... args); }; /** Indicate std::optional field semantics. */ @@ -315,7 +317,7 @@ struct OptionaledField { TypedField const* f; - explicit OptionaledField(TypedField const& f_) : f(&f_) + explicit OptionaledField(TypedField const& f) : f(&f) { } }; @@ -366,8 +368,8 @@ using SF_XCHAIN_BRIDGE = TypedField; #define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SField const sfName; #define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName; -extern SField const sfInvalid; -extern SField const sfGeneric; +extern SField const kSF_INVALID; +extern SField const kSF_GENERIC; #include diff --git a/include/xrpl/protocol/SOTemplate.h b/include/xrpl/protocol/SOTemplate.h index 3bfe07d049..72e0573d29 100644 --- a/include/xrpl/protocol/SOTemplate.h +++ b/include/xrpl/protocol/SOTemplate.h @@ -14,17 +14,18 @@ namespace xrpl { // 2026 usages, 129 files // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum SOEStyle { - soeINVALID = -1, - soeREQUIRED = 0, // required - soeOPTIONAL = 1, // optional, may be present with default value - soeDEFAULT = 2, // optional, if present, must not have default value + SoeInvalid = -1, + SoeRequired = 0, // required + SoeOptional = 1, // optional, may be present with default value + SoeDefault = 2, // optional, if present, must not have default value // inner object with the default fields has to be // constructed with STObject::makeInnerObject() }; // Part of a Python-parsed DSL (transactions.macro); bare enumerator names required by the parser +/** Amount fields that can support MPT */ // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) -enum SOETxMPTIssue { soeMPTNone, soeMPTSupported, soeMPTNotSupported }; +enum SOETxMPTIssue { SoeMptNone, SoeMptSupported, SoeMptNotSupported }; //------------------------------------------------------------------------------ @@ -34,7 +35,7 @@ class SOElement // Use std::reference_wrapper so SOElement can be stored in a std::vector. std::reference_wrapper sField_; SOEStyle style_; - SOETxMPTIssue supportMpt_ = soeMPTNone; + SOETxMPTIssue supportMpt_ = SoeMptNone; private: void @@ -60,7 +61,7 @@ public: SOElement( TypedField const& fieldName, SOEStyle style, - SOETxMPTIssue supportMpt = soeMPTNotSupported) + SOETxMPTIssue supportMpt = SoeMptNotSupported) : sField_(fieldName), style_(style), supportMpt_(supportMpt) { init(fieldName); diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index f681f811b7..7fa6ef88ae 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -34,39 +34,39 @@ public: using rep = std::pair; private: - Asset mAsset; - mantissa_type mValue{}; - exponent_type mOffset; - bool mIsNegative{}; + Asset asset_; + mantissa_type value_{}; + exponent_type offset_; + bool isNegative_{}; public: using value_type = STAmount; - constexpr static int cMinOffset = -96; - constexpr static int cMaxOffset = 80; + constexpr static int kMIN_OFFSET = -96; + constexpr static int kMAX_OFFSET = 80; // Maximum native value supported by the code - constexpr static std::uint64_t cMinValue = 1'000'000'000'000'000ull; - static_assert(isPowerOfTen(cMinValue)); - constexpr static std::uint64_t cMaxValue = (cMinValue * 10) - 1; - static_assert(cMaxValue == 9'999'999'999'999'999ull); - constexpr static std::uint64_t cMaxNative = 9'000'000'000'000'000'000ull; + constexpr static std::uint64_t kMIN_VALUE = 1'000'000'000'000'000ull; + static_assert(isPowerOfTen(kMIN_VALUE)); + constexpr static std::uint64_t kMAX_VALUE = (kMIN_VALUE * 10) - 1; + static_assert(kMAX_VALUE == 9'999'999'999'999'999ull); + constexpr static std::uint64_t kMAX_NATIVE = 9'000'000'000'000'000'000ull; // Max native value on network. - constexpr static std::uint64_t cMaxNativeN = 100'000'000'000'000'000ull; - constexpr static std::uint64_t cIssuedCurrency = 0x8'000'000'000'000'000ull; - constexpr static std::uint64_t cPositive = 0x4'000'000'000'000'000ull; - constexpr static std::uint64_t cMPToken = 0x2'000'000'000'000'000ull; - constexpr static std::uint64_t cValueMask = ~(cPositive | cMPToken); + constexpr static std::uint64_t kMAX_NATIVE_N = 100'000'000'000'000'000ull; + constexpr static std::uint64_t kISSUED_CURRENCY = 0x8'000'000'000'000'000ull; + constexpr static std::uint64_t kPOSITIVE = 0x4'000'000'000'000'000ull; + constexpr static std::uint64_t kMP_TOKEN = 0x2'000'000'000'000'000ull; + constexpr static std::uint64_t kVALUE_MASK = ~(kPOSITIVE | kMP_TOKEN); - static std::uint64_t const uRateOne; + static std::uint64_t const kU_RATE_ONE; //-------------------------------------------------------------------------- STAmount(SerialIter& sit, SField const& name); - struct unchecked + struct Unchecked { - explicit unchecked() = default; + explicit Unchecked() = default; }; // Do not call canonicalize @@ -77,7 +77,7 @@ public: mantissa_type mantissa, exponent_type exponent, bool negative, - unchecked); + Unchecked); template STAmount( @@ -85,7 +85,7 @@ public: mantissa_type mantissa, exponent_type exponent, bool negative, - unchecked); + Unchecked); // Call canonicalize template @@ -106,7 +106,7 @@ public: template STAmount(A const& asset, std::uint64_t mantissa = 0, int exponent = 0, bool negative = false) - : mAsset(asset), mValue(mantissa), mOffset(exponent), mIsNegative(negative) + : asset_(asset), value_(mantissa), offset_(exponent), isNegative_(negative) { canonicalize(); } @@ -179,7 +179,7 @@ public: zeroed() const; void - setJson(Json::Value&) const; + setJson(json::Value&) const; [[nodiscard]] STAmount const& value() const noexcept; @@ -241,7 +241,7 @@ public: [[nodiscard]] std::string getText() const override; - [[nodiscard]] Json::Value getJson(JsonOptions = JsonOptions::none) const override; + [[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override; void add(Serializer& s) const override; @@ -293,8 +293,8 @@ STAmount::STAmount( mantissa_type mantissa, exponent_type exponent, bool negative, - unchecked) - : STBase(name), mAsset(asset), mValue(mantissa), mOffset(exponent), mIsNegative(negative) + Unchecked) + : STBase(name), asset_(asset), value_(mantissa), offset_(exponent), isNegative_(negative) { } @@ -304,8 +304,8 @@ STAmount::STAmount( mantissa_type mantissa, exponent_type exponent, bool negative, - unchecked) - : mAsset(asset), mValue(mantissa), mOffset(exponent), mIsNegative(negative) + Unchecked) + : asset_(asset), value_(mantissa), offset_(exponent), isNegative_(negative) { } @@ -316,19 +316,19 @@ STAmount::STAmount( std::uint64_t mantissa, int exponent, bool negative) - : STBase(name), mAsset(asset), mValue(mantissa), mOffset(exponent), mIsNegative(negative) + : STBase(name), asset_(asset), value_(mantissa), offset_(exponent), isNegative_(negative) { - // mValue is uint64, but needs to fit in the range of int64 - if (Number::getMantissaScale() == MantissaRange::mantissa_scale::small) + // value_ is uint64, but needs to fit in the range of int64 + if (Number::getMantissaScale() == MantissaRange::MantissaScale::Small) { XRPL_ASSERT( - mValue <= std::numeric_limits::max(), + value_ <= std::numeric_limits::max(), "xrpl::STAmount::STAmount(SField, A, std::uint64_t, int, bool) : " "maximum mantissa input"); } else { - if (integral() && mValue > std::numeric_limits::max()) + if (integral() && value_ > std::numeric_limits::max()) throw std::overflow_error("STAmount mantissa is too large " + std::to_string(mantissa)); } canonicalize(); @@ -336,7 +336,7 @@ STAmount::STAmount( template STAmount::STAmount(A const& asset, std::int64_t mantissa, int exponent) - : mAsset(asset), mOffset(exponent) + : asset_(asset), offset_(exponent) { set(mantissa); canonicalize(); @@ -344,42 +344,42 @@ STAmount::STAmount(A const& asset, std::int64_t mantissa, int exponent) template STAmount::STAmount(A const& asset, std::uint32_t mantissa, int exponent, bool negative) - : STAmount(asset, safe_cast(mantissa), exponent, negative) + : STAmount(asset, safeCast(mantissa), exponent, negative) { } template STAmount::STAmount(A const& asset, int mantissa, int exponent) - : STAmount(asset, safe_cast(mantissa), exponent) + : STAmount(asset, safeCast(mantissa), exponent) { } // Legacy support for new-style amounts inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue) - : mAsset(issue), mOffset(amount.exponent()), mIsNegative(amount < beast::zero) + : asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZERO) { - if (mIsNegative) + if (isNegative_) { - mValue = unsafe_cast(-amount.mantissa()); + value_ = unsafeCast(-amount.mantissa()); } else { - mValue = unsafe_cast(amount.mantissa()); + value_ = unsafeCast(amount.mantissa()); } canonicalize(); } inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue) - : mAsset(mptIssue), mOffset(0), mIsNegative(amount < beast::zero) + : asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZERO) { - if (mIsNegative) + if (isNegative_) { - mValue = unsafe_cast(-amount.value()); + value_ = unsafeCast(-amount.value()); } else { - mValue = unsafe_cast(amount.value()); + value_ = unsafeCast(amount.value()); } canonicalize(); @@ -399,10 +399,10 @@ STAmount amountFromString(Asset const& asset, std::string const& amount); STAmount -amountFromJson(SField const& name, Json::Value const& v); +amountFromJson(SField const& name, json::Value const& v); bool -amountFromJsonNoThrow(STAmount& result, Json::Value const& jvSource); +amountFromJsonNoThrow(STAmount& result, json::Value const& jvSource); // IOUAmount and XRPAmount define toSTAmount, defining this // trivial conversion here makes writing generic code easier @@ -421,84 +421,84 @@ toSTAmount(STAmount const& a) inline int STAmount::exponent() const noexcept { - return mOffset; + return offset_; } inline bool STAmount::integral() const noexcept { - return mAsset.integral(); + return asset_.integral(); } inline bool STAmount::native() const noexcept { - return mAsset.native(); + return asset_.native(); } template constexpr bool STAmount::holds() const noexcept { - return mAsset.holds(); + return asset_.holds(); } inline bool STAmount::negative() const noexcept { - return mIsNegative; + return isNegative_; } inline std::uint64_t STAmount::mantissa() const noexcept { - return mValue; + return value_; } inline Asset const& STAmount::asset() const { - return mAsset; + return asset_; } template [[nodiscard]] constexpr TIss const& STAmount::get() const { - return mAsset.get(); + return asset_.get(); } template TIss& STAmount::get() { - return mAsset.get(); + return asset_.get(); } inline AccountID const& STAmount::getIssuer() const { - return mAsset.getIssuer(); + return asset_.getIssuer(); } inline int STAmount::signum() const noexcept { - if (mValue == 0u) + if (value_ == 0u) return 0; - return mIsNegative ? -1 : 1; + return isNegative_ ? -1 : 1; } inline STAmount STAmount::zeroed() const { - return STAmount(mAsset); + return STAmount(asset_); } inline STAmount:: operator bool() const noexcept { - return *this != beast::zero; + return *this != beast::kZERO; } inline STAmount:: @@ -540,7 +540,7 @@ STAmount::fromNumber(A const& a, Number const& number) return STAmount{asset, intValue, 0, negative}; } - auto const [mantissa, exponent] = working.normalizeToRange(cMinValue, cMaxValue); + auto const [mantissa, exponent] = working.normalizeToRange(kMIN_VALUE, kMAX_VALUE); return STAmount{asset, mantissa, exponent, negative}; } @@ -548,8 +548,8 @@ STAmount::fromNumber(A const& a, Number const& number) inline void STAmount::negate() { - if (*this != beast::zero) - mIsNegative = !mIsNegative; + if (*this != beast::kZERO) + isNegative_ = !isNegative_; } inline void @@ -557,9 +557,9 @@ STAmount::clear() { // The -100 is used to allow 0 to sort less than a small positive values // which have a negative exponent. - mOffset = integral() ? 0 : -100; - mValue = 0; - mIsNegative = false; + offset_ = integral() ? 0 : -100; + value_ = 0; + isNegative_ = false; } inline void @@ -578,7 +578,7 @@ STAmount::value() const noexcept inline bool isLegalNet(STAmount const& value) { - return !value.native() || (value.mantissa() <= STAmount::cMaxNativeN); + return !value.native() || (value.mantissa() <= STAmount::kMAX_NATIVE_N); } //------------------------------------------------------------------------------ @@ -674,7 +674,7 @@ getRate(STAmount const& offerOut, STAmount const& offerIn); roundToScale( STAmount const& value, std::int32_t scale, - Number::rounding_mode rounding = Number::getround()); + Number::RoundingMode rounding = Number::getround()); /** Round an arbitrary precision Number IN PLACE to the precision of a given * Asset. @@ -709,7 +709,7 @@ roundToAsset( A const& asset, Number const& value, std::int32_t scale, - Number::rounding_mode rounding = Number::getround()) + Number::RoundingMode rounding = Number::getround()) { NumberRoundModeGuard const mg(rounding); STAmount const ret{asset, value}; @@ -752,16 +752,16 @@ scale(Number const& number, Asset const& asset) } // namespace xrpl //------------------------------------------------------------------------------ -namespace Json { +namespace json { template <> inline xrpl::STAmount -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; - Json::StaticString const& key = field.getJsonName(); + json::StaticString const& key = field.getJsonName(); if (!v.isMember(key)) Throw(key); - Json::Value const& inner = v[key]; + json::Value const& inner = v[key]; return amountFromJson(field, inner); } -} // namespace Json +} // namespace json diff --git a/include/xrpl/protocol/STArray.h b/include/xrpl/protocol/STArray.h index f1ac58075b..61753c52dc 100644 --- a/include/xrpl/protocol/STArray.h +++ b/include/xrpl/protocol/STArray.h @@ -58,13 +58,28 @@ public: template void - emplace_back(Args&&... args); + emplaceBack(Args&&... args); void - push_back(STObject const& object); + pushBack(STObject const& object); void - push_back(STObject&& object); + pushBack(STObject&& object); + + // STL-compatible alias required by std::back_insert_iterator + void + // NOLINTNEXTLINE(readability-identifier-naming) + push_back(STObject const& object) + { + pushBack(object); + } + + void + // NOLINTNEXTLINE(readability-identifier-naming) + push_back(STObject&& object) + { + pushBack(std::move(object)); + } iterator begin(); @@ -99,7 +114,7 @@ public: [[nodiscard]] std::string getText() const override; - [[nodiscard]] Json::Value + [[nodiscard]] json::Value getJson(JsonOptions index) const override; void @@ -180,19 +195,19 @@ STArray::back() const template inline void -STArray::emplace_back(Args&&... args) +STArray::emplaceBack(Args&&... args) { v_.emplace_back(std::forward(args)...); } inline void -STArray::push_back(STObject const& object) +STArray::pushBack(STObject const& object) { v_.push_back(object); } inline void -STArray::push_back(STObject&& object) +STArray::pushBack(STObject&& object) { v_.push_back(std::move(object)); } diff --git a/include/xrpl/protocol/STBase.h b/include/xrpl/protocol/STBase.h index 7ebf22fe8f..cba0bfbe74 100644 --- a/include/xrpl/protocol/STBase.h +++ b/include/xrpl/protocol/STBase.h @@ -20,14 +20,14 @@ struct JsonOptions // Bitwise flags with operator~ // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum values : underlying_t { + enum Values : underlying_t { // clang-format off - none = 0b0000'0000, - include_date = 0b0000'0001, - disable_API_prior_V2 = 0b0000'0010, + KNone = 0b0000'0000, + KIncludeDate = 0b0000'0001, + KDisableApiPriorV2 = 0b0000'0010, - // IMPORTANT `_all` must be union of all of the above; see also operator~ - _all = 0b0000'0011 + // IMPORTANT `kALL` must be union of all of the above; see also operator~ + KAll = 0b0000'0011 // clang-format on }; @@ -65,22 +65,22 @@ struct JsonOptions } /// Returns JsonOptions binary negation, can be used with & (above) for set - /// difference e.g. `(options & ~JsonOptions::include_date)` + /// difference e.g. `(options & ~JsonOptions::kINCLUDE_DATE)` [[nodiscard]] constexpr JsonOptions friend operator~(JsonOptions v) noexcept { - return {~v.value & static_cast(_all)}; + return {~v.value & static_cast(KAll)}; } }; template requires requires(T const& t) { - { t.getJson(JsonOptions::none) } -> std::convertible_to; + { t.getJson(JsonOptions::KNone) } -> std::convertible_to; } -Json::Value -to_json(T const& t) +json::Value +toJson(T const& t) { - return t.getJson(JsonOptions::none); + return t.getJson(JsonOptions::KNone); } namespace detail { @@ -115,7 +115,7 @@ class STVar; */ class STBase { - SField const* fName; + SField const* fName_; public: virtual ~STBase() = default; @@ -148,7 +148,7 @@ public: [[nodiscard]] virtual std::string getText() const; - [[nodiscard]] virtual Json::Value getJson(JsonOptions = JsonOptions::none) const; + [[nodiscard]] virtual json::Value getJson(JsonOptions = JsonOptions::KNone) const; virtual void add(Serializer& s) const; diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index 6f2e08e401..efb98cfe27 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -16,7 +16,7 @@ class STBitString final : public STBase, public CountedObject> static_assert(Bits > 0, "Number of bits must be positive"); public: - using value_type = base_uint; + using value_type = BaseUint; private: value_type value_{}; @@ -46,7 +46,7 @@ public: template void - setValue(base_uint const& v); + setValue(BaseUint const& v); [[nodiscard]] value_type const& value() const; @@ -157,7 +157,7 @@ STBitString::add(Serializer& s) const template template void -STBitString::setValue(base_uint const& v) +STBitString::setValue(BaseUint const& v) { value_ = v; } @@ -180,7 +180,7 @@ template bool STBitString::isDefault() const { - return value_ == beast::zero; + return value_ == beast::kZERO; } } // namespace xrpl diff --git a/include/xrpl/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h index 0667c54e30..84f44f1b78 100644 --- a/include/xrpl/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -24,7 +24,7 @@ public: STBlob(SField const& f, void const* data, std::size_t size); STBlob(SField const& f, Buffer&& b); STBlob(SField const& n); - STBlob(SerialIter&, SField const& name = sfGeneric); + STBlob(SerialIter&, SField const& name = kSF_GENERIC); [[nodiscard]] std::size_t size() const; diff --git a/include/xrpl/protocol/STCurrency.h b/include/xrpl/protocol/STCurrency.h index a81b589a2c..55d1ab1e74 100644 --- a/include/xrpl/protocol/STCurrency.h +++ b/include/xrpl/protocol/STCurrency.h @@ -39,7 +39,7 @@ public: [[nodiscard]] std::string getText() const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; void add(Serializer& s) const override; @@ -63,7 +63,7 @@ private: }; STCurrency -currencyFromJson(SField const& name, Json::Value const& v); +currencyFromJson(SField const& name, json::Value const& v); inline Currency const& STCurrency::currency() const diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 5f6e8c8800..4e3c9a8923 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -22,7 +22,7 @@ public: [[nodiscard]] SerializedTypeID getSType() const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; [[nodiscard]] std::string getText() const override; diff --git a/include/xrpl/protocol/STIssue.h b/include/xrpl/protocol/STIssue.h index 8a64f39336..f5e1f61168 100644 --- a/include/xrpl/protocol/STIssue.h +++ b/include/xrpl/protocol/STIssue.h @@ -49,7 +49,7 @@ public: [[nodiscard]] std::string getText() const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; void add(Serializer& s) const override; @@ -89,7 +89,7 @@ STIssue::STIssue(SField const& name, A const& asset) : STBase{name}, asset_{asse } STIssue -issueFromJson(SField const& name, Json::Value const& v); +issueFromJson(SField const& name, json::Value const& v); template bool diff --git a/include/xrpl/protocol/STLedgerEntry.h b/include/xrpl/protocol/STLedgerEntry.h index 2e884bc2bf..e37b132806 100644 --- a/include/xrpl/protocol/STLedgerEntry.h +++ b/include/xrpl/protocol/STLedgerEntry.h @@ -37,8 +37,8 @@ public: [[nodiscard]] std::string getText() const override; - [[nodiscard]] Json::Value - getJson(JsonOptions options = JsonOptions::none) const override; + [[nodiscard]] json::Value + getJson(JsonOptions options = JsonOptions::KNone) const override; /** Returns the 'key' (or 'index') of this item. The key identifies this entry's position in diff --git a/include/xrpl/protocol/STNumber.h b/include/xrpl/protocol/STNumber.h index 802bdf671f..8594a292f4 100644 --- a/include/xrpl/protocol/STNumber.h +++ b/include/xrpl/protocol/STNumber.h @@ -96,6 +96,6 @@ NumberParts partsFromString(std::string const& number); STNumber -numberFromJson(SField const& field, Json::Value const& value); +numberFromJson(SField const& field, json::Value const& value); } // namespace xrpl diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 187bde6dae..a9e46e8717 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -57,7 +57,7 @@ class STObject : public STBase, public CountedObject using list_type = std::vector; list_type v_; - SOTemplate const* mType{}; + SOTemplate const* type_{}; public: using iterator = boost::transform_iterator; @@ -132,7 +132,7 @@ public: getText() const override; // TODO(tom): options should be an enum. - [[nodiscard]] Json::Value getJson(JsonOptions = JsonOptions::none) const override; + [[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override; void addWithoutSigningFields(Serializer& s) const; @@ -142,7 +142,7 @@ public: template std::size_t - emplace_back(Args&&... args); + emplaceBack(Args&&... args); [[nodiscard]] int getCount() const; @@ -381,7 +381,7 @@ public: template void - setFieldH160(SField const& field, base_uint<160, Tag> const& v); + setFieldH160(SField const& field, BaseUint<160, Tag> const& v); STObject& peekFieldObject(SField const& field); @@ -415,9 +415,9 @@ public: private: enum class WhichFields : bool { // These values are carefully chosen to do the right thing if passed - // to SField::shouldInclude (bool) via static_cast - omitSigningFields = false, - withAllFields = true + // to SField::shouldInclude (bool) + OmitSigningFields = false, + WithAllFields = true }; void @@ -667,7 +667,7 @@ public: // Emulate std::optional::value_or [[nodiscard]] value_type - value_or(value_type val) const; + valueOr(value_type val) const; OptionalProxy& operator=(std::nullopt_t const&); @@ -692,7 +692,7 @@ private: disengage(); [[nodiscard]] optional_type - optional_value() const; + optionalValue() const; }; class STObject::FieldErr : public std::runtime_error @@ -703,16 +703,16 @@ class STObject::FieldErr : public std::runtime_error template STObject::Proxy::Proxy(STObject* st, TypedField const* f) : st_(st), f_(f) { - if (st_->mType != nullptr) + if (st_->type_ != nullptr) { // STObject has associated template if (!st_->peekAtPField(*f_)) Throw("Template field error '" + this->f_->getName() + "'"); - style_ = st_->mType->style(*f_); + style_ = st_->type_->style(*f_); } else { - style_ = soeINVALID; + style_ = SoeInvalid; } } @@ -723,11 +723,11 @@ STObject::Proxy::value() const -> value_type auto const t = find(); if (t) return t->value(); - if (style_ == soeINVALID) + if (style_ == SoeInvalid) { Throw("Value requested from invalid STObject."); } - if (style_ != soeDEFAULT) + if (style_ != SoeDefault) { Throw("Missing field '" + this->f_->getName() + "'"); } @@ -762,13 +762,13 @@ template void STObject::Proxy::assign(U&& u) { - if (style_ == soeDEFAULT && u == value_type{}) + if (style_ == SoeDefault && u == value_type{}) { st_->makeFieldAbsent(*f_); return; } T* t = nullptr; - if (style_ == soeINVALID) + if (style_ == SoeInvalid) { t = dynamic_cast(st_->getPField(*f_, true)); } @@ -836,14 +836,14 @@ template STObject::OptionalProxy:: operator typename STObject::OptionalProxy::optional_type() const { - return optional_value(); + return optionalValue(); } template typename STObject::OptionalProxy::optional_type STObject::OptionalProxy::operator~() const { - return optional_value(); + return optionalValue(); } template @@ -904,16 +904,16 @@ template bool STObject::OptionalProxy::engaged() const noexcept { - return this->style_ == soeDEFAULT || this->find() != nullptr; + return this->style_ == SoeDefault || this->find() != nullptr; } template void STObject::OptionalProxy::disengage() { - if (this->style_ == soeREQUIRED || this->style_ == soeDEFAULT) + if (this->style_ == SoeRequired || this->style_ == SoeDefault) Throw("Template field error '" + this->f_->getName() + "'"); - if (this->style_ == soeINVALID) + if (this->style_ == SoeInvalid) { this->st_->delField(*this->f_); } @@ -925,7 +925,7 @@ STObject::OptionalProxy::disengage() template auto -STObject::OptionalProxy::optional_value() const -> optional_type +STObject::OptionalProxy::optionalValue() const -> optional_type { if (!engaged()) return std::nullopt; @@ -934,7 +934,7 @@ STObject::OptionalProxy::optional_value() const -> optional_type template typename STObject::OptionalProxy::value_type -STObject::OptionalProxy::value_or(value_type val) const +STObject::OptionalProxy::valueOr(value_type val) const { return engaged() ? this->value() : val; } @@ -981,13 +981,13 @@ STObject::reserve(std::size_t n) inline bool STObject::isFree() const { - return mType == nullptr; + return type_ == nullptr; } inline void STObject::addWithoutSigningFields(Serializer& s) const { - add(s, WhichFields::omitSigningFields); + add(s, WhichFields::OmitSigningFields); } // VFALCO NOTE does this return an expensive copy of an object with a @@ -997,13 +997,13 @@ inline Serializer STObject::getSerializer() const { Serializer s; - add(s, WhichFields::withAllFields); + add(s, WhichFields::WithAllFields); return s; } template inline std::size_t -STObject::emplace_back(Args&&... args) +STObject::emplaceBack(Args&&... args) { v_.emplace_back(std::forward(args)...); return v_.size() - 1; @@ -1082,21 +1082,21 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - XRPL_ASSERT(mType, "xrpl::STObject::at(TypedField auto) : field template non-null"); + XRPL_ASSERT(type_, "xrpl::STObject::at(TypedField auto) : field template non-null"); XRPL_ASSERT( b->getSType() == STI_NOTPRESENT, "xrpl::STObject::at(TypedField auto) : type not present"); - if (mType->style(f) == soeOPTIONAL) + if (type_->style(f) == SoeOptional) Throw("Missing optional field: " + f.getName()); XRPL_ASSERT( - mType->style(f) == soeDEFAULT, + type_->style(f) == SoeDefault, "xrpl::STObject::at(TypedField auto) : template style is default"); // Used to help handle the case where value_type is a const reference, // otherwise we would return the address of a temporary. - static std::decay_t const dv{}; - return dv; + static std::decay_t const kDV{}; + return kDV; } template @@ -1110,16 +1110,16 @@ STObject::at(OptionaledField const& of) const if (!u) { XRPL_ASSERT( - mType, + type_, "xrpl::STObject::at(OptionaledField auto) : field template " "non-null"); XRPL_ASSERT( b->getSType() == STI_NOTPRESENT, "xrpl::STObject::at(OptionaledField auto) : type not present"); - if (mType->style(*of.f) == soeOPTIONAL) + if (type_->style(*of.f) == SoeOptional) return std::nullopt; XRPL_ASSERT( - mType->style(*of.f) == soeDEFAULT, + type_->style(*of.f) == SoeDefault, "xrpl::STObject::at(OptionaledField auto) : template style is " "default"); return typename T::value_type{}; @@ -1143,7 +1143,7 @@ STObject::at(OptionaledField const& of) -> OptionalProxy template void -STObject::setFieldH160(SField const& field, base_uint<160, Tag> const& v) +STObject::setFieldH160(SField const& field, BaseUint<160, Tag> const& v) { STBase* rf = getPField(field, true); diff --git a/include/xrpl/protocol/STParsedJSON.h b/include/xrpl/protocol/STParsedJSON.h index 772785fd70..d5b4f33be7 100644 --- a/include/xrpl/protocol/STParsedJSON.h +++ b/include/xrpl/protocol/STParsedJSON.h @@ -19,7 +19,7 @@ public: @param name The name of the JSON field, used in diagnostics. @param json The JSON-RPC to parse. */ - STParsedJSONObject(std::string const& name, Json::Value const& json); + STParsedJSONObject(std::string const& name, json::Value const& json); STParsedJSONObject() = delete; STParsedJSONObject(STParsedJSONObject const&) = delete; @@ -31,7 +31,7 @@ public: std::optional object; /** On failure, an appropriate set of error values. */ - Json::Value error; + json::Value error; }; } // namespace xrpl diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index ce9a73523c..a1891164f6 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -16,10 +16,10 @@ namespace xrpl { class STPathElement final : public CountedObject { - unsigned int mType; - AccountID mAccountID; - PathAsset mAssetID; - AccountID mIssuerID; + unsigned int type_; + AccountID accountID_; + PathAsset assetID_; + AccountID issuerID_; bool is_offer_; std::size_t hash_value_; @@ -28,14 +28,14 @@ public: // Bitwise values (typeCurrency | typeMPT) // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum Type { - typeNone = 0x00, - typeAccount = 0x01, // Rippling through an account (vs taking an offer). - typeCurrency = 0x10, // Currency follows. - typeIssuer = 0x20, // Issuer follows. - typeMPT = 0x40, // MPT follows. - typeBoundary = 0xFF, // Boundary between alternate paths. - typeAsset = typeCurrency | typeMPT, - typeAll = typeAccount | typeCurrency | typeIssuer | typeMPT, + TypeNone = 0x00, + TypeAccount = 0x01, // Rippling through an account (vs taking an offer). + TypeCurrency = 0x10, // Currency follows. + TypeIssuer = 0x20, // Issuer follows. + TypeMpt = 0x40, // MPT follows. + TypeBoundary = 0xFF, // Boundary between alternate paths. + TypeAsset = TypeCurrency | TypeMpt, + TypeAll = TypeAccount | TypeCurrency | TypeIssuer | TypeMpt, // Combination of all types. }; @@ -113,12 +113,12 @@ public: private: static std::size_t - get_hash(STPathElement const& element); + getHash(STPathElement const& element); }; class STPath final : public CountedObject { - std::vector mPath; + std::vector path_; public: STPath() = default; @@ -132,16 +132,16 @@ public: empty() const; void - push_back(STPathElement const& e); + pushBack(STPathElement const& e); template void - emplace_back(Args&&... args); + emplaceBack(Args&&... args); [[nodiscard]] bool hasSeen(AccountID const& account, PathAsset const& asset, AccountID const& issuer) const; - [[nodiscard]] Json::Value getJson(JsonOptions) const; + [[nodiscard]] json::Value getJson(JsonOptions) const; [[nodiscard]] std::vector::const_iterator begin() const; @@ -173,7 +173,7 @@ public: // A set of zero or more payment paths class STPathSet final : public STBase, public CountedObject { - std::vector value; + std::vector value_; public: STPathSet() = default; @@ -184,7 +184,7 @@ public: void add(Serializer& s) const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; [[nodiscard]] SerializedTypeID getSType() const override; @@ -218,11 +218,11 @@ public: empty() const; void - push_back(STPath const& e); + pushBack(STPath const& e); template void - emplace_back(Args&&... args); + emplaceBack(Args&&... args); private: STBase* @@ -235,16 +235,16 @@ private: // ------------ STPathElement ------------ -inline STPathElement::STPathElement() : mType(typeNone), is_offer_(true) +inline STPathElement::STPathElement() : type_(TypeNone), is_offer_(true) { - hash_value_ = get_hash(*this); + hash_value_ = getHash(*this); } inline STPathElement::STPathElement( std::optional const& account, std::optional const& asset, std::optional const& issuer) - : mType(typeNone) + : type_(TypeNone) { if (!account) { @@ -253,26 +253,26 @@ inline STPathElement::STPathElement( else { is_offer_ = false; - mAccountID = *account; - mType |= typeAccount; + accountID_ = *account; + type_ |= TypeAccount; XRPL_ASSERT( - mAccountID != noAccount(), "xrpl::STPathElement::STPathElement : account is set"); + accountID_ != noAccount(), "xrpl::STPathElement::STPathElement : account is set"); } if (asset) { - mAssetID = *asset; - mType |= mAssetID.holds() ? typeCurrency : typeMPT; + assetID_ = *asset; + type_ |= assetID_.holds() ? TypeCurrency : TypeMpt; } if (issuer) { - mIssuerID = *issuer; - mType |= typeIssuer; - XRPL_ASSERT(mIssuerID != noAccount(), "xrpl::STPathElement::STPathElement : issuer is set"); + issuerID_ = *issuer; + type_ |= TypeIssuer; + XRPL_ASSERT(issuerID_ != noAccount(), "xrpl::STPathElement::STPathElement : issuer is set"); } - hash_value_ = get_hash(*this); + hash_value_ = getHash(*this); } inline STPathElement::STPathElement( @@ -280,22 +280,22 @@ inline STPathElement::STPathElement( PathAsset const& asset, AccountID const& issuer, bool forceAsset) - : mType(typeNone) - , mAccountID(account) - , mAssetID(asset) - , mIssuerID(issuer) - , is_offer_(isXRP(mAccountID)) + : type_(TypeNone) + , accountID_(account) + , assetID_(asset) + , issuerID_(issuer) + , is_offer_(isXRP(accountID_)) { if (!is_offer_) - mType |= typeAccount; + type_ |= TypeAccount; - if (forceAsset || !isXRP(mAssetID)) - mType |= asset.holds() ? typeCurrency : typeMPT; + if (forceAsset || !isXRP(assetID_)) + type_ |= asset.holds() ? TypeCurrency : TypeMpt; if (!isXRP(issuer)) - mType |= typeIssuer; + type_ |= TypeIssuer; - hash_value_ = get_hash(*this); + hash_value_ = getHash(*this); } inline STPathElement::STPathElement( @@ -303,24 +303,22 @@ inline STPathElement::STPathElement( AccountID const& account, PathAsset const& asset, AccountID const& issuer) - : mType(uType) - , mAccountID(account) - , mAssetID(asset) - , mIssuerID(issuer) - , is_offer_(isXRP(mAccountID)) + : type_(uType) + , accountID_(account) + , assetID_(asset) + , issuerID_(issuer) + , is_offer_(isXRP(accountID_)) { - // uType could be assetType; i.e. either Currency or MPTID. - // Get the actual type. - mAssetID.visit( - [&](Currency const&) { mType = mType & (~Type::typeMPT); }, - [&](MPTID const&) { mType = mType & (~Type::typeCurrency); }); - hash_value_ = get_hash(*this); + assetID_.visit( + [&](Currency const&) { type_ = type_ & (~Type::TypeMpt); }, + [&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); }); + hash_value_ = getHash(*this); } inline auto STPathElement::getNodeType() const { - return mType; + return type_; } inline bool @@ -338,37 +336,37 @@ STPathElement::isAccount() const inline bool STPathElement::isType(Type const& pe) const { - return (mType & pe) != 0u; + return (type_ & pe) != 0u; } inline bool STPathElement::hasIssuer() const { - return isType(STPathElement::typeIssuer); + return isType(STPathElement::TypeIssuer); } inline bool STPathElement::hasCurrency() const { - return isType(STPathElement::typeCurrency); + return isType(STPathElement::TypeCurrency); } inline bool STPathElement::hasMPT() const { - return isType(STPathElement::typeMPT); + return isType(STPathElement::TypeMpt); } inline bool STPathElement::hasAsset() const { - return isType(STPathElement::typeAsset); + return isType(STPathElement::TypeAsset); } inline bool STPathElement::isNone() const { - return getNodeType() == STPathElement::typeNone; + return getNodeType() == STPathElement::TypeNone; } // Nodes are either an account ID or a offer prefix. Offer prefixs denote a @@ -376,38 +374,38 @@ STPathElement::isNone() const inline AccountID const& STPathElement::getAccountID() const { - return mAccountID; + return accountID_; } inline PathAsset const& STPathElement::getPathAsset() const { - return mAssetID; + return assetID_; } inline Currency const& STPathElement::getCurrency() const { - return mAssetID.get(); + return assetID_.get(); } inline MPTID const& STPathElement::getMPTID() const { - return mAssetID.get(); + return assetID_.get(); } inline AccountID const& STPathElement::getIssuerID() const { - return mIssuerID; + return issuerID_; } inline bool STPathElement::operator==(STPathElement const& t) const { - return (mType & typeAccount) == (t.mType & typeAccount) && hash_value_ == t.hash_value_ && - mAccountID == t.mAccountID && mAssetID == t.mAssetID && mIssuerID == t.mIssuerID; + return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hash_value_ == t.hash_value_ && + accountID_ == t.accountID_ && assetID_ == t.assetID_ && issuerID_ == t.issuerID_; } inline bool @@ -418,81 +416,81 @@ STPathElement::operator!=(STPathElement const& t) const // ------------ STPath ------------ -inline STPath::STPath(std::vector p) : mPath(std::move(p)) +inline STPath::STPath(std::vector p) : path_(std::move(p)) { } inline std::vector::size_type STPath::size() const { - return mPath.size(); + return path_.size(); } inline bool STPath::empty() const { - return mPath.empty(); + return path_.empty(); } inline void -STPath::push_back(STPathElement const& e) +STPath::pushBack(STPathElement const& e) { - mPath.push_back(e); + path_.push_back(e); } template inline void -STPath::emplace_back(Args&&... args) +STPath::emplaceBack(Args&&... args) { - mPath.emplace_back(std::forward(args)...); + path_.emplace_back(std::forward(args)...); } inline std::vector::const_iterator STPath::begin() const { - return mPath.begin(); + return path_.begin(); } inline std::vector::const_iterator STPath::end() const { - return mPath.end(); + return path_.end(); } inline bool STPath::operator==(STPath const& t) const { - return mPath == t.mPath; + return path_ == t.path_; } inline std::vector::const_reference STPath::back() const { - return mPath.back(); + return path_.back(); } inline std::vector::const_reference STPath::front() const { - return mPath.front(); + return path_.front(); } inline STPathElement& STPath::operator[](int i) { - return mPath[i]; + return path_[i]; } inline STPathElement const& STPath::operator[](int i) const { - return mPath[i]; + return path_[i]; } inline void STPath::reserve(size_t s) { - mPath.reserve(s); + path_.reserve(s); } // ------------ STPathSet ------------ @@ -505,50 +503,50 @@ inline STPathSet::STPathSet(SField const& n) : STBase(n) inline std::vector::const_reference STPathSet::operator[](std::vector::size_type n) const { - return value[n]; + return value_[n]; } inline std::vector::reference STPathSet::operator[](std::vector::size_type n) { - return value[n]; + return value_[n]; } inline std::vector::const_iterator STPathSet::begin() const { - return value.begin(); + return value_.begin(); } inline std::vector::const_iterator STPathSet::end() const { - return value.end(); + return value_.end(); } inline std::vector::size_type STPathSet::size() const { - return value.size(); + return value_.size(); } inline bool STPathSet::empty() const { - return value.empty(); + return value_.empty(); } inline void -STPathSet::push_back(STPath const& e) +STPathSet::pushBack(STPath const& e) { - value.push_back(e); + value_.push_back(e); } template inline void -STPathSet::emplace_back(Args&&... args) +STPathSet::emplaceBack(Args&&... args) { - value.emplace_back(std::forward(args)...); + value_.emplace_back(std::forward(args)...); } } // namespace xrpl diff --git a/include/xrpl/protocol/STTx.h b/include/xrpl/protocol/STTx.h index b27d9e0637..d1bd32848f 100644 --- a/include/xrpl/protocol/STTx.h +++ b/include/xrpl/protocol/STTx.h @@ -16,12 +16,12 @@ namespace xrpl { enum class TxnSql : char { - txnSqlNew = 'N', - txnSqlConflict = 'C', - txnSqlHeld = 'H', - txnSqlValidated = 'V', - txnSqlIncluded = 'I', - txnSqlUnknown = 'U' + New = 'N', + Conflict = 'C', + Held = 'H', + Validated = 'V', + Included = 'I', + Unknown = 'U' }; class STTx final : public STObject, public CountedObject @@ -30,8 +30,8 @@ class STTx final : public STObject, public CountedObject TxType tx_type_; public: - static constexpr std::size_t minMultiSigners = 1; - static constexpr std::size_t maxMultiSigners = 32; + static constexpr std::size_t kMIN_MULTI_SIGNERS = 1; + static constexpr std::size_t kMAX_MULTI_SIGNERS = 32; STTx() = delete; STTx(STTx const& other) = default; @@ -92,10 +92,10 @@ public: uint256 getTransactionID() const; - Json::Value + json::Value getJson(JsonOptions options) const override; - Json::Value + json::Value getJson(JsonOptions options, bool binary) const; void diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index c645336b59..27d5ef1051 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -16,14 +16,14 @@ namespace xrpl { // Validation flags // This is a full (as opposed to a partial) validation -constexpr std::uint32_t vfFullValidation = 0x00000001; +constexpr std::uint32_t kVF_FULL_VALIDATION = 0x00000001; // The signature is fully canonical -constexpr std::uint32_t vfFullyCanonicalSig = 0x80000000; +constexpr std::uint32_t kVF_FULLY_CANONICAL_SIG = 0x80000000; class STValidation final : public STObject, public CountedObject { - bool mTrusted = false; + bool trusted_ = false; // Determines the validity of the signature in this validation; unseated // optional if we haven't yet checked it, a boolean otherwise. @@ -151,7 +151,7 @@ STValidation::STValidation(SerialIter& sit, LookupNodeID&& lookupNodeID, bool ch , signingPubKey_([this]() { auto const spk = getFieldVL(sfSigningPubKey); - if (publicKeyType(makeSlice(spk)) != KeyType::secp256k1) + if (publicKeyType(makeSlice(spk)) != KeyType::Secp256k1) Throw("Invalid public key in validation"); return PublicKey{makeSlice(spk)}; @@ -161,7 +161,7 @@ STValidation::STValidation(SerialIter& sit, LookupNodeID&& lookupNodeID, bool ch if (checkSignature && !isValid()) { JLOG(debugLog().error()) << "Invalid signature in validation: " - << getJson(JsonOptions::none); + << getJson(JsonOptions::KNone); Throw("Invalid signature in validation"); } @@ -194,8 +194,8 @@ STValidation::STValidation( "node"); // First, set our own public key: - if (publicKeyType(pk) != KeyType::secp256k1) - LogicError("We can only use secp256k1 keys for signing validations"); + if (publicKeyType(pk) != KeyType::Secp256k1) + logicError("We can only use secp256k1 keys for signing validations"); setFieldVL(sfSigningPubKey, pk.slice()); setFieldU32(sfSigningTime, signTime.time_since_epoch().count()); @@ -204,15 +204,15 @@ STValidation::STValidation( f(*this); // Finally, sign the validation and mark it as trusted: - setFlag(vfFullyCanonicalSig); + setFlag(kVF_FULLY_CANONICAL_SIG); setFieldVL(sfSignature, signDigest(pk, sk, getSigningHash())); setTrusted(); // Check to ensure that all required fields are present. for (auto const& e : validationFormat()) { - if (e.style() == soeREQUIRED && !isFieldPresent(e.sField())) - LogicError("Required field '" + e.sField().getName() + "' missing from validation."); + if (e.style() == SoeRequired && !isFieldPresent(e.sField())) + logicError("Required field '" + e.sField().getName() + "' missing from validation."); } // We just signed this, so it should be valid. @@ -234,19 +234,19 @@ STValidation::getNodeID() const noexcept inline bool STValidation::isTrusted() const noexcept { - return mTrusted; + return trusted_; } inline void STValidation::setTrusted() { - mTrusted = true; + trusted_ = true; } inline void STValidation::setUntrusted() { - mTrusted = false; + trusted_ = false; } inline void diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index c650c565ce..ab3a2f99e3 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -9,7 +9,7 @@ namespace xrpl { class STVector256 : public STBase, public CountedObject { - std::vector mValue; + std::vector value_; public: using value_type = std::vector const&; @@ -27,7 +27,7 @@ public: void add(Serializer& s) const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; [[nodiscard]] bool isEquivalent(STBase const& t) const override; @@ -70,7 +70,7 @@ public: insert(std::vector::const_iterator pos, uint256 const& value); void - push_back(uint256 const& v); + pushBack(uint256 const& v); std::vector::iterator begin(); @@ -103,124 +103,124 @@ inline STVector256::STVector256(SField const& n) : STBase(n) { } -inline STVector256::STVector256(std::vector const& vector) : mValue(vector) +inline STVector256::STVector256(std::vector const& vector) : value_(vector) { } inline STVector256::STVector256(SField const& n, std::vector const& vector) - : STBase(n), mValue(vector) + : STBase(n), value_(vector) { } inline STVector256& STVector256::operator=(std::vector const& v) { - mValue = v; + value_ = v; return *this; } inline STVector256& STVector256::operator=(std::vector&& v) { - mValue = std::move(v); + value_ = std::move(v); return *this; } inline void STVector256::setValue(STVector256 const& v) { - mValue = v.mValue; + value_ = v.value_; } /** Retrieve a copy of the vector we contain */ inline STVector256:: operator std::vector() const { - return mValue; + return value_; } inline std::size_t STVector256::size() const { - return mValue.size(); + return value_.size(); } inline void STVector256::resize(std::size_t n) { - mValue.resize(n); + value_.resize(n); } inline bool STVector256::empty() const { - return mValue.empty(); + return value_.empty(); } inline std::vector::reference STVector256::operator[](std::vector::size_type n) { - return mValue[n]; + return value_[n]; } inline std::vector::const_reference STVector256::operator[](std::vector::size_type n) const { - return mValue[n]; + return value_[n]; } inline std::vector const& STVector256::value() const { - return mValue; + return value_; } inline std::vector::iterator STVector256::insert(std::vector::const_iterator pos, uint256 const& value) { - return mValue.insert(pos, value); + return value_.insert(pos, value); } inline void -STVector256::push_back(uint256 const& v) +STVector256::pushBack(uint256 const& v) { - mValue.push_back(v); + value_.push_back(v); } inline std::vector::iterator STVector256::begin() { - return mValue.begin(); + return value_.begin(); } inline std::vector::const_iterator STVector256::begin() const { - return mValue.begin(); + return value_.begin(); } inline std::vector::iterator STVector256::end() { - return mValue.end(); + return value_.end(); } inline std::vector::const_iterator STVector256::end() const { - return mValue.end(); + return value_.end(); } inline std::vector::iterator STVector256::erase(std::vector::iterator position) { - return mValue.erase(position); + return value_.erase(position); } inline void STVector256::clear() noexcept { - mValue.clear(); + value_.clear(); } } // namespace xrpl diff --git a/include/xrpl/protocol/STXChainBridge.h b/include/xrpl/protocol/STXChainBridge.h index 2dc2fbce48..292ffe2767 100644 --- a/include/xrpl/protocol/STXChainBridge.h +++ b/include/xrpl/protocol/STXChainBridge.h @@ -20,7 +20,7 @@ class STXChainBridge final : public STBase, public CountedObject public: using value_type = STXChainBridge; - enum class ChainType { locking, issuing }; + enum class ChainType { Locking, Issuing }; static ChainType otherChain(ChainType ct); @@ -45,9 +45,9 @@ public: AccountID const& dstChainDoor, Issue const& dstChainIssue); - explicit STXChainBridge(Json::Value const& v); + explicit STXChainBridge(json::Value const& v); - explicit STXChainBridge(SField const& name, Json::Value const& v); + explicit STXChainBridge(SField const& name, json::Value const& v); explicit STXChainBridge(SerialIter& sit, SField const& name); @@ -81,7 +81,7 @@ public: [[nodiscard]] SerializedTypeID getSType() const override; - [[nodiscard]] Json::Value getJson(JsonOptions) const override; + [[nodiscard]] json::Value getJson(JsonOptions) const override; void add(Serializer& s) const override; @@ -174,7 +174,7 @@ STXChainBridge::value() const noexcept inline AccountID const& STXChainBridge::door(ChainType ct) const { - if (ct == ChainType::locking) + if (ct == ChainType::Locking) return lockingChainDoor(); return issuingChainDoor(); } @@ -182,7 +182,7 @@ STXChainBridge::door(ChainType ct) const inline Issue const& STXChainBridge::issue(ChainType ct) const { - if (ct == ChainType::locking) + if (ct == ChainType::Locking) return lockingChainIssue(); return issuingChainIssue(); } @@ -190,25 +190,25 @@ STXChainBridge::issue(ChainType ct) const inline STXChainBridge::ChainType STXChainBridge::otherChain(ChainType ct) { - if (ct == ChainType::locking) - return ChainType::issuing; - return ChainType::locking; + if (ct == ChainType::Locking) + return ChainType::Issuing; + return ChainType::Locking; } inline STXChainBridge::ChainType STXChainBridge::srcChain(bool wasLockingChainSend) { if (wasLockingChainSend) - return ChainType::locking; - return ChainType::issuing; + return ChainType::Locking; + return ChainType::Issuing; } inline STXChainBridge::ChainType STXChainBridge::dstChain(bool wasLockingChainSend) { if (wasLockingChainSend) - return ChainType::issuing; - return ChainType::locking; + return ChainType::Issuing; + return ChainType::Locking; } } // namespace xrpl diff --git a/include/xrpl/protocol/SecretKey.h b/include/xrpl/protocol/SecretKey.h index 462a48f4bd..9af27e9709 100644 --- a/include/xrpl/protocol/SecretKey.h +++ b/include/xrpl/protocol/SecretKey.h @@ -17,10 +17,10 @@ namespace xrpl { class SecretKey { public: - static constexpr std::size_t size_ = 32; + static constexpr std::size_t kSIZE = 32; private: - std::uint8_t buf_[size_]{}; + std::uint8_t buf_[kSIZE]{}; public: using const_iterator = std::uint8_t const*; @@ -37,7 +37,7 @@ public: ~SecretKey(); - SecretKey(std::array const& data); + SecretKey(std::array const& data); SecretKey(Slice const& slice); [[nodiscard]] std::uint8_t const* @@ -58,7 +58,7 @@ public: to avoid accidental exposure of secret key material. */ [[nodiscard]] std::string - to_string() const; + toString() const; [[nodiscard]] const_iterator begin() const noexcept diff --git a/include/xrpl/protocol/SeqProxy.h b/include/xrpl/protocol/SeqProxy.h index 820004681d..be040cceec 100644 --- a/include/xrpl/protocol/SeqProxy.h +++ b/include/xrpl/protocol/SeqProxy.h @@ -35,7 +35,7 @@ namespace xrpl { class SeqProxy { public: - enum class Type : std::uint8_t { seq = 0, ticket }; + enum class Type : std::uint8_t { Seq = 0, Ticket }; private: std::uint32_t value_; @@ -55,7 +55,7 @@ public: static constexpr SeqProxy sequence(std::uint32_t v) { - return SeqProxy{Type::seq, v}; + return SeqProxy{Type::Seq, v}; } [[nodiscard]] constexpr std::uint32_t @@ -67,13 +67,13 @@ public: [[nodiscard]] constexpr bool isSeq() const { - return type_ == Type::seq; + return type_ == Type::Seq; } [[nodiscard]] constexpr bool isTicket() const { - return type_ == Type::ticket; + return type_ == Type::Ticket; } // Occasionally it is convenient to be able to increase the value_ diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index e14d008cd1..385c09009a 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -21,41 +21,41 @@ class Serializer { private: // DEPRECATED - Blob mData; + Blob data_; public: explicit Serializer(int n = 256) { - mData.reserve(n); + data_.reserve(n); } Serializer(void const* data, std::size_t size) { - mData.resize(size); + data_.resize(size); if (size != 0u) { XRPL_ASSERT(data, "xrpl::Serializer::Serializer(void const*) : non-null input"); - std::memcpy(mData.data(), data, size); + std::memcpy(data_.data(), data, size); } } [[nodiscard]] Slice slice() const noexcept { - return Slice(mData.data(), mData.size()); + return Slice(data_.data(), data_.size()); } [[nodiscard]] std::size_t size() const noexcept { - return mData.size(); + return data_.size(); } [[nodiscard]] void const* data() const noexcept { - return mData.data(); + return data_.data(); } // assemble functions @@ -69,11 +69,11 @@ public: int add32(T i) { - int const ret = mData.size(); - mData.push_back(static_cast((i >> 24) & 0xff)); - mData.push_back(static_cast((i >> 16) & 0xff)); - mData.push_back(static_cast((i >> 8) & 0xff)); - mData.push_back(static_cast(i & 0xff)); + int const ret = data_.size(); + data_.push_back(static_cast((i >> 24) & 0xff)); + data_.push_back(static_cast((i >> 16) & 0xff)); + data_.push_back(static_cast((i >> 8) & 0xff)); + data_.push_back(static_cast(i & 0xff)); return ret; } @@ -85,15 +85,15 @@ public: int add64(T i) { - int const ret = mData.size(); - mData.push_back(static_cast((i >> 56) & 0xff)); - mData.push_back(static_cast((i >> 48) & 0xff)); - mData.push_back(static_cast((i >> 40) & 0xff)); - mData.push_back(static_cast((i >> 32) & 0xff)); - mData.push_back(static_cast((i >> 24) & 0xff)); - mData.push_back(static_cast((i >> 16) & 0xff)); - mData.push_back(static_cast((i >> 8) & 0xff)); - mData.push_back(static_cast(i & 0xff)); + int const ret = data_.size(); + data_.push_back(static_cast((i >> 56) & 0xff)); + data_.push_back(static_cast((i >> 48) & 0xff)); + data_.push_back(static_cast((i >> 40) & 0xff)); + data_.push_back(static_cast((i >> 32) & 0xff)); + data_.push_back(static_cast((i >> 24) & 0xff)); + data_.push_back(static_cast((i >> 16) & 0xff)); + data_.push_back(static_cast((i >> 8) & 0xff)); + data_.push_back(static_cast(i & 0xff)); return ret; } @@ -102,7 +102,7 @@ public: template int - addBitString(base_uint const& v) + addBitString(BaseUint const& v) { return addRaw(v.data(), v.size()); } @@ -134,13 +134,13 @@ public: bool getInteger(Integer& number, int offset) { - static auto const bytes = sizeof(Integer); - if ((offset + bytes) > mData.size()) + static auto const kBYTES = sizeof(Integer); + if ((offset + kBYTES) > data_.size()) return false; number = 0; - auto ptr = &mData[offset]; - for (auto i = 0; i < bytes; ++i) + auto ptr = &data_[offset]; + for (auto i = 0; i < kBYTES; ++i) { if (i) number <<= 8; @@ -151,11 +151,11 @@ public: template bool - getBitString(base_uint& data, int offset) const + getBitString(BaseUint& data, int offset) const { - auto success = (offset + (Bits / 8)) <= mData.size(); + auto success = (offset + (Bits / 8)) <= data_.size(); if (success) - memcpy(data.begin(), &(mData.front()) + offset, (Bits / 8)); + memcpy(data.begin(), &(data_.front()) + offset, (Bits / 8)); return success; } @@ -164,7 +164,7 @@ public: int addFieldID(SerializedTypeID type, int name) { - return addFieldID(safe_cast(type), name); + return addFieldID(safeCast(type), name); } // DEPRECATED @@ -175,38 +175,38 @@ public: [[nodiscard]] Blob const& peekData() const { - return mData; + return data_; } [[nodiscard]] Blob getData() const { - return mData; + return data_; } Blob& modData() { - return mData; + return data_; } [[nodiscard]] int getDataLength() const { - return mData.size(); + return data_.size(); } [[nodiscard]] void const* getDataPtr() const { - return mData.data(); + return data_.data(); } void* getDataPtr() { - return mData.data(); + return data_.data(); } [[nodiscard]] int getLength() const { - return mData.size(); + return data_.size(); } [[nodiscard]] std::string getString() const @@ -216,7 +216,7 @@ public: void erase() { - mData.clear(); + data_.clear(); } bool chop(int num); @@ -225,58 +225,58 @@ public: Blob ::iterator begin() { - return mData.begin(); + return data_.begin(); } Blob ::iterator end() { - return mData.end(); + return data_.end(); } [[nodiscard]] Blob ::const_iterator begin() const { - return mData.begin(); + return data_.begin(); } [[nodiscard]] Blob ::const_iterator end() const { - return mData.end(); + return data_.end(); } void reserve(size_t n) { - mData.reserve(n); + data_.reserve(n); } void resize(size_t n) { - mData.resize(n); + data_.resize(n); } [[nodiscard]] size_t capacity() const { - return mData.capacity(); + return data_.capacity(); } bool operator==(Blob const& v) const { - return v == mData; + return v == data_; } bool operator!=(Blob const& v) const { - return v != mData; + return v != data_; } bool operator==(Serializer const& v) const { - return v.mData == mData; + return v.data_ == data_; } bool operator!=(Serializer const& v) const { - return v.mData != mData; + return v.data_ != data_; } static int @@ -369,7 +369,7 @@ public: geti64(); template - base_uint + BaseUint getBitString(); uint128 @@ -428,7 +428,7 @@ public: }; template -base_uint +BaseUint SerialIter::getBitString() { auto const n = Bits / 8; @@ -442,7 +442,7 @@ SerialIter::getBitString() used_ += n; remain_ -= n; - return base_uint::fromVoid(x); + return BaseUint::fromVoid(x); } } // namespace xrpl diff --git a/include/xrpl/protocol/SystemParameters.h b/include/xrpl/protocol/SystemParameters.h index b51e011533..029c0418b5 100644 --- a/include/xrpl/protocol/SystemParameters.h +++ b/include/xrpl/protocol/SystemParameters.h @@ -14,22 +14,22 @@ namespace xrpl { static inline std::string const& systemName() { - static std::string const name = "xrpld"; - return name; + static std::string const kNAME = "xrpld"; + return kNAME; } /** Configure the native currency. */ /** Number of drops in the genesis account. */ -constexpr XRPAmount INITIAL_XRP{100'000'000'000 * DROPS_PER_XRP}; -static_assert(INITIAL_XRP.drops() == 100'000'000'000'000'000); -static_assert(Number::maxRep >= INITIAL_XRP.drops()); +constexpr XRPAmount kINITIAL_XRP{100'000'000'000 * kDROPS_PER_XRP}; +static_assert(kINITIAL_XRP.drops() == 100'000'000'000'000'000); +static_assert(Number::kMAX_REP >= kINITIAL_XRP.drops()); /** Returns true if the amount does not exceed the initial XRP in existence. */ inline bool isLegalAmount(XRPAmount const& amount) { - return amount <= INITIAL_XRP; + return amount <= kINITIAL_XRP; } /** Returns true if the absolute value of the amount does not exceed the initial @@ -37,31 +37,31 @@ isLegalAmount(XRPAmount const& amount) inline bool isLegalAmountSigned(XRPAmount const& amount) { - return amount >= -INITIAL_XRP && amount <= INITIAL_XRP; + return amount >= -kINITIAL_XRP && amount <= kINITIAL_XRP; } /* The currency code for the native currency. */ static inline std::string const& systemCurrencyCode() { - static std::string const code = "XRP"; - return code; + static std::string const kCODE = "XRP"; + return kCODE; } /** The XRP ledger network's earliest allowed sequence */ -static constexpr std::uint32_t XRP_LEDGER_EARLIEST_SEQ{32570u}; +static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_SEQ{32570u}; /** The XRP Ledger mainnet's earliest ledger with a FeeSettings object. Only * used in asserts and tests. */ -static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES{562177u}; +static constexpr std::uint32_t kXRP_LEDGER_EARLIEST_FEES{562177u}; /** The minimum amount of support an amendment should have. */ -constexpr std::ratio<80, 100> amendmentMajorityCalcThreshold; +constexpr std::ratio<80, 100> kAMENDMENT_MAJORITY_CALC_THRESHOLD; /** The minimum amount of time an amendment must hold a majority */ -constexpr std::chrono::seconds const defaultAmendmentMajorityTime = weeks{2}; +constexpr std::chrono::seconds const kDEFAULT_AMENDMENT_MAJORITY_TIME = weeks{2}; } // namespace xrpl /** Default peer port (IANA registered) */ -inline std::uint16_t constexpr DEFAULT_PEER_PORT{2459}; +inline std::uint16_t constexpr kDEFAULT_PEER_PORT{2459}; diff --git a/include/xrpl/protocol/TER.h b/include/xrpl/protocol/TER.h index 6494453b91..c89610f354 100644 --- a/include/xrpl/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -1,5 +1,7 @@ #pragma once +// NOLINTBEGIN(readability-identifier-naming) + #include #include @@ -364,37 +366,37 @@ enum TECcodes : TERUnderlyingType { constexpr TERUnderlyingType TERtoInt(TELcodes v) { - return safe_cast(v); + return safeCast(v); } constexpr TERUnderlyingType TERtoInt(TEMcodes v) { - return safe_cast(v); + return safeCast(v); } constexpr TERUnderlyingType TERtoInt(TEFcodes v) { - return safe_cast(v); + return safeCast(v); } constexpr TERUnderlyingType TERtoInt(TERcodes v) { - return safe_cast(v); + return safeCast(v); } constexpr TERUnderlyingType TERtoInt(TEScodes v) { - return safe_cast(v); + return safeCast(v); } constexpr TERUnderlyingType TERtoInt(TECcodes v) { - return safe_cast(v); + return safeCast(v); } //------------------------------------------------------------------------------ @@ -455,11 +457,11 @@ public: return code_ != tesSUCCESS; } - // Conversion to Json::Value allows assignment to Json::Objects + // Conversion to json::Value allows assignment to json::Objects // without casting. - operator Json::Value() const + operator json::Value() const { - return Json::Value{code_}; + return json::Value{code_}; } // Streaming operator. @@ -680,3 +682,5 @@ std::optional transCode(std::string const& token); } // namespace xrpl + +// NOLINTEND(readability-identifier-naming) diff --git a/include/xrpl/protocol/TxFlags.h b/include/xrpl/protocol/TxFlags.h index 7bbbd12707..4652cc1bf0 100644 --- a/include/xrpl/protocol/TxFlags.h +++ b/include/xrpl/protocol/TxFlags.h @@ -1,5 +1,7 @@ #pragma once +// NOLINTBEGIN(readability-identifier-naming) + #include #include @@ -444,3 +446,5 @@ getAsfFlagMap() #pragma pop_macro("ACCOUNTSET_FLAGS") } // namespace xrpl + +// NOLINTEND(readability-identifier-naming) diff --git a/include/xrpl/protocol/TxFormats.h b/include/xrpl/protocol/TxFormats.h index 235fb7b16e..77ab069feb 100644 --- a/include/xrpl/protocol/TxFormats.h +++ b/include/xrpl/protocol/TxFormats.h @@ -51,16 +51,16 @@ enum TxType : std::uint16_t #pragma pop_macro("TRANSACTION") /** This transaction type is deprecated; it is retained for historical purposes. */ - ttNICKNAME_SET [[deprecated("This transaction type is not supported and should not be used.")]] = 6, + TtNicknameSet [[deprecated("This transaction type is not supported and should not be used.")]] = 6, /** This transaction type is deprecated; it is retained for historical purposes. */ - ttCONTRACT [[deprecated("This transaction type is not supported and should not be used.")]] = 9, + TtContract [[deprecated("This transaction type is not supported and should not be used.")]] = 9, /** This identifier was never used, but the slot is reserved for historical purposes. */ - ttSPINAL_TAP [[deprecated("This transaction type is not supported and should not be used.")]] = 11, + TtSpinalTap [[deprecated("This transaction type is not supported and should not be used.")]] = 11, /** This transaction type installs a hook. */ - ttHOOK_SET [[maybe_unused]] = 22, + TtHookSet [[maybe_unused]] = 22, }; // clang-format on diff --git a/include/xrpl/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h index 31be3bdb47..6895350e9f 100644 --- a/include/xrpl/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -55,7 +55,7 @@ public: [[nodiscard]] boost::container::flat_set getAffectedAccounts() const; - [[nodiscard]] Json::Value + [[nodiscard]] json::Value getJson(JsonOptions p) const { return getAsObject().getJson(p); diff --git a/include/xrpl/protocol/UintTypes.h b/include/xrpl/protocol/UintTypes.h index fd48244d89..6fb0648b5f 100644 --- a/include/xrpl/protocol/UintTypes.h +++ b/include/xrpl/protocol/UintTypes.h @@ -30,21 +30,21 @@ public: /** Directory is an index into the directory of offer books. The last 64 bits of this are the quality. */ -using Directory = base_uint<256, detail::DirectoryTag>; +using Directory = BaseUint<256, detail::DirectoryTag>; /** Currency is a hash representing a specific currency. */ -using Currency = base_uint<160, detail::CurrencyTag>; +using Currency = BaseUint<160, detail::CurrencyTag>; /** NodeID is a 160-bit hash representing one node. */ -using NodeID = base_uint<160, detail::NodeIDTag>; +using NodeID = BaseUint<160, detail::NodeIDTag>; /** MPTID is a 192-bit value representing MPT Issuance ID, * which is a concatenation of a 32-bit sequence (big endian) * and a 160-bit account */ -using MPTID = base_uint<192>; +using MPTID = BaseUint<192>; /** Domain is a 256-bit hash representing a specific domain. */ -using Domain = base_uint<256>; +using Domain = BaseUint<256>; /** XRP currency. */ Currency const& @@ -62,7 +62,7 @@ badCurrency(); inline bool isXRP(Currency const& c) { - return c == beast::zero; + return c == beast::kZERO; } /** Returns "", "XRP", or three letter ISO code. */ @@ -77,7 +77,7 @@ to_string(Currency const& c); to rewrite some unit test code. */ bool -to_currency(Currency&, std::string const&); +toCurrency(Currency&, std::string const&); /** Tries to convert a string to a Currency, returns noCurrency() on failure. @@ -86,7 +86,7 @@ to_currency(Currency&, std::string const&); everywhere and may mean having to rewrite some unit test code. */ Currency -to_currency(std::string const&); +toCurrency(std::string const&); inline std::ostream& operator<<(std::ostream& os, Currency const& x) diff --git a/include/xrpl/protocol/Units.h b/include/xrpl/protocol/Units.h index 8faabd7138..dd5cfdeffd 100644 --- a/include/xrpl/protocol/Units.h +++ b/include/xrpl/protocol/Units.h @@ -117,7 +117,7 @@ public: template Other> constexpr ValueUnit(ValueUnit const& value) requires SafeToCast - : ValueUnit(safe_cast(value.value())) + : ValueUnit(safeCast(value.value())) { } @@ -209,7 +209,7 @@ public: return *this; } - template + template ValueUnit& operator%=(value_type const& rhs) { @@ -291,22 +291,22 @@ public: // known valid type tags can be converted to JSON. At the time // of implementation, that includes all known tags, but more may // be added in the future. - [[nodiscard]] Json::Value + [[nodiscard]] json::Value jsonClipped() const requires Usable { if constexpr (std::is_integral_v) { using jsontype = - std::conditional_t, Json::Int, Json::UInt>; + std::conditional_t, json::Int, json::UInt>; - constexpr auto min = std::numeric_limits::min(); - constexpr auto max = std::numeric_limits::max(); + constexpr auto kMIN = std::numeric_limits::min(); + constexpr auto kMAX = std::numeric_limits::max(); - if (value_ < min) - return min; - if (value_ > max) - return max; + if (value_ < kMIN) + return kMIN; + if (value_ > kMAX) + return kMAX; return static_cast(value_); } else @@ -392,14 +392,14 @@ mulDivU(Source1 value, Dest mul, Source2 div) } using desttype = typename Dest::value_type; - constexpr auto max = std::numeric_limits::max(); + constexpr auto kMAX = std::numeric_limits::max(); // Shortcuts, since these happen a lot in the real world if (value == div) return mul; if (mul.value() == div.value()) { - if (value.value() > max) + if (value.value() > kMAX) return std::nullopt; return Dest{static_cast(value.value())}; } @@ -414,7 +414,7 @@ mulDivU(Source1 value, Dest mul, Source2 div) auto quotient = product / div.value(); - if (quotient > max) + if (quotient > kMAX) return std::nullopt; return Dest{static_cast(quotient)}; @@ -494,34 +494,34 @@ mulDiv(std::uint64_t value, Source1 mul, Source2 div) template Src> constexpr Dest -safe_cast(Src s) noexcept +safeCast(Src s) noexcept { // Dest may not have an explicit value constructor - return Dest{safe_cast(s.value())}; + return Dest{safeCast(s.value())}; } template constexpr Dest -safe_cast(Src s) noexcept +safeCast(Src s) noexcept { // Dest may not have an explicit value constructor - return Dest{safe_cast(s)}; + return Dest{safeCast(s)}; } template Src> constexpr Dest -unsafe_cast(Src s) noexcept +unsafeCast(Src s) noexcept { // Dest may not have an explicit value constructor - return Dest{unsafe_cast(s.value())}; + return Dest{unsafeCast(s.value())}; } template constexpr Dest -unsafe_cast(Src s) noexcept +unsafeCast(Src s) noexcept { // Dest may not have an explicit value constructor - return Dest{unsafe_cast(s)}; + return Dest{unsafeCast(s)}; } } // namespace xrpl diff --git a/include/xrpl/protocol/XChainAttestations.h b/include/xrpl/protocol/XChainAttestations.h index 83bb6267a2..d8a35a29e3 100644 --- a/include/xrpl/protocol/XChainAttestations.h +++ b/include/xrpl/protocol/XChainAttestations.h @@ -42,13 +42,13 @@ struct AttestationBase bool wasLockingChainSend; explicit AttestationBase( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_); + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend); AttestationBase(AttestationBase const&) = default; @@ -63,7 +63,7 @@ struct AttestationBase protected: explicit AttestationBase(STObject const& o); - explicit AttestationBase(Json::Value const& v); + explicit AttestationBase(json::Value const& v); [[nodiscard]] static bool equalHelper(AttestationBase const& lhs, AttestationBase const& rhs); @@ -86,30 +86,30 @@ struct AttestationClaim : AttestationBase std::optional dst; explicit AttestationClaim( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t claimID_, - std::optional const& dst_); + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t claimId, + std::optional const& dst); explicit AttestationClaim( STXChainBridge const& bridge, - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - SecretKey const& secretKey_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t claimID_, - std::optional const& dst_); + AccountID attestationSignerAccount, + PublicKey const& publicKey, + SecretKey const& secretKey, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t claimId, + std::optional const& dst); explicit AttestationClaim(STObject const& o); - explicit AttestationClaim(Json::Value const& v); + explicit AttestationClaim(json::Value const& v); [[nodiscard]] STObject toSTObject() const; @@ -162,32 +162,32 @@ struct AttestationCreateAccount : AttestationBase explicit AttestationCreateAccount(STObject const& o); - explicit AttestationCreateAccount(Json::Value const& v); + explicit AttestationCreateAccount(json::Value const& v); explicit AttestationCreateAccount( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - STAmount rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t createCount_, - AccountID const& toCreate_); + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + STAmount rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t createCount, + AccountID const& toCreate); explicit AttestationCreateAccount( STXChainBridge const& bridge, - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - SecretKey const& secretKey_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - STAmount const& rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t createCount_, - AccountID const& toCreate_); + AccountID attestationSignerAccount, + PublicKey const& publicKey, + SecretKey const& secretKey, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + STAmount const& rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t createCount, + AccountID const& toCreate); [[nodiscard]] STObject toSTObject() const; @@ -232,17 +232,17 @@ struct CmpByCreateCount // Result when checking when two attestation match. enum class AttestationMatch { // One of the fields doesn't match, and it isn't the dst field - nonDstMismatch, + NonDstMismatch, // all of the fields match, except the dst field - matchExceptDst, + MatchExceptDst, // all of the fields match - match + Match }; struct XChainClaimAttestation { using TSignedAttestation = Attestations::AttestationClaim; - static SField const& ArrayFieldName; + static SField const& arrayFieldName; AccountID keyAccount; PublicKey publicKey; @@ -264,26 +264,26 @@ struct XChainClaimAttestation }; explicit XChainClaimAttestation( - AccountID const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, + AccountID const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + AccountID const& rewardAccount, + bool wasLockingChainSend, std::optional const& dst); explicit XChainClaimAttestation( - STAccount const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - STAccount const& rewardAccount_, - bool wasLockingChainSend_, + STAccount const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + STAccount const& rewardAccount, + bool wasLockingChainSend, std::optional const& dst); explicit XChainClaimAttestation(TSignedAttestation const& claimAtt); explicit XChainClaimAttestation(STObject const& o); - explicit XChainClaimAttestation(Json::Value const& v); + explicit XChainClaimAttestation(json::Value const& v); [[nodiscard]] AttestationMatch match(MatchFields const& rhs) const; @@ -298,7 +298,7 @@ struct XChainClaimAttestation struct XChainCreateAccountAttestation { using TSignedAttestation = Attestations::AttestationCreateAccount; - static SField const& ArrayFieldName; + static SField const& arrayFieldName; AccountID keyAccount; PublicKey publicKey; @@ -319,19 +319,19 @@ struct XChainCreateAccountAttestation }; explicit XChainCreateAccountAttestation( - AccountID const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - STAmount const& rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - AccountID const& dst_); + AccountID const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + STAmount const& rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + AccountID const& dst); explicit XChainCreateAccountAttestation(TSignedAttestation const& claimAtt); explicit XChainCreateAccountAttestation(STObject const& o); - explicit XChainCreateAccountAttestation(Json::Value const& v); + explicit XChainCreateAccountAttestation(json::Value const& v); [[nodiscard]] STObject toSTObject() const; @@ -357,7 +357,7 @@ private: // Set a max number of allowed attestations to limit the amount of memory // allocated and processing time. This number is much larger than the actual // number of attestation a server would ever expect. - static constexpr std::uint32_t maxAttestations = 256; + static constexpr std::uint32_t kMAX_ATTESTATIONS = 256; AttCollection attestations_; protected: @@ -372,7 +372,7 @@ public: explicit XChainAttestationsBase(AttCollection&& sigs); - explicit XChainAttestationsBase(Json::Value const& v); + explicit XChainAttestationsBase(json::Value const& v); explicit XChainAttestationsBase(STArray const& arr); @@ -393,7 +393,7 @@ public: template std::size_t - erase_if(F&& f); + eraseIf(F&& f); [[nodiscard]] std::size_t size() const; @@ -406,7 +406,7 @@ public: template void - emplace_back(T&& att); + emplaceBack(T&& att); }; template @@ -428,7 +428,7 @@ XChainAttestationsBase::attestations() const template template inline void -XChainAttestationsBase::emplace_back(T&& att) +XChainAttestationsBase::emplaceBack(T&& att) { attestations_.emplace_back(std::forward(att)); }; @@ -436,7 +436,7 @@ XChainAttestationsBase::emplace_back(T&& att) template template inline std::size_t -XChainAttestationsBase::erase_if(F&& f) +XChainAttestationsBase::eraseIf(F&& f) { return std::erase_if(attestations_, std::forward(f)); } diff --git a/include/xrpl/protocol/XRPAmount.h b/include/xrpl/protocol/XRPAmount.h index bc7ef891dc..067ea511da 100644 --- a/include/xrpl/protocol/XRPAmount.h +++ b/include/xrpl/protocol/XRPAmount.h @@ -195,21 +195,21 @@ public: * in contexts that don't expect the value to ever approach * the 32-bit limits (i.e. fees and reserves). */ - [[nodiscard]] Json::Value + [[nodiscard]] json::Value jsonClipped() const { static_assert( std::is_signed_v && std::is_integral_v, "Expected XRPAmount to be a signed integral type"); - constexpr auto min = std::numeric_limits::min(); - constexpr auto max = std::numeric_limits::max(); + constexpr auto kMIN = std::numeric_limits::min(); + constexpr auto kMAX = std::numeric_limits::max(); - if (drops_ < min) - return min; - if (drops_ > max) - return max; - return static_cast(drops_); + if (drops_ < kMIN) + return kMIN; + if (drops_ > kMAX) + return kMAX; + return static_cast(drops_); } /** Returns the underlying value. Code SHOULD NOT call this @@ -237,12 +237,12 @@ public: }; /** Number of drops per 1 XRP */ -constexpr XRPAmount DROPS_PER_XRP{1'000'000}; +constexpr XRPAmount kDROPS_PER_XRP{1'000'000}; constexpr double XRPAmount::decimalXRP() const { - return static_cast(drops_) / DROPS_PER_XRP.drops(); + return static_cast(drops_) / kDROPS_PER_XRP.drops(); } // Output XRPAmount as just the drops value. diff --git a/include/xrpl/protocol/detail/STVar.h b/include/xrpl/protocol/detail/STVar.h index c819740a90..52045965fd 100644 --- a/include/xrpl/protocol/detail/STVar.h +++ b/include/xrpl/protocol/detail/STVar.h @@ -9,18 +9,18 @@ namespace xrpl::detail { -struct defaultObject_t +struct DefaultObjectT { - explicit defaultObject_t() = default; + explicit DefaultObjectT() = default; }; -struct nonPresentObject_t +struct NonPresentObjectT { - explicit nonPresentObject_t() = default; + explicit NonPresentObjectT() = default; }; -extern defaultObject_t defaultObject; -extern nonPresentObject_t nonPresentObject; +extern DefaultObjectT gDefaultObject; +extern NonPresentObjectT gNonPresentObject; // Concept to constrain STVar constructors, which // instantiate ST* types from SerializedTypeID @@ -35,9 +35,9 @@ class STVar { private: // The largest "small object" we can accommodate - static std::size_t constexpr max_size = 72; + static std::size_t constexpr kMAX_SIZE = 72; - std::aligned_storage::type d_ = {}; + std::aligned_storage::type d_ = {}; STBase* p_ = nullptr; public: @@ -51,16 +51,16 @@ public: STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) { - p_ = t.move(max_size, &d_); + p_ = t.move(kMAX_SIZE, &d_); } STVar(STBase const& t) { - p_ = t.copy(max_size, &d_); + p_ = t.copy(kMAX_SIZE, &d_); } - STVar(defaultObject_t, SField const& name); - STVar(nonPresentObject_t, SField const& name); + STVar(DefaultObjectT, SField const& name); + STVar(NonPresentObjectT, SField const& name); STVar(SerialIter& sit, SField const& name, int depth = 0); STBase& @@ -96,7 +96,7 @@ public: template friend STVar - make_stvar(Args&&... args); + makeStvar(Args&&... args); private: STVar() = default; @@ -110,7 +110,7 @@ private: void construct(Args&&... args) { - if constexpr (sizeof(T) > max_size) + if constexpr (sizeof(T) > kMAX_SIZE) { p_ = new T(std::forward(args)...); } @@ -130,7 +130,7 @@ private: constructST(SerializedTypeID id, int depth, Args&&... arg); [[nodiscard]] bool - on_heap() const + onHeap() const { return static_cast(p_) != static_cast(&d_); } @@ -138,7 +138,7 @@ private: template inline STVar -make_stvar(Args&&... args) +makeStvar(Args&&... args) { STVar st; st.construct(std::forward(args)...); diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index ec0e159230..f860dc40c4 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -22,14 +22,14 @@ namespace b58_fast::detail { // This optimizes to what hand written asm would do (single divide) [[nodiscard]] inline std::tuple -div_rem(std::uint64_t a, std::uint64_t b) +divRem(std::uint64_t a, std::uint64_t b) { return {a / b, a % b}; } // This optimizes to what hand written asm would do (single multiply) [[nodiscard]] inline std::tuple -carrying_mul(std::uint64_t a, std::uint64_t b, std::uint64_t carry) +carryingMul(std::uint64_t a, std::uint64_t b, std::uint64_t carry) { unsigned __int128 const x = a; unsigned __int128 const y = b; @@ -38,7 +38,7 @@ carrying_mul(std::uint64_t a, std::uint64_t b, std::uint64_t carry) } [[nodiscard]] inline std::tuple -carrying_add(std::uint64_t a, std::uint64_t b) +carryingAdd(std::uint64_t a, std::uint64_t b) { unsigned __int128 const x = a; unsigned __int128 const y = b; @@ -52,58 +52,58 @@ carrying_add(std::uint64_t a, std::uint64_t b) // panics if overflows (this is a specialized adder for b58 decoding. // it should never overflow). [[nodiscard]] inline TokenCodecErrc -inplace_bigint_add(std::span a, std::uint64_t b) +inplaceBigintAdd(std::span a, std::uint64_t b) { if (a.size() <= 1) { - return TokenCodecErrc::inputTooSmall; + return TokenCodecErrc::InputTooSmall; } std::uint64_t carry = 0; - std::tie(a[0], carry) = carrying_add(a[0], b); + std::tie(a[0], carry) = carryingAdd(a[0], b); for (auto& v : a.subspan(1)) { if (carry == 0u) { - return TokenCodecErrc::success; + return TokenCodecErrc::Success; } - std::tie(v, carry) = carrying_add(v, 1); + std::tie(v, carry) = carryingAdd(v, 1); } if (carry != 0u) { - return TokenCodecErrc::overflowAdd; + return TokenCodecErrc::OverflowAdd; } - return TokenCodecErrc::success; + return TokenCodecErrc::Success; } [[nodiscard]] inline TokenCodecErrc -inplace_bigint_mul(std::span a, std::uint64_t b) +inplaceBigintMul(std::span a, std::uint64_t b) { if (a.empty()) { - return TokenCodecErrc::inputTooSmall; + return TokenCodecErrc::InputTooSmall; } - auto const last_index = a.size() - 1; - if (a[last_index] != 0) + auto const lastIndex = a.size() - 1; + if (a[lastIndex] != 0) { - return TokenCodecErrc::inputTooLarge; + return TokenCodecErrc::InputTooLarge; } std::uint64_t carry = 0; - for (auto& coeff : a.subspan(0, last_index)) + for (auto& coeff : a.subspan(0, lastIndex)) { - std::tie(coeff, carry) = carrying_mul(coeff, b, carry); + std::tie(coeff, carry) = carryingMul(coeff, b, carry); } - a[last_index] = carry; - return TokenCodecErrc::success; + a[lastIndex] = carry; + return TokenCodecErrc::Success; } // divide a "big uint" value inplace and return the mod // numerator is stored so smallest coefficients come first [[nodiscard]] inline std::uint64_t -inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) +inplaceBigintDivRem(std::span numerator, std::uint64_t divisor) { if (numerator.empty()) { @@ -111,60 +111,60 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) // the a null set of numbers to be zero, so the remainder is also zero. // LCOV_EXCL_START UNREACHABLE( - "xrpl::b58_fast::detail::inplace_bigint_div_rem : empty " + "xrpl::b58_fast::detail::inplaceBigintDivRem : empty " "numerator"); return 0; // LCOV_EXCL_STOP } - auto to_u128 = [](std::uint64_t high, std::uint64_t low) -> unsigned __int128 { + auto toU128 = [](std::uint64_t high, std::uint64_t low) -> unsigned __int128 { unsigned __int128 const high128 = high; unsigned __int128 const low128 = low; return ((high128 << 64) | low128); }; - auto div_rem_64 = [](unsigned __int128 num, - std::uint64_t denom) -> std::tuple { + auto divRe64 = [](unsigned __int128 num, + std::uint64_t denom) -> std::tuple { unsigned __int128 const denom128 = denom; unsigned __int128 const d = num / denom128; unsigned __int128 const r = num - (denom128 * d); XRPL_ASSERT( d >> 64 == 0, - "xrpl::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " + "xrpl::b58_fast::detail::inplaceBigintDivRem::divRe64 : " "valid division result"); XRPL_ASSERT( r >> 64 == 0, - "xrpl::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " + "xrpl::b58_fast::detail::inplaceBigintDivRem::divRe64 : " "valid remainder"); return {static_cast(d), static_cast(r)}; }; - std::uint64_t prev_rem = 0; - int const last_index = numerator.size() - 1; - std::tie(numerator[last_index], prev_rem) = div_rem(numerator[last_index], divisor); - for (int i = last_index - 1; i >= 0; --i) + std::uint64_t prevRem = 0; + int const lastIndex = numerator.size() - 1; + std::tie(numerator[lastIndex], prevRem) = divRem(numerator[lastIndex], divisor); + for (int i = lastIndex - 1; i >= 0; --i) { - unsigned __int128 const cur_num = to_u128(prev_rem, numerator[i]); - std::tie(numerator[i], prev_rem) = div_rem_64(cur_num, divisor); + unsigned __int128 const curNum = toU128(prevRem, numerator[i]); + std::tie(numerator[i], prevRem) = divRe64(curNum, divisor); } - return prev_rem; + return prevRem; } // convert from base 58^10 to base 58 // put largest coeffs first // the `_be` suffix stands for "big endian" [[nodiscard]] inline std::array -b58_10_to_b58_be(std::uint64_t input) +b5810ToB58Be(std::uint64_t input) { - [[maybe_unused]] static constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10; - XRPL_ASSERT(input < B_58_10, "xrpl::b58_fast::detail::b58_10_to_b58_be : valid input"); - constexpr std::size_t resultSize = 10; - std::array result{}; + [[maybe_unused]] static constexpr std::uint64_t kB_58_10 = 430804206899405824; // 58^10; + XRPL_ASSERT(input < kB_58_10, "xrpl::b58_fast::detail::b5810ToB58Be : valid input"); + constexpr std::size_t kRESULT_SIZE = 10; + std::array result{}; int i = 0; while (input > 0) { std::uint64_t rem = 0; - std::tie(input, rem) = div_rem(input, 58); - result[resultSize - 1 - i] = rem; + std::tie(input, rem) = divRem(input, 58); + result[kRESULT_SIZE - 1 - i] = rem; i += 1; } diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro index 8fbc28123f..78b78e132e 100644 --- a/include/xrpl/protocol/detail/features.macro +++ b/include/xrpl/protocol/detail/features.macro @@ -15,62 +15,62 @@ // Add new amendments to the top of this list. // Keep it sorted in reverse chronological order. -XRPL_FIX (Cleanup3_2_0, Supported::no, VoteBehavior::DefaultNo) -XRPL_FEATURE(MPTokensV2, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (Security3_1_3, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (PermissionedDomainInvariant, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (BatchInnerSigs, Supported::no, VoteBehavior::DefaultNo) -XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(PermissionDelegationV1_1, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (DirectoryLimit, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (IncludeKeyletFields, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(DynamicMPT, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (TokenEscrowV1, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (PriceOracleOrder, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (MPTDeliveredAmount, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (AMMClawbackRounding, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(TokenEscrow, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (EnforceNFTokenTrustlineV2, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (AMMv1_3, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(PermissionedDEX, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(Batch, Supported::no, VoteBehavior::DefaultNo) -XRPL_FEATURE(SingleAssetVault, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (PayChanCancelAfter, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (Cleanup3_2_0, Supported::No, VoteBehavior::DefaultNo) +XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo) +XRPL_FIX (Security3_1_3, Supported::No, VoteBehavior::DefaultNo) +XRPL_FIX (PermissionedDomainInvariant, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (BatchInnerSigs, Supported::No, VoteBehavior::DefaultNo) +XRPL_FEATURE(LendingProtocol, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(PermissionDelegationV1_1, Supported::No, VoteBehavior::DefaultNo) +XRPL_FIX (DirectoryLimit, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (IncludeKeyletFields, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DynamicMPT, Supported::No, VoteBehavior::DefaultNo) +XRPL_FIX (TokenEscrowV1, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (PriceOracleOrder, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (MPTDeliveredAmount, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMClawbackRounding, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(TokenEscrow, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (EnforceNFTokenTrustlineV2, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMv1_3, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(PermissionedDEX, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(Batch, Supported::No, VoteBehavior::DefaultNo) +XRPL_FEATURE(SingleAssetVault, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (PayChanCancelAfter, Supported::Yes, VoteBehavior::DefaultNo) // Check flags in Credential transactions -XRPL_FIX (InvalidTxFlags, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (FrozenLPTokenTransfer, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(DeepFreeze, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(PermissionedDomains, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(DynamicNFT, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo) -// InvariantsV1_1 will be changed to Supported::yes when all the invariants expected to be included -// under it are complete. -XRPL_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (NFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (InnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (EnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (ReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (AMMv1_1, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (PreviousTxnID, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (XChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (EmptyDID, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(PriceOracle, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (AMMOverflowOffer, Supported::yes, VoteBehavior::DefaultYes) -XRPL_FIX (InnerObjTemplate, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (NFTokenReserve, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (FillOrKill, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (DisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo) -XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (InvalidTxFlags, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (FrozenLPTokenTransfer, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DeepFreeze, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(PermissionedDomains, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DynamicNFT, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(Credentials, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(AMMClawback, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMv1_2, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(MPTokensV1, Supported::Yes, VoteBehavior::DefaultNo) +// InvariantsV1_1 will be changes to Supported::yes when all the +// invariants expected to be included under it are complete. +XRPL_FEATURE(InvariantsV1_1, Supported::No, VoteBehavior::DefaultNo) +XRPL_FIX (NFTokenPageLinks, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (InnerObjTemplate2, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (EnforceNFTokenTrustline, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (ReducedOffersV2, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(NFTokenMintOffer, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMv1_1, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (PreviousTxnID, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (XChainRewardRounding, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (EmptyDID, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(PriceOracle, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMOverflowOffer, Supported::Yes, VoteBehavior::DefaultYes) +XRPL_FIX (InnerObjTemplate, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (NFTokenReserve, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (FillOrKill, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DID, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (DisallowIncomingV1, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(AMM, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(Clawback, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (UniversalNumber, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(XRPFees, Supported::Yes, VoteBehavior::DefaultNo) +XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::Yes, VoteBehavior::DefaultYes) // The following amendments are obsolete, but must remain supported // because they could potentially get enabled. diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 93cef79ef7..bf641862d1 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -24,15 +24,15 @@ \sa keylet::nftoffer */ LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, nft_offer, ({ - {sfOwner, soeREQUIRED}, - {sfNFTokenID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfNFTokenOfferNode, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfOwner, SoeRequired}, + {sfNFTokenID, SoeRequired}, + {sfAmount, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfNFTokenOfferNode, SoeRequired}, + {sfDestination, SoeOptional}, + {sfExpiration, SoeOptional}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which describes a check. @@ -40,18 +40,18 @@ LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, nft_offer, ({ \sa keylet::check */ LEDGER_ENTRY(ltCHECK, 0x0043, Check, check, ({ - {sfAccount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSendMax, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfDestinationNode, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfInvoiceID, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfDestination, SoeRequired}, + {sfSendMax, SoeRequired}, + {sfSequence, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfDestinationNode, SoeRequired}, + {sfExpiration, SoeOptional}, + {sfInvoiceID, SoeOptional}, + {sfSourceTag, SoeOptional}, + {sfDestinationTag, SoeOptional}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** The ledger object which tracks the DID. @@ -59,13 +59,13 @@ LEDGER_ENTRY(ltCHECK, 0x0043, Check, check, ({ \sa keylet::did */ LEDGER_ENTRY(ltDID, 0x0049, DID, did, ({ - {sfAccount, soeREQUIRED}, - {sfDIDDocument, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfData, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfDIDDocument, SoeOptional}, + {sfURI, SoeOptional}, + {sfData, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** The ledger object which tracks the current negative UNL state. @@ -75,11 +75,11 @@ LEDGER_ENTRY(ltDID, 0x0049, DID, did, ({ \sa keylet::negativeUNL */ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({ - {sfDisabledValidators, soeOPTIONAL}, - {sfValidatorToDisable, soeOPTIONAL}, - {sfValidatorToReEnable, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, + {sfDisabledValidators, SoeOptional}, + {sfValidatorToDisable, SoeOptional}, + {sfValidatorToReEnable, SoeOptional}, + {sfPreviousTxnID, SoeOptional}, + {sfPreviousTxnLgrSeq, SoeOptional}, })) /** A ledger object which contains a list of NFTs @@ -87,27 +87,27 @@ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({ \sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage */ LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({ - {sfPreviousPageMin, soeOPTIONAL}, - {sfNextPageMin, soeOPTIONAL}, - {sfNFTokens, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfPreviousPageMin, SoeOptional}, + {sfNextPageMin, SoeOptional}, + {sfNFTokens, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which contains a signer list for an account. \sa keylet::signers */ -// All fields are soeREQUIRED because there is always a SignerEntries. +// All fields are SoeRequired because there is always a SignerEntries. // If there are no SignerEntries the node is deleted. LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({ - {sfOwner, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfSignerQuorum, soeREQUIRED}, - {sfSignerEntries, soeREQUIRED}, - {sfSignerListID, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfOwner, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfSignerQuorum, SoeRequired}, + {sfSignerEntries, SoeRequired}, + {sfSignerListID, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which describes a ticket. @@ -115,11 +115,11 @@ LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({ \sa keylet::ticket */ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({ - {sfAccount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfTicketSequence, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfTicketSequence, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which describes an account. @@ -127,29 +127,29 @@ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({ \sa keylet::account */ LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({ - {sfAccount, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfBalance, soeREQUIRED}, - {sfOwnerCount, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfAccountTxnID, soeOPTIONAL}, - {sfRegularKey, soeOPTIONAL}, - {sfEmailHash, soeOPTIONAL}, - {sfWalletLocator, soeOPTIONAL}, - {sfWalletSize, soeOPTIONAL}, - {sfMessageKey, soeOPTIONAL}, - {sfTransferRate, soeOPTIONAL}, - {sfDomain, soeOPTIONAL}, - {sfTickSize, soeOPTIONAL}, - {sfTicketCount, soeOPTIONAL}, - {sfNFTokenMinter, soeOPTIONAL}, - {sfMintedNFTokens, soeDEFAULT}, - {sfBurnedNFTokens, soeDEFAULT}, - {sfFirstNFTokenSequence, soeOPTIONAL}, - {sfAMMID, soeOPTIONAL}, // pseudo-account designator - {sfVaultID, soeOPTIONAL}, // pseudo-account designator - {sfLoanBrokerID, soeOPTIONAL}, // pseudo-account designator + {sfAccount, SoeRequired}, + {sfSequence, SoeRequired}, + {sfBalance, SoeRequired}, + {sfOwnerCount, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfAccountTxnID, SoeOptional}, + {sfRegularKey, SoeOptional}, + {sfEmailHash, SoeOptional}, + {sfWalletLocator, SoeOptional}, + {sfWalletSize, SoeOptional}, + {sfMessageKey, SoeOptional}, + {sfTransferRate, SoeOptional}, + {sfDomain, SoeOptional}, + {sfTickSize, SoeOptional}, + {sfTicketCount, SoeOptional}, + {sfNFTokenMinter, SoeOptional}, + {sfMintedNFTokens, SoeDefault}, + {sfBurnedNFTokens, SoeDefault}, + {sfFirstNFTokenSequence, SoeOptional}, + {sfAMMID, SoeOptional}, // pseudo-account designator + {sfVaultID, SoeOptional}, // pseudo-account designator + {sfLoanBrokerID, SoeOptional}, // pseudo-account designator })) /** A ledger object which contains a list of object identifiers. @@ -158,22 +158,22 @@ LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({ keylet::ownerDir */ LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, directory, ({ - {sfOwner, soeOPTIONAL}, // for owner directories - {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories - {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories - {sfTakerPaysMPT, soeOPTIONAL}, // order book directories - {sfTakerGetsCurrency, soeOPTIONAL}, // order book directories - {sfTakerGetsIssuer, soeOPTIONAL}, // order book directories - {sfTakerGetsMPT, soeOPTIONAL}, // order book directories - {sfExchangeRate, soeOPTIONAL}, // order book directories - {sfIndexes, soeREQUIRED}, - {sfRootIndex, soeREQUIRED}, - {sfIndexNext, soeOPTIONAL}, - {sfIndexPrevious, soeOPTIONAL}, - {sfNFTokenID, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL} // order book directories + {sfOwner, SoeOptional}, // for owner directories + {sfTakerPaysCurrency, SoeOptional}, // order book directories + {sfTakerPaysIssuer, SoeOptional}, // order book directories + {sfTakerPaysMPT, SoeOptional}, // order book directories + {sfTakerGetsCurrency, SoeOptional}, // order book directories + {sfTakerGetsIssuer, SoeOptional}, // order book directories + {sfTakerGetsMPT, SoeOptional}, // order book directories + {sfExchangeRate, SoeOptional}, // order book directories + {sfIndexes, SoeRequired}, + {sfRootIndex, SoeRequired}, + {sfIndexNext, SoeOptional}, + {sfIndexPrevious, SoeOptional}, + {sfNFTokenID, SoeOptional}, + {sfPreviousTxnID, SoeOptional}, + {sfPreviousTxnLgrSeq, SoeOptional}, + {sfDomainID, SoeOptional} // order book directories })) /** The ledger object which lists details about amendments on the network. @@ -183,10 +183,10 @@ LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, directory, ({ \sa keylet::amendments */ LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, amendments, ({ - {sfAmendments, soeOPTIONAL}, // Enabled - {sfMajorities, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, + {sfAmendments, SoeOptional}, // Enabled + {sfMajorities, SoeOptional}, + {sfPreviousTxnID, SoeOptional}, + {sfPreviousTxnLgrSeq, SoeOptional}, })) /** A ledger object that contains a list of ledger hashes. @@ -198,9 +198,9 @@ LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, amendments, ({ \sa keylet::skip */ LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, hashes, ({ - {sfFirstLedgerSequence, soeOPTIONAL}, - {sfLastLedgerSequence, soeOPTIONAL}, - {sfHashes, soeREQUIRED}, + {sfFirstLedgerSequence, SoeOptional}, + {sfLastLedgerSequence, SoeOptional}, + {sfHashes, SoeRequired}, })) /** The ledger object which lists details about sidechains. @@ -208,16 +208,16 @@ LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, hashes, ({ \sa keylet::bridge */ LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, bridge, ({ - {sfAccount, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfMinAccountCreateAmount, soeOPTIONAL}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfXChainAccountClaimCount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfSignatureReward, SoeRequired}, + {sfMinAccountCreateAmount, SoeOptional}, + {sfXChainBridge, SoeRequired}, + {sfXChainClaimID, SoeRequired}, + {sfXChainAccountCreateCount, SoeRequired}, + {sfXChainAccountClaimCount, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which describes an offer on the DEX. @@ -225,18 +225,18 @@ LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, bridge, ({ \sa keylet::offer */ LEDGER_ENTRY(ltOFFER, 0x006f, Offer, offer, ({ - {sfAccount, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfTakerPays, soeREQUIRED}, - {sfTakerGets, soeREQUIRED}, - {sfBookDirectory, soeREQUIRED}, - {sfBookNode, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, - {sfAdditionalBooks, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfSequence, SoeRequired}, + {sfTakerPays, SoeRequired}, + {sfTakerGets, SoeRequired}, + {sfBookDirectory, SoeRequired}, + {sfBookNode, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfExpiration, SoeOptional}, + {sfDomainID, SoeOptional}, + {sfAdditionalBooks, SoeOptional}, })) /** A ledger object which describes a deposit pre-authorization. @@ -244,12 +244,12 @@ LEDGER_ENTRY(ltOFFER, 0x006f, Offer, offer, ({ \sa keylet::depositPreauth */ LEDGER_ENTRY_DUPLICATE(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preauth, ({ - {sfAccount, soeREQUIRED}, - {sfAuthorize, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfAuthorizeCredentials, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfAuthorize, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfAuthorizeCredentials, SoeOptional}, })) /** A claim id for a cross chain transaction. @@ -257,15 +257,15 @@ LEDGER_ENTRY_DUPLICATE(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preaut \sa keylet::xChainClaimID */ LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, xchain_owned_claim_id, ({ - {sfAccount, soeREQUIRED}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfXChainClaimAttestations, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfXChainBridge, SoeRequired}, + {sfXChainClaimID, SoeRequired}, + {sfOtherChainSource, SoeRequired}, + {sfXChainClaimAttestations, SoeRequired}, + {sfSignatureReward, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which describes a bidirectional trust line. @@ -275,17 +275,17 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, xchain_owned_c \sa keylet::line */ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({ - {sfBalance, soeREQUIRED}, - {sfLowLimit, soeREQUIRED}, - {sfHighLimit, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfLowNode, soeOPTIONAL}, - {sfLowQualityIn, soeOPTIONAL}, - {sfLowQualityOut, soeOPTIONAL}, - {sfHighNode, soeOPTIONAL}, - {sfHighQualityIn, soeOPTIONAL}, - {sfHighQualityOut, soeOPTIONAL}, + {sfBalance, SoeRequired}, + {sfLowLimit, SoeRequired}, + {sfHighLimit, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfLowNode, SoeOptional}, + {sfLowQualityIn, SoeOptional}, + {sfLowQualityOut, SoeOptional}, + {sfHighNode, SoeOptional}, + {sfHighQualityIn, SoeOptional}, + {sfHighQualityOut, SoeOptional}, })) /** The ledger object which lists the network's fee settings. @@ -296,16 +296,16 @@ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({ */ LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({ // Old version uses raw numbers - {sfBaseFee, soeOPTIONAL}, - {sfReferenceFeeUnits, soeOPTIONAL}, - {sfReserveBase, soeOPTIONAL}, - {sfReserveIncrement, soeOPTIONAL}, + {sfBaseFee, SoeOptional}, + {sfReferenceFeeUnits, SoeOptional}, + {sfReserveBase, SoeOptional}, + {sfReserveIncrement, SoeOptional}, // New version uses Amounts - {sfBaseFeeDrops, soeOPTIONAL}, - {sfReserveBaseDrops, soeOPTIONAL}, - {sfReserveIncrementDrops, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, + {sfBaseFeeDrops, SoeOptional}, + {sfReserveBaseDrops, SoeOptional}, + {sfReserveIncrementDrops, SoeOptional}, + {sfPreviousTxnID, SoeOptional}, + {sfPreviousTxnLgrSeq, SoeOptional}, })) /** A claim id for a cross chain create account transaction. @@ -313,13 +313,13 @@ LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({ \sa keylet::xChainCreateAccountClaimID */ LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAccountClaimID, xchain_owned_create_account_claim_id, ({ - {sfAccount, soeREQUIRED}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfXChainCreateAccountAttestations, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfXChainBridge, SoeRequired}, + {sfXChainAccountCreateCount, SoeRequired}, + {sfXChainCreateAccountAttestations, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object describing a single escrow. @@ -327,21 +327,21 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAc \sa keylet::escrow */ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({ - {sfAccount, soeREQUIRED}, - {sfSequence, soeOPTIONAL}, - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfCondition, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfFinishAfter, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfDestinationNode, soeOPTIONAL}, - {sfTransferRate, soeOPTIONAL}, - {sfIssuerNode, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfSequence, SoeOptional}, + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired}, + {sfCondition, SoeOptional}, + {sfCancelAfter, SoeOptional}, + {sfFinishAfter, SoeOptional}, + {sfSourceTag, SoeOptional}, + {sfDestinationTag, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfDestinationNode, SoeOptional}, + {sfTransferRate, SoeOptional}, + {sfIssuerNode, SoeOptional}, })) /** A ledger object describing a single unidirectional XRP payment channel. @@ -349,21 +349,21 @@ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({ \sa keylet::payChan */ LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, payment_channel, ({ - {sfAccount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSequence, soeOPTIONAL}, - {sfAmount, soeREQUIRED}, - {sfBalance, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSettleDelay, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfDestinationNode, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfDestination, SoeRequired}, + {sfSequence, SoeOptional}, + {sfAmount, SoeRequired}, + {sfBalance, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfSettleDelay, SoeRequired}, + {sfExpiration, SoeOptional}, + {sfCancelAfter, SoeOptional}, + {sfSourceTag, SoeOptional}, + {sfDestinationTag, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfDestinationNode, SoeOptional}, })) /** The ledger object which tracks the AMM. @@ -371,125 +371,125 @@ LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, payment_channel, ({ \sa keylet::amm */ LEDGER_ENTRY(ltAMM, 0x0079, AMM, amm, ({ - {sfAccount, soeREQUIRED}, - {sfTradingFee, soeDEFAULT}, - {sfVoteSlots, soeOPTIONAL}, - {sfAuctionSlot, soeOPTIONAL}, - {sfLPTokenBalance, soeREQUIRED}, - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfTradingFee, SoeDefault}, + {sfVoteSlots, SoeOptional}, + {sfAuctionSlot, SoeOptional}, + {sfLPTokenBalance, SoeRequired}, + {sfAsset, SoeRequired}, + {sfAsset2, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeOptional}, + {sfPreviousTxnLgrSeq, SoeOptional}, })) /** A ledger object which tracks MPTokenIssuance \sa keylet::mptIssuance */ LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, mpt_issuance, ({ - {sfIssuer, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfTransferFee, soeDEFAULT}, - {sfOwnerNode, soeREQUIRED}, - {sfAssetScale, soeDEFAULT}, - {sfMaximumAmount, soeOPTIONAL}, - {sfOutstandingAmount, soeREQUIRED}, - {sfLockedAmount, soeOPTIONAL}, - {sfMPTokenMetadata, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfDomainID, soeOPTIONAL}, - {sfMutableFlags, soeDEFAULT}, + {sfIssuer, SoeRequired}, + {sfSequence, SoeRequired}, + {sfTransferFee, SoeDefault}, + {sfOwnerNode, SoeRequired}, + {sfAssetScale, SoeDefault}, + {sfMaximumAmount, SoeOptional}, + {sfOutstandingAmount, SoeRequired}, + {sfLockedAmount, SoeOptional}, + {sfMPTokenMetadata, SoeOptional}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfDomainID, SoeOptional}, + {sfMutableFlags, SoeDefault}, })) /** A ledger object which tracks MPToken \sa keylet::mptoken */ LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, mptoken, ({ - {sfAccount, soeREQUIRED}, - {sfMPTokenIssuanceID, soeREQUIRED}, - {sfMPTAmount, soeDEFAULT}, - {sfLockedAmount, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfMPTokenIssuanceID, SoeRequired}, + {sfMPTAmount, SoeDefault}, + {sfLockedAmount, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which tracks Oracle \sa keylet::oracle */ LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, oracle, ({ - {sfOwner, soeREQUIRED}, - {sfOracleDocumentID, soeOPTIONAL}, - {sfProvider, soeREQUIRED}, - {sfPriceDataSeries, soeREQUIRED}, - {sfAssetClass, soeREQUIRED}, - {sfLastUpdateTime, soeREQUIRED}, - {sfURI, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfOwner, SoeRequired}, + {sfOracleDocumentID, SoeOptional}, + {sfProvider, SoeRequired}, + {sfPriceDataSeries, SoeRequired}, + {sfAssetClass, SoeRequired}, + {sfLastUpdateTime, SoeRequired}, + {sfURI, SoeOptional}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which tracks Credential \sa keylet::credential */ LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, credential, ({ - {sfSubject, soeREQUIRED}, - {sfIssuer, soeREQUIRED}, - {sfCredentialType, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfIssuerNode, soeREQUIRED}, - {sfSubjectNode, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfSubject, SoeRequired}, + {sfIssuer, SoeRequired}, + {sfCredentialType, SoeRequired}, + {sfExpiration, SoeOptional}, + {sfURI, SoeOptional}, + {sfIssuerNode, SoeRequired}, + {sfSubjectNode, SoeOptional}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object which tracks PermissionedDomain \sa keylet::permissionedDomain */ LEDGER_ENTRY(ltPERMISSIONED_DOMAIN, 0x0082, PermissionedDomain, permissioned_domain, ({ - {sfOwner, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfAcceptedCredentials, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfOwner, SoeRequired}, + {sfSequence, SoeRequired}, + {sfAcceptedCredentials, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object representing permissions an account has delegated to another account. \sa keylet::delegate */ LEDGER_ENTRY(ltDELEGATE, 0x0083, Delegate, delegate, ({ - {sfAccount, soeREQUIRED}, - {sfAuthorize, soeREQUIRED}, - {sfPermissions, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfDestinationNode, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfAuthorize, SoeRequired}, + {sfPermissions, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfDestinationNode, SoeOptional}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, })) /** A ledger object representing a single asset vault. \sa keylet::vault */ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({ - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfOwner, soeREQUIRED}, - {sfAccount, soeREQUIRED}, - {sfData, soeOPTIONAL}, - {sfAsset, soeREQUIRED}, - {sfAssetsTotal, soeDEFAULT}, - {sfAssetsAvailable, soeDEFAULT}, - {sfAssetsMaximum, soeDEFAULT}, - {sfLossUnrealized, soeDEFAULT}, - {sfShareMPTID, soeREQUIRED}, - {sfWithdrawalPolicy, soeREQUIRED}, - {sfScale, soeDEFAULT}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfSequence, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfOwner, SoeRequired}, + {sfAccount, SoeRequired}, + {sfData, SoeOptional}, + {sfAsset, SoeRequired}, + {sfAssetsTotal, SoeDefault}, + {sfAssetsAvailable, SoeDefault}, + {sfAssetsMaximum, SoeDefault}, + {sfLossUnrealized, SoeDefault}, + {sfShareMPTID, SoeRequired}, + {sfWithdrawalPolicy, SoeRequired}, + {sfScale, SoeDefault}, // no SharesTotal ever (use MPTIssuance.sfOutstandingAmount) // no PermissionedDomainID ever (use MPTIssuance.sfDomainID) })) @@ -501,23 +501,23 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({ \sa keylet::loanbroker */ LEDGER_ENTRY(ltLOAN_BROKER, 0x0088, LoanBroker, loan_broker, ({ - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfVaultNode, soeREQUIRED}, - {sfVaultID, soeREQUIRED}, - {sfAccount, soeREQUIRED}, - {sfOwner, soeREQUIRED}, - {sfLoanSequence, soeREQUIRED}, - {sfData, soeDEFAULT}, - {sfManagementFeeRate, soeDEFAULT}, - {sfOwnerCount, soeDEFAULT}, - {sfDebtTotal, soeDEFAULT}, - {sfDebtMaximum, soeDEFAULT}, - {sfCoverAvailable, soeDEFAULT}, - {sfCoverRateMinimum, soeDEFAULT}, - {sfCoverRateLiquidation, soeDEFAULT}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfSequence, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfVaultNode, SoeRequired}, + {sfVaultID, SoeRequired}, + {sfAccount, SoeRequired}, + {sfOwner, SoeRequired}, + {sfLoanSequence, SoeRequired}, + {sfData, SoeDefault}, + {sfManagementFeeRate, SoeDefault}, + {sfOwnerCount, SoeDefault}, + {sfDebtTotal, SoeDefault}, + {sfDebtMaximum, SoeDefault}, + {sfCoverAvailable, SoeDefault}, + {sfCoverRateMinimum, SoeDefault}, + {sfCoverRateLiquidation, SoeDefault}, })) /** A ledger object representing a loan between a Borrower and a Loan Broker @@ -525,27 +525,27 @@ LEDGER_ENTRY(ltLOAN_BROKER, 0x0088, LoanBroker, loan_broker, ({ \sa keylet::loan */ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({ - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfLoanBrokerNode, soeREQUIRED}, - {sfLoanBrokerID, soeREQUIRED}, - {sfLoanSequence, soeREQUIRED}, - {sfBorrower, soeREQUIRED}, - {sfLoanOriginationFee, soeDEFAULT}, - {sfLoanServiceFee, soeDEFAULT}, - {sfLatePaymentFee, soeDEFAULT}, - {sfClosePaymentFee, soeDEFAULT}, - {sfOverpaymentFee, soeDEFAULT}, - {sfInterestRate, soeDEFAULT}, - {sfLateInterestRate, soeDEFAULT}, - {sfCloseInterestRate, soeDEFAULT}, - {sfOverpaymentInterestRate, soeDEFAULT}, - {sfStartDate, soeREQUIRED}, - {sfPaymentInterval, soeREQUIRED}, - {sfGracePeriod, soeDEFAULT}, - {sfPreviousPaymentDueDate, soeDEFAULT}, - {sfNextPaymentDueDate, soeDEFAULT}, + {sfPreviousTxnID, SoeRequired}, + {sfPreviousTxnLgrSeq, SoeRequired}, + {sfOwnerNode, SoeRequired}, + {sfLoanBrokerNode, SoeRequired}, + {sfLoanBrokerID, SoeRequired}, + {sfLoanSequence, SoeRequired}, + {sfBorrower, SoeRequired}, + {sfLoanOriginationFee, SoeDefault}, + {sfLoanServiceFee, SoeDefault}, + {sfLatePaymentFee, SoeDefault}, + {sfClosePaymentFee, SoeDefault}, + {sfOverpaymentFee, SoeDefault}, + {sfInterestRate, SoeDefault}, + {sfLateInterestRate, SoeDefault}, + {sfCloseInterestRate, SoeDefault}, + {sfOverpaymentInterestRate, SoeDefault}, + {sfStartDate, SoeRequired}, + {sfPaymentInterval, SoeRequired}, + {sfGracePeriod, SoeDefault}, + {sfPreviousPaymentDueDate, SoeDefault}, + {sfNextPaymentDueDate, SoeDefault}, // The loan object tracks these values: // // - PaymentRemaining: The number of payments left in the loan. When it @@ -593,17 +593,17 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({ // // Note the the "True" values may differ significantly from the tracked // rounded values. - {sfPaymentRemaining, soeDEFAULT}, - {sfPeriodicPayment, soeREQUIRED}, - {sfPrincipalOutstanding, soeDEFAULT}, - {sfTotalValueOutstanding, soeDEFAULT}, - {sfManagementFeeOutstanding, soeDEFAULT}, + {sfPaymentRemaining, SoeDefault}, + {sfPeriodicPayment, SoeRequired}, + {sfPrincipalOutstanding, SoeDefault}, + {sfTotalValueOutstanding, SoeDefault}, + {sfManagementFeeOutstanding, SoeDefault}, // Based on the computed total value at creation, used for // rounding calculated values so they are all on a // consistent scale - that is, they all have the same // number of digits after the decimal point (excluding // trailing zeros). - {sfLoanScale, soeDEFAULT}, + {sfLoanScale, SoeDefault}, })) #undef EXPAND diff --git a/include/xrpl/protocol/detail/secp256k1.h b/include/xrpl/protocol/detail/secp256k1.h index 0ac810fd80..17dfa3ff25 100644 --- a/include/xrpl/protocol/detail/secp256k1.h +++ b/include/xrpl/protocol/detail/secp256k1.h @@ -8,20 +8,20 @@ template secp256k1_context const* secp256k1Context() { - struct holder + struct Holder { secp256k1_context* impl; - holder() : impl(secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN)) + Holder() : impl(secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN)) { } - ~holder() + ~Holder() { secp256k1_context_destroy(impl); } }; - static holder const h; - return h.impl; + static Holder const kH; + return kH.impl; } } // namespace xrpl diff --git a/include/xrpl/protocol/detail/sfields.macro b/include/xrpl/protocol/detail/sfields.macro index 4f21207831..3637acc1c4 100644 --- a/include/xrpl/protocol/detail/sfields.macro +++ b/include/xrpl/protocol/detail/sfields.macro @@ -27,7 +27,7 @@ TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19) TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20) // 16-bit integers (common) -TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::sMD_Never) +TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::SMdNever) TYPED_SFIELD(sfTransactionType, UINT16, 2) TYPED_SFIELD(sfSignerWeight, UINT16, 3) TYPED_SFIELD(sfTransferFee, UINT16, 4) @@ -48,7 +48,7 @@ TYPED_SFIELD(sfNetworkID, UINT32, 1) TYPED_SFIELD(sfFlags, UINT32, 2) TYPED_SFIELD(sfSourceTag, UINT32, 3) TYPED_SFIELD(sfSequence, UINT32, 4) -TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::sMD_DeleteFinal) +TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::SMdDeleteFinal) TYPED_SFIELD(sfLedgerSequence, UINT32, 6) TYPED_SFIELD(sfCloseTime, UINT32, 7) TYPED_SFIELD(sfParentCloseTime, UINT32, 8) @@ -138,12 +138,12 @@ TYPED_SFIELD(sfXChainClaimID, UINT64, 20) TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21) TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22) TYPED_SFIELD(sfAssetPrice, UINT64, 23) -TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::sMD_BaseTen|SField::sMD_Default) -TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::sMD_BaseTen|SField::sMD_Default) -TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::sMD_BaseTen|SField::sMD_Default) +TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::SMdBaseTen|SField::SMdDefault) +TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::SMdBaseTen|SField::SMdDefault) +TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::SMdBaseTen|SField::SMdDefault) TYPED_SFIELD(sfIssuerNode, UINT64, 27) TYPED_SFIELD(sfSubjectNode, UINT64, 28) -TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::sMD_BaseTen|SField::sMD_Default) +TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::SMdBaseTen|SField::SMdDefault) TYPED_SFIELD(sfVaultNode, UINT64, 30) TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31) @@ -167,17 +167,17 @@ TYPED_SFIELD(sfLedgerHash, UINT256, 1) TYPED_SFIELD(sfParentHash, UINT256, 2) TYPED_SFIELD(sfTransactionHash, UINT256, 3) TYPED_SFIELD(sfAccountHash, UINT256, 4) -TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::sMD_DeleteFinal) +TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::SMdDeleteFinal) TYPED_SFIELD(sfLedgerIndex, UINT256, 6) TYPED_SFIELD(sfWalletLocator, UINT256, 7) -TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::sMD_Always) +TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::SMdAlways) TYPED_SFIELD(sfAccountTxnID, UINT256, 9) TYPED_SFIELD(sfNFTokenID, UINT256, 10) TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11) TYPED_SFIELD(sfEmitNonce, UINT256, 12) TYPED_SFIELD(sfEmitHookHash, UINT256, 13) TYPED_SFIELD(sfAMMID, UINT256, 14, - SField::sMD_PseudoAccount | SField::sMD_Default) + SField::SMdPseudoAccount | SField::SMdDefault) // 256-bit (uncommon) TYPED_SFIELD(sfBookDirectory, UINT256, 16) @@ -200,30 +200,30 @@ TYPED_SFIELD(sfHookNamespace, UINT256, 32) TYPED_SFIELD(sfHookSetTxnID, UINT256, 33) TYPED_SFIELD(sfDomainID, UINT256, 34) TYPED_SFIELD(sfVaultID, UINT256, 35, - SField::sMD_PseudoAccount | SField::sMD_Default) + SField::SMdPseudoAccount | SField::SMdDefault) TYPED_SFIELD(sfParentBatchID, UINT256, 36) TYPED_SFIELD(sfLoanBrokerID, UINT256, 37, - SField::sMD_PseudoAccount | SField::sMD_Default) + SField::SMdPseudoAccount | SField::SMdDefault) TYPED_SFIELD(sfLoanID, UINT256, 38) // number (common) TYPED_SFIELD(sfNumber, NUMBER, 1) -TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::sMD_NeedsAsset | SField::sMD_Default) -TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::sMD_NeedsAsset | SField::sMD_Default) +TYPED_SFIELD(sfAssetsAvailable, NUMBER, 2, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfAssetsMaximum, NUMBER, 3, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfAssetsTotal, NUMBER, 4, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfLossUnrealized, NUMBER, 5, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfDebtTotal, NUMBER, 6, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfDebtMaximum, NUMBER, 7, SField::SMdNeedsAsset | SField::SMdDefault) +TYPED_SFIELD(sfCoverAvailable, NUMBER, 8, SField::SMdNeedsAsset | SField::SMdDefault) TYPED_SFIELD(sfLoanOriginationFee, NUMBER, 9) TYPED_SFIELD(sfLoanServiceFee, NUMBER, 10) TYPED_SFIELD(sfLatePaymentFee, NUMBER, 11) TYPED_SFIELD(sfClosePaymentFee, NUMBER, 12) -TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::sMD_NeedsAsset | SField::sMD_Default) +TYPED_SFIELD(sfPrincipalOutstanding, NUMBER, 13, SField::SMdNeedsAsset | SField::SMdDefault) TYPED_SFIELD(sfPrincipalRequested, NUMBER, 14) -TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::sMD_NeedsAsset | SField::sMD_Default) +TYPED_SFIELD(sfTotalValueOutstanding, NUMBER, 15, SField::SMdNeedsAsset | SField::SMdDefault) TYPED_SFIELD(sfPeriodicPayment, NUMBER, 16) -TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::sMD_NeedsAsset | SField::sMD_Default) +TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::SMdNeedsAsset | SField::SMdDefault) // int32 TYPED_SFIELD(sfLoanScale, INT32, 1) @@ -269,9 +269,9 @@ TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31) TYPED_SFIELD(sfPublicKey, VL, 1) TYPED_SFIELD(sfMessageKey, VL, 2) TYPED_SFIELD(sfSigningPubKey, VL, 3) -TYPED_SFIELD(sfTxnSignature, VL, 4, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfTxnSignature, VL, 4, SField::SMdDefault, SField::kNOT_SIGNING) TYPED_SFIELD(sfURI, VL, 5) -TYPED_SFIELD(sfSignature, VL, 6, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfSignature, VL, 6, SField::SMdDefault, SField::kNOT_SIGNING) TYPED_SFIELD(sfDomain, VL, 7) TYPED_SFIELD(sfFundCode, VL, 8) TYPED_SFIELD(sfRemoveCode, VL, 9) @@ -284,7 +284,7 @@ TYPED_SFIELD(sfMemoFormat, VL, 14) // variable length (uncommon) TYPED_SFIELD(sfFulfillment, VL, 16) TYPED_SFIELD(sfCondition, VL, 17) -TYPED_SFIELD(sfMasterSignature, VL, 18, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfMasterSignature, VL, 18, SField::SMdDefault, SField::kNOT_SIGNING) TYPED_SFIELD(sfUNLModifyValidator, VL, 19) TYPED_SFIELD(sfValidatorToDisable, VL, 20) TYPED_SFIELD(sfValidatorToReEnable, VL, 21) @@ -326,7 +326,7 @@ TYPED_SFIELD(sfBorrower, ACCOUNT, 25) TYPED_SFIELD(sfCounterparty, ACCOUNT, 26) // vector of 256-bit -TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::sMD_Never) +TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::SMdNever) TYPED_SFIELD(sfHashes, VECTOR256, 2) TYPED_SFIELD(sfAmendments, VECTOR256, 3) TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4) @@ -387,13 +387,13 @@ UNTYPED_SFIELD(sfCredential, OBJECT, 33) UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34) UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35) UNTYPED_SFIELD(sfBook, OBJECT, 36) -UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::sMD_Default, SField::notSigning) +UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::SMdDefault, SField::kNOT_SIGNING) // array of objects (common) // ARRAY/1 is reserved for end of array // sfSigningAccounts has never been used. //UNTYPED_SFIELD(sfSigningAccounts, ARRAY, 2) -UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::sMD_Default, SField::notSigning) +UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::SMdDefault, SField::kNOT_SIGNING) UNTYPED_SFIELD(sfSignerEntries, ARRAY, 4) UNTYPED_SFIELD(sfTemplate, ARRAY, 5) UNTYPED_SFIELD(sfNecessary, ARRAY, 6) @@ -421,4 +421,4 @@ UNTYPED_SFIELD(sfUnauthorizeCredentials, ARRAY, 27) UNTYPED_SFIELD(sfAcceptedCredentials, ARRAY, 28) UNTYPED_SFIELD(sfPermissions, ARRAY, 29) UNTYPED_SFIELD(sfRawTransactions, ARRAY, 30) -UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::sMD_Default, SField::notSigning) +UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::SMdDefault, SField::kNOT_SIGNING) diff --git a/include/xrpl/protocol/detail/token_errors.h b/include/xrpl/protocol/detail/token_errors.h index a663d145b1..9d5e98e646 100644 --- a/include/xrpl/protocol/detail/token_errors.h +++ b/include/xrpl/protocol/detail/token_errors.h @@ -4,16 +4,16 @@ namespace xrpl { enum class TokenCodecErrc { - success = 0, - inputTooLarge, - inputTooSmall, - badB58Character, - outputTooSmall, - mismatchedTokenType, - mismatchedChecksum, - invalidEncodingChar, - overflowAdd, - unknown, + Success = 0, + InputTooLarge, + InputTooSmall, + BadB58Character, + OutputTooSmall, + MismatchedTokenType, + MismatchedChecksum, + InvalidEncodingChar, + OverflowAdd, + Unknown, }; } // namespace xrpl @@ -41,23 +41,23 @@ public: { switch (static_cast(c)) { - case TokenCodecErrc::success: + case TokenCodecErrc::Success: return "conversion successful"; - case TokenCodecErrc::inputTooLarge: + case TokenCodecErrc::InputTooLarge: return "input too large"; - case TokenCodecErrc::inputTooSmall: + case TokenCodecErrc::InputTooSmall: return "input too small"; - case TokenCodecErrc::badB58Character: + case TokenCodecErrc::BadB58Character: return "bad base 58 character"; - case TokenCodecErrc::outputTooSmall: + case TokenCodecErrc::OutputTooSmall: return "output too small"; - case TokenCodecErrc::mismatchedTokenType: + case TokenCodecErrc::MismatchedTokenType: return "mismatched token type"; - case TokenCodecErrc::mismatchedChecksum: + case TokenCodecErrc::MismatchedChecksum: return "mismatched checksum"; - case TokenCodecErrc::invalidEncodingChar: + case TokenCodecErrc::InvalidEncodingChar: return "invalid encoding char"; - case TokenCodecErrc::unknown: + case TokenCodecErrc::Unknown: return "unknown"; default: return "unknown"; @@ -67,15 +67,15 @@ public: } // namespace detail inline xrpl::detail::TokenCodecErrcCategory const& -TokenCodecErrcCategory() +tokenCodecErrcCategory() { - static xrpl::detail::TokenCodecErrcCategory const c; - return c; + static xrpl::detail::TokenCodecErrcCategory const kC; + return kC; } inline std::error_code make_error_code(xrpl::TokenCodecErrc e) { - return {static_cast(e), TokenCodecErrcCategory()}; + return {static_cast(e), tokenCodecErrcCategory()}; } } // namespace xrpl diff --git a/include/xrpl/protocol/detail/transactions.macro b/include/xrpl/protocol/detail/transactions.macro index e52d28ce2a..9bac9ef7db 100644 --- a/include/xrpl/protocol/detail/transactions.macro +++ b/include/xrpl/protocol/detail/transactions.macro @@ -25,19 +25,19 @@ # include #endif TRANSACTION(ttPAYMENT, 0, Payment, - Delegation::delegable, + Delegation::Delegable, uint256{}, - createAcct | mayCreateMPT, + CreateAcct | MayCreateMpt, ({ - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfSendMax, soeOPTIONAL, soeMPTSupported}, - {sfPaths, soeDEFAULT}, - {sfInvoiceID, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfDeliverMin, soeOPTIONAL, soeMPTSupported}, - {sfCredentialIDs, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfSendMax, SoeOptional, SoeMptSupported}, + {sfPaths, SoeDefault}, + {sfInvoiceID, SoeOptional}, + {sfDestinationTag, SoeOptional}, + {sfDeliverMin, SoeOptional, SoeMptSupported}, + {sfCredentialIDs, SoeOptional}, + {sfDomainID, SoeOptional}, })) /** This transaction type creates an escrow object. */ @@ -45,16 +45,16 @@ TRANSACTION(ttPAYMENT, 0, Payment, # include #endif TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfCondition, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfFinishAfter, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfCondition, SoeOptional}, + {sfCancelAfter, SoeOptional}, + {sfFinishAfter, SoeOptional}, + {sfDestinationTag, SoeOptional}, })) /** This transaction type completes an existing escrow. */ @@ -62,15 +62,15 @@ TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate, # include #endif TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfOwner, soeREQUIRED}, - {sfOfferSequence, soeREQUIRED}, - {sfFulfillment, soeOPTIONAL}, - {sfCondition, soeOPTIONAL}, - {sfCredentialIDs, soeOPTIONAL}, + {sfOwner, SoeRequired}, + {sfOfferSequence, SoeRequired}, + {sfFulfillment, SoeOptional}, + {sfCondition, SoeOptional}, + {sfCredentialIDs, SoeOptional}, })) @@ -79,20 +79,20 @@ TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish, # include #endif TRANSACTION(ttACCOUNT_SET, 3, AccountSet, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfEmailHash, soeOPTIONAL}, - {sfWalletLocator, soeOPTIONAL}, - {sfWalletSize, soeOPTIONAL}, - {sfMessageKey, soeOPTIONAL}, - {sfDomain, soeOPTIONAL}, - {sfTransferRate, soeOPTIONAL}, - {sfSetFlag, soeOPTIONAL}, - {sfClearFlag, soeOPTIONAL}, - {sfTickSize, soeOPTIONAL}, - {sfNFTokenMinter, soeOPTIONAL}, + {sfEmailHash, SoeOptional}, + {sfWalletLocator, SoeOptional}, + {sfWalletSize, SoeOptional}, + {sfMessageKey, SoeOptional}, + {sfDomain, SoeOptional}, + {sfTransferRate, SoeOptional}, + {sfSetFlag, SoeOptional}, + {sfClearFlag, SoeOptional}, + {sfTickSize, SoeOptional}, + {sfNFTokenMinter, SoeOptional}, })) /** This transaction type cancels an existing escrow. */ @@ -100,12 +100,12 @@ TRANSACTION(ttACCOUNT_SET, 3, AccountSet, # include #endif TRANSACTION(ttESCROW_CANCEL, 4, EscrowCancel, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfOwner, soeREQUIRED}, - {sfOfferSequence, soeREQUIRED}, + {sfOwner, SoeRequired}, + {sfOfferSequence, SoeRequired}, })) /** This transaction type sets or clears an account's "regular key". */ @@ -113,11 +113,11 @@ TRANSACTION(ttESCROW_CANCEL, 4, EscrowCancel, # include #endif TRANSACTION(ttREGULAR_KEY_SET, 5, SetRegularKey, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfRegularKey, soeOPTIONAL}, + {sfRegularKey, SoeOptional}, })) // 6 deprecated @@ -127,15 +127,15 @@ TRANSACTION(ttREGULAR_KEY_SET, 5, SetRegularKey, # include #endif TRANSACTION(ttOFFER_CREATE, 7, OfferCreate, - Delegation::delegable, + Delegation::Delegable, uint256{}, - mayCreateMPT, + MayCreateMpt, ({ - {sfTakerPays, soeREQUIRED, soeMPTSupported}, - {sfTakerGets, soeREQUIRED, soeMPTSupported}, - {sfExpiration, soeOPTIONAL}, - {sfOfferSequence, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, + {sfTakerPays, SoeRequired, SoeMptSupported}, + {sfTakerGets, SoeRequired, SoeMptSupported}, + {sfExpiration, SoeOptional}, + {sfOfferSequence, SoeOptional}, + {sfDomainID, SoeOptional}, })) /** This transaction type cancels existing offers to trade one asset for another. */ @@ -143,11 +143,11 @@ TRANSACTION(ttOFFER_CREATE, 7, OfferCreate, # include #endif TRANSACTION(ttOFFER_CANCEL, 8, OfferCancel, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfOfferSequence, soeREQUIRED}, + {sfOfferSequence, SoeRequired}, })) // 9 deprecated @@ -157,11 +157,11 @@ TRANSACTION(ttOFFER_CANCEL, 8, OfferCancel, # include #endif TRANSACTION(ttTICKET_CREATE, 10, TicketCreate, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfTicketCount, soeREQUIRED}, + {sfTicketCount, SoeRequired}, })) // 11 deprecated @@ -173,12 +173,12 @@ TRANSACTION(ttTICKET_CREATE, 10, TicketCreate, # include #endif TRANSACTION(ttSIGNER_LIST_SET, 12, SignerListSet, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfSignerQuorum, soeREQUIRED}, - {sfSignerEntries, soeOPTIONAL}, + {sfSignerQuorum, SoeRequired}, + {sfSignerEntries, SoeOptional}, })) /** This transaction type creates a new unidirectional XRP payment channel. */ @@ -186,16 +186,16 @@ TRANSACTION(ttSIGNER_LIST_SET, 12, SignerListSet, # include #endif TRANSACTION(ttPAYCHAN_CREATE, 13, PaymentChannelCreate, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSettleDelay, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfCancelAfter, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired}, + {sfSettleDelay, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfCancelAfter, SoeOptional}, + {sfDestinationTag, SoeOptional}, })) /** This transaction type funds an existing unidirectional XRP payment channel. */ @@ -203,13 +203,13 @@ TRANSACTION(ttPAYCHAN_CREATE, 13, PaymentChannelCreate, # include #endif TRANSACTION(ttPAYCHAN_FUND, 14, PaymentChannelFund, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfChannel, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, + {sfChannel, SoeRequired}, + {sfAmount, SoeRequired}, + {sfExpiration, SoeOptional}, })) /** This transaction type submits a claim against an existing unidirectional payment channel. */ @@ -217,16 +217,16 @@ TRANSACTION(ttPAYCHAN_FUND, 14, PaymentChannelFund, # include #endif TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfChannel, soeREQUIRED}, - {sfAmount, soeOPTIONAL}, - {sfBalance, soeOPTIONAL}, - {sfSignature, soeOPTIONAL}, - {sfPublicKey, soeOPTIONAL}, - {sfCredentialIDs, soeOPTIONAL}, + {sfChannel, SoeRequired}, + {sfAmount, SoeOptional}, + {sfBalance, SoeOptional}, + {sfSignature, SoeOptional}, + {sfPublicKey, SoeOptional}, + {sfCredentialIDs, SoeOptional}, })) /** This transaction type creates a new check. */ @@ -234,15 +234,15 @@ TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim, # include #endif TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfDestination, soeREQUIRED}, - {sfSendMax, soeREQUIRED, soeMPTSupported}, - {sfExpiration, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfInvoiceID, soeOPTIONAL}, + {sfDestination, SoeRequired}, + {sfSendMax, SoeRequired, SoeMptSupported}, + {sfExpiration, SoeOptional}, + {sfDestinationTag, SoeOptional}, + {sfInvoiceID, SoeOptional}, })) /** This transaction type cashes an existing check. */ @@ -250,13 +250,13 @@ TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, # include #endif TRANSACTION(ttCHECK_CASH, 17, CheckCash, - Delegation::delegable, + Delegation::Delegable, uint256{}, - mayCreateMPT, + MayCreateMpt, ({ - {sfCheckID, soeREQUIRED}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, - {sfDeliverMin, soeOPTIONAL, soeMPTSupported}, + {sfCheckID, SoeRequired}, + {sfAmount, SoeOptional, SoeMptSupported}, + {sfDeliverMin, SoeOptional, SoeMptSupported}, })) /** This transaction type cancels an existing check. */ @@ -264,11 +264,11 @@ TRANSACTION(ttCHECK_CASH, 17, CheckCash, # include #endif TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfCheckID, soeREQUIRED}, + {sfCheckID, SoeRequired}, })) /** This transaction type grants or revokes authorization to transfer funds. */ @@ -276,14 +276,14 @@ TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, # include #endif TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfAuthorize, soeOPTIONAL}, - {sfUnauthorize, soeOPTIONAL}, - {sfAuthorizeCredentials, soeOPTIONAL}, - {sfUnauthorizeCredentials, soeOPTIONAL}, + {sfAuthorize, SoeOptional}, + {sfUnauthorize, SoeOptional}, + {sfAuthorizeCredentials, SoeOptional}, + {sfUnauthorizeCredentials, SoeOptional}, })) /** This transaction type modifies a trustline between two accounts. */ @@ -291,13 +291,13 @@ TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, # include #endif TRANSACTION(ttTRUST_SET, 20, TrustSet, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfLimitAmount, soeOPTIONAL}, - {sfQualityIn, soeOPTIONAL}, - {sfQualityOut, soeOPTIONAL}, + {sfLimitAmount, SoeOptional}, + {sfQualityIn, SoeOptional}, + {sfQualityOut, SoeOptional}, })) /** This transaction type deletes an existing account. */ @@ -305,13 +305,13 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet, # include #endif TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - mustDeleteAcct, + MustDeleteAcct, ({ - {sfDestination, soeREQUIRED}, - {sfDestinationTag, soeOPTIONAL}, - {sfCredentialIDs, soeOPTIONAL}, + {sfDestination, SoeRequired}, + {sfDestinationTag, SoeOptional}, + {sfCredentialIDs, SoeOptional}, })) // 22 reserved @@ -321,17 +321,17 @@ TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, # include #endif TRANSACTION(ttNFTOKEN_MINT, 25, NFTokenMint, - Delegation::delegable, + Delegation::Delegable, uint256{}, - changeNFTCounts, + ChangeNftCounts, ({ - {sfNFTokenTaxon, soeREQUIRED}, - {sfTransferFee, soeOPTIONAL}, - {sfIssuer, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfAmount, soeOPTIONAL}, - {sfDestination, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, + {sfNFTokenTaxon, SoeRequired}, + {sfTransferFee, SoeOptional}, + {sfIssuer, SoeOptional}, + {sfURI, SoeOptional}, + {sfAmount, SoeOptional}, + {sfDestination, SoeOptional}, + {sfExpiration, SoeOptional}, })) /** This transaction burns (i.e. destroys) an existing NFT. */ @@ -339,12 +339,12 @@ TRANSACTION(ttNFTOKEN_MINT, 25, NFTokenMint, # include #endif TRANSACTION(ttNFTOKEN_BURN, 26, NFTokenBurn, - Delegation::delegable, + Delegation::Delegable, uint256{}, - changeNFTCounts, + ChangeNftCounts, ({ - {sfNFTokenID, soeREQUIRED}, - {sfOwner, soeOPTIONAL}, + {sfNFTokenID, SoeRequired}, + {sfOwner, SoeOptional}, })) /** This transaction creates a new offer to buy or sell an NFT. */ @@ -352,15 +352,15 @@ TRANSACTION(ttNFTOKEN_BURN, 26, NFTokenBurn, # include #endif TRANSACTION(ttNFTOKEN_CREATE_OFFER, 27, NFTokenCreateOffer, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfNFTokenID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, - {sfOwner, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, + {sfNFTokenID, SoeRequired}, + {sfAmount, SoeRequired}, + {sfDestination, SoeOptional}, + {sfOwner, SoeOptional}, + {sfExpiration, SoeOptional}, })) /** This transaction cancels an existing offer to buy or sell an existing NFT. */ @@ -368,11 +368,11 @@ TRANSACTION(ttNFTOKEN_CREATE_OFFER, 27, NFTokenCreateOffer, # include #endif TRANSACTION(ttNFTOKEN_CANCEL_OFFER, 28, NFTokenCancelOffer, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfNFTokenOffers, soeREQUIRED}, + {sfNFTokenOffers, SoeRequired}, })) /** This transaction accepts an existing offer to buy or sell an existing NFT. */ @@ -380,13 +380,13 @@ TRANSACTION(ttNFTOKEN_CANCEL_OFFER, 28, NFTokenCancelOffer, # include #endif TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer, - Delegation::delegable, + Delegation::Delegable, uint256{}, - noPriv, + NoPriv, ({ - {sfNFTokenBuyOffer, soeOPTIONAL}, - {sfNFTokenSellOffer, soeOPTIONAL}, - {sfNFTokenBrokerFee, soeOPTIONAL}, + {sfNFTokenBuyOffer, SoeOptional}, + {sfNFTokenSellOffer, SoeOptional}, + {sfNFTokenBrokerFee, SoeOptional}, })) /** This transaction claws back issued tokens. */ @@ -394,12 +394,12 @@ TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer, # include #endif TRANSACTION(ttCLAWBACK, 30, Clawback, - Delegation::delegable, + Delegation::Delegable, featureClawback, - noPriv, + NoPriv, ({ - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfHolder, soeOPTIONAL}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfHolder, SoeOptional}, })) /** This transaction claws back tokens from an AMM pool. */ @@ -407,14 +407,14 @@ TRANSACTION(ttCLAWBACK, 30, Clawback, # include #endif TRANSACTION(ttAMM_CLAWBACK, 31, AMMClawback, - Delegation::delegable, + Delegation::Delegable, featureAMMClawback, - mayDeleteAcct | overrideFreeze | mayAuthorizeMPT, + MayDeleteAcct | OverrideFreeze | MayAuthorizeMpt, ({ - {sfHolder, soeREQUIRED}, - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, + {sfHolder, SoeRequired}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, + {sfAmount, SoeOptional, SoeMptSupported}, })) /** This transaction type creates an AMM instance */ @@ -422,13 +422,13 @@ TRANSACTION(ttAMM_CLAWBACK, 31, AMMClawback, # include #endif TRANSACTION(ttAMM_CREATE, 35, AMMCreate, - Delegation::delegable, + Delegation::Delegable, featureAMM, - createPseudoAcct | mayCreateMPT, + CreatePseudoAcct | MayCreateMpt, ({ - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfAmount2, soeREQUIRED, soeMPTSupported}, - {sfTradingFee, soeREQUIRED}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfAmount2, SoeRequired, SoeMptSupported}, + {sfTradingFee, SoeRequired}, })) /** This transaction type deposits into an AMM instance */ @@ -436,17 +436,17 @@ TRANSACTION(ttAMM_CREATE, 35, AMMCreate, # include #endif TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, - Delegation::delegable, + Delegation::Delegable, featureAMM, - noPriv, + NoPriv, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, - {sfAmount2, soeOPTIONAL, soeMPTSupported}, - {sfEPrice, soeOPTIONAL}, - {sfLPTokenOut, soeOPTIONAL}, - {sfTradingFee, soeOPTIONAL}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, + {sfAmount, SoeOptional, SoeMptSupported}, + {sfAmount2, SoeOptional, SoeMptSupported}, + {sfEPrice, SoeOptional}, + {sfLPTokenOut, SoeOptional}, + {sfTradingFee, SoeOptional}, })) /** This transaction type withdraws from an AMM instance */ @@ -454,16 +454,16 @@ TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, # include #endif TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, - Delegation::delegable, + Delegation::Delegable, featureAMM, - mayDeleteAcct | mayAuthorizeMPT, + MayDeleteAcct | MayAuthorizeMpt, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, - {sfAmount2, soeOPTIONAL, soeMPTSupported}, - {sfEPrice, soeOPTIONAL}, - {sfLPTokenIn, soeOPTIONAL}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, + {sfAmount, SoeOptional, SoeMptSupported}, + {sfAmount2, SoeOptional, SoeMptSupported}, + {sfEPrice, SoeOptional}, + {sfLPTokenIn, SoeOptional}, })) /** This transaction type votes for the trading fee */ @@ -471,13 +471,13 @@ TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, # include #endif TRANSACTION(ttAMM_VOTE, 38, AMMVote, - Delegation::delegable, + Delegation::Delegable, featureAMM, - noPriv, + NoPriv, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, - {sfTradingFee, soeREQUIRED}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, + {sfTradingFee, SoeRequired}, })) /** This transaction type bids for the auction slot */ @@ -485,15 +485,15 @@ TRANSACTION(ttAMM_VOTE, 38, AMMVote, # include #endif TRANSACTION(ttAMM_BID, 39, AMMBid, - Delegation::delegable, + Delegation::Delegable, featureAMM, - noPriv, + NoPriv, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, - {sfBidMin, soeOPTIONAL}, - {sfBidMax, soeOPTIONAL}, - {sfAuthAccounts, soeOPTIONAL}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, + {sfBidMin, SoeOptional}, + {sfBidMax, SoeOptional}, + {sfAuthAccounts, SoeOptional}, })) /** This transaction type deletes AMM in the empty state */ @@ -501,12 +501,12 @@ TRANSACTION(ttAMM_BID, 39, AMMBid, # include #endif TRANSACTION(ttAMM_DELETE, 40, AMMDelete, - Delegation::delegable, + Delegation::Delegable, featureAMM, - mustDeleteAcct | mayDeleteMPT, + MustDeleteAcct | MayDeleteMpt, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAsset2, soeREQUIRED, soeMPTSupported}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAsset2, SoeRequired, SoeMptSupported}, })) /** This transactions creates a crosschain sequence number */ @@ -514,114 +514,114 @@ TRANSACTION(ttAMM_DELETE, 40, AMMDelete, # include #endif TRANSACTION(ttXCHAIN_CREATE_CLAIM_ID, 41, XChainCreateClaimID, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, + {sfXChainBridge, SoeRequired}, + {sfSignatureReward, SoeRequired}, + {sfOtherChainSource, SoeRequired}, })) /** This transactions initiates a crosschain transaction */ TRANSACTION(ttXCHAIN_COMMIT, 42, XChainCommit, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfOtherChainDestination, soeOPTIONAL}, + {sfXChainBridge, SoeRequired}, + {sfXChainClaimID, SoeRequired}, + {sfAmount, SoeRequired}, + {sfOtherChainDestination, SoeOptional}, })) /** This transaction completes a crosschain transaction */ TRANSACTION(ttXCHAIN_CLAIM, 43, XChainClaim, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfDestinationTag, soeOPTIONAL}, - {sfAmount, soeREQUIRED}, + {sfXChainBridge, SoeRequired}, + {sfXChainClaimID, SoeRequired}, + {sfDestination, SoeRequired}, + {sfDestinationTag, SoeOptional}, + {sfAmount, SoeRequired}, })) /** This transaction initiates a crosschain account create transaction */ TRANSACTION(ttXCHAIN_ACCOUNT_CREATE_COMMIT, 44, XChainAccountCreateCommit, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, + {sfXChainBridge, SoeRequired}, + {sfDestination, SoeRequired}, + {sfAmount, SoeRequired}, + {sfSignatureReward, SoeRequired}, })) /** This transaction adds an attestation to a claim */ TRANSACTION(ttXCHAIN_ADD_CLAIM_ATTESTATION, 45, XChainAddClaimAttestation, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - createAcct, + CreateAcct, ({ - {sfXChainBridge, soeREQUIRED}, + {sfXChainBridge, SoeRequired}, - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfSignature, SoeRequired}, + {sfOtherChainSource, SoeRequired}, + {sfAmount, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, - {sfXChainClaimID, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, + {sfXChainClaimID, SoeRequired}, + {sfDestination, SoeOptional}, })) /** This transaction adds an attestation to an account */ TRANSACTION(ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, 46, XChainAddAccountCreateAttestation, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - createAcct, + CreateAcct, ({ - {sfXChainBridge, soeREQUIRED}, + {sfXChainBridge, SoeRequired}, - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfSignature, SoeRequired}, + {sfOtherChainSource, SoeRequired}, + {sfAmount, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, + {sfXChainAccountCreateCount, SoeRequired}, + {sfDestination, SoeRequired}, + {sfSignatureReward, SoeRequired}, })) /** This transaction modifies a sidechain */ TRANSACTION(ttXCHAIN_MODIFY_BRIDGE, 47, XChainModifyBridge, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeOPTIONAL}, - {sfMinAccountCreateAmount, soeOPTIONAL}, + {sfXChainBridge, SoeRequired}, + {sfSignatureReward, SoeOptional}, + {sfMinAccountCreateAmount, SoeOptional}, })) /** This transactions creates a sidechain */ TRANSACTION(ttXCHAIN_CREATE_BRIDGE, 48, XChainCreateBridge, - Delegation::delegable, + Delegation::Delegable, featureXChainBridge, - noPriv, + NoPriv, ({ - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfMinAccountCreateAmount, soeOPTIONAL}, + {sfXChainBridge, SoeRequired}, + {sfSignatureReward, SoeRequired}, + {sfMinAccountCreateAmount, SoeOptional}, })) /** This transaction type creates or updates a DID */ @@ -629,13 +629,13 @@ TRANSACTION(ttXCHAIN_CREATE_BRIDGE, 48, XChainCreateBridge, # include #endif TRANSACTION(ttDID_SET, 49, DIDSet, - Delegation::delegable, + Delegation::Delegable, featureDID, - noPriv, + NoPriv, ({ - {sfDIDDocument, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfData, soeOPTIONAL}, + {sfDIDDocument, SoeOptional}, + {sfURI, SoeOptional}, + {sfData, SoeOptional}, })) /** This transaction type deletes a DID */ @@ -643,9 +643,9 @@ TRANSACTION(ttDID_SET, 49, DIDSet, # include #endif TRANSACTION(ttDID_DELETE, 50, DIDDelete, - Delegation::delegable, + Delegation::Delegable, featureDID, - noPriv, + NoPriv, ({})) /** This transaction type creates an Oracle instance */ @@ -653,16 +653,16 @@ TRANSACTION(ttDID_DELETE, 50, DIDDelete, # include #endif TRANSACTION(ttORACLE_SET, 51, OracleSet, - Delegation::delegable, + Delegation::Delegable, featurePriceOracle, - noPriv, + NoPriv, ({ - {sfOracleDocumentID, soeREQUIRED}, - {sfProvider, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfAssetClass, soeOPTIONAL}, - {sfLastUpdateTime, soeREQUIRED}, - {sfPriceDataSeries, soeREQUIRED}, + {sfOracleDocumentID, SoeRequired}, + {sfProvider, SoeOptional}, + {sfURI, SoeOptional}, + {sfAssetClass, SoeOptional}, + {sfLastUpdateTime, SoeRequired}, + {sfPriceDataSeries, SoeRequired}, })) /** This transaction type deletes an Oracle instance */ @@ -670,11 +670,11 @@ TRANSACTION(ttORACLE_SET, 51, OracleSet, # include #endif TRANSACTION(ttORACLE_DELETE, 52, OracleDelete, - Delegation::delegable, + Delegation::Delegable, featurePriceOracle, - noPriv, + NoPriv, ({ - {sfOracleDocumentID, soeREQUIRED}, + {sfOracleDocumentID, SoeRequired}, })) /** This transaction type fixes a problem in the ledger state */ @@ -682,12 +682,12 @@ TRANSACTION(ttORACLE_DELETE, 52, OracleDelete, # include #endif TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix, - Delegation::delegable, + Delegation::Delegable, fixNFTokenPageLinks, - noPriv, + NoPriv, ({ - {sfLedgerFixType, soeREQUIRED}, - {sfOwner, soeOPTIONAL}, + {sfLedgerFixType, SoeRequired}, + {sfOwner, SoeOptional}, })) /** This transaction type creates a MPTokensIssuance instance */ @@ -695,16 +695,16 @@ TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix, # include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_CREATE, 54, MPTokenIssuanceCreate, - Delegation::delegable, + Delegation::Delegable, featureMPTokensV1, - createMPTIssuance, + CreateMptIssuance, ({ - {sfAssetScale, soeOPTIONAL}, - {sfTransferFee, soeOPTIONAL}, - {sfMaximumAmount, soeOPTIONAL}, - {sfMPTokenMetadata, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, - {sfMutableFlags, soeOPTIONAL}, + {sfAssetScale, SoeOptional}, + {sfTransferFee, SoeOptional}, + {sfMaximumAmount, SoeOptional}, + {sfMPTokenMetadata, SoeOptional}, + {sfDomainID, SoeOptional}, + {sfMutableFlags, SoeOptional}, })) /** This transaction type destroys a MPTokensIssuance instance */ @@ -712,11 +712,11 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_CREATE, 54, MPTokenIssuanceCreate, # include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_DESTROY, 55, MPTokenIssuanceDestroy, - Delegation::delegable, + Delegation::Delegable, featureMPTokensV1, - destroyMPTIssuance, + DestroyMptIssuance, ({ - {sfMPTokenIssuanceID, soeREQUIRED}, + {sfMPTokenIssuanceID, SoeRequired}, })) /** This transaction type sets flags on a MPTokensIssuance or MPToken instance */ @@ -724,16 +724,16 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_DESTROY, 55, MPTokenIssuanceDestroy, # include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_SET, 56, MPTokenIssuanceSet, - Delegation::delegable, + Delegation::Delegable, featureMPTokensV1, - noPriv, + NoPriv, ({ - {sfMPTokenIssuanceID, soeREQUIRED}, - {sfHolder, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, - {sfMPTokenMetadata, soeOPTIONAL}, - {sfTransferFee, soeOPTIONAL}, - {sfMutableFlags, soeOPTIONAL}, + {sfMPTokenIssuanceID, SoeRequired}, + {sfHolder, SoeOptional}, + {sfDomainID, SoeOptional}, + {sfMPTokenMetadata, SoeOptional}, + {sfTransferFee, SoeOptional}, + {sfMutableFlags, SoeOptional}, })) /** This transaction type authorizes a MPToken instance */ @@ -741,12 +741,12 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_SET, 56, MPTokenIssuanceSet, # include #endif TRANSACTION(ttMPTOKEN_AUTHORIZE, 57, MPTokenAuthorize, - Delegation::delegable, + Delegation::Delegable, featureMPTokensV1, - mustAuthorizeMPT, + MustAuthorizeMpt, ({ - {sfMPTokenIssuanceID, soeREQUIRED}, - {sfHolder, soeOPTIONAL}, + {sfMPTokenIssuanceID, SoeRequired}, + {sfHolder, SoeOptional}, })) /** This transaction type create an Credential instance */ @@ -754,14 +754,14 @@ TRANSACTION(ttMPTOKEN_AUTHORIZE, 57, MPTokenAuthorize, # include #endif TRANSACTION(ttCREDENTIAL_CREATE, 58, CredentialCreate, - Delegation::delegable, + Delegation::Delegable, featureCredentials, - noPriv, + NoPriv, ({ - {sfSubject, soeREQUIRED}, - {sfCredentialType, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, + {sfSubject, SoeRequired}, + {sfCredentialType, SoeRequired}, + {sfExpiration, SoeOptional}, + {sfURI, SoeOptional}, })) /** This transaction type accept an Credential object */ @@ -769,12 +769,12 @@ TRANSACTION(ttCREDENTIAL_CREATE, 58, CredentialCreate, # include #endif TRANSACTION(ttCREDENTIAL_ACCEPT, 59, CredentialAccept, - Delegation::delegable, + Delegation::Delegable, featureCredentials, - noPriv, + NoPriv, ({ - {sfIssuer, soeREQUIRED}, - {sfCredentialType, soeREQUIRED}, + {sfIssuer, SoeRequired}, + {sfCredentialType, SoeRequired}, })) /** This transaction type delete an Credential object */ @@ -782,13 +782,13 @@ TRANSACTION(ttCREDENTIAL_ACCEPT, 59, CredentialAccept, # include #endif TRANSACTION(ttCREDENTIAL_DELETE, 60, CredentialDelete, - Delegation::delegable, + Delegation::Delegable, featureCredentials, - noPriv, + NoPriv, ({ - {sfSubject, soeOPTIONAL}, - {sfIssuer, soeOPTIONAL}, - {sfCredentialType, soeREQUIRED}, + {sfSubject, SoeOptional}, + {sfIssuer, SoeOptional}, + {sfCredentialType, SoeRequired}, })) /** This transaction type modify a NFToken */ @@ -796,13 +796,13 @@ TRANSACTION(ttCREDENTIAL_DELETE, 60, CredentialDelete, # include #endif TRANSACTION(ttNFTOKEN_MODIFY, 61, NFTokenModify, - Delegation::delegable, + Delegation::Delegable, featureDynamicNFT, - noPriv, + NoPriv, ({ - {sfNFTokenID, soeREQUIRED}, - {sfOwner, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, + {sfNFTokenID, SoeRequired}, + {sfOwner, SoeOptional}, + {sfURI, SoeOptional}, })) /** This transaction type creates or modifies a Permissioned Domain */ @@ -810,12 +810,12 @@ TRANSACTION(ttNFTOKEN_MODIFY, 61, NFTokenModify, # include #endif TRANSACTION(ttPERMISSIONED_DOMAIN_SET, 62, PermissionedDomainSet, - Delegation::delegable, + Delegation::Delegable, featurePermissionedDomains, - noPriv, + NoPriv, ({ - {sfDomainID, soeOPTIONAL}, - {sfAcceptedCredentials, soeREQUIRED}, + {sfDomainID, SoeOptional}, + {sfAcceptedCredentials, SoeRequired}, })) /** This transaction type deletes a Permissioned Domain */ @@ -823,11 +823,11 @@ TRANSACTION(ttPERMISSIONED_DOMAIN_SET, 62, PermissionedDomainSet, # include #endif TRANSACTION(ttPERMISSIONED_DOMAIN_DELETE, 63, PermissionedDomainDelete, - Delegation::delegable, + Delegation::Delegable, featurePermissionedDomains, - noPriv, + NoPriv, ({ - {sfDomainID, soeREQUIRED}, + {sfDomainID, SoeRequired}, })) /** This transaction type delegates authorized account specified permissions */ @@ -835,12 +835,12 @@ TRANSACTION(ttPERMISSIONED_DOMAIN_DELETE, 63, PermissionedDomainDelete, # include #endif TRANSACTION(ttDELEGATE_SET, 64, DelegateSet, - Delegation::notDelegable, + Delegation::NotDelegable, featurePermissionDelegationV1_1, - noPriv, + NoPriv, ({ - {sfAuthorize, soeREQUIRED}, - {sfPermissions, soeREQUIRED}, + {sfAuthorize, SoeRequired}, + {sfPermissions, SoeRequired}, })) /** This transaction creates a single asset vault. */ @@ -848,17 +848,17 @@ TRANSACTION(ttDELEGATE_SET, 64, DelegateSet, # include #endif TRANSACTION(ttVAULT_CREATE, 65, VaultCreate, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - createPseudoAcct | createMPTIssuance | mustModifyVault, + CreatePseudoAcct | CreateMptIssuance | MustModifyVault, ({ - {sfAsset, soeREQUIRED, soeMPTSupported}, - {sfAssetsMaximum, soeOPTIONAL}, - {sfMPTokenMetadata, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, - {sfWithdrawalPolicy, soeOPTIONAL}, - {sfData, soeOPTIONAL}, - {sfScale, soeOPTIONAL}, + {sfAsset, SoeRequired, SoeMptSupported}, + {sfAssetsMaximum, SoeOptional}, + {sfMPTokenMetadata, SoeOptional}, + {sfDomainID, SoeOptional}, + {sfWithdrawalPolicy, SoeOptional}, + {sfData, SoeOptional}, + {sfScale, SoeOptional}, })) /** This transaction updates a single asset vault. */ @@ -866,14 +866,14 @@ TRANSACTION(ttVAULT_CREATE, 65, VaultCreate, # include #endif TRANSACTION(ttVAULT_SET, 66, VaultSet, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - mustModifyVault, + MustModifyVault, ({ - {sfVaultID, soeREQUIRED}, - {sfAssetsMaximum, soeOPTIONAL}, - {sfDomainID, soeOPTIONAL}, - {sfData, soeOPTIONAL}, + {sfVaultID, SoeRequired}, + {sfAssetsMaximum, SoeOptional}, + {sfDomainID, SoeOptional}, + {sfData, SoeOptional}, })) /** This transaction deletes a single asset vault. */ @@ -881,11 +881,11 @@ TRANSACTION(ttVAULT_SET, 66, VaultSet, # include #endif TRANSACTION(ttVAULT_DELETE, 67, VaultDelete, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - mustDeleteAcct | destroyMPTIssuance | mustModifyVault, + MustDeleteAcct | DestroyMptIssuance | MustModifyVault, ({ - {sfVaultID, soeREQUIRED}, + {sfVaultID, SoeRequired}, })) /** This transaction trades assets for shares with a vault. */ @@ -893,12 +893,12 @@ TRANSACTION(ttVAULT_DELETE, 67, VaultDelete, # include #endif TRANSACTION(ttVAULT_DEPOSIT, 68, VaultDeposit, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - mayAuthorizeMPT | mustModifyVault, + MayAuthorizeMpt | MustModifyVault, ({ - {sfVaultID, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, + {sfVaultID, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, })) /** This transaction trades shares for assets with a vault. */ @@ -906,14 +906,14 @@ TRANSACTION(ttVAULT_DEPOSIT, 68, VaultDeposit, # include #endif TRANSACTION(ttVAULT_WITHDRAW, 69, VaultWithdraw, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - mayDeleteMPT | mayAuthorizeMPT | mustModifyVault, + MayDeleteMpt | MayAuthorizeMpt | MustModifyVault, ({ - {sfVaultID, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfDestination, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, + {sfVaultID, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfDestination, SoeOptional}, + {sfDestinationTag, SoeOptional}, })) /** This transaction claws back tokens from a vault. */ @@ -921,13 +921,13 @@ TRANSACTION(ttVAULT_WITHDRAW, 69, VaultWithdraw, # include #endif TRANSACTION(ttVAULT_CLAWBACK, 70, VaultClawback, - Delegation::notDelegable, + Delegation::NotDelegable, featureSingleAssetVault, - mayDeleteMPT | mustModifyVault, + MayDeleteMpt | MustModifyVault, ({ - {sfVaultID, soeREQUIRED}, - {sfHolder, soeREQUIRED}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, + {sfVaultID, SoeRequired}, + {sfHolder, SoeRequired}, + {sfAmount, SoeOptional, SoeMptSupported}, })) /** This transaction type batches together transactions. */ @@ -935,12 +935,12 @@ TRANSACTION(ttVAULT_CLAWBACK, 70, VaultClawback, # include #endif TRANSACTION(ttBATCH, 71, Batch, - Delegation::notDelegable, + Delegation::NotDelegable, featureBatch, - noPriv, + NoPriv, ({ - {sfRawTransactions, soeREQUIRED}, - {sfBatchSigners, soeOPTIONAL}, + {sfRawTransactions, SoeRequired}, + {sfBatchSigners, SoeOptional}, })) /** Reserve 72-73 for future Vault-related transactions */ @@ -950,16 +950,16 @@ TRANSACTION(ttBATCH, 71, Batch, # include #endif TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - createPseudoAcct | mayAuthorizeMPT, ({ - {sfVaultID, soeREQUIRED}, - {sfLoanBrokerID, soeOPTIONAL}, - {sfData, soeOPTIONAL}, - {sfManagementFeeRate, soeOPTIONAL}, - {sfDebtMaximum, soeOPTIONAL}, - {sfCoverRateMinimum, soeOPTIONAL}, - {sfCoverRateLiquidation, soeOPTIONAL}, + CreatePseudoAcct | MayAuthorizeMpt, ({ + {sfVaultID, SoeRequired}, + {sfLoanBrokerID, SoeOptional}, + {sfData, SoeOptional}, + {sfManagementFeeRate, SoeOptional}, + {sfDebtMaximum, SoeOptional}, + {sfCoverRateMinimum, SoeOptional}, + {sfCoverRateLiquidation, SoeOptional}, })) /** This transaction deletes a Loan Broker */ @@ -967,10 +967,10 @@ TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet, # include #endif TRANSACTION(ttLOAN_BROKER_DELETE, 75, LoanBrokerDelete, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - mustDeleteAcct | mayAuthorizeMPT, ({ - {sfLoanBrokerID, soeREQUIRED}, + MustDeleteAcct | MayAuthorizeMpt, ({ + {sfLoanBrokerID, SoeRequired}, })) /** This transaction deposits First Loss Capital into a Loan Broker */ @@ -978,11 +978,11 @@ TRANSACTION(ttLOAN_BROKER_DELETE, 75, LoanBrokerDelete, # include #endif TRANSACTION(ttLOAN_BROKER_COVER_DEPOSIT, 76, LoanBrokerCoverDeposit, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - noPriv, ({ - {sfLoanBrokerID, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, + NoPriv, ({ + {sfLoanBrokerID, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, })) /** This transaction withdraws First Loss Capital from a Loan Broker */ @@ -990,13 +990,13 @@ TRANSACTION(ttLOAN_BROKER_COVER_DEPOSIT, 76, LoanBrokerCoverDeposit, # include #endif TRANSACTION(ttLOAN_BROKER_COVER_WITHDRAW, 77, LoanBrokerCoverWithdraw, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - mayAuthorizeMPT, ({ - {sfLoanBrokerID, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, - {sfDestination, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, + MayAuthorizeMpt, ({ + {sfLoanBrokerID, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, + {sfDestination, SoeOptional}, + {sfDestinationTag, SoeOptional}, })) /** This transaction claws back First Loss Capital from a Loan Broker to @@ -1005,11 +1005,11 @@ TRANSACTION(ttLOAN_BROKER_COVER_WITHDRAW, 77, LoanBrokerCoverWithdraw, # include #endif TRANSACTION(ttLOAN_BROKER_COVER_CLAWBACK, 78, LoanBrokerCoverClawback, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - noPriv, ({ - {sfLoanBrokerID, soeOPTIONAL}, - {sfAmount, soeOPTIONAL, soeMPTSupported}, + NoPriv, ({ + {sfLoanBrokerID, SoeOptional}, + {sfAmount, SoeOptional, SoeMptSupported}, })) /** This transaction creates a Loan */ @@ -1017,26 +1017,26 @@ TRANSACTION(ttLOAN_BROKER_COVER_CLAWBACK, 78, LoanBrokerCoverClawback, # include #endif TRANSACTION(ttLOAN_SET, 80, LoanSet, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - mayAuthorizeMPT | mustModifyVault, ({ - {sfLoanBrokerID, soeREQUIRED}, - {sfData, soeOPTIONAL}, - {sfCounterparty, soeOPTIONAL}, - {sfCounterpartySignature, soeOPTIONAL}, - {sfLoanOriginationFee, soeOPTIONAL}, - {sfLoanServiceFee, soeOPTIONAL}, - {sfLatePaymentFee, soeOPTIONAL}, - {sfClosePaymentFee, soeOPTIONAL}, - {sfOverpaymentFee, soeOPTIONAL}, - {sfInterestRate, soeOPTIONAL}, - {sfLateInterestRate, soeOPTIONAL}, - {sfCloseInterestRate, soeOPTIONAL}, - {sfOverpaymentInterestRate, soeOPTIONAL}, - {sfPrincipalRequested, soeREQUIRED}, - {sfPaymentTotal, soeOPTIONAL}, - {sfPaymentInterval, soeOPTIONAL}, - {sfGracePeriod, soeOPTIONAL}, + MayAuthorizeMpt | MustModifyVault, ({ + {sfLoanBrokerID, SoeRequired}, + {sfData, SoeOptional}, + {sfCounterparty, SoeOptional}, + {sfCounterpartySignature, SoeOptional}, + {sfLoanOriginationFee, SoeOptional}, + {sfLoanServiceFee, SoeOptional}, + {sfLatePaymentFee, SoeOptional}, + {sfClosePaymentFee, SoeOptional}, + {sfOverpaymentFee, SoeOptional}, + {sfInterestRate, SoeOptional}, + {sfLateInterestRate, SoeOptional}, + {sfCloseInterestRate, SoeOptional}, + {sfOverpaymentInterestRate, SoeOptional}, + {sfPrincipalRequested, SoeRequired}, + {sfPaymentTotal, SoeOptional}, + {sfPaymentInterval, SoeOptional}, + {sfGracePeriod, SoeOptional}, })) /** This transaction deletes an existing Loan */ @@ -1044,10 +1044,10 @@ TRANSACTION(ttLOAN_SET, 80, LoanSet, # include #endif TRANSACTION(ttLOAN_DELETE, 81, LoanDelete, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - noPriv, ({ - {sfLoanID, soeREQUIRED}, + NoPriv, ({ + {sfLoanID, SoeRequired}, })) /** This transaction is used to change the delinquency status of an existing Loan */ @@ -1055,13 +1055,13 @@ TRANSACTION(ttLOAN_DELETE, 81, LoanDelete, # include #endif TRANSACTION(ttLOAN_MANAGE, 82, LoanManage, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, // All of the LoanManage options will modify the vault, but the // transaction can succeed without options, essentially making it // a noop. - mayModifyVault, ({ - {sfLoanID, soeREQUIRED}, + MayModifyVault, ({ + {sfLoanID, SoeRequired}, })) /** The Borrower uses this transaction to make a Payment on the Loan. */ @@ -1069,11 +1069,11 @@ TRANSACTION(ttLOAN_MANAGE, 82, LoanManage, # include #endif TRANSACTION(ttLOAN_PAY, 84, LoanPay, - Delegation::notDelegable, + Delegation::NotDelegable, featureLendingProtocol, - mayAuthorizeMPT | mustModifyVault, ({ - {sfLoanID, soeREQUIRED}, - {sfAmount, soeREQUIRED, soeMPTSupported}, + MayAuthorizeMpt | MustModifyVault, ({ + {sfLoanID, SoeRequired}, + {sfAmount, SoeRequired, SoeMptSupported}, })) /** This system-generated transaction type is used to update the status of the various amendments. @@ -1084,32 +1084,32 @@ TRANSACTION(ttLOAN_PAY, 84, LoanPay, # include #endif TRANSACTION(ttAMENDMENT, 100, EnableAmendment, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfLedgerSequence, soeREQUIRED}, - {sfAmendment, soeREQUIRED}, + {sfLedgerSequence, SoeRequired}, + {sfAmendment, SoeRequired}, })) /** This system-generated transaction type is used to update the network's fee settings. For details, see: https://xrpl.org/fee-voting.html */ TRANSACTION(ttFEE, 101, SetFee, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfLedgerSequence, soeOPTIONAL}, + {sfLedgerSequence, SoeOptional}, // Old version uses raw numbers - {sfBaseFee, soeOPTIONAL}, - {sfReferenceFeeUnits, soeOPTIONAL}, - {sfReserveBase, soeOPTIONAL}, - {sfReserveIncrement, soeOPTIONAL}, + {sfBaseFee, SoeOptional}, + {sfReferenceFeeUnits, SoeOptional}, + {sfReserveBase, SoeOptional}, + {sfReserveIncrement, SoeOptional}, // New version uses Amounts - {sfBaseFeeDrops, soeOPTIONAL}, - {sfReserveBaseDrops, soeOPTIONAL}, - {sfReserveIncrementDrops, soeOPTIONAL}, + {sfBaseFeeDrops, SoeOptional}, + {sfReserveBaseDrops, SoeOptional}, + {sfReserveIncrementDrops, SoeOptional}, })) /** This system-generated transaction type is used to update the network's negative UNL @@ -1117,11 +1117,11 @@ TRANSACTION(ttFEE, 101, SetFee, For details, see: https://xrpl.org/negative-unl.html */ TRANSACTION(ttUNL_MODIFY, 102, UNLModify, - Delegation::notDelegable, + Delegation::NotDelegable, uint256{}, - noPriv, + NoPriv, ({ - {sfUNLModifyDisabling, soeREQUIRED}, - {sfLedgerSequence, soeREQUIRED}, - {sfUNLModifyValidator, soeREQUIRED}, + {sfUNLModifyDisabling, SoeRequired}, + {sfLedgerSequence, SoeRequired}, + {sfUNLModifyValidator, SoeRequired}, })) diff --git a/include/xrpl/protocol/digest.h b/include/xrpl/protocol/digest.h index bbb38fa543..6564237771 100644 --- a/include/xrpl/protocol/digest.h +++ b/include/xrpl/protocol/digest.h @@ -24,14 +24,14 @@ namespace xrpl { @note This uses the OpenSSL implementation */ -struct openssl_ripemd160_hasher +struct OpensslRipemd160Hasher { public: - static constexpr auto const endian = boost::endian::order::native; + static constexpr auto const kENDIAN = boost::endian::order::native; using result_type = std::array; - openssl_ripemd160_hasher(); + OpensslRipemd160Hasher(); void operator()(void const* data, std::size_t size) noexcept; @@ -47,14 +47,14 @@ private: @note This uses the OpenSSL implementation */ -struct openssl_sha512_hasher +struct OpensslSha512Hasher { public: - static constexpr auto const endian = boost::endian::order::native; + static constexpr auto const kENDIAN = boost::endian::order::native; using result_type = std::array; - openssl_sha512_hasher(); + OpensslSha512Hasher(); void operator()(void const* data, std::size_t size) noexcept; @@ -70,14 +70,14 @@ private: @note This uses the OpenSSL implementation */ -struct openssl_sha256_hasher +struct OpensslSha256Hasher { public: - static constexpr auto const endian = boost::endian::order::native; + static constexpr auto const kENDIAN = boost::endian::order::native; using result_type = std::array; - openssl_sha256_hasher(); + OpensslSha256Hasher(); void operator()(void const* data, std::size_t size) noexcept; @@ -91,9 +91,9 @@ private: //------------------------------------------------------------------------------ -using ripemd160_hasher = openssl_ripemd160_hasher; -using sha256_hasher = openssl_sha256_hasher; -using sha512_hasher = openssl_sha512_hasher; +using ripemd160_hasher = OpensslRipemd160Hasher; +using sha256_hasher = OpensslSha256Hasher; +using sha512_hasher = OpensslSha512Hasher; //------------------------------------------------------------------------------ @@ -112,13 +112,13 @@ using sha512_hasher = openssl_sha512_hasher; Meets the requirements of Hasher (in hash_append) */ -struct ripesha_hasher +struct RipeshaHasher { private: sha256_hasher h_; public: - static constexpr auto const endian = boost::endian::order::native; + static constexpr auto const kENDIAN = boost::endian::order::native; using result_type = std::array; @@ -148,17 +148,17 @@ namespace detail { SHA-512 digest of the message. */ template -struct basic_sha512_half_hasher +struct BasicSha512HalfHasher { private: sha512_hasher h_; public: - static constexpr auto const endian = boost::endian::order::big; + static constexpr auto const kENDIAN = boost::endian::order::big; using result_type = uint256; - ~basic_sha512_half_hasher() + ~BasicSha512HalfHasher() { erase(std::integral_constant{}); } @@ -185,16 +185,16 @@ private: void erase(std::true_type) { - secure_erase(&h_, sizeof(h_)); + secureErase(&h_, sizeof(h_)); } }; } // namespace detail -using sha512_half_hasher = detail::basic_sha512_half_hasher; +using sha512_half_hasher = detail::BasicSha512HalfHasher; // secure version -using sha512_half_hasher_s = detail::basic_sha512_half_hasher; +using sha512_half_hasher_s = detail::BasicSha512HalfHasher; //------------------------------------------------------------------------------ @@ -217,7 +217,7 @@ sha512Half(Args const&... args) */ template sha512_half_hasher_s::result_type -sha512Half_s(Args const&... args) +sha512HalfS(Args const&... args) { sha512_half_hasher_s h; using beast::hash_append; diff --git a/include/xrpl/protocol/json_get_or_throw.h b/include/xrpl/protocol/json_get_or_throw.h index 949fb64cf2..9399f25827 100644 --- a/include/xrpl/protocol/json_get_or_throw.h +++ b/include/xrpl/protocol/json_get_or_throw.h @@ -10,12 +10,12 @@ #include #include -namespace Json { +namespace json { struct JsonMissingKeyError : std::exception { char const* const key; mutable std::string msg; - JsonMissingKeyError(Json::StaticString const& k) : key{k.c_str()} + JsonMissingKeyError(json::StaticString const& k) : key{k.cStr()} { } char const* @@ -34,8 +34,8 @@ struct JsonTypeMismatchError : std::exception char const* const key; std::string const expectedType; mutable std::string msg; - JsonTypeMismatchError(Json::StaticString const& k, std::string et) - : key{k.c_str()}, expectedType{std::move(et)} + JsonTypeMismatchError(json::StaticString const& k, std::string et) + : key{k.cStr()}, expectedType{std::move(et)} { } char const* @@ -52,21 +52,21 @@ struct JsonTypeMismatchError : std::exception template T -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { static_assert(sizeof(T) == -1, "This function must be specialized"); } template <> inline std::string -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; - Json::StaticString const& key = field.getJsonName(); + json::StaticString const& key = field.getJsonName(); if (!v.isMember(key)) Throw(key); - Json::Value const& inner = v[key]; + json::Value const& inner = v[key]; if (!inner.isString()) Throw(key, "string"); return inner.asString(); @@ -75,13 +75,13 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) // Note, this allows integer numeric fields to act as bools template <> inline bool -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; - Json::StaticString const& key = field.getJsonName(); + json::StaticString const& key = field.getJsonName(); if (!v.isMember(key)) Throw(key); - Json::Value const& inner = v[key]; + json::Value const& inner = v[key]; if (inner.isBool()) return inner.asBool(); if (!inner.isIntegral()) @@ -92,13 +92,13 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) template <> inline std::uint64_t -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; - Json::StaticString const& key = field.getJsonName(); + json::StaticString const& key = field.getJsonName(); if (!v.isMember(key)) Throw(key); - Json::Value const& inner = v[key]; + json::Value const& inner = v[key]; if (inner.isUInt()) return inner.asUInt(); if (inner.isInt()) @@ -125,7 +125,7 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) template <> inline xrpl::Buffer -getOrThrow(Json::Value const& v, xrpl::SField const& field) +getOrThrow(json::Value const& v, xrpl::SField const& field) { using namespace xrpl; std::string const hex = getOrThrow(v, field); @@ -140,7 +140,7 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field) // This function may be used by external projects (like the witness server). template std::optional -getOptional(Json::Value const& v, xrpl::SField const& field) +getOptional(json::Value const& v, xrpl::SField const& field) { try { @@ -152,4 +152,4 @@ getOptional(Json::Value const& v, xrpl::SField const& field) return {}; } -} // namespace Json +} // namespace json diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index 0e94285be9..8a2a112542 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -4,17 +4,18 @@ namespace xrpl::jss { +// NOLINTBEGIN(readability-identifier-naming) // JSON static strings -#define JSS(x) constexpr ::Json::StaticString x(#x) +#define JSS(x) constexpr ::json::StaticString x(#x) /* These "StaticString" field names are used instead of string literals to - optimize the performance of accessing properties of Json::Value objects. + optimize the performance of accessing properties of json::Value objects. Most strings have a trailing comment. Here is the legend: - in: Read by the given RPC handler from its `Json::Value` parameter. - out: Assigned by the given RPC handler in the `Json::Value` it returns. + in: Read by the given RPC handler from its `json::Value` parameter. + out: Assigned by the given RPC handler in the `json::Value` it returns. field: A field of at least one type of transaction. RPC: Common properties of RPC requests and responses. error: Common properties of RPC error responses. @@ -707,4 +708,6 @@ JSS(write_load); // out: GetCounts #undef JSS +// NOLINTEND(readability-identifier-naming) + } // namespace xrpl::jss diff --git a/include/xrpl/protocol/nft.h b/include/xrpl/protocol/nft.h index 6dce8d1045..ce73e244c1 100644 --- a/include/xrpl/protocol/nft.h +++ b/include/xrpl/protocol/nft.h @@ -15,7 +15,7 @@ namespace xrpl::nft { struct TaxonTag { }; -using Taxon = tagged_integer; +using Taxon = TaggedInteger; inline Taxon toTaxon(std::uint32_t i) @@ -29,11 +29,11 @@ toUInt32(Taxon t) return static_cast(t); } -constexpr std::uint16_t const flagBurnable = 0x0001; -constexpr std::uint16_t const flagOnlyXRP = 0x0002; -constexpr std::uint16_t const flagCreateTrustLines = 0x0004; -constexpr std::uint16_t const flagTransferable = 0x0008; -constexpr std::uint16_t const flagMutable = 0x0010; +constexpr std::uint16_t const kFLAG_BURNABLE = 0x0001; +constexpr std::uint16_t const kFLAG_ONLY_XRP = 0x0002; +constexpr std::uint16_t const kFLAG_CREATE_TRUST_LINES = 0x0004; +constexpr std::uint16_t const kFLAG_TRANSFERABLE = 0x0008; +constexpr std::uint16_t const kFLAG_MUTABLE = 0x0010; inline std::uint16_t getFlags(uint256 const& id) diff --git a/include/xrpl/protocol/nftPageMask.h b/include/xrpl/protocol/nftPageMask.h index 9889db5341..d679c319fa 100644 --- a/include/xrpl/protocol/nftPageMask.h +++ b/include/xrpl/protocol/nftPageMask.h @@ -8,7 +8,7 @@ namespace xrpl::nft { // NFT directory pages order their contents based only on the low 96 bits of // the NFToken value. This mask provides easy access to the necessary mask. -uint256 constexpr pageMask( +uint256 constexpr kPAGE_MASK( std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff")); } // namespace xrpl::nft diff --git a/include/xrpl/protocol/tokens.h b/include/xrpl/protocol/tokens.h index 043db02825..125cfe8583 100644 --- a/include/xrpl/protocol/tokens.h +++ b/include/xrpl/protocol/tokens.h @@ -62,7 +62,7 @@ decodeBase58Token(std::string const& s, TokenType type); namespace detail { // Expose detail functions for unit tests only std::string -encodeBase58(void const* message, std::size_t size, void* temp, std::size_t temp_size); +encodeBase58(void const* message, std::size_t size, void* temp, std::size_t tempSize); std::string decodeBase58(std::string const& s); @@ -75,7 +75,7 @@ namespace b58_fast { // particular) [[nodiscard]] B58Result> encodeBase58Token( - TokenType token_type, + TokenType tokenType, std::span input, std::span out); @@ -93,10 +93,10 @@ decodeBase58Token(std::string const& s, TokenType type); namespace detail { // Expose detail functions for unit tests only B58Result> -b256_to_b58_be(std::span input, std::span out); +b256ToB58Be(std::span input, std::span out); B58Result> -b58_to_b256_be(std::string_view input, std::span out); +b58ToB256Be(std::string_view input, std::span out); } // namespace detail } // namespace b58_fast diff --git a/include/xrpl/protocol_autogen/STObjectValidation.h b/include/xrpl/protocol_autogen/STObjectValidation.h index cd0633af5d..b8ca7df3b7 100644 --- a/include/xrpl/protocol_autogen/STObjectValidation.h +++ b/include/xrpl/protocol_autogen/STObjectValidation.h @@ -11,12 +11,12 @@ validateSTObject(STObject const& obj, SOTemplate const& format) { for (auto const& field : format) { - if (!obj.isFieldPresent(field.sField()) && field.style() == soeREQUIRED) + if (!obj.isFieldPresent(field.sField()) && field.style() == SoeRequired) { return false; // LCOV_EXCL_LINE } - if (field.supportMPT() == soeMPTNotSupported && obj.isFieldPresent(field.sField())) + if (field.supportMPT() == SoeMptNotSupported && obj.isFieldPresent(field.sField())) { if (field.sField().fieldType == STI_AMOUNT) { diff --git a/include/xrpl/protocol_autogen/TransactionBuilderBase.h b/include/xrpl/protocol_autogen/TransactionBuilderBase.h index 3abfd07a1c..14975b152e 100644 --- a/include/xrpl/protocol_autogen/TransactionBuilderBase.h +++ b/include/xrpl/protocol_autogen/TransactionBuilderBase.h @@ -250,10 +250,10 @@ protected: // Set the signing public key object_.setFieldVL(sfSigningPubKey, publicKey.slice()); - // Build the signing data: HashPrefix::txSign + serialized object + // Build the signing data: HashPrefix::TxSign + serialized object // (without signing fields) Serializer s; - s.add32(HashPrefix::txSign); + s.add32(HashPrefix::TxSign); object_.addWithoutSigningFields(s); // Sign and set the signature diff --git a/include/xrpl/protocol_autogen/ledger_entries/AMM.h b/include/xrpl/protocol_autogen/ledger_entries/AMM.h index f92f15eaa8..529e3f4df7 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/AMM.h +++ b/include/xrpl/protocol_autogen/ledger_entries/AMM.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfTradingFee (soeDEFAULT) + * @brief Get sfTradingFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfVoteSlots (soeOPTIONAL) + * @brief Get sfVoteSlots (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -106,7 +106,7 @@ public: } /** - * @brief Get sfAuctionSlot (soeOPTIONAL) + * @brief Get sfAuctionSlot (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -131,7 +131,7 @@ public: } /** - * @brief Get sfLPTokenBalance (soeREQUIRED) + * @brief Get sfLPTokenBalance (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -142,7 +142,7 @@ public: } /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -153,7 +153,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -164,7 +164,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -175,7 +175,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeOPTIONAL) + * @brief Get sfPreviousTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -199,7 +199,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Get sfPreviousTxnLgrSeq (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -227,7 +227,7 @@ public: * @brief Builder for AMM ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class AMMBuilder : public LedgerEntryBuilderBase @@ -268,7 +268,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -279,7 +279,7 @@ public: } /** - * @brief Set sfTradingFee (soeDEFAULT) + * @brief Set sfTradingFee (SoeDefault) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -290,7 +290,7 @@ public: } /** - * @brief Set sfVoteSlots (soeOPTIONAL) + * @brief Set sfVoteSlots (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -301,7 +301,7 @@ public: } /** - * @brief Set sfAuctionSlot (soeOPTIONAL) + * @brief Set sfAuctionSlot (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -312,7 +312,7 @@ public: } /** - * @brief Set sfLPTokenBalance (soeREQUIRED) + * @brief Set sfLPTokenBalance (SoeRequired) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -323,7 +323,7 @@ public: } /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -334,7 +334,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -345,7 +345,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -356,7 +356,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeOPTIONAL) + * @brief Set sfPreviousTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBuilder& @@ -367,7 +367,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Set sfPreviousTxnLgrSeq (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/AccountRoot.h b/include/xrpl/protocol_autogen/ledger_entries/AccountRoot.h index 15cf14b21a..e20259330d 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/AccountRoot.h +++ b/include/xrpl/protocol_autogen/ledger_entries/AccountRoot.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfBalance (soeREQUIRED) + * @brief Get sfBalance (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfOwnerCount (soeREQUIRED) + * @brief Get sfOwnerCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfAccountTxnID (soeOPTIONAL) + * @brief Get sfAccountTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfRegularKey (soeOPTIONAL) + * @brief Get sfRegularKey (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -160,7 +160,7 @@ public: } /** - * @brief Get sfEmailHash (soeOPTIONAL) + * @brief Get sfEmailHash (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -184,7 +184,7 @@ public: } /** - * @brief Get sfWalletLocator (soeOPTIONAL) + * @brief Get sfWalletLocator (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -208,7 +208,7 @@ public: } /** - * @brief Get sfWalletSize (soeOPTIONAL) + * @brief Get sfWalletSize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -232,7 +232,7 @@ public: } /** - * @brief Get sfMessageKey (soeOPTIONAL) + * @brief Get sfMessageKey (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -256,7 +256,7 @@ public: } /** - * @brief Get sfTransferRate (soeOPTIONAL) + * @brief Get sfTransferRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -280,7 +280,7 @@ public: } /** - * @brief Get sfDomain (soeOPTIONAL) + * @brief Get sfDomain (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -304,7 +304,7 @@ public: } /** - * @brief Get sfTickSize (soeOPTIONAL) + * @brief Get sfTickSize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -328,7 +328,7 @@ public: } /** - * @brief Get sfTicketCount (soeOPTIONAL) + * @brief Get sfTicketCount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -352,7 +352,7 @@ public: } /** - * @brief Get sfNFTokenMinter (soeOPTIONAL) + * @brief Get sfNFTokenMinter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -376,7 +376,7 @@ public: } /** - * @brief Get sfMintedNFTokens (soeDEFAULT) + * @brief Get sfMintedNFTokens (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -400,7 +400,7 @@ public: } /** - * @brief Get sfBurnedNFTokens (soeDEFAULT) + * @brief Get sfBurnedNFTokens (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -424,7 +424,7 @@ public: } /** - * @brief Get sfFirstNFTokenSequence (soeOPTIONAL) + * @brief Get sfFirstNFTokenSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -448,7 +448,7 @@ public: } /** - * @brief Get sfAMMID (soeOPTIONAL) + * @brief Get sfAMMID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -472,7 +472,7 @@ public: } /** - * @brief Get sfVaultID (soeOPTIONAL) + * @brief Get sfVaultID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -496,7 +496,7 @@ public: } /** - * @brief Get sfLoanBrokerID (soeOPTIONAL) + * @brief Get sfLoanBrokerID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -524,7 +524,7 @@ public: * @brief Builder for AccountRoot ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class AccountRootBuilder : public LedgerEntryBuilderBase @@ -567,7 +567,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -578,7 +578,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -589,7 +589,7 @@ public: } /** - * @brief Set sfBalance (soeREQUIRED) + * @brief Set sfBalance (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -600,7 +600,7 @@ public: } /** - * @brief Set sfOwnerCount (soeREQUIRED) + * @brief Set sfOwnerCount (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -611,7 +611,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -622,7 +622,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -633,7 +633,7 @@ public: } /** - * @brief Set sfAccountTxnID (soeOPTIONAL) + * @brief Set sfAccountTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -644,7 +644,7 @@ public: } /** - * @brief Set sfRegularKey (soeOPTIONAL) + * @brief Set sfRegularKey (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -655,7 +655,7 @@ public: } /** - * @brief Set sfEmailHash (soeOPTIONAL) + * @brief Set sfEmailHash (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -666,7 +666,7 @@ public: } /** - * @brief Set sfWalletLocator (soeOPTIONAL) + * @brief Set sfWalletLocator (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -677,7 +677,7 @@ public: } /** - * @brief Set sfWalletSize (soeOPTIONAL) + * @brief Set sfWalletSize (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -688,7 +688,7 @@ public: } /** - * @brief Set sfMessageKey (soeOPTIONAL) + * @brief Set sfMessageKey (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -699,7 +699,7 @@ public: } /** - * @brief Set sfTransferRate (soeOPTIONAL) + * @brief Set sfTransferRate (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -710,7 +710,7 @@ public: } /** - * @brief Set sfDomain (soeOPTIONAL) + * @brief Set sfDomain (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -721,7 +721,7 @@ public: } /** - * @brief Set sfTickSize (soeOPTIONAL) + * @brief Set sfTickSize (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -732,7 +732,7 @@ public: } /** - * @brief Set sfTicketCount (soeOPTIONAL) + * @brief Set sfTicketCount (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -743,7 +743,7 @@ public: } /** - * @brief Set sfNFTokenMinter (soeOPTIONAL) + * @brief Set sfNFTokenMinter (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -754,7 +754,7 @@ public: } /** - * @brief Set sfMintedNFTokens (soeDEFAULT) + * @brief Set sfMintedNFTokens (SoeDefault) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -765,7 +765,7 @@ public: } /** - * @brief Set sfBurnedNFTokens (soeDEFAULT) + * @brief Set sfBurnedNFTokens (SoeDefault) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -776,7 +776,7 @@ public: } /** - * @brief Set sfFirstNFTokenSequence (soeOPTIONAL) + * @brief Set sfFirstNFTokenSequence (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -787,7 +787,7 @@ public: } /** - * @brief Set sfAMMID (soeOPTIONAL) + * @brief Set sfAMMID (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -798,7 +798,7 @@ public: } /** - * @brief Set sfVaultID (soeOPTIONAL) + * @brief Set sfVaultID (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& @@ -809,7 +809,7 @@ public: } /** - * @brief Set sfLoanBrokerID (soeOPTIONAL) + * @brief Set sfLoanBrokerID (SoeOptional) * @return Reference to this builder for method chaining. */ AccountRootBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Amendments.h b/include/xrpl/protocol_autogen/ledger_entries/Amendments.h index 2b51b83747..4f1b316b99 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Amendments.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Amendments.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAmendments (soeOPTIONAL) + * @brief Get sfAmendments (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfMajorities (soeOPTIONAL) + * @brief Get sfMajorities (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -95,7 +95,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeOPTIONAL) + * @brief Get sfPreviousTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -119,7 +119,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Get sfPreviousTxnLgrSeq (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: * @brief Builder for Amendments ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class AmendmentsBuilder : public LedgerEntryBuilderBase @@ -178,7 +178,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAmendments (soeOPTIONAL) + * @brief Set sfAmendments (SoeOptional) * @return Reference to this builder for method chaining. */ AmendmentsBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfMajorities (soeOPTIONAL) + * @brief Set sfMajorities (SoeOptional) * @return Reference to this builder for method chaining. */ AmendmentsBuilder& @@ -200,7 +200,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeOPTIONAL) + * @brief Set sfPreviousTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ AmendmentsBuilder& @@ -211,7 +211,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Set sfPreviousTxnLgrSeq (SoeOptional) * @return Reference to this builder for method chaining. */ AmendmentsBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Bridge.h b/include/xrpl/protocol_autogen/ledger_entries/Bridge.h index 3926ff65fa..fd7df1977f 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Bridge.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Bridge.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Get sfMinAccountCreateAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfXChainClaimID (soeREQUIRED) + * @brief Get sfXChainClaimID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -114,7 +114,7 @@ public: } /** - * @brief Get sfXChainAccountCreateCount (soeREQUIRED) + * @brief Get sfXChainAccountCreateCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfXChainAccountClaimCount (soeREQUIRED) + * @brief Get sfXChainAccountClaimCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -158,7 +158,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -173,7 +173,7 @@ public: * @brief Builder for Bridge ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class BridgeBuilder : public LedgerEntryBuilderBase @@ -222,7 +222,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -233,7 +233,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -244,7 +244,7 @@ public: } /** - * @brief Set sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Set sfMinAccountCreateAmount (SoeOptional) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -255,7 +255,7 @@ public: } /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -266,7 +266,7 @@ public: } /** - * @brief Set sfXChainClaimID (soeREQUIRED) + * @brief Set sfXChainClaimID (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -277,7 +277,7 @@ public: } /** - * @brief Set sfXChainAccountCreateCount (soeREQUIRED) + * @brief Set sfXChainAccountCreateCount (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -288,7 +288,7 @@ public: } /** - * @brief Set sfXChainAccountClaimCount (soeREQUIRED) + * @brief Set sfXChainAccountClaimCount (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -299,7 +299,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -310,7 +310,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& @@ -321,7 +321,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ BridgeBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Check.h b/include/xrpl/protocol_autogen/ledger_entries/Check.h index c071186afb..750270cad9 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Check.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Check.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfSendMax (soeREQUIRED) + * @brief Get sfSendMax (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfDestinationNode (soeREQUIRED) + * @brief Get sfDestinationNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfInvoiceID (soeOPTIONAL) + * @brief Get sfInvoiceID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -160,7 +160,7 @@ public: } /** - * @brief Get sfSourceTag (soeOPTIONAL) + * @brief Get sfSourceTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -184,7 +184,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -208,7 +208,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -219,7 +219,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -234,7 +234,7 @@ public: * @brief Builder for Check ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class CheckBuilder : public LedgerEntryBuilderBase @@ -281,7 +281,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -292,7 +292,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -303,7 +303,7 @@ public: } /** - * @brief Set sfSendMax (soeREQUIRED) + * @brief Set sfSendMax (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -314,7 +314,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -325,7 +325,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -336,7 +336,7 @@ public: } /** - * @brief Set sfDestinationNode (soeREQUIRED) + * @brief Set sfDestinationNode (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -347,7 +347,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -358,7 +358,7 @@ public: } /** - * @brief Set sfInvoiceID (soeOPTIONAL) + * @brief Set sfInvoiceID (SoeOptional) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -369,7 +369,7 @@ public: } /** - * @brief Set sfSourceTag (soeOPTIONAL) + * @brief Set sfSourceTag (SoeOptional) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -380,7 +380,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -391,7 +391,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& @@ -402,7 +402,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ CheckBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Credential.h b/include/xrpl/protocol_autogen/ledger_entries/Credential.h index 4c45f80a8d..5433f00b33 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Credential.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Credential.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfSubject (soeREQUIRED) + * @brief Get sfSubject (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfIssuer (soeREQUIRED) + * @brief Get sfIssuer (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfCredentialType (soeREQUIRED) + * @brief Get sfCredentialType (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: } /** - * @brief Get sfIssuerNode (soeREQUIRED) + * @brief Get sfIssuerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -138,7 +138,7 @@ public: } /** - * @brief Get sfSubjectNode (soeOPTIONAL) + * @brief Get sfSubjectNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -162,7 +162,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -173,7 +173,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -188,7 +188,7 @@ public: * @brief Builder for Credential ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class CredentialBuilder : public LedgerEntryBuilderBase @@ -231,7 +231,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfSubject (soeREQUIRED) + * @brief Set sfSubject (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -242,7 +242,7 @@ public: } /** - * @brief Set sfIssuer (soeREQUIRED) + * @brief Set sfIssuer (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -253,7 +253,7 @@ public: } /** - * @brief Set sfCredentialType (soeREQUIRED) + * @brief Set sfCredentialType (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -264,7 +264,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -275,7 +275,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -286,7 +286,7 @@ public: } /** - * @brief Set sfIssuerNode (soeREQUIRED) + * @brief Set sfIssuerNode (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -297,7 +297,7 @@ public: } /** - * @brief Set sfSubjectNode (soeOPTIONAL) + * @brief Set sfSubjectNode (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -308,7 +308,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& @@ -319,7 +319,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/DID.h b/include/xrpl/protocol_autogen/ledger_entries/DID.h index fc88e988df..2f57961be4 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/DID.h +++ b/include/xrpl/protocol_autogen/ledger_entries/DID.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfDIDDocument (soeOPTIONAL) + * @brief Get sfDIDDocument (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -105,7 +105,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -129,7 +129,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -140,7 +140,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -151,7 +151,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -166,7 +166,7 @@ public: * @brief Builder for DID ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class DIDBuilder : public LedgerEntryBuilderBase @@ -205,7 +205,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -216,7 +216,7 @@ public: } /** - * @brief Set sfDIDDocument (soeOPTIONAL) + * @brief Set sfDIDDocument (SoeOptional) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -227,7 +227,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -238,7 +238,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -249,7 +249,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -260,7 +260,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ DIDBuilder& @@ -271,7 +271,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ DIDBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Delegate.h b/include/xrpl/protocol_autogen/ledger_entries/Delegate.h index e2660632cd..7458b8103a 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Delegate.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Delegate.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfAuthorize (soeREQUIRED) + * @brief Get sfAuthorize (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfPermissions (soeREQUIRED) + * @brief Get sfPermissions (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -80,7 +80,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -91,7 +91,7 @@ public: } /** - * @brief Get sfDestinationNode (soeOPTIONAL) + * @brief Get sfDestinationNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -141,7 +141,7 @@ public: * @brief Builder for Delegate ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class DelegateBuilder : public LedgerEntryBuilderBase @@ -184,7 +184,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -195,7 +195,7 @@ public: } /** - * @brief Set sfAuthorize (soeREQUIRED) + * @brief Set sfAuthorize (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -206,7 +206,7 @@ public: } /** - * @brief Set sfPermissions (soeREQUIRED) + * @brief Set sfPermissions (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfDestinationNode (soeOPTIONAL) + * @brief Set sfDestinationNode (SoeOptional) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& @@ -250,7 +250,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/DepositPreauth.h b/include/xrpl/protocol_autogen/ledger_entries/DepositPreauth.h index 533caba619..42b430a665 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/DepositPreauth.h +++ b/include/xrpl/protocol_autogen/ledger_entries/DepositPreauth.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfAuthorize (soeOPTIONAL) + * @brief Get sfAuthorize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -114,7 +114,7 @@ public: } /** - * @brief Get sfAuthorizeCredentials (soeOPTIONAL) + * @brief Get sfAuthorizeCredentials (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -143,7 +143,7 @@ public: * @brief Builder for DepositPreauth ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class DepositPreauthBuilder : public LedgerEntryBuilderBase @@ -182,7 +182,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -193,7 +193,7 @@ public: } /** - * @brief Set sfAuthorize (soeOPTIONAL) + * @brief Set sfAuthorize (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -204,7 +204,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -215,7 +215,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -226,7 +226,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -237,7 +237,7 @@ public: } /** - * @brief Set sfAuthorizeCredentials (soeOPTIONAL) + * @brief Set sfAuthorizeCredentials (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/DirectoryNode.h b/include/xrpl/protocol_autogen/ledger_entries/DirectoryNode.h index 4c06ac5bbb..e47cb98a26 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/DirectoryNode.h +++ b/include/xrpl/protocol_autogen/ledger_entries/DirectoryNode.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfTakerPaysCurrency (soeOPTIONAL) + * @brief Get sfTakerPaysCurrency (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -94,7 +94,7 @@ public: } /** - * @brief Get sfTakerPaysIssuer (soeOPTIONAL) + * @brief Get sfTakerPaysIssuer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -118,7 +118,7 @@ public: } /** - * @brief Get sfTakerPaysMPT (soeOPTIONAL) + * @brief Get sfTakerPaysMPT (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -142,7 +142,7 @@ public: } /** - * @brief Get sfTakerGetsCurrency (soeOPTIONAL) + * @brief Get sfTakerGetsCurrency (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -166,7 +166,7 @@ public: } /** - * @brief Get sfTakerGetsIssuer (soeOPTIONAL) + * @brief Get sfTakerGetsIssuer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -190,7 +190,7 @@ public: } /** - * @brief Get sfTakerGetsMPT (soeOPTIONAL) + * @brief Get sfTakerGetsMPT (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -214,7 +214,7 @@ public: } /** - * @brief Get sfExchangeRate (soeOPTIONAL) + * @brief Get sfExchangeRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -238,7 +238,7 @@ public: } /** - * @brief Get sfIndexes (soeREQUIRED) + * @brief Get sfIndexes (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -249,7 +249,7 @@ public: } /** - * @brief Get sfRootIndex (soeREQUIRED) + * @brief Get sfRootIndex (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -260,7 +260,7 @@ public: } /** - * @brief Get sfIndexNext (soeOPTIONAL) + * @brief Get sfIndexNext (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -284,7 +284,7 @@ public: } /** - * @brief Get sfIndexPrevious (soeOPTIONAL) + * @brief Get sfIndexPrevious (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -308,7 +308,7 @@ public: } /** - * @brief Get sfNFTokenID (soeOPTIONAL) + * @brief Get sfNFTokenID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -332,7 +332,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeOPTIONAL) + * @brief Get sfPreviousTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -356,7 +356,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Get sfPreviousTxnLgrSeq (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -380,7 +380,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -408,7 +408,7 @@ public: * @brief Builder for DirectoryNode ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class DirectoryNodeBuilder : public LedgerEntryBuilderBase @@ -443,7 +443,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -454,7 +454,7 @@ public: } /** - * @brief Set sfTakerPaysCurrency (soeOPTIONAL) + * @brief Set sfTakerPaysCurrency (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -465,7 +465,7 @@ public: } /** - * @brief Set sfTakerPaysIssuer (soeOPTIONAL) + * @brief Set sfTakerPaysIssuer (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -476,7 +476,7 @@ public: } /** - * @brief Set sfTakerPaysMPT (soeOPTIONAL) + * @brief Set sfTakerPaysMPT (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -487,7 +487,7 @@ public: } /** - * @brief Set sfTakerGetsCurrency (soeOPTIONAL) + * @brief Set sfTakerGetsCurrency (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -498,7 +498,7 @@ public: } /** - * @brief Set sfTakerGetsIssuer (soeOPTIONAL) + * @brief Set sfTakerGetsIssuer (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -509,7 +509,7 @@ public: } /** - * @brief Set sfTakerGetsMPT (soeOPTIONAL) + * @brief Set sfTakerGetsMPT (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -520,7 +520,7 @@ public: } /** - * @brief Set sfExchangeRate (soeOPTIONAL) + * @brief Set sfExchangeRate (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -531,7 +531,7 @@ public: } /** - * @brief Set sfIndexes (soeREQUIRED) + * @brief Set sfIndexes (SoeRequired) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -542,7 +542,7 @@ public: } /** - * @brief Set sfRootIndex (soeREQUIRED) + * @brief Set sfRootIndex (SoeRequired) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -553,7 +553,7 @@ public: } /** - * @brief Set sfIndexNext (soeOPTIONAL) + * @brief Set sfIndexNext (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -564,7 +564,7 @@ public: } /** - * @brief Set sfIndexPrevious (soeOPTIONAL) + * @brief Set sfIndexPrevious (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -575,7 +575,7 @@ public: } /** - * @brief Set sfNFTokenID (soeOPTIONAL) + * @brief Set sfNFTokenID (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -586,7 +586,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeOPTIONAL) + * @brief Set sfPreviousTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -597,7 +597,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Set sfPreviousTxnLgrSeq (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& @@ -608,7 +608,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ DirectoryNodeBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Escrow.h b/include/xrpl/protocol_autogen/ledger_entries/Escrow.h index fd15b2a713..ae8219a4f0 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Escrow.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Escrow.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSequence (soeOPTIONAL) + * @brief Get sfSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfCondition (soeOPTIONAL) + * @brief Get sfCondition (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: } /** - * @brief Get sfCancelAfter (soeOPTIONAL) + * @brief Get sfCancelAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -151,7 +151,7 @@ public: } /** - * @brief Get sfFinishAfter (soeOPTIONAL) + * @brief Get sfFinishAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -175,7 +175,7 @@ public: } /** - * @brief Get sfSourceTag (soeOPTIONAL) + * @brief Get sfSourceTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -199,7 +199,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -223,7 +223,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -234,7 +234,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -245,7 +245,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -256,7 +256,7 @@ public: } /** - * @brief Get sfDestinationNode (soeOPTIONAL) + * @brief Get sfDestinationNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -280,7 +280,7 @@ public: } /** - * @brief Get sfTransferRate (soeOPTIONAL) + * @brief Get sfTransferRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -304,7 +304,7 @@ public: } /** - * @brief Get sfIssuerNode (soeOPTIONAL) + * @brief Get sfIssuerNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -332,7 +332,7 @@ public: * @brief Builder for Escrow ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class EscrowBuilder : public LedgerEntryBuilderBase @@ -375,7 +375,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -386,7 +386,7 @@ public: } /** - * @brief Set sfSequence (soeOPTIONAL) + * @brief Set sfSequence (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -397,7 +397,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -408,7 +408,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -419,7 +419,7 @@ public: } /** - * @brief Set sfCondition (soeOPTIONAL) + * @brief Set sfCondition (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -430,7 +430,7 @@ public: } /** - * @brief Set sfCancelAfter (soeOPTIONAL) + * @brief Set sfCancelAfter (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -441,7 +441,7 @@ public: } /** - * @brief Set sfFinishAfter (soeOPTIONAL) + * @brief Set sfFinishAfter (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -452,7 +452,7 @@ public: } /** - * @brief Set sfSourceTag (soeOPTIONAL) + * @brief Set sfSourceTag (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -463,7 +463,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -474,7 +474,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -485,7 +485,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -496,7 +496,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -507,7 +507,7 @@ public: } /** - * @brief Set sfDestinationNode (soeOPTIONAL) + * @brief Set sfDestinationNode (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -518,7 +518,7 @@ public: } /** - * @brief Set sfTransferRate (soeOPTIONAL) + * @brief Set sfTransferRate (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& @@ -529,7 +529,7 @@ public: } /** - * @brief Set sfIssuerNode (soeOPTIONAL) + * @brief Set sfIssuerNode (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/FeeSettings.h b/include/xrpl/protocol_autogen/ledger_entries/FeeSettings.h index e3c9ca0091..cfd7a591e8 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/FeeSettings.h +++ b/include/xrpl/protocol_autogen/ledger_entries/FeeSettings.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfBaseFee (soeOPTIONAL) + * @brief Get sfBaseFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfReferenceFeeUnits (soeOPTIONAL) + * @brief Get sfReferenceFeeUnits (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -94,7 +94,7 @@ public: } /** - * @brief Get sfReserveBase (soeOPTIONAL) + * @brief Get sfReserveBase (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -118,7 +118,7 @@ public: } /** - * @brief Get sfReserveIncrement (soeOPTIONAL) + * @brief Get sfReserveIncrement (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -142,7 +142,7 @@ public: } /** - * @brief Get sfBaseFeeDrops (soeOPTIONAL) + * @brief Get sfBaseFeeDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -166,7 +166,7 @@ public: } /** - * @brief Get sfReserveBaseDrops (soeOPTIONAL) + * @brief Get sfReserveBaseDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -190,7 +190,7 @@ public: } /** - * @brief Get sfReserveIncrementDrops (soeOPTIONAL) + * @brief Get sfReserveIncrementDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -214,7 +214,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeOPTIONAL) + * @brief Get sfPreviousTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -238,7 +238,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Get sfPreviousTxnLgrSeq (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -266,7 +266,7 @@ public: * @brief Builder for FeeSettings ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class FeeSettingsBuilder : public LedgerEntryBuilderBase @@ -297,7 +297,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfBaseFee (soeOPTIONAL) + * @brief Set sfBaseFee (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -308,7 +308,7 @@ public: } /** - * @brief Set sfReferenceFeeUnits (soeOPTIONAL) + * @brief Set sfReferenceFeeUnits (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -319,7 +319,7 @@ public: } /** - * @brief Set sfReserveBase (soeOPTIONAL) + * @brief Set sfReserveBase (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -330,7 +330,7 @@ public: } /** - * @brief Set sfReserveIncrement (soeOPTIONAL) + * @brief Set sfReserveIncrement (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -341,7 +341,7 @@ public: } /** - * @brief Set sfBaseFeeDrops (soeOPTIONAL) + * @brief Set sfBaseFeeDrops (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -352,7 +352,7 @@ public: } /** - * @brief Set sfReserveBaseDrops (soeOPTIONAL) + * @brief Set sfReserveBaseDrops (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -363,7 +363,7 @@ public: } /** - * @brief Set sfReserveIncrementDrops (soeOPTIONAL) + * @brief Set sfReserveIncrementDrops (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -374,7 +374,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeOPTIONAL) + * @brief Set sfPreviousTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& @@ -385,7 +385,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Set sfPreviousTxnLgrSeq (SoeOptional) * @return Reference to this builder for method chaining. */ FeeSettingsBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/LedgerHashes.h b/include/xrpl/protocol_autogen/ledger_entries/LedgerHashes.h index c95ca303ba..8c082be685 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/LedgerHashes.h +++ b/include/xrpl/protocol_autogen/ledger_entries/LedgerHashes.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfFirstLedgerSequence (soeOPTIONAL) + * @brief Get sfFirstLedgerSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfLastLedgerSequence (soeOPTIONAL) + * @brief Get sfLastLedgerSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -94,7 +94,7 @@ public: } /** - * @brief Get sfHashes (soeREQUIRED) + * @brief Get sfHashes (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -109,7 +109,7 @@ public: * @brief Builder for LedgerHashes ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class LedgerHashesBuilder : public LedgerEntryBuilderBase @@ -142,7 +142,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfFirstLedgerSequence (soeOPTIONAL) + * @brief Set sfFirstLedgerSequence (SoeOptional) * @return Reference to this builder for method chaining. */ LedgerHashesBuilder& @@ -153,7 +153,7 @@ public: } /** - * @brief Set sfLastLedgerSequence (soeOPTIONAL) + * @brief Set sfLastLedgerSequence (SoeOptional) * @return Reference to this builder for method chaining. */ LedgerHashesBuilder& @@ -164,7 +164,7 @@ public: } /** - * @brief Set sfHashes (soeREQUIRED) + * @brief Set sfHashes (SoeRequired) * @return Reference to this builder for method chaining. */ LedgerHashesBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Loan.h b/include/xrpl/protocol_autogen/ledger_entries/Loan.h index 73b37ea892..4408c278db 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Loan.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Loan.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfLoanBrokerNode (soeREQUIRED) + * @brief Get sfLoanBrokerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfLoanBrokerID (soeREQUIRED) + * @brief Get sfLoanBrokerID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfLoanSequence (soeREQUIRED) + * @brief Get sfLoanSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfBorrower (soeREQUIRED) + * @brief Get sfBorrower (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: } /** - * @brief Get sfLoanOriginationFee (soeDEFAULT) + * @brief Get sfLoanOriginationFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: } /** - * @brief Get sfLoanServiceFee (soeDEFAULT) + * @brief Get sfLoanServiceFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -171,7 +171,7 @@ public: } /** - * @brief Get sfLatePaymentFee (soeDEFAULT) + * @brief Get sfLatePaymentFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -195,7 +195,7 @@ public: } /** - * @brief Get sfClosePaymentFee (soeDEFAULT) + * @brief Get sfClosePaymentFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -219,7 +219,7 @@ public: } /** - * @brief Get sfOverpaymentFee (soeDEFAULT) + * @brief Get sfOverpaymentFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -243,7 +243,7 @@ public: } /** - * @brief Get sfInterestRate (soeDEFAULT) + * @brief Get sfInterestRate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -267,7 +267,7 @@ public: } /** - * @brief Get sfLateInterestRate (soeDEFAULT) + * @brief Get sfLateInterestRate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -291,7 +291,7 @@ public: } /** - * @brief Get sfCloseInterestRate (soeDEFAULT) + * @brief Get sfCloseInterestRate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -315,7 +315,7 @@ public: } /** - * @brief Get sfOverpaymentInterestRate (soeDEFAULT) + * @brief Get sfOverpaymentInterestRate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -339,7 +339,7 @@ public: } /** - * @brief Get sfStartDate (soeREQUIRED) + * @brief Get sfStartDate (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -350,7 +350,7 @@ public: } /** - * @brief Get sfPaymentInterval (soeREQUIRED) + * @brief Get sfPaymentInterval (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -361,7 +361,7 @@ public: } /** - * @brief Get sfGracePeriod (soeDEFAULT) + * @brief Get sfGracePeriod (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -385,7 +385,7 @@ public: } /** - * @brief Get sfPreviousPaymentDueDate (soeDEFAULT) + * @brief Get sfPreviousPaymentDueDate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -409,7 +409,7 @@ public: } /** - * @brief Get sfNextPaymentDueDate (soeDEFAULT) + * @brief Get sfNextPaymentDueDate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -433,7 +433,7 @@ public: } /** - * @brief Get sfPaymentRemaining (soeDEFAULT) + * @brief Get sfPaymentRemaining (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -457,7 +457,7 @@ public: } /** - * @brief Get sfPeriodicPayment (soeREQUIRED) + * @brief Get sfPeriodicPayment (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -468,7 +468,7 @@ public: } /** - * @brief Get sfPrincipalOutstanding (soeDEFAULT) + * @brief Get sfPrincipalOutstanding (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -492,7 +492,7 @@ public: } /** - * @brief Get sfTotalValueOutstanding (soeDEFAULT) + * @brief Get sfTotalValueOutstanding (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -516,7 +516,7 @@ public: } /** - * @brief Get sfManagementFeeOutstanding (soeDEFAULT) + * @brief Get sfManagementFeeOutstanding (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -540,7 +540,7 @@ public: } /** - * @brief Get sfLoanScale (soeDEFAULT) + * @brief Get sfLoanScale (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -568,7 +568,7 @@ public: * @brief Builder for Loan ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class LoanBuilder : public LedgerEntryBuilderBase @@ -619,7 +619,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -630,7 +630,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -641,7 +641,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -652,7 +652,7 @@ public: } /** - * @brief Set sfLoanBrokerNode (soeREQUIRED) + * @brief Set sfLoanBrokerNode (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -663,7 +663,7 @@ public: } /** - * @brief Set sfLoanBrokerID (soeREQUIRED) + * @brief Set sfLoanBrokerID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -674,7 +674,7 @@ public: } /** - * @brief Set sfLoanSequence (soeREQUIRED) + * @brief Set sfLoanSequence (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -685,7 +685,7 @@ public: } /** - * @brief Set sfBorrower (soeREQUIRED) + * @brief Set sfBorrower (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -696,7 +696,7 @@ public: } /** - * @brief Set sfLoanOriginationFee (soeDEFAULT) + * @brief Set sfLoanOriginationFee (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -707,7 +707,7 @@ public: } /** - * @brief Set sfLoanServiceFee (soeDEFAULT) + * @brief Set sfLoanServiceFee (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -718,7 +718,7 @@ public: } /** - * @brief Set sfLatePaymentFee (soeDEFAULT) + * @brief Set sfLatePaymentFee (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -729,7 +729,7 @@ public: } /** - * @brief Set sfClosePaymentFee (soeDEFAULT) + * @brief Set sfClosePaymentFee (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -740,7 +740,7 @@ public: } /** - * @brief Set sfOverpaymentFee (soeDEFAULT) + * @brief Set sfOverpaymentFee (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -751,7 +751,7 @@ public: } /** - * @brief Set sfInterestRate (soeDEFAULT) + * @brief Set sfInterestRate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -762,7 +762,7 @@ public: } /** - * @brief Set sfLateInterestRate (soeDEFAULT) + * @brief Set sfLateInterestRate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -773,7 +773,7 @@ public: } /** - * @brief Set sfCloseInterestRate (soeDEFAULT) + * @brief Set sfCloseInterestRate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -784,7 +784,7 @@ public: } /** - * @brief Set sfOverpaymentInterestRate (soeDEFAULT) + * @brief Set sfOverpaymentInterestRate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -795,7 +795,7 @@ public: } /** - * @brief Set sfStartDate (soeREQUIRED) + * @brief Set sfStartDate (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -806,7 +806,7 @@ public: } /** - * @brief Set sfPaymentInterval (soeREQUIRED) + * @brief Set sfPaymentInterval (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -817,7 +817,7 @@ public: } /** - * @brief Set sfGracePeriod (soeDEFAULT) + * @brief Set sfGracePeriod (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -828,7 +828,7 @@ public: } /** - * @brief Set sfPreviousPaymentDueDate (soeDEFAULT) + * @brief Set sfPreviousPaymentDueDate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -839,7 +839,7 @@ public: } /** - * @brief Set sfNextPaymentDueDate (soeDEFAULT) + * @brief Set sfNextPaymentDueDate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -850,7 +850,7 @@ public: } /** - * @brief Set sfPaymentRemaining (soeDEFAULT) + * @brief Set sfPaymentRemaining (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -861,7 +861,7 @@ public: } /** - * @brief Set sfPeriodicPayment (soeREQUIRED) + * @brief Set sfPeriodicPayment (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -872,7 +872,7 @@ public: } /** - * @brief Set sfPrincipalOutstanding (soeDEFAULT) + * @brief Set sfPrincipalOutstanding (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -883,7 +883,7 @@ public: } /** - * @brief Set sfTotalValueOutstanding (soeDEFAULT) + * @brief Set sfTotalValueOutstanding (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -894,7 +894,7 @@ public: } /** - * @brief Set sfManagementFeeOutstanding (soeDEFAULT) + * @brief Set sfManagementFeeOutstanding (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& @@ -905,7 +905,7 @@ public: } /** - * @brief Set sfLoanScale (soeDEFAULT) + * @brief Set sfLoanScale (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/LoanBroker.h b/include/xrpl/protocol_autogen/ledger_entries/LoanBroker.h index 99083d6fce..b1c6dd8a54 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/LoanBroker.h +++ b/include/xrpl/protocol_autogen/ledger_entries/LoanBroker.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfVaultNode (soeREQUIRED) + * @brief Get sfVaultNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: } /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -134,7 +134,7 @@ public: } /** - * @brief Get sfLoanSequence (soeREQUIRED) + * @brief Get sfLoanSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -145,7 +145,7 @@ public: } /** - * @brief Get sfData (soeDEFAULT) + * @brief Get sfData (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -169,7 +169,7 @@ public: } /** - * @brief Get sfManagementFeeRate (soeDEFAULT) + * @brief Get sfManagementFeeRate (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -193,7 +193,7 @@ public: } /** - * @brief Get sfOwnerCount (soeDEFAULT) + * @brief Get sfOwnerCount (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -217,7 +217,7 @@ public: } /** - * @brief Get sfDebtTotal (soeDEFAULT) + * @brief Get sfDebtTotal (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -241,7 +241,7 @@ public: } /** - * @brief Get sfDebtMaximum (soeDEFAULT) + * @brief Get sfDebtMaximum (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -265,7 +265,7 @@ public: } /** - * @brief Get sfCoverAvailable (soeDEFAULT) + * @brief Get sfCoverAvailable (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -289,7 +289,7 @@ public: } /** - * @brief Get sfCoverRateMinimum (soeDEFAULT) + * @brief Get sfCoverRateMinimum (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -313,7 +313,7 @@ public: } /** - * @brief Get sfCoverRateLiquidation (soeDEFAULT) + * @brief Get sfCoverRateLiquidation (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -341,7 +341,7 @@ public: * @brief Builder for LoanBroker ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class LoanBrokerBuilder : public LedgerEntryBuilderBase @@ -390,7 +390,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -401,7 +401,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -412,7 +412,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -423,7 +423,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -434,7 +434,7 @@ public: } /** - * @brief Set sfVaultNode (soeREQUIRED) + * @brief Set sfVaultNode (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -445,7 +445,7 @@ public: } /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -456,7 +456,7 @@ public: } /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -467,7 +467,7 @@ public: } /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -478,7 +478,7 @@ public: } /** - * @brief Set sfLoanSequence (soeREQUIRED) + * @brief Set sfLoanSequence (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -489,7 +489,7 @@ public: } /** - * @brief Set sfData (soeDEFAULT) + * @brief Set sfData (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -500,7 +500,7 @@ public: } /** - * @brief Set sfManagementFeeRate (soeDEFAULT) + * @brief Set sfManagementFeeRate (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -511,7 +511,7 @@ public: } /** - * @brief Set sfOwnerCount (soeDEFAULT) + * @brief Set sfOwnerCount (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -522,7 +522,7 @@ public: } /** - * @brief Set sfDebtTotal (soeDEFAULT) + * @brief Set sfDebtTotal (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -533,7 +533,7 @@ public: } /** - * @brief Set sfDebtMaximum (soeDEFAULT) + * @brief Set sfDebtMaximum (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -544,7 +544,7 @@ public: } /** - * @brief Set sfCoverAvailable (soeDEFAULT) + * @brief Set sfCoverAvailable (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -555,7 +555,7 @@ public: } /** - * @brief Set sfCoverRateMinimum (soeDEFAULT) + * @brief Set sfCoverRateMinimum (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& @@ -566,7 +566,7 @@ public: } /** - * @brief Set sfCoverRateLiquidation (soeDEFAULT) + * @brief Set sfCoverRateLiquidation (SoeDefault) * @return Reference to this builder for method chaining. */ LoanBrokerBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/MPToken.h b/include/xrpl/protocol_autogen/ledger_entries/MPToken.h index d11a8effd3..8176b74fe9 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/MPToken.h +++ b/include/xrpl/protocol_autogen/ledger_entries/MPToken.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfMPTokenIssuanceID (soeREQUIRED) + * @brief Get sfMPTokenIssuanceID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfMPTAmount (soeDEFAULT) + * @brief Get sfMPTAmount (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfLockedAmount (soeOPTIONAL) + * @brief Get sfLockedAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -116,7 +116,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -138,7 +138,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -153,7 +153,7 @@ public: * @brief Builder for MPToken ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class MPTokenBuilder : public LedgerEntryBuilderBase @@ -194,7 +194,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -205,7 +205,7 @@ public: } /** - * @brief Set sfMPTokenIssuanceID (soeREQUIRED) + * @brief Set sfMPTokenIssuanceID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -216,7 +216,7 @@ public: } /** - * @brief Set sfMPTAmount (soeDEFAULT) + * @brief Set sfMPTAmount (SoeDefault) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -227,7 +227,7 @@ public: } /** - * @brief Set sfLockedAmount (soeOPTIONAL) + * @brief Set sfLockedAmount (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -238,7 +238,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -249,7 +249,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenBuilder& @@ -260,7 +260,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/MPTokenIssuance.h b/include/xrpl/protocol_autogen/ledger_entries/MPTokenIssuance.h index 23b8a05015..8377fdf1a4 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/MPTokenIssuance.h +++ b/include/xrpl/protocol_autogen/ledger_entries/MPTokenIssuance.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfIssuer (soeREQUIRED) + * @brief Get sfIssuer (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfTransferFee (soeDEFAULT) + * @brief Get sfTransferFee (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfAssetScale (soeDEFAULT) + * @brief Get sfAssetScale (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: } /** - * @brief Get sfMaximumAmount (soeOPTIONAL) + * @brief Get sfMaximumAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -151,7 +151,7 @@ public: } /** - * @brief Get sfOutstandingAmount (soeREQUIRED) + * @brief Get sfOutstandingAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -162,7 +162,7 @@ public: } /** - * @brief Get sfLockedAmount (soeOPTIONAL) + * @brief Get sfLockedAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -186,7 +186,7 @@ public: } /** - * @brief Get sfMPTokenMetadata (soeOPTIONAL) + * @brief Get sfMPTokenMetadata (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -210,7 +210,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -221,7 +221,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -232,7 +232,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -256,7 +256,7 @@ public: } /** - * @brief Get sfMutableFlags (soeDEFAULT) + * @brief Get sfMutableFlags (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -284,7 +284,7 @@ public: * @brief Builder for MPTokenIssuance ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class MPTokenIssuanceBuilder : public LedgerEntryBuilderBase @@ -327,7 +327,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfIssuer (soeREQUIRED) + * @brief Set sfIssuer (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -338,7 +338,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -349,7 +349,7 @@ public: } /** - * @brief Set sfTransferFee (soeDEFAULT) + * @brief Set sfTransferFee (SoeDefault) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -360,7 +360,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -371,7 +371,7 @@ public: } /** - * @brief Set sfAssetScale (soeDEFAULT) + * @brief Set sfAssetScale (SoeDefault) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -382,7 +382,7 @@ public: } /** - * @brief Set sfMaximumAmount (soeOPTIONAL) + * @brief Set sfMaximumAmount (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -393,7 +393,7 @@ public: } /** - * @brief Set sfOutstandingAmount (soeREQUIRED) + * @brief Set sfOutstandingAmount (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -404,7 +404,7 @@ public: } /** - * @brief Set sfLockedAmount (soeOPTIONAL) + * @brief Set sfLockedAmount (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -415,7 +415,7 @@ public: } /** - * @brief Set sfMPTokenMetadata (soeOPTIONAL) + * @brief Set sfMPTokenMetadata (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -426,7 +426,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -437,7 +437,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -448,7 +448,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& @@ -459,7 +459,7 @@ public: } /** - * @brief Set sfMutableFlags (soeDEFAULT) + * @brief Set sfMutableFlags (SoeDefault) * @return Reference to this builder for method chaining. */ MPTokenIssuanceBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/NFTokenOffer.h b/include/xrpl/protocol_autogen/ledger_entries/NFTokenOffer.h index c500cde14c..c0a6ee6cbc 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/NFTokenOffer.h +++ b/include/xrpl/protocol_autogen/ledger_entries/NFTokenOffer.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfNFTokenID (soeREQUIRED) + * @brief Get sfNFTokenID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfNFTokenOfferNode (soeREQUIRED) + * @brief Get sfNFTokenOfferNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -149,7 +149,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -160,7 +160,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -175,7 +175,7 @@ public: * @brief Builder for NFTokenOffer ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class NFTokenOfferBuilder : public LedgerEntryBuilderBase @@ -220,7 +220,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -231,7 +231,7 @@ public: } /** - * @brief Set sfNFTokenID (soeREQUIRED) + * @brief Set sfNFTokenID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -242,7 +242,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -253,7 +253,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -264,7 +264,7 @@ public: } /** - * @brief Set sfNFTokenOfferNode (soeREQUIRED) + * @brief Set sfNFTokenOfferNode (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -275,7 +275,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -286,7 +286,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -297,7 +297,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& @@ -308,7 +308,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenOfferBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/NFTokenPage.h b/include/xrpl/protocol_autogen/ledger_entries/NFTokenPage.h index fa8c415495..c4190f9068 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/NFTokenPage.h +++ b/include/xrpl/protocol_autogen/ledger_entries/NFTokenPage.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfPreviousPageMin (soeOPTIONAL) + * @brief Get sfPreviousPageMin (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfNextPageMin (soeOPTIONAL) + * @brief Get sfNextPageMin (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -94,7 +94,7 @@ public: } /** - * @brief Get sfNFTokens (soeREQUIRED) + * @brief Get sfNFTokens (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -106,7 +106,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -117,7 +117,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -132,7 +132,7 @@ public: * @brief Builder for NFTokenPage ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class NFTokenPageBuilder : public LedgerEntryBuilderBase @@ -169,7 +169,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfPreviousPageMin (soeOPTIONAL) + * @brief Set sfPreviousPageMin (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenPageBuilder& @@ -180,7 +180,7 @@ public: } /** - * @brief Set sfNextPageMin (soeOPTIONAL) + * @brief Set sfNextPageMin (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenPageBuilder& @@ -191,7 +191,7 @@ public: } /** - * @brief Set sfNFTokens (soeREQUIRED) + * @brief Set sfNFTokens (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenPageBuilder& @@ -202,7 +202,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenPageBuilder& @@ -213,7 +213,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenPageBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/NegativeUNL.h b/include/xrpl/protocol_autogen/ledger_entries/NegativeUNL.h index 8ac2db5683..b09135e5f8 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/NegativeUNL.h +++ b/include/xrpl/protocol_autogen/ledger_entries/NegativeUNL.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfDisabledValidators (soeOPTIONAL) + * @brief Get sfDisabledValidators (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfValidatorToDisable (soeOPTIONAL) + * @brief Get sfValidatorToDisable (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -95,7 +95,7 @@ public: } /** - * @brief Get sfValidatorToReEnable (soeOPTIONAL) + * @brief Get sfValidatorToReEnable (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -119,7 +119,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeOPTIONAL) + * @brief Get sfPreviousTxnID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -143,7 +143,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Get sfPreviousTxnLgrSeq (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -171,7 +171,7 @@ public: * @brief Builder for NegativeUNL ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class NegativeUNLBuilder : public LedgerEntryBuilderBase @@ -202,7 +202,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfDisabledValidators (soeOPTIONAL) + * @brief Set sfDisabledValidators (SoeOptional) * @return Reference to this builder for method chaining. */ NegativeUNLBuilder& @@ -213,7 +213,7 @@ public: } /** - * @brief Set sfValidatorToDisable (soeOPTIONAL) + * @brief Set sfValidatorToDisable (SoeOptional) * @return Reference to this builder for method chaining. */ NegativeUNLBuilder& @@ -224,7 +224,7 @@ public: } /** - * @brief Set sfValidatorToReEnable (soeOPTIONAL) + * @brief Set sfValidatorToReEnable (SoeOptional) * @return Reference to this builder for method chaining. */ NegativeUNLBuilder& @@ -235,7 +235,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeOPTIONAL) + * @brief Set sfPreviousTxnID (SoeOptional) * @return Reference to this builder for method chaining. */ NegativeUNLBuilder& @@ -246,7 +246,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeOPTIONAL) + * @brief Set sfPreviousTxnLgrSeq (SoeOptional) * @return Reference to this builder for method chaining. */ NegativeUNLBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Offer.h b/include/xrpl/protocol_autogen/ledger_entries/Offer.h index cccd9183a1..a6d427cbbd 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Offer.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Offer.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfTakerPays (soeREQUIRED) + * @brief Get sfTakerPays (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfTakerGets (soeREQUIRED) + * @brief Get sfTakerGets (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfBookDirectory (soeREQUIRED) + * @brief Get sfBookDirectory (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfBookNode (soeREQUIRED) + * @brief Get sfBookNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -134,7 +134,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -145,7 +145,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -169,7 +169,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -193,7 +193,7 @@ public: } /** - * @brief Get sfAdditionalBooks (soeOPTIONAL) + * @brief Get sfAdditionalBooks (SoeOptional) * @note This is an untyped field (unknown). * @return The field value, or std::nullopt if not present. */ @@ -222,7 +222,7 @@ public: * @brief Builder for Offer ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class OfferBuilder : public LedgerEntryBuilderBase @@ -271,7 +271,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -282,7 +282,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -293,7 +293,7 @@ public: } /** - * @brief Set sfTakerPays (soeREQUIRED) + * @brief Set sfTakerPays (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -304,7 +304,7 @@ public: } /** - * @brief Set sfTakerGets (soeREQUIRED) + * @brief Set sfTakerGets (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -315,7 +315,7 @@ public: } /** - * @brief Set sfBookDirectory (soeREQUIRED) + * @brief Set sfBookDirectory (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -326,7 +326,7 @@ public: } /** - * @brief Set sfBookNode (soeREQUIRED) + * @brief Set sfBookNode (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -337,7 +337,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -348,7 +348,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -359,7 +359,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -370,7 +370,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -381,7 +381,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ OfferBuilder& @@ -392,7 +392,7 @@ public: } /** - * @brief Set sfAdditionalBooks (soeOPTIONAL) + * @brief Set sfAdditionalBooks (SoeOptional) * @return Reference to this builder for method chaining. */ OfferBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Oracle.h b/include/xrpl/protocol_autogen/ledger_entries/Oracle.h index 4da93773e6..31735a713c 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Oracle.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Oracle.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfOracleDocumentID (soeOPTIONAL) + * @brief Get sfOracleDocumentID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfProvider (soeREQUIRED) + * @brief Get sfProvider (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfPriceDataSeries (soeREQUIRED) + * @brief Get sfPriceDataSeries (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -104,7 +104,7 @@ public: } /** - * @brief Get sfAssetClass (soeREQUIRED) + * @brief Get sfAssetClass (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: } /** - * @brief Get sfLastUpdateTime (soeREQUIRED) + * @brief Get sfLastUpdateTime (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -150,7 +150,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -161,7 +161,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -172,7 +172,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -187,7 +187,7 @@ public: * @brief Builder for Oracle ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class OracleBuilder : public LedgerEntryBuilderBase @@ -234,7 +234,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -245,7 +245,7 @@ public: } /** - * @brief Set sfOracleDocumentID (soeOPTIONAL) + * @brief Set sfOracleDocumentID (SoeOptional) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -256,7 +256,7 @@ public: } /** - * @brief Set sfProvider (soeREQUIRED) + * @brief Set sfProvider (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -267,7 +267,7 @@ public: } /** - * @brief Set sfPriceDataSeries (soeREQUIRED) + * @brief Set sfPriceDataSeries (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -278,7 +278,7 @@ public: } /** - * @brief Set sfAssetClass (soeREQUIRED) + * @brief Set sfAssetClass (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -289,7 +289,7 @@ public: } /** - * @brief Set sfLastUpdateTime (soeREQUIRED) + * @brief Set sfLastUpdateTime (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -300,7 +300,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -311,7 +311,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -322,7 +322,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& @@ -333,7 +333,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ OracleBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/PayChannel.h b/include/xrpl/protocol_autogen/ledger_entries/PayChannel.h index 50245bc0d8..097f287425 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/PayChannel.h +++ b/include/xrpl/protocol_autogen/ledger_entries/PayChannel.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfSequence (soeOPTIONAL) + * @brief Get sfSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfBalance (soeREQUIRED) + * @brief Get sfBalance (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -114,7 +114,7 @@ public: } /** - * @brief Get sfPublicKey (soeREQUIRED) + * @brief Get sfPublicKey (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfSettleDelay (soeREQUIRED) + * @brief Get sfSettleDelay (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -160,7 +160,7 @@ public: } /** - * @brief Get sfCancelAfter (soeOPTIONAL) + * @brief Get sfCancelAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -184,7 +184,7 @@ public: } /** - * @brief Get sfSourceTag (soeOPTIONAL) + * @brief Get sfSourceTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -208,7 +208,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -232,7 +232,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -243,7 +243,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -254,7 +254,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -265,7 +265,7 @@ public: } /** - * @brief Get sfDestinationNode (soeOPTIONAL) + * @brief Get sfDestinationNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -293,7 +293,7 @@ public: * @brief Builder for PayChannel ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class PayChannelBuilder : public LedgerEntryBuilderBase @@ -342,7 +342,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -353,7 +353,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -364,7 +364,7 @@ public: } /** - * @brief Set sfSequence (soeOPTIONAL) + * @brief Set sfSequence (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -375,7 +375,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -386,7 +386,7 @@ public: } /** - * @brief Set sfBalance (soeREQUIRED) + * @brief Set sfBalance (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -397,7 +397,7 @@ public: } /** - * @brief Set sfPublicKey (soeREQUIRED) + * @brief Set sfPublicKey (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -408,7 +408,7 @@ public: } /** - * @brief Set sfSettleDelay (soeREQUIRED) + * @brief Set sfSettleDelay (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -419,7 +419,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -430,7 +430,7 @@ public: } /** - * @brief Set sfCancelAfter (soeOPTIONAL) + * @brief Set sfCancelAfter (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -441,7 +441,7 @@ public: } /** - * @brief Set sfSourceTag (soeOPTIONAL) + * @brief Set sfSourceTag (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -452,7 +452,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -463,7 +463,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -474,7 +474,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -485,7 +485,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ PayChannelBuilder& @@ -496,7 +496,7 @@ public: } /** - * @brief Set sfDestinationNode (soeOPTIONAL) + * @brief Set sfDestinationNode (SoeOptional) * @return Reference to this builder for method chaining. */ PayChannelBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/PermissionedDomain.h b/include/xrpl/protocol_autogen/ledger_entries/PermissionedDomain.h index 630f46517f..cc5a1649ef 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/PermissionedDomain.h +++ b/include/xrpl/protocol_autogen/ledger_entries/PermissionedDomain.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfAcceptedCredentials (soeREQUIRED) + * @brief Get sfAcceptedCredentials (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -80,7 +80,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -91,7 +91,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -102,7 +102,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -117,7 +117,7 @@ public: * @brief Builder for PermissionedDomain ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class PermissionedDomainBuilder : public LedgerEntryBuilderBase @@ -160,7 +160,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& @@ -171,7 +171,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& @@ -182,7 +182,7 @@ public: } /** - * @brief Set sfAcceptedCredentials (soeREQUIRED) + * @brief Set sfAcceptedCredentials (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& @@ -193,7 +193,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& @@ -204,7 +204,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& @@ -215,7 +215,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/RippleState.h b/include/xrpl/protocol_autogen/ledger_entries/RippleState.h index 993496d38f..cb221bb2ad 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/RippleState.h +++ b/include/xrpl/protocol_autogen/ledger_entries/RippleState.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfBalance (soeREQUIRED) + * @brief Get sfBalance (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfLowLimit (soeREQUIRED) + * @brief Get sfLowLimit (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfHighLimit (soeREQUIRED) + * @brief Get sfHighLimit (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfLowNode (soeOPTIONAL) + * @brief Get sfLowNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfLowQualityIn (soeOPTIONAL) + * @brief Get sfLowQualityIn (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -149,7 +149,7 @@ public: } /** - * @brief Get sfLowQualityOut (soeOPTIONAL) + * @brief Get sfLowQualityOut (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -173,7 +173,7 @@ public: } /** - * @brief Get sfHighNode (soeOPTIONAL) + * @brief Get sfHighNode (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -197,7 +197,7 @@ public: } /** - * @brief Get sfHighQualityIn (soeOPTIONAL) + * @brief Get sfHighQualityIn (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -221,7 +221,7 @@ public: } /** - * @brief Get sfHighQualityOut (soeOPTIONAL) + * @brief Get sfHighQualityOut (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -249,7 +249,7 @@ public: * @brief Builder for RippleState ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class RippleStateBuilder : public LedgerEntryBuilderBase @@ -290,7 +290,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfBalance (soeREQUIRED) + * @brief Set sfBalance (SoeRequired) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -301,7 +301,7 @@ public: } /** - * @brief Set sfLowLimit (soeREQUIRED) + * @brief Set sfLowLimit (SoeRequired) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -312,7 +312,7 @@ public: } /** - * @brief Set sfHighLimit (soeREQUIRED) + * @brief Set sfHighLimit (SoeRequired) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -323,7 +323,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -334,7 +334,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -345,7 +345,7 @@ public: } /** - * @brief Set sfLowNode (soeOPTIONAL) + * @brief Set sfLowNode (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -356,7 +356,7 @@ public: } /** - * @brief Set sfLowQualityIn (soeOPTIONAL) + * @brief Set sfLowQualityIn (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -367,7 +367,7 @@ public: } /** - * @brief Set sfLowQualityOut (soeOPTIONAL) + * @brief Set sfLowQualityOut (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -378,7 +378,7 @@ public: } /** - * @brief Set sfHighNode (soeOPTIONAL) + * @brief Set sfHighNode (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -389,7 +389,7 @@ public: } /** - * @brief Set sfHighQualityIn (soeOPTIONAL) + * @brief Set sfHighQualityIn (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& @@ -400,7 +400,7 @@ public: } /** - * @brief Set sfHighQualityOut (soeOPTIONAL) + * @brief Set sfHighQualityOut (SoeOptional) * @return Reference to this builder for method chaining. */ RippleStateBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/SignerList.h b/include/xrpl/protocol_autogen/ledger_entries/SignerList.h index 57d706bc28..dfc7eb4506 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/SignerList.h +++ b/include/xrpl/protocol_autogen/ledger_entries/SignerList.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfSignerQuorum (soeREQUIRED) + * @brief Get sfSignerQuorum (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfSignerEntries (soeREQUIRED) + * @brief Get sfSignerEntries (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -104,7 +104,7 @@ public: } /** - * @brief Get sfSignerListID (soeREQUIRED) + * @brief Get sfSignerListID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -141,7 +141,7 @@ public: * @brief Builder for SignerList ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class SignerListBuilder : public LedgerEntryBuilderBase @@ -184,7 +184,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -195,7 +195,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -206,7 +206,7 @@ public: } /** - * @brief Set sfSignerQuorum (soeREQUIRED) + * @brief Set sfSignerQuorum (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfSignerEntries (soeREQUIRED) + * @brief Set sfSignerEntries (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfSignerListID (soeREQUIRED) + * @brief Set sfSignerListID (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& @@ -250,7 +250,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Ticket.h b/include/xrpl/protocol_autogen/ledger_entries/Ticket.h index f13e8a398f..ceadd70765 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Ticket.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Ticket.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfTicketSequence (soeREQUIRED) + * @brief Get sfTicketSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -105,7 +105,7 @@ public: * @brief Builder for Ticket ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class TicketBuilder : public LedgerEntryBuilderBase @@ -146,7 +146,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ TicketBuilder& @@ -157,7 +157,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ TicketBuilder& @@ -168,7 +168,7 @@ public: } /** - * @brief Set sfTicketSequence (soeREQUIRED) + * @brief Set sfTicketSequence (SoeRequired) * @return Reference to this builder for method chaining. */ TicketBuilder& @@ -179,7 +179,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ TicketBuilder& @@ -190,7 +190,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ TicketBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/Vault.h b/include/xrpl/protocol_autogen/ledger_entries/Vault.h index e24e73fab3..168894d8d2 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/Vault.h +++ b/include/xrpl/protocol_autogen/ledger_entries/Vault.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfSequence (soeREQUIRED) + * @brief Get sfSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -101,7 +101,7 @@ public: } /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: } /** - * @brief Get sfAssetsTotal (soeDEFAULT) + * @brief Get sfAssetsTotal (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -171,7 +171,7 @@ public: } /** - * @brief Get sfAssetsAvailable (soeDEFAULT) + * @brief Get sfAssetsAvailable (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -195,7 +195,7 @@ public: } /** - * @brief Get sfAssetsMaximum (soeDEFAULT) + * @brief Get sfAssetsMaximum (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -219,7 +219,7 @@ public: } /** - * @brief Get sfLossUnrealized (soeDEFAULT) + * @brief Get sfLossUnrealized (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -243,7 +243,7 @@ public: } /** - * @brief Get sfShareMPTID (soeREQUIRED) + * @brief Get sfShareMPTID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -254,7 +254,7 @@ public: } /** - * @brief Get sfWithdrawalPolicy (soeREQUIRED) + * @brief Get sfWithdrawalPolicy (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -265,7 +265,7 @@ public: } /** - * @brief Get sfScale (soeDEFAULT) + * @brief Get sfScale (SoeDefault) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -293,7 +293,7 @@ public: * @brief Builder for Vault ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class VaultBuilder : public LedgerEntryBuilderBase @@ -342,7 +342,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -353,7 +353,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -364,7 +364,7 @@ public: } /** - * @brief Set sfSequence (soeREQUIRED) + * @brief Set sfSequence (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -375,7 +375,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -386,7 +386,7 @@ public: } /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -397,7 +397,7 @@ public: } /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -408,7 +408,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -419,7 +419,7 @@ public: } /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -430,7 +430,7 @@ public: } /** - * @brief Set sfAssetsTotal (soeDEFAULT) + * @brief Set sfAssetsTotal (SoeDefault) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -441,7 +441,7 @@ public: } /** - * @brief Set sfAssetsAvailable (soeDEFAULT) + * @brief Set sfAssetsAvailable (SoeDefault) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -452,7 +452,7 @@ public: } /** - * @brief Set sfAssetsMaximum (soeDEFAULT) + * @brief Set sfAssetsMaximum (SoeDefault) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -463,7 +463,7 @@ public: } /** - * @brief Set sfLossUnrealized (soeDEFAULT) + * @brief Set sfLossUnrealized (SoeDefault) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -474,7 +474,7 @@ public: } /** - * @brief Set sfShareMPTID (soeREQUIRED) + * @brief Set sfShareMPTID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -485,7 +485,7 @@ public: } /** - * @brief Set sfWithdrawalPolicy (soeREQUIRED) + * @brief Set sfWithdrawalPolicy (SoeRequired) * @return Reference to this builder for method chaining. */ VaultBuilder& @@ -496,7 +496,7 @@ public: } /** - * @brief Set sfScale (soeDEFAULT) + * @brief Set sfScale (SoeDefault) * @return Reference to this builder for method chaining. */ VaultBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedClaimID.h b/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedClaimID.h index 3309228951..4a3e9c9103 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedClaimID.h +++ b/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedClaimID.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfXChainClaimID (soeREQUIRED) + * @brief Get sfXChainClaimID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfOtherChainSource (soeREQUIRED) + * @brief Get sfOtherChainSource (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: } /** - * @brief Get sfXChainClaimAttestations (soeREQUIRED) + * @brief Get sfXChainClaimAttestations (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -102,7 +102,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -113,7 +113,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -124,7 +124,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -135,7 +135,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -150,7 +150,7 @@ public: * @brief Builder for XChainOwnedClaimID ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class XChainOwnedClaimIDBuilder : public LedgerEntryBuilderBase @@ -199,7 +199,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -210,7 +210,7 @@ public: } /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -221,7 +221,7 @@ public: } /** - * @brief Set sfXChainClaimID (soeREQUIRED) + * @brief Set sfXChainClaimID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -232,7 +232,7 @@ public: } /** - * @brief Set sfOtherChainSource (soeREQUIRED) + * @brief Set sfOtherChainSource (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfXChainClaimAttestations (soeREQUIRED) + * @brief Set sfXChainClaimAttestations (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& @@ -287,7 +287,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedClaimIDBuilder& diff --git a/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedCreateAccountClaimID.h b/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedCreateAccountClaimID.h index 5415d52884..542de104ea 100644 --- a/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedCreateAccountClaimID.h +++ b/include/xrpl/protocol_autogen/ledger_entries/XChainOwnedCreateAccountClaimID.h @@ -46,7 +46,7 @@ public: // Ledger entry-specific field getters /** - * @brief Get sfAccount (soeREQUIRED) + * @brief Get sfAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -57,7 +57,7 @@ public: } /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -68,7 +68,7 @@ public: } /** - * @brief Get sfXChainAccountCreateCount (soeREQUIRED) + * @brief Get sfXChainAccountCreateCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -79,7 +79,7 @@ public: } /** - * @brief Get sfXChainCreateAccountAttestations (soeREQUIRED) + * @brief Get sfXChainCreateAccountAttestations (SoeRequired) * @note This is an untyped field (unknown). * @return The field value. */ @@ -91,7 +91,7 @@ public: } /** - * @brief Get sfOwnerNode (soeREQUIRED) + * @brief Get sfOwnerNode (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -102,7 +102,7 @@ public: } /** - * @brief Get sfPreviousTxnID (soeREQUIRED) + * @brief Get sfPreviousTxnID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -113,7 +113,7 @@ public: } /** - * @brief Get sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Get sfPreviousTxnLgrSeq (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -128,7 +128,7 @@ public: * @brief Builder for XChainOwnedCreateAccountClaimID ledger entries. * * Provides a fluent interface for constructing ledger entries with method chaining. - * Uses Json::Value internally for flexible ledger entry construction. + * Uses STObject internally for flexible ledger entry construction. * Inherits common field setters from LedgerEntryBuilderBase. */ class XChainOwnedCreateAccountClaimIDBuilder : public LedgerEntryBuilderBase @@ -173,7 +173,7 @@ public: /** @brief Ledger entry-specific field setters */ /** - * @brief Set sfAccount (soeREQUIRED) + * @brief Set sfAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -184,7 +184,7 @@ public: } /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -195,7 +195,7 @@ public: } /** - * @brief Set sfXChainAccountCreateCount (soeREQUIRED) + * @brief Set sfXChainAccountCreateCount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -206,7 +206,7 @@ public: } /** - * @brief Set sfXChainCreateAccountAttestations (soeREQUIRED) + * @brief Set sfXChainCreateAccountAttestations (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfOwnerNode (soeREQUIRED) + * @brief Set sfOwnerNode (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfPreviousTxnID (soeREQUIRED) + * @brief Set sfPreviousTxnID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfPreviousTxnLgrSeq (soeREQUIRED) + * @brief Set sfPreviousTxnLgrSeq (SoeRequired) * @return Reference to this builder for method chaining. */ XChainOwnedCreateAccountClaimIDBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AMMBid.h b/include/xrpl/protocol_autogen/transactions/AMMBid.h index 4e5c5d1d15..cd2792e810 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMBid.h +++ b/include/xrpl/protocol_autogen/transactions/AMMBid.h @@ -19,9 +19,9 @@ class AMMBidBuilder; * @brief Transaction: AMMBid * * Type: ttAMM_BID (39) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use AMMBidBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfBidMin (soeOPTIONAL) + * @brief Get sfBidMin (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -98,7 +98,7 @@ public: } /** - * @brief Get sfBidMax (soeOPTIONAL) + * @brief Get sfBidMax (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: return this->tx_->isFieldPresent(sfBidMax); } /** - * @brief Get sfAuthAccounts (soeOPTIONAL) + * @brief Get sfAuthAccounts (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -152,7 +152,7 @@ public: * @brief Builder for AMMBid transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMBidBuilder : public TransactionBuilderBase @@ -193,7 +193,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -205,7 +205,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfBidMin (soeOPTIONAL) + * @brief Set sfBidMin (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBidBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfBidMax (soeOPTIONAL) + * @brief Set sfBidMax (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBidBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfAuthAccounts (soeOPTIONAL) + * @brief Set sfAuthAccounts (SoeOptional) * @return Reference to this builder for method chaining. */ AMMBidBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AMMClawback.h b/include/xrpl/protocol_autogen/transactions/AMMClawback.h index 3a968f34d2..ccbd7d99e6 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMClawback.h +++ b/include/xrpl/protocol_autogen/transactions/AMMClawback.h @@ -19,9 +19,9 @@ class AMMClawbackBuilder; * @brief Transaction: AMMClawback * * Type: ttAMM_CLAWBACK (31) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMMClawback - * Privileges: mayDeleteAcct | overrideFreeze | mayAuthorizeMPT + * Privileges: MayDeleteAcct | OverrideFreeze | MayAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use AMMClawbackBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfHolder (soeREQUIRED) + * @brief Get sfHolder (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -83,7 +83,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -114,7 +114,7 @@ public: * @brief Builder for AMMClawback transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMClawbackBuilder : public TransactionBuilderBase @@ -157,7 +157,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfHolder (soeREQUIRED) + * @brief Set sfHolder (SoeRequired) * @return Reference to this builder for method chaining. */ AMMClawbackBuilder& @@ -168,7 +168,7 @@ public: } /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -180,7 +180,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -192,7 +192,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/AMMCreate.h b/include/xrpl/protocol_autogen/transactions/AMMCreate.h index ad6a253ffc..cc88428e7a 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMCreate.h +++ b/include/xrpl/protocol_autogen/transactions/AMMCreate.h @@ -19,9 +19,9 @@ class AMMCreateBuilder; * @brief Transaction: AMMCreate * * Type: ttAMM_CREATE (35) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: createPseudoAcct | mayCreateMPT + * Privileges: CreatePseudoAcct | MayCreateMpt * * Immutable wrapper around STTx providing type-safe field access. * Use AMMCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAmount2 (soeREQUIRED) + * @brief Get sfAmount2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfTradingFee (soeREQUIRED) + * @brief Get sfTradingFee (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -87,7 +87,7 @@ public: * @brief Builder for AMMCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMCreateBuilder : public TransactionBuilderBase @@ -130,7 +130,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -142,7 +142,7 @@ public: } /** - * @brief Set sfAmount2 (soeREQUIRED) + * @brief Set sfAmount2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -154,7 +154,7 @@ public: } /** - * @brief Set sfTradingFee (soeREQUIRED) + * @brief Set sfTradingFee (SoeRequired) * @return Reference to this builder for method chaining. */ AMMCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AMMDelete.h b/include/xrpl/protocol_autogen/transactions/AMMDelete.h index 3325ee63b3..4cc0497c32 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMDelete.h +++ b/include/xrpl/protocol_autogen/transactions/AMMDelete.h @@ -19,9 +19,9 @@ class AMMDeleteBuilder; * @brief Transaction: AMMDelete * * Type: ttAMM_DELETE (40) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: mustDeleteAcct | mayDeleteMPT + * Privileges: MustDeleteAcct | MayDeleteMpt * * Immutable wrapper around STTx providing type-safe field access. * Use AMMDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -76,7 +76,7 @@ public: * @brief Builder for AMMDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMDeleteBuilder : public TransactionBuilderBase @@ -117,7 +117,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -129,7 +129,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/AMMDeposit.h b/include/xrpl/protocol_autogen/transactions/AMMDeposit.h index bb9a36d218..e01332c3e2 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMDeposit.h +++ b/include/xrpl/protocol_autogen/transactions/AMMDeposit.h @@ -19,9 +19,9 @@ class AMMDepositBuilder; * @brief Transaction: AMMDeposit * * Type: ttAMM_DEPOSIT (36) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use AMMDepositBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -99,7 +99,7 @@ public: } /** - * @brief Get sfAmount2 (soeOPTIONAL) + * @brief Get sfAmount2 (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfEPrice (soeOPTIONAL) + * @brief Get sfEPrice (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: } /** - * @brief Get sfLPTokenOut (soeOPTIONAL) + * @brief Get sfLPTokenOut (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -178,7 +178,7 @@ public: } /** - * @brief Get sfTradingFee (soeOPTIONAL) + * @brief Get sfTradingFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -208,7 +208,7 @@ public: * @brief Builder for AMMDeposit transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMDepositBuilder : public TransactionBuilderBase @@ -249,7 +249,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -261,7 +261,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -273,7 +273,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -285,7 +285,7 @@ public: } /** - * @brief Set sfAmount2 (soeOPTIONAL) + * @brief Set sfAmount2 (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -297,7 +297,7 @@ public: } /** - * @brief Set sfEPrice (soeOPTIONAL) + * @brief Set sfEPrice (SoeOptional) * @return Reference to this builder for method chaining. */ AMMDepositBuilder& @@ -308,7 +308,7 @@ public: } /** - * @brief Set sfLPTokenOut (soeOPTIONAL) + * @brief Set sfLPTokenOut (SoeOptional) * @return Reference to this builder for method chaining. */ AMMDepositBuilder& @@ -319,7 +319,7 @@ public: } /** - * @brief Set sfTradingFee (soeOPTIONAL) + * @brief Set sfTradingFee (SoeOptional) * @return Reference to this builder for method chaining. */ AMMDepositBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AMMVote.h b/include/xrpl/protocol_autogen/transactions/AMMVote.h index 3baa3f6d41..b19d440c84 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMVote.h +++ b/include/xrpl/protocol_autogen/transactions/AMMVote.h @@ -19,9 +19,9 @@ class AMMVoteBuilder; * @brief Transaction: AMMVote * * Type: ttAMM_VOTE (38) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use AMMVoteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfTradingFee (soeREQUIRED) + * @brief Get sfTradingFee (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -87,7 +87,7 @@ public: * @brief Builder for AMMVote transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMVoteBuilder : public TransactionBuilderBase @@ -130,7 +130,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -142,7 +142,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -154,7 +154,7 @@ public: } /** - * @brief Set sfTradingFee (soeREQUIRED) + * @brief Set sfTradingFee (SoeRequired) * @return Reference to this builder for method chaining. */ AMMVoteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AMMWithdraw.h b/include/xrpl/protocol_autogen/transactions/AMMWithdraw.h index 99f82b69c8..196f0faba2 100644 --- a/include/xrpl/protocol_autogen/transactions/AMMWithdraw.h +++ b/include/xrpl/protocol_autogen/transactions/AMMWithdraw.h @@ -19,9 +19,9 @@ class AMMWithdrawBuilder; * @brief Transaction: AMMWithdraw * * Type: ttAMM_WITHDRAW (37) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureAMM - * Privileges: mayDeleteAcct | mayAuthorizeMPT + * Privileges: MayDeleteAcct | MayAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use AMMWithdrawBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAsset2 (soeREQUIRED) + * @brief Get sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -99,7 +99,7 @@ public: } /** - * @brief Get sfAmount2 (soeOPTIONAL) + * @brief Get sfAmount2 (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfEPrice (soeOPTIONAL) + * @brief Get sfEPrice (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: } /** - * @brief Get sfLPTokenIn (soeOPTIONAL) + * @brief Get sfLPTokenIn (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -182,7 +182,7 @@ public: * @brief Builder for AMMWithdraw transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AMMWithdrawBuilder : public TransactionBuilderBase @@ -223,7 +223,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -235,7 +235,7 @@ public: } /** - * @brief Set sfAsset2 (soeREQUIRED) + * @brief Set sfAsset2 (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -247,7 +247,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -259,7 +259,7 @@ public: } /** - * @brief Set sfAmount2 (soeOPTIONAL) + * @brief Set sfAmount2 (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -271,7 +271,7 @@ public: } /** - * @brief Set sfEPrice (soeOPTIONAL) + * @brief Set sfEPrice (SoeOptional) * @return Reference to this builder for method chaining. */ AMMWithdrawBuilder& @@ -282,7 +282,7 @@ public: } /** - * @brief Set sfLPTokenIn (soeOPTIONAL) + * @brief Set sfLPTokenIn (SoeOptional) * @return Reference to this builder for method chaining. */ AMMWithdrawBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AccountDelete.h b/include/xrpl/protocol_autogen/transactions/AccountDelete.h index 86ae9af546..c0346d9499 100644 --- a/include/xrpl/protocol_autogen/transactions/AccountDelete.h +++ b/include/xrpl/protocol_autogen/transactions/AccountDelete.h @@ -19,9 +19,9 @@ class AccountDeleteBuilder; * @brief Transaction: AccountDelete * * Type: ttACCOUNT_DELETE (21) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: mustDeleteAcct + * Privileges: MustDeleteAcct * * Immutable wrapper around STTx providing type-safe field access. * Use AccountDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfCredentialIDs (soeOPTIONAL) + * @brief Get sfCredentialIDs (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: * @brief Builder for AccountDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AccountDeleteBuilder : public TransactionBuilderBase @@ -154,7 +154,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ AccountDeleteBuilder& @@ -165,7 +165,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ AccountDeleteBuilder& @@ -176,7 +176,7 @@ public: } /** - * @brief Set sfCredentialIDs (soeOPTIONAL) + * @brief Set sfCredentialIDs (SoeOptional) * @return Reference to this builder for method chaining. */ AccountDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/AccountSet.h b/include/xrpl/protocol_autogen/transactions/AccountSet.h index c00142bd1e..7ddda45752 100644 --- a/include/xrpl/protocol_autogen/transactions/AccountSet.h +++ b/include/xrpl/protocol_autogen/transactions/AccountSet.h @@ -19,9 +19,9 @@ class AccountSetBuilder; * @brief Transaction: AccountSet * * Type: ttACCOUNT_SET (3) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use AccountSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfEmailHash (soeOPTIONAL) + * @brief Get sfEmailHash (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfWalletLocator (soeOPTIONAL) + * @brief Get sfWalletLocator (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfWalletSize (soeOPTIONAL) + * @brief Get sfWalletSize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfMessageKey (soeOPTIONAL) + * @brief Get sfMessageKey (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: } /** - * @brief Get sfDomain (soeOPTIONAL) + * @brief Get sfDomain (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -178,7 +178,7 @@ public: } /** - * @brief Get sfTransferRate (soeOPTIONAL) + * @brief Get sfTransferRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -204,7 +204,7 @@ public: } /** - * @brief Get sfSetFlag (soeOPTIONAL) + * @brief Get sfSetFlag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -230,7 +230,7 @@ public: } /** - * @brief Get sfClearFlag (soeOPTIONAL) + * @brief Get sfClearFlag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -256,7 +256,7 @@ public: } /** - * @brief Get sfTickSize (soeOPTIONAL) + * @brief Get sfTickSize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -282,7 +282,7 @@ public: } /** - * @brief Get sfNFTokenMinter (soeOPTIONAL) + * @brief Get sfNFTokenMinter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -312,7 +312,7 @@ public: * @brief Builder for AccountSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class AccountSetBuilder : public TransactionBuilderBase @@ -349,7 +349,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfEmailHash (soeOPTIONAL) + * @brief Set sfEmailHash (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -360,7 +360,7 @@ public: } /** - * @brief Set sfWalletLocator (soeOPTIONAL) + * @brief Set sfWalletLocator (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -371,7 +371,7 @@ public: } /** - * @brief Set sfWalletSize (soeOPTIONAL) + * @brief Set sfWalletSize (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -382,7 +382,7 @@ public: } /** - * @brief Set sfMessageKey (soeOPTIONAL) + * @brief Set sfMessageKey (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -393,7 +393,7 @@ public: } /** - * @brief Set sfDomain (soeOPTIONAL) + * @brief Set sfDomain (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -404,7 +404,7 @@ public: } /** - * @brief Set sfTransferRate (soeOPTIONAL) + * @brief Set sfTransferRate (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -415,7 +415,7 @@ public: } /** - * @brief Set sfSetFlag (soeOPTIONAL) + * @brief Set sfSetFlag (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -426,7 +426,7 @@ public: } /** - * @brief Set sfClearFlag (soeOPTIONAL) + * @brief Set sfClearFlag (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -437,7 +437,7 @@ public: } /** - * @brief Set sfTickSize (soeOPTIONAL) + * @brief Set sfTickSize (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& @@ -448,7 +448,7 @@ public: } /** - * @brief Set sfNFTokenMinter (soeOPTIONAL) + * @brief Set sfNFTokenMinter (SoeOptional) * @return Reference to this builder for method chaining. */ AccountSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/Batch.h b/include/xrpl/protocol_autogen/transactions/Batch.h index 0bb638435c..55b99d0eef 100644 --- a/include/xrpl/protocol_autogen/transactions/Batch.h +++ b/include/xrpl/protocol_autogen/transactions/Batch.h @@ -19,9 +19,9 @@ class BatchBuilder; * @brief Transaction: Batch * * Type: ttBATCH (71) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureBatch - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use BatchBuilder to construct new transactions. @@ -47,7 +47,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfRawTransactions (soeREQUIRED) + * @brief Get sfRawTransactions (SoeRequired) * @note This is an untyped field. * @return The field value. */ @@ -58,7 +58,7 @@ public: return this->tx_->getFieldArray(sfRawTransactions); } /** - * @brief Get sfBatchSigners (soeOPTIONAL) + * @brief Get sfBatchSigners (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -87,7 +87,7 @@ public: * @brief Builder for Batch transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class BatchBuilder : public TransactionBuilderBase @@ -126,7 +126,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfRawTransactions (soeREQUIRED) + * @brief Set sfRawTransactions (SoeRequired) * @return Reference to this builder for method chaining. */ BatchBuilder& @@ -137,7 +137,7 @@ public: } /** - * @brief Set sfBatchSigners (soeOPTIONAL) + * @brief Set sfBatchSigners (SoeOptional) * @return Reference to this builder for method chaining. */ BatchBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/CheckCancel.h b/include/xrpl/protocol_autogen/transactions/CheckCancel.h index 2409e7064c..4f7534278b 100644 --- a/include/xrpl/protocol_autogen/transactions/CheckCancel.h +++ b/include/xrpl/protocol_autogen/transactions/CheckCancel.h @@ -19,9 +19,9 @@ class CheckCancelBuilder; * @brief Transaction: CheckCancel * * Type: ttCHECK_CANCEL (18) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use CheckCancelBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfCheckID (soeREQUIRED) + * @brief Get sfCheckID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for CheckCancel transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CheckCancelBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfCheckID (soeREQUIRED) + * @brief Set sfCheckID (SoeRequired) * @return Reference to this builder for method chaining. */ CheckCancelBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/CheckCash.h b/include/xrpl/protocol_autogen/transactions/CheckCash.h index 34dc91c61b..a58a20c57e 100644 --- a/include/xrpl/protocol_autogen/transactions/CheckCash.h +++ b/include/xrpl/protocol_autogen/transactions/CheckCash.h @@ -19,9 +19,9 @@ class CheckCashBuilder; * @brief Transaction: CheckCash * * Type: ttCHECK_CASH (17) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: mayCreateMPT + * Privileges: MayCreateMpt * * Immutable wrapper around STTx providing type-safe field access. * Use CheckCashBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfCheckID (soeREQUIRED) + * @brief Get sfCheckID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -86,7 +86,7 @@ public: } /** - * @brief Get sfDeliverMin (soeOPTIONAL) + * @brief Get sfDeliverMin (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -117,7 +117,7 @@ public: * @brief Builder for CheckCash transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CheckCashBuilder : public TransactionBuilderBase @@ -156,7 +156,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfCheckID (soeREQUIRED) + * @brief Set sfCheckID (SoeRequired) * @return Reference to this builder for method chaining. */ CheckCashBuilder& @@ -167,7 +167,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -179,7 +179,7 @@ public: } /** - * @brief Set sfDeliverMin (soeOPTIONAL) + * @brief Set sfDeliverMin (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/CheckCreate.h b/include/xrpl/protocol_autogen/transactions/CheckCreate.h index f5e2ad23a9..17f985ac63 100644 --- a/include/xrpl/protocol_autogen/transactions/CheckCreate.h +++ b/include/xrpl/protocol_autogen/transactions/CheckCreate.h @@ -19,9 +19,9 @@ class CheckCreateBuilder; * @brief Transaction: CheckCreate * * Type: ttCHECK_CREATE (16) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use CheckCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfSendMax (soeREQUIRED) + * @brief Get sfSendMax (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -97,7 +97,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: } /** - * @brief Get sfInvoiceID (soeOPTIONAL) + * @brief Get sfInvoiceID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -153,7 +153,7 @@ public: * @brief Builder for CheckCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CheckCreateBuilder : public TransactionBuilderBase @@ -194,7 +194,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ CheckCreateBuilder& @@ -205,7 +205,7 @@ public: } /** - * @brief Set sfSendMax (soeREQUIRED) + * @brief Set sfSendMax (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ CheckCreateBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ CheckCreateBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfInvoiceID (soeOPTIONAL) + * @brief Set sfInvoiceID (SoeOptional) * @return Reference to this builder for method chaining. */ CheckCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/Clawback.h b/include/xrpl/protocol_autogen/transactions/Clawback.h index 6c34ceff11..bbf1c411f3 100644 --- a/include/xrpl/protocol_autogen/transactions/Clawback.h +++ b/include/xrpl/protocol_autogen/transactions/Clawback.h @@ -19,9 +19,9 @@ class ClawbackBuilder; * @brief Transaction: Clawback * * Type: ttCLAWBACK (30) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureClawback - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use ClawbackBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfHolder (soeOPTIONAL) + * @brief Get sfHolder (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -90,7 +90,7 @@ public: * @brief Builder for Clawback transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class ClawbackBuilder : public TransactionBuilderBase @@ -129,7 +129,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -141,7 +141,7 @@ public: } /** - * @brief Set sfHolder (soeOPTIONAL) + * @brief Set sfHolder (SoeOptional) * @return Reference to this builder for method chaining. */ ClawbackBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/CredentialAccept.h b/include/xrpl/protocol_autogen/transactions/CredentialAccept.h index c739e4abcb..152c18ea09 100644 --- a/include/xrpl/protocol_autogen/transactions/CredentialAccept.h +++ b/include/xrpl/protocol_autogen/transactions/CredentialAccept.h @@ -19,9 +19,9 @@ class CredentialAcceptBuilder; * @brief Transaction: CredentialAccept * * Type: ttCREDENTIAL_ACCEPT (59) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureCredentials - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use CredentialAcceptBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfIssuer (soeREQUIRED) + * @brief Get sfIssuer (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfCredentialType (soeREQUIRED) + * @brief Get sfCredentialType (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: * @brief Builder for CredentialAccept transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CredentialAcceptBuilder : public TransactionBuilderBase @@ -115,7 +115,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfIssuer (soeREQUIRED) + * @brief Set sfIssuer (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialAcceptBuilder& @@ -126,7 +126,7 @@ public: } /** - * @brief Set sfCredentialType (soeREQUIRED) + * @brief Set sfCredentialType (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialAcceptBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/CredentialCreate.h b/include/xrpl/protocol_autogen/transactions/CredentialCreate.h index 4da5b3ff47..d7e056f590 100644 --- a/include/xrpl/protocol_autogen/transactions/CredentialCreate.h +++ b/include/xrpl/protocol_autogen/transactions/CredentialCreate.h @@ -19,9 +19,9 @@ class CredentialCreateBuilder; * @brief Transaction: CredentialCreate * * Type: ttCREDENTIAL_CREATE (58) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureCredentials - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use CredentialCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfSubject (soeREQUIRED) + * @brief Get sfSubject (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfCredentialType (soeREQUIRED) + * @brief Get sfCredentialType (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -96,7 +96,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: * @brief Builder for CredentialCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CredentialCreateBuilder : public TransactionBuilderBase @@ -167,7 +167,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfSubject (soeREQUIRED) + * @brief Set sfSubject (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialCreateBuilder& @@ -178,7 +178,7 @@ public: } /** - * @brief Set sfCredentialType (soeREQUIRED) + * @brief Set sfCredentialType (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialCreateBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialCreateBuilder& @@ -200,7 +200,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/CredentialDelete.h b/include/xrpl/protocol_autogen/transactions/CredentialDelete.h index bd840ed104..512f230a26 100644 --- a/include/xrpl/protocol_autogen/transactions/CredentialDelete.h +++ b/include/xrpl/protocol_autogen/transactions/CredentialDelete.h @@ -19,9 +19,9 @@ class CredentialDeleteBuilder; * @brief Transaction: CredentialDelete * * Type: ttCREDENTIAL_DELETE (60) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureCredentials - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use CredentialDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfSubject (soeOPTIONAL) + * @brief Get sfSubject (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfIssuer (soeOPTIONAL) + * @brief Get sfIssuer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfCredentialType (soeREQUIRED) + * @brief Get sfCredentialType (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: * @brief Builder for CredentialDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class CredentialDeleteBuilder : public TransactionBuilderBase @@ -154,7 +154,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfSubject (soeOPTIONAL) + * @brief Set sfSubject (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialDeleteBuilder& @@ -165,7 +165,7 @@ public: } /** - * @brief Set sfIssuer (soeOPTIONAL) + * @brief Set sfIssuer (SoeOptional) * @return Reference to this builder for method chaining. */ CredentialDeleteBuilder& @@ -176,7 +176,7 @@ public: } /** - * @brief Set sfCredentialType (soeREQUIRED) + * @brief Set sfCredentialType (SoeRequired) * @return Reference to this builder for method chaining. */ CredentialDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/DIDDelete.h b/include/xrpl/protocol_autogen/transactions/DIDDelete.h index c4e61eb19e..5f90821bfd 100644 --- a/include/xrpl/protocol_autogen/transactions/DIDDelete.h +++ b/include/xrpl/protocol_autogen/transactions/DIDDelete.h @@ -19,9 +19,9 @@ class DIDDeleteBuilder; * @brief Transaction: DIDDelete * * Type: ttDID_DELETE (50) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureDID - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use DIDDeleteBuilder to construct new transactions. @@ -52,7 +52,7 @@ public: * @brief Builder for DIDDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class DIDDeleteBuilder : public TransactionBuilderBase diff --git a/include/xrpl/protocol_autogen/transactions/DIDSet.h b/include/xrpl/protocol_autogen/transactions/DIDSet.h index 33313d384c..27242cda71 100644 --- a/include/xrpl/protocol_autogen/transactions/DIDSet.h +++ b/include/xrpl/protocol_autogen/transactions/DIDSet.h @@ -19,9 +19,9 @@ class DIDSetBuilder; * @brief Transaction: DIDSet * * Type: ttDID_SET (49) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureDID - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use DIDSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDIDDocument (soeOPTIONAL) + * @brief Get sfDIDDocument (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -130,7 +130,7 @@ public: * @brief Builder for DIDSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class DIDSetBuilder : public TransactionBuilderBase @@ -167,7 +167,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDIDDocument (soeOPTIONAL) + * @brief Set sfDIDDocument (SoeOptional) * @return Reference to this builder for method chaining. */ DIDSetBuilder& @@ -178,7 +178,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ DIDSetBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ DIDSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/DelegateSet.h b/include/xrpl/protocol_autogen/transactions/DelegateSet.h index cac4b3abef..1f454ff4a1 100644 --- a/include/xrpl/protocol_autogen/transactions/DelegateSet.h +++ b/include/xrpl/protocol_autogen/transactions/DelegateSet.h @@ -19,9 +19,9 @@ class DelegateSetBuilder; * @brief Transaction: DelegateSet * * Type: ttDELEGATE_SET (64) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featurePermissionDelegationV1_1 - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use DelegateSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAuthorize (soeREQUIRED) + * @brief Get sfAuthorize (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -58,7 +58,7 @@ public: return this->tx_->at(sfAuthorize); } /** - * @brief Get sfPermissions (soeREQUIRED) + * @brief Get sfPermissions (SoeRequired) * @note This is an untyped field. * @return The field value. */ @@ -74,7 +74,7 @@ public: * @brief Builder for DelegateSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class DelegateSetBuilder : public TransactionBuilderBase @@ -115,7 +115,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAuthorize (soeREQUIRED) + * @brief Set sfAuthorize (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateSetBuilder& @@ -126,7 +126,7 @@ public: } /** - * @brief Set sfPermissions (soeREQUIRED) + * @brief Set sfPermissions (SoeRequired) * @return Reference to this builder for method chaining. */ DelegateSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/DepositPreauth.h b/include/xrpl/protocol_autogen/transactions/DepositPreauth.h index eae8b113a9..d303ffbeff 100644 --- a/include/xrpl/protocol_autogen/transactions/DepositPreauth.h +++ b/include/xrpl/protocol_autogen/transactions/DepositPreauth.h @@ -19,9 +19,9 @@ class DepositPreauthBuilder; * @brief Transaction: DepositPreauth * * Type: ttDEPOSIT_PREAUTH (19) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use DepositPreauthBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAuthorize (soeOPTIONAL) + * @brief Get sfAuthorize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfUnauthorize (soeOPTIONAL) + * @brief Get sfUnauthorize (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -99,7 +99,7 @@ public: return this->tx_->isFieldPresent(sfUnauthorize); } /** - * @brief Get sfAuthorizeCredentials (soeOPTIONAL) + * @brief Get sfAuthorizeCredentials (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -123,7 +123,7 @@ public: return this->tx_->isFieldPresent(sfAuthorizeCredentials); } /** - * @brief Get sfUnauthorizeCredentials (soeOPTIONAL) + * @brief Get sfUnauthorizeCredentials (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -152,7 +152,7 @@ public: * @brief Builder for DepositPreauth transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class DepositPreauthBuilder : public TransactionBuilderBase @@ -189,7 +189,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAuthorize (soeOPTIONAL) + * @brief Set sfAuthorize (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -200,7 +200,7 @@ public: } /** - * @brief Set sfUnauthorize (soeOPTIONAL) + * @brief Set sfUnauthorize (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -211,7 +211,7 @@ public: } /** - * @brief Set sfAuthorizeCredentials (soeOPTIONAL) + * @brief Set sfAuthorizeCredentials (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& @@ -222,7 +222,7 @@ public: } /** - * @brief Set sfUnauthorizeCredentials (soeOPTIONAL) + * @brief Set sfUnauthorizeCredentials (SoeOptional) * @return Reference to this builder for method chaining. */ DepositPreauthBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/EnableAmendment.h b/include/xrpl/protocol_autogen/transactions/EnableAmendment.h index 0bf3dfd575..b397c5df87 100644 --- a/include/xrpl/protocol_autogen/transactions/EnableAmendment.h +++ b/include/xrpl/protocol_autogen/transactions/EnableAmendment.h @@ -19,9 +19,9 @@ class EnableAmendmentBuilder; * @brief Transaction: EnableAmendment * * Type: ttAMENDMENT (100) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use EnableAmendmentBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLedgerSequence (soeREQUIRED) + * @brief Get sfLedgerSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmendment (soeREQUIRED) + * @brief Get sfAmendment (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: * @brief Builder for EnableAmendment transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class EnableAmendmentBuilder : public TransactionBuilderBase @@ -115,7 +115,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLedgerSequence (soeREQUIRED) + * @brief Set sfLedgerSequence (SoeRequired) * @return Reference to this builder for method chaining. */ EnableAmendmentBuilder& @@ -126,7 +126,7 @@ public: } /** - * @brief Set sfAmendment (soeREQUIRED) + * @brief Set sfAmendment (SoeRequired) * @return Reference to this builder for method chaining. */ EnableAmendmentBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/EscrowCancel.h b/include/xrpl/protocol_autogen/transactions/EscrowCancel.h index a92d5b10ae..4da943c351 100644 --- a/include/xrpl/protocol_autogen/transactions/EscrowCancel.h +++ b/include/xrpl/protocol_autogen/transactions/EscrowCancel.h @@ -19,9 +19,9 @@ class EscrowCancelBuilder; * @brief Transaction: EscrowCancel * * Type: ttESCROW_CANCEL (4) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use EscrowCancelBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfOfferSequence (soeREQUIRED) + * @brief Get sfOfferSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: * @brief Builder for EscrowCancel transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class EscrowCancelBuilder : public TransactionBuilderBase @@ -115,7 +115,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowCancelBuilder& @@ -126,7 +126,7 @@ public: } /** - * @brief Set sfOfferSequence (soeREQUIRED) + * @brief Set sfOfferSequence (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowCancelBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/EscrowCreate.h b/include/xrpl/protocol_autogen/transactions/EscrowCreate.h index 32dae6cc57..35775c31ae 100644 --- a/include/xrpl/protocol_autogen/transactions/EscrowCreate.h +++ b/include/xrpl/protocol_autogen/transactions/EscrowCreate.h @@ -19,9 +19,9 @@ class EscrowCreateBuilder; * @brief Transaction: EscrowCreate * * Type: ttESCROW_CREATE (1) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use EscrowCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfCondition (soeOPTIONAL) + * @brief Get sfCondition (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -97,7 +97,7 @@ public: } /** - * @brief Get sfCancelAfter (soeOPTIONAL) + * @brief Get sfCancelAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -123,7 +123,7 @@ public: } /** - * @brief Get sfFinishAfter (soeOPTIONAL) + * @brief Get sfFinishAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -149,7 +149,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -179,7 +179,7 @@ public: * @brief Builder for EscrowCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class EscrowCreateBuilder : public TransactionBuilderBase @@ -220,7 +220,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowCreateBuilder& @@ -231,7 +231,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfCondition (soeOPTIONAL) + * @brief Set sfCondition (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowCreateBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfCancelAfter (soeOPTIONAL) + * @brief Set sfCancelAfter (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowCreateBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfFinishAfter (soeOPTIONAL) + * @brief Set sfFinishAfter (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowCreateBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/EscrowFinish.h b/include/xrpl/protocol_autogen/transactions/EscrowFinish.h index 20e9a089fb..f6ca73d209 100644 --- a/include/xrpl/protocol_autogen/transactions/EscrowFinish.h +++ b/include/xrpl/protocol_autogen/transactions/EscrowFinish.h @@ -19,9 +19,9 @@ class EscrowFinishBuilder; * @brief Transaction: EscrowFinish * * Type: ttESCROW_FINISH (2) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use EscrowFinishBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfOwner (soeREQUIRED) + * @brief Get sfOwner (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfOfferSequence (soeREQUIRED) + * @brief Get sfOfferSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfFulfillment (soeOPTIONAL) + * @brief Get sfFulfillment (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -96,7 +96,7 @@ public: } /** - * @brief Get sfCondition (soeOPTIONAL) + * @brief Get sfCondition (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -122,7 +122,7 @@ public: } /** - * @brief Get sfCredentialIDs (soeOPTIONAL) + * @brief Get sfCredentialIDs (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: * @brief Builder for EscrowFinish transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class EscrowFinishBuilder : public TransactionBuilderBase @@ -193,7 +193,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfOwner (soeREQUIRED) + * @brief Set sfOwner (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowFinishBuilder& @@ -204,7 +204,7 @@ public: } /** - * @brief Set sfOfferSequence (soeREQUIRED) + * @brief Set sfOfferSequence (SoeRequired) * @return Reference to this builder for method chaining. */ EscrowFinishBuilder& @@ -215,7 +215,7 @@ public: } /** - * @brief Set sfFulfillment (soeOPTIONAL) + * @brief Set sfFulfillment (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowFinishBuilder& @@ -226,7 +226,7 @@ public: } /** - * @brief Set sfCondition (soeOPTIONAL) + * @brief Set sfCondition (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowFinishBuilder& @@ -237,7 +237,7 @@ public: } /** - * @brief Set sfCredentialIDs (soeOPTIONAL) + * @brief Set sfCredentialIDs (SoeOptional) * @return Reference to this builder for method chaining. */ EscrowFinishBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LedgerStateFix.h b/include/xrpl/protocol_autogen/transactions/LedgerStateFix.h index 6f60b81a04..3c58815a02 100644 --- a/include/xrpl/protocol_autogen/transactions/LedgerStateFix.h +++ b/include/xrpl/protocol_autogen/transactions/LedgerStateFix.h @@ -19,9 +19,9 @@ class LedgerStateFixBuilder; * @brief Transaction: LedgerStateFix * * Type: ttLEDGER_STATE_FIX (53) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: fixNFTokenPageLinks - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use LedgerStateFixBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLedgerFixType (soeREQUIRED) + * @brief Get sfLedgerFixType (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -89,7 +89,7 @@ public: * @brief Builder for LedgerStateFix transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LedgerStateFixBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLedgerFixType (soeREQUIRED) + * @brief Set sfLedgerFixType (SoeRequired) * @return Reference to this builder for method chaining. */ LedgerStateFixBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ LedgerStateFixBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverClawback.h b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverClawback.h index d8a9d9d52a..4842381362 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverClawback.h +++ b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverClawback.h @@ -19,9 +19,9 @@ class LoanBrokerCoverClawbackBuilder; * @brief Transaction: LoanBrokerCoverClawback * * Type: ttLOAN_BROKER_COVER_CLAWBACK (78) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use LoanBrokerCoverClawbackBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanBrokerID (soeOPTIONAL) + * @brief Get sfLoanBrokerID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -105,7 +105,7 @@ public: * @brief Builder for LoanBrokerCoverClawback transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanBrokerCoverClawbackBuilder : public TransactionBuilderBase @@ -142,7 +142,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanBrokerID (soeOPTIONAL) + * @brief Set sfLoanBrokerID (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerCoverClawbackBuilder& @@ -153,7 +153,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverDeposit.h b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverDeposit.h index baa567a7ac..98cebdccb2 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverDeposit.h +++ b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverDeposit.h @@ -19,9 +19,9 @@ class LoanBrokerCoverDepositBuilder; * @brief Transaction: LoanBrokerCoverDeposit * * Type: ttLOAN_BROKER_COVER_DEPOSIT (76) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use LoanBrokerCoverDepositBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanBrokerID (soeREQUIRED) + * @brief Get sfLoanBrokerID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -75,7 +75,7 @@ public: * @brief Builder for LoanBrokerCoverDeposit transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanBrokerCoverDepositBuilder : public TransactionBuilderBase @@ -116,7 +116,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanBrokerID (soeREQUIRED) + * @brief Set sfLoanBrokerID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerCoverDepositBuilder& @@ -127,7 +127,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverWithdraw.h b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverWithdraw.h index 3690b6a40a..e734c6802a 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverWithdraw.h +++ b/include/xrpl/protocol_autogen/transactions/LoanBrokerCoverWithdraw.h @@ -19,9 +19,9 @@ class LoanBrokerCoverWithdrawBuilder; * @brief Transaction: LoanBrokerCoverWithdraw * * Type: ttLOAN_BROKER_COVER_WITHDRAW (77) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: mayAuthorizeMPT + * Privileges: MayAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use LoanBrokerCoverWithdrawBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanBrokerID (soeREQUIRED) + * @brief Get sfLoanBrokerID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -97,7 +97,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: * @brief Builder for LoanBrokerCoverWithdraw transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanBrokerCoverWithdrawBuilder : public TransactionBuilderBase @@ -168,7 +168,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanBrokerID (soeREQUIRED) + * @brief Set sfLoanBrokerID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerCoverWithdrawBuilder& @@ -179,7 +179,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -191,7 +191,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerCoverWithdrawBuilder& @@ -202,7 +202,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerCoverWithdrawBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanBrokerDelete.h b/include/xrpl/protocol_autogen/transactions/LoanBrokerDelete.h index 2c174ae500..55c0a12381 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanBrokerDelete.h +++ b/include/xrpl/protocol_autogen/transactions/LoanBrokerDelete.h @@ -19,9 +19,9 @@ class LoanBrokerDeleteBuilder; * @brief Transaction: LoanBrokerDelete * * Type: ttLOAN_BROKER_DELETE (75) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: mustDeleteAcct | mayAuthorizeMPT + * Privileges: MustDeleteAcct | MayAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use LoanBrokerDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanBrokerID (soeREQUIRED) + * @brief Get sfLoanBrokerID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for LoanBrokerDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanBrokerDeleteBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanBrokerID (soeREQUIRED) + * @brief Set sfLoanBrokerID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanBrokerSet.h b/include/xrpl/protocol_autogen/transactions/LoanBrokerSet.h index ba6ca06266..854022242d 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanBrokerSet.h +++ b/include/xrpl/protocol_autogen/transactions/LoanBrokerSet.h @@ -19,9 +19,9 @@ class LoanBrokerSetBuilder; * @brief Transaction: LoanBrokerSet * * Type: ttLOAN_BROKER_SET (74) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: createPseudoAcct | mayAuthorizeMPT + * Privileges: CreatePseudoAcct | MayAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use LoanBrokerSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfLoanBrokerID (soeOPTIONAL) + * @brief Get sfLoanBrokerID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfManagementFeeRate (soeOPTIONAL) + * @brief Get sfManagementFeeRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -137,7 +137,7 @@ public: } /** - * @brief Get sfDebtMaximum (soeOPTIONAL) + * @brief Get sfDebtMaximum (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -163,7 +163,7 @@ public: } /** - * @brief Get sfCoverRateMinimum (soeOPTIONAL) + * @brief Get sfCoverRateMinimum (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -189,7 +189,7 @@ public: } /** - * @brief Get sfCoverRateLiquidation (soeOPTIONAL) + * @brief Get sfCoverRateLiquidation (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -219,7 +219,7 @@ public: * @brief Builder for LoanBrokerSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanBrokerSetBuilder : public TransactionBuilderBase @@ -258,7 +258,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -269,7 +269,7 @@ public: } /** - * @brief Set sfLoanBrokerID (soeOPTIONAL) + * @brief Set sfLoanBrokerID (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -280,7 +280,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -291,7 +291,7 @@ public: } /** - * @brief Set sfManagementFeeRate (soeOPTIONAL) + * @brief Set sfManagementFeeRate (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -302,7 +302,7 @@ public: } /** - * @brief Set sfDebtMaximum (soeOPTIONAL) + * @brief Set sfDebtMaximum (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -313,7 +313,7 @@ public: } /** - * @brief Set sfCoverRateMinimum (soeOPTIONAL) + * @brief Set sfCoverRateMinimum (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& @@ -324,7 +324,7 @@ public: } /** - * @brief Set sfCoverRateLiquidation (soeOPTIONAL) + * @brief Set sfCoverRateLiquidation (SoeOptional) * @return Reference to this builder for method chaining. */ LoanBrokerSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanDelete.h b/include/xrpl/protocol_autogen/transactions/LoanDelete.h index df1b49d17e..70c9e50097 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanDelete.h +++ b/include/xrpl/protocol_autogen/transactions/LoanDelete.h @@ -19,9 +19,9 @@ class LoanDeleteBuilder; * @brief Transaction: LoanDelete * * Type: ttLOAN_DELETE (81) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use LoanDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanID (soeREQUIRED) + * @brief Get sfLoanID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for LoanDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanDeleteBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanID (soeREQUIRED) + * @brief Set sfLoanID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanManage.h b/include/xrpl/protocol_autogen/transactions/LoanManage.h index 3da31e4487..f11782c4e1 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanManage.h +++ b/include/xrpl/protocol_autogen/transactions/LoanManage.h @@ -19,9 +19,9 @@ class LoanManageBuilder; * @brief Transaction: LoanManage * * Type: ttLOAN_MANAGE (82) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: mayModifyVault + * Privileges: MayModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use LoanManageBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanID (soeREQUIRED) + * @brief Get sfLoanID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for LoanManage transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanManageBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanID (soeREQUIRED) + * @brief Set sfLoanID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanManageBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/LoanPay.h b/include/xrpl/protocol_autogen/transactions/LoanPay.h index e0b4376e18..4012225e17 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanPay.h +++ b/include/xrpl/protocol_autogen/transactions/LoanPay.h @@ -19,9 +19,9 @@ class LoanPayBuilder; * @brief Transaction: LoanPay * * Type: ttLOAN_PAY (84) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: mayAuthorizeMPT | mustModifyVault + * Privileges: MayAuthorizeMpt | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use LoanPayBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanID (soeREQUIRED) + * @brief Get sfLoanID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -75,7 +75,7 @@ public: * @brief Builder for LoanPay transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanPayBuilder : public TransactionBuilderBase @@ -116,7 +116,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanID (soeREQUIRED) + * @brief Set sfLoanID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanPayBuilder& @@ -127,7 +127,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/LoanSet.h b/include/xrpl/protocol_autogen/transactions/LoanSet.h index 7d6181f517..3fa3c905c2 100644 --- a/include/xrpl/protocol_autogen/transactions/LoanSet.h +++ b/include/xrpl/protocol_autogen/transactions/LoanSet.h @@ -19,9 +19,9 @@ class LoanSetBuilder; * @brief Transaction: LoanSet * * Type: ttLOAN_SET (80) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureLendingProtocol - * Privileges: mayAuthorizeMPT | mustModifyVault + * Privileges: MayAuthorizeMpt | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use LoanSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLoanBrokerID (soeREQUIRED) + * @brief Get sfLoanBrokerID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfCounterparty (soeOPTIONAL) + * @brief Get sfCounterparty (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -110,7 +110,7 @@ public: return this->tx_->isFieldPresent(sfCounterparty); } /** - * @brief Get sfCounterpartySignature (soeOPTIONAL) + * @brief Get sfCounterpartySignature (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -135,7 +135,7 @@ public: } /** - * @brief Get sfLoanOriginationFee (soeOPTIONAL) + * @brief Get sfLoanOriginationFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -161,7 +161,7 @@ public: } /** - * @brief Get sfLoanServiceFee (soeOPTIONAL) + * @brief Get sfLoanServiceFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -187,7 +187,7 @@ public: } /** - * @brief Get sfLatePaymentFee (soeOPTIONAL) + * @brief Get sfLatePaymentFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -213,7 +213,7 @@ public: } /** - * @brief Get sfClosePaymentFee (soeOPTIONAL) + * @brief Get sfClosePaymentFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -239,7 +239,7 @@ public: } /** - * @brief Get sfOverpaymentFee (soeOPTIONAL) + * @brief Get sfOverpaymentFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -265,7 +265,7 @@ public: } /** - * @brief Get sfInterestRate (soeOPTIONAL) + * @brief Get sfInterestRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -291,7 +291,7 @@ public: } /** - * @brief Get sfLateInterestRate (soeOPTIONAL) + * @brief Get sfLateInterestRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -317,7 +317,7 @@ public: } /** - * @brief Get sfCloseInterestRate (soeOPTIONAL) + * @brief Get sfCloseInterestRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -343,7 +343,7 @@ public: } /** - * @brief Get sfOverpaymentInterestRate (soeOPTIONAL) + * @brief Get sfOverpaymentInterestRate (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -369,7 +369,7 @@ public: } /** - * @brief Get sfPrincipalRequested (soeREQUIRED) + * @brief Get sfPrincipalRequested (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -380,7 +380,7 @@ public: } /** - * @brief Get sfPaymentTotal (soeOPTIONAL) + * @brief Get sfPaymentTotal (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -406,7 +406,7 @@ public: } /** - * @brief Get sfPaymentInterval (soeOPTIONAL) + * @brief Get sfPaymentInterval (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -432,7 +432,7 @@ public: } /** - * @brief Get sfGracePeriod (soeOPTIONAL) + * @brief Get sfGracePeriod (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -462,7 +462,7 @@ public: * @brief Builder for LoanSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class LoanSetBuilder : public TransactionBuilderBase @@ -503,7 +503,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLoanBrokerID (soeREQUIRED) + * @brief Set sfLoanBrokerID (SoeRequired) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -514,7 +514,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -525,7 +525,7 @@ public: } /** - * @brief Set sfCounterparty (soeOPTIONAL) + * @brief Set sfCounterparty (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -536,7 +536,7 @@ public: } /** - * @brief Set sfCounterpartySignature (soeOPTIONAL) + * @brief Set sfCounterpartySignature (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -547,7 +547,7 @@ public: } /** - * @brief Set sfLoanOriginationFee (soeOPTIONAL) + * @brief Set sfLoanOriginationFee (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -558,7 +558,7 @@ public: } /** - * @brief Set sfLoanServiceFee (soeOPTIONAL) + * @brief Set sfLoanServiceFee (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -569,7 +569,7 @@ public: } /** - * @brief Set sfLatePaymentFee (soeOPTIONAL) + * @brief Set sfLatePaymentFee (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -580,7 +580,7 @@ public: } /** - * @brief Set sfClosePaymentFee (soeOPTIONAL) + * @brief Set sfClosePaymentFee (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -591,7 +591,7 @@ public: } /** - * @brief Set sfOverpaymentFee (soeOPTIONAL) + * @brief Set sfOverpaymentFee (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -602,7 +602,7 @@ public: } /** - * @brief Set sfInterestRate (soeOPTIONAL) + * @brief Set sfInterestRate (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -613,7 +613,7 @@ public: } /** - * @brief Set sfLateInterestRate (soeOPTIONAL) + * @brief Set sfLateInterestRate (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -624,7 +624,7 @@ public: } /** - * @brief Set sfCloseInterestRate (soeOPTIONAL) + * @brief Set sfCloseInterestRate (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -635,7 +635,7 @@ public: } /** - * @brief Set sfOverpaymentInterestRate (soeOPTIONAL) + * @brief Set sfOverpaymentInterestRate (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -646,7 +646,7 @@ public: } /** - * @brief Set sfPrincipalRequested (soeREQUIRED) + * @brief Set sfPrincipalRequested (SoeRequired) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -657,7 +657,7 @@ public: } /** - * @brief Set sfPaymentTotal (soeOPTIONAL) + * @brief Set sfPaymentTotal (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -668,7 +668,7 @@ public: } /** - * @brief Set sfPaymentInterval (soeOPTIONAL) + * @brief Set sfPaymentInterval (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& @@ -679,7 +679,7 @@ public: } /** - * @brief Set sfGracePeriod (soeOPTIONAL) + * @brief Set sfGracePeriod (SoeOptional) * @return Reference to this builder for method chaining. */ LoanSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/MPTokenAuthorize.h b/include/xrpl/protocol_autogen/transactions/MPTokenAuthorize.h index a4641f5dc0..90440c41f9 100644 --- a/include/xrpl/protocol_autogen/transactions/MPTokenAuthorize.h +++ b/include/xrpl/protocol_autogen/transactions/MPTokenAuthorize.h @@ -19,9 +19,9 @@ class MPTokenAuthorizeBuilder; * @brief Transaction: MPTokenAuthorize * * Type: ttMPTOKEN_AUTHORIZE (57) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureMPTokensV1 - * Privileges: mustAuthorizeMPT + * Privileges: MustAuthorizeMpt * * Immutable wrapper around STTx providing type-safe field access. * Use MPTokenAuthorizeBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfMPTokenIssuanceID (soeREQUIRED) + * @brief Get sfMPTokenIssuanceID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfHolder (soeOPTIONAL) + * @brief Get sfHolder (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -89,7 +89,7 @@ public: * @brief Builder for MPTokenAuthorize transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class MPTokenAuthorizeBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfMPTokenIssuanceID (soeREQUIRED) + * @brief Set sfMPTokenIssuanceID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenAuthorizeBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfHolder (soeOPTIONAL) + * @brief Set sfHolder (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenAuthorizeBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceCreate.h b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceCreate.h index 6f5c50fc4a..d723a3041c 100644 --- a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceCreate.h +++ b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceCreate.h @@ -19,9 +19,9 @@ class MPTokenIssuanceCreateBuilder; * @brief Transaction: MPTokenIssuanceCreate * * Type: ttMPTOKEN_ISSUANCE_CREATE (54) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureMPTokensV1 - * Privileges: createMPTIssuance + * Privileges: CreateMptIssuance * * Immutable wrapper around STTx providing type-safe field access. * Use MPTokenIssuanceCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAssetScale (soeOPTIONAL) + * @brief Get sfAssetScale (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfTransferFee (soeOPTIONAL) + * @brief Get sfTransferFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfMaximumAmount (soeOPTIONAL) + * @brief Get sfMaximumAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfMPTokenMetadata (soeOPTIONAL) + * @brief Get sfMPTokenMetadata (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -178,7 +178,7 @@ public: } /** - * @brief Get sfMutableFlags (soeOPTIONAL) + * @brief Get sfMutableFlags (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -208,7 +208,7 @@ public: * @brief Builder for MPTokenIssuanceCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class MPTokenIssuanceCreateBuilder : public TransactionBuilderBase @@ -245,7 +245,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAssetScale (soeOPTIONAL) + * @brief Set sfAssetScale (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& @@ -256,7 +256,7 @@ public: } /** - * @brief Set sfTransferFee (soeOPTIONAL) + * @brief Set sfTransferFee (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& @@ -267,7 +267,7 @@ public: } /** - * @brief Set sfMaximumAmount (soeOPTIONAL) + * @brief Set sfMaximumAmount (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& @@ -278,7 +278,7 @@ public: } /** - * @brief Set sfMPTokenMetadata (soeOPTIONAL) + * @brief Set sfMPTokenMetadata (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& @@ -289,7 +289,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& @@ -300,7 +300,7 @@ public: } /** - * @brief Set sfMutableFlags (soeOPTIONAL) + * @brief Set sfMutableFlags (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceDestroy.h b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceDestroy.h index 28d2e49971..19c4530792 100644 --- a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceDestroy.h +++ b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceDestroy.h @@ -19,9 +19,9 @@ class MPTokenIssuanceDestroyBuilder; * @brief Transaction: MPTokenIssuanceDestroy * * Type: ttMPTOKEN_ISSUANCE_DESTROY (55) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureMPTokensV1 - * Privileges: destroyMPTIssuance + * Privileges: DestroyMptIssuance * * Immutable wrapper around STTx providing type-safe field access. * Use MPTokenIssuanceDestroyBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfMPTokenIssuanceID (soeREQUIRED) + * @brief Get sfMPTokenIssuanceID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for MPTokenIssuanceDestroy transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class MPTokenIssuanceDestroyBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfMPTokenIssuanceID (soeREQUIRED) + * @brief Set sfMPTokenIssuanceID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceDestroyBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceSet.h b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceSet.h index 429b252e95..a92521173b 100644 --- a/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceSet.h +++ b/include/xrpl/protocol_autogen/transactions/MPTokenIssuanceSet.h @@ -19,9 +19,9 @@ class MPTokenIssuanceSetBuilder; * @brief Transaction: MPTokenIssuanceSet * * Type: ttMPTOKEN_ISSUANCE_SET (56) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureMPTokensV1 - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use MPTokenIssuanceSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfMPTokenIssuanceID (soeREQUIRED) + * @brief Get sfMPTokenIssuanceID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfHolder (soeOPTIONAL) + * @brief Get sfHolder (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfMPTokenMetadata (soeOPTIONAL) + * @brief Get sfMPTokenMetadata (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -137,7 +137,7 @@ public: } /** - * @brief Get sfTransferFee (soeOPTIONAL) + * @brief Get sfTransferFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -163,7 +163,7 @@ public: } /** - * @brief Get sfMutableFlags (soeOPTIONAL) + * @brief Get sfMutableFlags (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -193,7 +193,7 @@ public: * @brief Builder for MPTokenIssuanceSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class MPTokenIssuanceSetBuilder : public TransactionBuilderBase @@ -232,7 +232,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfMPTokenIssuanceID (soeREQUIRED) + * @brief Set sfMPTokenIssuanceID (SoeRequired) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfHolder (soeOPTIONAL) + * @brief Set sfHolder (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfMPTokenMetadata (soeOPTIONAL) + * @brief Set sfMPTokenMetadata (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfTransferFee (soeOPTIONAL) + * @brief Set sfTransferFee (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& @@ -287,7 +287,7 @@ public: } /** - * @brief Set sfMutableFlags (soeOPTIONAL) + * @brief Set sfMutableFlags (SoeOptional) * @return Reference to this builder for method chaining. */ MPTokenIssuanceSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenAcceptOffer.h b/include/xrpl/protocol_autogen/transactions/NFTokenAcceptOffer.h index 53ae614ee4..7627437a52 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenAcceptOffer.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenAcceptOffer.h @@ -19,9 +19,9 @@ class NFTokenAcceptOfferBuilder; * @brief Transaction: NFTokenAcceptOffer * * Type: ttNFTOKEN_ACCEPT_OFFER (29) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenAcceptOfferBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenBuyOffer (soeOPTIONAL) + * @brief Get sfNFTokenBuyOffer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfNFTokenSellOffer (soeOPTIONAL) + * @brief Get sfNFTokenSellOffer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfNFTokenBrokerFee (soeOPTIONAL) + * @brief Get sfNFTokenBrokerFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -130,7 +130,7 @@ public: * @brief Builder for NFTokenAcceptOffer transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenAcceptOfferBuilder : public TransactionBuilderBase @@ -167,7 +167,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenBuyOffer (soeOPTIONAL) + * @brief Set sfNFTokenBuyOffer (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenAcceptOfferBuilder& @@ -178,7 +178,7 @@ public: } /** - * @brief Set sfNFTokenSellOffer (soeOPTIONAL) + * @brief Set sfNFTokenSellOffer (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenAcceptOfferBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfNFTokenBrokerFee (soeOPTIONAL) + * @brief Set sfNFTokenBrokerFee (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenAcceptOfferBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenBurn.h b/include/xrpl/protocol_autogen/transactions/NFTokenBurn.h index 123418d00a..9f981b1ec4 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenBurn.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenBurn.h @@ -19,9 +19,9 @@ class NFTokenBurnBuilder; * @brief Transaction: NFTokenBurn * * Type: ttNFTOKEN_BURN (26) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: changeNFTCounts + * Privileges: ChangeNftCounts * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenBurnBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenID (soeREQUIRED) + * @brief Get sfNFTokenID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -89,7 +89,7 @@ public: * @brief Builder for NFTokenBurn transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenBurnBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenID (soeREQUIRED) + * @brief Set sfNFTokenID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenBurnBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenBurnBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenCancelOffer.h b/include/xrpl/protocol_autogen/transactions/NFTokenCancelOffer.h index 5fbbeca96c..2eca27fc8d 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenCancelOffer.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenCancelOffer.h @@ -19,9 +19,9 @@ class NFTokenCancelOfferBuilder; * @brief Transaction: NFTokenCancelOffer * * Type: ttNFTOKEN_CANCEL_OFFER (28) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenCancelOfferBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenOffers (soeREQUIRED) + * @brief Get sfNFTokenOffers (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for NFTokenCancelOffer transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenCancelOfferBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenOffers (soeREQUIRED) + * @brief Set sfNFTokenOffers (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenCancelOfferBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenCreateOffer.h b/include/xrpl/protocol_autogen/transactions/NFTokenCreateOffer.h index e820272f83..a5c6e226d9 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenCreateOffer.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenCreateOffer.h @@ -19,9 +19,9 @@ class NFTokenCreateOfferBuilder; * @brief Transaction: NFTokenCreateOffer * * Type: ttNFTOKEN_CREATE_OFFER (27) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenCreateOfferBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenID (soeREQUIRED) + * @brief Get sfNFTokenID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -96,7 +96,7 @@ public: } /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -122,7 +122,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: * @brief Builder for NFTokenCreateOffer transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenCreateOfferBuilder : public TransactionBuilderBase @@ -193,7 +193,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenID (soeREQUIRED) + * @brief Set sfNFTokenID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenCreateOfferBuilder& @@ -204,7 +204,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenCreateOfferBuilder& @@ -215,7 +215,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenCreateOfferBuilder& @@ -226,7 +226,7 @@ public: } /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenCreateOfferBuilder& @@ -237,7 +237,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenCreateOfferBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenMint.h b/include/xrpl/protocol_autogen/transactions/NFTokenMint.h index 9854147570..ad68f1a18b 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenMint.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenMint.h @@ -19,9 +19,9 @@ class NFTokenMintBuilder; * @brief Transaction: NFTokenMint * * Type: ttNFTOKEN_MINT (25) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: changeNFTCounts + * Privileges: ChangeNftCounts * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenMintBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenTaxon (soeREQUIRED) + * @brief Get sfNFTokenTaxon (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfTransferFee (soeOPTIONAL) + * @brief Get sfTransferFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfIssuer (soeOPTIONAL) + * @brief Get sfIssuer (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -137,7 +137,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -163,7 +163,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -189,7 +189,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -219,7 +219,7 @@ public: * @brief Builder for NFTokenMint transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenMintBuilder : public TransactionBuilderBase @@ -258,7 +258,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenTaxon (soeREQUIRED) + * @brief Set sfNFTokenTaxon (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -269,7 +269,7 @@ public: } /** - * @brief Set sfTransferFee (soeOPTIONAL) + * @brief Set sfTransferFee (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -280,7 +280,7 @@ public: } /** - * @brief Set sfIssuer (soeOPTIONAL) + * @brief Set sfIssuer (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -291,7 +291,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -302,7 +302,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -313,7 +313,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& @@ -324,7 +324,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenMintBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/NFTokenModify.h b/include/xrpl/protocol_autogen/transactions/NFTokenModify.h index 6f9b75532c..277146ce78 100644 --- a/include/xrpl/protocol_autogen/transactions/NFTokenModify.h +++ b/include/xrpl/protocol_autogen/transactions/NFTokenModify.h @@ -19,9 +19,9 @@ class NFTokenModifyBuilder; * @brief Transaction: NFTokenModify * * Type: ttNFTOKEN_MODIFY (61) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureDynamicNFT - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use NFTokenModifyBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfNFTokenID (soeREQUIRED) + * @brief Get sfNFTokenID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfOwner (soeOPTIONAL) + * @brief Get sfOwner (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: * @brief Builder for NFTokenModify transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class NFTokenModifyBuilder : public TransactionBuilderBase @@ -154,7 +154,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfNFTokenID (soeREQUIRED) + * @brief Set sfNFTokenID (SoeRequired) * @return Reference to this builder for method chaining. */ NFTokenModifyBuilder& @@ -165,7 +165,7 @@ public: } /** - * @brief Set sfOwner (soeOPTIONAL) + * @brief Set sfOwner (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenModifyBuilder& @@ -176,7 +176,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ NFTokenModifyBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/OfferCancel.h b/include/xrpl/protocol_autogen/transactions/OfferCancel.h index ed2c761c0e..833924f683 100644 --- a/include/xrpl/protocol_autogen/transactions/OfferCancel.h +++ b/include/xrpl/protocol_autogen/transactions/OfferCancel.h @@ -19,9 +19,9 @@ class OfferCancelBuilder; * @brief Transaction: OfferCancel * * Type: ttOFFER_CANCEL (8) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use OfferCancelBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfOfferSequence (soeREQUIRED) + * @brief Get sfOfferSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for OfferCancel transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class OfferCancelBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfOfferSequence (soeREQUIRED) + * @brief Set sfOfferSequence (SoeRequired) * @return Reference to this builder for method chaining. */ OfferCancelBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/OfferCreate.h b/include/xrpl/protocol_autogen/transactions/OfferCreate.h index 2735eb85f7..13e868643f 100644 --- a/include/xrpl/protocol_autogen/transactions/OfferCreate.h +++ b/include/xrpl/protocol_autogen/transactions/OfferCreate.h @@ -19,9 +19,9 @@ class OfferCreateBuilder; * @brief Transaction: OfferCreate * * Type: ttOFFER_CREATE (7) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: mayCreateMPT + * Privileges: MayCreateMpt * * Immutable wrapper around STTx providing type-safe field access. * Use OfferCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfTakerPays (soeREQUIRED) + * @brief Get sfTakerPays (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfTakerGets (soeREQUIRED) + * @brief Get sfTakerGets (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -72,7 +72,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -98,7 +98,7 @@ public: } /** - * @brief Get sfOfferSequence (soeOPTIONAL) + * @brief Get sfOfferSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -124,7 +124,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -154,7 +154,7 @@ public: * @brief Builder for OfferCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class OfferCreateBuilder : public TransactionBuilderBase @@ -195,7 +195,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfTakerPays (soeREQUIRED) + * @brief Set sfTakerPays (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -207,7 +207,7 @@ public: } /** - * @brief Set sfTakerGets (soeREQUIRED) + * @brief Set sfTakerGets (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -219,7 +219,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ OfferCreateBuilder& @@ -230,7 +230,7 @@ public: } /** - * @brief Set sfOfferSequence (soeOPTIONAL) + * @brief Set sfOfferSequence (SoeOptional) * @return Reference to this builder for method chaining. */ OfferCreateBuilder& @@ -241,7 +241,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ OfferCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/OracleDelete.h b/include/xrpl/protocol_autogen/transactions/OracleDelete.h index 6cafd2b6de..d6d46d1d7a 100644 --- a/include/xrpl/protocol_autogen/transactions/OracleDelete.h +++ b/include/xrpl/protocol_autogen/transactions/OracleDelete.h @@ -19,9 +19,9 @@ class OracleDeleteBuilder; * @brief Transaction: OracleDelete * * Type: ttORACLE_DELETE (52) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featurePriceOracle - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use OracleDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfOracleDocumentID (soeREQUIRED) + * @brief Get sfOracleDocumentID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for OracleDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class OracleDeleteBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfOracleDocumentID (soeREQUIRED) + * @brief Set sfOracleDocumentID (SoeRequired) * @return Reference to this builder for method chaining. */ OracleDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/OracleSet.h b/include/xrpl/protocol_autogen/transactions/OracleSet.h index 8dd0d88865..1d295b4cc2 100644 --- a/include/xrpl/protocol_autogen/transactions/OracleSet.h +++ b/include/xrpl/protocol_autogen/transactions/OracleSet.h @@ -19,9 +19,9 @@ class OracleSetBuilder; * @brief Transaction: OracleSet * * Type: ttORACLE_SET (51) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featurePriceOracle - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use OracleSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfOracleDocumentID (soeREQUIRED) + * @brief Get sfOracleDocumentID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfProvider (soeOPTIONAL) + * @brief Get sfProvider (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfURI (soeOPTIONAL) + * @brief Get sfURI (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfAssetClass (soeOPTIONAL) + * @brief Get sfAssetClass (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -137,7 +137,7 @@ public: } /** - * @brief Get sfLastUpdateTime (soeREQUIRED) + * @brief Get sfLastUpdateTime (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: return this->tx_->at(sfLastUpdateTime); } /** - * @brief Get sfPriceDataSeries (soeREQUIRED) + * @brief Get sfPriceDataSeries (SoeRequired) * @note This is an untyped field. * @return The field value. */ @@ -163,7 +163,7 @@ public: * @brief Builder for OracleSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class OracleSetBuilder : public TransactionBuilderBase @@ -206,7 +206,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfOracleDocumentID (soeREQUIRED) + * @brief Set sfOracleDocumentID (SoeRequired) * @return Reference to this builder for method chaining. */ OracleSetBuilder& @@ -217,7 +217,7 @@ public: } /** - * @brief Set sfProvider (soeOPTIONAL) + * @brief Set sfProvider (SoeOptional) * @return Reference to this builder for method chaining. */ OracleSetBuilder& @@ -228,7 +228,7 @@ public: } /** - * @brief Set sfURI (soeOPTIONAL) + * @brief Set sfURI (SoeOptional) * @return Reference to this builder for method chaining. */ OracleSetBuilder& @@ -239,7 +239,7 @@ public: } /** - * @brief Set sfAssetClass (soeOPTIONAL) + * @brief Set sfAssetClass (SoeOptional) * @return Reference to this builder for method chaining. */ OracleSetBuilder& @@ -250,7 +250,7 @@ public: } /** - * @brief Set sfLastUpdateTime (soeREQUIRED) + * @brief Set sfLastUpdateTime (SoeRequired) * @return Reference to this builder for method chaining. */ OracleSetBuilder& @@ -261,7 +261,7 @@ public: } /** - * @brief Set sfPriceDataSeries (soeREQUIRED) + * @brief Set sfPriceDataSeries (SoeRequired) * @return Reference to this builder for method chaining. */ OracleSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/Payment.h b/include/xrpl/protocol_autogen/transactions/Payment.h index edf496dc6d..b2e82cd6af 100644 --- a/include/xrpl/protocol_autogen/transactions/Payment.h +++ b/include/xrpl/protocol_autogen/transactions/Payment.h @@ -19,9 +19,9 @@ class PaymentBuilder; * @brief Transaction: Payment * * Type: ttPAYMENT (0) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: createAcct | mayCreateMPT + * Privileges: CreateAcct | MayCreateMpt * * Immutable wrapper around STTx providing type-safe field access. * Use PaymentBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfSendMax (soeOPTIONAL) + * @brief Get sfSendMax (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -97,7 +97,7 @@ public: return this->tx_->isFieldPresent(sfSendMax); } /** - * @brief Get sfPaths (soeDEFAULT) + * @brief Get sfPaths (SoeDefault) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -122,7 +122,7 @@ public: } /** - * @brief Get sfInvoiceID (soeOPTIONAL) + * @brief Get sfInvoiceID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -148,7 +148,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -174,7 +174,7 @@ public: } /** - * @brief Get sfDeliverMin (soeOPTIONAL) + * @brief Get sfDeliverMin (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -201,7 +201,7 @@ public: } /** - * @brief Get sfCredentialIDs (soeOPTIONAL) + * @brief Get sfCredentialIDs (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -227,7 +227,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -257,7 +257,7 @@ public: * @brief Builder for Payment transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PaymentBuilder : public TransactionBuilderBase @@ -298,7 +298,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentBuilder& @@ -309,7 +309,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -321,7 +321,7 @@ public: } /** - * @brief Set sfSendMax (soeOPTIONAL) + * @brief Set sfSendMax (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -333,7 +333,7 @@ public: } /** - * @brief Set sfPaths (soeDEFAULT) + * @brief Set sfPaths (SoeDefault) * @return Reference to this builder for method chaining. */ PaymentBuilder& @@ -344,7 +344,7 @@ public: } /** - * @brief Set sfInvoiceID (soeOPTIONAL) + * @brief Set sfInvoiceID (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentBuilder& @@ -355,7 +355,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentBuilder& @@ -366,7 +366,7 @@ public: } /** - * @brief Set sfDeliverMin (soeOPTIONAL) + * @brief Set sfDeliverMin (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -378,7 +378,7 @@ public: } /** - * @brief Set sfCredentialIDs (soeOPTIONAL) + * @brief Set sfCredentialIDs (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentBuilder& @@ -389,7 +389,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/PaymentChannelClaim.h b/include/xrpl/protocol_autogen/transactions/PaymentChannelClaim.h index 1e90c74aa1..1db3057366 100644 --- a/include/xrpl/protocol_autogen/transactions/PaymentChannelClaim.h +++ b/include/xrpl/protocol_autogen/transactions/PaymentChannelClaim.h @@ -19,9 +19,9 @@ class PaymentChannelClaimBuilder; * @brief Transaction: PaymentChannelClaim * * Type: ttPAYCHAN_CLAIM (15) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use PaymentChannelClaimBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfChannel (soeREQUIRED) + * @brief Get sfChannel (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfBalance (soeOPTIONAL) + * @brief Get sfBalance (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfSignature (soeOPTIONAL) + * @brief Get sfSignature (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -137,7 +137,7 @@ public: } /** - * @brief Get sfPublicKey (soeOPTIONAL) + * @brief Get sfPublicKey (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -163,7 +163,7 @@ public: } /** - * @brief Get sfCredentialIDs (soeOPTIONAL) + * @brief Get sfCredentialIDs (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -193,7 +193,7 @@ public: * @brief Builder for PaymentChannelClaim transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PaymentChannelClaimBuilder : public TransactionBuilderBase @@ -232,7 +232,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfChannel (soeREQUIRED) + * @brief Set sfChannel (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfBalance (soeOPTIONAL) + * @brief Set sfBalance (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfSignature (soeOPTIONAL) + * @brief Set sfSignature (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfPublicKey (soeOPTIONAL) + * @brief Set sfPublicKey (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& @@ -287,7 +287,7 @@ public: } /** - * @brief Set sfCredentialIDs (soeOPTIONAL) + * @brief Set sfCredentialIDs (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelClaimBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/PaymentChannelCreate.h b/include/xrpl/protocol_autogen/transactions/PaymentChannelCreate.h index 4242046114..cf0cbae2aa 100644 --- a/include/xrpl/protocol_autogen/transactions/PaymentChannelCreate.h +++ b/include/xrpl/protocol_autogen/transactions/PaymentChannelCreate.h @@ -19,9 +19,9 @@ class PaymentChannelCreateBuilder; * @brief Transaction: PaymentChannelCreate * * Type: ttPAYCHAN_CREATE (13) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use PaymentChannelCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfSettleDelay (soeREQUIRED) + * @brief Get sfSettleDelay (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfPublicKey (soeREQUIRED) + * @brief Get sfPublicKey (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfCancelAfter (soeOPTIONAL) + * @brief Get sfCancelAfter (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -118,7 +118,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -148,7 +148,7 @@ public: * @brief Builder for PaymentChannelCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PaymentChannelCreateBuilder : public TransactionBuilderBase @@ -193,7 +193,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& @@ -204,7 +204,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& @@ -215,7 +215,7 @@ public: } /** - * @brief Set sfSettleDelay (soeREQUIRED) + * @brief Set sfSettleDelay (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& @@ -226,7 +226,7 @@ public: } /** - * @brief Set sfPublicKey (soeREQUIRED) + * @brief Set sfPublicKey (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& @@ -237,7 +237,7 @@ public: } /** - * @brief Set sfCancelAfter (soeOPTIONAL) + * @brief Set sfCancelAfter (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& @@ -248,7 +248,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/PaymentChannelFund.h b/include/xrpl/protocol_autogen/transactions/PaymentChannelFund.h index 2fecf21154..3612fcbf48 100644 --- a/include/xrpl/protocol_autogen/transactions/PaymentChannelFund.h +++ b/include/xrpl/protocol_autogen/transactions/PaymentChannelFund.h @@ -19,9 +19,9 @@ class PaymentChannelFundBuilder; * @brief Transaction: PaymentChannelFund * * Type: ttPAYCHAN_FUND (14) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use PaymentChannelFundBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfChannel (soeREQUIRED) + * @brief Get sfChannel (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfExpiration (soeOPTIONAL) + * @brief Get sfExpiration (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: * @brief Builder for PaymentChannelFund transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PaymentChannelFundBuilder : public TransactionBuilderBase @@ -141,7 +141,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfChannel (soeREQUIRED) + * @brief Set sfChannel (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelFundBuilder& @@ -152,7 +152,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ PaymentChannelFundBuilder& @@ -163,7 +163,7 @@ public: } /** - * @brief Set sfExpiration (soeOPTIONAL) + * @brief Set sfExpiration (SoeOptional) * @return Reference to this builder for method chaining. */ PaymentChannelFundBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/PermissionedDomainDelete.h b/include/xrpl/protocol_autogen/transactions/PermissionedDomainDelete.h index c95e0f2e18..e08ff1ed5a 100644 --- a/include/xrpl/protocol_autogen/transactions/PermissionedDomainDelete.h +++ b/include/xrpl/protocol_autogen/transactions/PermissionedDomainDelete.h @@ -19,9 +19,9 @@ class PermissionedDomainDeleteBuilder; * @brief Transaction: PermissionedDomainDelete * * Type: ttPERMISSIONED_DOMAIN_DELETE (63) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featurePermissionedDomains - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use PermissionedDomainDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDomainID (soeREQUIRED) + * @brief Get sfDomainID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for PermissionedDomainDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PermissionedDomainDeleteBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDomainID (soeREQUIRED) + * @brief Set sfDomainID (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/PermissionedDomainSet.h b/include/xrpl/protocol_autogen/transactions/PermissionedDomainSet.h index 38df7f4fc7..68f1cfebb2 100644 --- a/include/xrpl/protocol_autogen/transactions/PermissionedDomainSet.h +++ b/include/xrpl/protocol_autogen/transactions/PermissionedDomainSet.h @@ -19,9 +19,9 @@ class PermissionedDomainSetBuilder; * @brief Transaction: PermissionedDomainSet * * Type: ttPERMISSIONED_DOMAIN_SET (62) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featurePermissionedDomains - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use PermissionedDomainSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -73,7 +73,7 @@ public: return this->tx_->isFieldPresent(sfDomainID); } /** - * @brief Get sfAcceptedCredentials (soeREQUIRED) + * @brief Get sfAcceptedCredentials (SoeRequired) * @note This is an untyped field. * @return The field value. */ @@ -89,7 +89,7 @@ public: * @brief Builder for PermissionedDomainSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class PermissionedDomainSetBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ PermissionedDomainSetBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfAcceptedCredentials (soeREQUIRED) + * @brief Set sfAcceptedCredentials (SoeRequired) * @return Reference to this builder for method chaining. */ PermissionedDomainSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/SetFee.h b/include/xrpl/protocol_autogen/transactions/SetFee.h index 7bf73201b9..bc5fc0e603 100644 --- a/include/xrpl/protocol_autogen/transactions/SetFee.h +++ b/include/xrpl/protocol_autogen/transactions/SetFee.h @@ -19,9 +19,9 @@ class SetFeeBuilder; * @brief Transaction: SetFee * * Type: ttFEE (101) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use SetFeeBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLedgerSequence (soeOPTIONAL) + * @brief Get sfLedgerSequence (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfBaseFee (soeOPTIONAL) + * @brief Get sfBaseFee (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfReferenceFeeUnits (soeOPTIONAL) + * @brief Get sfReferenceFeeUnits (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -126,7 +126,7 @@ public: } /** - * @brief Get sfReserveBase (soeOPTIONAL) + * @brief Get sfReserveBase (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -152,7 +152,7 @@ public: } /** - * @brief Get sfReserveIncrement (soeOPTIONAL) + * @brief Get sfReserveIncrement (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -178,7 +178,7 @@ public: } /** - * @brief Get sfBaseFeeDrops (soeOPTIONAL) + * @brief Get sfBaseFeeDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -204,7 +204,7 @@ public: } /** - * @brief Get sfReserveBaseDrops (soeOPTIONAL) + * @brief Get sfReserveBaseDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -230,7 +230,7 @@ public: } /** - * @brief Get sfReserveIncrementDrops (soeOPTIONAL) + * @brief Get sfReserveIncrementDrops (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -260,7 +260,7 @@ public: * @brief Builder for SetFee transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class SetFeeBuilder : public TransactionBuilderBase @@ -297,7 +297,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLedgerSequence (soeOPTIONAL) + * @brief Set sfLedgerSequence (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -308,7 +308,7 @@ public: } /** - * @brief Set sfBaseFee (soeOPTIONAL) + * @brief Set sfBaseFee (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -319,7 +319,7 @@ public: } /** - * @brief Set sfReferenceFeeUnits (soeOPTIONAL) + * @brief Set sfReferenceFeeUnits (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -330,7 +330,7 @@ public: } /** - * @brief Set sfReserveBase (soeOPTIONAL) + * @brief Set sfReserveBase (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -341,7 +341,7 @@ public: } /** - * @brief Set sfReserveIncrement (soeOPTIONAL) + * @brief Set sfReserveIncrement (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -352,7 +352,7 @@ public: } /** - * @brief Set sfBaseFeeDrops (soeOPTIONAL) + * @brief Set sfBaseFeeDrops (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -363,7 +363,7 @@ public: } /** - * @brief Set sfReserveBaseDrops (soeOPTIONAL) + * @brief Set sfReserveBaseDrops (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& @@ -374,7 +374,7 @@ public: } /** - * @brief Set sfReserveIncrementDrops (soeOPTIONAL) + * @brief Set sfReserveIncrementDrops (SoeOptional) * @return Reference to this builder for method chaining. */ SetFeeBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/SetRegularKey.h b/include/xrpl/protocol_autogen/transactions/SetRegularKey.h index 3d70d092c5..1eca1bef25 100644 --- a/include/xrpl/protocol_autogen/transactions/SetRegularKey.h +++ b/include/xrpl/protocol_autogen/transactions/SetRegularKey.h @@ -19,9 +19,9 @@ class SetRegularKeyBuilder; * @brief Transaction: SetRegularKey * * Type: ttREGULAR_KEY_SET (5) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use SetRegularKeyBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfRegularKey (soeOPTIONAL) + * @brief Get sfRegularKey (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -78,7 +78,7 @@ public: * @brief Builder for SetRegularKey transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class SetRegularKeyBuilder : public TransactionBuilderBase @@ -115,7 +115,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfRegularKey (soeOPTIONAL) + * @brief Set sfRegularKey (SoeOptional) * @return Reference to this builder for method chaining. */ SetRegularKeyBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/SignerListSet.h b/include/xrpl/protocol_autogen/transactions/SignerListSet.h index ec5330a9cb..c711864e95 100644 --- a/include/xrpl/protocol_autogen/transactions/SignerListSet.h +++ b/include/xrpl/protocol_autogen/transactions/SignerListSet.h @@ -19,9 +19,9 @@ class SignerListSetBuilder; * @brief Transaction: SignerListSet * * Type: ttSIGNER_LIST_SET (12) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use SignerListSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfSignerQuorum (soeREQUIRED) + * @brief Get sfSignerQuorum (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -58,7 +58,7 @@ public: return this->tx_->at(sfSignerQuorum); } /** - * @brief Get sfSignerEntries (soeOPTIONAL) + * @brief Get sfSignerEntries (SoeOptional) * @note This is an untyped field. * @return The field value, or std::nullopt if not present. */ @@ -87,7 +87,7 @@ public: * @brief Builder for SignerListSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class SignerListSetBuilder : public TransactionBuilderBase @@ -126,7 +126,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfSignerQuorum (soeREQUIRED) + * @brief Set sfSignerQuorum (SoeRequired) * @return Reference to this builder for method chaining. */ SignerListSetBuilder& @@ -137,7 +137,7 @@ public: } /** - * @brief Set sfSignerEntries (soeOPTIONAL) + * @brief Set sfSignerEntries (SoeOptional) * @return Reference to this builder for method chaining. */ SignerListSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/TicketCreate.h b/include/xrpl/protocol_autogen/transactions/TicketCreate.h index 842ae93111..0b4206152e 100644 --- a/include/xrpl/protocol_autogen/transactions/TicketCreate.h +++ b/include/xrpl/protocol_autogen/transactions/TicketCreate.h @@ -19,9 +19,9 @@ class TicketCreateBuilder; * @brief Transaction: TicketCreate * * Type: ttTICKET_CREATE (10) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use TicketCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfTicketCount (soeREQUIRED) + * @brief Get sfTicketCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for TicketCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class TicketCreateBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfTicketCount (soeREQUIRED) + * @brief Set sfTicketCount (SoeRequired) * @return Reference to this builder for method chaining. */ TicketCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/TrustSet.h b/include/xrpl/protocol_autogen/transactions/TrustSet.h index 5623311b92..30d537492d 100644 --- a/include/xrpl/protocol_autogen/transactions/TrustSet.h +++ b/include/xrpl/protocol_autogen/transactions/TrustSet.h @@ -19,9 +19,9 @@ class TrustSetBuilder; * @brief Transaction: TrustSet * * Type: ttTRUST_SET (20) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use TrustSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfLimitAmount (soeOPTIONAL) + * @brief Get sfLimitAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -74,7 +74,7 @@ public: } /** - * @brief Get sfQualityIn (soeOPTIONAL) + * @brief Get sfQualityIn (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: } /** - * @brief Get sfQualityOut (soeOPTIONAL) + * @brief Get sfQualityOut (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -130,7 +130,7 @@ public: * @brief Builder for TrustSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class TrustSetBuilder : public TransactionBuilderBase @@ -167,7 +167,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfLimitAmount (soeOPTIONAL) + * @brief Set sfLimitAmount (SoeOptional) * @return Reference to this builder for method chaining. */ TrustSetBuilder& @@ -178,7 +178,7 @@ public: } /** - * @brief Set sfQualityIn (soeOPTIONAL) + * @brief Set sfQualityIn (SoeOptional) * @return Reference to this builder for method chaining. */ TrustSetBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfQualityOut (soeOPTIONAL) + * @brief Set sfQualityOut (SoeOptional) * @return Reference to this builder for method chaining. */ TrustSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/UNLModify.h b/include/xrpl/protocol_autogen/transactions/UNLModify.h index b5e64f19a0..a8556ca699 100644 --- a/include/xrpl/protocol_autogen/transactions/UNLModify.h +++ b/include/xrpl/protocol_autogen/transactions/UNLModify.h @@ -19,9 +19,9 @@ class UNLModifyBuilder; * @brief Transaction: UNLModify * * Type: ttUNL_MODIFY (102) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: uint256{} - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use UNLModifyBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfUNLModifyDisabling (soeREQUIRED) + * @brief Get sfUNLModifyDisabling (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfLedgerSequence (soeREQUIRED) + * @brief Get sfLedgerSequence (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfUNLModifyValidator (soeREQUIRED) + * @brief Get sfUNLModifyValidator (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: * @brief Builder for UNLModify transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class UNLModifyBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfUNLModifyDisabling (soeREQUIRED) + * @brief Set sfUNLModifyDisabling (SoeRequired) * @return Reference to this builder for method chaining. */ UNLModifyBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfLedgerSequence (soeREQUIRED) + * @brief Set sfLedgerSequence (SoeRequired) * @return Reference to this builder for method chaining. */ UNLModifyBuilder& @@ -150,7 +150,7 @@ public: } /** - * @brief Set sfUNLModifyValidator (soeREQUIRED) + * @brief Set sfUNLModifyValidator (SoeRequired) * @return Reference to this builder for method chaining. */ UNLModifyBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/VaultClawback.h b/include/xrpl/protocol_autogen/transactions/VaultClawback.h index 82b2b32e8d..8ec1d359dc 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultClawback.h +++ b/include/xrpl/protocol_autogen/transactions/VaultClawback.h @@ -19,9 +19,9 @@ class VaultClawbackBuilder; * @brief Transaction: VaultClawback * * Type: ttVAULT_CLAWBACK (70) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: mayDeleteMPT | mustModifyVault + * Privileges: MayDeleteMpt | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultClawbackBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfHolder (soeREQUIRED) + * @brief Get sfHolder (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfAmount (soeOPTIONAL) + * @brief Get sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value, or std::nullopt if not present. */ @@ -101,7 +101,7 @@ public: * @brief Builder for VaultClawback transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultClawbackBuilder : public TransactionBuilderBase @@ -142,7 +142,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultClawbackBuilder& @@ -153,7 +153,7 @@ public: } /** - * @brief Set sfHolder (soeREQUIRED) + * @brief Set sfHolder (SoeRequired) * @return Reference to this builder for method chaining. */ VaultClawbackBuilder& @@ -164,7 +164,7 @@ public: } /** - * @brief Set sfAmount (soeOPTIONAL) + * @brief Set sfAmount (SoeOptional) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/VaultCreate.h b/include/xrpl/protocol_autogen/transactions/VaultCreate.h index 03d4d4b88d..c8efa83cbf 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultCreate.h +++ b/include/xrpl/protocol_autogen/transactions/VaultCreate.h @@ -19,9 +19,9 @@ class VaultCreateBuilder; * @brief Transaction: VaultCreate * * Type: ttVAULT_CREATE (65) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: createPseudoAcct | createMPTIssuance | mustModifyVault + * Privileges: CreatePseudoAcct | CreateMptIssuance | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultCreateBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfAsset (soeREQUIRED) + * @brief Get sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -60,7 +60,7 @@ public: } /** - * @brief Get sfAssetsMaximum (soeOPTIONAL) + * @brief Get sfAssetsMaximum (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -86,7 +86,7 @@ public: } /** - * @brief Get sfMPTokenMetadata (soeOPTIONAL) + * @brief Get sfMPTokenMetadata (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -112,7 +112,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -138,7 +138,7 @@ public: } /** - * @brief Get sfWithdrawalPolicy (soeOPTIONAL) + * @brief Get sfWithdrawalPolicy (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -164,7 +164,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -190,7 +190,7 @@ public: } /** - * @brief Get sfScale (soeOPTIONAL) + * @brief Get sfScale (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -220,7 +220,7 @@ public: * @brief Builder for VaultCreate transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultCreateBuilder : public TransactionBuilderBase @@ -259,7 +259,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfAsset (soeREQUIRED) + * @brief Set sfAsset (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -271,7 +271,7 @@ public: } /** - * @brief Set sfAssetsMaximum (soeOPTIONAL) + * @brief Set sfAssetsMaximum (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& @@ -282,7 +282,7 @@ public: } /** - * @brief Set sfMPTokenMetadata (soeOPTIONAL) + * @brief Set sfMPTokenMetadata (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& @@ -293,7 +293,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& @@ -304,7 +304,7 @@ public: } /** - * @brief Set sfWithdrawalPolicy (soeOPTIONAL) + * @brief Set sfWithdrawalPolicy (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& @@ -315,7 +315,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& @@ -326,7 +326,7 @@ public: } /** - * @brief Set sfScale (soeOPTIONAL) + * @brief Set sfScale (SoeOptional) * @return Reference to this builder for method chaining. */ VaultCreateBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/VaultDelete.h b/include/xrpl/protocol_autogen/transactions/VaultDelete.h index 89a4ef2a2f..2b6e248c0a 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultDelete.h +++ b/include/xrpl/protocol_autogen/transactions/VaultDelete.h @@ -19,9 +19,9 @@ class VaultDeleteBuilder; * @brief Transaction: VaultDelete * * Type: ttVAULT_DELETE (67) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: mustDeleteAcct | destroyMPTIssuance | mustModifyVault + * Privileges: MustDeleteAcct | DestroyMptIssuance | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultDeleteBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -63,7 +63,7 @@ public: * @brief Builder for VaultDelete transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultDeleteBuilder : public TransactionBuilderBase @@ -102,7 +102,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultDeleteBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/VaultDeposit.h b/include/xrpl/protocol_autogen/transactions/VaultDeposit.h index 4127638e57..01f707e07f 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultDeposit.h +++ b/include/xrpl/protocol_autogen/transactions/VaultDeposit.h @@ -19,9 +19,9 @@ class VaultDepositBuilder; * @brief Transaction: VaultDeposit * * Type: ttVAULT_DEPOSIT (68) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: mayAuthorizeMPT | mustModifyVault + * Privileges: MayAuthorizeMpt | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultDepositBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -75,7 +75,7 @@ public: * @brief Builder for VaultDeposit transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultDepositBuilder : public TransactionBuilderBase @@ -116,7 +116,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultDepositBuilder& @@ -127,7 +127,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ diff --git a/include/xrpl/protocol_autogen/transactions/VaultSet.h b/include/xrpl/protocol_autogen/transactions/VaultSet.h index 372697b5f7..5bdc6a7a95 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultSet.h +++ b/include/xrpl/protocol_autogen/transactions/VaultSet.h @@ -19,9 +19,9 @@ class VaultSetBuilder; * @brief Transaction: VaultSet * * Type: ttVAULT_SET (66) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: mustModifyVault + * Privileges: MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultSetBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAssetsMaximum (soeOPTIONAL) + * @brief Get sfAssetsMaximum (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfDomainID (soeOPTIONAL) + * @brief Get sfDomainID (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: } /** - * @brief Get sfData (soeOPTIONAL) + * @brief Get sfData (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -141,7 +141,7 @@ public: * @brief Builder for VaultSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultSetBuilder : public TransactionBuilderBase @@ -180,7 +180,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultSetBuilder& @@ -191,7 +191,7 @@ public: } /** - * @brief Set sfAssetsMaximum (soeOPTIONAL) + * @brief Set sfAssetsMaximum (SoeOptional) * @return Reference to this builder for method chaining. */ VaultSetBuilder& @@ -202,7 +202,7 @@ public: } /** - * @brief Set sfDomainID (soeOPTIONAL) + * @brief Set sfDomainID (SoeOptional) * @return Reference to this builder for method chaining. */ VaultSetBuilder& @@ -213,7 +213,7 @@ public: } /** - * @brief Set sfData (soeOPTIONAL) + * @brief Set sfData (SoeOptional) * @return Reference to this builder for method chaining. */ VaultSetBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/VaultWithdraw.h b/include/xrpl/protocol_autogen/transactions/VaultWithdraw.h index 8b2a6a9a3c..75b5b90035 100644 --- a/include/xrpl/protocol_autogen/transactions/VaultWithdraw.h +++ b/include/xrpl/protocol_autogen/transactions/VaultWithdraw.h @@ -19,9 +19,9 @@ class VaultWithdrawBuilder; * @brief Transaction: VaultWithdraw * * Type: ttVAULT_WITHDRAW (69) - * Delegable: Delegation::notDelegable + * Delegable: Delegation::NotDelegable * Amendment: featureSingleAssetVault - * Privileges: mayDeleteMPT | mayAuthorizeMPT | mustModifyVault + * Privileges: MayDeleteMpt | MayAuthorizeMpt | MustModifyVault * * Immutable wrapper around STTx providing type-safe field access. * Use VaultWithdrawBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfVaultID (soeREQUIRED) + * @brief Get sfVaultID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return The field value. */ @@ -71,7 +71,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -97,7 +97,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -127,7 +127,7 @@ public: * @brief Builder for VaultWithdraw transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class VaultWithdrawBuilder : public TransactionBuilderBase @@ -168,7 +168,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfVaultID (soeREQUIRED) + * @brief Set sfVaultID (SoeRequired) * @return Reference to this builder for method chaining. */ VaultWithdrawBuilder& @@ -179,7 +179,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @note This field supports MPT (Multi-Purpose Token) amounts. * @return Reference to this builder for method chaining. */ @@ -191,7 +191,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ VaultWithdrawBuilder& @@ -202,7 +202,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ VaultWithdrawBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainAccountCreateCommit.h b/include/xrpl/protocol_autogen/transactions/XChainAccountCreateCommit.h index aebfbea5d3..36d8170af1 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainAccountCreateCommit.h +++ b/include/xrpl/protocol_autogen/transactions/XChainAccountCreateCommit.h @@ -19,9 +19,9 @@ class XChainAccountCreateCommitBuilder; * @brief Transaction: XChainAccountCreateCommit * * Type: ttXCHAIN_ACCOUNT_CREATE_COMMIT (44) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainAccountCreateCommitBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -96,7 +96,7 @@ public: * @brief Builder for XChainAccountCreateCommit transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainAccountCreateCommitBuilder : public TransactionBuilderBase @@ -141,7 +141,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAccountCreateCommitBuilder& @@ -152,7 +152,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAccountCreateCommitBuilder& @@ -163,7 +163,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAccountCreateCommitBuilder& @@ -174,7 +174,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAccountCreateCommitBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainAddAccountCreateAttestation.h b/include/xrpl/protocol_autogen/transactions/XChainAddAccountCreateAttestation.h index 08dc646470..a04eec1505 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainAddAccountCreateAttestation.h +++ b/include/xrpl/protocol_autogen/transactions/XChainAddAccountCreateAttestation.h @@ -19,9 +19,9 @@ class XChainAddAccountCreateAttestationBuilder; * @brief Transaction: XChainAddAccountCreateAttestation * * Type: ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION (46) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: createAcct + * Privileges: CreateAcct * * Immutable wrapper around STTx providing type-safe field access. * Use XChainAddAccountCreateAttestationBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAttestationSignerAccount (soeREQUIRED) + * @brief Get sfAttestationSignerAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfPublicKey (soeREQUIRED) + * @brief Get sfPublicKey (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfSignature (soeREQUIRED) + * @brief Get sfSignature (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfOtherChainSource (soeREQUIRED) + * @brief Get sfOtherChainSource (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -114,7 +114,7 @@ public: } /** - * @brief Get sfAttestationRewardAccount (soeREQUIRED) + * @brief Get sfAttestationRewardAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfWasLockingChainSend (soeREQUIRED) + * @brief Get sfWasLockingChainSend (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfXChainAccountCreateCount (soeREQUIRED) + * @brief Get sfXChainAccountCreateCount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -158,7 +158,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -173,7 +173,7 @@ public: * @brief Builder for XChainAddAccountCreateAttestation transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainAddAccountCreateAttestationBuilder : public TransactionBuilderBase @@ -232,7 +232,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfAttestationSignerAccount (soeREQUIRED) + * @brief Set sfAttestationSignerAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfPublicKey (soeREQUIRED) + * @brief Set sfPublicKey (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfSignature (soeREQUIRED) + * @brief Set sfSignature (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfOtherChainSource (soeREQUIRED) + * @brief Set sfOtherChainSource (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -287,7 +287,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -298,7 +298,7 @@ public: } /** - * @brief Set sfAttestationRewardAccount (soeREQUIRED) + * @brief Set sfAttestationRewardAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -309,7 +309,7 @@ public: } /** - * @brief Set sfWasLockingChainSend (soeREQUIRED) + * @brief Set sfWasLockingChainSend (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -320,7 +320,7 @@ public: } /** - * @brief Set sfXChainAccountCreateCount (soeREQUIRED) + * @brief Set sfXChainAccountCreateCount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -331,7 +331,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& @@ -342,7 +342,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddAccountCreateAttestationBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainAddClaimAttestation.h b/include/xrpl/protocol_autogen/transactions/XChainAddClaimAttestation.h index 100fc855aa..1896f11681 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainAddClaimAttestation.h +++ b/include/xrpl/protocol_autogen/transactions/XChainAddClaimAttestation.h @@ -19,9 +19,9 @@ class XChainAddClaimAttestationBuilder; * @brief Transaction: XChainAddClaimAttestation * * Type: ttXCHAIN_ADD_CLAIM_ATTESTATION (45) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: createAcct + * Privileges: CreateAcct * * Immutable wrapper around STTx providing type-safe field access. * Use XChainAddClaimAttestationBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfAttestationSignerAccount (soeREQUIRED) + * @brief Get sfAttestationSignerAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfPublicKey (soeREQUIRED) + * @brief Get sfPublicKey (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfSignature (soeREQUIRED) + * @brief Get sfSignature (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -92,7 +92,7 @@ public: } /** - * @brief Get sfOtherChainSource (soeREQUIRED) + * @brief Get sfOtherChainSource (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -103,7 +103,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -114,7 +114,7 @@ public: } /** - * @brief Get sfAttestationRewardAccount (soeREQUIRED) + * @brief Get sfAttestationRewardAccount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -125,7 +125,7 @@ public: } /** - * @brief Get sfWasLockingChainSend (soeREQUIRED) + * @brief Get sfWasLockingChainSend (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -136,7 +136,7 @@ public: } /** - * @brief Get sfXChainClaimID (soeREQUIRED) + * @brief Get sfXChainClaimID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -147,7 +147,7 @@ public: } /** - * @brief Get sfDestination (soeOPTIONAL) + * @brief Get sfDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -177,7 +177,7 @@ public: * @brief Builder for XChainAddClaimAttestation transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainAddClaimAttestationBuilder : public TransactionBuilderBase @@ -232,7 +232,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -243,7 +243,7 @@ public: } /** - * @brief Set sfAttestationSignerAccount (soeREQUIRED) + * @brief Set sfAttestationSignerAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -254,7 +254,7 @@ public: } /** - * @brief Set sfPublicKey (soeREQUIRED) + * @brief Set sfPublicKey (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -265,7 +265,7 @@ public: } /** - * @brief Set sfSignature (soeREQUIRED) + * @brief Set sfSignature (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -276,7 +276,7 @@ public: } /** - * @brief Set sfOtherChainSource (soeREQUIRED) + * @brief Set sfOtherChainSource (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -287,7 +287,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -298,7 +298,7 @@ public: } /** - * @brief Set sfAttestationRewardAccount (soeREQUIRED) + * @brief Set sfAttestationRewardAccount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -309,7 +309,7 @@ public: } /** - * @brief Set sfWasLockingChainSend (soeREQUIRED) + * @brief Set sfWasLockingChainSend (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -320,7 +320,7 @@ public: } /** - * @brief Set sfXChainClaimID (soeREQUIRED) + * @brief Set sfXChainClaimID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& @@ -331,7 +331,7 @@ public: } /** - * @brief Set sfDestination (soeOPTIONAL) + * @brief Set sfDestination (SoeOptional) * @return Reference to this builder for method chaining. */ XChainAddClaimAttestationBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainClaim.h b/include/xrpl/protocol_autogen/transactions/XChainClaim.h index 6b1b748677..f5b680049e 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainClaim.h +++ b/include/xrpl/protocol_autogen/transactions/XChainClaim.h @@ -19,9 +19,9 @@ class XChainClaimBuilder; * @brief Transaction: XChainClaim * * Type: ttXCHAIN_CLAIM (43) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainClaimBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfXChainClaimID (soeREQUIRED) + * @brief Get sfXChainClaimID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfDestination (soeREQUIRED) + * @brief Get sfDestination (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfDestinationTag (soeOPTIONAL) + * @brief Get sfDestinationTag (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -107,7 +107,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -122,7 +122,7 @@ public: * @brief Builder for XChainClaim transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainClaimBuilder : public TransactionBuilderBase @@ -167,7 +167,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainClaimBuilder& @@ -178,7 +178,7 @@ public: } /** - * @brief Set sfXChainClaimID (soeREQUIRED) + * @brief Set sfXChainClaimID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainClaimBuilder& @@ -189,7 +189,7 @@ public: } /** - * @brief Set sfDestination (soeREQUIRED) + * @brief Set sfDestination (SoeRequired) * @return Reference to this builder for method chaining. */ XChainClaimBuilder& @@ -200,7 +200,7 @@ public: } /** - * @brief Set sfDestinationTag (soeOPTIONAL) + * @brief Set sfDestinationTag (SoeOptional) * @return Reference to this builder for method chaining. */ XChainClaimBuilder& @@ -211,7 +211,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainClaimBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainCommit.h b/include/xrpl/protocol_autogen/transactions/XChainCommit.h index 879c76f180..a9ce7d1d08 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainCommit.h +++ b/include/xrpl/protocol_autogen/transactions/XChainCommit.h @@ -19,9 +19,9 @@ class XChainCommitBuilder; * @brief Transaction: XChainCommit * * Type: ttXCHAIN_COMMIT (42) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainCommitBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfXChainClaimID (soeREQUIRED) + * @brief Get sfXChainClaimID (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfAmount (soeREQUIRED) + * @brief Get sfAmount (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -81,7 +81,7 @@ public: } /** - * @brief Get sfOtherChainDestination (soeOPTIONAL) + * @brief Get sfOtherChainDestination (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -111,7 +111,7 @@ public: * @brief Builder for XChainCommit transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainCommitBuilder : public TransactionBuilderBase @@ -154,7 +154,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCommitBuilder& @@ -165,7 +165,7 @@ public: } /** - * @brief Set sfXChainClaimID (soeREQUIRED) + * @brief Set sfXChainClaimID (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCommitBuilder& @@ -176,7 +176,7 @@ public: } /** - * @brief Set sfAmount (soeREQUIRED) + * @brief Set sfAmount (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCommitBuilder& @@ -187,7 +187,7 @@ public: } /** - * @brief Set sfOtherChainDestination (soeOPTIONAL) + * @brief Set sfOtherChainDestination (SoeOptional) * @return Reference to this builder for method chaining. */ XChainCommitBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainCreateBridge.h b/include/xrpl/protocol_autogen/transactions/XChainCreateBridge.h index 6ec22dd9fc..ae5be4108f 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainCreateBridge.h +++ b/include/xrpl/protocol_autogen/transactions/XChainCreateBridge.h @@ -19,9 +19,9 @@ class XChainCreateBridgeBuilder; * @brief Transaction: XChainCreateBridge * * Type: ttXCHAIN_CREATE_BRIDGE (48) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainCreateBridgeBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Get sfMinAccountCreateAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -100,7 +100,7 @@ public: * @brief Builder for XChainCreateBridge transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainCreateBridgeBuilder : public TransactionBuilderBase @@ -141,7 +141,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCreateBridgeBuilder& @@ -152,7 +152,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCreateBridgeBuilder& @@ -163,7 +163,7 @@ public: } /** - * @brief Set sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Set sfMinAccountCreateAmount (SoeOptional) * @return Reference to this builder for method chaining. */ XChainCreateBridgeBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainCreateClaimID.h b/include/xrpl/protocol_autogen/transactions/XChainCreateClaimID.h index ab76ee0e77..7c1beb20c7 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainCreateClaimID.h +++ b/include/xrpl/protocol_autogen/transactions/XChainCreateClaimID.h @@ -19,9 +19,9 @@ class XChainCreateClaimIDBuilder; * @brief Transaction: XChainCreateClaimID * * Type: ttXCHAIN_CREATE_CLAIM_ID (41) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainCreateClaimIDBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfSignatureReward (soeREQUIRED) + * @brief Get sfSignatureReward (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -70,7 +70,7 @@ public: } /** - * @brief Get sfOtherChainSource (soeREQUIRED) + * @brief Get sfOtherChainSource (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: * @brief Builder for XChainCreateClaimID transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainCreateClaimIDBuilder : public TransactionBuilderBase @@ -128,7 +128,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCreateClaimIDBuilder& @@ -139,7 +139,7 @@ public: } /** - * @brief Set sfSignatureReward (soeREQUIRED) + * @brief Set sfSignatureReward (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCreateClaimIDBuilder& @@ -150,7 +150,7 @@ public: } /** - * @brief Set sfOtherChainSource (soeREQUIRED) + * @brief Set sfOtherChainSource (SoeRequired) * @return Reference to this builder for method chaining. */ XChainCreateClaimIDBuilder& diff --git a/include/xrpl/protocol_autogen/transactions/XChainModifyBridge.h b/include/xrpl/protocol_autogen/transactions/XChainModifyBridge.h index b57e0fdbdc..30558ab88c 100644 --- a/include/xrpl/protocol_autogen/transactions/XChainModifyBridge.h +++ b/include/xrpl/protocol_autogen/transactions/XChainModifyBridge.h @@ -19,9 +19,9 @@ class XChainModifyBridgeBuilder; * @brief Transaction: XChainModifyBridge * * Type: ttXCHAIN_MODIFY_BRIDGE (47) - * Delegable: Delegation::delegable + * Delegable: Delegation::Delegable * Amendment: featureXChainBridge - * Privileges: noPriv + * Privileges: NoPriv * * Immutable wrapper around STTx providing type-safe field access. * Use XChainModifyBridgeBuilder to construct new transactions. @@ -48,7 +48,7 @@ public: // Transaction-specific field getters /** - * @brief Get sfXChainBridge (soeREQUIRED) + * @brief Get sfXChainBridge (SoeRequired) * @return The field value. */ [[nodiscard]] @@ -59,7 +59,7 @@ public: } /** - * @brief Get sfSignatureReward (soeOPTIONAL) + * @brief Get sfSignatureReward (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -85,7 +85,7 @@ public: } /** - * @brief Get sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Get sfMinAccountCreateAmount (SoeOptional) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] @@ -115,7 +115,7 @@ public: * @brief Builder for XChainModifyBridge transactions. * * Provides a fluent interface for constructing transactions with method chaining. - * Uses Json::Value internally for flexible transaction construction. + * Uses STObject internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class XChainModifyBridgeBuilder : public TransactionBuilderBase @@ -154,7 +154,7 @@ public: /** @brief Transaction-specific field setters */ /** - * @brief Set sfXChainBridge (soeREQUIRED) + * @brief Set sfXChainBridge (SoeRequired) * @return Reference to this builder for method chaining. */ XChainModifyBridgeBuilder& @@ -165,7 +165,7 @@ public: } /** - * @brief Set sfSignatureReward (soeOPTIONAL) + * @brief Set sfSignatureReward (SoeOptional) * @return Reference to this builder for method chaining. */ XChainModifyBridgeBuilder& @@ -176,7 +176,7 @@ public: } /** - * @brief Set sfMinAccountCreateAmount (soeOPTIONAL) + * @brief Set sfMinAccountCreateAmount (SoeOptional) * @return Reference to this builder for method chaining. */ XChainModifyBridgeBuilder& diff --git a/include/xrpl/rdb/DBInit.h b/include/xrpl/rdb/DBInit.h index 56bc752343..59806b2e85 100644 --- a/include/xrpl/rdb/DBInit.h +++ b/include/xrpl/rdb/DBInit.h @@ -9,20 +9,20 @@ namespace xrpl { // These pragmas are built at startup and applied to all database // connections, unless otherwise noted. -inline constexpr char const* CommonDBPragmaJournal{"PRAGMA journal_mode=%s;"}; -inline constexpr char const* CommonDBPragmaSync{"PRAGMA synchronous=%s;"}; -inline constexpr char const* CommonDBPragmaTemp{"PRAGMA temp_store=%s;"}; +inline constexpr char const* kCOMMON_DB_PRAGMA_JOURNAL{"PRAGMA journal_mode=%s;"}; +inline constexpr char const* kCOMMON_DB_PRAGMA_SYNC{"PRAGMA synchronous=%s;"}; +inline constexpr char const* kCOMMON_DB_PRAGMA_TEMP{"PRAGMA temp_store=%s;"}; // A warning will be logged if any lower-safety sqlite tuning settings // are used and at least this much ledger history is configured. This // includes full history nodes. This is because such a large amount of // data will be more difficult to recover if a rare failure occurs, // which are more likely with some of the other available tuning settings. -inline constexpr std::uint32_t SQLITE_TUNING_CUTOFF = 10'000'000; +inline constexpr std::uint32_t kSQLITE_TUNING_CUTOFF = 10'000'000; // Ledger database holds ledgers and ledger confirmations -inline constexpr auto LgrDBName{"ledger.db"}; +inline constexpr auto kLGR_DB_NAME{"ledger.db"}; -inline constexpr std::array LgrDBInit{ +inline constexpr std::array kLGR_DB_INIT{ {"BEGIN TRANSACTION;", "CREATE TABLE IF NOT EXISTS Ledgers ( \ @@ -47,9 +47,9 @@ inline constexpr std::array LgrDBInit{ //////////////////////////////////////////////////////////////////////////////// // Transaction database holds transactions and public keys -inline constexpr auto TxDBName{"transaction.db"}; +inline constexpr auto kTX_DB_NAME{"transaction.db"}; -inline constexpr std::array TxDBInit{ +inline constexpr std::array kTX_DB_INIT{ {"BEGIN TRANSACTION;", "CREATE TABLE IF NOT EXISTS Transactions ( \ @@ -82,9 +82,9 @@ inline constexpr std::array TxDBInit{ //////////////////////////////////////////////////////////////////////////////// -inline constexpr auto WalletDBName{"wallet.db"}; +inline constexpr auto kWALLET_DB_NAME{"wallet.db"}; -inline constexpr std::array WalletDBInit{ +inline constexpr std::array kWALLET_DB_INIT{ {"BEGIN TRANSACTION;", // A node's identity must be persisted, including diff --git a/include/xrpl/rdb/RelationalDatabase.h b/include/xrpl/rdb/RelationalDatabase.h index 1c28ddec0a..a38d6a997f 100644 --- a/include/xrpl/rdb/RelationalDatabase.h +++ b/include/xrpl/rdb/RelationalDatabase.h @@ -417,7 +417,7 @@ public: getTransaction( uint256 const& id, std::optional> const& range, - error_code_i& ec) = 0; + ErrorCodeI& ec) = 0; /** * @brief getKBUsedAll Returns the amount of space used by all databases. diff --git a/include/xrpl/resource/Charge.h b/include/xrpl/resource/Charge.h index 582688260e..3fd8b02e83 100644 --- a/include/xrpl/resource/Charge.h +++ b/include/xrpl/resource/Charge.h @@ -27,7 +27,7 @@ public: /** Converts this charge into a human readable string. */ [[nodiscard]] std::string - to_string() const; + toString() const; bool operator==(Charge const&) const; @@ -39,8 +39,8 @@ public: operator*(value_type m) const; private: - value_type m_cost; - std::string m_label; + value_type cost_; + std::string label_; }; std::ostream& diff --git a/include/xrpl/resource/Consumer.h b/include/xrpl/resource/Consumer.h index ebb214d129..14935bb3f1 100644 --- a/include/xrpl/resource/Consumer.h +++ b/include/xrpl/resource/Consumer.h @@ -26,7 +26,7 @@ public: /** Return a human readable string uniquely identifying this consumer. */ [[nodiscard]] std::string - to_string() const; + toString() const; /** Returns `true` if this is a privileged endpoint. */ [[nodiscard]] bool @@ -71,8 +71,8 @@ public: setPublicKey(PublicKey const& publicKey); private: - Logic* m_logic; - Entry* m_entry; + Logic* logic_; + Entry* entry_; }; std::ostream& diff --git a/include/xrpl/resource/Disposition.h b/include/xrpl/resource/Disposition.h index 59a1c3840a..6dad8db19a 100644 --- a/include/xrpl/resource/Disposition.h +++ b/include/xrpl/resource/Disposition.h @@ -5,15 +5,15 @@ namespace xrpl::Resource { /** The disposition of a consumer after applying a load charge. */ enum class Disposition { /** No action required. */ - ok + Ok /** Consumer should be warned that consumption is high. */ , - warn + Warn /** Consumer should be disconnected for excess consumption. */ , - drop + Drop }; } // namespace xrpl::Resource diff --git a/include/xrpl/resource/Fees.h b/include/xrpl/resource/Fees.h index 366b2d287f..dc14e3bd4d 100644 --- a/include/xrpl/resource/Fees.h +++ b/include/xrpl/resource/Fees.h @@ -6,27 +6,28 @@ namespace xrpl::Resource { /** Schedule of fees charged for imposing load on the server. */ /** @{ */ -extern Charge const feeMalformedRequest; // A request that we can immediately tell is invalid. -extern Charge const feeRequestNoReply; // A request that we cannot satisfy. -extern Charge const feeInvalidSignature; // An object whose signature we had to check that failed. -extern Charge const feeUselessData; // Data we have no use for. -extern Charge const feeInvalidData; // Data we have to verify before rejecting. +extern Charge const kFEE_MALFORMED_REQUEST; // A request that we can immediately tell is invalid. +extern Charge const kFEE_REQUEST_NO_REPLY; // A request that we cannot satisfy. +extern Charge const + kFEE_INVALID_SIGNATURE; // An object whose signature we had to check that failed. +extern Charge const kFEE_USELESS_DATA; // Data we have no use for. +extern Charge const kFEE_INVALID_DATA; // Data we have to verify before rejecting. // RPC loads -extern Charge const feeMalformedRPC; // An RPC request that we can immediately tell is invalid. -extern Charge const feeReferenceRPC; // A default "reference" unspecified load. -extern Charge const feeExceptionRPC; // RPC load that causes an exception. -extern Charge const feeMediumBurdenRPC; // A somewhat burdensome RPC load. -extern Charge const feeHeavyBurdenRPC; // A very burdensome RPC load. +extern Charge const kFEE_MALFORMED_RPC; // An RPC request that we can immediately tell is invalid. +extern Charge const kFEE_REFERENCE_RPC; // A default "reference" unspecified load. +extern Charge const kFEE_EXCEPTION_RPC; // RPC load that causes an exception. +extern Charge const kFEE_MEDIUM_BURDEN_RPC; // A somewhat burdensome RPC load. +extern Charge const kFEE_HEAVY_BURDEN_RPC; // A very burdensome RPC load. // Peer loads -extern Charge const feeTrivialPeer; // Requires no reply. -extern Charge const feeModerateBurdenPeer; // Requires some work. -extern Charge const feeHeavyBurdenPeer; // Extensive work. +extern Charge const kFEE_TRIVIAL_PEER; // Requires no reply. +extern Charge const kFEE_MODERATE_BURDEN_PEER; // Requires some work. +extern Charge const kFEE_HEAVY_BURDEN_PEER; // Extensive work. // Administrative -extern Charge const feeWarning; // The cost of receiving a warning. -extern Charge const feeDrop; // The cost of being dropped for excess load. +extern Charge const kFEE_WARNING; // The cost of receiving a warning. +extern Charge const kFEE_DROP; // The cost of being dropped for excess load. /** @} */ } // namespace xrpl::Resource diff --git a/include/xrpl/resource/ResourceManager.h b/include/xrpl/resource/ResourceManager.h index 96e5255272..42b2a47126 100644 --- a/include/xrpl/resource/ResourceManager.h +++ b/include/xrpl/resource/ResourceManager.h @@ -44,9 +44,9 @@ public: exportConsumers() = 0; /** Extract consumer information for reporting. */ - virtual Json::Value + virtual json::Value getJson() = 0; - virtual Json::Value + virtual json::Value getJson(int threshold) = 0; /** Import packaged consumer information. @@ -59,6 +59,6 @@ public: //------------------------------------------------------------------------------ std::unique_ptr -make_Manager(beast::insight::Collector::ptr const& collector, beast::Journal journal); +makeManager(beast::insight::Collector::ptr const& collector, beast::Journal journal); } // namespace xrpl::Resource diff --git a/include/xrpl/resource/detail/Entry.h b/include/xrpl/resource/detail/Entry.h index 2cbf06d5c3..a821461e2e 100644 --- a/include/xrpl/resource/detail/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -9,7 +9,7 @@ namespace xrpl::Resource { -using clock_type = beast::abstract_clock; +using clock_type = beast::AbstractClock; // An entry in the table // VFALCO DEPRECATED using boost::intrusive list @@ -26,7 +26,7 @@ struct Entry : public beast::List::Node } [[nodiscard]] std::string - to_string() const + toString() const { return getFingerprint(key->address, publicKey); } @@ -39,7 +39,7 @@ struct Entry : public beast::List::Node [[nodiscard]] bool isUnlimited() const { - return key->kind == Kind::kindUnlimited; + return key->kind == Kind::Unlimited; } // Balance including remote contributions @@ -67,7 +67,7 @@ struct Entry : public beast::List::Node int refcount; // Exponentially decaying balance of resource consumption - DecayingSample local_balance; + DecayingSample local_balance; // Normalized balance contribution from imports int remote_balance; @@ -82,7 +82,7 @@ struct Entry : public beast::List::Node inline std::ostream& operator<<(std::ostream& os, Entry const& v) { - os << v.to_string(); + os << v.toString(); return os; } diff --git a/include/xrpl/resource/detail/Key.h b/include/xrpl/resource/detail/Key.h index c9a233b634..935d44425e 100644 --- a/include/xrpl/resource/detail/Key.h +++ b/include/xrpl/resource/detail/Key.h @@ -20,21 +20,21 @@ struct Key { } - struct hasher + struct Hasher { std::size_t operator()(Key const& v) const { - return m_addr_hash(v.address); + return addr_hash_(v.address); } private: - beast::uhash<> m_addr_hash; + beast::Uhash<> addr_hash_; }; - struct key_equal + struct KeyEqual { - key_equal() = default; + KeyEqual() = default; bool operator()(Key const& lhs, Key const& rhs) const diff --git a/include/xrpl/resource/detail/Kind.h b/include/xrpl/resource/detail/Kind.h index 5cbddce6bb..ce2e0773cf 100644 --- a/include/xrpl/resource/detail/Kind.h +++ b/include/xrpl/resource/detail/Kind.h @@ -10,6 +10,6 @@ namespace xrpl::Resource { * subjected to administrative restrictions, such as * use of some RPC commands like "stop". */ -enum class Kind { kindInbound, kindOutbound, kindUnlimited }; +enum class Kind { Inbound, Outbound, Unlimited }; } // namespace xrpl::Resource diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index 3102a1f119..3bbe08724d 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -22,24 +22,24 @@ class Logic private: using clock_type = Stopwatch; using Imports = hash_map; - using Table = hash_map; + using Table = hash_map; using EntryIntrusiveList = beast::List; struct Stats { Stats(beast::insight::Collector::ptr const& collector) { - warn = collector->make_meter("warn"); - drop = collector->make_meter("drop"); + warn = collector->makeMeter("warn"); + drop = collector->makeMeter("drop"); } beast::insight::Meter warn; beast::insight::Meter drop; }; - Stats m_stats; - Stopwatch& m_clock; - beast::Journal m_journal; + Stats stats_; + Stopwatch& clock_; + beast::Journal journal_; std::recursive_mutex lock_; @@ -71,7 +71,7 @@ public: beast::insight::Collector::ptr const& collector, clock_type& clock, beast::Journal journal) - : m_stats(collector), m_clock(clock), m_journal(journal) + : stats_(collector), clock_(clock), journal_(journal) { } @@ -95,8 +95,8 @@ public: std::scoped_lock const _(lock_); auto [resultIt, resultInserted] = table_.emplace( std::piecewise_construct, - std::make_tuple(Kind::kindInbound, address.at_port(0)), // Key - std::make_tuple(m_clock.now())); // Entry + std::make_tuple(Kind::Inbound, address.atPort(0)), // Key + std::make_tuple(clock_.now())); // Entry entry = &resultIt->second; entry->key = &resultIt->first; @@ -105,13 +105,13 @@ public: { if (!resultInserted) { - inactive_.erase(inactive_.iterator_to(*entry)); + inactive_.erase(inactive_.iteratorTo(*entry)); } - inbound_.push_back(*entry); + inbound_.pushBack(*entry); } } - JLOG(m_journal.debug()) << "New inbound endpoint " << *entry; + JLOG(journal_.debug()) << "New inbound endpoint " << *entry; return Consumer(*this, *entry); } @@ -125,8 +125,8 @@ public: std::scoped_lock const _(lock_); auto [resultIt, resultInserted] = table_.emplace( std::piecewise_construct, - std::make_tuple(Kind::kindOutbound, address), // Key - std::make_tuple(m_clock.now())); // Entry + std::make_tuple(Kind::Outbound, address), // Key + std::make_tuple(clock_.now())); // Entry entry = &resultIt->second; entry->key = &resultIt->first; @@ -134,12 +134,12 @@ public: if (entry->refcount == 1) { if (!resultInserted) - inactive_.erase(inactive_.iterator_to(*entry)); - outbound_.push_back(*entry); + inactive_.erase(inactive_.iteratorTo(*entry)); + outbound_.pushBack(*entry); } } - JLOG(m_journal.debug()) << "New outbound endpoint " << *entry; + JLOG(journal_.debug()) << "New outbound endpoint " << *entry; return Consumer(*this, *entry); } @@ -158,8 +158,8 @@ public: std::scoped_lock const _(lock_); auto [resultIt, resultInserted] = table_.emplace( std::piecewise_construct, - std::make_tuple(Kind::kindUnlimited, address.at_port(1)), // Key - std::make_tuple(m_clock.now())); // Entry + std::make_tuple(Kind::Unlimited, address.atPort(1)), // Key + std::make_tuple(clock_.now())); // Entry entry = &resultIt->second; entry->key = &resultIt->first; @@ -167,29 +167,29 @@ public: if (entry->refcount == 1) { if (!resultInserted) - inactive_.erase(inactive_.iterator_to(*entry)); - admin_.push_back(*entry); + inactive_.erase(inactive_.iteratorTo(*entry)); + admin_.pushBack(*entry); } } - JLOG(m_journal.debug()) << "New unlimited endpoint " << *entry; + JLOG(journal_.debug()) << "New unlimited endpoint " << *entry; return Consumer(*this, *entry); } - Json::Value + json::Value getJson() { - return getJson(warningThreshold); + return getJson(WarningThreshold); } - /** Returns a Json::objectValue. */ - Json::Value + /** Returns a json::objectValue. */ + json::Value getJson(int threshold) { - clock_type::time_point const now(m_clock.now()); + clock_type::time_point const now(clock_.now()); - Json::Value ret(Json::objectValue); + json::Value ret(json::ObjectValue); std::scoped_lock const _(lock_); for (auto& inboundEntry : inbound_) @@ -197,7 +197,7 @@ public: int const localBalance = inboundEntry.local_balance.value(now); if ((localBalance + inboundEntry.remote_balance) >= threshold) { - Json::Value& entry = (ret[inboundEntry.to_string()] = Json::objectValue); + json::Value& entry = (ret[inboundEntry.toString()] = json::ObjectValue); entry[jss::local] = localBalance; entry[jss::remote] = inboundEntry.remote_balance; entry[jss::type] = "inbound"; @@ -208,7 +208,7 @@ public: int const localBalance = outboundEntry.local_balance.value(now); if ((localBalance + outboundEntry.remote_balance) >= threshold) { - Json::Value& entry = (ret[outboundEntry.to_string()] = Json::objectValue); + json::Value& entry = (ret[outboundEntry.toString()] = json::ObjectValue); entry[jss::local] = localBalance; entry[jss::remote] = outboundEntry.remote_balance; entry[jss::type] = "outbound"; @@ -219,7 +219,7 @@ public: int const localBalance = adminEntry.local_balance.value(now); if ((localBalance + adminEntry.remote_balance) >= threshold) { - Json::Value& entry = (ret[adminEntry.to_string()] = Json::objectValue); + json::Value& entry = (ret[adminEntry.toString()] = json::ObjectValue); entry[jss::local] = localBalance; entry[jss::remote] = adminEntry.remote_balance; entry[jss::type] = "admin"; @@ -232,7 +232,7 @@ public: Gossip exportConsumers() { - clock_type::time_point const now(m_clock.now()); + clock_type::time_point const now(clock_.now()); Gossip gossip; std::scoped_lock const _(lock_); @@ -243,7 +243,7 @@ public: { Gossip::Item item; item.balance = inboundEntry.local_balance.value(now); - if (item.balance >= minimumGossipBalance) + if (item.balance >= MinimumGossipBalance) { item.address = inboundEntry.key->address; gossip.items.push_back(item); @@ -258,19 +258,19 @@ public: void importConsumers(std::string const& origin, Gossip const& gossip) { - auto const elapsed = m_clock.now(); + auto const elapsed = clock_.now(); { std::scoped_lock const _(lock_); auto [resultIt, resultInserted] = importTable_.emplace( std::piecewise_construct, - std::make_tuple(origin), // Key - std::make_tuple(m_clock.now().time_since_epoch().count())); // Import + std::make_tuple(origin), // Key + std::make_tuple(clock_.now().time_since_epoch().count())); // Import if (resultInserted) { // This is a new import Import& next(resultIt->second); - next.whenExpires = elapsed + gossipExpirationSeconds; + next.whenExpires = elapsed + kGOSSIP_EXPIRATION_SECONDS; next.items.reserve(gossip.items.size()); for (auto const& gossipItem : gossip.items) @@ -288,7 +288,7 @@ public: // balances and then deduct the old remote balances. Import next; - next.whenExpires = elapsed + gossipExpirationSeconds; + next.whenExpires = elapsed + kGOSSIP_EXPIRATION_SECONDS; next.items.reserve(gossip.items.size()); for (auto const& gossipItem : gossip.items) { @@ -319,16 +319,16 @@ public: { std::scoped_lock const _(lock_); - auto const elapsed = m_clock.now(); + auto const elapsed = clock_.now(); for (auto iter(inactive_.begin()); iter != inactive_.end();) { if (iter->whenExpires <= elapsed) { - JLOG(m_journal.debug()) << "Expired " << *iter; - auto table_iter = table_.find(*iter->key); + JLOG(journal_.debug()) << "Expired " << *iter; + auto tableIter = table_.find(*iter->key); ++iter; - erase(table_iter); + erase(tableIter); } else { @@ -342,10 +342,10 @@ public: Import& import(iter->second); if (iter->second.whenExpires <= elapsed) { - for (auto item_iter(import.items.begin()); item_iter != import.items.end(); - ++item_iter) + for (auto itemIter(import.items.begin()); itemIter != import.items.end(); + ++itemIter) { - item_iter->consumer.entry().remote_balance -= item_iter->balance; + itemIter->consumer.entry().remote_balance -= itemIter->balance; } iter = importTable_.erase(iter); @@ -363,13 +363,13 @@ public: static Disposition disposition(int balance) { - if (balance >= dropThreshold) - return Disposition::drop; + if (balance >= DropThreshold) + return Disposition::Drop; - if (balance >= warningThreshold) - return Disposition::warn; + if (balance >= WarningThreshold) + return Disposition::Warn; - return Disposition::ok; + return Disposition::Ok; } void @@ -378,7 +378,7 @@ public: std::scoped_lock const _(lock_); Entry& entry(iter->second); XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used"); - inactive_.erase(inactive_.iterator_to(entry)); + inactive_.erase(inactive_.iteratorTo(entry)); table_.erase(iter); } @@ -395,18 +395,18 @@ public: std::scoped_lock const _(lock_); if (--entry.refcount == 0) { - JLOG(m_journal.debug()) << "Inactive " << entry; + JLOG(journal_.debug()) << "Inactive " << entry; switch (entry.key->kind) { - case Kind::kindInbound: - inbound_.erase(inbound_.iterator_to(entry)); + case Kind::Inbound: + inbound_.erase(inbound_.iteratorTo(entry)); break; - case Kind::kindOutbound: - outbound_.erase(outbound_.iterator_to(entry)); + case Kind::Outbound: + outbound_.erase(outbound_.iteratorTo(entry)); break; - case Kind::kindUnlimited: - admin_.erase(admin_.iterator_to(entry)); + case Kind::Unlimited: + admin_.erase(admin_.iteratorTo(entry)); break; default: // LCOV_EXCL_START @@ -416,26 +416,27 @@ public: break; // LCOV_EXCL_STOP } - inactive_.push_back(entry); - entry.whenExpires = m_clock.now() + secondsUntilExpiration; + inactive_.pushBack(entry); + entry.whenExpires = clock_.now() + kSECONDS_UNTIL_EXPIRATION; } } Disposition charge(Entry& entry, Charge const& fee, std::string context = {}) { - static constexpr Charge::value_type feeLogAsWarn = 3000; - static constexpr Charge::value_type feeLogAsInfo = 1000; - static constexpr Charge::value_type feeLogAsDebug = 100; + static constexpr Charge::value_type kFEE_LOG_AS_WARN = 3000; + static constexpr Charge::value_type kFEE_LOG_AS_INFO = 1000; + static constexpr Charge::value_type kFEE_LOG_AS_DEBUG = 100; static_assert( - feeLogAsWarn > feeLogAsInfo && feeLogAsInfo > feeLogAsDebug && feeLogAsDebug > 10); + kFEE_LOG_AS_WARN > kFEE_LOG_AS_INFO && kFEE_LOG_AS_INFO > kFEE_LOG_AS_DEBUG && + kFEE_LOG_AS_DEBUG > 10); - static auto getStream = [](Resource::Charge::value_type cost, beast::Journal& journal) { - if (cost >= feeLogAsWarn) + static auto kGET_STREAM = [](Resource::Charge::value_type cost, beast::Journal& journal) { + if (cost >= kFEE_LOG_AS_WARN) return journal.warn(); - if (cost >= feeLogAsInfo) + if (cost >= kFEE_LOG_AS_INFO) return journal.info(); - if (cost >= feeLogAsDebug) + if (cost >= kFEE_LOG_AS_DEBUG) return journal.debug(); return journal.trace(); }; @@ -444,9 +445,10 @@ public: context = " (" + context + ")"; std::scoped_lock const _(lock_); - clock_type::time_point const now(m_clock.now()); + clock_type::time_point const now(clock_.now()); int const balance(entry.add(fee.cost(), now)); - JLOG(getStream(fee.cost(), m_journal)) << "Charging " << entry << " for " << fee << context; + JLOG(kGET_STREAM(fee.cost(), journal_)) + << "Charging " << entry << " for " << fee << context; return disposition(balance); } @@ -458,17 +460,17 @@ public: std::scoped_lock const _(lock_); bool notify(false); - auto const elapsed = m_clock.now(); - if (entry.balance(m_clock.now()) >= warningThreshold && elapsed != entry.lastWarningTime) + auto const elapsed = clock_.now(); + if (entry.balance(clock_.now()) >= WarningThreshold && elapsed != entry.lastWarningTime) { - charge(entry, feeWarning); + charge(entry, kFEE_WARNING); notify = true; entry.lastWarningTime = elapsed; } if (notify) { - JLOG(m_journal.info()) << "Load warning: " << entry; - ++m_stats.warn; + JLOG(journal_.info()) << "Load warning: " << entry; + ++stats_.warn; } return notify; } @@ -481,18 +483,18 @@ public: std::scoped_lock const _(lock_); bool drop(false); - clock_type::time_point const now(m_clock.now()); + clock_type::time_point const now(clock_.now()); int const balance(entry.balance(now)); - if (balance >= dropThreshold) + if (balance >= DropThreshold) { - JLOG(m_journal.warn()) << "Consumer entry " << entry << " dropped with balance " - << balance << " at or above drop threshold " << dropThreshold; + JLOG(journal_.warn()) << "Consumer entry " << entry << " dropped with balance " + << balance << " at or above drop threshold " << DropThreshold; // Adding feeDrop at this point keeps the dropped connection // from re-connecting for at least a little while after it is // dropped. - charge(entry, feeDrop); - ++m_stats.drop; + charge(entry, kFEE_DROP); + ++stats_.drop; drop = true; } return drop; @@ -502,7 +504,7 @@ public: balance(Entry& entry) { std::scoped_lock const _(lock_); - return entry.balance(m_clock.now()); + return entry.balance(clock_.now()); } //-------------------------------------------------------------------------- @@ -518,7 +520,7 @@ public: beast::PropertyStream::Map item(items); if (entry.refcount != 0) item["count"] = entry.refcount; - item["name"] = entry.to_string(); + item["name"] = entry.toString(); item["balance"] = entry.balance(now); if (entry.remote_balance != 0) item["remote_balance"] = entry.remote_balance; @@ -528,7 +530,7 @@ public: void onWrite(beast::PropertyStream::Map& map) { - clock_type::time_point const now(m_clock.now()); + clock_type::time_point const now(clock_.now()); std::scoped_lock const _(lock_); diff --git a/include/xrpl/resource/detail/Tuning.h b/include/xrpl/resource/detail/Tuning.h index d5e872d16c..3452005c35 100644 --- a/include/xrpl/resource/detail/Tuning.h +++ b/include/xrpl/resource/detail/Tuning.h @@ -9,26 +9,26 @@ namespace xrpl::Resource { // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum { // Balance at which a warning is issued - warningThreshold = 5000 + WarningThreshold = 5000 // Balance at which the consumer is disconnected , - dropThreshold = 25000 + DropThreshold = 25000 // The number of seconds in the exponential decay window // (This should be a power of two) , - decayWindowSeconds = 32 + DecayWindowSeconds = 32 // The minimum balance required in order to include a load source in gossip , - minimumGossipBalance = 1000 + MinimumGossipBalance = 1000 }; // The number of seconds until an inactive table item is removed -std::chrono::seconds constexpr secondsUntilExpiration{300}; +std::chrono::seconds constexpr kSECONDS_UNTIL_EXPIRATION{300}; // Number of seconds until imported gossip expires -std::chrono::seconds constexpr gossipExpirationSeconds{30}; +std::chrono::seconds constexpr kGOSSIP_EXPIRATION_SECONDS{30}; } // namespace xrpl::Resource diff --git a/include/xrpl/server/InfoSub.h b/include/xrpl/server/InfoSub.h index b6dff5983d..e93676a938 100644 --- a/include/xrpl/server/InfoSub.h +++ b/include/xrpl/server/InfoSub.h @@ -19,10 +19,10 @@ public: virtual ~InfoSubRequest() = default; - virtual Json::Value + virtual json::Value doClose() = 0; - virtual Json::Value - doStatus(Json::Value const&) = 0; + virtual json::Value + doStatus(json::Value const&) = 0; }; /** Manages a client's subscription to data feeds. @@ -72,7 +72,7 @@ public: * historical transactions * @return rpcSUCCESS if successful, otherwise an error code */ - virtual error_code_i + virtual ErrorCodeI subAccountHistory(ref ispListener, AccountID const& account) = 0; /** @@ -94,7 +94,7 @@ public: // VFALCO TODO Document the bool return value virtual bool - subLedger(ref ispListener, Json::Value& jvResult) = 0; + subLedger(ref ispListener, json::Value& jvResult) = 0; virtual bool unsubLedger(std::uint64_t uListener) = 0; @@ -111,7 +111,7 @@ public: pubManifest(Manifest const&) = 0; virtual bool - subServer(ref ispListener, Json::Value& jvResult, bool admin) = 0; + subServer(ref ispListener, json::Value& jvResult, bool admin) = 0; virtual bool unsubServer(std::uint64_t uListener) = 0; @@ -141,7 +141,7 @@ public: virtual bool unsubPeerStatus(std::uint64_t uListener) = 0; virtual void - pubPeerStatus(std::function const&) = 0; + pubPeerStatus(std::function const&) = 0; virtual bool subConsensus(ref ispListener) = 0; @@ -170,7 +170,7 @@ public: getConsumer(); virtual void - send(Json::Value const& jvObj, bool broadcast) = 0; + send(json::Value const& jvObj, bool broadcast) = 0; [[nodiscard]] std::uint64_t getSeq() const; @@ -207,23 +207,23 @@ public: getApiVersion() const noexcept; protected: - std::mutex mLock; + std::mutex lock_; private: - Consumer m_consumer; - Source& m_source; + Consumer consumer_; + Source& source_; hash_set realTimeSubscriptions_; hash_set normalSubscriptions_; std::shared_ptr request_; - std::uint64_t mSeq; + std::uint64_t seq_; hash_set accountHistorySubscriptions_; unsigned int apiVersion_ = 0; static int - assign_id() + assignId() { - static std::atomic id(0); - return ++id; + static std::atomic kID(0); + return ++kID; } }; diff --git a/include/xrpl/server/LoadFeeTrack.h b/include/xrpl/server/LoadFeeTrack.h index e54ea4d280..5ad3972836 100644 --- a/include/xrpl/server/LoadFeeTrack.h +++ b/include/xrpl/server/LoadFeeTrack.h @@ -63,7 +63,7 @@ public: static std::uint32_t getLoadBase() { - return lftNormalFee; + return kLFT_NORMAL_FEE; } std::uint32_t @@ -100,29 +100,29 @@ public: isLoadedLocal() const { std::scoped_lock const sl(lock_); - return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee); + return (raiseCount_ != 0) || (localTxnLoadFee_ != kLFT_NORMAL_FEE); } bool isLoadedCluster() const { std::scoped_lock const sl(lock_); - return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) || - (clusterTxnLoadFee_ != lftNormalFee); + return (raiseCount_ != 0) || (localTxnLoadFee_ != kLFT_NORMAL_FEE) || + (clusterTxnLoadFee_ != kLFT_NORMAL_FEE); } private: - static std::uint32_t constexpr lftNormalFee = 256; // 256 is the minimum/normal load factor - static std::uint32_t constexpr lftFeeIncFraction = 4; // increase fee by 1/4 - static std::uint32_t constexpr lftFeeDecFraction = 4; // decrease fee by 1/4 - static std::uint32_t constexpr lftFeeMax = lftNormalFee * 1000000; + static std::uint32_t constexpr kLFT_NORMAL_FEE = 256; // 256 is the minimum/normal load factor + static std::uint32_t constexpr kLFT_FEE_INC_FRACTION = 4; // increase fee by 1/4 + static std::uint32_t constexpr kLFT_FEE_DEC_FRACTION = 4; // decrease fee by 1/4 + static std::uint32_t constexpr kLFT_FEE_MAX = kLFT_NORMAL_FEE * 1000000; beast::Journal const j_; std::mutex mutable lock_; - std::uint32_t localTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee - std::uint32_t remoteTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee - std::uint32_t clusterTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee + std::uint32_t localTxnLoadFee_{kLFT_NORMAL_FEE}; // Scale factor, lftNormalFee = normal fee + std::uint32_t remoteTxnLoadFee_{kLFT_NORMAL_FEE}; // Scale factor, lftNormalFee = normal fee + std::uint32_t clusterTxnLoadFee_{kLFT_NORMAL_FEE}; // Scale factor, lftNormalFee = normal fee std::uint32_t raiseCount_{0}; }; diff --git a/include/xrpl/server/Manifest.h b/include/xrpl/server/Manifest.h index e11d5dc0da..eed1c14dae 100644 --- a/include/xrpl/server/Manifest.h +++ b/include/xrpl/server/Manifest.h @@ -81,16 +81,16 @@ struct Manifest Manifest() = delete; Manifest( - std::string serialized_, - PublicKey const& masterKey_, - std::optional const& signingKey_, + std::string serialized, + PublicKey const& masterKey, + std::optional const& signingKey, std::uint32_t seq, - std::string domain_) - : serialized(std::move(serialized_)) - , masterKey(masterKey_) - , signingKey(signingKey_) + std::string domain) + : serialized(std::move(serialized)) + , masterKey(masterKey) + , signingKey(signingKey) , sequence(seq) - , domain(std::move(domain_)) + , domain(std::move(domain)) { } @@ -194,19 +194,19 @@ loadValidatorToken( enum class ManifestDisposition { /// Manifest is valid - accepted = 0, + Accepted = 0, /// Sequence is too old - stale, + Stale, /// The master key is not acceptable to us - badMasterKey, + BadMasterKey, /// The ephemeral key is not acceptable to us - badEphemeralKey, + BadEphemeralKey, /// Timely, but invalid signature - invalid + Invalid }; inline std::string @@ -214,15 +214,15 @@ to_string(ManifestDisposition m) { switch (m) { - case ManifestDisposition::accepted: + case ManifestDisposition::Accepted: return "accepted"; - case ManifestDisposition::stale: + case ManifestDisposition::Stale: return "stale"; - case ManifestDisposition::badMasterKey: + case ManifestDisposition::BadMasterKey: return "badMasterKey"; - case ManifestDisposition::badEphemeralKey: + case ManifestDisposition::BadEphemeralKey: return "badEphemeralKey"; - case ManifestDisposition::invalid: + case ManifestDisposition::Invalid: return "invalid"; default: return "unknown"; @@ -400,7 +400,7 @@ public: */ template void - for_each_manifest(Function&& f) const + forEachManifest(Function&& f) const { std::shared_lock const lock{mutex_}; for (auto const& [_, manifest] : map_) @@ -428,7 +428,7 @@ public: */ template void - for_each_manifest(PreFun&& pf, EachFun&& f) const + forEachManifest(PreFun&& pf, EachFun&& f) const { std::shared_lock const lock{mutex_}; pf(map_.size()); diff --git a/include/xrpl/server/NetworkOPs.h b/include/xrpl/server/NetworkOPs.h index c449bd283b..e2aa17566e 100644 --- a/include/xrpl/server/NetworkOPs.h +++ b/include/xrpl/server/NetworkOPs.h @@ -70,13 +70,13 @@ enum class OperatingMode { class NetworkOPs : public InfoSub::Source { public: - using clock_type = beast::abstract_clock; + using clock_type = beast::AbstractClock; - enum class FailHard : unsigned char { no, yes }; + enum class FailHard : unsigned char { No, Yes }; static FailHard doFailHard(bool noMeansDont) { - return noMeansDont ? FailHard::yes : FailHard::no; + return noMeansDont ? FailHard::Yes : FailHard::No; } public: @@ -136,7 +136,7 @@ public: // Owner functions // - virtual Json::Value + virtual json::Value getOwnerInfo(std::shared_ptr lpLedger, AccountID const& account) = 0; //-------------------------------------------------------------------------- @@ -151,8 +151,8 @@ public: AccountID const& uTakerID, bool const bProof, unsigned int iLimit, - Json::Value const& jvMarker, - Json::Value& jvResult) = 0; + json::Value const& jvMarker, + json::Value& jvResult) = 0; //-------------------------------------------------------------------------- @@ -207,13 +207,13 @@ public: virtual void consensusViewChange() = 0; - virtual Json::Value + virtual json::Value getConsensusInfo() = 0; - virtual Json::Value + virtual json::Value getServerInfo(bool human, bool admin, bool counters) = 0; virtual void clearLedgerFetch() = 0; - virtual Json::Value + virtual json::Value getLedgerFetchInfo() = 0; /** Accepts the current transaction tree, return the new ledger's sequence @@ -248,7 +248,7 @@ public: pubValidation(std::shared_ptr const& val) = 0; virtual void - stateAccounting(Json::Value& obj) = 0; + stateAccounting(json::Value& obj) = 0; }; } // namespace xrpl diff --git a/include/xrpl/server/Port.h b/include/xrpl/server/Port.h index 515846b2a8..9207e0552b 100644 --- a/include/xrpl/server/Port.h +++ b/include/xrpl/server/Port.h @@ -16,7 +16,7 @@ #include namespace boost::asio::ssl { -class context; +class context; // NOLINT(readability-identifier-naming) -- external library name } // namespace boost::asio::ssl namespace xrpl { @@ -97,6 +97,6 @@ struct ParsedPort }; void -parse_Port(ParsedPort& port, Section const& section, std::ostream& log); +parsePort(ParsedPort& port, Section const& section, std::ostream& log); } // namespace xrpl diff --git a/include/xrpl/server/Server.h b/include/xrpl/server/Server.h index 52340ac900..4d97fe9877 100644 --- a/include/xrpl/server/Server.h +++ b/include/xrpl/server/Server.h @@ -12,9 +12,9 @@ namespace xrpl { /** Create the HTTP server using the specified handler. */ template std::unique_ptr -make_Server(Handler& handler, boost::asio::io_context& io_context, beast::Journal journal) +makeServer(Handler& handler, boost::asio::io_context& ioContext, beast::Journal journal) { - return std::make_unique>(handler, io_context, journal); + return std::make_unique>(handler, ioContext, journal); } } // namespace xrpl diff --git a/include/xrpl/server/Session.h b/include/xrpl/server/Session.h index f7146c3b00..2cb991e130 100644 --- a/include/xrpl/server/Session.h +++ b/include/xrpl/server/Session.h @@ -75,7 +75,7 @@ public: write(void const* buffer, std::size_t bytes) = 0; virtual void - write(std::shared_ptr const& writer, bool keep_alive) = 0; + write(std::shared_ptr const& writer, bool keepAlive) = 0; /** @} */ diff --git a/include/xrpl/server/SimpleWriter.h b/include/xrpl/server/SimpleWriter.h index 0c3b711187..dfb0b165e8 100644 --- a/include/xrpl/server/SimpleWriter.h +++ b/include/xrpl/server/SimpleWriter.h @@ -17,8 +17,8 @@ class SimpleWriter : public Writer boost::beast::multi_buffer sb_; public: - template - explicit SimpleWriter(boost::beast::http::message const& msg) + template + explicit SimpleWriter(boost::beast::http::message const& msg) { boost::beast::ostream(sb_) << msg; } diff --git a/include/xrpl/server/WSSession.h b/include/xrpl/server/WSSession.h index 01032359b3..b2fa52c859 100644 --- a/include/xrpl/server/WSSession.h +++ b/include/xrpl/server/WSSession.h @@ -103,7 +103,7 @@ struct WSSession request() const = 0; [[nodiscard]] virtual boost::asio::ip::tcp::endpoint const& - remote_endpoint() const = 0; + remoteEndpoint() const = 0; /** Send a WebSockets message. */ virtual void diff --git a/include/xrpl/server/Wallet.h b/include/xrpl/server/Wallet.h index 29b28c41a1..c15014b1ef 100644 --- a/include/xrpl/server/Wallet.h +++ b/include/xrpl/server/Wallet.h @@ -31,14 +31,14 @@ makeTestWalletDB(DatabaseCon::Setup const& setup, std::string const& dbname, bea * @param session Session with the database. * @param dbTable Name of the database table from which the manifest will be * extracted. - * @param mCache Cache for storing the manifest. + * @param cache_ Cache for storing the manifest. * @param j Journal. */ void getManifests( soci::session& session, std::string const& dbTable, - ManifestCache& mCache, + ManifestCache& cache, beast::Journal j); /** @@ -89,7 +89,7 @@ getNodeIdentity(soci::session& session); * @param j Journal. * @return Peer reservation hash table. */ -std::unordered_set, KeyEqual> +std::unordered_set, KeyEqual> getPeerReservationTable(soci::session& session, beast::Journal j); /** @@ -123,7 +123,7 @@ createFeatureVotes(soci::session& session); // For historical reasons the up-vote and down-vote integer representations // are unintuitive. -enum class AmendmentVote : int { obsolete = -1, up = 0, down = 1 }; +enum class AmendmentVote : int { Obsolete = -1, Up = 0, Down = 1 }; /** * @brief readAmendments Reads all amendments from the FeatureVotes table. @@ -135,8 +135,8 @@ void readAmendments( soci::session& session, std::function amendment_hash, - boost::optional amendment_name, + boost::optional amendmentHash, + boost::optional amendmentName, boost::optional vote)> const& callback); /** diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index 31820402ab..0260cd6b84 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -30,7 +30,7 @@ namespace xrpl { /** Represents an active connection. */ template -class BaseHTTPPeer : public io_list::work, public Session +class BaseHTTPPeer : public IoList::Work, public Session { protected: using clock_type = std::chrono::system_clock; @@ -42,16 +42,16 @@ protected: // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum { // Size of our read/write buffer - bufferSize = 4 * 1024, + BufferSize = 4 * 1024, // Max seconds without completing a message - timeoutSeconds = 30, - timeoutSecondsLocal = 3 // used for localhost clients + TimeoutSeconds = 30, + TimeoutSecondsLocal = 3 // used for localhost clients }; - struct buffer + struct Buffer { - buffer(void const* ptr, std::size_t len) : data(new char[len]), bytes(len) + Buffer(void const* ptr, std::size_t len) : data(new char[len]), bytes(len) { memcpy(data.get(), ptr, len); } @@ -73,8 +73,8 @@ protected: boost::asio::streambuf read_buf_; http_request_type message_; - std::vector wq_; - std::vector wq2_; + std::vector wq_; + std::vector wq2_; std::mutex mutex_; bool graceful_ = false; bool complete_ = false; @@ -93,7 +93,7 @@ public: Handler& handler, boost::asio::executor const& executor, beast::Journal journal, - endpoint_type remote_address, + endpoint_type remoteAddress, ConstBufferSequence const& buffers); ~BaseHTTPPeer() override; @@ -118,28 +118,28 @@ protected: fail(error_code ec, char const* what); void - start_timer(); + startTimer(); void - cancel_timer(); + cancelTimer(); void - on_timer(); + onTimer(); void - do_read(yield_context do_yield); + doRead(yield_context doYield); void - on_write(error_code const& ec, std::size_t bytes_transferred); + onWrite(error_code const& ec, std::size_t bytesTransferred); void - do_writer(std::shared_ptr const& writer, bool keep_alive, yield_context do_yield); + doWriter(std::shared_ptr const& writer, bool keepAlive, yield_context doYield); virtual void - do_request() = 0; + doRequest() = 0; virtual void - do_close() = 0; + doClose() = 0; // Session @@ -158,7 +158,7 @@ protected: beast::IP::Endpoint remoteAddress() override { - return beast::IPAddressConversion::from_asio(remote_address_); + return beast::IPAddressConversion::fromAsio(remote_address_); } http_request_type& @@ -171,7 +171,7 @@ protected: write(void const* buffer, std::size_t bytes) override; void - write(std::shared_ptr const& writer, bool keep_alive) override; + write(std::shared_ptr const& writer, bool keepAlive) override; std::shared_ptr detach() override; @@ -192,19 +192,19 @@ BaseHTTPPeer::BaseHTTPPeer( Handler& handler, boost::asio::executor const& executor, beast::Journal journal, - endpoint_type remote_address, + endpoint_type remoteAddress, ConstBufferSequence const& buffers) : port_(port) , handler_(handler) , work_(boost::asio::make_work_guard(executor)) , strand_(boost::asio::make_strand(executor)) - , remote_address_(std::move(remote_address)) + , remote_address_(std::move(remoteAddress)) , journal_(journal) { read_buf_.commit( boost::asio::buffer_copy(read_buf_.prepare(boost::asio::buffer_size(buffers)), buffers)); - static std::atomic sid; - nid_ = ++sid; + static std::atomic kSID; + nid_ = ++kSID; id_ = std::string("#") + std::to_string(nid_) + " "; JLOG(journal_.trace()) << id_ << "accept: " << remote_address_.address(); } @@ -247,18 +247,18 @@ BaseHTTPPeer::fail(error_code ec, char const* what) template void -BaseHTTPPeer::start_timer() +BaseHTTPPeer::startTimer() { boost::beast::get_lowest_layer(impl().stream_) .expires_after( std::chrono::seconds( - remote_address_.address().is_loopback() ? timeoutSecondsLocal : timeoutSeconds)); + remote_address_.address().is_loopback() ? TimeoutSecondsLocal : TimeoutSeconds)); } // Convenience for discarding the error code template void -BaseHTTPPeer::cancel_timer() +BaseHTTPPeer::cancelTimer() { boost::beast::get_lowest_layer(impl().stream_).expires_never(); } @@ -266,7 +266,7 @@ BaseHTTPPeer::cancel_timer() // Called when session times out template void -BaseHTTPPeer::on_timer() +BaseHTTPPeer::onTimer() { auto ec = boost::system::errc::make_error_code(boost::system::errc::timed_out); fail(ec, "timer"); @@ -276,34 +276,34 @@ BaseHTTPPeer::on_timer() template void -BaseHTTPPeer::do_read(yield_context do_yield) +BaseHTTPPeer::doRead(yield_context doYield) { complete_ = false; error_code ec; - start_timer(); - boost::beast::http::async_read(impl().stream_, read_buf_, message_, do_yield[ec]); - cancel_timer(); + startTimer(); + boost::beast::http::async_read(impl().stream_, read_buf_, message_, doYield[ec]); + cancelTimer(); if (ec == boost::beast::http::error::end_of_stream) - return do_close(); + return doClose(); if (ec == boost::beast::error::timeout) - return on_timer(); + return onTimer(); if (ec) return fail(ec, "http::read"); - do_request(); + doRequest(); } // Send everything in the write queue. // The write queue must not be empty upon entry. template void -BaseHTTPPeer::on_write(error_code const& ec, std::size_t bytes_transferred) +BaseHTTPPeer::onWrite(error_code const& ec, std::size_t bytesTransferred) { - cancel_timer(); + cancelTimer(); if (ec == boost::beast::error::timeout) - return on_timer(); + return onTimer(); if (ec) return fail(ec, "write"); - bytes_out_ += bytes_transferred; + bytes_out_ += bytesTransferred; { std::scoped_lock const lock(mutex_); wq2_.clear(); @@ -316,14 +316,14 @@ BaseHTTPPeer::on_write(error_code const& ec, std::size_t bytes_tr v.reserve(wq2_.size()); for (auto const& b : wq2_) v.emplace_back(b.data.get(), b.bytes); - start_timer(); + startTimer(); return boost::asio::async_write( impl().stream_, v, bind_executor( strand_, std::bind( - &BaseHTTPPeer::on_write, + &BaseHTTPPeer::onWrite, impl().shared_from_this(), std::placeholders::_1, std::placeholders::_2))); @@ -331,58 +331,58 @@ BaseHTTPPeer::on_write(error_code const& ec, std::size_t bytes_tr if (!complete_) return; if (graceful_) - return do_close(); + return doClose(); util::spawn( strand_, std::bind( - &BaseHTTPPeer::do_read, + &BaseHTTPPeer::doRead, impl().shared_from_this(), std::placeholders::_1)); } template void -BaseHTTPPeer::do_writer( +BaseHTTPPeer::doWriter( std::shared_ptr const& writer, - bool keep_alive, - yield_context do_yield) + bool keepAlive, + yield_context doYield) { std::function resume; { auto const p = impl().shared_from_this(); - resume = std::function([this, p, writer, keep_alive]() { + resume = std::function([this, p, writer, keepAlive]() { util::spawn( strand_, std::bind( - &BaseHTTPPeer::do_writer, + &BaseHTTPPeer::doWriter, p, writer, - keep_alive, + keepAlive, std::placeholders::_1)); }); } for (;;) { - if (!writer->prepare(bufferSize, resume)) + if (!writer->prepare(BufferSize, resume)) return; error_code ec; - auto const bytes_transferred = boost::asio::async_write( - impl().stream_, writer->data(), boost::asio::transfer_at_least(1), do_yield[ec]); + auto const bytesTransferred = boost::asio::async_write( + impl().stream_, writer->data(), boost::asio::transfer_at_least(1), doYield[ec]); if (ec) return fail(ec, "writer"); - writer->consume(bytes_transferred); + writer->consume(bytesTransferred); if (writer->complete()) break; } - if (!keep_alive) - return do_close(); + if (!keepAlive) + return doClose(); util::spawn( strand_, std::bind( - &BaseHTTPPeer::do_read, + &BaseHTTPPeer::doRead, impl().shared_from_this(), std::placeholders::_1)); } @@ -406,23 +406,23 @@ BaseHTTPPeer::write(void const* buf, std::size_t bytes) { return post( strand_, - std::bind(&BaseHTTPPeer::on_write, impl().shared_from_this(), error_code{}, 0)); + std::bind(&BaseHTTPPeer::onWrite, impl().shared_from_this(), error_code{}, 0)); } - return on_write(error_code{}, 0); + return onWrite(error_code{}, 0); } } template void -BaseHTTPPeer::write(std::shared_ptr const& writer, bool keep_alive) +BaseHTTPPeer::write(std::shared_ptr const& writer, bool keepAlive) { util::spawn( strand_, std::bind( - &BaseHTTPPeer::do_writer, + &BaseHTTPPeer::doWriter, impl().shared_from_this(), writer, - keep_alive, + keepAlive, std::placeholders::_1)); } @@ -460,7 +460,7 @@ BaseHTTPPeer::complete() util::spawn( strand_, std::bind( - &BaseHTTPPeer::do_read, + &BaseHTTPPeer::doRead, impl().shared_from_this(), std::placeholders::_1)); } @@ -490,7 +490,7 @@ BaseHTTPPeer::close(bool graceful) if (!wq_.empty() || !wq2_.empty()) return; } - return do_close(); + return doClose(); } boost::beast::get_lowest_layer(impl().stream_).close(); diff --git a/include/xrpl/server/detail/BasePeer.h b/include/xrpl/server/detail/BasePeer.h index 5bde6924a5..4aec164fe2 100644 --- a/include/xrpl/server/detail/BasePeer.h +++ b/include/xrpl/server/detail/BasePeer.h @@ -17,7 +17,7 @@ namespace xrpl { // Common part of all peers template -class BasePeer : public io_list::work +class BasePeer : public IoList::Work { protected: using clock_type = std::chrono::system_clock; @@ -40,7 +40,7 @@ public: Port const& port, Handler& handler, boost::asio::executor const& executor, - endpoint_type remote_address, + endpoint_type remoteAddress, beast::Journal journal); void @@ -61,16 +61,16 @@ BasePeer::BasePeer( Port const& port, Handler& handler, boost::asio::executor const& executor, - endpoint_type remote_address, + endpoint_type remoteAddress, beast::Journal journal) : port_(port) , handler_(handler) - , remote_address_(std::move(remote_address)) + , remote_address_(std::move(remoteAddress)) , sink_( journal.sink(), [] { - static std::atomic id{0}; - return "##" + std::to_string(++id) + " "; + static std::atomic kID{0}; + return "##" + std::to_string(++kID) + " "; }()) , j_(sink_) , work_(boost::asio::make_work_guard(executor)) @@ -85,7 +85,7 @@ BasePeer::close() if (!strand_.running_in_this_thread()) return post(strand_, std::bind(&BasePeer::close, impl().shared_from_this())); error_code ec; - xrpl::get_lowest_layer(impl().ws_).socket().close(ec); + xrpl::getLowestLayer(impl().ws_).socket().close(ec); } } // namespace xrpl diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index aaa4791059..0d592ff09f 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -59,7 +59,7 @@ public: Handler& handler, boost::asio::executor const& executor, waitable_timer timer, - endpoint_type remote_address, + endpoint_type remoteAddress, boost::beast::http::request&& request, beast::Journal journal); @@ -83,7 +83,7 @@ public: } [[nodiscard]] boost::asio::ip::tcp::endpoint const& - remote_endpoint() const override + remoteEndpoint() const override { return this->remote_address_; } @@ -108,40 +108,40 @@ protected: } void - on_ws_handshake(error_code const& ec); + onWsHandshake(error_code const& ec); void - do_write(); + doWrite(); void - on_write(error_code const& ec); + onWrite(error_code const& ec); void - on_write_fin(error_code const& ec); + onWriteFin(error_code const& ec); void - do_read(); + doRead(); void - on_read(error_code const& ec); + onRead(error_code const& ec); void - on_close(error_code const& ec); + onClose(error_code const& ec); void - start_timer(); + startTimer(); void - cancel_timer(); + cancelTimer(); void - on_ping(error_code const& ec); + onPing(error_code const& ec); void - on_ping_pong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload); + onPingPong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload); void - on_timer(error_code ec); + onTimer(error_code ec); template void @@ -157,10 +157,10 @@ BaseWSPeer::BaseWSPeer( Handler& handler, boost::asio::executor const& executor, waitable_timer timer, - endpoint_type remote_address, + endpoint_type remoteAddress, boost::beast::http::request&& request, beast::Journal journal) - : BasePeer(port, handler, executor, remote_address, journal) + : BasePeer(port, handler, executor, remoteAddress, journal) , request_(std::move(request)) , timer_(std::move(timer)) , payload_("12345678") // ensures size is 8 bytes @@ -177,9 +177,9 @@ BaseWSPeer::run() // Must manage the control callback memory outside of the `control_callback` // function control_callback_ = - std::bind(&BaseWSPeer::on_ping_pong, this, std::placeholders::_1, std::placeholders::_2); + std::bind(&BaseWSPeer::onPingPong, this, std::placeholders::_1, std::placeholders::_2); impl().ws_.control_callback(control_callback_); - start_timer(); + startTimer(); close_on_timer_ = true; impl().ws_.set_option(boost::beast::websocket::stream_base::decorator([](auto& res) { res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString()); @@ -189,7 +189,7 @@ BaseWSPeer::run() bind_executor( strand_, std::bind( - &BaseWSPeer::on_ws_handshake, impl().shared_from_this(), std::placeholders::_1))); + &BaseWSPeer::onWsHandshake, impl().shared_from_this(), std::placeholders::_1))); } template @@ -202,7 +202,7 @@ BaseWSPeer::send(std::shared_ptr w) return; if (wq_.size() > port().ws_queue_limit) { - cr_.code = safe_cast(boost::beast::websocket::close_code::policy_error); + cr_.code = safeCast(boost::beast::websocket::close_code::policy_error); cr_.reason = "Policy error: client is too slow."; JLOG(this->j_.info()) << cr_.reason; wq_.erase(std::next(wq_.begin()), wq_.end()); @@ -211,7 +211,7 @@ BaseWSPeer::send(std::shared_ptr w) } wq_.emplace_back(std::move(w)); if (wq_.size() == 1) - on_write({}); + onWrite({}); } template @@ -236,7 +236,7 @@ BaseWSPeer::close(boost::beast::websocket::close_reason const& re reason, bind_executor( strand_, [self = impl().shared_from_this()](boost::beast::error_code const& ec) { - self->on_close(ec); + self->onClose(ec); })); } else @@ -251,40 +251,40 @@ BaseWSPeer::complete() { if (!strand_.running_in_this_thread()) return post(strand_, std::bind(&BaseWSPeer::complete, impl().shared_from_this())); - do_read(); + doRead(); } template void -BaseWSPeer::on_ws_handshake(error_code const& ec) +BaseWSPeer::onWsHandshake(error_code const& ec) { if (ec) return fail(ec, "on_ws_handshake"); close_on_timer_ = false; - do_read(); + doRead(); } template void -BaseWSPeer::do_write() +BaseWSPeer::doWrite() { if (!strand_.running_in_this_thread()) - return post(strand_, std::bind(&BaseWSPeer::do_write, impl().shared_from_this())); - on_write({}); + return post(strand_, std::bind(&BaseWSPeer::doWrite, impl().shared_from_this())); + onWrite({}); } template void -BaseWSPeer::on_write(error_code const& ec) +BaseWSPeer::onWrite(error_code const& ec) { if (ec) return fail(ec, "write"); auto& w = *wq_.front(); auto const result = - w.prepare(65536, std::bind(&BaseWSPeer::do_write, impl().shared_from_this())); + w.prepare(65536, std::bind(&BaseWSPeer::doWrite, impl().shared_from_this())); if (boost::indeterminate(result.first)) return; - start_timer(); + startTimer(); if (!result.first) { impl().ws_.async_write_some( @@ -292,8 +292,7 @@ BaseWSPeer::on_write(error_code const& ec) result.second, bind_executor( strand_, - std::bind( - &BaseWSPeer::on_write, impl().shared_from_this(), std::placeholders::_1))); + std::bind(&BaseWSPeer::onWrite, impl().shared_from_this(), std::placeholders::_1))); } else { @@ -303,13 +302,13 @@ BaseWSPeer::on_write(error_code const& ec) bind_executor( strand_, std::bind( - &BaseWSPeer::on_write_fin, impl().shared_from_this(), std::placeholders::_1))); + &BaseWSPeer::onWriteFin, impl().shared_from_this(), std::placeholders::_1))); } } template void -BaseWSPeer::on_write_fin(error_code const& ec) +BaseWSPeer::onWriteFin(error_code const& ec) { if (ec) return fail(ec, "write_fin"); @@ -320,34 +319,33 @@ BaseWSPeer::on_write_fin(error_code const& ec) cr_, bind_executor( strand_, - std::bind( - &BaseWSPeer::on_close, impl().shared_from_this(), std::placeholders::_1))); + std::bind(&BaseWSPeer::onClose, impl().shared_from_this(), std::placeholders::_1))); } else if (!wq_.empty()) { - on_write({}); + onWrite({}); } } template void -BaseWSPeer::do_read() +BaseWSPeer::doRead() { if (!strand_.running_in_this_thread()) - return post(strand_, std::bind(&BaseWSPeer::do_read, impl().shared_from_this())); + return post(strand_, std::bind(&BaseWSPeer::doRead, impl().shared_from_this())); impl().ws_.async_read( rb_, bind_executor( strand_, - std::bind(&BaseWSPeer::on_read, impl().shared_from_this(), std::placeholders::_1))); + std::bind(&BaseWSPeer::onRead, impl().shared_from_this(), std::placeholders::_1))); } template void -BaseWSPeer::on_read(error_code const& ec) +BaseWSPeer::onRead(error_code const& ec) { if (ec == boost::beast::websocket::error::closed) - return on_close({}); + return onClose({}); if (ec) return fail(ec, "read"); auto const& data = rb_.data(); @@ -360,22 +358,22 @@ BaseWSPeer::on_read(error_code const& ec) template void -BaseWSPeer::on_close(error_code const& ec) +BaseWSPeer::onClose(error_code const& ec) { - cancel_timer(); + cancelTimer(); } template void -BaseWSPeer::start_timer() +BaseWSPeer::startTimer() { // Max seconds without completing a message - static constexpr std::chrono::seconds timeout{30}; - static constexpr std::chrono::seconds timeoutLocal{3}; + static constexpr std::chrono::seconds kTIMEOUT{30}; + static constexpr std::chrono::seconds kTIMEOUT_LOCAL{3}; try { - timer_.expires_after(remote_endpoint().address().is_loopback() ? timeoutLocal : timeout); + timer_.expires_after(remoteEndpoint().address().is_loopback() ? kTIMEOUT_LOCAL : kTIMEOUT); } catch (boost::system::system_error const& e) { @@ -385,7 +383,7 @@ BaseWSPeer::start_timer() timer_.async_wait(bind_executor( strand_, std::bind( - &BaseWSPeer::on_timer, + &BaseWSPeer::onTimer, impl().shared_from_this(), std::placeholders::_1))); } @@ -393,7 +391,7 @@ BaseWSPeer::start_timer() // Convenience for discarding the error code template void -BaseWSPeer::cancel_timer() +BaseWSPeer::cancelTimer() { try { @@ -407,7 +405,7 @@ BaseWSPeer::cancel_timer() template void -BaseWSPeer::on_ping(error_code const& ec) +BaseWSPeer::onPing(error_code const& ec) { if (ec == boost::asio::error::operation_aborted) return; @@ -419,7 +417,7 @@ BaseWSPeer::on_ping(error_code const& ec) template void -BaseWSPeer::on_ping_pong( +BaseWSPeer::onPingPong( boost::beast::websocket::frame_type kind, boost::beast::string_view payload) { @@ -440,7 +438,7 @@ BaseWSPeer::on_ping_pong( template void -BaseWSPeer::on_timer(error_code ec) +BaseWSPeer::onTimer(error_code ec) { if (ec == boost::asio::error::operation_aborted) return; @@ -448,17 +446,17 @@ BaseWSPeer::on_timer(error_code ec) { if (!close_on_timer_ || !ping_active_) { - start_timer(); + startTimer(); close_on_timer_ = true; ping_active_ = true; // cryptographic is probably overkill.. - beast::rngfill(payload_.begin(), payload_.size(), crypto_prng()); + beast::rngfill(payload_.begin(), payload_.size(), cryptoPrng()); impl().ws_.async_ping( payload_, bind_executor( strand_, std::bind( - &BaseWSPeer::on_ping, impl().shared_from_this(), std::placeholders::_1))); + &BaseWSPeer::onPing, impl().shared_from_this(), std::placeholders::_1))); JLOG(this->j_.trace()) << "sent ping"; return; } @@ -474,12 +472,12 @@ BaseWSPeer::fail(error_code ec, String const& what) { XRPL_ASSERT(strand_.running_in_this_thread(), "xrpl::BaseWSPeer::fail : strand in this thread"); - cancel_timer(); + cancelTimer(); if (!ec_ && ec != boost::asio::error::operation_aborted) { ec_ = ec; JLOG(this->j_.trace()) << what << ": " << ec.message(); - xrpl::get_lowest_layer(impl().ws_).socket().close(ec); + xrpl::getLowestLayer(impl().ws_).socket().close(ec); } } diff --git a/include/xrpl/server/detail/Door.h b/include/xrpl/server/detail/Door.h index 2d95a1c5aa..811bf68a74 100644 --- a/include/xrpl/server/detail/Door.h +++ b/include/xrpl/server/detail/Door.h @@ -39,7 +39,7 @@ namespace xrpl { /** A listening socket. */ template -class Door : public io_list::work, public std::enable_shared_from_this> +class Door : public IoList::Work, public std::enable_shared_from_this> { private: using clock_type = std::chrono::steady_clock; @@ -53,7 +53,7 @@ private: using stream_type = boost::beast::tcp_stream; // Detects SSL on a socket - class Detector : public io_list::work, public std::enable_shared_from_this + class Detector : public IoList::Work, public std::enable_shared_from_this { private: Port const& port_; @@ -71,7 +71,7 @@ private: Handler& handler, boost::asio::io_context& ioc, stream_type&& stream, - endpoint_type remote_address, + endpoint_type remoteAddress, beast::Journal j); void run(); @@ -80,7 +80,7 @@ private: private: void - do_detect(yield_context yield); + doDetect(yield_context yield); }; beast::Journal const j_; @@ -95,11 +95,11 @@ private: bool plain_{ port_.protocol.count("http") > 0 || port_.protocol.count("ws") > 0 || (port_.protocol.count("ws2") != 0u)}; - static constexpr std::chrono::milliseconds INITIAL_ACCEPT_DELAY{50}; - static constexpr std::chrono::milliseconds MAX_ACCEPT_DELAY{2000}; - std::chrono::milliseconds accept_delay_{INITIAL_ACCEPT_DELAY}; + static constexpr std::chrono::milliseconds kINITIAL_ACCEPT_DELAY{50}; + static constexpr std::chrono::milliseconds kMAX_ACCEPT_DELAY{2000}; + std::chrono::milliseconds accept_delay_{kINITIAL_ACCEPT_DELAY}; boost::asio::steady_timer backoff_timer_; - static constexpr double FREE_FD_THRESHOLD = 0.70; + static constexpr double kFREE_FD_THRESHOLD = 0.70; struct FDStats { @@ -111,13 +111,13 @@ private: reOpen(); std::optional - query_fd_stats() const; + queryFdStats() const; bool - should_throttle_for_fds(); + shouldThrottleForFds(); public: - Door(Handler& handler, boost::asio::io_context& io_context, Port const& port, beast::Journal j); + Door(Handler& handler, boost::asio::io_context& ioContext, Port const& port, beast::Journal j); // Work-around because we can't call shared_from_this in ctor void @@ -133,7 +133,7 @@ public: close() override; [[nodiscard]] endpoint_type - get_endpoint() const + getEndpoint() const { return acceptor_.local_endpoint(); } @@ -145,10 +145,10 @@ private: bool ssl, ConstBufferSequence const& buffers, stream_type&& stream, - endpoint_type remote_address); + endpoint_type remoteAddress); void - do_accept(yield_context yield); + doAccept(yield_context yield); }; template @@ -157,14 +157,14 @@ Door::Detector::Detector( Handler& handler, boost::asio::io_context& ioc, stream_type&& stream, - endpoint_type remote_address, + endpoint_type remoteAddress, beast::Journal j) : port_(port) , handler_(handler) , ioc_(ioc) , stream_(std::move(stream)) , socket_(stream_.socket()) - , remote_address_(std::move(remote_address)) + , remote_address_(std::move(remoteAddress)) , strand_(boost::asio::make_strand(ioc_)) , j_(j) { @@ -175,7 +175,7 @@ void Door::Detector::run() { util::spawn( - strand_, std::bind(&Detector::do_detect, this->shared_from_this(), std::placeholders::_1)); + strand_, std::bind(&Detector::doDetect, this->shared_from_this(), std::placeholders::_1)); } template @@ -187,12 +187,12 @@ Door::Detector::close() template void -Door::Detector::do_detect(boost::asio::yield_context do_yield) +Door::Detector::doDetect(boost::asio::yield_context doYield) { boost::beast::multi_buffer buf(16); stream_.expires_after(std::chrono::seconds(15)); boost::system::error_code ec; - bool const ssl = async_detect_ssl(stream_, buf, do_yield[ec]); + bool const ssl = async_detect_ssl(stream_, buf, doYield[ec]); stream_.expires_never(); if (!ec) { @@ -234,9 +234,9 @@ Door::reOpen() } } - endpoint_type const local_address = endpoint_type(port_.ip, port_.port); + endpoint_type const localAddress = endpoint_type(port_.ip, port_.port); - acceptor_.open(local_address.protocol(), ec); + acceptor_.open(localAddress.protocol(), ec); if (ec) { JLOG(j_.error()) << "Open port '" << port_.name << "' failed:" << ec.message(); @@ -250,7 +250,7 @@ Door::reOpen() Throw(); } - acceptor_.bind(local_address, ec); + acceptor_.bind(localAddress, ec); if (ec) { JLOG(j_.error()) << "Bind port '" << port_.name << "' failed:" << ec.message(); @@ -270,16 +270,16 @@ Door::reOpen() template Door::Door( Handler& handler, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, Port const& port, beast::Journal j) : j_(j) , port_(port) , handler_(handler) - , ioc_(io_context) - , acceptor_(io_context) - , strand_(boost::asio::make_strand(io_context)) - , backoff_timer_(io_context) + , ioc_(ioContext) + , acceptor_(ioContext) + , strand_(boost::asio::make_strand(ioContext)) + , backoff_timer_(ioContext) { reOpen(); } @@ -290,7 +290,7 @@ Door::run() { util::spawn( strand_, - std::bind(&Door::do_accept, this->shared_from_this(), std::placeholders::_1)); + std::bind(&Door::doAccept, this->shared_from_this(), std::placeholders::_1)); } template @@ -316,41 +316,41 @@ Door::create( bool ssl, ConstBufferSequence const& buffers, stream_type&& stream, - endpoint_type remote_address) + endpoint_type remoteAddress) { if (ssl) { if (auto sp = ios().template emplace>( - port_, handler_, ioc_, j_, remote_address, buffers, std::move(stream))) + port_, handler_, ioc_, j_, remoteAddress, buffers, std::move(stream))) sp->run(); return; } if (auto sp = ios().template emplace>( - port_, handler_, ioc_, j_, remote_address, buffers, std::move(stream))) + port_, handler_, ioc_, j_, remoteAddress, buffers, std::move(stream))) sp->run(); } template void -Door::do_accept(boost::asio::yield_context do_yield) +Door::doAccept(boost::asio::yield_context doYield) { while (acceptor_.is_open()) { - if (should_throttle_for_fds()) + if (shouldThrottleForFds()) { backoff_timer_.expires_after(accept_delay_); boost::system::error_code tec; - backoff_timer_.async_wait(do_yield[tec]); - accept_delay_ = std::min(accept_delay_ * 2, MAX_ACCEPT_DELAY); + backoff_timer_.async_wait(doYield[tec]); + accept_delay_ = std::min(accept_delay_ * 2, kMAX_ACCEPT_DELAY); JLOG(j_.warn()) << "Throttling do_accept for " << accept_delay_.count() << "ms."; continue; } error_code ec; - endpoint_type remote_address; + endpoint_type remoteAddress; stream_type stream(ioc_); socket_type& socket = stream.socket(); - acceptor_.async_accept(socket, remote_address, do_yield[ec]); + acceptor_.async_accept(socket, remoteAddress, doYield[ec]); if (ec) { if (ec == boost::asio::error::operation_aborted) @@ -364,9 +364,9 @@ Door::do_accept(boost::asio::yield_context do_yield) backoff_timer_.expires_after(accept_delay_); boost::system::error_code tec; - backoff_timer_.async_wait(do_yield[tec]); + backoff_timer_.async_wait(doYield[tec]); - accept_delay_ = std::min(accept_delay_ * 2, MAX_ACCEPT_DELAY); + accept_delay_ = std::min(accept_delay_ * 2, kMAX_ACCEPT_DELAY); } else { @@ -375,24 +375,24 @@ Door::do_accept(boost::asio::yield_context do_yield) continue; } - accept_delay_ = INITIAL_ACCEPT_DELAY; + accept_delay_ = kINITIAL_ACCEPT_DELAY; if (ssl_ && plain_) { if (auto sp = ios().template emplace( - port_, handler_, ioc_, std::move(stream), remote_address, j_)) + port_, handler_, ioc_, std::move(stream), remoteAddress, j_)) sp->run(); } else if (ssl_ || plain_) { - create(ssl_, boost::asio::null_buffers{}, std::move(stream), remote_address); + create(ssl_, boost::asio::null_buffers{}, std::move(stream), remoteAddress); } } } template std::optional::FDStats> -Door::query_fd_stats() const +Door::queryFdStats() const { #if BOOST_OS_WINDOWS return std::nullopt; @@ -403,11 +403,11 @@ Door::query_fd_stats() const return std::nullopt; s.limit = static_cast(rl.rlim_cur); #if BOOST_OS_LINUX - constexpr char const* kFdDir = "/proc/self/fd"; + constexpr char const* kFD_DIR = "/proc/self/fd"; #else - constexpr char const* kFdDir = "/dev/fd"; + constexpr char const* kFD_DIR = "/dev/fd"; #endif - if (DIR* d = ::opendir(kFdDir)) + if (DIR* d = ::opendir(kFD_DIR)) { std::uint64_t cnt = 0; while (::readdir(d) != nullptr) @@ -423,19 +423,19 @@ Door::query_fd_stats() const template bool -Door::should_throttle_for_fds() +Door::shouldThrottleForFds() { #if BOOST_OS_WINDOWS return false; #else - auto const stats = query_fd_stats(); + auto const stats = queryFdStats(); if (!stats || stats->limit == 0) return false; auto const& s = *stats; auto const free = (s.limit > s.used) ? (s.limit - s.used) : 0ull; - double const free_ratio = static_cast(free) / static_cast(s.limit); - return free_ratio < FREE_FD_THRESHOLD; + double const freeRatio = static_cast(free) / static_cast(s.limit); + return freeRatio < kFREE_FD_THRESHOLD; #endif } diff --git a/include/xrpl/server/detail/JSONRPCUtil.h b/include/xrpl/server/detail/JSONRPCUtil.h index 934085f8e6..b2e87f5332 100644 --- a/include/xrpl/server/detail/JSONRPCUtil.h +++ b/include/xrpl/server/detail/JSONRPCUtil.h @@ -7,6 +7,6 @@ namespace xrpl { void -HTTPReply(int nStatus, std::string const& strMsg, Json::Output const&, beast::Journal j); +httpReply(int nStatus, std::string const& strMsg, json::Output const&, beast::Journal j); } // namespace xrpl diff --git a/include/xrpl/server/detail/LowestLayer.h b/include/xrpl/server/detail/LowestLayer.h index b8b0d46180..d28510d1a5 100644 --- a/include/xrpl/server/detail/LowestLayer.h +++ b/include/xrpl/server/detail/LowestLayer.h @@ -11,7 +11,7 @@ namespace xrpl { // Before boost 1.70, get_lowest_layer required an explicit template parameter template decltype(auto) -get_lowest_layer(T& t) noexcept +getLowestLayer(T& t) noexcept { #if BOOST_VERSION >= 107000 return boost::beast::get_lowest_layer(t); diff --git a/include/xrpl/server/detail/PlainHTTPPeer.h b/include/xrpl/server/detail/PlainHTTPPeer.h index ef6128560a..40f7fe2571 100644 --- a/include/xrpl/server/detail/PlainHTTPPeer.h +++ b/include/xrpl/server/detail/PlainHTTPPeer.h @@ -30,7 +30,7 @@ public: Handler& handler, boost::asio::io_context& ioc, beast::Journal journal, - endpoint_type remote_address, + endpoint_type remoteAddress, ConstBufferSequence const& buffers, stream_type&& stream); @@ -42,10 +42,10 @@ public: private: void - do_request() override; + doRequest() override; void - do_close() override; + doClose() override; }; //------------------------------------------------------------------------------ @@ -57,7 +57,7 @@ PlainHTTPPeer::PlainHTTPPeer( Handler& handler, boost::asio::io_context& ioc, beast::Journal journal, - endpoint_type remote_endpoint, + endpoint_type remoteEndpoint, ConstBufferSequence const& buffers, stream_type&& stream) : BaseHTTPPeer( @@ -65,7 +65,7 @@ PlainHTTPPeer::PlainHTTPPeer( handler, ioc.get_executor(), journal, - remote_endpoint, + remoteEndpoint, buffers) , stream_(std::move(stream)) , socket_(stream_.socket()) @@ -74,7 +74,7 @@ PlainHTTPPeer::PlainHTTPPeer( // otherwise Nagle's algorithm makes Env // tests run slower on Linux systems. // - if (remote_endpoint.address().is_loopback()) + if (remoteEndpoint.address().is_loopback()) socket_.set_option(boost::asio::ip::tcp::no_delay{true}); } @@ -84,7 +84,7 @@ PlainHTTPPeer::run() { if (!this->handler_.onAccept(this->session(), this->remote_address_)) { - util::spawn(this->strand_, std::bind(&PlainHTTPPeer::do_close, this->shared_from_this())); + util::spawn(this->strand_, std::bind(&PlainHTTPPeer::doClose, this->shared_from_this())); return; } @@ -93,7 +93,7 @@ PlainHTTPPeer::run() util::spawn( this->strand_, - std::bind(&PlainHTTPPeer::do_read, this->shared_from_this(), std::placeholders::_1)); + std::bind(&PlainHTTPPeer::doRead, this->shared_from_this(), std::placeholders::_1)); } template @@ -112,7 +112,7 @@ PlainHTTPPeer::websocketUpgrade() template void -PlainHTTPPeer::do_request() +PlainHTTPPeer::doRequest() { ++this->request_count_; auto const what = @@ -131,7 +131,7 @@ PlainHTTPPeer::do_request() } // Perform half-close when Connection: close and not SSL - if (!beast::rfc2616::is_keep_alive(this->message_)) + if (!beast::rfc2616::isKeepAlive(this->message_)) socket_.shutdown(socket_type::shutdown_receive, ec); if (ec) return this->fail(ec, "request"); @@ -141,7 +141,7 @@ PlainHTTPPeer::do_request() template void -PlainHTTPPeer::do_close() +PlainHTTPPeer::doClose() { boost::system::error_code ec; socket_.shutdown(socket_type::shutdown_send, ec); diff --git a/include/xrpl/server/detail/PlainWSPeer.h b/include/xrpl/server/detail/PlainWSPeer.h index 9196d5ea49..593973a3ed 100644 --- a/include/xrpl/server/detail/PlainWSPeer.h +++ b/include/xrpl/server/detail/PlainWSPeer.h @@ -28,7 +28,7 @@ public: PlainWSPeer( Port const& port, Handler& handler, - endpoint_type remote_address, + endpoint_type remoteAddress, boost::beast::http::request&& request, socket_type&& socket, beast::Journal journal); @@ -41,7 +41,7 @@ template PlainWSPeer::PlainWSPeer( Port const& port, Handler& handler, - endpoint_type remote_address, + endpoint_type remoteAddress, boost::beast::http::request&& request, socket_type&& socket, beast::Journal journal) @@ -50,7 +50,7 @@ PlainWSPeer::PlainWSPeer( handler, socket.get_executor(), waitable_timer{socket.get_executor()}, - remote_address, + remoteAddress, std::move(request), journal) , ws_(std::move(socket)) diff --git a/include/xrpl/server/detail/SSLHTTPPeer.h b/include/xrpl/server/detail/SSLHTTPPeer.h index 240261fce6..2eec8ed60f 100644 --- a/include/xrpl/server/detail/SSLHTTPPeer.h +++ b/include/xrpl/server/detail/SSLHTTPPeer.h @@ -37,7 +37,7 @@ public: Handler& handler, boost::asio::io_context& ioc, beast::Journal journal, - endpoint_type remote_address, + endpoint_type remoteAddress, ConstBufferSequence const& buffers, middle_type&& stream); @@ -49,16 +49,16 @@ public: private: void - do_handshake(yield_context do_yield); + doHandshake(yield_context doYield); void - do_request() override; + doRequest() override; void - do_close() override; + doClose() override; void - on_shutdown(error_code ec); + onShutdown(error_code ec); }; //------------------------------------------------------------------------------ @@ -70,7 +70,7 @@ SSLHTTPPeer::SSLHTTPPeer( Handler& handler, boost::asio::io_context& ioc, beast::Journal journal, - endpoint_type remote_address, + endpoint_type remoteAddress, ConstBufferSequence const& buffers, middle_type&& stream) : BaseHTTPPeer( @@ -78,7 +78,7 @@ SSLHTTPPeer::SSLHTTPPeer( handler, ioc.get_executor(), journal, - remote_address, + remoteAddress, buffers) , stream_ptr_(std::make_unique(middle_type(std::move(stream)), *port.context)) , stream_(*stream_ptr_) @@ -93,14 +93,14 @@ SSLHTTPPeer::run() { if (!this->handler_.onAccept(this->session(), this->remote_address_)) { - util::spawn(this->strand_, std::bind(&SSLHTTPPeer::do_close, this->shared_from_this())); + util::spawn(this->strand_, std::bind(&SSLHTTPPeer::doClose, this->shared_from_this())); return; } if (!socket_.is_open()) return; util::spawn( this->strand_, - std::bind(&SSLHTTPPeer::do_handshake, this->shared_from_this(), std::placeholders::_1)); + std::bind(&SSLHTTPPeer::doHandshake, this->shared_from_this(), std::placeholders::_1)); } template @@ -119,16 +119,16 @@ SSLHTTPPeer::websocketUpgrade() template void -SSLHTTPPeer::do_handshake(yield_context do_yield) +SSLHTTPPeer::doHandshake(yield_context doYield) { boost::system::error_code ec; stream_.set_verify_mode(boost::asio::ssl::verify_none); - this->start_timer(); + this->startTimer(); this->read_buf_.consume( - stream_.async_handshake(stream_type::server, this->read_buf_.data(), do_yield[ec])); - this->cancel_timer(); + stream_.async_handshake(stream_type::server, this->read_buf_.data(), doYield[ec])); + this->cancelTimer(); if (ec == boost::beast::error::timeout) - return this->on_timer(); + return this->onTimer(); if (ec) return this->fail(ec, "handshake"); bool const http = this->port().protocol.count("peer") > 0 || @@ -138,7 +138,7 @@ SSLHTTPPeer::do_handshake(yield_context do_yield) { util::spawn( this->strand_, - std::bind(&SSLHTTPPeer::do_read, this->shared_from_this(), std::placeholders::_1)); + std::bind(&SSLHTTPPeer::doRead, this->shared_from_this(), std::placeholders::_1)); return; } // `this` will be destroyed @@ -146,7 +146,7 @@ SSLHTTPPeer::do_handshake(yield_context do_yield) template void -SSLHTTPPeer::do_request() +SSLHTTPPeer::doRequest() { ++this->request_count_; auto const what = this->handler_.onHandoff( @@ -161,19 +161,19 @@ SSLHTTPPeer::do_request() template void -SSLHTTPPeer::do_close() +SSLHTTPPeer::doClose() { - this->start_timer(); + this->startTimer(); stream_.async_shutdown(bind_executor( this->strand_, - std::bind(&SSLHTTPPeer::on_shutdown, this->shared_from_this(), std::placeholders::_1))); + std::bind(&SSLHTTPPeer::onShutdown, this->shared_from_this(), std::placeholders::_1))); } template void -SSLHTTPPeer::on_shutdown(error_code ec) +SSLHTTPPeer::onShutdown(error_code ec) { - this->cancel_timer(); + this->cancelTimer(); if (ec == boost::asio::error::operation_aborted) return; diff --git a/include/xrpl/server/detail/SSLWSPeer.h b/include/xrpl/server/detail/SSLWSPeer.h index b80312e55f..19b77ea932 100644 --- a/include/xrpl/server/detail/SSLWSPeer.h +++ b/include/xrpl/server/detail/SSLWSPeer.h @@ -36,9 +36,9 @@ public: SSLWSPeer( Port const& port, Handler& handler, - endpoint_type remote_endpoint, + endpoint_type remoteEndpoint, boost::beast::http::request&& request, - std::unique_ptr&& stream_ptr, + std::unique_ptr&& streamPtr, beast::Journal journal); }; @@ -49,19 +49,19 @@ template SSLWSPeer::SSLWSPeer( Port const& port, Handler& handler, - endpoint_type remote_endpoint, + endpoint_type remoteEndpoint, boost::beast::http::request&& request, - std::unique_ptr&& stream_ptr, + std::unique_ptr&& streamPtr, beast::Journal journal) : BaseWSPeer( port, handler, - stream_ptr->get_executor(), - waitable_timer{stream_ptr->get_executor()}, - remote_endpoint, + streamPtr->get_executor(), + waitable_timer{streamPtr->get_executor()}, + remoteEndpoint, std::move(request), journal) - , stream_ptr_(std::move(stream_ptr)) + , stream_ptr_(std::move(streamPtr)) , ws_(*stream_ptr_) { } diff --git a/include/xrpl/server/detail/ServerImpl.h b/include/xrpl/server/detail/ServerImpl.h index 2c3a8330e1..ce3a1c19c7 100644 --- a/include/xrpl/server/detail/ServerImpl.h +++ b/include/xrpl/server/detail/ServerImpl.h @@ -64,7 +64,7 @@ private: // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum { historySize = 100 }; + enum { HistorySize = 100 }; Handler& handler_; beast::Journal const j_; @@ -78,10 +78,10 @@ private: int high_ = 0; std::array hist_{}; - io_list ios_; + IoList ios_; public: - ServerImpl(Handler& handler, boost::asio::io_context& io_context, beast::Journal journal); + ServerImpl(Handler& handler, boost::asio::io_context& ioContext, beast::Journal journal); ~ServerImpl() override; @@ -97,14 +97,14 @@ public: void close() override; - io_list& + IoList& ios() { return ios_; } boost::asio::io_context& - get_io_context() + getIoContext() { return io_context_; } @@ -114,17 +114,17 @@ public: private: static int - ceil_log2(unsigned long long x); + ceilLog2(unsigned long long x); }; template ServerImpl::ServerImpl( Handler& handler, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, beast::Journal journal) : handler_(handler) , j_(journal) - , io_context_(io_context) + , io_context_(ioContext) , strand_(boost::asio::make_strand(io_context_)) , work_(std::in_place, boost::asio::make_work_guard(io_context_)) { @@ -156,7 +156,7 @@ ServerImpl::ports(std::vector const& ports) { list_.push_back(sp); - auto ep = sp->get_endpoint(); + auto ep = sp->getEndpoint(); if (internalPort.port == 0u) internalPort.port = ep.port(); eps.emplace(port.name, std::move(ep)); diff --git a/include/xrpl/server/detail/io_list.h b/include/xrpl/server/detail/io_list.h index 67e04d04b6..a7037b683c 100644 --- a/include/xrpl/server/detail/io_list.h +++ b/include/xrpl/server/detail/io_list.h @@ -12,31 +12,31 @@ namespace xrpl { /** Manages a set of objects performing asynchronous I/O. */ -class io_list final +class IoList final { public: - class work + class Work { template void destroy(); - friend class io_list; - io_list* ios_ = nullptr; + friend class IoList; + IoList* ios_ = nullptr; public: - virtual ~work() + virtual ~Work() { destroy(); } - /** Return the io_list associated with the work. + /** Return the IoList associated with the work. Requirements: - The call to io_list::emplace to + The call to IoList::emplace to create the work has already returned. */ - io_list& + IoList& ios() { return *ios_; @@ -55,21 +55,21 @@ private: std::size_t n_ = 0; bool closed_ = false; std::condition_variable cv_; - boost::container::flat_map> map_; + boost::container::flat_map> map_; std::function f_; public: - io_list() = default; + IoList() = default; /** Destroy the list. Effects: - Closes the io_list if it was not previously + Closes the IoList if it was not previously closed. No finisher is invoked in this case. Blocks until all work is destroyed. */ - ~io_list() + ~IoList() { destroy(); } @@ -89,7 +89,7 @@ public: /** Create associated work if not closed. Requirements: - `std::is_base_of_v == true` + `std::is_base_of_v == true` Thread Safety: May be called concurrently. @@ -101,7 +101,7 @@ public: If the call succeeds and returns a new object, it is guaranteed that a subsequent call to close - will invoke work::close on the object. + will invoke Work::close on the object. */ template @@ -159,7 +159,7 @@ public: template void -io_list::work::destroy() +IoList::Work::destroy() { if (!ios_) return; @@ -179,7 +179,7 @@ io_list::work::destroy() template void -io_list::destroy() +IoList::destroy() { close(); join(); @@ -187,9 +187,9 @@ io_list::destroy() template std::shared_ptr -io_list::emplace(Args&&... args) +IoList::emplace(Args&&... args) { - static_assert(std::is_base_of_v, "T must derive from io_list::work"); + static_assert(std::is_base_of_v, "T must derive from IoList::Work"); if (closed_) return nullptr; auto sp = std::make_shared(std::forward(args)...); @@ -199,7 +199,7 @@ io_list::emplace(Args&&... args) if (!closed_) { ++n_; - sp->work::ios_ = this; + sp->Work::ios_ = this; map_.emplace(sp.get(), sp); } else @@ -211,7 +211,7 @@ io_list::emplace(Args&&... args) template void -io_list::close(Finisher&& f) +IoList::close(Finisher&& f) { std::unique_lock lock(m_); if (closed_) @@ -237,7 +237,7 @@ io_list::close(Finisher&& f) template void -io_list::join() +IoList::join() { std::unique_lock lock(m_); cv_.wait(lock, [&] { return closed_ && n_ == 0; }); diff --git a/include/xrpl/shamap/FullBelowCache.h b/include/xrpl/shamap/FullBelowCache.h index e17a640672..0812f97c7b 100644 --- a/include/xrpl/shamap/FullBelowCache.h +++ b/include/xrpl/shamap/FullBelowCache.h @@ -24,7 +24,7 @@ private: public: // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum { defaultCacheTargetSize = 0 }; + enum { DefaultCacheTargetSize = 0 }; using key_type = uint256; using clock_type = typename CacheType::clock_type; @@ -40,10 +40,10 @@ public: std::string const& name, clock_type& clock, beast::Journal j, - beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::New(), - std::size_t target_size = defaultCacheTargetSize, + beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::make(), + std::size_t targetSize = DefaultCacheTargetSize, std::chrono::seconds expiration = std::chrono::minutes{2}) - : m_cache(name, target_size, expiration, clock, j, collector), m_gen(1) + : cache_(name, targetSize, expiration, clock, j, collector), gen_(1) { } @@ -51,7 +51,7 @@ public: clock_type& clock() { - return m_cache.clock(); + return cache_.clock(); } /** Return the number of elements in the cache. @@ -61,7 +61,7 @@ public: std::size_t size() const { - return m_cache.size(); + return cache_.size(); } /** Remove expired cache items. @@ -71,7 +71,7 @@ public: void sweep() { - m_cache.sweep(); + cache_.sweep(); } /** Refresh the last access time of an item, if it exists. @@ -81,9 +81,9 @@ public: @return `true` If the key exists. */ bool - touch_if_exists(key_type const& key) + touchIfExists(key_type const& key) { - return m_cache.touch_if_exists(key); + return cache_.touchIfExists(key); } /** Insert a key into the cache. @@ -96,33 +96,33 @@ public: void insert(key_type const& key) { - m_cache.insert(key); + cache_.insert(key); } /** generation determines whether cached entry is valid */ std::uint32_t getGeneration(void) const { - return m_gen; + return gen_; } void clear() { - m_cache.clear(); - ++m_gen; + cache_.clear(); + ++gen_; } void reset() { - m_cache.clear(); - m_gen = 1; + cache_.clear(); + gen_ = 1; } private: - CacheType m_cache; - std::atomic m_gen; + CacheType cache_; + std::atomic gen_; }; } // namespace detail diff --git a/include/xrpl/shamap/SHAMap.h b/include/xrpl/shamap/SHAMap.h index 43b2734d65..ba48e1927b 100644 --- a/include/xrpl/shamap/SHAMap.h +++ b/include/xrpl/shamap/SHAMap.h @@ -94,10 +94,10 @@ private: public: /** Number of children each non-leaf node has (the 'radix tree' part of the * map) */ - static constexpr unsigned int branchFactor = SHAMapInnerNode::branchFactor; + static constexpr unsigned int kBRANCH_FACTOR = SHAMapInnerNode::kBRANCH_FACTOR; /** The depth of the hash map: data is only present in the leaves */ - static constexpr unsigned int leafDepth = 64; + static constexpr unsigned int kLEAF_DEPTH = 64; using DeltaItem = std::pair, boost::intrusive_ptr>; @@ -136,11 +136,11 @@ public: This is always a const iterator. Meets the requirements of ForwardRange. */ - class const_iterator; + class ConstIterator; - const_iterator + ConstIterator begin() const; - const_iterator + ConstIterator end() const; //-------------------------------------------------------------------------- @@ -199,8 +199,8 @@ public: @note The item does not need to exist. */ - const_iterator - upper_bound(uint256 const& id) const; + ConstIterator + upperBound(uint256 const& id) const; /** Find the object with the greatest object id smaller than the input id. @@ -208,8 +208,8 @@ public: @note The item does not need to exist. */ - const_iterator - lower_bound(uint256 const& id) const; + ConstIterator + lowerBound(uint256 const& id) const; /** Visit every node in this SHAMap @@ -390,7 +390,7 @@ private: lastBelow( intr_ptr::SharedPtr node, SharedPtrNodeStack& stack, - int branch = branchFactor) const; + int branch = kBRANCH_FACTOR) const; // helper function for firstBelow and lastBelow SHAMapLeafNode* @@ -469,14 +469,14 @@ private: operator=(MissingNodes const&) = delete; // basic parameters - int max_; - SHAMapSyncFilter* filter_; - int const maxDefer_; - std::uint32_t generation_; + int max; + SHAMapSyncFilter* filter; + int const maxDefer; + std::uint32_t generation; // nodes we have discovered to be missing - std::vector> missingNodes_; - std::set missingHashes_; + std::vector> missingNodes; + std::set missingHashes; // nodes we are in the process of traversing using StackEntry = std::tuple< @@ -491,7 +491,7 @@ private: // elements will not be invalidated during the course of element // insertion and removal. Containers that do not offer this guarantee, // such as std::vector, can't be used here. - std::stack> stack_; + std::stack> stack; // nodes we may have acquired from deferred reads using DeferredNode = std::tuple< @@ -500,28 +500,28 @@ private: int, // branch intr_ptr::SharedPtr>; // node - int deferred_; - std::mutex deferLock_; - std::condition_variable deferCondVar_; - std::vector finishedReads_; + int deferred; + std::mutex deferLock; + std::condition_variable deferCondVar; + std::vector finishedReads; // nodes we need to resume after we get their children from deferred // reads - std::map resumes_; + std::map resumes; MissingNodes(int max, SHAMapSyncFilter* filter, int maxDefer, std::uint32_t generation) - : max_(max), filter_(filter), maxDefer_(maxDefer), generation_(generation), deferred_(0) + : max(max), filter(filter), maxDefer(maxDefer), generation(generation), deferred(0) { - missingNodes_.reserve(max); - finishedReads_.reserve(maxDefer); + missingNodes.reserve(max); + finishedReads.reserve(maxDefer); } }; // getMissingNodes helper functions void - gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node); + gmnProcessNodes(MissingNodes&, MissingNodes::StackEntry& node); static void - gmn_ProcessDeferredReads(MissingNodes&); + gmnProcessDeferredReads(MissingNodes&); // fetch from DB helper function intr_ptr::SharedPtr @@ -579,7 +579,7 @@ SHAMap::setUnbacked() //------------------------------------------------------------------------------ -class SHAMap::const_iterator +class SHAMap::ConstIterator { public: using iterator_category = std::forward_iterator_tag; @@ -594,35 +594,35 @@ private: pointer item_ = nullptr; public: - const_iterator() = delete; + ConstIterator() = delete; - const_iterator(const_iterator const& other) = default; - const_iterator& - operator=(const_iterator const& other) = default; + ConstIterator(ConstIterator const& other) = default; + ConstIterator& + operator=(ConstIterator const& other) = default; - ~const_iterator() = default; + ~ConstIterator() = default; reference operator*() const; pointer operator->() const; - const_iterator& + ConstIterator& operator++(); - const_iterator + ConstIterator operator++(int); private: - explicit const_iterator(SHAMap const* map); - const_iterator(SHAMap const* map, std::nullptr_t); - const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack); + explicit ConstIterator(SHAMap const* map); + ConstIterator(SHAMap const* map, std::nullptr_t); + ConstIterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack); friend bool - operator==(const_iterator const& x, const_iterator const& y); + operator==(ConstIterator const& x, ConstIterator const& y); friend class SHAMap; }; -inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) +inline SHAMap::ConstIterator::ConstIterator(SHAMap const* map) : map_(map) { XRPL_ASSERT(map_, "xrpl::SHAMap::const_iterator::const_iterator : non-null input"); @@ -630,11 +630,11 @@ inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) item_ = temp->peekItem().get(); } -inline SHAMap::const_iterator::const_iterator(SHAMap const* map, std::nullptr_t) : map_(map) +inline SHAMap::ConstIterator::ConstIterator(SHAMap const* map, std::nullptr_t) : map_(map) { } -inline SHAMap::const_iterator::const_iterator( +inline SHAMap::ConstIterator::ConstIterator( SHAMap const* map, pointer item, SharedPtrNodeStack&& stack) @@ -642,20 +642,20 @@ inline SHAMap::const_iterator::const_iterator( { } -inline SHAMap::const_iterator::reference -SHAMap::const_iterator::operator*() const +inline SHAMap::ConstIterator::reference +SHAMap::ConstIterator::operator*() const { return *item_; } -inline SHAMap::const_iterator::pointer -SHAMap::const_iterator::operator->() const +inline SHAMap::ConstIterator::pointer +SHAMap::ConstIterator::operator->() const { return item_; } -inline SHAMap::const_iterator& -SHAMap::const_iterator::operator++() +inline SHAMap::ConstIterator& +SHAMap::ConstIterator::operator++() { if (auto temp = map_->peekNextItem(item_->key(), stack_)) { @@ -668,8 +668,8 @@ SHAMap::const_iterator::operator++() return *this; } -inline SHAMap::const_iterator -SHAMap::const_iterator::operator++(int) +inline SHAMap::ConstIterator +SHAMap::ConstIterator::operator++(int) { auto tmp = *this; ++(*this); @@ -677,7 +677,7 @@ SHAMap::const_iterator::operator++(int) } inline bool -operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) +operator==(SHAMap::ConstIterator const& x, SHAMap::ConstIterator const& y) { XRPL_ASSERT( x.map_ == y.map_, @@ -687,21 +687,21 @@ operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) } inline bool -operator!=(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) +operator!=(SHAMap::ConstIterator const& x, SHAMap::ConstIterator const& y) { return !(x == y); } -inline SHAMap::const_iterator +inline SHAMap::ConstIterator SHAMap::begin() const { - return const_iterator(this); + return ConstIterator(this); } -inline SHAMap::const_iterator +inline SHAMap::ConstIterator SHAMap::end() const { - return const_iterator(this, nullptr); + return ConstIterator(this, nullptr); } } // namespace xrpl diff --git a/include/xrpl/shamap/SHAMapAccountStateLeafNode.h b/include/xrpl/shamap/SHAMapAccountStateLeafNode.h index 2f71d10b0a..c006b2de37 100644 --- a/include/xrpl/shamap/SHAMapAccountStateLeafNode.h +++ b/include/xrpl/shamap/SHAMapAccountStateLeafNode.h @@ -30,19 +30,19 @@ public: intr_ptr::SharedPtr clone(std::uint32_t cowid) const final { - return intr_ptr::make_shared(item_, cowid, hash_); + return intr_ptr::makeShared(item_, cowid, hash_); } SHAMapNodeType getType() const final { - return SHAMapNodeType::tnACCOUNT_STATE; + return SHAMapNodeType::TnAccountState; } void updateHash() final { - hash_ = SHAMapHash{sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())}; + hash_ = SHAMapHash{sha512Half(HashPrefix::LeafNode, item_->slice(), item_->key())}; } void @@ -50,13 +50,13 @@ public: { s.addRaw(item_->slice()); s.addBitString(item_->key()); - s.add8(wireTypeAccountState); + s.add8(kWIRE_TYPE_ACCOUNT_STATE); } void serializeWithPrefix(Serializer& s) const final { - s.add32(HashPrefix::leafNode); + s.add32(HashPrefix::LeafNode); s.addRaw(item_->slice()); s.addBitString(item_->key()); } diff --git a/include/xrpl/shamap/SHAMapAddNode.h b/include/xrpl/shamap/SHAMapAddNode.h index a560568126..87222f74d8 100644 --- a/include/xrpl/shamap/SHAMapAddNode.h +++ b/include/xrpl/shamap/SHAMapAddNode.h @@ -8,9 +8,9 @@ namespace xrpl { class SHAMapAddNode { private: - int mGood; - int mBad; - int mDuplicate; + int good_; + int bad_; + int duplicate_; public: SHAMapAddNode(); @@ -47,63 +47,63 @@ private: SHAMapAddNode(int good, int bad, int duplicate); }; -inline SHAMapAddNode::SHAMapAddNode() : mGood(0), mBad(0), mDuplicate(0) +inline SHAMapAddNode::SHAMapAddNode() : good_(0), bad_(0), duplicate_(0) { } inline SHAMapAddNode::SHAMapAddNode(int good, int bad, int duplicate) - : mGood(good), mBad(bad), mDuplicate(duplicate) + : good_(good), bad_(bad), duplicate_(duplicate) { } inline void SHAMapAddNode::incInvalid() { - ++mBad; + ++bad_; } inline void SHAMapAddNode::incUseful() { - ++mGood; + ++good_; } inline void SHAMapAddNode::incDuplicate() { - ++mDuplicate; + ++duplicate_; } inline void SHAMapAddNode::reset() { - mGood = mBad = mDuplicate = 0; + good_ = bad_ = duplicate_ = 0; } inline int SHAMapAddNode::getGood() const { - return mGood; + return good_; } inline bool SHAMapAddNode::isInvalid() const { - return mBad > 0; + return bad_ > 0; } inline bool SHAMapAddNode::isUseful() const { - return mGood > 0; + return good_ > 0; } inline SHAMapAddNode& SHAMapAddNode::operator+=(SHAMapAddNode const& n) { - mGood += n.mGood; - mBad += n.mBad; - mDuplicate += n.mDuplicate; + good_ += n.good_; + bad_ += n.bad_; + duplicate_ += n.duplicate_; return *this; } @@ -111,7 +111,7 @@ SHAMapAddNode::operator+=(SHAMapAddNode const& n) inline bool SHAMapAddNode::isGood() const { - return (mGood + mDuplicate) > mBad; + return (good_ + duplicate_) > bad_; } inline SHAMapAddNode @@ -136,24 +136,24 @@ inline std::string SHAMapAddNode::get() const { std::string ret; - if (mGood > 0) + if (good_ > 0) { ret.append("good:"); - ret.append(std::to_string(mGood)); + ret.append(std::to_string(good_)); } - if (mBad > 0) + if (bad_ > 0) { if (!ret.empty()) ret.append(" "); ret.append("bad:"); - ret.append(std::to_string(mBad)); + ret.append(std::to_string(bad_)); } - if (mDuplicate > 0) + if (duplicate_ > 0) { if (!ret.empty()) ret.append(" "); ret.append("dupe:"); - ret.append(std::to_string(mDuplicate)); + ret.append(std::to_string(duplicate_)); } if (ret.empty()) ret = "no nodes processed"; diff --git a/include/xrpl/shamap/SHAMapInnerNode.h b/include/xrpl/shamap/SHAMapInnerNode.h index f2c34cbc1a..ee2a18bf03 100644 --- a/include/xrpl/shamap/SHAMapInnerNode.h +++ b/include/xrpl/shamap/SHAMapInnerNode.h @@ -15,7 +15,7 @@ class SHAMapInnerNode final : public SHAMapTreeNode, public CountedObject makeFullInner(Slice data, SHAMapHash const& hash, bool hashValid); diff --git a/include/xrpl/shamap/SHAMapItem.h b/include/xrpl/shamap/SHAMapItem.h index da70e16db3..d781dbf894 100644 --- a/include/xrpl/shamap/SHAMapItem.h +++ b/include/xrpl/shamap/SHAMapItem.h @@ -25,7 +25,7 @@ class SHAMapItem : public CountedObject // This is the interface for creating new instances of this class. friend boost::intrusive_ptr - make_shamapitem(uint256 const& tag, Slice data); + makeShamapitem(uint256 const& tag, Slice data); private: uint256 const tag_; @@ -93,7 +93,7 @@ namespace detail { // The slab cutoffs and the number of megabytes per allocation are customized // based on the number of objects of each size we expect to need at any point // in time and with an eye to minimize the number of slack bytes in a block. -inline SlabAllocatorSet slabber({ +inline SlabAllocatorSet gSlabber({ { 128, megabytes(std::size_t(60)) }, { 192, megabytes(std::size_t(46)) }, { 272, megabytes(std::size_t(60)) }, @@ -112,7 +112,7 @@ intrusive_ptr_add_ref(SHAMapItem const* x) // This can only happen if someone releases the last reference to the // item while we were trying to increment the refcount. if (x->refcount_++ == 0) - LogicError("SHAMapItem: the reference count is 0!"); + logicError("SHAMapItem: the reference count is 0!"); } inline void @@ -130,19 +130,19 @@ intrusive_ptr_release(SHAMapItem const* x) // If the slabber doesn't claim this pointer, it was allocated // manually, so we free it manually. - if (!detail::slabber.deallocate(const_cast(p))) + if (!detail::gSlabber.deallocate(const_cast(p))) delete[] p; } } inline boost::intrusive_ptr -make_shamapitem(uint256 const& tag, Slice data) +makeShamapitem(uint256 const& tag, Slice data) { XRPL_ASSERT( data.size() <= megabytes(16), "xrpl::make_shamapitem : maximum input size"); // NOLINTNEXTLINE(misc-const-correctness) - std::uint8_t* raw = detail::slabber.allocate(data.size()); + std::uint8_t* raw = detail::gSlabber.allocate(data.size()); // If we can't grab memory from the slab allocators, we fall back to // the standard library and try to grab a precisely-sized memory block: @@ -160,9 +160,9 @@ static_assert(alignof(SHAMapItem) != 40); static_assert(alignof(SHAMapItem) == 8 || alignof(SHAMapItem) == 4); inline boost::intrusive_ptr -make_shamapitem(SHAMapItem const& other) +makeShamapitem(SHAMapItem const& other) { - return make_shamapitem(other.key(), other.slice()); + return makeShamapitem(other.key(), other.slice()); } } // namespace xrpl diff --git a/include/xrpl/shamap/SHAMapLeafNode.h b/include/xrpl/shamap/SHAMapLeafNode.h index a63041c31c..af5ed29702 100644 --- a/include/xrpl/shamap/SHAMapLeafNode.h +++ b/include/xrpl/shamap/SHAMapLeafNode.h @@ -37,7 +37,7 @@ public: } void - invariants(bool is_root = false) const final; + invariants(bool isRoot = false) const final; public: boost::intrusive_ptr const& diff --git a/include/xrpl/shamap/SHAMapMissingNode.h b/include/xrpl/shamap/SHAMapMissingNode.h index f1670587eb..0bc072463e 100644 --- a/include/xrpl/shamap/SHAMapMissingNode.h +++ b/include/xrpl/shamap/SHAMapMissingNode.h @@ -28,7 +28,7 @@ to_string(SHAMapType t) case SHAMapType::FREE: return "Free Tree"; default: - return std::to_string(safe_cast>(t)); + return std::to_string(safeCast>(t)); } } diff --git a/include/xrpl/shamap/SHAMapTreeNode.h b/include/xrpl/shamap/SHAMapTreeNode.h index 55b18a2d12..d50fc65ccb 100644 --- a/include/xrpl/shamap/SHAMapTreeNode.h +++ b/include/xrpl/shamap/SHAMapTreeNode.h @@ -14,17 +14,17 @@ namespace xrpl { // These are wire-protocol identifiers used during serialization to encode the // type of a node. They should not be arbitrarily be changed. -static constexpr unsigned char const wireTypeTransaction = 0; -static constexpr unsigned char const wireTypeAccountState = 1; -static constexpr unsigned char const wireTypeInner = 2; -static constexpr unsigned char const wireTypeCompressedInner = 3; -static constexpr unsigned char const wireTypeTransactionWithMeta = 4; +static constexpr unsigned char const kWIRE_TYPE_TRANSACTION = 0; +static constexpr unsigned char const kWIRE_TYPE_ACCOUNT_STATE = 1; +static constexpr unsigned char const kWIRE_TYPE_INNER = 2; +static constexpr unsigned char const kWIRE_TYPE_COMPRESSED_INNER = 3; +static constexpr unsigned char const kWIRE_TYPE_TRANSACTION_WITH_META = 4; enum class SHAMapNodeType { - tnINNER = 1, - tnTRANSACTION_NM = 2, // transaction, no metadata - tnTRANSACTION_MD = 3, // transaction, with metadata - tnACCOUNT_STATE = 4 + TnInner = 1, + TnTransactionNm = 2, // transaction, no metadata + TnTransactionMd = 3, // transaction, with metadata + TnAccountState = 4 }; class SHAMapTreeNode : public IntrusiveRefCounts @@ -147,7 +147,7 @@ public: getString(SHAMapNodeID const&) const; virtual void - invariants(bool is_root = false) const = 0; + invariants(bool isRoot = false) const = 0; static intr_ptr::SharedPtr makeFromPrefix(Slice rawNode, SHAMapHash const& hash); diff --git a/include/xrpl/shamap/SHAMapTxLeafNode.h b/include/xrpl/shamap/SHAMapTxLeafNode.h index 368aa2e21b..eaac104c7e 100644 --- a/include/xrpl/shamap/SHAMapTxLeafNode.h +++ b/include/xrpl/shamap/SHAMapTxLeafNode.h @@ -29,32 +29,32 @@ public: intr_ptr::SharedPtr clone(std::uint32_t cowid) const final { - return intr_ptr::make_shared(item_, cowid, hash_); + return intr_ptr::makeShared(item_, cowid, hash_); } SHAMapNodeType getType() const final { - return SHAMapNodeType::tnTRANSACTION_NM; + return SHAMapNodeType::TnTransactionNm; } void updateHash() final { - hash_ = SHAMapHash{sha512Half(HashPrefix::transactionID, item_->slice())}; + hash_ = SHAMapHash{sha512Half(HashPrefix::TransactionId, item_->slice())}; } void serializeForWire(Serializer& s) const final { s.addRaw(item_->slice()); - s.add8(wireTypeTransaction); + s.add8(kWIRE_TYPE_TRANSACTION); } void serializeWithPrefix(Serializer& s) const final { - s.add32(HashPrefix::transactionID); + s.add32(HashPrefix::TransactionId); s.addRaw(item_->slice()); } }; diff --git a/include/xrpl/shamap/SHAMapTxPlusMetaLeafNode.h b/include/xrpl/shamap/SHAMapTxPlusMetaLeafNode.h index 40be482ed9..5cf5b723b0 100644 --- a/include/xrpl/shamap/SHAMapTxPlusMetaLeafNode.h +++ b/include/xrpl/shamap/SHAMapTxPlusMetaLeafNode.h @@ -30,19 +30,19 @@ public: intr_ptr::SharedPtr clone(std::uint32_t cowid) const override { - return intr_ptr::make_shared(item_, cowid, hash_); + return intr_ptr::makeShared(item_, cowid, hash_); } SHAMapNodeType getType() const override { - return SHAMapNodeType::tnTRANSACTION_MD; + return SHAMapNodeType::TnTransactionMd; } void updateHash() final { - hash_ = SHAMapHash{sha512Half(HashPrefix::txNode, item_->slice(), item_->key())}; + hash_ = SHAMapHash{sha512Half(HashPrefix::TxNode, item_->slice(), item_->key())}; } void @@ -50,13 +50,13 @@ public: { s.addRaw(item_->slice()); s.addBitString(item_->key()); - s.add8(wireTypeTransactionWithMeta); + s.add8(kWIRE_TYPE_TRANSACTION_WITH_META); } void serializeWithPrefix(Serializer& s) const final { - s.add32(HashPrefix::txNode); + s.add32(HashPrefix::TxNode); s.addRaw(item_->slice()); s.addBitString(item_->key()); } diff --git a/include/xrpl/shamap/detail/TaggedPointer.h b/include/xrpl/shamap/detail/TaggedPointer.h index 31d5f2ba65..d3c0a6542f 100644 --- a/include/xrpl/shamap/detail/TaggedPointer.h +++ b/include/xrpl/shamap/detail/TaggedPointer.h @@ -47,9 +47,9 @@ private: */ std::uintptr_t tp_ = 0; /** bit-and with this mask to get the tag bits (lowest two bits) */ - static constexpr std::uintptr_t tagMask = 3; + static constexpr std::uintptr_t kTAG_MASK = 3; /** bit-and with this mask to get the pointer bits (mask out the tag) */ - static constexpr std::uintptr_t ptrMask = ~tagMask; + static constexpr std::uintptr_t kPTR_MASK = ~kTAG_MASK; /** Deallocate memory and run destructors */ void diff --git a/include/xrpl/shamap/detail/TaggedPointer.ipp b/include/xrpl/shamap/detail/TaggedPointer.ipp index 903108ac66..d4b5ca3365 100644 --- a/include/xrpl/shamap/detail/TaggedPointer.ipp +++ b/include/xrpl/shamap/detail/TaggedPointer.ipp @@ -4,6 +4,7 @@ #include +#include #include namespace xrpl { @@ -13,131 +14,130 @@ namespace { // Given n children, an array of size `*std::lower_bound(boundaries.begin(), // boundaries.end(), n);` is used to store the children. Note that the last // element must be the number of children in a dense array. -constexpr std::array boundaries{2, 4, 6, SHAMapInnerNode::branchFactor}; +constexpr std::array kBOUNDARIES{2, 4, 6, SHAMapInnerNode::kBRANCH_FACTOR}; static_assert( - boundaries.size() <= 4, + kBOUNDARIES.size() <= 4, "The hashesAndChildren member uses a tagged array format with two bits " "reserved for the tag. This supports at most 4 values."); static_assert( - boundaries.back() == SHAMapInnerNode::branchFactor, + kBOUNDARIES.back() == SHAMapInnerNode::kBRANCH_FACTOR, "Last element of boundaries must be number of children in a dense array"); // Terminology: A chunk is the memory being allocated from a block. A block // contains multiple chunks. This is the terminology the boost documentation // uses. Pools use "Simple Segregated Storage" as their storage format. -constexpr size_t elementSizeBytes = +constexpr size_t kELEMENT_SIZE_BYTES = (sizeof(SHAMapHash) + sizeof(intr_ptr::SharedPtr)); -constexpr size_t blockSizeBytes = kilobytes(512); +constexpr size_t kBLOCK_SIZE_BYTES = kilobytes(512); template -constexpr std::array +constexpr std::array initArrayChunkSizeBytes(std::index_sequence) { - return std::array{ - boundaries[I] * elementSizeBytes..., + return std::array{ + kBOUNDARIES[I] * kELEMENT_SIZE_BYTES..., }; } -constexpr auto arrayChunkSizeBytes = - initArrayChunkSizeBytes(std::make_index_sequence{}); +constexpr auto kARRAY_CHUNK_SIZE_BYTES = + initArrayChunkSizeBytes(std::make_index_sequence{}); template -constexpr std::array +constexpr std::array initArrayChunksPerBlock(std::index_sequence) { - return std::array{ - blockSizeBytes / arrayChunkSizeBytes[I]..., + return std::array{ + kBLOCK_SIZE_BYTES / kARRAY_CHUNK_SIZE_BYTES[I]..., }; } -constexpr auto chunksPerBlock = - initArrayChunksPerBlock(std::make_index_sequence{}); +constexpr auto kCHUNKS_PER_BLOCK = + initArrayChunksPerBlock(std::make_index_sequence{}); [[nodiscard]] inline std::uint8_t numAllocatedChildren(std::uint8_t n) { - XRPL_ASSERT(n <= SHAMapInnerNode::branchFactor, "xrpl::numAllocatedChildren : valid input"); - return *std::lower_bound(boundaries.begin(), boundaries.end(), n); + XRPL_ASSERT(n <= SHAMapInnerNode::kBRANCH_FACTOR, "xrpl::numAllocatedChildren : valid input"); + return *std::ranges::lower_bound(kBOUNDARIES, n); } [[nodiscard]] inline std::size_t boundariesIndex(std::uint8_t numChildren) { XRPL_ASSERT( - numChildren <= SHAMapInnerNode::branchFactor, "xrpl::boundariesIndex : valid input"); - return std::distance( - boundaries.begin(), std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); + numChildren <= SHAMapInnerNode::kBRANCH_FACTOR, "xrpl::boundariesIndex : valid input"); + return std::distance(kBOUNDARIES.begin(), std::ranges::lower_bound(kBOUNDARIES, numChildren)); } template -std::array, boundaries.size()> +std::array, kBOUNDARIES.size()> initAllocateArrayFuns(std::index_sequence) { - return std::array, boundaries.size()>{ + return std::array, kBOUNDARIES.size()>{ boost::singleton_pool< boost::fast_pool_allocator_tag, - arrayChunkSizeBytes[I], + kARRAY_CHUNK_SIZE_BYTES[I], boost::default_user_allocator_new_delete, std::mutex, - chunksPerBlock[I], - chunksPerBlock[I]>::malloc..., + kCHUNKS_PER_BLOCK[I], + kCHUNKS_PER_BLOCK[I]>::malloc..., }; } -std::array, boundaries.size()> const allocateArrayFuns = - initAllocateArrayFuns(std::make_index_sequence{}); +std::array, kBOUNDARIES.size()> const kALLOCATE_ARRAY_FUNS = + initAllocateArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> +std::array, kBOUNDARIES.size()> initFreeArrayFuns(std::index_sequence) { - return std::array, boundaries.size()>{ + return std::array, kBOUNDARIES.size()>{ static_cast(boost::singleton_pool< boost::fast_pool_allocator_tag, - arrayChunkSizeBytes[I], + kARRAY_CHUNK_SIZE_BYTES[I], boost::default_user_allocator_new_delete, std::mutex, - chunksPerBlock[I], - chunksPerBlock[I]>::free)..., + kCHUNKS_PER_BLOCK[I], + kCHUNKS_PER_BLOCK[I]>::free)..., }; } -std::array, boundaries.size()> const freeArrayFuns = - initFreeArrayFuns(std::make_index_sequence{}); +std::array, kBOUNDARIES.size()> const kFREE_ARRAY_FUNS = + initFreeArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> +std::array, kBOUNDARIES.size()> initIsFromArrayFuns(std::index_sequence) { - return std::array, boundaries.size()>{ + return std::array, kBOUNDARIES.size()>{ boost::singleton_pool< boost::fast_pool_allocator_tag, - arrayChunkSizeBytes[I], + kARRAY_CHUNK_SIZE_BYTES[I], boost::default_user_allocator_new_delete, std::mutex, - chunksPerBlock[I], - chunksPerBlock[I]>::is_from..., + kCHUNKS_PER_BLOCK[I], + kCHUNKS_PER_BLOCK[I]>::is_from..., }; } -std::array, boundaries.size()> const isFromArrayFuns = - initIsFromArrayFuns(std::make_index_sequence{}); +std::array, kBOUNDARIES.size()> const kIS_FROM_ARRAY_FUNS = + initIsFromArrayFuns(std::make_index_sequence{}); // This function returns an untagged pointer [[nodiscard]] inline std::pair allocateArrays(std::uint8_t numChildren) { auto const i = boundariesIndex(numChildren); - return {i, allocateArrayFuns[i]()}; + return {i, kALLOCATE_ARRAY_FUNS[i]()}; } // This function takes an untagged pointer inline void deallocateArrays(std::uint8_t boundaryIndex, void* p) { - XRPL_ASSERT(isFromArrayFuns[boundaryIndex](p), "xrpl::deallocateArrays : valid inputs"); - freeArrayFuns[boundaryIndex](p); + XRPL_ASSERT(kIS_FROM_ARRAY_FUNS[boundaryIndex](p), "xrpl::deallocateArrays : valid inputs"); + kFREE_ARRAY_FUNS[boundaryIndex](p); } // Used in `iterChildren` and elsewhere as the hash value for sparse arrays when // the hash isn't actually stored in the array. -static SHAMapHash const zeroSHAMapHash; +SHAMapHash const kZERO_SHA_MAP_HASH; } // namespace @@ -146,17 +146,17 @@ void TaggedPointer::iterChildren(std::uint16_t isBranch, F&& f) const { auto [numAllocated, hashes, _] = getHashesAndChildren(); - if (numAllocated == SHAMapInnerNode::branchFactor) + if (numAllocated == SHAMapInnerNode::kBRANCH_FACTOR) { // dense case - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) f(hashes[i]); } else { // sparse case int curHashI = 0; - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { if ((1 << i) & isBranch) { @@ -164,7 +164,7 @@ TaggedPointer::iterChildren(std::uint16_t isBranch, F&& f) const } else { - f(zeroSHAMapHash); + f(kZERO_SHA_MAP_HASH); } } } @@ -174,10 +174,10 @@ template void TaggedPointer::iterNonEmptyChildIndexes(std::uint16_t isBranch, F&& f) const { - if (capacity() == SHAMapInnerNode::branchFactor) + if (capacity() == SHAMapInnerNode::kBRANCH_FACTOR) { // dense case - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { if ((1 << i) & isBranch) { @@ -189,7 +189,7 @@ TaggedPointer::iterNonEmptyChildIndexes(std::uint16_t isBranch, F&& f) const { // sparse case int curHashI = 0; - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { if ((1 << i) & isBranch) { @@ -200,9 +200,10 @@ TaggedPointer::iterNonEmptyChildIndexes(std::uint16_t isBranch, F&& f) const } inline void +// NOLINTNEXTLINE(readability-make-member-function-const) TaggedPointer::destroyHashesAndChildren() { - if (!tp_) + if (tp_ == 0u) return; auto [numAllocated, hashes, children] = getHashesAndChildren(); @@ -246,11 +247,11 @@ inline TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t numChildren) { auto [tag, p] = allocateArrays(numChildren); XRPL_ASSERT( - tag < boundaries.size(), + tag < kBOUNDARIES.size(), "xrpl::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " "maximum tag"); XRPL_ASSERT( - (reinterpret_cast(p) & ptrMask) == reinterpret_cast(p), + (reinterpret_cast(p) & kPTR_MASK) == reinterpret_cast(p), "xrpl::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " "valid pointer"); tp_ = reinterpret_cast(p) + tag; @@ -274,11 +275,11 @@ inline TaggedPointer::TaggedPointer( auto [srcDstNumAllocated, srcDstHashes, srcDstChildren] = getHashesAndChildren(); bool const srcDstIsDense = isDense(); int srcDstIndex = 0; - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { auto const mask = (1 << i); - bool const inSrc = (srcBranches & mask); - bool const inDst = (dstBranches & mask); + bool const inSrc = (srcBranches & mask) != 0; + bool const inDst = (dstBranches & mask) != 0; if (inSrc && inDst) { // keep @@ -348,16 +349,16 @@ inline TaggedPointer::TaggedPointer( auto [dstNumAllocated, dstHashes, dstChildren] = dst.getHashesAndChildren(); // Move `other` into a local var so it's not in a partially moved from // state after this function runs - TaggedPointer src(std::move(other)); + TaggedPointer const src(std::move(other)); auto [srcNumAllocated, srcHashes, srcChildren] = src.getHashesAndChildren(); bool const srcIsDense = src.isDense(); bool const dstIsDense = dst.isDense(); int srcIndex = 0, dstIndex = 0; - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { auto const mask = (1 << i); - bool const inSrc = (srcBranches & mask); - bool const inDst = (dstBranches & mask); + bool const inSrc = (srcBranches & mask) != 0; + bool const inDst = (dstBranches & mask) != 0; if (inSrc && inDst) { // keep @@ -432,14 +433,14 @@ inline TaggedPointer::TaggedPointer( // allocate hashes and children, but do not run constructors TaggedPointer newHashesAndChildren{RawAllocateTag{}, toAllocate}; - SHAMapHash *newHashes, *oldHashes; - intr_ptr::SharedPtr*newChildren, *oldChildren; - std::uint8_t newNumAllocated; + SHAMapHash *newHashes = nullptr, *oldHashes = nullptr; + intr_ptr::SharedPtr*newChildren = nullptr, *oldChildren = nullptr; + std::uint8_t newNumAllocated = 0; // structured bindings can't be captured in c++ 17; use tie instead std::tie(newNumAllocated, newHashes, newChildren) = newHashesAndChildren.getHashesAndChildren(); std::tie(std::ignore, oldHashes, oldChildren) = getHashesAndChildren(); - if (newNumAllocated == SHAMapInnerNode::branchFactor) + if (newNumAllocated == SHAMapInnerNode::kBRANCH_FACTOR) { // new arrays are dense, old arrays are sparse iterNonEmptyChildIndexes(isBranch, [&](auto branchNum, auto indexNum) { @@ -448,9 +449,9 @@ inline TaggedPointer::TaggedPointer( intr_ptr::SharedPtr{std::move(oldChildren[indexNum])}; }); // Run the constructors for the remaining elements - for (int i = 0; i < SHAMapInnerNode::branchFactor; ++i) + for (int i = 0; i < SHAMapInnerNode::kBRANCH_FACTOR; ++i) { - if ((1 << i) & isBranch) + if (((1 << i) & isBranch) != 0) continue; new (&newHashes[i]) SHAMapHash{}; new (&newChildren[i]) intr_ptr::SharedPtr{}; @@ -507,19 +508,19 @@ TaggedPointer::operator=(TaggedPointer&& other) [[nodiscard]] inline std::pair TaggedPointer::decode() const { - return {tp_ & tagMask, reinterpret_cast(tp_ & ptrMask)}; + return {tp_ & kTAG_MASK, reinterpret_cast(tp_ & kPTR_MASK)}; } [[nodiscard]] inline std::uint8_t TaggedPointer::capacity() const { - return boundaries[tp_ & tagMask]; + return kBOUNDARIES[tp_ & kTAG_MASK]; } [[nodiscard]] inline bool TaggedPointer::isDense() const { - return (tp_ & tagMask) == boundaries.size() - 1; + return (tp_ & kTAG_MASK) == kBOUNDARIES.size() - 1; } [[nodiscard]] inline std::tuple*> @@ -527,7 +528,7 @@ TaggedPointer::getHashesAndChildren() const { auto const [tag, ptr] = decode(); auto const hashes = reinterpret_cast(ptr); - std::uint8_t numAllocated = boundaries[tag]; + std::uint8_t const numAllocated = kBOUNDARIES[tag]; auto const children = reinterpret_cast*>(hashes + numAllocated); return {numAllocated, hashes, children}; @@ -536,7 +537,7 @@ TaggedPointer::getHashesAndChildren() const [[nodiscard]] inline SHAMapHash* TaggedPointer::getHashes() const { - return reinterpret_cast(tp_ & ptrMask); + return reinterpret_cast(tp_ & kPTR_MASK); }; [[nodiscard]] inline intr_ptr::SharedPtr* diff --git a/include/xrpl/tx/ApplyContext.h b/include/xrpl/tx/ApplyContext.h index ea936017e0..910ec6be42 100644 --- a/include/xrpl/tx/ApplyContext.h +++ b/include/xrpl/tx/ApplyContext.h @@ -34,7 +34,7 @@ public: beast::Journal journal = beast::Journal{beast::Journal::getNullSink()}) : ApplyContext(registry, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal) { - XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set"); + XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set"); } std::reference_wrapper registry; diff --git a/include/xrpl/tx/Transactor.h b/include/xrpl/tx/Transactor.h index 918bbe5da6..cf8030b275 100644 --- a/include/xrpl/tx/Transactor.h +++ b/include/xrpl/tx/Transactor.h @@ -23,31 +23,31 @@ public: beast::Journal const j; PreflightContext( - ServiceRegistry& registry_, - STTx const& tx_, - uint256 parentBatchId_, - Rules rules_, - ApplyFlags flags_, - beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : registry(registry_) - , tx(tx_) - , rules(std::move(rules_)) - , flags(flags_) - , parentBatchId(parentBatchId_) - , j(j_) + ServiceRegistry& registry, + STTx const& tx, + uint256 parentBatchId, + Rules rules, + ApplyFlags flags, + beast::Journal j = beast::Journal{beast::Journal::getNullSink()}) + : registry(registry) + , tx(tx) + , rules(std::move(rules)) + , flags(flags) + , parentBatchId(parentBatchId) + , j(j) { - XRPL_ASSERT((flags_ & tapBATCH) == tapBATCH, "Batch apply flag should be set"); + XRPL_ASSERT((flags & TapBatch) == TapBatch, "Batch apply flag should be set"); } PreflightContext( - ServiceRegistry& registry_, - STTx const& tx_, - Rules rules_, - ApplyFlags flags_, - beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : registry(registry_), tx(tx_), rules(std::move(rules_)), flags(flags_), j(j_) + ServiceRegistry& registry, + STTx const& tx, + Rules rules, + ApplyFlags flags, + beast::Journal j = beast::Journal{beast::Journal::getNullSink()}) + : registry(registry), tx(tx), rules(std::move(rules)), flags(flags), j(j) { - XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set"); + XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set"); } PreflightContext& @@ -67,36 +67,36 @@ public: beast::Journal const j; PreclaimContext( - ServiceRegistry& registry_, - ReadView const& view_, - TER preflightResult_, - STTx const& tx_, - ApplyFlags flags_, - std::optional parentBatchId_, - beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : registry(registry_) - , view(view_) - , preflightResult(preflightResult_) - , flags(flags_) - , tx(tx_) - , parentBatchId(parentBatchId_) - , j(j_) + ServiceRegistry& registry, + ReadView const& view, + TER preflightResult, + STTx const& tx, + ApplyFlags flags, + std::optional parentBatchId, + beast::Journal j = beast::Journal{beast::Journal::getNullSink()}) + : registry(registry) + , view(view) + , preflightResult(preflightResult) + , flags(flags) + , tx(tx) + , parentBatchId(parentBatchId) + , j(j) { XRPL_ASSERT( - parentBatchId.has_value() == ((flags_ & tapBATCH) == tapBATCH), + parentBatchId.has_value() == ((flags & TapBatch) == TapBatch), "Parent Batch ID should be set if batch apply flag is set"); } PreclaimContext( - ServiceRegistry& registry_, - ReadView const& view_, - TER preflightResult_, - STTx const& tx_, - ApplyFlags flags_, - beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : PreclaimContext(registry_, view_, preflightResult_, tx_, flags_, std::nullopt, j_) + ServiceRegistry& registry, + ReadView const& view, + TER preflightResult, + STTx const& tx, + ApplyFlags flags, + beast::Journal j = beast::Journal{beast::Journal::getNullSink()}) + : PreclaimContext(registry, view, preflightResult, tx, flags, std::nullopt, j) { - XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set"); + XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set"); } PreclaimContext& diff --git a/include/xrpl/tx/applySteps.h b/include/xrpl/tx/applySteps.h index dc4140956c..897cf500d6 100644 --- a/include/xrpl/tx/applySteps.h +++ b/include/xrpl/tx/applySteps.h @@ -27,7 +27,7 @@ struct ApplyResult inline bool isTecClaimHardFail(TER ter, ApplyFlags flags) { - return isTecClaim(ter) && ((flags & tapRETRY) == 0u); + return isTecClaim(ter) && ((flags & TapRetry) == 0u); } /** Class describing the consequences to the account @@ -41,10 +41,10 @@ public: /// transactions enum class Category { /// Moves currency around, creates offers, etc. - normal = 0, + Normal = 0, /// Affects the ability of subsequent transactions /// to claim a fee. Eg. `SetRegularKey` - blocker + Blocker }; private: @@ -160,13 +160,13 @@ public: /// Constructor template - PreflightResult(Context const& ctx_, std::pair const& result) - : tx(ctx_.tx) - , parentBatchId(ctx_.parentBatchId) - , rules(ctx_.rules) + PreflightResult(Context const& ctx, std::pair const& result) + : tx(ctx.tx) + , parentBatchId(ctx.parentBatchId) + , rules(ctx.rules) , consequences(result.second) - , flags(ctx_.flags) - , j(ctx_.j) + , flags(ctx.flags) + , j(ctx.j) , ter(result.first) { } @@ -206,13 +206,13 @@ public: /// Constructor template - PreclaimResult(Context const& ctx_, TER ter_) - : view(ctx_.view) - , tx(ctx_.tx) - , parentBatchId(ctx_.parentBatchId) - , flags(ctx_.flags) - , j(ctx_.j) - , ter(ter_) + PreclaimResult(Context const& ctx, TER ter) + : view(ctx.view) + , tx(ctx.tx) + , parentBatchId(ctx.parentBatchId) + , flags(ctx.flags) + , j(ctx.j) + , ter(ter) , likelyToClaimFee(isTesSuccess(ter) || isTecClaimHardFail(ter, flags)) { } diff --git a/include/xrpl/tx/invariants/InvariantCheck.h b/include/xrpl/tx/invariants/InvariantCheck.h index 028a110acd..bc9608fd56 100644 --- a/include/xrpl/tx/invariants/InvariantCheck.h +++ b/include/xrpl/tx/invariants/InvariantCheck.h @@ -321,8 +321,8 @@ public: */ class ValidClawback { - std::uint32_t trustlinesChanged = 0; - std::uint32_t mptokensChanged = 0; + std::uint32_t trustlinesChanged_ = 0; + std::uint32_t mptokensChanged_ = 0; public: void diff --git a/include/xrpl/tx/invariants/InvariantCheckPrivilege.h b/include/xrpl/tx/invariants/InvariantCheckPrivilege.h index 44131167b6..5f76a43759 100644 --- a/include/xrpl/tx/invariants/InvariantCheckPrivilege.h +++ b/include/xrpl/tx/invariants/InvariantCheckPrivilege.h @@ -28,33 +28,33 @@ so that bad code gets caught and fixed as early as possible. // Bitwise flags, 86 files // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum Privilege { - noPriv = 0x0000, // The transaction can not do any of the enumerated operations - createAcct = 0x0001, // The transaction can create a new ACCOUNT_ROOT object. - createPseudoAcct = 0x0002, // The transaction can create a pseudo account, + NoPriv = 0x0000, // The transaction can not do any of the enumerated operations + CreateAcct = 0x0001, // The transaction can create a new ACCOUNT_ROOT object. + CreatePseudoAcct = 0x0002, // The transaction can create a pseudo account, // which implies createAcct - mustDeleteAcct = 0x0004, // The transaction must delete an ACCOUNT_ROOT object - mayDeleteAcct = 0x0008, // The transaction may delete an ACCOUNT_ROOT + MustDeleteAcct = 0x0004, // The transaction must delete an ACCOUNT_ROOT object + MayDeleteAcct = 0x0008, // The transaction may delete an ACCOUNT_ROOT // object, but does not have to - overrideFreeze = 0x0010, // The transaction can override some freeze rules - changeNFTCounts = 0x0020, // The transaction can mint or burn an NFT - createMPTIssuance = 0x0040, // The transaction can create a new MPT issuance - destroyMPTIssuance = 0x0080, // The transaction can destroy an MPT issuance - mustAuthorizeMPT = 0x0100, // The transaction MUST create or delete an MPT + OverrideFreeze = 0x0010, // The transaction can override some freeze rules + ChangeNftCounts = 0x0020, // The transaction can mint or burn an NFT + CreateMptIssuance = 0x0040, // The transaction can create a new MPT issuance + DestroyMptIssuance = 0x0080, // The transaction can destroy an MPT issuance + MustAuthorizeMpt = 0x0100, // The transaction MUST create or delete an MPT // object (except by issuer) - mayAuthorizeMPT = 0x0200, // The transaction MAY create or delete an MPT + MayAuthorizeMpt = 0x0200, // The transaction MAY create or delete an MPT // object (except by issuer) - mayDeleteMPT = 0x0400, // The transaction MAY delete an MPT object. May not create. - mustModifyVault = 0x0800, // The transaction must modify, delete or create, a vault - mayModifyVault = 0x1000, // The transaction MAY modify, delete or create, a vault - mayCreateMPT = 0x2000, // The transaction MAY create an MPT object, except for issuer. + MayDeleteMpt = 0x0400, // The transaction MAY delete an MPT object. May not create. + MustModifyVault = 0x0800, // The transaction must modify, delete or create, a vault + MayModifyVault = 0x1000, // The transaction MAY modify, delete or create, a vault + MayCreateMpt = 0x2000, // The transaction MAY create an MPT object, except for issuer. }; constexpr Privilege operator|(Privilege lhs, Privilege rhs) { - return safe_cast( - safe_cast>(lhs) | - safe_cast>(rhs)); + return safeCast( + safeCast>(lhs) | + safeCast>(rhs)); } bool diff --git a/include/xrpl/tx/invariants/NFTInvariant.h b/include/xrpl/tx/invariants/NFTInvariant.h index 527b0e8097..fa056ecbb0 100644 --- a/include/xrpl/tx/invariants/NFTInvariant.h +++ b/include/xrpl/tx/invariants/NFTInvariant.h @@ -54,10 +54,10 @@ public: */ class NFTokenCountTracking { - std::uint32_t beforeMintedTotal = 0; - std::uint32_t beforeBurnedTotal = 0; - std::uint32_t afterMintedTotal = 0; - std::uint32_t afterBurnedTotal = 0; + std::uint32_t beforeMintedTotal_ = 0; + std::uint32_t beforeBurnedTotal_ = 0; + std::uint32_t afterMintedTotal_ = 0; + std::uint32_t afterBurnedTotal_ = 0; public: void diff --git a/include/xrpl/tx/invariants/PermissionedDomainInvariant.h b/include/xrpl/tx/invariants/PermissionedDomainInvariant.h index f6c902ecb2..2475ed8f6b 100644 --- a/include/xrpl/tx/invariants/PermissionedDomainInvariant.h +++ b/include/xrpl/tx/invariants/PermissionedDomainInvariant.h @@ -23,10 +23,10 @@ class ValidPermissionedDomain { struct SleStatus { - std::size_t credentialsSize_{0}; - bool isSorted_ = false; - bool isUnique_ = false; - bool isDelete_ = false; + std::size_t credentialsSize{0}; + bool isSorted = false; + bool isUnique = false; + bool isDelete = false; }; std::vector sleStatus_; diff --git a/include/xrpl/tx/invariants/VaultInvariant.h b/include/xrpl/tx/invariants/VaultInvariant.h index b9b3bf746f..7ca67f546d 100644 --- a/include/xrpl/tx/invariants/VaultInvariant.h +++ b/include/xrpl/tx/invariants/VaultInvariant.h @@ -35,15 +35,15 @@ namespace xrpl { */ class ValidVault { - Number static constexpr zero{}; + Number static constexpr kZERO{}; struct Vault final { - uint256 key = beast::zero; + uint256 key = beast::kZERO; Asset asset; AccountID pseudoId; AccountID owner; - uint192 shareMPTID = beast::zero; + uint192 shareMPTID = beast::kZERO; Number assetsTotal = 0; Number assetsAvailable = 0; Number assetsMaximum = 0; @@ -64,7 +64,7 @@ class ValidVault public: struct DeltaInfo final { - Number delta = numZero; + Number delta = kNUM_ZERO; std::optional scale; // Compute the delta between two Numbers, taking the coarsest scale diff --git a/include/xrpl/tx/paths/AMMLiquidity.h b/include/xrpl/tx/paths/AMMLiquidity.h index d7a62dce65..3211d0caa7 100644 --- a/include/xrpl/tx/paths/AMMLiquidity.h +++ b/include/xrpl/tx/paths/AMMLiquidity.h @@ -31,7 +31,7 @@ template class AMMLiquidity { private: - inline static Number const InitialFibSeqPct = Number(5) / 20000; + inline static Number const kINITIAL_FIB_SEQ_PCT = Number(5) / 20000; AMMContext& ammContext_; AccountID const ammAccountID_; std::uint32_t const tradingFee_; diff --git a/include/xrpl/tx/paths/AMMOffer.h b/include/xrpl/tx/paths/AMMOffer.h index bdffec5ab9..21c45c36a3 100644 --- a/include/xrpl/tx/paths/AMMOffer.h +++ b/include/xrpl/tx/paths/AMMOffer.h @@ -75,7 +75,7 @@ public: consume(ApplyView& view, TAmounts const& consumed); [[nodiscard]] bool - fully_consumed() const + fullyConsumed() const { return consumed_; } diff --git a/include/xrpl/tx/paths/BookTip.h b/include/xrpl/tx/paths/BookTip.h index 2d7490d144..e06a2da86c 100644 --- a/include/xrpl/tx/paths/BookTip.h +++ b/include/xrpl/tx/paths/BookTip.h @@ -16,13 +16,13 @@ class BookTip { private: ApplyView& view_; - bool m_valid{false}; - uint256 m_book; - uint256 m_end; - uint256 m_dir; - uint256 m_index; - std::shared_ptr m_entry; - Quality m_quality{}; + bool valid_{false}; + uint256 book_; + uint256 end_; + uint256 dir_; + uint256 index_; + std::shared_ptr entry_; + Quality quality_{}; public: /** Create the iterator. */ @@ -31,25 +31,25 @@ public: [[nodiscard]] uint256 const& dir() const noexcept { - return m_dir; + return dir_; } [[nodiscard]] uint256 const& index() const noexcept { - return m_index; + return index_; } [[nodiscard]] Quality const& quality() const noexcept { - return m_quality; + return quality_; } [[nodiscard]] SLE::pointer const& entry() const noexcept { - return m_entry; + return entry_; } /** Erases the current offer and advance to the next offer. diff --git a/include/xrpl/tx/paths/Offer.h b/include/xrpl/tx/paths/Offer.h index 7e3eee0430..0a551f4c2d 100644 --- a/include/xrpl/tx/paths/Offer.h +++ b/include/xrpl/tx/paths/Offer.h @@ -19,13 +19,13 @@ template class TOffer { private: - SLE::pointer m_entry; - Quality m_quality{}; - AccountID m_account; + SLE::pointer entry_; + Quality quality_{}; + AccountID account_; Asset assetIn_; Asset assetOut_; - TAmounts m_amounts{}; + TAmounts amounts_{}; void setFieldAmounts(); @@ -46,14 +46,14 @@ public: [[nodiscard]] Quality quality() const noexcept { - return m_quality; + return quality_; } /** Returns the account id of the offer's owner. */ [[nodiscard]] AccountID const& owner() const { - return m_account; + return account_; } /** Returns the in and out amounts. @@ -62,16 +62,16 @@ public: [[nodiscard]] TAmounts const& amount() const { - return m_amounts; + return amounts_; } /** Returns `true` if no more funds can flow through this offer. */ [[nodiscard]] bool - fully_consumed() const + fullyConsumed() const { - if (m_amounts.in <= beast::zero) + if (amounts_.in <= beast::kZERO) return true; - if (m_amounts.out <= beast::zero) + if (amounts_.out <= beast::kZERO) return true; return false; } @@ -80,27 +80,27 @@ public: void consume(ApplyView& view, TAmounts const& consumed) { - if (consumed.in > m_amounts.in) + if (consumed.in > amounts_.in) Throw("can't consume more than is available."); - if (consumed.out > m_amounts.out) + if (consumed.out > amounts_.out) Throw("can't produce more than is available."); - m_amounts -= consumed; + amounts_ -= consumed; setFieldAmounts(); - view.update(m_entry); + view.update(entry_); } [[nodiscard]] std::string id() const { - return to_string(m_entry->key()); + return to_string(entry_->key()); } [[nodiscard]] std::optional key() const { - return m_entry->key(); + return entry_->key(); } [[nodiscard]] Asset const& @@ -122,7 +122,7 @@ public: isFunded() const { // Offer owner is issuer; they have unlimited funds if IOU - return m_account == assetOut_.getIssuer() && assetOut_.holds(); + return account_ == assetOut_.getIssuer() && assetOut_.holds(); } static std::pair @@ -141,13 +141,13 @@ public: if (!isFeatureEnabled(fixAMMv1_3)) return true; - if (consumed.in > m_amounts.in || consumed.out > m_amounts.out) + if (consumed.in > amounts_.in || consumed.out > amounts_.out) { // LCOV_EXCL_START JLOG(j.error()) << "AMMOffer::checkInvariant failed: consumed " << to_string(consumed.in) << " " << to_string(consumed.out) - << " amounts " << to_string(m_amounts.in) << " " - << to_string(m_amounts.out); + << " amounts " << to_string(amounts_.in) << " " + << to_string(amounts_.out); return false; // LCOV_EXCL_STOP @@ -159,12 +159,12 @@ public: template TOffer::TOffer(SLE::pointer entry, Quality quality) - : m_entry(std::move(entry)), m_quality(quality), m_account(m_entry->getAccountID(sfAccount)) + : entry_(std::move(entry)), quality_(quality), account_(entry_->getAccountID(sfAccount)) { - auto const tp = m_entry->getFieldAmount(sfTakerPays); - auto const tg = m_entry->getFieldAmount(sfTakerGets); - m_amounts.in = toAmount(tp); - m_amounts.out = toAmount(tg); + auto const tp = entry_->getFieldAmount(sfTakerPays); + auto const tg = entry_->getFieldAmount(sfTakerGets); + amounts_.in = toAmount(tp); + amounts_.out = toAmount(tg); assetIn_ = tp.asset(); assetOut_ = tg.asset(); } @@ -175,20 +175,20 @@ TOffer::setFieldAmounts() { if constexpr (std::is_same_v) { - m_entry->setFieldAmount(sfTakerPays, toSTAmount(m_amounts.in)); + entry_->setFieldAmount(sfTakerPays, toSTAmount(amounts_.in)); } else { - m_entry->setFieldAmount(sfTakerPays, toSTAmount(m_amounts.in, assetIn_)); + entry_->setFieldAmount(sfTakerPays, toSTAmount(amounts_.in, assetIn_)); } if constexpr (std::is_same_v) { - m_entry->setFieldAmount(sfTakerGets, toSTAmount(m_amounts.out)); + entry_->setFieldAmount(sfTakerGets, toSTAmount(amounts_.out)); } else { - m_entry->setFieldAmount(sfTakerGets, toSTAmount(m_amounts.out, assetOut_)); + entry_->setFieldAmount(sfTakerGets, toSTAmount(amounts_.out, assetOut_)); } } @@ -199,7 +199,7 @@ TOffer::limitOut(TAmounts const& offerAmount, TOut const& { // It turns out that the ceil_out implementation has some slop in // it, which ceil_out_strict removes. - return quality().ceil_out_strict(offerAmount, limit, roundUp); + return quality().ceilOutStrict(offerAmount, limit, roundUp); } template @@ -214,9 +214,9 @@ TOffer::limitIn(TAmounts const& offerAmount, TIn const& li // it. ceil_in_strict removes that slop. But removing that slop // affects transaction outcomes, so the change must be made using // an amendment. - return quality().ceil_in_strict(offerAmount, limit, roundUp); + return quality().ceilInStrict(offerAmount, limit, roundUp); } - return m_quality.ceil_in(offerAmount, limit); + return quality_.ceilIn(offerAmount, limit); } template diff --git a/include/xrpl/tx/paths/RippleCalc.h b/include/xrpl/tx/paths/RippleCalc.h index 771467cdc7..c747787820 100644 --- a/include/xrpl/tx/paths/RippleCalc.h +++ b/include/xrpl/tx/paths/RippleCalc.h @@ -102,7 +102,7 @@ public: // unfunded offers in a deterministic order (hence the ordered container). // // Offers that were found unfunded. - boost::container::flat_set permanentlyUnfundedOffers_; + boost::container::flat_set permanentlyUnfundedOffers; }; } // namespace path diff --git a/include/xrpl/tx/paths/detail/FlatSets.h b/include/xrpl/tx/paths/detail/FlatSets.h index a7546cc514..c0fc8fa417 100644 --- a/include/xrpl/tx/paths/detail/FlatSets.h +++ b/include/xrpl/tx/paths/detail/FlatSets.h @@ -12,7 +12,7 @@ namespace xrpl { */ template void -SetUnion(boost::container::flat_set& dst, boost::container::flat_set const& src) +setUnion(boost::container::flat_set& dst, boost::container::flat_set const& src) { if (src.empty()) return; diff --git a/include/xrpl/tx/paths/detail/FlowDebugInfo.h b/include/xrpl/tx/paths/detail/FlowDebugInfo.h index 36c0bd7de0..ec7df86e53 100644 --- a/include/xrpl/tx/paths/detail/FlowDebugInfo.h +++ b/include/xrpl/tx/paths/detail/FlowDebugInfo.h @@ -23,7 +23,7 @@ struct FlowDebugInfo struct PassInfo { PassInfo() = delete; - PassInfo(bool nativeIn_, bool nativeOut_) : nativeIn(nativeIn_), nativeOut(nativeOut_) + PassInfo(bool nativeIn, bool nativeOut) : nativeIn(nativeIn), nativeOut(nativeOut) { } bool const nativeIn; @@ -52,10 +52,10 @@ struct FlowDebugInfo } void - push_back(EitherAmount const& in_amt, EitherAmount const& out_amt, std::size_t active) + pushBack(EitherAmount const& inAmt, EitherAmount const& outAmt, std::size_t active) { - in.push_back(in_amt); - out.push_back(out_amt); + in.push_back(inAmt); + out.push_back(outAmt); numActive.push_back(active); } @@ -167,7 +167,7 @@ struct FlowDebugInfo void pushPass(EitherAmount const& in, EitherAmount const& out, std::size_t activeStrands) { - passInfo.push_back(in, out, activeStrands); + passInfo.pushBack(in, out, activeStrands); } void @@ -183,7 +183,7 @@ struct FlowDebugInfo } [[nodiscard]] std::string - to_string(bool writePassInfo) const + toString(bool writePassInfo) const { std::ostringstream ostr; @@ -193,7 +193,7 @@ struct FlowDebugInfo if (writePassInfo) { - auto write_list = [&ostr](auto const& vals, auto&& fun, char delim = ';') { + auto writeList = [&ostr](auto const& vals, auto&& fun, char delim = ';') { ostr << '['; if (!vals.empty()) { @@ -203,24 +203,24 @@ struct FlowDebugInfo } ostr << ']'; }; - auto writeXrpAmtList = [&write_list]( + auto writeXrpAmtList = [&writeList]( std::vector const& amts, char delim = ';') { - auto get_val = [](EitherAmount const& a) -> std::string { + auto getVal = [](EitherAmount const& a) -> std::string { return xrpl::to_string(a.get()); }; - write_list(amts, get_val, delim); + writeList(amts, getVal, delim); }; - auto writeIouAmtList = [&write_list]( + auto writeIouAmtList = [&writeList]( std::vector const& amts, char delim = ';') { - auto get_val = [](EitherAmount const& a) -> std::string { + auto getVal = [](EitherAmount const& a) -> std::string { return xrpl::to_string(a.get()); }; - write_list(amts, get_val, delim); + writeList(amts, getVal, delim); }; - auto writeIntList = [&write_list](std::vector const& vals, char delim = ';') { + auto writeIntList = [&writeList](std::vector const& vals, char delim = ';') { // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) - auto get_val = [](size_t const& v) -> size_t const& { return v; }; - write_list(vals, get_val); + auto getVal = [](size_t const& v) -> size_t const& { return v; }; + writeList(vals, getVal); }; auto writeNestedIouAmtList = [&ostr, &writeIouAmtList](std::vector> const& amts) { diff --git a/include/xrpl/tx/paths/detail/Steps.h b/include/xrpl/tx/paths/detail/Steps.h index 9b37f06ca9..db9d3a6f3a 100644 --- a/include/xrpl/tx/paths/detail/Steps.h +++ b/include/xrpl/tx/paths/detail/Steps.h @@ -18,21 +18,21 @@ class ReadView; class ApplyView; class AMMContext; -enum class DebtDirection { issues, redeems }; -enum class QualityDirection { in, out }; -enum class StrandDirection { forward, reverse }; -enum class OfferCrossing { no = 0, yes = 1, sell = 2 }; +enum class DebtDirection { Issues, Redeems }; +enum class QualityDirection { In, Out }; +enum class StrandDirection { Forward, Reverse }; +enum class OfferCrossing { No = 0, Yes = 1, Sell = 2 }; inline bool redeems(DebtDirection dir) { - return dir == DebtDirection::redeems; + return dir == DebtDirection::Redeems; } inline bool issues(DebtDirection dir) { - return dir == DebtDirection::issues; + return dir == DebtDirection::Issues; } /** @@ -460,7 +460,7 @@ public: [[nodiscard]] bool isZero(EitherAmount const& out) const override { - return get(out) == beast::zero; + return get(out) == beast::kZERO; } [[nodiscard]] bool @@ -547,24 +547,24 @@ struct StrandContext /** StrandContext constructor. */ StrandContext( - ReadView const& view_, - std::vector> const& strand_, + ReadView const& view, + std::vector> const& strand, // A strand may not include an inner node that // replicates the source or destination. - AccountID const& strandSrc_, - AccountID const& strandDst_, - Asset const& strandDeliver_, - std::optional const& limitQuality_, - bool isLast_, - bool ownerPaysTransferFee_, - OfferCrossing offerCrossing_, - bool isDefaultPath_, + AccountID const& strandSrc, + AccountID const& strandDst, + Asset const& strandDeliver, + std::optional const& limitQuality, + bool isLast, + bool ownerPaysTransferFee, + OfferCrossing offerCrossing, + bool isDefaultPath, std::array, 2>& - seenDirectAssets_, ///< For detecting currency loops - boost::container::flat_set& seenBookOuts_, ///< For detecting book loops - AMMContext& ammContext_, + seenDirectAssets, ///< For detecting currency loops + boost::container::flat_set& seenBookOuts, ///< For detecting book loops + AMMContext& ammContext, std::optional const& domainID, - beast::Journal j_); ///< Journal for logging + beast::Journal j); ///< Journal for logging }; /// @cond INTERNAL @@ -592,45 +592,45 @@ bookStepEqual(Step const& step, xrpl::Book const& book); } // namespace test std::pair> -make_DirectStepI( +makeDirectStepI( StrandContext const& ctx, AccountID const& src, AccountID const& dst, Currency const& c); std::pair> -make_MPTEndpointStep( +makeMptEndpointStep( StrandContext const& ctx, AccountID const& src, AccountID const& dst, MPTID const& a); std::pair> -make_BookStepII(StrandContext const& ctx, Issue const& in, Issue const& out); +makeBookStepIi(StrandContext const& ctx, Issue const& in, Issue const& out); std::pair> -make_BookStepIX(StrandContext const& ctx, Issue const& in); +makeBookStepIx(StrandContext const& ctx, Issue const& in); std::pair> -make_BookStepXI(StrandContext const& ctx, Issue const& out); +makeBookStepXi(StrandContext const& ctx, Issue const& out); std::pair> -make_XRPEndpointStep(StrandContext const& ctx, AccountID const& acc); +makeXrpEndpointStep(StrandContext const& ctx, AccountID const& acc); std::pair> -make_BookStepMM(StrandContext const& ctx, MPTIssue const& in, MPTIssue const& out); +makeBookStepMm(StrandContext const& ctx, MPTIssue const& in, MPTIssue const& out); std::pair> -make_BookStepMX(StrandContext const& ctx, MPTIssue const& in); +makeBookStepMx(StrandContext const& ctx, MPTIssue const& in); std::pair> -make_BookStepXM(StrandContext const& ctx, MPTIssue const& out); +makeBookStepXm(StrandContext const& ctx, MPTIssue const& out); std::pair> -make_BookStepMI(StrandContext const& ctx, MPTIssue const& in, Issue const& out); +makeBookStepMi(StrandContext const& ctx, MPTIssue const& in, Issue const& out); std::pair> -make_BookStepIM(StrandContext const& ctx, Issue const& in, MPTIssue const& out); +makeBookStepIm(StrandContext const& ctx, Issue const& in, MPTIssue const& out); template bool diff --git a/include/xrpl/tx/paths/detail/StrandFlow.h b/include/xrpl/tx/paths/detail/StrandFlow.h index 03ec9cc871..f69e10e99a 100644 --- a/include/xrpl/tx/paths/detail/StrandFlow.h +++ b/include/xrpl/tx/paths/detail/StrandFlow.h @@ -28,8 +28,8 @@ template struct StrandResult { bool success = false; ///< Strand succeeded - TInAmt in = beast::zero; ///< Currency amount in - TOutAmt out = beast::zero; ///< Currency amount out + TInAmt in = beast::kZERO; ///< Currency amount in + TOutAmt out = beast::kZERO; ///< Currency amount out std::optional sandbox; ///< Resulting Sandbox state boost::container::flat_set ofrsToRm; ///< Offers to remove // Num offers consumed or partially consumed (includes expired and unfunded @@ -45,23 +45,23 @@ struct StrandResult StrandResult( Strand const& strand, - TInAmt const& in_, - TOutAmt const& out_, - PaymentSandbox&& sandbox_, - boost::container::flat_set ofrsToRm_, - bool inactive_) + TInAmt const& in, + TOutAmt const& out, + PaymentSandbox&& sandbox, + boost::container::flat_set ofrsToRemoveMember, + bool inactive) : success(true) - , in(in_) - , out(out_) - , sandbox(std::move(sandbox_)) - , ofrsToRm(std::move(ofrsToRm_)) + , in(in) + , out(out) + , sandbox(std::move(sandbox)) + , ofrsToRm(std::move(ofrsToRemoveMember)) , ofrsUsed(offersUsed(strand)) - , inactive(inactive_) + , inactive(inactive) { } - StrandResult(Strand const& strand, boost::container::flat_set ofrsToRm_) - : ofrsToRm(std::move(ofrsToRm_)), ofrsUsed(offersUsed(strand)) + StrandResult(Strand const& strand, boost::container::flat_set ofrsToRemoveMember) + : ofrsToRm(std::move(ofrsToRemoveMember)), ofrsUsed(offersUsed(strand)) { } }; @@ -246,7 +246,8 @@ flow( // Re-executing the strand will change the cached values PaymentSandbox checkSB(&baseView); PaymentSandbox checkAfView(&baseView); - EitherAmount stepIn(*strand[0]->cachedIn()); + EitherAmount stepIn( + *strand[0]->cachedIn()); // NOLINT(bugprone-unchecked-optional-access) for (auto i = 0; i < s; ++i) { bool valid = false; @@ -283,8 +284,8 @@ flow( template struct FlowResult { - TInAmt in = beast::zero; - TOutAmt out = beast::zero; + TInAmt in = beast::kZERO; + TOutAmt out = beast::kZERO; std::optional sandbox; boost::container::flat_set removableOffers; TER ter = temUNKNOWN; @@ -292,29 +293,29 @@ struct FlowResult FlowResult() = default; FlowResult( - TInAmt const& in_, - TOutAmt const& out_, - PaymentSandbox&& sandbox_, + TInAmt const& in, + TOutAmt const& out, + PaymentSandbox&& sandbox, boost::container::flat_set ofrsToRm) - : in(in_) - , out(out_) - , sandbox(std::move(sandbox_)) + : in(in) + , out(out) + , sandbox(std::move(sandbox)) , removableOffers(std::move(ofrsToRm)) , ter(tesSUCCESS) { } - FlowResult(TER ter_, boost::container::flat_set ofrsToRm) - : removableOffers(std::move(ofrsToRm)), ter(ter_) + FlowResult(TER ter, boost::container::flat_set ofrsToRm) + : removableOffers(std::move(ofrsToRm)), ter(ter) { } FlowResult( - TER ter_, - TInAmt const& in_, - TOutAmt const& out_, + TER ter, + TInAmt const& in, + TOutAmt const& out, boost::container::flat_set ofrsToRm) - : in(in_), out(out_), removableOffers(std::move(ofrsToRm)), ter(ter_) + : in(in), out(out), removableOffers(std::move(ofrsToRm)), ter(ter) { } }; @@ -324,14 +325,14 @@ struct FlowResult inline std::optional qualityUpperBound(ReadView const& v, Strand const& strand) { - Quality q{STAmount::uRateOne}; + Quality q{STAmount::kU_RATE_ONE}; std::optional stepQ; - DebtDirection dir = DebtDirection::issues; + DebtDirection dir = DebtDirection::Issues; for (auto const& step : strand) { if (std::tie(stepQ, dir) = step->qualityUpperBound(v, dir); stepQ) { - q = composed_quality(q, *stepQ); + q = composedQuality(q, *stepQ); } else { @@ -361,7 +362,7 @@ limitOut( { std::optional stepQualityFunc; std::optional qf; - DebtDirection dir = DebtDirection::issues; + DebtDirection dir = DebtDirection::Issues; for (auto const& step : strand) { if (std::tie(stepQualityFunc, dir) = step->getQualityFunc(v, dir); stepQualityFunc) @@ -575,12 +576,12 @@ flow( Quality quality; BestStrand( - TInAmt const& in_, - TOutAmt const& out_, - PaymentSandbox&& sb_, - Strand const& strand_, - Quality const& quality_) - : in(in_), out(out_), sb(std::move(sb_)), strand(strand_), quality(quality_) + TInAmt const& in, + TOutAmt const& out, + PaymentSandbox&& sb, + Strand const& strand, + Quality const& quality) + : in(in), out(out), sb(std::move(sb)), strand(strand), quality(quality) { } }; @@ -594,9 +595,9 @@ flow( // values if `remainingIn` is initialized through a copy constructor. We can // get similar warnings for `sendMax` if it is initialized in the most // natural way. Using `make_optional`, allows us to work around this bug. - TInAmt const sendMaxInit = sendMaxST ? toAmount(*sendMaxST) : TInAmt{beast::zero}; + TInAmt const sendMaxInit = sendMaxST ? toAmount(*sendMaxST) : TInAmt{beast::kZERO}; std::optional const sendMax = - (sendMaxST && sendMaxInit >= beast::zero) ? std::make_optional(sendMaxInit) : std::nullopt; + (sendMaxST && sendMaxInit >= beast::kZERO) ? std::make_optional(sendMaxInit) : std::nullopt; std::optional remainingIn = !!sendMax ? std::make_optional(sendMaxInit) : std::nullopt; // std::optional remainingIn{sendMax}; @@ -618,7 +619,7 @@ flow( auto sum = [](auto const& col) { using TResult = std::decay_t; if (col.empty()) - return TResult{beast::zero}; + return TResult{beast::kZERO}; return std::accumulate(col.begin() + 1, col.end(), *col.begin()); }; @@ -626,7 +627,7 @@ flow( // successful boost::container::flat_set ofrsToRmOnFail; - while (remainingOut > beast::zero && (!remainingIn || *remainingIn > beast::zero)) + while (remainingOut > beast::kZERO && (!remainingIn || *remainingIn > beast::kZERO)) { ++curTry; if (curTry >= maxTries) @@ -665,7 +666,7 @@ flow( // the previous strand execution failed. It has to be reset // since this strand might not have AMM liquidity. ammContext.clear(); - if (offerCrossing != OfferCrossing::no && limitQuality) + if (offerCrossing != OfferCrossing::No && limitQuality) { auto const strandQ = qualityUpperBound(sb, *strand); if (!strandQ || *strandQ < *limitQuality) @@ -674,11 +675,11 @@ flow( auto f = flow(sb, *strand, remainingIn, limitRemainingOut, j); // rm bad offers even if the strand fails - SetUnion(ofrsToRm, f.ofrsToRm); + setUnion(ofrsToRm, f.ofrsToRm); offersConsidered += f.ofrsUsed; - if (!f.success || f.out == beast::zero) + if (!f.success || f.out == beast::kZERO) continue; if (flowDebugInfo) @@ -740,11 +741,10 @@ flow( JLOG(j.trace()) << "All strands dry."; } - best.reset(); // view in best must be destroyed before modifying base - // view + best.reset(); // view in best must be destroyed before modifying base view if (!ofrsToRm.empty()) { - SetUnion(ofrsToRmOnFail, ofrsToRm); + setUnion(ofrsToRmOnFail, ofrsToRm); for (auto const& o : ofrsToRm) { if (auto ok = sb.peek(keylet::offer(o))) @@ -779,35 +779,34 @@ flow( { if (actualOut > outReq) { - // Rounding in the payment engine is causing this assert to - // sometimes fire with "dust" amounts. This is causing issues when - // running debug builds of xrpld. While this issue still needs to - // be resolved, the assert is causing more harm than good at this - // point. + // Rounding in the payment engine is causing this assert to sometimes fire with "dust" + // amounts. This is causing issues when running debug builds of xrpld. + // While this issue still needs to be resolved, the assert is causing more harm than + // good at this point. // UNREACHABLE("xrpl::flow : rounding error"); return {tefEXCEPTION, std::move(ofrsToRmOnFail)}; } if (!partialPayment) { - // If we're offerCrossing a !partialPayment, then we're - // handling tfFillOrKill. + // If we're offerCrossing a !partialPayment, then we're handling tfFillOrKill. // Pre-fixFillOrKill amendment: // That case is handled below; not here. // fixFillOrKill amendment: - // That case is handled here if tfSell is also not set; i.e, - // case 1. - if (offerCrossing == OfferCrossing::no || - (fillOrKillEnabled && offerCrossing != OfferCrossing::sell)) + // That case is handled here if tfSell is also not set; i.e, case 1. + if (offerCrossing == OfferCrossing::No || + (fillOrKillEnabled && offerCrossing != OfferCrossing::Sell)) + { return {tecPATH_PARTIAL, actualIn, actualOut, std::move(ofrsToRmOnFail)}; + } } - else if (actualOut == beast::zero) + else if (actualOut == beast::kZERO) { return {tecPATH_DRY, std::move(ofrsToRmOnFail)}; } } - if (offerCrossing != OfferCrossing::no && - (!partialPayment && (!fillOrKillEnabled || offerCrossing == OfferCrossing::sell))) + if (offerCrossing != OfferCrossing::No && + (!partialPayment && (!fillOrKillEnabled || offerCrossing == OfferCrossing::Sell))) { // If we're offer crossing and partialPayment is *not* true, then // we're handling a FillOrKill offer. In this case remainingIn must @@ -817,7 +816,7 @@ flow( // fixFillOrKill amendment: // Handles 2. 1. is handled above and falls through for tfSell. XRPL_ASSERT(remainingIn, "xrpl::flow : nonzero remainingIn"); - if (remainingIn && *remainingIn != beast::zero) + if (remainingIn && *remainingIn != beast::kZERO) return {tecPATH_PARTIAL, actualIn, actualOut, std::move(ofrsToRmOnFail)}; } diff --git a/include/xrpl/tx/transactors/account/AccountDelete.h b/include/xrpl/tx/transactors/account/AccountDelete.h index 23fc55da48..1491ae09d9 100644 --- a/include/xrpl/tx/transactors/account/AccountDelete.h +++ b/include/xrpl/tx/transactors/account/AccountDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class AccountDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit AccountDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/account/AccountSet.h b/include/xrpl/tx/transactors/account/AccountSet.h index fd2106e20c..780ad846da 100644 --- a/include/xrpl/tx/transactors/account/AccountSet.h +++ b/include/xrpl/tx/transactors/account/AccountSet.h @@ -8,7 +8,7 @@ namespace xrpl { class AccountSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; explicit AccountSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/account/SetRegularKey.h b/include/xrpl/tx/transactors/account/SetRegularKey.h index 54e574939a..22a40714db 100644 --- a/include/xrpl/tx/transactors/account/SetRegularKey.h +++ b/include/xrpl/tx/transactors/account/SetRegularKey.h @@ -7,7 +7,7 @@ namespace xrpl { class SetRegularKey : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit SetRegularKey(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/account/SignerListSet.h b/include/xrpl/tx/transactors/account/SignerListSet.h index 12419076e3..16e7bf3a06 100644 --- a/include/xrpl/tx/transactors/account/SignerListSet.h +++ b/include/xrpl/tx/transactors/account/SignerListSet.h @@ -18,13 +18,13 @@ class SignerListSet : public Transactor { private: // Values determined during preCompute for use later. - enum class Operation { unknown, set, destroy }; - Operation do_{Operation::unknown}; + enum class Operation { Unknown, Set, Destroy }; + Operation do_{Operation::Unknown}; std::uint32_t quorum_{0}; std::vector signers_; public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit SignerListSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/bridge/XChainBridge.h b/include/xrpl/tx/transactors/bridge/XChainBridge.h index cd16c0b791..79755c0c2f 100644 --- a/include/xrpl/tx/transactors/bridge/XChainBridge.h +++ b/include/xrpl/tx/transactors/bridge/XChainBridge.h @@ -5,14 +5,14 @@ namespace xrpl { -constexpr size_t xbridgeMaxAccountCreateClaims = 128; +constexpr size_t kXBRIDGE_MAX_ACCOUNT_CREATE_CLAIMS = 128; // Attach a new bridge to a door account. Once this is done, the cross-chain // transfer transactions may be used to transfer funds from this account. class XChainCreateBridge : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit XChainCreateBridge(ApplyContext& ctx) : Transactor(ctx) { @@ -45,7 +45,7 @@ public: class BridgeModify : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit BridgeModify(ApplyContext& ctx) : Transactor(ctx) { @@ -95,7 +95,7 @@ class XChainClaim : public Transactor { public: // Blocker since we cannot accurately calculate the consequences - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit XChainClaim(ApplyContext& ctx) : Transactor(ctx) { @@ -133,7 +133,7 @@ public: class XChainCommit : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; static TxConsequences makeTxConsequences(PreflightContext const& ctx); @@ -179,7 +179,7 @@ public: class XChainCreateClaimID : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit XChainCreateClaimID(ApplyContext& ctx) : Transactor(ctx) { @@ -222,7 +222,7 @@ class XChainAddClaimAttestation : public Transactor { public: // Blocker since we cannot accurately calculate the consequences - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit XChainAddClaimAttestation(ApplyContext& ctx) : Transactor(ctx) { @@ -256,7 +256,7 @@ class XChainAddAccountCreateAttestation : public Transactor { public: // Blocker since we cannot accurately calculate the consequences - static constexpr ConsequencesFactoryType ConsequencesFactory{Blocker}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Blocker}; explicit XChainAddAccountCreateAttestation(ApplyContext& ctx) : Transactor(ctx) { @@ -314,7 +314,7 @@ public: class XChainCreateAccountCommit : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit XChainCreateAccountCommit(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/check/CheckCancel.h b/include/xrpl/tx/transactors/check/CheckCancel.h index 14abeaa978..4861a05a02 100644 --- a/include/xrpl/tx/transactors/check/CheckCancel.h +++ b/include/xrpl/tx/transactors/check/CheckCancel.h @@ -7,7 +7,7 @@ namespace xrpl { class CheckCancel : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CheckCancel(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/check/CheckCash.h b/include/xrpl/tx/transactors/check/CheckCash.h index 312c5a983e..c831cc279e 100644 --- a/include/xrpl/tx/transactors/check/CheckCash.h +++ b/include/xrpl/tx/transactors/check/CheckCash.h @@ -7,7 +7,7 @@ namespace xrpl { class CheckCash : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CheckCash(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/check/CheckCreate.h b/include/xrpl/tx/transactors/check/CheckCreate.h index ff24d36e2c..494870cb1c 100644 --- a/include/xrpl/tx/transactors/check/CheckCreate.h +++ b/include/xrpl/tx/transactors/check/CheckCreate.h @@ -7,7 +7,7 @@ namespace xrpl { class CheckCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CheckCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/credentials/CredentialAccept.h b/include/xrpl/tx/transactors/credentials/CredentialAccept.h index f3abc80666..0da5dd6131 100644 --- a/include/xrpl/tx/transactors/credentials/CredentialAccept.h +++ b/include/xrpl/tx/transactors/credentials/CredentialAccept.h @@ -7,7 +7,7 @@ namespace xrpl { class CredentialAccept : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CredentialAccept(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/credentials/CredentialCreate.h b/include/xrpl/tx/transactors/credentials/CredentialCreate.h index 22247feb36..d7a1a245df 100644 --- a/include/xrpl/tx/transactors/credentials/CredentialCreate.h +++ b/include/xrpl/tx/transactors/credentials/CredentialCreate.h @@ -7,7 +7,7 @@ namespace xrpl { class CredentialCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CredentialCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/credentials/CredentialDelete.h b/include/xrpl/tx/transactors/credentials/CredentialDelete.h index 91ea4d05ad..60de0957ca 100644 --- a/include/xrpl/tx/transactors/credentials/CredentialDelete.h +++ b/include/xrpl/tx/transactors/credentials/CredentialDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class CredentialDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit CredentialDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/delegate/DelegateSet.h b/include/xrpl/tx/transactors/delegate/DelegateSet.h index eaa22532ae..ee4bfeaaef 100644 --- a/include/xrpl/tx/transactors/delegate/DelegateSet.h +++ b/include/xrpl/tx/transactors/delegate/DelegateSet.h @@ -7,7 +7,7 @@ namespace xrpl { class DelegateSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit DelegateSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMBid.h b/include/xrpl/tx/transactors/dex/AMMBid.h index e872c0d12d..979ca0250d 100644 --- a/include/xrpl/tx/transactors/dex/AMMBid.h +++ b/include/xrpl/tx/transactors/dex/AMMBid.h @@ -45,7 +45,7 @@ namespace xrpl { class AMMBid : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMBid(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMClawback.h b/include/xrpl/tx/transactors/dex/AMMClawback.h index 4f44da60d2..3cf6288ccf 100644 --- a/include/xrpl/tx/transactors/dex/AMMClawback.h +++ b/include/xrpl/tx/transactors/dex/AMMClawback.h @@ -7,7 +7,7 @@ class Sandbox; class AMMClawback : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMClawback(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMContext.h b/include/xrpl/tx/transactors/dex/AMMContext.h index f582384e12..3d13547b52 100644 --- a/include/xrpl/tx/transactors/dex/AMMContext.h +++ b/include/xrpl/tx/transactors/dex/AMMContext.h @@ -18,7 +18,7 @@ public: // Restrict number of AMM offers. If this restriction is removed // then need to restrict in some other way because AMM offers are // not counted in the BookStep offer counter. - constexpr static std::uint8_t MaxIterations = 30; + constexpr static std::uint8_t kMAX_ITERATIONS = 30; private: // Tx account owner is required to get the AMM trading fee in BookStep @@ -68,7 +68,7 @@ public: [[nodiscard]] bool maxItersReached() const { - return ammIters_ >= MaxIterations; + return ammIters_ >= kMAX_ITERATIONS; } [[nodiscard]] std::uint16_t diff --git a/include/xrpl/tx/transactors/dex/AMMCreate.h b/include/xrpl/tx/transactors/dex/AMMCreate.h index a3ee083b9a..485273ca17 100644 --- a/include/xrpl/tx/transactors/dex/AMMCreate.h +++ b/include/xrpl/tx/transactors/dex/AMMCreate.h @@ -37,7 +37,7 @@ namespace xrpl { class AMMCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMDelete.h b/include/xrpl/tx/transactors/dex/AMMDelete.h index a1708eec88..1fbb4ec9e8 100644 --- a/include/xrpl/tx/transactors/dex/AMMDelete.h +++ b/include/xrpl/tx/transactors/dex/AMMDelete.h @@ -13,7 +13,7 @@ namespace xrpl { class AMMDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMDeposit.h b/include/xrpl/tx/transactors/dex/AMMDeposit.h index 87f2871d27..3847a2a529 100644 --- a/include/xrpl/tx/transactors/dex/AMMDeposit.h +++ b/include/xrpl/tx/transactors/dex/AMMDeposit.h @@ -42,7 +42,7 @@ class Sandbox; class AMMDeposit : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMDeposit(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMVote.h b/include/xrpl/tx/transactors/dex/AMMVote.h index f83cdcfcd2..c1fa059bd6 100644 --- a/include/xrpl/tx/transactors/dex/AMMVote.h +++ b/include/xrpl/tx/transactors/dex/AMMVote.h @@ -30,7 +30,7 @@ namespace xrpl { class AMMVote : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMVote(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/AMMWithdraw.h b/include/xrpl/tx/transactors/dex/AMMWithdraw.h index a07cfca693..cbaae78433 100644 --- a/include/xrpl/tx/transactors/dex/AMMWithdraw.h +++ b/include/xrpl/tx/transactors/dex/AMMWithdraw.h @@ -50,7 +50,7 @@ enum class WithdrawAll : bool { No = false, Yes }; class AMMWithdraw : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit AMMWithdraw(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/OfferCancel.h b/include/xrpl/tx/transactors/dex/OfferCancel.h index d18808d236..a8e408492e 100644 --- a/include/xrpl/tx/transactors/dex/OfferCancel.h +++ b/include/xrpl/tx/transactors/dex/OfferCancel.h @@ -8,7 +8,7 @@ namespace xrpl { class OfferCancel : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit OfferCancel(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/dex/OfferCreate.h b/include/xrpl/tx/transactors/dex/OfferCreate.h index 09c9c0dd6f..2c5e63705a 100644 --- a/include/xrpl/tx/transactors/dex/OfferCreate.h +++ b/include/xrpl/tx/transactors/dex/OfferCreate.h @@ -12,7 +12,7 @@ class Sandbox; class OfferCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; /** Construct a Transactor subclass that creates an offer in the ledger. */ explicit OfferCreate(ApplyContext& ctx) : Transactor(ctx) @@ -56,7 +56,7 @@ public: private: std::pair - applyGuts(Sandbox& view, Sandbox& view_cancel); + applyGuts(Sandbox& view, Sandbox& viewCancel); // Determine if we are authorized to hold the asset we want to get. static TER @@ -76,13 +76,13 @@ private: std::optional const& domainID); static std::string - format_amount(STAmount const& amount); + formatAmount(STAmount const& amount); TER applyHybrid( Sandbox& sb, std::shared_ptr sleOffer, - Keylet const& offer_index, + Keylet const& offerIndex, STAmount const& saTakerPays, STAmount const& saTakerGets, std::function)> const& setDir); diff --git a/include/xrpl/tx/transactors/did/DIDDelete.h b/include/xrpl/tx/transactors/did/DIDDelete.h index 47b4112762..2699307b39 100644 --- a/include/xrpl/tx/transactors/did/DIDDelete.h +++ b/include/xrpl/tx/transactors/did/DIDDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class DIDDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit DIDDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/did/DIDSet.h b/include/xrpl/tx/transactors/did/DIDSet.h index 2e88570065..fa07cfc295 100644 --- a/include/xrpl/tx/transactors/did/DIDSet.h +++ b/include/xrpl/tx/transactors/did/DIDSet.h @@ -7,7 +7,7 @@ namespace xrpl { class DIDSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit DIDSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/escrow/EscrowCancel.h b/include/xrpl/tx/transactors/escrow/EscrowCancel.h index 253d88613f..13270b6741 100644 --- a/include/xrpl/tx/transactors/escrow/EscrowCancel.h +++ b/include/xrpl/tx/transactors/escrow/EscrowCancel.h @@ -7,7 +7,7 @@ namespace xrpl { class EscrowCancel : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit EscrowCancel(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/escrow/EscrowCreate.h b/include/xrpl/tx/transactors/escrow/EscrowCreate.h index 3cbeb47fa1..4e809e3bf5 100644 --- a/include/xrpl/tx/transactors/escrow/EscrowCreate.h +++ b/include/xrpl/tx/transactors/escrow/EscrowCreate.h @@ -7,7 +7,7 @@ namespace xrpl { class EscrowCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; explicit EscrowCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/escrow/EscrowFinish.h b/include/xrpl/tx/transactors/escrow/EscrowFinish.h index 6279b3a9af..0fc6b46311 100644 --- a/include/xrpl/tx/transactors/escrow/EscrowFinish.h +++ b/include/xrpl/tx/transactors/escrow/EscrowFinish.h @@ -7,7 +7,7 @@ namespace xrpl { class EscrowFinish : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit EscrowFinish(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanBrokerCoverClawback.h b/include/xrpl/tx/transactors/lending/LoanBrokerCoverClawback.h index 9a028b6448..a774e23717 100644 --- a/include/xrpl/tx/transactors/lending/LoanBrokerCoverClawback.h +++ b/include/xrpl/tx/transactors/lending/LoanBrokerCoverClawback.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanBrokerCoverClawback : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanBrokerCoverClawback(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanBrokerCoverDeposit.h b/include/xrpl/tx/transactors/lending/LoanBrokerCoverDeposit.h index 9b0cd9b176..f69c47afbc 100644 --- a/include/xrpl/tx/transactors/lending/LoanBrokerCoverDeposit.h +++ b/include/xrpl/tx/transactors/lending/LoanBrokerCoverDeposit.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanBrokerCoverDeposit : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanBrokerCoverDeposit(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.h b/include/xrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.h index 74c35d5667..b70b0a758a 100644 --- a/include/xrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.h +++ b/include/xrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanBrokerCoverWithdraw : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanBrokerCoverWithdraw(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanBrokerDelete.h b/include/xrpl/tx/transactors/lending/LoanBrokerDelete.h index 3de0f6fec2..ca58fc75bd 100644 --- a/include/xrpl/tx/transactors/lending/LoanBrokerDelete.h +++ b/include/xrpl/tx/transactors/lending/LoanBrokerDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanBrokerDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanBrokerDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanBrokerSet.h b/include/xrpl/tx/transactors/lending/LoanBrokerSet.h index 519ccd6ce9..6c07740f9a 100644 --- a/include/xrpl/tx/transactors/lending/LoanBrokerSet.h +++ b/include/xrpl/tx/transactors/lending/LoanBrokerSet.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanBrokerSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanBrokerSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanDelete.h b/include/xrpl/tx/transactors/lending/LoanDelete.h index 5c6ec46d33..6f9d3ed5f0 100644 --- a/include/xrpl/tx/transactors/lending/LoanDelete.h +++ b/include/xrpl/tx/transactors/lending/LoanDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanManage.h b/include/xrpl/tx/transactors/lending/LoanManage.h index 98b7e38ba6..c01d25e428 100644 --- a/include/xrpl/tx/transactors/lending/LoanManage.h +++ b/include/xrpl/tx/transactors/lending/LoanManage.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanManage : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanManage(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanPay.h b/include/xrpl/tx/transactors/lending/LoanPay.h index 83271cf4e7..6c2aa0ec47 100644 --- a/include/xrpl/tx/transactors/lending/LoanPay.h +++ b/include/xrpl/tx/transactors/lending/LoanPay.h @@ -7,7 +7,7 @@ namespace xrpl { class LoanPay : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanPay(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/lending/LoanSet.h b/include/xrpl/tx/transactors/lending/LoanSet.h index 3ede5adc4c..e926c927fb 100644 --- a/include/xrpl/tx/transactors/lending/LoanSet.h +++ b/include/xrpl/tx/transactors/lending/LoanSet.h @@ -8,7 +8,7 @@ namespace xrpl { class LoanSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LoanSet(ApplyContext& ctx) : Transactor(ctx) { @@ -53,16 +53,16 @@ public: beast::Journal const& j) override; public: - static std::uint32_t constexpr minPaymentTotal = 1; - static std::uint32_t constexpr defaultPaymentTotal = 1; - static_assert(defaultPaymentTotal >= minPaymentTotal); + static std::uint32_t constexpr kMIN_PAYMENT_TOTAL = 1; + static std::uint32_t constexpr kDEFAULT_PAYMENT_TOTAL = 1; + static_assert(kDEFAULT_PAYMENT_TOTAL >= kMIN_PAYMENT_TOTAL); - static std::uint32_t constexpr minPaymentInterval = 60; - static std::uint32_t constexpr defaultPaymentInterval = 60; - static_assert(defaultPaymentInterval >= minPaymentInterval); + static std::uint32_t constexpr kMIN_PAYMENT_INTERVAL = 60; + static std::uint32_t constexpr kDEFAULT_PAYMENT_INTERVAL = 60; + static_assert(kDEFAULT_PAYMENT_INTERVAL >= kMIN_PAYMENT_INTERVAL); - static std::uint32_t constexpr defaultGracePeriod = 60; - static_assert(defaultGracePeriod >= minPaymentInterval); + static std::uint32_t constexpr kDEFAULT_GRACE_PERIOD = 60; + static_assert(kDEFAULT_GRACE_PERIOD >= kMIN_PAYMENT_INTERVAL); }; //------------------------------------------------------------------------------ diff --git a/include/xrpl/tx/transactors/nft/NFTokenAcceptOffer.h b/include/xrpl/tx/transactors/nft/NFTokenAcceptOffer.h index 7291db9a2e..7c77b02277 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenAcceptOffer.h +++ b/include/xrpl/tx/transactors/nft/NFTokenAcceptOffer.h @@ -20,7 +20,7 @@ private: transferNFToken(AccountID const& buyer, AccountID const& seller, uint256 const& nfTokenID); public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenAcceptOffer(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/nft/NFTokenBurn.h b/include/xrpl/tx/transactors/nft/NFTokenBurn.h index 2830b7c22a..075bcc59ce 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenBurn.h +++ b/include/xrpl/tx/transactors/nft/NFTokenBurn.h @@ -7,7 +7,7 @@ namespace xrpl { class NFTokenBurn : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenBurn(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/nft/NFTokenCancelOffer.h b/include/xrpl/tx/transactors/nft/NFTokenCancelOffer.h index 540258b8d6..f78c29dfe5 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenCancelOffer.h +++ b/include/xrpl/tx/transactors/nft/NFTokenCancelOffer.h @@ -7,7 +7,7 @@ namespace xrpl { class NFTokenCancelOffer : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenCancelOffer(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/nft/NFTokenCreateOffer.h b/include/xrpl/tx/transactors/nft/NFTokenCreateOffer.h index 532aa5c120..bdb76e1c44 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenCreateOffer.h +++ b/include/xrpl/tx/transactors/nft/NFTokenCreateOffer.h @@ -7,7 +7,7 @@ namespace xrpl { class NFTokenCreateOffer : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenCreateOffer(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/nft/NFTokenMint.h b/include/xrpl/tx/transactors/nft/NFTokenMint.h index 6dcf8eaf12..5274e1b4b8 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenMint.h +++ b/include/xrpl/tx/transactors/nft/NFTokenMint.h @@ -9,7 +9,7 @@ namespace xrpl { class NFTokenMint : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenMint(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/nft/NFTokenModify.h b/include/xrpl/tx/transactors/nft/NFTokenModify.h index a1076a96a9..6d3bac49f5 100644 --- a/include/xrpl/tx/transactors/nft/NFTokenModify.h +++ b/include/xrpl/tx/transactors/nft/NFTokenModify.h @@ -7,7 +7,7 @@ namespace xrpl { class NFTokenModify : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit NFTokenModify(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/oracle/OracleDelete.h b/include/xrpl/tx/transactors/oracle/OracleDelete.h index 5de69e980f..85ca9a2a88 100644 --- a/include/xrpl/tx/transactors/oracle/OracleDelete.h +++ b/include/xrpl/tx/transactors/oracle/OracleDelete.h @@ -16,7 +16,7 @@ namespace xrpl { class OracleDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit OracleDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/oracle/OracleSet.h b/include/xrpl/tx/transactors/oracle/OracleSet.h index 426f46c2b4..7bedf9c837 100644 --- a/include/xrpl/tx/transactors/oracle/OracleSet.h +++ b/include/xrpl/tx/transactors/oracle/OracleSet.h @@ -16,7 +16,7 @@ namespace xrpl { class OracleSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit OracleSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/payment/DepositPreauth.h b/include/xrpl/tx/transactors/payment/DepositPreauth.h index f74be24c56..365ba157a5 100644 --- a/include/xrpl/tx/transactors/payment/DepositPreauth.h +++ b/include/xrpl/tx/transactors/payment/DepositPreauth.h @@ -7,7 +7,7 @@ namespace xrpl { class DepositPreauth : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit DepositPreauth(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/payment/Payment.h b/include/xrpl/tx/transactors/payment/Payment.h index 3baf1fa55f..4ad870ce3f 100644 --- a/include/xrpl/tx/transactors/payment/Payment.h +++ b/include/xrpl/tx/transactors/payment/Payment.h @@ -7,13 +7,13 @@ namespace xrpl { class Payment : public Transactor { /* The largest number of paths we allow */ - static std::size_t const MaxPathSize = 6; + static std::size_t const kMAX_PATH_SIZE = 6; /* The longest path we allow */ - static std::size_t const MaxPathLength = 8; + static std::size_t const kMAX_PATH_LENGTH = 8; public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; explicit Payment(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/payment_channel/PaymentChannelClaim.h b/include/xrpl/tx/transactors/payment_channel/PaymentChannelClaim.h index 6e9a269b8d..d5e8235d31 100644 --- a/include/xrpl/tx/transactors/payment_channel/PaymentChannelClaim.h +++ b/include/xrpl/tx/transactors/payment_channel/PaymentChannelClaim.h @@ -7,7 +7,7 @@ namespace xrpl { class PaymentChannelClaim : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit PaymentChannelClaim(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/payment_channel/PaymentChannelCreate.h b/include/xrpl/tx/transactors/payment_channel/PaymentChannelCreate.h index cd0250713a..94a43ea165 100644 --- a/include/xrpl/tx/transactors/payment_channel/PaymentChannelCreate.h +++ b/include/xrpl/tx/transactors/payment_channel/PaymentChannelCreate.h @@ -7,7 +7,7 @@ namespace xrpl { class PaymentChannelCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; explicit PaymentChannelCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/payment_channel/PaymentChannelFund.h b/include/xrpl/tx/transactors/payment_channel/PaymentChannelFund.h index befe9ac951..3f16cf1ec1 100644 --- a/include/xrpl/tx/transactors/payment_channel/PaymentChannelFund.h +++ b/include/xrpl/tx/transactors/payment_channel/PaymentChannelFund.h @@ -7,7 +7,7 @@ namespace xrpl { class PaymentChannelFund : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; explicit PaymentChannelFund(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.h b/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.h index 93879c55b2..4aaff83a7a 100644 --- a/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.h +++ b/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class PermissionedDomainDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit PermissionedDomainDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h b/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h index 3187be08e1..820b36688c 100644 --- a/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h +++ b/include/xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h @@ -7,7 +7,7 @@ namespace xrpl { class PermissionedDomainSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit PermissionedDomainSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/system/Batch.h b/include/xrpl/tx/transactors/system/Batch.h index 1d9a66ec9a..b1af9a2f86 100644 --- a/include/xrpl/tx/transactors/system/Batch.h +++ b/include/xrpl/tx/transactors/system/Batch.h @@ -9,7 +9,7 @@ namespace xrpl { class Batch : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit Batch(ApplyContext& ctx) : Transactor(ctx) { @@ -47,7 +47,7 @@ public: ReadView const& view, beast::Journal const& j) override; - static constexpr auto disabledTxTypes = std::to_array({ + static constexpr auto kDISABLED_TX_TYPES = std::to_array({ ttVAULT_CREATE, ttVAULT_SET, ttVAULT_DELETE, diff --git a/include/xrpl/tx/transactors/system/Change.h b/include/xrpl/tx/transactors/system/Change.h index b966ef73ec..fc68fd55c2 100644 --- a/include/xrpl/tx/transactors/system/Change.h +++ b/include/xrpl/tx/transactors/system/Change.h @@ -7,7 +7,7 @@ namespace xrpl { class Change : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit Change(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/system/LedgerStateFix.h b/include/xrpl/tx/transactors/system/LedgerStateFix.h index da3cb33398..72ad8196c1 100644 --- a/include/xrpl/tx/transactors/system/LedgerStateFix.h +++ b/include/xrpl/tx/transactors/system/LedgerStateFix.h @@ -8,10 +8,10 @@ class LedgerStateFix : public Transactor { public: enum class FixType : std::uint16_t { - nfTokenPageLink = 1, + NfTokenPageLink = 1, }; - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit LedgerStateFix(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/system/TicketCreate.h b/include/xrpl/tx/transactors/system/TicketCreate.h index 13b6e7eca5..fc1743236f 100644 --- a/include/xrpl/tx/transactors/system/TicketCreate.h +++ b/include/xrpl/tx/transactors/system/TicketCreate.h @@ -7,9 +7,9 @@ namespace xrpl { class TicketCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Custom}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Custom}; - constexpr static std::uint32_t minValidCount = 1; + constexpr static std::uint32_t kMIN_VALID_COUNT = 1; // A note on how the maxValidCount was determined. The goal is for // a single TicketCreate transaction to not use more compute power than @@ -31,7 +31,7 @@ public: // about the same compute time as a single compute-intensive payment. // // October 2018. - constexpr static std::uint32_t maxValidCount = 250; + constexpr static std::uint32_t kMAX_VALID_COUNT = 250; // The maximum number of Tickets an account may hold. If a // TicketCreate would cause an account to own more than this many @@ -39,7 +39,7 @@ public: // // The number was chosen arbitrarily and is an effort toward avoiding // ledger-stuffing with Tickets. - constexpr static std::uint32_t maxTicketThreshold = 250; + constexpr static std::uint32_t kMAX_TICKET_THRESHOLD = 250; explicit TicketCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/Clawback.h b/include/xrpl/tx/transactors/token/Clawback.h index f7b77b872c..e21f98bd7a 100644 --- a/include/xrpl/tx/transactors/token/Clawback.h +++ b/include/xrpl/tx/transactors/token/Clawback.h @@ -7,7 +7,7 @@ namespace xrpl { class Clawback : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit Clawback(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/MPTokenAuthorize.h b/include/xrpl/tx/transactors/token/MPTokenAuthorize.h index 0cbc683e91..29cdda275a 100644 --- a/include/xrpl/tx/transactors/token/MPTokenAuthorize.h +++ b/include/xrpl/tx/transactors/token/MPTokenAuthorize.h @@ -16,7 +16,7 @@ struct MPTAuthorizeArgs class MPTokenAuthorize : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit MPTokenAuthorize(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h b/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h index 6718d28e4d..0107c11598 100644 --- a/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h +++ b/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h @@ -27,7 +27,7 @@ struct MPTCreateArgs class MPTokenIssuanceCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit MPTokenIssuanceCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h b/include/xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h index aaac508cf5..8e2a4c3dcd 100644 --- a/include/xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h +++ b/include/xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h @@ -7,7 +7,7 @@ namespace xrpl { class MPTokenIssuanceDestroy : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit MPTokenIssuanceDestroy(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/MPTokenIssuanceSet.h b/include/xrpl/tx/transactors/token/MPTokenIssuanceSet.h index 8dc423376a..e15027ab5e 100644 --- a/include/xrpl/tx/transactors/token/MPTokenIssuanceSet.h +++ b/include/xrpl/tx/transactors/token/MPTokenIssuanceSet.h @@ -7,7 +7,7 @@ namespace xrpl { class MPTokenIssuanceSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit MPTokenIssuanceSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/token/TrustSet.h b/include/xrpl/tx/transactors/token/TrustSet.h index cf4f042515..e99d599fe4 100644 --- a/include/xrpl/tx/transactors/token/TrustSet.h +++ b/include/xrpl/tx/transactors/token/TrustSet.h @@ -8,7 +8,7 @@ namespace xrpl { class TrustSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit TrustSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultClawback.h b/include/xrpl/tx/transactors/vault/VaultClawback.h index 9c69c88f75..4f0328aa4f 100644 --- a/include/xrpl/tx/transactors/vault/VaultClawback.h +++ b/include/xrpl/tx/transactors/vault/VaultClawback.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultClawback : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultClawback(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultCreate.h b/include/xrpl/tx/transactors/vault/VaultCreate.h index 6861c9d164..61b3e552cc 100644 --- a/include/xrpl/tx/transactors/vault/VaultCreate.h +++ b/include/xrpl/tx/transactors/vault/VaultCreate.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultCreate : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultCreate(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultDelete.h b/include/xrpl/tx/transactors/vault/VaultDelete.h index 33a86dd050..9a75fcebac 100644 --- a/include/xrpl/tx/transactors/vault/VaultDelete.h +++ b/include/xrpl/tx/transactors/vault/VaultDelete.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultDelete : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultDelete(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultDeposit.h b/include/xrpl/tx/transactors/vault/VaultDeposit.h index 5a0c63a3b1..21dc1749e2 100644 --- a/include/xrpl/tx/transactors/vault/VaultDeposit.h +++ b/include/xrpl/tx/transactors/vault/VaultDeposit.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultDeposit : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultDeposit(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultSet.h b/include/xrpl/tx/transactors/vault/VaultSet.h index 6abbe80fec..59a9639126 100644 --- a/include/xrpl/tx/transactors/vault/VaultSet.h +++ b/include/xrpl/tx/transactors/vault/VaultSet.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultSet : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultSet(ApplyContext& ctx) : Transactor(ctx) { diff --git a/include/xrpl/tx/transactors/vault/VaultWithdraw.h b/include/xrpl/tx/transactors/vault/VaultWithdraw.h index b8604d039e..f9b7665fd6 100644 --- a/include/xrpl/tx/transactors/vault/VaultWithdraw.h +++ b/include/xrpl/tx/transactors/vault/VaultWithdraw.h @@ -7,7 +7,7 @@ namespace xrpl { class VaultWithdraw : public Transactor { public: - static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + static constexpr ConsequencesFactoryType kCONSEQUENCES_FACTORY{Normal}; explicit VaultWithdraw(ApplyContext& ctx) : Transactor(ctx) { diff --git a/src/libxrpl/basics/BasicConfig.cpp b/src/libxrpl/basics/BasicConfig.cpp index 8fed7e5345..c1997eb713 100644 --- a/src/libxrpl/basics/BasicConfig.cpp +++ b/src/libxrpl/basics/BasicConfig.cpp @@ -28,7 +28,7 @@ void Section::append(std::vector const& lines) { // '=' - static boost::regex const re1( + static boost::regex const kRE1( "^" // start of line "(?:\\s*)" // whitespace (optional) "([a-zA-Z][_a-zA-Z0-9]*)" // @@ -43,8 +43,8 @@ Section::append(std::vector const& lines) lines_.reserve(lines_.size() + lines.size()); for (auto line : lines) { - auto remove_comment = [](std::string& val) -> bool { - bool removed_trailing = false; + auto removeComment = [](std::string& val) -> bool { + bool removedTrailing = false; auto comment = val.find('#'); while (comment != std::string::npos) { @@ -65,24 +65,24 @@ Section::append(std::vector const& lines) { // this must be a real comment. Extract the value // as a substring and stop looking. - val = trim_whitespace(val.substr(0, comment)); - removed_trailing = true; + val = trimWhitespace(val.substr(0, comment)); + removedTrailing = true; break; } comment = val.find('#', comment); } - return removed_trailing; + return removedTrailing; }; - if (remove_comment(line) && !line.empty()) - had_trailing_comments_ = true; + if (removeComment(line) && !line.empty()) + hadTrailingComments_ = true; if (line.empty()) continue; boost::smatch match; - if (boost::regex_match(line, match, re1)) + if (boost::regex_match(line, match, kRE1)) { set(match[1], match[2]); } @@ -126,10 +126,10 @@ BasicConfig::section(std::string const& name) Section const& BasicConfig::section(std::string const& name) const { - static Section const none(""); + static Section const kNONE(""); auto const iter = map_.find(name); if (iter == map_.end()) - return none; + return kNONE; return iter->second; } diff --git a/src/libxrpl/basics/CountedObject.cpp b/src/libxrpl/basics/CountedObject.cpp index 8eb6ca9dc2..1bf88687f8 100644 --- a/src/libxrpl/basics/CountedObject.cpp +++ b/src/libxrpl/basics/CountedObject.cpp @@ -7,12 +7,12 @@ namespace xrpl { CountedObjects& CountedObjects::getInstance() noexcept { - static CountedObjects instance; + static CountedObjects kINSTANCE; - return instance; + return kINSTANCE; } -CountedObjects::CountedObjects() noexcept : m_count(0), m_head(nullptr) +CountedObjects::CountedObjects() noexcept : count_(0), head_(nullptr) { } @@ -23,9 +23,9 @@ CountedObjects::getCounts(int minimumThreshold) const // When other operations are concurrent, the count // might be temporarily less than the actual count. - counts.reserve(m_count.load()); + counts.reserve(count_.load()); - for (auto* ctr = m_head.load(); ctr != nullptr; ctr = ctr->getNext()) + for (auto* ctr = head_.load(); ctr != nullptr; ctr = ctr->getNext()) { if (ctr->getCount() >= minimumThreshold) counts.emplace_back(ctr->getName(), ctr->getCount()); diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index eb93feaa3e..a629d865b8 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -42,14 +42,14 @@ Logs::Sink::writeAlways(beast::severities::Severity level, std::string const& te //------------------------------------------------------------------------------ -Logs::File::File() : m_stream(nullptr) +Logs::File::File() : stream_(nullptr) { } bool Logs::File::isOpen() const noexcept { - return m_stream != nullptr; + return stream_ != nullptr; } bool @@ -64,9 +64,9 @@ Logs::File::open(boost::filesystem::path const& path) if (stream->good()) { - m_path = path; + path_ = path; - m_stream = std::move(stream); + stream_ = std::move(stream); wasOpened = true; } @@ -79,29 +79,29 @@ Logs::File::closeAndReopen() { close(); - return open(m_path); + return open(path_); } void Logs::File::close() { - m_stream = nullptr; + stream_ = nullptr; } void Logs::File::write(char const* text) { - if (m_stream != nullptr) - (*m_stream) << text; + if (stream_ != nullptr) + (*stream_) << text; } void Logs::File::writeln(char const* text) { - if (m_stream != nullptr) + if (stream_ != nullptr) { - (*m_stream) << text; - (*m_stream) << std::endl; + (*stream_) << text; + (*stream_) << std::endl; } } @@ -153,7 +153,7 @@ Logs::threshold(beast::severities::Severity thresh) } std::vector> -Logs::partition_severities() const +Logs::partitionSeverities() const { std::vector> list; std::scoped_lock const lock(mutex_); @@ -203,27 +203,27 @@ Logs::fromSeverity(beast::severities::Severity level) using namespace beast::severities; switch (level) { - case kTrace: - return lsTRACE; - case kDebug: - return lsDEBUG; - case kInfo: - return lsINFO; - case kWarning: - return lsWARNING; - case kError: - return lsERROR; + case KTrace: + return LSTrace; + case KDebug: + return LSDebug; + case KInfo: + return LSInfo; + case KWarning: + return LSWarning; + case KError: + return LSError; // LCOV_EXCL_START default: UNREACHABLE("xrpl::Logs::fromSeverity : invalid severity"); [[fallthrough]]; // LCOV_EXCL_STOP - case kFatal: + case KFatal: break; } - return lsFATAL; + return LSFatal; } beast::severities::Severity @@ -232,26 +232,26 @@ Logs::toSeverity(LogSeverity level) using namespace beast::severities; switch (level) { - case lsTRACE: - return kTrace; - case lsDEBUG: - return kDebug; - case lsINFO: - return kInfo; - case lsWARNING: - return kWarning; - case lsERROR: - return kError; + case LSTrace: + return KTrace; + case LSDebug: + return KDebug; + case LSInfo: + return KInfo; + case LSWarning: + return KWarning; + case LSError: + return KError; // LCOV_EXCL_START default: UNREACHABLE("xrpl::Logs::toSeverity : invalid severity"); [[fallthrough]]; // LCOV_EXCL_STOP - case lsFATAL: + case LSFatal: break; } - return kFatal; + return KFatal; } std::string @@ -259,21 +259,21 @@ Logs::toString(LogSeverity s) { switch (s) { - case lsTRACE: + case LSTrace: return "Trace"; - case lsDEBUG: + case LSDebug: return "Debug"; - case lsINFO: + case LSInfo: return "Info"; - case lsWARNING: + case LSWarning: return "Warning"; - case lsERROR: + case LSError: return "Error"; - case lsFATAL: + case LSFatal: return "Fatal"; // LCOV_EXCL_START default: - UNREACHABLE("xrpl::Logs::toString : invalid severity"); + UNREACHABLE("xrpl::Logs::to_string : invalid severity"); return "Unknown"; // LCOV_EXCL_STOP } @@ -283,24 +283,24 @@ LogSeverity Logs::fromString(std::string const& s) { if (boost::iequals(s, "trace")) - return lsTRACE; + return LSTrace; if (boost::iequals(s, "debug")) - return lsDEBUG; + return LSDebug; if (boost::iequals(s, "info") || boost::iequals(s, "information")) - return lsINFO; + return LSInfo; if (boost::iequals(s, "warn") || boost::iequals(s, "warning") || boost::iequals(s, "warnings")) - return lsWARNING; + return LSWarning; if (boost::iequals(s, "error") || boost::iequals(s, "errors")) - return lsERROR; + return LSError; if (boost::iequals(s, "fatal") || boost::iequals(s, "fatals")) - return lsFATAL; + return LSFatal; - return lsINVALID; + return LSInvalid; } void @@ -312,7 +312,7 @@ Logs::format( { output.reserve(message.size() + partition.size() + 100); - output = to_string(std::chrono::system_clock::now()); + output = xrpl::to_string(std::chrono::system_clock::now()); output += " "; if (!partition.empty()) @@ -321,19 +321,19 @@ Logs::format( using namespace beast::severities; switch (severity) { - case kTrace: + case KTrace: output += "TRC "; break; - case kDebug: + case KDebug: output += "DBG "; break; - case kInfo: + case KInfo: output += "NFO "; break; - case kWarning: + case KWarning: output += "WRN "; break; - case kError: + case KError: output += "ERR "; break; // LCOV_EXCL_START @@ -341,7 +341,7 @@ Logs::format( UNREACHABLE("xrpl::Logs::format : invalid severity"); [[fallthrough]]; // LCOV_EXCL_STOP - case kFatal: + case KFatal: output += "FTL "; break; } @@ -349,9 +349,9 @@ Logs::format( output += message; // Limit the maximum length of the output - if (output.size() > maximumMessageCharacters) + if (output.size() > MaximumMessageCharacters) { - output.resize(maximumMessageCharacters - 3); + output.resize(MaximumMessageCharacters - 3); output += "..."; } @@ -394,7 +394,7 @@ class DebugSink private: std::reference_wrapper sink_; std::unique_ptr holder_; - std::mutex m_; + std::mutex mtx_; public: DebugSink() : sink_(beast::Journal::getNullSink()) @@ -412,7 +412,7 @@ public: std::unique_ptr set(std::unique_ptr sink) { - std::scoped_lock const _(m_); + std::scoped_lock const _(mtx_); using std::swap; swap(holder_, sink); @@ -432,7 +432,7 @@ public: beast::Journal::Sink& get() { - std::scoped_lock const _(m_); + std::scoped_lock const _(mtx_); return sink_.get(); } }; @@ -440,8 +440,8 @@ public: static DebugSink& debugSink() { - static DebugSink _; - return _; + static DebugSink kINST; + return kINST; } std::unique_ptr diff --git a/src/libxrpl/basics/MallocTrim.cpp b/src/libxrpl/basics/MallocTrim.cpp index 07b5b9ffc5..6fb9ab611b 100644 --- a/src/libxrpl/basics/MallocTrim.cpp +++ b/src/libxrpl/basics/MallocTrim.cpp @@ -86,7 +86,7 @@ mallocTrim(std::string_view tag, beast::Journal journal) // Keep glibc malloc_trim padding at 0 (default): 12h Mainnet tests across 0/256KB/1MB/16MB // showed no clear, consistent benefit from custom padding—0 provided the best overall balance // of RSS reduction and trim-latency stability without adding a tuning surface. - constexpr std::size_t TRIM_PAD = 0; + constexpr static std::size_t kTRIM_PAD = 0; report.supported = true; @@ -110,16 +110,16 @@ mallocTrim(std::string_view tag, beast::Journal journal) long const rssBeforeKB = detail::parseStatmRSSkB(statmBefore); struct rusage ru0{}; - bool const have_ru0 = getRusageThread(ru0); + bool const haveRu0 = getRusageThread(ru0); auto const t0 = std::chrono::steady_clock::now(); - report.trimResult = detail::mallocTrimWithPad(TRIM_PAD); + report.trimResult = detail::mallocTrimWithPad(kTRIM_PAD); auto const t1 = std::chrono::steady_clock::now(); struct rusage ru1{}; - bool const have_ru1 = getRusageThread(ru1); + bool const haveRu1 = getRusageThread(ru1); auto const statmAfter = readFile(statmPath); long const rssAfterKB = detail::parseStatmRSSkB(statmAfter); @@ -129,7 +129,7 @@ mallocTrim(std::string_view tag, beast::Journal journal) report.rssAfterKB = rssAfterKB; report.durationUs = std::chrono::duration_cast(t1 - t0); - if (have_ru0 && have_ru1) + if (haveRu0 && haveRu1) { report.minfltDelta = ru1.ru_minflt - ru0.ru_minflt; report.majfltDelta = ru1.ru_majflt - ru0.ru_majflt; @@ -140,7 +140,7 @@ mallocTrim(std::string_view tag, beast::Journal journal) : (static_cast(rssAfterKB) - static_cast(rssBeforeKB)); JLOG(journal.debug()) << "malloc_trim tag=" << tagStr << " result=" << report.trimResult - << " pad=" << TRIM_PAD << " bytes" + << " pad=" << kTRIM_PAD << " bytes" << " rss_before=" << rssBeforeKB << "kB" << " rss_after=" << rssAfterKB << "kB" << " delta=" << deltaKB << "kB" @@ -150,7 +150,7 @@ mallocTrim(std::string_view tag, beast::Journal journal) } else { - report.trimResult = detail::mallocTrimWithPad(TRIM_PAD); + report.trimResult = detail::mallocTrimWithPad(kTRIM_PAD); } #endif diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index ba444b77e0..08ead182bf 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -27,34 +27,34 @@ using int128_t = __int128_t; namespace xrpl { -thread_local Number::rounding_mode Number::mode_ = Number::rounding_mode::to_nearest; -thread_local std::reference_wrapper Number::range_ = largeRange; +thread_local Number::RoundingMode Number::mode = Number::RoundingMode::ToNearest; +thread_local std::reference_wrapper Number::kRANGE = kLARGE_RANGE; -Number::rounding_mode +Number::RoundingMode Number::getround() { - return mode_; + return mode; } -Number::rounding_mode -Number::setround(rounding_mode mode) +Number::RoundingMode +Number::setround(RoundingMode inMode) { - return std::exchange(mode_, mode); + return std::exchange(Number::mode, inMode); } -MantissaRange::mantissa_scale +MantissaRange::MantissaScale Number::getMantissaScale() { - return range_.get().scale; + return kRANGE.get().scale; } void -Number::setMantissaScale(MantissaRange::mantissa_scale scale) +Number::setMantissaScale(MantissaRange::MantissaScale scale) { - if (scale != MantissaRange::mantissa_scale::small && - scale != MantissaRange::mantissa_scale::large) - LogicError("Unknown mantissa scale"); - range_ = scale == MantissaRange::mantissa_scale::small ? smallRange : largeRange; + if (scale != MantissaRange::MantissaScale::Small && + scale != MantissaRange::MantissaScale::Large) + logicError("Unknown mantissa scale"); + kRANGE = scale == MantissaRange::MantissaScale::Small ? kSMALL_RANGE : kLARGE_RANGE; } // Guard @@ -77,11 +77,11 @@ public: // set & test the sign bit void - set_positive() noexcept; + setPositive() noexcept; void - set_negative() noexcept; + setNegative() noexcept; [[nodiscard]] bool - is_negative() const noexcept; + isNegative() const noexcept; // add a digit template @@ -128,19 +128,19 @@ private: }; inline void -Number::Guard::set_positive() noexcept +Number::Guard::setPositive() noexcept { sbit_ = 0; } inline void -Number::Guard::set_negative() noexcept +Number::Guard::setNegative() noexcept { sbit_ = 1; } inline bool -Number::Guard::is_negative() const noexcept +Number::Guard::isNegative() const noexcept { return sbit_ == 1; } @@ -177,10 +177,10 @@ Number::Guard::round() const noexcept { auto mode = Number::getround(); - if (mode == rounding_mode::towards_zero) + if (mode == RoundingMode::TowardsZero) return -1; - if (mode == rounding_mode::downward) + if (mode == RoundingMode::Downward) { if (sbit_) { @@ -190,7 +190,7 @@ Number::Guard::round() const noexcept return -1; } - if (mode == rounding_mode::upward) + if (mode == RoundingMode::Upward) { if (sbit_) return -1; @@ -224,13 +224,13 @@ Number::Guard::bringIntoRange( mantissa *= 10; --exponent; } - if (exponent < minExponent) + if (exponent < kMIN_EXPONENT) { - constexpr Number zero = Number{}; + constexpr Number kZERO = Number{}; - negative = zero.negative_; - mantissa = zero.mantissa_; - exponent = zero.exponent_; + negative = kZERO.negative_; + mantissa = kZERO.mantissa_; + exponent = kZERO.exponent_; } } @@ -250,14 +250,14 @@ Number::Guard::doRoundUp( ++mantissa; // Ensure mantissa after incrementing fits within both the // min/maxMantissa range and is a valid "rep". - if (mantissa > maxMantissa || mantissa > maxRep) + if (mantissa > maxMantissa || mantissa > kMAX_REP) { mantissa /= 10; ++exponent; } } bringIntoRange(negative, mantissa, exponent, minMantissa); - if (exponent > maxExponent) + if (exponent > kMAX_EXPONENT) Throw(std::string(location)); } @@ -289,7 +289,7 @@ Number::Guard::doRound(rep& drops, std::string location) const auto r = round(); if (r == 1 || (r == 0 && (drops & 1) == 1)) { - if (drops >= maxRep) + if (drops >= kMAX_REP) { static_assert(sizeof(internalrep) == sizeof(rep)); // This should be impossible, because it's impossible to represent @@ -302,7 +302,7 @@ Number::Guard::doRound(rep& drops, std::string location) const } ++drops; } - if (is_negative()) + if (isNegative()) drops = -drops; } @@ -334,26 +334,26 @@ Number::externalToInternal(rep mantissa) constexpr Number Number::oneSmall() { - return Number{false, Number::smallRange.min, -Number::smallRange.log, Number::unchecked{}}; + return Number{false, Number::kSMALL_RANGE.min, -Number::kSMALL_RANGE.log, Number::Unchecked{}}; }; -constexpr Number oneSml = Number::oneSmall(); +constexpr Number kONE_SML = Number::oneSmall(); constexpr Number Number::oneLarge() { - return Number{false, Number::largeRange.min, -Number::largeRange.log, Number::unchecked{}}; + return Number{false, Number::kLARGE_RANGE.min, -Number::kLARGE_RANGE.log, Number::Unchecked{}}; }; -constexpr Number oneLrg = Number::oneLarge(); +constexpr Number kONE_LRG = Number::oneLarge(); Number Number::one() { - if (&range_.get() == &smallRange) - return oneSml; - XRPL_ASSERT(&range_.get() == &largeRange, "Number::one() : valid range_"); - return oneLrg; + if (&kRANGE.get() == &kSMALL_RANGE) + return kONE_SML; + XRPL_ASSERT(&kRANGE.get() == &kLARGE_RANGE, "Number::one() : valid range"); + return kONE_LRG; } // Use the member names in this static function for now so the diff is cleaner @@ -362,47 +362,47 @@ template void doNormalize( bool& negative, - T& mantissa_, - int& exponent_, + T& mantissa, + int& exponent, MantissaRange::rep const& minMantissa, MantissaRange::rep const& maxMantissa) { - auto constexpr minExponent = Number::minExponent; - auto constexpr maxExponent = Number::maxExponent; - auto constexpr maxRep = Number::maxRep; + auto constexpr kMIN_EXPONENT = Number::kMIN_EXPONENT; + auto constexpr kMAX_EXPONENT = Number::kMAX_EXPONENT; + auto constexpr kMAX_REP = Number::kMAX_REP; using Guard = Number::Guard; - constexpr Number zero = Number{}; - if (mantissa_ == 0) + constexpr Number kZERO = Number{}; + if (mantissa == 0) { - mantissa_ = zero.mantissa_; - exponent_ = zero.exponent_; - negative = zero.negative_; + mantissa = kZERO.mantissa_; + exponent = kZERO.exponent_; + negative = kZERO.negative_; return; } - auto m = mantissa_; - while ((m < minMantissa) && (exponent_ > minExponent)) + auto m = mantissa; + while ((m < minMantissa) && (exponent > kMIN_EXPONENT)) { m *= 10; - --exponent_; + --exponent; } Guard g; if (negative) - g.set_negative(); + g.setNegative(); while (m > maxMantissa) { - if (exponent_ >= maxExponent) + if (exponent >= kMAX_EXPONENT) throw std::overflow_error("Number::normalize 1"); g.push(m % 10); m /= 10; - ++exponent_; + ++exponent; } - if ((exponent_ < minExponent) || (m < minMantissa)) + if ((exponent < kMIN_EXPONENT) || (m < minMantissa)) { - mantissa_ = zero.mantissa_; - exponent_ = zero.exponent_; - negative = zero.negative_; + mantissa = kZERO.mantissa_; + exponent = kZERO.exponent_; + negative = kZERO.negative_; return; } @@ -419,24 +419,24 @@ doNormalize( // 9,900,000,000,000,123,450 or 9,900,000,000,000,123,460. // mantissa() will return mantissa_ / 10, and exponent() will return // exponent_ + 1. - if (m > maxRep) + if (m > kMAX_REP) { - if (exponent_ >= maxExponent) + if (exponent >= kMAX_EXPONENT) throw std::overflow_error("Number::normalize 1.5"); g.push(m % 10); m /= 10; - ++exponent_; + ++exponent; } // Before modification, m should be within the min/max range. After // modification, it must be less than maxRep. In other words, the original // value should have been no more than maxRep * 10. // (maxRep * 10 > maxMantissa) - XRPL_ASSERT_PARTS(m <= maxRep, "xrpl::doNormalize", "intermediate mantissa fits in int64"); - mantissa_ = m; + XRPL_ASSERT_PARTS(m <= kMAX_REP, "xrpl::doNormalize", "intermediate mantissa fits in int64"); + mantissa = m; - g.doRoundUp(negative, mantissa_, exponent_, minMantissa, maxMantissa, "Number::normalize 2"); + g.doRoundUp(negative, mantissa, exponent, minMantissa, maxMantissa, "Number::normalize 2"); XRPL_ASSERT_PARTS( - mantissa_ >= minMantissa && mantissa_ <= maxMantissa, + mantissa >= minMantissa && mantissa <= maxMantissa, "xrpl::doNormalize", "final mantissa fits in range"); } @@ -480,7 +480,7 @@ Number::normalize( void Number::normalize() { - auto const& range = range_.get(); + auto const& range = kRANGE.get(); normalize(negative_, mantissa_, exponent_, range.min, range.max); } @@ -492,13 +492,13 @@ Number::shiftExponent(int exponentDelta) const { XRPL_ASSERT_PARTS(isnormal(), "xrpl::Number::shiftExponent", "normalized"); auto const newExponent = exponent_ + exponentDelta; - if (newExponent >= maxExponent) + if (newExponent >= kMAX_EXPONENT) throw std::overflow_error("Number::shiftExponent"); - if (newExponent < minExponent) + if (newExponent < kMIN_EXPONENT) { return Number{}; } - Number const result{negative_, mantissa_, newExponent, unchecked{}}; + Number const result{negative_, mantissa_, newExponent, Unchecked{}}; XRPL_ASSERT_PARTS(result.isnormal(), "xrpl::Number::shiftExponent", "result is normalized"); return result; } @@ -506,17 +506,17 @@ Number::shiftExponent(int exponentDelta) const Number& Number::operator+=(Number const& y) { - constexpr Number zero = Number{}; - if (y == zero) + constexpr Number kZERO = Number{}; + if (y == kZERO) return *this; - if (*this == zero) + if (*this == kZERO) { *this = y; return *this; } if (*this == -y) { - *this = zero; + *this = kZERO; return *this; } @@ -539,7 +539,7 @@ Number::operator+=(Number const& y) if (xe < ye) { if (xn) - g.set_negative(); + g.setNegative(); do { g.push(xm % 10); @@ -550,7 +550,7 @@ Number::operator+=(Number const& y) else if (xe > ye) { if (yn) - g.set_negative(); + g.setNegative(); do { g.push(ym % 10); @@ -559,14 +559,14 @@ Number::operator+=(Number const& y) } while (xe > ye); } - auto const& range = range_.get(); + auto const& range = kRANGE.get(); auto const& minMantissa = range.min; auto const& maxMantissa = range.max; if (xn == yn) { xm += ym; - if (xm > maxMantissa || xm > maxRep) + if (xm > maxMantissa || xm > kMAX_REP) { g.push(xm % 10); xm /= 10; @@ -586,7 +586,7 @@ Number::operator+=(Number const& y) xe = ye; xn = yn; } - while (xm < minMantissa && xm * 10 <= maxRep) + while (xm < minMantissa && xm * 10 <= kMAX_REP) { xm *= 10; xm -= g.pop(); @@ -633,10 +633,10 @@ divu10(uint128_t& u) Number& Number::operator*=(Number const& y) { - constexpr Number zero = Number{}; - if (*this == zero) + constexpr Number kZERO = Number{}; + if (*this == kZERO) return *this; - if (y == zero) + if (y == kZERO) { *this = y; return *this; @@ -662,13 +662,13 @@ Number::operator*=(Number const& y) bool zn = (zs == -1); Guard g; if (zn) - g.set_negative(); + g.setNegative(); - auto const& range = range_.get(); + auto const& range = kRANGE.get(); auto const& minMantissa = range.min; auto const& maxMantissa = range.max; - while (zm > maxMantissa || zm > maxRep) + while (zm > maxMantissa || zm > kMAX_REP) { // The following is optimization for: // g.push(static_cast(zm % 10)); @@ -696,10 +696,10 @@ Number::operator*=(Number const& y) Number& Number::operator/=(Number const& y) { - constexpr Number zero = Number{}; - if (y == zero) + constexpr Number kZERO = Number{}; + if (y == kZERO) throw std::overflow_error("Number: divide by 0"); - if (*this == zero) + if (*this == kZERO) return *this; // n* = numerator // d* = denominator @@ -718,7 +718,7 @@ Number::operator/=(Number const& y) auto dm = y.mantissa_; auto de = y.exponent_; - auto const& range = range_.get(); + auto const& range = kRANGE.get(); auto const& minMantissa = range.min; auto const& maxMantissa = range.max; @@ -728,9 +728,9 @@ Number::operator/=(Number const& y) // log(2^128,10) ~ 38.5 // largeRange.log = 18, fits in 10^19 // f can be up to 10^(38-19) = 10^19 safely - static_assert(smallRange.log == 15); - static_assert(largeRange.log == 18); - bool const small = Number::getMantissaScale() == MantissaRange::mantissa_scale::small; + static_assert(kSMALL_RANGE.log == 15); + static_assert(kLARGE_RANGE.log == 18); + bool const small = Number::getMantissaScale() == MantissaRange::MantissaScale::Small; uint128_t const f = small ? 100'000'000'000'000'000 : 10'000'000'000'000'000'000ULL; XRPL_ASSERT_PARTS(f >= minMantissa * 10, "Number::operator/=", "factor expected size"); @@ -798,7 +798,7 @@ operator rep() const { if (negative_) { - g.set_negative(); + g.setNegative(); drops = -drops; } for (; offset < 0; ++offset) @@ -808,7 +808,7 @@ operator rep() const } for (; offset > 0; --offset) { - if (drops > maxRep / 10) + if (drops > kMAX_REP / 10) throw std::overflow_error("Number::operator rep() overflow"); drops *= 10; } @@ -839,8 +839,8 @@ std::string to_string(Number const& amount) { // keep full internal accuracy, but make more human friendly if possible - constexpr Number zero = Number{}; - if (amount == zero) + constexpr Number kZERO = Number{}; + if (amount == kZERO) return "0"; auto exponent = amount.exponent_; @@ -851,7 +851,7 @@ to_string(Number const& amount) auto const rangeLog = Number::mantissaLog(); if (((exponent != 0) && ((exponent < -(rangeLog + 10)) || (exponent > -(rangeLog - 10))))) { - while (mantissa != 0 && mantissa % 10 == 0 && exponent < Number::maxExponent) + while (mantissa != 0 && mantissa % 10 == 0 && exponent < Number::kMAX_EXPONENT) { mantissa /= 10; ++exponent; @@ -865,46 +865,46 @@ to_string(Number const& amount) XRPL_ASSERT(exponent + 43 > 0, "xrpl::to_string(Number) : minimum exponent"); - ptrdiff_t const pad_prefix = rangeLog + 12; - ptrdiff_t const pad_suffix = rangeLog + 8; + ptrdiff_t const padPrefix = rangeLog + 12; + ptrdiff_t const padSuffix = rangeLog + 8; - std::string const raw_value(std::to_string(mantissa)); + std::string const rawValue(std::to_string(mantissa)); std::string val; - val.reserve(raw_value.length() + pad_prefix + pad_suffix); - val.append(pad_prefix, '0'); - val.append(raw_value); - val.append(pad_suffix, '0'); + val.reserve(rawValue.length() + padPrefix + padSuffix); + val.append(padPrefix, '0'); + val.append(rawValue); + val.append(padSuffix, '0'); - ptrdiff_t const offset(exponent + pad_prefix + rangeLog + 1); + ptrdiff_t const offset(exponent + padPrefix + rangeLog + 1); - auto pre_from(val.begin()); - auto const pre_to(val.begin() + offset); + auto preFrom(val.begin()); + auto const preTo(val.begin() + offset); - auto const post_from(val.begin() + offset); - auto post_to(val.end()); + auto const postFrom(val.begin() + offset); + auto postTo(val.end()); // Crop leading zeroes. Take advantage of the fact that there's always a // fixed amount of leading zeroes and skip them. - if (std::distance(pre_from, pre_to) > pad_prefix) - pre_from += pad_prefix; + if (std::distance(preFrom, preTo) > padPrefix) + preFrom += padPrefix; - XRPL_ASSERT(post_to >= post_from, "xrpl::to_string(Number) : first distance check"); + XRPL_ASSERT(postTo >= postFrom, "xrpl::to_string(Number) : first distance check"); - pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); + preFrom = std::find_if(preFrom, preTo, [](char c) { return c != '0'; }); // Crop trailing zeroes. Take advantage of the fact that there's always a // fixed amount of trailing zeroes and skip them. - if (std::distance(post_from, post_to) > pad_suffix) - post_to -= pad_suffix; + if (std::distance(postFrom, postTo) > padSuffix) + postTo -= padSuffix; - XRPL_ASSERT(post_to >= post_from, "xrpl::to_string(Number) : second distance check"); + XRPL_ASSERT(postTo >= postFrom, "xrpl::to_string(Number) : second distance check"); - post_to = std::find_if( - std::make_reverse_iterator(post_to), - std::make_reverse_iterator(post_from), - [](char c) { return c != '0'; }) - .base(); + postTo = std::find_if( + std::make_reverse_iterator(postTo), + std::make_reverse_iterator(postFrom), + [](char c) { return c != '0'; }) + .base(); std::string ret; @@ -912,19 +912,19 @@ to_string(Number const& amount) ret.append(1, '-'); // Assemble the output: - if (pre_from == pre_to) + if (preFrom == preTo) { ret.append(1, '0'); } else { - ret.append(pre_from, pre_to); + ret.append(preFrom, preTo); } - if (post_to != post_from) + if (postTo != postFrom) { ret.append(1, '.'); - ret.append(post_from, post_to); + ret.append(postFrom, postTo); } return ret; @@ -959,7 +959,7 @@ power(Number const& f, unsigned n) Number root(Number f, unsigned d) { - constexpr Number zero = Number{}; + constexpr Number kZERO = Number{}; auto const one = Number::one(); if (f == one || d == 1) @@ -969,12 +969,12 @@ root(Number f, unsigned d) if (f == -one) return one; if (abs(f) < one) - return zero; + return kZERO; throw std::overflow_error("Number::root infinity"); } - if (f < zero && d % 2 == 0) + if (f < kZERO && d % 2 == 0) throw std::overflow_error("Number::root nan"); - if (f == zero) + if (f == kZERO) return f; // Scale f into the range (0, 1) such that f's exponent is a multiple of d @@ -993,14 +993,14 @@ root(Number f, unsigned d) XRPL_ASSERT_PARTS(f.isnormal(), "xrpl::root(Number, unsigned)", "f is normalized"); bool neg = false; - if (f < zero) + if (f < kZERO) { neg = true; f = -f; } // Quadratic least squares curve fit of f^(1/d) in the range [0, 1] - auto const D = (((6 * di + 11) * di + 6) * di) + 1; + auto const D = (((6 * di + 11) * di + 6) * di) + 1; // NOLINT(readability-identifier-naming) auto const a0 = 3 * di * ((2 * di - 3) * di + 1); auto const a1 = 24 * di * (2 * di - 1); auto const a2 = -30 * (di - 1) * di; @@ -1031,14 +1031,14 @@ root(Number f, unsigned d) Number root2(Number f) { - constexpr Number zero = Number{}; + constexpr Number kZERO = Number{}; auto const one = Number::one(); if (f == one) return f; - if (f < zero) + if (f < kZERO) throw std::overflow_error("Number::root nan"); - if (f == zero) + if (f == kZERO) return f; // Scale f into the range (0, 1) such that f's exponent is a multiple of d @@ -1049,7 +1049,7 @@ root2(Number f) XRPL_ASSERT_PARTS(f.isnormal(), "xrpl::root2(Number)", "f is normalized"); // Quadratic least squares curve fit of f^(1/d) in the range [0, 1] - auto const D = 105; + auto const D = 105; // NOLINT(readability-identifier-naming) auto const a0 = 18; auto const a1 = 144; auto const a2 = -60; @@ -1078,7 +1078,7 @@ root2(Number f) Number power(Number const& f, unsigned n, unsigned d) { - constexpr Number zero = Number{}; + constexpr Number kZERO = Number{}; auto const one = Number::one(); if (f == one) @@ -1091,7 +1091,7 @@ power(Number const& f, unsigned n, unsigned d) if (f == -one) return one; if (abs(f) < one) - return zero; + return kZERO; // abs(f) > one throw std::overflow_error("Number::power infinity"); } @@ -1099,7 +1099,7 @@ power(Number const& f, unsigned n, unsigned d) return one; n /= g; d /= g; - if ((n % 2) == 1 && (d % 2) == 0 && f < zero) + if ((n % 2) == 1 && (d % 2) == 0 && f < kZERO) throw std::overflow_error("Number::power nan"); return root(power(f, n), d); } diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 0443aa3502..4e64c280c7 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -40,7 +40,7 @@ namespace xrpl { template class AsyncObject { - AsyncObject() : m_pending(0) + AsyncObject() : pending_(0) { } @@ -48,7 +48,7 @@ public: ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - XRPL_ASSERT(m_pending.load() == 0, "xrpl::AsyncObject::~AsyncObject : nothing pending"); + XRPL_ASSERT(pending_.load() == 0, "xrpl::AsyncObject::~AsyncObject : nothing pending"); } /** RAII container that maintains the count of pending I/O. @@ -58,45 +58,45 @@ public: class CompletionCounter { public: - explicit CompletionCounter(Derived* owner) : m_owner(owner) + explicit CompletionCounter(Derived* owner) : owner_(owner) { - ++m_owner->m_pending; + ++owner_->pending_; } - CompletionCounter(CompletionCounter const& other) : m_owner(other.m_owner) + CompletionCounter(CompletionCounter const& other) : owner_(other.owner_) { - ++m_owner->m_pending; + ++owner_->pending_; } ~CompletionCounter() { - if (--m_owner->m_pending == 0) - m_owner->asyncHandlersComplete(); + if (--owner_->pending_ == 0) + owner_->asyncHandlersComplete(); } CompletionCounter& operator=(CompletionCounter const&) = delete; private: - Derived* m_owner; + Derived* owner_; }; void addReference() { - ++m_pending; + ++pending_; } void removeReference() { - if (--m_pending == 0) + if (--pending_ == 0) (static_cast(this))->asyncHandlersComplete(); } private: // The number of handlers pending. - std::atomic m_pending; + std::atomic pending_; friend Derived; }; @@ -106,18 +106,18 @@ class ResolverAsioImpl : public ResolverAsio, public AsyncObject; - beast::Journal m_journal; + beast::Journal journal; - boost::asio::io_context& m_io_context; - boost::asio::strand m_strand; - boost::asio::ip::tcp::resolver m_resolver; + boost::asio::io_context& io_context; + boost::asio::strand strand; + boost::asio::ip::tcp::resolver resolver; - std::condition_variable m_cv; - std::mutex m_mut; - bool m_asyncHandlersCompleted{true}; + std::condition_variable cv; + std::mutex mut; + bool asyncHandlersCompleted{true}; - std::atomic m_stop_called; - std::atomic m_stopped; + std::atomic stop_called; + std::atomic stopped; // Represents a unit of work for the resolver to do struct Work @@ -126,30 +126,30 @@ public: HandlerType handler; template - Work(StringSequence const& names_, HandlerType handler_) : handler(std::move(handler_)) + Work(StringSequence const& inNames, HandlerType handler) : handler(std::move(handler)) { - names.reserve(names_.size()); + names.reserve(inNames.size()); - std::reverse_copy(names_.begin(), names_.end(), std::back_inserter(names)); + std::reverse_copy(inNames.begin(), inNames.end(), std::back_inserter(names)); } }; - std::deque m_work; + std::deque work; - ResolverAsioImpl(boost::asio::io_context& io_context, beast::Journal journal) - : m_journal(journal) - , m_io_context(io_context) - , m_strand(boost::asio::make_strand(io_context)) - , m_resolver(io_context) - , m_stop_called(false) - , m_stopped(true) + ResolverAsioImpl(boost::asio::io_context& ioContext, beast::Journal journal) + : journal(journal) + , io_context(ioContext) + , strand(boost::asio::make_strand(ioContext)) + , resolver(ioContext) + , stop_called(false) + , stopped(true) { } ~ResolverAsioImpl() override { - XRPL_ASSERT(m_work.empty(), "xrpl::ResolverAsioImpl::~ResolverAsioImpl : no pending work"); - XRPL_ASSERT(m_stopped, "xrpl::ResolverAsioImpl::~ResolverAsioImpl : stopped"); + XRPL_ASSERT(work.empty(), "xrpl::ResolverAsioImpl::~ResolverAsioImpl : no pending work"); + XRPL_ASSERT(stopped, "xrpl::ResolverAsioImpl::~ResolverAsioImpl : stopped"); } //------------------------------------------------------------------------- @@ -157,9 +157,9 @@ public: void asyncHandlersComplete() { - std::unique_lock const lk{m_mut}; - m_asyncHandlersCompleted = true; - m_cv.notify_all(); + std::unique_lock const lk{mut}; + asyncHandlersCompleted = true; + cv.notify_all(); } //-------------------------------------------------------------------------- @@ -171,80 +171,79 @@ public: void start() override { - XRPL_ASSERT(m_stopped == true, "xrpl::ResolverAsioImpl::start : stopped"); - XRPL_ASSERT(m_stop_called == false, "xrpl::ResolverAsioImpl::start : not stopping"); + XRPL_ASSERT(stopped == true, "xrpl::ResolverAsioImpl::start : stopped"); + XRPL_ASSERT(stop_called == false, "xrpl::ResolverAsioImpl::start : not stopping"); - if (m_stopped.exchange(false)) + if (stopped.exchange(false)) { { - std::scoped_lock const lk{m_mut}; - m_asyncHandlersCompleted = false; + std::scoped_lock const lk{mut}; + asyncHandlersCompleted = false; } addReference(); } } void - stop_async() override + stopAsync() override { - if (!m_stop_called.exchange(true)) + if (!stop_called.exchange(true)) { boost::asio::dispatch( - m_io_context, + io_context, boost::asio::bind_executor( - m_strand, - std::bind(&ResolverAsioImpl::do_stop, this, CompletionCounter(this)))); + strand, std::bind(&ResolverAsioImpl::doStop, this, CompletionCounter(this)))); - JLOG(m_journal.debug()) << "Queued a stop request"; + JLOG(journal.debug()) << "Queued a stop request"; } } void stop() override { - stop_async(); + stopAsync(); - JLOG(m_journal.debug()) << "Waiting to stop"; - std::unique_lock lk{m_mut}; - m_cv.wait(lk, [this] { return m_asyncHandlersCompleted; }); + JLOG(journal.debug()) << "Waiting to stop"; + std::unique_lock lk{mut}; + cv.wait(lk, [this] { return asyncHandlersCompleted; }); lk.unlock(); - JLOG(m_journal.debug()) << "Stopped"; + JLOG(journal.debug()) << "Stopped"; } void resolve(std::vector const& names, HandlerType const& handler) override { - XRPL_ASSERT(m_stop_called == false, "xrpl::ResolverAsioImpl::resolve : not stopping"); + XRPL_ASSERT(stop_called == false, "xrpl::ResolverAsioImpl::resolve : not stopping"); XRPL_ASSERT(!names.empty(), "xrpl::ResolverAsioImpl::resolve : names non-empty"); // TODO NIKB use rvalue references to construct and move // reducing cost. boost::asio::dispatch( - m_io_context, + io_context, boost::asio::bind_executor( - m_strand, + strand, std::bind( - &ResolverAsioImpl::do_resolve, this, names, handler, CompletionCounter(this)))); + &ResolverAsioImpl::doResolve, this, names, handler, CompletionCounter(this)))); } //------------------------------------------------------------------------- // Resolver void - do_stop(CompletionCounter) + doStop(CompletionCounter) { - XRPL_ASSERT(m_stop_called == true, "xrpl::ResolverAsioImpl::do_stop : stopping"); + XRPL_ASSERT(stop_called == true, "xrpl::ResolverAsioImpl::do_stop : stopping"); - if (!m_stopped.exchange(true)) + if (!stopped.exchange(true)) { - m_work.clear(); - m_resolver.cancel(); + work.clear(); + resolver.cancel(); removeReference(); } } void - do_finish( + doFinish( std::string name, boost::system::error_code const& ec, HandlerType handler, @@ -263,7 +262,7 @@ public: { while (iter != results.end()) { - addresses.push_back(beast::IPAddressConversion::from_asio(*iter)); + addresses.push_back(beast::IPAddressConversion::fromAsio(*iter)); ++iter; } } @@ -271,9 +270,9 @@ public: handler(name, addresses); boost::asio::post( - m_io_context, + io_context, boost::asio::bind_executor( - m_strand, std::bind(&ResolverAsioImpl::do_work, this, CompletionCounter(this)))); + strand, std::bind(&ResolverAsioImpl::doWork, this, CompletionCounter(this)))); } static HostAndPort @@ -282,7 +281,7 @@ public: // first attempt to parse as an endpoint (IP addr + port). // If that doesn't succeed, fall back to generic name + port parsing - if (auto const result = beast::IP::Endpoint::from_string_checked(str)) + if (auto const result = beast::IP::Endpoint::fromStringChecked(str)) { return make_pair(result->address().to_string(), std::to_string(result->port())); } @@ -292,20 +291,20 @@ public: // a port separator // Attempt to find the first and last non-whitespace - auto const find_whitespace = + auto const findWhitespace = std::bind(&std::isspace, std::placeholders::_1, std::locale()); - auto host_first = std::ranges::find_if_not(str, find_whitespace); + auto hostFirst = std::ranges::find_if_not(str, findWhitespace); - auto port_last = - std::ranges::find_if_not(std::ranges::reverse_view(str), find_whitespace).base(); + auto portLast = + std::ranges::find_if_not(std::ranges::reverse_view(str), findWhitespace).base(); // This should only happen for all-whitespace strings - if (host_first >= port_last) + if (hostFirst >= portLast) return std::make_pair(std::string(), std::string()); // Attempt to find the first and last valid port separators - auto const find_port_separator = [](char const c) -> bool { + auto const findPortSeparator = [](char const c) -> bool { if (std::isspace(static_cast(c))) return true; @@ -315,51 +314,50 @@ public: return false; }; - auto host_last = std::find_if(host_first, port_last, find_port_separator); + auto hostLast = std::find_if(hostFirst, portLast, findPortSeparator); - auto port_first = std::find_if_not(host_last, port_last, find_port_separator); + auto portFirst = std::find_if_not(hostLast, portLast, findPortSeparator); - return make_pair(std::string(host_first, host_last), std::string(port_first, port_last)); + return make_pair(std::string(hostFirst, hostLast), std::string(portFirst, portLast)); } void - do_work(CompletionCounter) + doWork(CompletionCounter) { - if (m_stop_called) + if (stop_called) return; // We don't have any work to do at this time - if (m_work.empty()) + if (work.empty()) return; - std::string const name(m_work.front().names.back()); - HandlerType const handler(m_work.front().handler); + std::string const name(work.front().names.back()); + HandlerType const handler(work.front().handler); - m_work.front().names.pop_back(); + work.front().names.pop_back(); - if (m_work.front().names.empty()) - m_work.pop_front(); + if (work.front().names.empty()) + work.pop_front(); auto const [host, port] = parseName(name); if (host.empty()) { - JLOG(m_journal.error()) << "Unable to parse '" << name << "'"; + JLOG(journal.error()) << "Unable to parse '" << name << "'"; boost::asio::post( - m_io_context, + io_context, boost::asio::bind_executor( - m_strand, - std::bind(&ResolverAsioImpl::do_work, this, CompletionCounter(this)))); + strand, std::bind(&ResolverAsioImpl::doWork, this, CompletionCounter(this)))); return; } - m_resolver.async_resolve( + resolver.async_resolve( host, port, std::bind( - &ResolverAsioImpl::do_finish, + &ResolverAsioImpl::doFinish, this, name, std::placeholders::_1, @@ -369,24 +367,24 @@ public: } void - do_resolve(std::vector const& names, HandlerType const& handler, CompletionCounter) + doResolve(std::vector const& names, HandlerType const& handler, CompletionCounter) { XRPL_ASSERT(!names.empty(), "xrpl::ResolverAsioImpl::do_resolve : names non-empty"); - if (!m_stop_called) + if (!stop_called) { - m_work.emplace_back(names, handler); + work.emplace_back(names, handler); - JLOG(m_journal.debug()) << "Queued new job with " << names.size() << " tasks. " - << m_work.size() << " jobs outstanding."; + JLOG(journal.debug()) << "Queued new job with " << names.size() << " tasks. " + << work.size() << " jobs outstanding."; - if (!m_work.empty()) + if (!work.empty()) { boost::asio::post( - m_io_context, + io_context, boost::asio::bind_executor( - m_strand, - std::bind(&ResolverAsioImpl::do_work, this, CompletionCounter(this)))); + strand, + std::bind(&ResolverAsioImpl::doWork, this, CompletionCounter(this)))); } } } @@ -395,9 +393,9 @@ public: //----------------------------------------------------------------------------- std::unique_ptr -ResolverAsio::New(boost::asio::io_context& io_context, beast::Journal journal) +ResolverAsio::make(boost::asio::io_context& ioContext, beast::Journal journal) { - return std::make_unique(io_context, journal); + return std::make_unique(ioContext, journal); } //----------------------------------------------------------------------------- diff --git a/src/libxrpl/basics/StringUtilities.cpp b/src/libxrpl/basics/StringUtilities.cpp index 7bf4c8e743..f1f8515ae1 100644 --- a/src/libxrpl/basics/StringUtilities.cpp +++ b/src/libxrpl/basics/StringUtilities.cpp @@ -34,10 +34,10 @@ sqlBlobLiteral(Blob const& blob) } bool -parseUrl(parsedURL& pUrl, std::string const& strUrl) +parseUrl(ParsedUrl& pUrl, std::string const& strUrl) { // scheme://username:password@hostname:port/rest - static boost::regex const reUrl( + static boost::regex const kRE_URL( "(?i)\\`\\s*" // required scheme "([[:alpha:]][-+.[:alpha:][:digit:]]*?):" @@ -58,7 +58,7 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl) // Bail if there is no match. try { - if (!boost::regex_match(strUrl, smMatch, reUrl)) + if (!boost::regex_match(strUrl, smMatch, kRE_URL)) return false; } catch (...) @@ -74,7 +74,7 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl) // We need to use Endpoint to parse the domain to // strip surrounding brackets from IPv6 addresses, // e.g. [::1] => ::1. - auto const result = beast::IP::Endpoint::from_string_checked(domain); + auto const result = beast::IP::Endpoint::fromStringChecked(domain); pUrl.domain = result ? result->address().to_string() : domain; std::string const port = smMatch[5]; if (!port.empty()) @@ -94,14 +94,14 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl) } std::string -trim_whitespace(std::string str) +trimWhitespace(std::string str) { boost::trim(str); return str; } std::optional -to_uint64(std::string const& s) +toUint64(std::string const& s) { std::uint64_t result = 0; if (beast::lexicalCastChecked(result, s)) @@ -120,7 +120,7 @@ isProperlyFormedTomlDomain(std::string_view domain) // obviously wrong domain names but it isn't perfect. It does not // really support IDNs. If this turns out to be an issue, a more // thorough regex can be used or this check can just be removed. - static boost::regex const re( + static boost::regex const kRE( "^" // Beginning of line "(" // Beginning of a segment "(?!-)" // - must not begin with '-' @@ -133,7 +133,7 @@ isProperlyFormedTomlDomain(std::string_view domain) , boost::regex_constants::optimize); - return boost::regex_match(domain.begin(), domain.end(), re); + return boost::regex_match(domain.begin(), domain.end(), kRE); } } // namespace xrpl diff --git a/src/libxrpl/basics/UptimeClock.cpp b/src/libxrpl/basics/UptimeClock.cpp index 3d1664482b..5b92617098 100644 --- a/src/libxrpl/basics/UptimeClock.cpp +++ b/src/libxrpl/basics/UptimeClock.cpp @@ -1,3 +1,4 @@ + #include #include @@ -6,15 +7,15 @@ namespace xrpl { -std::atomic UptimeClock::now_{0}; // seconds since start -std::atomic UptimeClock::stop_{false}; // stop update thread +std::atomic UptimeClock::kNOW{0}; // seconds since start +std::atomic UptimeClock::kSTOP{false}; // stop update thread // On xrpld shutdown, cancel and wait for the update thread -UptimeClock::update_thread::~update_thread() +UptimeClock::UpdateThread::~UpdateThread() { if (joinable()) { - stop_ = true; + kSTOP = true; // This join() may take up to a 1s, but happens only // once at xrpld shutdown. join(); @@ -22,20 +23,20 @@ UptimeClock::update_thread::~update_thread() } // Launch the update thread -UptimeClock::update_thread -UptimeClock::start_clock() +UptimeClock::UpdateThread +UptimeClock::startClock() { - return update_thread{[] { + return UpdateThread{[] { using namespace std; using namespace std::chrono; - // Wake up every second and update now_ + // Wake up every second and update kNOW auto next = system_clock::now() + 1s; - while (!stop_) + while (!kSTOP) { this_thread::sleep_until(next); next += 1s; - ++now_; + ++kNOW; } }}; } @@ -48,10 +49,10 @@ UptimeClock::time_point UptimeClock::now() { // start the update thread on first use - static auto const init = start_clock(); + static auto const kINIT = startClock(); // Return the number of seconds since xrpld start - return time_point{duration{now_}}; + return time_point{duration{kNOW}}; } } // namespace xrpl diff --git a/src/libxrpl/basics/base64.cpp b/src/libxrpl/basics/base64.cpp index f266d93194..7a649a8c3a 100644 --- a/src/libxrpl/basics/base64.cpp +++ b/src/libxrpl/basics/base64.cpp @@ -45,17 +45,17 @@ namespace xrpl { namespace base64 { inline char const* -get_alphabet() +getAlphabet() { - static char constexpr tab[] = { + static char constexpr kTAB[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"}; - return &tab[0]; + return &kTAB[0]; } inline signed char const* -get_inverse() +getInverse() { - static signed char constexpr tab[] = { + static signed char constexpr kTAB[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 16-31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, // 32-47 @@ -73,17 +73,17 @@ get_inverse() -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 224-239 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // 240-255 }; - return &tab[0]; + return &kTAB[0]; } /// Returns max chars needed to encode a base64 string -std::size_t constexpr encoded_size(std::size_t n) +std::size_t constexpr encodedSize(std::size_t n) { return 4 * ((n + 2) / 3); } /// Returns max bytes needed to decode a base64 string -std::size_t constexpr decoded_size(std::size_t n) +std::size_t constexpr decodedSize(std::size_t n) { return ((n / 4) * 3) + 2; } @@ -105,7 +105,7 @@ encode(void* dest, void const* src, std::size_t len) { char* out = static_cast(dest); // NOLINT(misc-const-correctness) char const* in = static_cast(src); - auto const tab = base64::get_alphabet(); + auto const tab = base64::getAlphabet(); for (auto n = len / 3; n > 0; --n) { @@ -160,7 +160,7 @@ decode(void* dest, char const* src, std::size_t len) int i = 0; int j = 0; - auto const inverse = base64::get_inverse(); + auto const inverse = base64::getInverse(); while (((len--) != 0u) && *in != '=') { @@ -197,19 +197,19 @@ decode(void* dest, char const* src, std::size_t len) } // namespace base64 std::string -base64_encode(std::uint8_t const* data, std::size_t len) +base64Encode(std::uint8_t const* data, std::size_t len) { std::string dest; - dest.resize(base64::encoded_size(len)); + dest.resize(base64::encodedSize(len)); dest.resize(base64::encode(&dest[0], data, len)); return dest; } std::string -base64_decode(std::string_view data) +base64Decode(std::string_view data) { std::string dest; - dest.resize(base64::decoded_size(data.size())); + dest.resize(base64::decodedSize(data.size())); auto const result = base64::decode(&dest[0], data.data(), data.size()); dest.resize(result.first); return dest; diff --git a/src/libxrpl/basics/contract.cpp b/src/libxrpl/basics/contract.cpp index 32628ac3d9..a249b82353 100644 --- a/src/libxrpl/basics/contract.cpp +++ b/src/libxrpl/basics/contract.cpp @@ -10,13 +10,13 @@ namespace xrpl { void -LogThrow(std::string const& title) +logThrow(std::string const& title) { JLOG(debugLog().warn()) << title; } [[noreturn]] void -LogicError(std::string const& s) noexcept +logicError(std::string const& s) noexcept { // LCOV_EXCL_START JLOG(debugLog().fatal()) << s; diff --git a/src/libxrpl/basics/make_SSLContext.cpp b/src/libxrpl/basics/make_SSLContext.cpp index aa04f22191..89da14333a 100644 --- a/src/libxrpl/basics/make_SSLContext.cpp +++ b/src/libxrpl/basics/make_SSLContext.cpp @@ -46,7 +46,7 @@ namespace openssl::detail { @note If you increase the number of bits you need to generate new default DH parameters and update defaultDH accordingly. * */ -int defaultRSAKeyBits = 2048; +int gDefaultRsaKeyBits = 2048; /** The default DH parameters. @@ -60,7 +60,7 @@ int defaultRSAKeyBits = 2048; @note If you increase the number of bits you need to update defaultRSAKeyBits accordingly. */ -static constexpr char const defaultDH[] = +static constexpr char const kDEFAULT_DH[] = "-----BEGIN DH PARAMETERS-----\n" "MIIBCAKCAQEApKSWfR7LKy0VoZ/SDCObCvJ5HKX2J93RJ+QN8kJwHh+uuA8G+t8Q\n" "MDRjL5HanlV/sKN9HXqBc7eqHmmbqYwIXKUt9MUZTLNheguddxVlc2IjdP5i9Ps8\n" @@ -84,52 +84,52 @@ static constexpr char const defaultDH[] = global or per-port basis, using the `ssl_ciphers` directive in the config file. */ -std::string const defaultCipherList = "TLSv1.2:!CBC:!DSS:!PSK:!eNULL:!aNULL"; +std::string const kDEFAULT_CIPHER_LIST = "TLSv1.2:!CBC:!DSS:!PSK:!eNULL:!aNULL"; static void initAnonymous(boost::asio::ssl::context& context) { using namespace openssl; - static auto defaultRSA = []() { + static auto kDEFAULT_RSA = []() { BIGNUM* bn = BN_new(); BN_set_word(bn, RSA_F4); auto rsa = RSA_new(); if (!rsa) - LogicError("RSA_new failed"); + logicError("RSA_new failed"); - if (RSA_generate_key_ex(rsa, defaultRSAKeyBits, bn, nullptr) != 1) - LogicError("RSA_generate_key_ex failure"); + if (RSA_generate_key_ex(rsa, gDefaultRsaKeyBits, bn, nullptr) != 1) + logicError("RSA_generate_key_ex failure"); BN_clear_free(bn); return rsa; }(); - static auto defaultEphemeralPrivateKey = []() { + static auto kDEFAULT_EPHEMERAL_PRIVATE_KEY = []() { auto pkey = EVP_PKEY_new(); if (!pkey) - LogicError("EVP_PKEY_new failed"); + logicError("EVP_PKEY_new failed"); // We need to up the reference count of here, since we are retaining a // copy of the key for (potential) reuse. - if (RSA_up_ref(defaultRSA) != 1) - LogicError("EVP_PKEY_assign_RSA: incrementing reference count failed"); + if (RSA_up_ref(kDEFAULT_RSA) != 1) + logicError("EVP_PKEY_assign_RSA: incrementing reference count failed"); - if (!EVP_PKEY_assign_RSA(pkey, defaultRSA)) - LogicError("EVP_PKEY_assign_RSA failed"); + if (!EVP_PKEY_assign_RSA(pkey, kDEFAULT_RSA)) + logicError("EVP_PKEY_assign_RSA failed"); return pkey; }(); - static auto defaultCert = []() { + static auto kDEFAULT_CERT = []() { auto x509 = X509_new(); if (x509 == nullptr) - LogicError("X509_new failed"); + logicError("X509_new failed"); // According to the standards (X.509 et al), the value should be one // less than the actually certificate version we want. Since we want @@ -147,7 +147,7 @@ initAnonymous(boost::asio::ssl::context& context) buf[ret] = 0; if (ASN1_TIME_set_string_X509(X509_get_notBefore(x509), buf) != 1) - LogicError("Unable to set certificate validity date"); + logicError("Unable to set certificate validity date"); // And make it valid for two years X509_gmtime_adj(X509_get_notAfter(x509), 2 * 365 * 24 * 60 * 60); @@ -205,61 +205,61 @@ initAnonymous(boost::asio::ssl::context& context) } // And a private key - X509_set_pubkey(x509, defaultEphemeralPrivateKey); + X509_set_pubkey(x509, kDEFAULT_EPHEMERAL_PRIVATE_KEY); - if (!X509_sign(x509, defaultEphemeralPrivateKey, EVP_sha256())) - LogicError("X509_sign failed"); + if (!X509_sign(x509, kDEFAULT_EPHEMERAL_PRIVATE_KEY, EVP_sha256())) + logicError("X509_sign failed"); return x509; }(); SSL_CTX* const ctx = context.native_handle(); - if (SSL_CTX_use_certificate(ctx, defaultCert) <= 0) - LogicError("SSL_CTX_use_certificate failed"); + if (SSL_CTX_use_certificate(ctx, kDEFAULT_CERT) <= 0) + logicError("SSL_CTX_use_certificate failed"); - if (SSL_CTX_use_PrivateKey(ctx, defaultEphemeralPrivateKey) <= 0) - LogicError("SSL_CTX_use_PrivateKey failed"); + if (SSL_CTX_use_PrivateKey(ctx, kDEFAULT_EPHEMERAL_PRIVATE_KEY) <= 0) + logicError("SSL_CTX_use_PrivateKey failed"); } static void initAuthenticated( boost::asio::ssl::context& context, - std::string const& key_file, - std::string const& cert_file, - std::string const& chain_file) + std::string const& keyFile, + std::string const& certFile, + std::string const& chainFile) { - auto fmt_error = [](boost::system::error_code ec) -> std::string { + auto fmtError = [](boost::system::error_code ec) -> std::string { return " [" + std::to_string(ec.value()) + ": " + ec.message() + "]"; }; SSL_CTX* const ssl = context.native_handle(); - bool cert_set = false; + bool certSet = false; - if (!cert_file.empty()) + if (!certFile.empty()) { boost::system::error_code ec; // NOLINTNEXTLINE(bugprone-unused-return-value) - context.use_certificate_file(cert_file, boost::asio::ssl::context::pem, ec); + context.use_certificate_file(certFile, boost::asio::ssl::context::pem, ec); if (ec) - LogicError("Problem with SSL certificate file" + fmt_error(ec)); + logicError("Problem with SSL certificate file" + fmtError(ec)); - cert_set = true; + certSet = true; } - if (!chain_file.empty()) + if (!chainFile.empty()) { // VFALCO Replace fopen() with RAII - FILE* f = fopen(chain_file.c_str(), "r"); + FILE* f = fopen(chainFile.c_str(), "r"); if (f == nullptr) { - LogicError( + logicError( "Problem opening SSL chain file" + - fmt_error(boost::system::error_code(errno, boost::system::generic_category()))); + fmtError(boost::system::error_code(errno, boost::system::generic_category()))); } try @@ -271,21 +271,21 @@ initAuthenticated( if (x == nullptr) break; - if (!cert_set) + if (!certSet) { if (SSL_CTX_use_certificate(ssl, x) != 1) { - LogicError( + logicError( "Problem retrieving SSL certificate from chain " "file."); } - cert_set = true; + certSet = true; } else if (SSL_CTX_add_extra_chain_cert(ssl, x) != 1) { X509_free(x); - LogicError("Problem adding SSL chain certificate."); + logicError("Problem adding SSL chain certificate."); } } @@ -294,32 +294,32 @@ initAuthenticated( catch (std::exception const& ex) { fclose(f); - LogicError( + logicError( std::string("Reading the SSL chain file generated an exception: ") + ex.what()); } } - if (!key_file.empty()) + if (!keyFile.empty()) { boost::system::error_code ec; // NOLINTNEXTLINE(bugprone-unused-return-value) - context.use_private_key_file(key_file, boost::asio::ssl::context::pem, ec); + context.use_private_key_file(keyFile, boost::asio::ssl::context::pem, ec); if (ec) { - LogicError("Problem using the SSL private key file" + fmt_error(ec)); + logicError("Problem using the SSL private key file" + fmtError(ec)); } } if (SSL_CTX_check_private_key(ssl) != 1) { - LogicError("Invalid key in SSL private key file."); + logicError("Invalid key in SSL private key file."); } } std::shared_ptr -get_context(std::string cipherList) +getContext(std::string cipherList) { auto c = std::make_shared(boost::asio::ssl::context::sslv23); @@ -330,12 +330,12 @@ get_context(std::string cipherList) boost::asio::ssl::context::no_compression); if (cipherList.empty()) - cipherList = defaultCipherList; + cipherList = kDEFAULT_CIPHER_LIST; if (auto result = SSL_CTX_set_cipher_list(c->native_handle(), cipherList.c_str()); result != 1) - LogicError("SSL_CTX_set_cipher_list failed"); + logicError("SSL_CTX_set_cipher_list failed"); - c->use_tmp_dh({std::addressof(detail::defaultDH), sizeof(defaultDH)}); + c->use_tmp_dh({std::addressof(detail::kDEFAULT_DH), sizeof(kDEFAULT_DH)}); // Disable all renegotiation support in TLS v1.2. This can help prevent // exploitation of the bug described in CVE-2021-3499 (for details see @@ -350,9 +350,9 @@ get_context(std::string cipherList) //------------------------------------------------------------------------------ std::shared_ptr -make_SSLContext(std::string const& cipherList) +makeSslContext(std::string const& cipherList) { - auto context = openssl::detail::get_context(cipherList); + auto context = openssl::detail::getContext(cipherList); openssl::detail::initAnonymous(*context); // VFALCO NOTE, It seems the WebSocket context never has // set_verify_mode called, for either setting of WEBSOCKET_SECURE @@ -361,13 +361,13 @@ make_SSLContext(std::string const& cipherList) } std::shared_ptr -make_SSLContextAuthed( +makeSslContextAuthed( std::string const& keyFile, std::string const& certFile, std::string const& chainFile, std::string const& cipherList) { - auto context = openssl::detail::get_context(cipherList); + auto context = openssl::detail::getContext(cipherList); openssl::detail::initAuthenticated(*context, keyFile, certFile, chainFile); return context; } diff --git a/src/libxrpl/basics/mulDiv.cpp b/src/libxrpl/basics/mulDiv.cpp index 4abdcc0f75..64d37a35c3 100644 --- a/src/libxrpl/basics/mulDiv.cpp +++ b/src/libxrpl/basics/mulDiv.cpp @@ -15,7 +15,7 @@ mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div) result /= div; - if (result > xrpl::muldiv_max) + if (result > xrpl::kMULDIV_MAX) return std::nullopt; return static_cast(result); diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index dc8f785974..2c8ac34b6a 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -13,9 +13,9 @@ namespace beast { namespace { // Updates the clock -class seconds_clock_thread +class SecondsClockThread { - using Clock = basic_seconds_clock::Clock; + using Clock = BasicSecondsClock::Clock; bool stop_{false}; std::mutex mut_; @@ -24,8 +24,8 @@ class seconds_clock_thread std::atomic tp_; public: - ~seconds_clock_thread(); - seconds_clock_thread(); + ~SecondsClockThread(); + SecondsClockThread(); Clock::time_point now(); @@ -37,7 +37,7 @@ private: static_assert(std::atomic::is_always_lock_free); -seconds_clock_thread::~seconds_clock_thread() +SecondsClockThread::~SecondsClockThread() { XRPL_ASSERT( thread_.joinable(), "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable"); @@ -49,19 +49,19 @@ seconds_clock_thread::~seconds_clock_thread() thread_.join(); } -seconds_clock_thread::seconds_clock_thread() : tp_{Clock::now().time_since_epoch().count()} +SecondsClockThread::SecondsClockThread() : tp_{Clock::now().time_since_epoch().count()} { - thread_ = std::thread(&seconds_clock_thread::run, this); + thread_ = std::thread(&SecondsClockThread::run, this); } -seconds_clock_thread::Clock::time_point -seconds_clock_thread::now() +SecondsClockThread::Clock::time_point +SecondsClockThread::now() { return Clock::time_point{Clock::duration{tp_.load()}}; } void -seconds_clock_thread::run() +SecondsClockThread::run() { std::unique_lock lock(mut_); while (true) @@ -78,11 +78,11 @@ seconds_clock_thread::run() } // unnamed namespace -basic_seconds_clock::time_point -basic_seconds_clock::now() +BasicSecondsClock::time_point +BasicSecondsClock::now() { - static seconds_clock_thread clk; - return clk.now(); + static SecondsClockThread kCLK; + return kCLK.now(); } } // namespace beast diff --git a/src/libxrpl/beast/core/CurrentThreadName.cpp b/src/libxrpl/beast/core/CurrentThreadName.cpp index fd8a4764fa..39daa286c6 100644 --- a/src/libxrpl/beast/core/CurrentThreadName.cpp +++ b/src/libxrpl/beast/core/CurrentThreadName.cpp @@ -80,18 +80,20 @@ inline void setCurrentThreadNameImpl(std::string_view name) { // truncate and set the thread name. - char boundedName[maxThreadNameLength + 1]; - auto const boundedSize = name.size() < maxThreadNameLength ? name.size() : maxThreadNameLength; + char boundedName[kMAX_THREAD_NAME_LENGTH + 1]; + auto const boundedSize = + name.size() < kMAX_THREAD_NAME_LENGTH ? name.size() : kMAX_THREAD_NAME_LENGTH; name.copy(boundedName, boundedSize); boundedName[boundedSize] = '\0'; pthread_setname_np(pthread_self(), boundedName); #ifdef TRUNCATED_THREAD_NAME_LOGS - if (name.size() > maxThreadNameLength) + if (name.size() > kMAX_THREAD_NAME_LENGTH) { std::cerr << "WARNING: Thread name \"" << name << "\" (length " << name.size() - << ") exceeds maximum of " << maxThreadNameLength << " characters on Linux.\n"; + << ") exceeds maximum of " << kMAX_THREAD_NAME_LENGTH + << " characters on Linux.\n"; } #endif } @@ -102,19 +104,19 @@ setCurrentThreadNameImpl(std::string_view name) namespace beast { namespace detail { -thread_local std::string threadName; +thread_local std::string gThreadName; } // namespace detail std::string getCurrentThreadName() { - return detail::threadName; + return detail::gThreadName; } void setCurrentThreadName(std::string_view name) { - detail::threadName = name; + detail::gThreadName = name; detail::setCurrentThreadNameImpl(name); } diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index 0cf4ac3113..a99437f8f2 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -15,7 +15,7 @@ namespace beast { std::string -print_identifiers(SemanticVersion::identifier_list const& list) +printIdentifiers(SemanticVersion::identifier_list const& list) { std::string ret; @@ -61,10 +61,10 @@ chopUInt(int& value, int limit, std::string& input) if (input.empty()) return false; - auto left_iter = std::ranges::find_if_not( + auto leftIter = std::ranges::find_if_not( input, [](std::string::value_type c) { return std::isdigit(c, std::locale::classic()); }); - std::string const item(input.begin(), left_iter); + std::string const item(input.begin(), leftIter); // Must not be empty if (item.empty()) @@ -84,14 +84,14 @@ chopUInt(int& value, int limit, std::string& input) if (n < 0 || n > limit) return false; - input.erase(input.begin(), left_iter); + input.erase(input.begin(), leftIter); value = n; return true; } bool -extract_identifier(std::string& value, bool allowLeadingZeroes, std::string& input) +extractIdentifier(std::string& value, bool allowLeadingZeroes, std::string& input) { // Must not be empty if (input.empty()) @@ -114,7 +114,7 @@ extract_identifier(std::string& value, bool allowLeadingZeroes, std::string& inp } bool -extract_identifiers( +extractIdentifiers( SemanticVersion::identifier_list& identifiers, bool allowLeadingZeroes, std::string& input) @@ -126,7 +126,7 @@ extract_identifiers( { std::string s; - if (!extract_identifier(s, allowLeadingZeroes, input)) + if (!extractIdentifier(s, allowLeadingZeroes, input)) return false; identifiers.push_back(s); } while (chop(".", input)); @@ -150,19 +150,19 @@ bool SemanticVersion::parse(std::string_view input) { // May not have leading or trailing whitespace - auto left_iter = std::ranges::find_if_not( + auto leftIter = std::ranges::find_if_not( input, [](std::string::value_type c) { return std::isspace(c, std::locale::classic()); }); - auto right_iter = + auto rightIter = std::ranges::find_if_not(std::ranges::reverse_view(input), [](std::string::value_type c) { return std::isspace(c, std::locale::classic()); }).base(); // Must not be empty! - if (left_iter >= right_iter) + if (leftIter >= rightIter) return false; - std::string version(left_iter, right_iter); + std::string version(leftIter, rightIter); // May not have leading or trailing whitespace if (version != input) @@ -187,7 +187,7 @@ SemanticVersion::parse(std::string_view input) // May have pre-release identifier list if (chop("-", version)) { - if (!extract_identifiers(preReleaseIdentifiers, false, version)) + if (!extractIdentifiers(preReleaseIdentifiers, false, version)) return false; // Must not be empty @@ -198,7 +198,7 @@ SemanticVersion::parse(std::string_view input) // May have metadata identifier list if (chop("+", version)) { - if (!extract_identifiers(metaData, true, version)) + if (!extractIdentifiers(metaData, true, version)) return false; // Must not be empty @@ -220,13 +220,13 @@ SemanticVersion::print() const if (!preReleaseIdentifiers.empty()) { s += "-"; - s += print_identifiers(preReleaseIdentifiers); + s += printIdentifiers(preReleaseIdentifiers); } if (!metaData.empty()) { s += "+"; - s += print_identifiers(metaData); + s += printIdentifiers(metaData); } return s; diff --git a/src/libxrpl/beast/insight/Groups.cpp b/src/libxrpl/beast/insight/Groups.cpp index c9e9453468..6a60c75aa2 100644 --- a/src/libxrpl/beast/insight/Groups.cpp +++ b/src/libxrpl/beast/insight/Groups.cpp @@ -21,12 +21,12 @@ namespace detail { class GroupImp : public std::enable_shared_from_this, public Group { -public: - std::string const m_name; - Collector::ptr m_collector; + std::string const name_; + Collector::ptr collector_; - GroupImp(std::string name_, Collector::ptr collector) - : m_name(std::move(name_)), m_collector(std::move(collector)) +public: + GroupImp(std::string name, Collector::ptr collector) + : name_(std::move(name)), collector_(std::move(collector)) { } @@ -35,43 +35,43 @@ public: std::string const& name() const override { - return m_name; + return name_; } std::string - make_name(std::string const& name) + makeName(std::string const& name) { - return m_name + "." + name; + return name_ + "." + name; } Hook - make_hook(HookImpl::HandlerType const& handler) override + makeHook(HookImpl::HandlerType const& handler) override { - return m_collector->make_hook(handler); + return collector_->makeHook(handler); } Counter - make_counter(std::string const& name) override + makeCounter(std::string const& name) override { - return m_collector->make_counter(make_name(name)); + return collector_->makeCounter(makeName(name)); } Event - make_event(std::string const& name) override + makeEvent(std::string const& name) override { - return m_collector->make_event(make_name(name)); + return collector_->makeEvent(makeName(name)); } Gauge - make_gauge(std::string const& name) override + makeGauge(std::string const& name) override { - return m_collector->make_gauge(make_name(name)); + return collector_->makeGauge(makeName(name)); } Meter - make_meter(std::string const& name) override + makeMeter(std::string const& name) override { - return m_collector->make_meter(make_name(name)); + return collector_->makeMeter(makeName(name)); } GroupImp& @@ -83,12 +83,12 @@ public: class GroupsImp : public Groups { public: - using Items = std::unordered_map, uhash<>>; + using Items = std::unordered_map, Uhash<>>; - Collector::ptr m_collector; - Items m_items; + Collector::ptr collector; + Items items; - explicit GroupsImp(Collector::ptr collector) : m_collector(std::move(collector)) + explicit GroupsImp(Collector::ptr collector) : collector(std::move(collector)) { } @@ -97,10 +97,10 @@ public: Group::ptr const& get(std::string const& name) override { - std::pair const result(m_items.emplace(name, Group::ptr())); + std::pair const result(items.emplace(name, Group::ptr())); Group::ptr& group(result.first->second); if (result.second) - group = std::make_shared(name, m_collector); + group = std::make_shared(name, collector); return group; } }; @@ -112,7 +112,7 @@ public: Groups::~Groups() = default; std::unique_ptr -make_Groups(Collector::ptr const& collector) +makeGroups(Collector::ptr const& collector) { return std::make_unique(collector); } diff --git a/src/libxrpl/beast/insight/NullCollector.cpp b/src/libxrpl/beast/insight/NullCollector.cpp index f5bb44bdba..03a12ee498 100644 --- a/src/libxrpl/beast/insight/NullCollector.cpp +++ b/src/libxrpl/beast/insight/NullCollector.cpp @@ -108,31 +108,31 @@ public: ~NullCollectorImp() override = default; Hook - make_hook(HookImpl::HandlerType const&) override + makeHook(HookImpl::HandlerType const&) override { return Hook(std::make_shared()); } Counter - make_counter(std::string const&) override + makeCounter(std::string const&) override { return Counter(std::make_shared()); } Event - make_event(std::string const&) override + makeEvent(std::string const&) override { return Event(std::make_shared()); } Gauge - make_gauge(std::string const&) override + makeGauge(std::string const&) override { return Gauge(std::make_shared()); } Meter - make_meter(std::string const&) override + makeMeter(std::string const&) override { return Meter(std::make_shared()); } @@ -143,7 +143,7 @@ public: //------------------------------------------------------------------------------ std::shared_ptr -NullCollector::New() +NullCollector::make() { return std::make_shared(); } diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index a83a11d7d6..90d06ddf28 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -53,7 +53,7 @@ class StatsDMetricBase : public List::Node { public: virtual void - do_process() = 0; + doProcess() = 0; virtual ~StatsDMetricBase() = default; StatsDMetricBase() = default; StatsDMetricBase(StatsDMetricBase const&) = delete; @@ -71,14 +71,14 @@ public: ~StatsDHookImpl() override; void - do_process() override; + doProcess() override; StatsDHookImpl& operator=(StatsDHookImpl const&) = delete; private: - std::shared_ptr m_impl; - HandlerType m_handler; + std::shared_ptr impl_; + HandlerType handler_; }; //------------------------------------------------------------------------------ @@ -96,18 +96,18 @@ public: void flush(); void - do_increment(CounterImpl::value_type amount); + doIncrement(CounterImpl::value_type amount); void - do_process() override; + doProcess() override; StatsDCounterImpl& operator=(StatsDCounterImpl const&) = delete; private: - std::shared_ptr m_impl; - std::string m_name; - CounterImpl::value_type m_value{0}; - bool m_dirty{false}; + std::shared_ptr impl_; + std::string name_; + CounterImpl::value_type value_{0}; + bool dirty_{false}; }; //------------------------------------------------------------------------------ @@ -123,16 +123,16 @@ public: notify(EventImpl::value_type const& value) override; void - do_notify(EventImpl::value_type const& value); + doNotify(EventImpl::value_type const& value); void - do_process(); + doProcess(); private: StatsDEventImpl& operator=(StatsDEventImpl const&); - std::shared_ptr m_impl; - std::string m_name; + std::shared_ptr impl_; + std::string name_; }; //------------------------------------------------------------------------------ @@ -152,21 +152,21 @@ public: void flush(); void - do_set(GaugeImpl::value_type value); + doSet(GaugeImpl::value_type value); void - do_increment(GaugeImpl::difference_type amount); + doIncrement(GaugeImpl::difference_type amount); void - do_process() override; + doProcess() override; StatsDGaugeImpl& operator=(StatsDGaugeImpl const&) = delete; private: - std::shared_ptr m_impl; - std::string m_name; - GaugeImpl::value_type m_last_value{0}; - GaugeImpl::value_type m_value{0}; - bool m_dirty{false}; + std::shared_ptr impl_; + std::string name_; + GaugeImpl::value_type last_value_{0}; + GaugeImpl::value_type value_{0}; + bool dirty_{false}; }; //------------------------------------------------------------------------------ @@ -184,18 +184,18 @@ public: void flush(); void - do_increment(MeterImpl::value_type amount); + doIncrement(MeterImpl::value_type amount); void - do_process() override; + doProcess() override; StatsDMeterImpl& operator=(StatsDMeterImpl const&) = delete; private: - std::shared_ptr m_impl; - std::string m_name; - MeterImpl::value_type m_value{0}; - bool m_dirty{false}; + std::shared_ptr impl_; + std::string name_; + MeterImpl::value_type value_{0}; + bool dirty_{false}; }; //------------------------------------------------------------------------------ @@ -207,41 +207,41 @@ private: // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) enum { - // max_packet_size = 484 - max_packet_size = 1472 + // MaxPacketSize = 484 + MaxPacketSize = 1472 }; - Journal m_journal; - IP::Endpoint m_address; - std::string m_prefix; - boost::asio::io_context m_io_context; - std::optional> m_work; - boost::asio::strand m_strand; - boost::asio::basic_waitable_timer m_timer; - boost::asio::ip::udp::socket m_socket; - std::deque m_data; + Journal journal_; + IP::Endpoint address_; + std::string prefix_; + boost::asio::io_context io_context_; + std::optional> work_; + boost::asio::strand strand_; + boost::asio::basic_waitable_timer timer_; + boost::asio::ip::udp::socket socket_; + std::deque data_; std::recursive_mutex metricsLock_; List metrics_; // Must come last for order of init - std::thread m_thread; + std::thread thread_; static boost::asio::ip::udp::endpoint - to_endpoint(IP::Endpoint const& ep) + toEndpoint(IP::Endpoint const& ep) { return boost::asio::ip::udp::endpoint(ep.address(), ep.port()); } public: StatsDCollectorImp(IP::Endpoint address, std::string prefix, Journal journal) - : m_journal(journal) - , m_address(std::move(address)) - , m_prefix(std::move(prefix)) - , m_work(boost::asio::make_work_guard(m_io_context)) - , m_strand(boost::asio::make_strand(m_io_context)) - , m_timer(m_io_context) - , m_socket(m_io_context) - , m_thread(&StatsDCollectorImp::run, this) + : journal_(journal) + , address_(std::move(address)) + , prefix_(std::move(prefix)) + , work_(boost::asio::make_work_guard(io_context_)) + , strand_(boost::asio::make_strand(io_context_)) + , timer_(io_context_) + , socket_(io_context_) + , thread_(&StatsDCollectorImp::run, this) { } @@ -249,43 +249,43 @@ public: { try { - m_timer.cancel(); + timer_.cancel(); } catch (boost::system::system_error const&) // NOLINT(bugprone-empty-catch) { // ignored } - m_work.reset(); - m_thread.join(); + work_.reset(); + thread_.join(); } Hook - make_hook(HookImpl::HandlerType const& handler) override + makeHook(HookImpl::HandlerType const& handler) override { return Hook(std::make_shared(handler, shared_from_this())); } Counter - make_counter(std::string const& name) override + makeCounter(std::string const& name) override { return Counter(std::make_shared(name, shared_from_this())); } Event - make_event(std::string const& name) override + makeEvent(std::string const& name) override { return Event(std::make_shared(name, shared_from_this())); } Gauge - make_gauge(std::string const& name) override + makeGauge(std::string const& name) override { return Gauge(std::make_shared(name, shared_from_this())); } Meter - make_meter(std::string const& name) override + makeMeter(std::string const& name) override { return Meter(std::make_shared(name, shared_from_this())); } @@ -296,49 +296,49 @@ public: add(StatsDMetricBase& metric) { std::scoped_lock const _(metricsLock_); - metrics_.push_back(metric); + metrics_.pushBack(metric); } void remove(StatsDMetricBase& metric) { std::scoped_lock const _(metricsLock_); - metrics_.erase(metrics_.iterator_to(metric)); + metrics_.erase(metrics_.iteratorTo(metric)); } //-------------------------------------------------------------------------- boost::asio::io_context& - get_io_context() + getIoContext() { - return m_io_context; + return io_context_; } std::string const& prefix() const { - return m_prefix; + return prefix_; } void - do_post_buffer(std::string const& buffer) + doPostBuffer(std::string const& buffer) { - m_data.emplace_back(buffer); + data_.emplace_back(buffer); } void - post_buffer(std::string&& buffer) + postBuffer(std::string&& buffer) { boost::asio::dispatch( - m_io_context, + io_context_, boost::asio::bind_executor( - m_strand, std::bind(&StatsDCollectorImp::do_post_buffer, this, std::move(buffer)))); + strand_, std::bind(&StatsDCollectorImp::doPostBuffer, this, std::move(buffer)))); } // The keepAlive parameter makes sure the buffers sent to // boost::asio::async_send do not go away until the call is finished void - on_send( + onSend( std::shared_ptr> /*keepAlive*/, boost::system::error_code ec, std::size_t) @@ -348,7 +348,7 @@ public: if (ec) { - if (auto stream = m_journal.error()) + if (auto stream = journal_.error()) stream << "async_send failed: " << ec.message(); return; } @@ -370,35 +370,35 @@ public: // Send what we have void - send_buffers() + sendBuffers() { - if (m_data.empty()) + if (data_.empty()) return; // Break up the array of strings into blocks // that each fit into one UDP packet. // std::vector buffers; - buffers.reserve(m_data.size()); + buffers.reserve(data_.size()); std::size_t size(0); - auto keepAlive = std::make_shared>(std::move(m_data)); - m_data.clear(); + auto keepAlive = std::make_shared>(std::move(data_)); + data_.clear(); for (auto const& s : *keepAlive) { std::size_t const length(s.size()); XRPL_ASSERT( !s.empty(), - "beast::insight::detail::StatsDCollectorImp::send_buffers : " + "beast::insight::detail::StatsDCollectorImp::sendBuffers : " "non-empty payload"); - if (!buffers.empty() && (size + length) > max_packet_size) + if (!buffers.empty() && (size + length) > MaxPacketSize) { log(buffers); - m_socket.async_send( + socket_.async_send( buffers, std::bind( - &StatsDCollectorImp::on_send, + &StatsDCollectorImp::onSend, this, keepAlive, std::placeholders::_1, @@ -414,10 +414,10 @@ public: if (!buffers.empty()) { log(buffers); - m_socket.async_send( + socket_.async_send( buffers, std::bind( - &StatsDCollectorImp::on_send, + &StatsDCollectorImp::onSend, this, keepAlive, std::placeholders::_1, @@ -426,34 +426,34 @@ public: } void - set_timer() + setTimer() { using namespace std::chrono_literals; - m_timer.expires_after(1s); - m_timer.async_wait(std::bind(&StatsDCollectorImp::on_timer, this, std::placeholders::_1)); + timer_.expires_after(1s); + timer_.async_wait(std::bind(&StatsDCollectorImp::onTimer, this, std::placeholders::_1)); } void - on_timer(boost::system::error_code ec) + onTimer(boost::system::error_code ec) { if (ec == boost::asio::error::operation_aborted) return; if (ec) { - if (auto stream = m_journal.error()) - stream << "on_timer failed: " << ec.message(); + if (auto stream = journal_.error()) + stream << "onTimer failed: " << ec.message(); return; } std::scoped_lock const _(metricsLock_); for (auto& m : metrics_) - m.do_process(); + m.doProcess(); - send_buffers(); + sendBuffers(); - set_timer(); + setTimer(); } void @@ -461,43 +461,43 @@ public: { boost::system::error_code ec; - if (m_socket.connect(to_endpoint(m_address), ec)) + if (socket_.connect(toEndpoint(address_), ec)) { - if (auto stream = m_journal.error()) + if (auto stream = journal_.error()) stream << "Connect failed: " << ec.message(); return; } - set_timer(); + setTimer(); - m_io_context.run(); + io_context_.run(); // NOLINTNEXTLINE(bugprone-unused-return-value) - m_socket.shutdown(boost::asio::ip::udp::socket::shutdown_send, ec); + socket_.shutdown(boost::asio::ip::udp::socket::shutdown_send, ec); - m_socket.close(); + socket_.close(); - m_io_context.poll(); + io_context_.poll(); } }; //------------------------------------------------------------------------------ StatsDHookImpl::StatsDHookImpl(HandlerType handler, std::shared_ptr const& impl) - : m_impl(impl), m_handler(std::move(handler)) + : impl_(impl), handler_(std::move(handler)) { - m_impl->add(*this); + impl_->add(*this); } StatsDHookImpl::~StatsDHookImpl() { - m_impl->remove(*this); + impl_->remove(*this); } void -StatsDHookImpl::do_process() +StatsDHookImpl::doProcess() { - m_handler(); + handler_(); } //------------------------------------------------------------------------------ @@ -505,23 +505,23 @@ StatsDHookImpl::do_process() StatsDCounterImpl::StatsDCounterImpl( std::string name, std::shared_ptr const& impl) - : m_impl(impl), m_name(std::move(name)) + : impl_(impl), name_(std::move(name)) { - m_impl->add(*this); + impl_->add(*this); } StatsDCounterImpl::~StatsDCounterImpl() { - m_impl->remove(*this); + impl_->remove(*this); } void StatsDCounterImpl::increment(CounterImpl::value_type amount) { boost::asio::dispatch( - m_impl->get_io_context(), + impl_->getIoContext(), std::bind( - &StatsDCounterImpl::do_increment, + &StatsDCounterImpl::doIncrement, std::static_pointer_cast(shared_from_this()), amount)); } @@ -529,26 +529,26 @@ StatsDCounterImpl::increment(CounterImpl::value_type amount) void StatsDCounterImpl::flush() { - if (m_dirty) + if (dirty_) { - m_dirty = false; + dirty_ = false; std::stringstream ss; - ss << m_impl->prefix() << "." << m_name << ":" << m_value << "|c" + ss << impl_->prefix() << "." << name_ << ":" << value_ << "|c" << "\n"; - m_value = 0; - m_impl->post_buffer(ss.str()); + value_ = 0; + impl_->postBuffer(ss.str()); } } void -StatsDCounterImpl::do_increment(CounterImpl::value_type amount) +StatsDCounterImpl::doIncrement(CounterImpl::value_type amount) { - m_value += amount; - m_dirty = true; + value_ += amount; + dirty_ = true; } void -StatsDCounterImpl::do_process() +StatsDCounterImpl::doProcess() { flush(); } @@ -556,7 +556,7 @@ StatsDCounterImpl::do_process() //------------------------------------------------------------------------------ StatsDEventImpl::StatsDEventImpl(std::string name, std::shared_ptr const& impl) - : m_impl(impl), m_name(std::move(name)) + : impl_(impl), name_(std::move(name)) { } @@ -564,42 +564,42 @@ void StatsDEventImpl::notify(EventImpl::value_type const& value) { boost::asio::dispatch( - m_impl->get_io_context(), + impl_->getIoContext(), std::bind( - &StatsDEventImpl::do_notify, + &StatsDEventImpl::doNotify, std::static_pointer_cast(shared_from_this()), value)); } void -StatsDEventImpl::do_notify(EventImpl::value_type const& value) +StatsDEventImpl::doNotify(EventImpl::value_type const& value) { std::stringstream ss; - ss << m_impl->prefix() << "." << m_name << ":" << value.count() << "|ms" + ss << impl_->prefix() << "." << name_ << ":" << value.count() << "|ms" << "\n"; - m_impl->post_buffer(ss.str()); + impl_->postBuffer(ss.str()); } //------------------------------------------------------------------------------ StatsDGaugeImpl::StatsDGaugeImpl(std::string name, std::shared_ptr const& impl) - : m_impl(impl), m_name(std::move(name)) + : impl_(impl), name_(std::move(name)) { - m_impl->add(*this); + impl_->add(*this); } StatsDGaugeImpl::~StatsDGaugeImpl() { - m_impl->remove(*this); + impl_->remove(*this); } void StatsDGaugeImpl::set(GaugeImpl::value_type value) { boost::asio::dispatch( - m_impl->get_io_context(), + impl_->getIoContext(), std::bind( - &StatsDGaugeImpl::do_set, + &StatsDGaugeImpl::doSet, std::static_pointer_cast(shared_from_this()), value)); } @@ -608,9 +608,9 @@ void StatsDGaugeImpl::increment(GaugeImpl::difference_type amount) { boost::asio::dispatch( - m_impl->get_io_context(), + impl_->getIoContext(), std::bind( - &StatsDGaugeImpl::do_increment, + &StatsDGaugeImpl::doIncrement, std::static_pointer_cast(shared_from_this()), amount)); } @@ -618,38 +618,38 @@ StatsDGaugeImpl::increment(GaugeImpl::difference_type amount) void StatsDGaugeImpl::flush() { - if (m_dirty) + if (dirty_) { - m_dirty = false; + dirty_ = false; std::stringstream ss; - ss << m_impl->prefix() << "." << m_name << ":" << m_value << "|g" + ss << impl_->prefix() << "." << name_ << ":" << value_ << "|g" << "\n"; - m_impl->post_buffer(ss.str()); + impl_->postBuffer(ss.str()); } } void -StatsDGaugeImpl::do_set(GaugeImpl::value_type value) +StatsDGaugeImpl::doSet(GaugeImpl::value_type value) { - m_value = value; + value_ = value; - if (m_value != m_last_value) + if (value_ != last_value_) { - m_last_value = m_value; - m_dirty = true; + last_value_ = value_; + dirty_ = true; } } void -StatsDGaugeImpl::do_increment(GaugeImpl::difference_type amount) +StatsDGaugeImpl::doIncrement(GaugeImpl::difference_type amount) { - GaugeImpl::value_type value(m_value); + GaugeImpl::value_type value(value_); if (amount > 0) { GaugeImpl::value_type const d(static_cast(amount)); - value += (d >= std::numeric_limits::max() - m_value) - ? std::numeric_limits::max() - m_value + value += (d >= std::numeric_limits::max() - value_) + ? std::numeric_limits::max() - value_ : d; } else if (amount < 0) @@ -658,11 +658,11 @@ StatsDGaugeImpl::do_increment(GaugeImpl::difference_type amount) value = (d >= value) ? 0 : value - d; } - do_set(value); + doSet(value); } void -StatsDGaugeImpl::do_process() +StatsDGaugeImpl::doProcess() { flush(); } @@ -670,23 +670,23 @@ StatsDGaugeImpl::do_process() //------------------------------------------------------------------------------ StatsDMeterImpl::StatsDMeterImpl(std::string name, std::shared_ptr const& impl) - : m_impl(impl), m_name(std::move(name)) + : impl_(impl), name_(std::move(name)) { - m_impl->add(*this); + impl_->add(*this); } StatsDMeterImpl::~StatsDMeterImpl() { - m_impl->remove(*this); + impl_->remove(*this); } void StatsDMeterImpl::increment(MeterImpl::value_type amount) { boost::asio::dispatch( - m_impl->get_io_context(), + impl_->getIoContext(), std::bind( - &StatsDMeterImpl::do_increment, + &StatsDMeterImpl::doIncrement, std::static_pointer_cast(shared_from_this()), amount)); } @@ -694,26 +694,26 @@ StatsDMeterImpl::increment(MeterImpl::value_type amount) void StatsDMeterImpl::flush() { - if (m_dirty) + if (dirty_) { - m_dirty = false; + dirty_ = false; std::stringstream ss; - ss << m_impl->prefix() << "." << m_name << ":" << m_value << "|m" + ss << impl_->prefix() << "." << name_ << ":" << value_ << "|m" << "\n"; - m_value = 0; - m_impl->post_buffer(ss.str()); + value_ = 0; + impl_->postBuffer(ss.str()); } } void -StatsDMeterImpl::do_increment(MeterImpl::value_type amount) +StatsDMeterImpl::doIncrement(MeterImpl::value_type amount) { - m_value += amount; - m_dirty = true; + value_ += amount; + dirty_ = true; } void -StatsDMeterImpl::do_process() +StatsDMeterImpl::doProcess() { flush(); } @@ -723,7 +723,7 @@ StatsDMeterImpl::do_process() //------------------------------------------------------------------------------ std::shared_ptr -StatsDCollector::New(IP::Endpoint const& address, std::string const& prefix, Journal journal) +StatsDCollector::make(IP::Endpoint const& address, std::string const& prefix, Journal journal) { return std::make_shared(address, prefix, journal); } diff --git a/src/libxrpl/beast/net/IPAddressConversion.cpp b/src/libxrpl/beast/net/IPAddressConversion.cpp index 14cb4bd44d..c0a37d234e 100644 --- a/src/libxrpl/beast/net/IPAddressConversion.cpp +++ b/src/libxrpl/beast/net/IPAddressConversion.cpp @@ -8,25 +8,25 @@ namespace beast::IP { Endpoint -from_asio(boost::asio::ip::address const& address) +fromAsio(boost::asio::ip::address const& address) { return Endpoint{address}; } Endpoint -from_asio(boost::asio::ip::tcp::endpoint const& endpoint) +fromAsio(boost::asio::ip::tcp::endpoint const& endpoint) { return Endpoint{endpoint.address(), endpoint.port()}; } boost::asio::ip::address -to_asio_address(Endpoint const& endpoint) +toAsioAddress(Endpoint const& endpoint) { return endpoint.address(); } boost::asio::ip::tcp::endpoint -to_asio_endpoint(Endpoint const& endpoint) +toAsioEndpoint(Endpoint const& endpoint) { return boost::asio::ip::tcp::endpoint{endpoint.address(), endpoint.port()}; } diff --git a/src/libxrpl/beast/net/IPAddressV4.cpp b/src/libxrpl/beast/net/IPAddressV4.cpp index f39e511c4c..48554d0ec3 100644 --- a/src/libxrpl/beast/net/IPAddressV4.cpp +++ b/src/libxrpl/beast/net/IPAddressV4.cpp @@ -3,7 +3,7 @@ namespace beast::IP { bool -is_private(AddressV4 const& addr) +isPrivate(AddressV4 const& addr) { return ((addr.to_uint() & 0xff000000) == 0x0a000000) || // Prefix /8, 10. #.#.# ((addr.to_uint() & 0xfff00000) == 0xac100000) || // Prefix /12 172. 16.#.# - 172.31.#.# @@ -12,16 +12,16 @@ is_private(AddressV4 const& addr) } bool -is_public(AddressV4 const& addr) +isPublic(AddressV4 const& addr) { - return !is_private(addr) && !addr.is_multicast(); + return !isPrivate(addr) && !addr.is_multicast(); } char -get_class(AddressV4 const& addr) +getClass(AddressV4 const& addr) { - static char const* table = "AAAABBCD"; // cspell:disable-line - return table[(addr.to_uint() & 0xE0000000) >> 29]; + static char const* kTABLE = "AAAABBCD"; // cspell:disable-line + return kTABLE[(addr.to_uint() & 0xE0000000) >> 29]; } } // namespace beast::IP diff --git a/src/libxrpl/beast/net/IPAddressV6.cpp b/src/libxrpl/beast/net/IPAddressV6.cpp index 3dbadf9779..fad11dddc0 100644 --- a/src/libxrpl/beast/net/IPAddressV6.cpp +++ b/src/libxrpl/beast/net/IPAddressV6.cpp @@ -7,19 +7,19 @@ namespace beast::IP { bool -is_private(AddressV6 const& addr) +isPrivate(AddressV6 const& addr) { return ( ((addr.to_bytes()[0] & 0xfd) != 0) || // TODO fc00::/8 too ? (addr.is_v4_mapped() && - is_private(boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, addr)))); + isPrivate(boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, addr)))); } bool -is_public(AddressV6 const& addr) +isPublic(AddressV6 const& addr) { // TODO is this correct? - return !is_private(addr) && !addr.is_multicast(); + return !isPrivate(addr) && !addr.is_multicast(); } } // namespace beast::IP diff --git a/src/libxrpl/beast/net/IPEndpoint.cpp b/src/libxrpl/beast/net/IPEndpoint.cpp index e1c7394b42..5877151187 100644 --- a/src/libxrpl/beast/net/IPEndpoint.cpp +++ b/src/libxrpl/beast/net/IPEndpoint.cpp @@ -16,16 +16,16 @@ namespace beast::IP { -Endpoint::Endpoint() : m_port(0) +Endpoint::Endpoint() : port_(0) { } -Endpoint::Endpoint(Address addr, Port port) : m_addr(std::move(addr)), m_port(port) +Endpoint::Endpoint(Address addr, Port port) : addr_(std::move(addr)), port_(port) { } std::optional -Endpoint::from_string_checked(std::string const& s) +Endpoint::fromStringChecked(std::string const& s) { if (s.size() <= 64) { @@ -39,15 +39,15 @@ Endpoint::from_string_checked(std::string const& s) } Endpoint -Endpoint::from_string(std::string const& s) +Endpoint::fromString(std::string const& s) { - if (std::optional const result = from_string_checked(s)) + if (std::optional const result = fromStringChecked(s)) return *result; return Endpoint{}; } std::string -Endpoint::to_string() const +Endpoint::toString() const { std::string s; s.reserve( diff --git a/src/libxrpl/beast/utility/beast_Journal.cpp b/src/libxrpl/beast/utility/beast_Journal.cpp index 0d0b5a0d1d..abe5072461 100644 --- a/src/libxrpl/beast/utility/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/beast_Journal.cpp @@ -12,7 +12,7 @@ namespace beast { class NullJournalSink : public Journal::Sink { public: - NullJournalSink() : Sink(severities::kDisabled, false) + NullJournalSink() : Sink(severities::KDisabled, false) { } @@ -38,7 +38,7 @@ public: [[nodiscard]] severities::Severity threshold() const override { - return severities::kDisabled; + return severities::KDisabled; } void @@ -62,13 +62,13 @@ public: Journal::Sink& Journal::getNullSink() { - static NullJournalSink sink; - return sink; + static NullJournalSink kSINK; + return kSINK; } //------------------------------------------------------------------------------ -Journal::Sink::Sink(Severity thresh, bool console) : thresh_(thresh), m_console(console) +Journal::Sink::Sink(Severity thresh, bool console) : thresh_(thresh), console_(console) { } @@ -83,13 +83,13 @@ Journal::Sink::active(Severity level) const bool Journal::Sink::console() const { - return m_console; + return console_; } void Journal::Sink::console(bool output) { - m_console = output; + console_ = output; } severities::Severity @@ -106,30 +106,30 @@ Journal::Sink::threshold(Severity thresh) //------------------------------------------------------------------------------ -Journal::ScopedStream::ScopedStream(Sink& sink, Severity level) : m_sink(sink), m_level(level) +Journal::ScopedStream::ScopedStream(Sink& sink, Severity level) : sink_(sink), level_(level) { // Modifiers applied from all ctors - m_ostream << std::boolalpha << std::showbase; + ostream_ << std::boolalpha << std::showbase; } Journal::ScopedStream::ScopedStream(Stream const& stream, std::ostream& manip(std::ostream&)) : ScopedStream(stream.sink(), stream.level()) { - m_ostream << manip; + ostream_ << manip; } Journal::ScopedStream::~ScopedStream() { - std::string const& s(m_ostream.str()); + std::string const& s(ostream_.str()); if (!s.empty()) { if (s == "\n") { - m_sink.write(m_level, ""); + sink_.write(level_, ""); } else { - m_sink.write(m_level, s); + sink_.write(level_, s); } } } @@ -137,7 +137,7 @@ Journal::ScopedStream::~ScopedStream() std::ostream& Journal::ScopedStream::operator<<(std::ostream& manip(std::ostream&)) const { - return m_ostream << manip; + return ostream_ << manip; } //------------------------------------------------------------------------------ diff --git a/src/libxrpl/beast/utility/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/beast_PropertyStream.cpp index 62c192bf64..c26a6dacf8 100644 --- a/src/libxrpl/beast/utility/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/beast_PropertyStream.cpp @@ -16,14 +16,14 @@ namespace beast { // //------------------------------------------------------------------------------ -PropertyStream::Item::Item(Source* source) : m_source(source) +PropertyStream::Item::Item(Source* source) : source_(source) { } PropertyStream::Source& PropertyStream::Item::source() const { - return *m_source; + return *source_; } PropertyStream::Source* @@ -44,25 +44,25 @@ PropertyStream::Item::operator*() const // //------------------------------------------------------------------------------ -PropertyStream::Proxy::Proxy(Map const& map, std::string key) : m_map(&map), m_key(std::move(key)) +PropertyStream::Proxy::Proxy(Map const& map, std::string key) : map_(&map), key_(std::move(key)) { } -PropertyStream::Proxy::Proxy(Proxy const& other) : m_map(other.m_map), m_key(other.m_key) +PropertyStream::Proxy::Proxy(Proxy const& other) : map_(other.map_), key_(other.key_) { } PropertyStream::Proxy::~Proxy() { - std::string const s(m_ostream.str()); + std::string const s(ostream_.str()); if (!s.empty()) - m_map->add(m_key, s); + map_->add(key_, s); } std::ostream& PropertyStream::Proxy::operator<<(std::ostream& manip(std::ostream&)) const { - return m_ostream << manip; + return ostream_ << manip; } //------------------------------------------------------------------------------ @@ -71,40 +71,40 @@ PropertyStream::Proxy::operator<<(std::ostream& manip(std::ostream&)) const // //------------------------------------------------------------------------------ -PropertyStream::Map::Map(PropertyStream& stream) : m_stream(stream) +PropertyStream::Map::Map(PropertyStream& stream) : stream_(stream) { } -PropertyStream::Map::Map(Set& parent) : m_stream(parent.stream()) +PropertyStream::Map::Map(Set& parent) : stream_(parent.stream()) { - m_stream.map_begin(); + stream_.mapBegin(); } -PropertyStream::Map::Map(std::string const& key, Map& map) : m_stream(map.stream()) +PropertyStream::Map::Map(std::string const& key, Map& map) : stream_(map.stream()) { - m_stream.map_begin(key); + stream_.mapBegin(key); } -PropertyStream::Map::Map(std::string const& key, PropertyStream& stream) : m_stream(stream) +PropertyStream::Map::Map(std::string const& key, PropertyStream& stream) : stream_(stream) { - m_stream.map_begin(key); + stream_.mapBegin(key); } PropertyStream::Map::~Map() { - m_stream.map_end(); + stream_.mapEnd(); } PropertyStream& PropertyStream::Map::stream() { - return m_stream; + return stream_; } PropertyStream const& PropertyStream::Map::stream() const { - return m_stream; + return stream_; } PropertyStream::Proxy @@ -119,31 +119,31 @@ PropertyStream::Map::operator[](std::string const& key) // //------------------------------------------------------------------------------ -PropertyStream::Set::Set(std::string const& key, Map& map) : m_stream(map.stream()) +PropertyStream::Set::Set(std::string const& key, Map& map) : stream_(map.stream()) { - m_stream.array_begin(key); + stream_.arrayBegin(key); } -PropertyStream::Set::Set(std::string const& key, PropertyStream& stream) : m_stream(stream) +PropertyStream::Set::Set(std::string const& key, PropertyStream& stream) : stream_(stream) { - m_stream.array_begin(key); + stream_.arrayBegin(key); } PropertyStream::Set::~Set() { - m_stream.array_end(); + stream_.arrayEnd(); } PropertyStream& PropertyStream::Set::stream() { - return m_stream; + return stream_; } PropertyStream const& PropertyStream::Set::stream() const { - return m_stream; + return stream_; } //------------------------------------------------------------------------------ @@ -152,7 +152,7 @@ PropertyStream::Set::stream() const // //------------------------------------------------------------------------------ -PropertyStream::Source::Source(std::string name) : m_name(std::move(name)), item_(this) +PropertyStream::Source::Source(std::string name) : name_(std::move(name)), item_(this) { } @@ -167,7 +167,7 @@ PropertyStream::Source::~Source() std::string const& PropertyStream::Source::name() const { - return m_name; + return name_; } void @@ -177,7 +177,7 @@ PropertyStream::Source::add(Source& source) XRPL_ASSERT( source.parent_ == nullptr, "beast::PropertyStream::Source::add : null source parent"); - children_.push_back(source.item_); + children_.pushBack(source.item_); source.parent_ = this; } @@ -188,7 +188,7 @@ PropertyStream::Source::remove(Source& child) XRPL_ASSERT( child.parent_ == this, "beast::PropertyStream::Source::remove : child parent match"); - children_.erase(children_.iterator_to(child.item_)); + children_.erase(children_.iteratorTo(child.item_)); child.parent_ = nullptr; } @@ -198,7 +198,7 @@ PropertyStream::Source::removeAll() std::scoped_lock const _(lock_); for (auto iter = children_.begin(); iter != children_.end();) { - std::scoped_lock const _cl((*iter)->lock_); + std::scoped_lock const cl((*iter)->lock_); remove(*(*iter)); } } @@ -206,16 +206,16 @@ PropertyStream::Source::removeAll() //------------------------------------------------------------------------------ void -PropertyStream::Source::write_one(PropertyStream& stream) +PropertyStream::Source::writeOne(PropertyStream& stream) { - Map map(m_name, stream); + Map map(name_, stream); onWrite(map); } void PropertyStream::Source::write(PropertyStream& stream) { - Map map(m_name, stream); + Map map(name_, stream); onWrite(map); std::scoped_lock const _(lock_); @@ -238,32 +238,32 @@ PropertyStream::Source::write(PropertyStream& stream, std::string const& path) } else { - result.first->write_one(stream); + result.first->writeOne(stream); } } std::pair PropertyStream::Source::find(std::string path) { - bool const deep(peel_trailing_slashstar(&path)); - bool const rooted(peel_leading_slash(&path)); + bool const deep(peelTrailingSlashstar(&path)); + bool const rooted(peelLeadingSlash(&path)); Source* source(this); if (!path.empty()) { if (!rooted) { - std::string const name(peel_name(&path)); - source = find_one_deep(name); + std::string const name(peelName(&path)); + source = findOneDeep(name); if (source == nullptr) return std::make_pair(nullptr, deep); } - source = source->find_path(path); + source = source->findPath(path); } return std::make_pair(source, deep); } bool -PropertyStream::Source::peel_leading_slash(std::string* path) +PropertyStream::Source::peelLeadingSlash(std::string* path) { if (!path->empty() && path->front() == '/') { @@ -274,7 +274,7 @@ PropertyStream::Source::peel_leading_slash(std::string* path) } bool -PropertyStream::Source::peel_trailing_slashstar(std::string* path) +PropertyStream::Source::peelTrailingSlashstar(std::string* path) { bool found(false); if (path->empty()) @@ -290,7 +290,7 @@ PropertyStream::Source::peel_trailing_slashstar(std::string* path) } std::string -PropertyStream::Source::peel_name(std::string* path) +PropertyStream::Source::peelName(std::string* path) { if (path->empty()) return ""; @@ -314,16 +314,16 @@ PropertyStream::Source::peel_name(std::string* path) // Recursive search through the whole tree until name is found PropertyStream::Source* -PropertyStream::Source::find_one_deep(std::string const& name) +PropertyStream::Source::findOneDeep(std::string const& name) { - Source* found = find_one(name); // NOLINT(misc-const-correctness) + Source* found = findOne(name); // NOLINT TODO if (found != nullptr) return found; std::scoped_lock const _(lock_); for (auto& s : children_) { - found = s.source().find_one_deep(name); + found = s.source().findOneDeep(name); if (found != nullptr) return found; } @@ -331,17 +331,17 @@ PropertyStream::Source::find_one_deep(std::string const& name) } PropertyStream::Source* -PropertyStream::Source::find_path(std::string path) +PropertyStream::Source::findPath(std::string path) { if (path.empty()) return this; Source* source(this); do { - std::string const name(peel_name(&path)); + std::string const name(peelName(&path)); if (name.empty()) break; - source = source->find_one(name); + source = source->findOne(name); } while (source != nullptr); return source; } @@ -349,12 +349,12 @@ PropertyStream::Source::find_path(std::string path) // This function only looks at immediate children // If no immediate children match, then return nullptr PropertyStream::Source* -PropertyStream::Source::find_one(std::string const& name) +PropertyStream::Source::findOne(std::string const& name) { std::scoped_lock const _(lock_); for (auto& s : children_) { - if (s.source().m_name == name) + if (s.source().name_ == name) return &s.source(); } return nullptr; @@ -387,85 +387,85 @@ PropertyStream::add(std::string const& key, bool value) void PropertyStream::add(std::string const& key, char value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, signed char value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, unsigned char value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, short value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, unsigned short value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, int value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, unsigned int value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, long value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, unsigned long value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, long long value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, unsigned long long value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, float value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, double value) { - lexical_add(key, value); + lexicalAdd(key, value); } void PropertyStream::add(std::string const& key, long double value) { - lexical_add(key, value); + lexicalAdd(key, value); } void @@ -484,85 +484,85 @@ PropertyStream::add(bool value) void PropertyStream::add(char value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(signed char value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(unsigned char value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(short value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(unsigned short value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(int value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(unsigned int value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(long value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(unsigned long value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(long long value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(unsigned long long value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(float value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(double value) { - lexical_add(value); + lexicalAdd(value); } void PropertyStream::add(long double value) { - lexical_add(value); + lexicalAdd(value); } } // namespace beast diff --git a/src/libxrpl/conditions/Condition.cpp b/src/libxrpl/conditions/Condition.cpp index ce3b55a827..004778bc4e 100644 --- a/src/libxrpl/conditions/Condition.cpp +++ b/src/libxrpl/conditions/Condition.cpp @@ -52,7 +52,7 @@ namespace detail { // ed25519Sha256 (4) // } -constexpr std::size_t fingerprintSize = 32; +constexpr std::size_t kFINGERPRINT_SIZE = 32; std::unique_ptr loadSimpleSha256(Type type, Slice s, std::error_code& ec) @@ -66,19 +66,19 @@ loadSimpleSha256(Type type, Slice s, std::error_code& ec) if (!isPrimitive(p) || !isContextSpecific(p)) { - ec = error::incorrect_encoding; + ec = Error::IncorrectEncoding; return {}; } if (p.tag != 0) { - ec = error::unexpected_tag; + ec = Error::UnexpectedTag; return {}; } - if (p.length != fingerprintSize) + if (p.length != kFINGERPRINT_SIZE) { - ec = error::fingerprint_size; + ec = Error::FingerprintSize; return {}; } @@ -94,13 +94,13 @@ loadSimpleSha256(Type type, Slice s, std::error_code& ec) if (!isPrimitive(p) || !isContextSpecific(p)) { - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return {}; } if (p.tag != 1) { - ec = error::unexpected_tag; + ec = Error::UnexpectedTag; return {}; } @@ -111,16 +111,16 @@ loadSimpleSha256(Type type, Slice s, std::error_code& ec) if (!s.empty()) { - ec = error::trailing_garbage; + ec = Error::TrailingGarbage; return {}; } switch (type) { - case Type::preimageSha256: - if (cost > PreimageSha256::maxPreimageLength) + case Type::PreimageSha256: + if (cost > PreimageSha256::kMAX_PREIMAGE_LENGTH) { - ec = error::preimage_too_long; + ec = Error::PreimageTooLong; return {}; } break; @@ -149,7 +149,7 @@ Condition::deserialize(Slice s, std::error_code& ec) // } if (s.empty()) { - ec = error::buffer_empty; + ec = Error::BufferEmpty; return {}; } @@ -163,19 +163,19 @@ Condition::deserialize(Slice s, std::error_code& ec) // types if (!isConstructed(p) || !isContextSpecific(p)) { - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return {}; } if (p.length > s.size()) { - ec = error::buffer_underfull; + ec = Error::BufferUnderfull; return {}; } - if (s.size() > maxSerializedCondition) + if (s.size() > kMAX_SERIALIZED_CONDITION) { - ec = error::large_size; + ec = Error::LargeSize; return {}; } @@ -184,35 +184,35 @@ Condition::deserialize(Slice s, std::error_code& ec) switch (p.tag) { case 0: // PreimageSha256 - c = detail::loadSimpleSha256(Type::preimageSha256, Slice(s.data(), p.length), ec); + c = detail::loadSimpleSha256(Type::PreimageSha256, Slice(s.data(), p.length), ec); if (!ec) s += p.length; break; case 1: // PrefixSha256 - ec = error::unsupported_type; + ec = Error::UnsupportedType; return {}; case 2: // ThresholdSha256 - ec = error::unsupported_type; + ec = Error::UnsupportedType; return {}; case 3: // RsaSha256 - ec = error::unsupported_type; + ec = Error::UnsupportedType; return {}; case 4: // Ed25519Sha256 - ec = error::unsupported_type; + ec = Error::UnsupportedType; return {}; default: - ec = error::unknown_type; + ec = Error::UnknownType; return {}; } if (!s.empty()) { - ec = error::trailing_garbage; + ec = Error::TrailingGarbage; return {}; } diff --git a/src/libxrpl/conditions/Fulfillment.cpp b/src/libxrpl/conditions/Fulfillment.cpp index d1f48bfd7c..52f89a6150 100644 --- a/src/libxrpl/conditions/Fulfillment.cpp +++ b/src/libxrpl/conditions/Fulfillment.cpp @@ -53,7 +53,7 @@ Fulfillment::deserialize(Slice s, std::error_code& ec) if (s.empty()) { - ec = error::buffer_empty; + ec = Error::BufferEmpty; return nullptr; } @@ -66,25 +66,25 @@ Fulfillment::deserialize(Slice s, std::error_code& ec) // All fulfillments are context-specific, constructed types if (!isConstructed(p) || !isContextSpecific(p)) { - ec = error::malformed_encoding; + ec = Error::MalformedEncoding; return nullptr; } if (p.length > s.size()) { - ec = error::buffer_underfull; + ec = Error::BufferUnderfull; return {}; } if (p.length < s.size()) { - ec = error::buffer_overfull; + ec = Error::BufferOverfull; return {}; } - if (p.length > maxSerializedFulfillment) + if (p.length > kMAX_SERIALIZED_FULFILLMENT) { - ec = error::large_size; + ec = Error::LargeSize; return {}; } @@ -93,40 +93,40 @@ Fulfillment::deserialize(Slice s, std::error_code& ec) using TagType = decltype(p.tag); switch (p.tag) { - case safe_cast(Type::preimageSha256): + case safeCast(Type::PreimageSha256): f = PreimageSha256::deserialize(Slice(s.data(), p.length), ec); if (ec) return {}; s += p.length; break; - case safe_cast(Type::prefixSha256): - ec = error::unsupported_type; + case safeCast(Type::PrefixSha256): + ec = Error::UnsupportedType; return {}; break; - case safe_cast(Type::thresholdSha256): - ec = error::unsupported_type; + case safeCast(Type::ThresholdSha256): + ec = Error::UnsupportedType; return {}; break; - case safe_cast(Type::rsaSha256): - ec = error::unsupported_type; + case safeCast(Type::RsaSha256): + ec = Error::UnsupportedType; return {}; break; - case safe_cast(Type::ed25519Sha256): - ec = error::unsupported_type; + case safeCast(Type::Ed25519Sha256): + ec = Error::UnsupportedType; return {}; default: - ec = error::unknown_type; + ec = Error::UnknownType; return {}; } if (!s.empty()) { - ec = error::trailing_garbage; + ec = Error::TrailingGarbage; return {}; } diff --git a/src/libxrpl/conditions/error.cpp b/src/libxrpl/conditions/error.cpp index 44fc17265a..a26a153975 100644 --- a/src/libxrpl/conditions/error.cpp +++ b/src/libxrpl/conditions/error.cpp @@ -9,10 +9,10 @@ namespace xrpl::cryptoconditions { namespace detail { -class cryptoconditions_error_category : public std::error_category +class CryptoconditionsErrorCategory : public std::error_category { public: - explicit cryptoconditions_error_category() = default; + explicit CryptoconditionsErrorCategory() = default; [[nodiscard]] char const* name() const noexcept override @@ -23,57 +23,57 @@ public: [[nodiscard]] std::string message(int ev) const override { - switch (safe_cast(ev)) + switch (safeCast(ev)) { - case error::unsupported_type: + case Error::UnsupportedType: return "Specification: Requested type not supported."; - case error::unsupported_subtype: + case Error::UnsupportedSubtype: return "Specification: Requested subtype not supported."; - case error::unknown_type: + case Error::UnknownType: return "Specification: Requested type not recognized."; - case error::unknown_subtype: + case Error::UnknownSubtype: return "Specification: Requested subtypes not recognized."; - case error::fingerprint_size: + case Error::FingerprintSize: return "Specification: Incorrect fingerprint size."; - case error::incorrect_encoding: + case Error::IncorrectEncoding: return "Specification: Incorrect encoding."; - case error::trailing_garbage: + case Error::TrailingGarbage: return "Bad buffer: contains trailing garbage."; - case error::buffer_empty: + case Error::BufferEmpty: return "Bad buffer: no data."; - case error::buffer_overfull: + case Error::BufferOverfull: return "Bad buffer: overfull."; - case error::buffer_underfull: + case Error::BufferUnderfull: return "Bad buffer: underfull."; - case error::malformed_encoding: + case Error::MalformedEncoding: return "Malformed DER encoding."; - case error::unexpected_tag: + case Error::UnexpectedTag: return "Malformed DER encoding: Unexpected tag."; - case error::short_preamble: + case Error::ShortPreamble: return "Malformed DER encoding: Short preamble."; - case error::long_tag: + case Error::LongTag: return "Implementation limit: Overlong tag."; - case error::large_size: + case Error::LargeSize: return "Implementation limit: Large payload."; - case error::preimage_too_long: + case Error::PreimageTooLong: return "Implementation limit: Specified preimage is too long."; - case error::generic: + case Error::Generic: default: return "generic error"; } @@ -99,20 +99,19 @@ public: }; inline std::error_category const& -get_cryptoconditions_error_category() +getCryptoconditionsErrorCategory() { - static cryptoconditions_error_category const cat{}; - return cat; + static CryptoconditionsErrorCategory const kCAT{}; + return kCAT; } } // namespace detail std::error_code -make_error_code(error ev) +make_error_code(Error ev) { return std::error_code{ - safe_cast>(ev), - detail::get_cryptoconditions_error_category()}; + safeCast>(ev), detail::getCryptoconditionsErrorCategory()}; } } // namespace xrpl::cryptoconditions diff --git a/src/libxrpl/core/HashRouter.cpp b/src/libxrpl/core/HashRouter.cpp index ecc2aa9f14..a3265bfcfd 100644 --- a/src/libxrpl/core/HashRouter.cpp +++ b/src/libxrpl/core/HashRouter.cpp @@ -71,7 +71,7 @@ HashRouter::shouldProcess( uint256 const& key, PeerShortID peer, HashRouterFlags& flags, - std::chrono::seconds tx_interval) + std::chrono::seconds txInterval) { std::scoped_lock const lock(mutex_); @@ -79,7 +79,7 @@ HashRouter::shouldProcess( auto& s = result.first; s.addPeer(peer); flags = s.getFlags(); - return s.shouldProcess(suppressionMap_.clock().now(), tx_interval); + return s.shouldProcess(suppressionMap_.clock().now(), txInterval); } HashRouterFlags diff --git a/src/libxrpl/core/detail/Job.cpp b/src/libxrpl/core/detail/Job.cpp index 069cc7f216..a1b88864d7 100644 --- a/src/libxrpl/core/detail/Job.cpp +++ b/src/libxrpl/core/detail/Job.cpp @@ -11,11 +11,11 @@ namespace xrpl { -Job::Job() : mType(jtINVALID), mJobIndex(0) +Job::Job() : type_(JtInvalid), jobIndex_(0) { } -Job::Job(JobType type, std::uint64_t index) : mType(type), mJobIndex(index) +Job::Job(JobType type, std::uint64_t index) : type_(type), jobIndex_(index) { } @@ -25,83 +25,83 @@ Job::Job( std::uint64_t index, LoadMonitor& lm, std::function const& job) - : mType(type), mJobIndex(index), mJob(job), mName(name), m_queue_time(clock_type::now()) + : type_(type), jobIndex_(index), job_(job), name_(name), queue_time_(clock_type::now()) { - m_loadEvent = std::make_shared(std::ref(lm), name, false); + loadEvent_ = std::make_shared(std::ref(lm), name, false); } JobType Job::getType() const { - return mType; + return type_; } Job::clock_type::time_point const& -Job::queue_time() const +Job::queueTime() const { - return m_queue_time; + return queue_time_; } void Job::doJob() { - beast::setCurrentThreadName("j:" + mName); - m_loadEvent->start(); - m_loadEvent->setName(mName); + beast::setCurrentThreadName("j:" + name_); + loadEvent_->start(); + loadEvent_->setName(name_); - mJob(); + job_(); // Destroy the lambda, otherwise we won't include // its duration in the time measurement - mJob = nullptr; + job_ = nullptr; } bool Job::operator>(Job const& j) const { - if (mType < j.mType) + if (type_ < j.type_) return true; - if (mType > j.mType) + if (type_ > j.type_) return false; - return mJobIndex > j.mJobIndex; + return jobIndex_ > j.jobIndex_; } bool Job::operator>=(Job const& j) const { - if (mType < j.mType) + if (type_ < j.type_) return true; - if (mType > j.mType) + if (type_ > j.type_) return false; - return mJobIndex >= j.mJobIndex; + return jobIndex_ >= j.jobIndex_; } bool Job::operator<(Job const& j) const { - if (mType < j.mType) + if (type_ < j.type_) return false; - if (mType > j.mType) + if (type_ > j.type_) return true; - return mJobIndex < j.mJobIndex; + return jobIndex_ < j.jobIndex_; } bool Job::operator<=(Job const& j) const { - if (mType < j.mType) + if (type_ < j.type_) return false; - if (mType > j.mType) + if (type_ > j.type_) return true; - return mJobIndex <= j.mJobIndex; + return jobIndex_ <= j.jobIndex_; } } // namespace xrpl diff --git a/src/libxrpl/core/detail/JobQueue.cpp b/src/libxrpl/core/detail/JobQueue.cpp index 9e6756e0c0..06a2d226e1 100644 --- a/src/libxrpl/core/detail/JobQueue.cpp +++ b/src/libxrpl/core/detail/JobQueue.cpp @@ -27,29 +27,29 @@ JobQueue::JobQueue( beast::Journal journal, Logs& logs, perf::PerfLog& perfLog) - : m_journal(journal) - , m_invalidJobData(JobTypes::instance().getInvalid(), collector, logs) - , m_workers(*this, &perfLog, "JobQueue", threadCount) + : journal_(journal) + , invalidJobData_(JobTypes::instance().getInvalid(), collector, logs) + , workers_(*this, &perfLog, "JobQueue", threadCount) , perfLog_(perfLog) - , m_collector(collector) + , collector_(collector) { - JLOG(m_journal.info()) << "Using " << threadCount << " threads"; + JLOG(journal_.info()) << "Using " << threadCount << " threads"; - hook = m_collector->make_hook(std::bind(&JobQueue::collect, this)); - job_count = m_collector->make_gauge("job_count"); + hook_ = collector_->makeHook(std::bind(&JobQueue::collect, this)); + job_count_ = collector_->makeGauge("job_count"); { - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); for (auto const& x : JobTypes::instance()) { JobTypeInfo const& jt = x.second; // And create dynamic information for all jobs - auto const result(m_jobData.emplace( + auto const result(jobData_.emplace( std::piecewise_construct, std::forward_as_tuple(jt.type()), - std::forward_as_tuple(jt, m_collector, logs))); + std::forward_as_tuple(jt, collector_, logs))); XRPL_ASSERT(result.second == true, "xrpl::JobQueue::JobQueue : jobs added"); (void)result.second; } @@ -59,52 +59,52 @@ JobQueue::JobQueue( JobQueue::~JobQueue() { // Must unhook before destroying - hook = beast::insight::Hook(); + hook_ = beast::insight::Hook(); } void JobQueue::collect() { - std::scoped_lock const lock(m_mutex); - job_count = m_jobSet.size(); + std::scoped_lock const lock(mutex_); + job_count_ = jobSet_.size(); } bool JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction const& func) { - XRPL_ASSERT(type != jtINVALID, "xrpl::JobQueue::addRefCountedJob : valid input job type"); + XRPL_ASSERT(type != JtInvalid, "xrpl::JobQueue::addRefCountedJob : valid input job type"); - auto iter(m_jobData.find(type)); + auto iter(jobData_.find(type)); XRPL_ASSERT( - iter != m_jobData.end(), "xrpl::JobQueue::addRefCountedJob : job type found in jobs"); - if (iter == m_jobData.end()) + iter != jobData_.end(), "xrpl::JobQueue::addRefCountedJob : job type found in jobs"); + if (iter == jobData_.end()) return false; - JLOG(m_journal.debug()) << __func__ << " : Adding job : " << name << " : " << type; + JLOG(journal_.debug()) << __func__ << " : Adding job : " << name << " : " << type; JobTypeData& data(iter->second); // FIXME: Workaround incorrect client shutdown ordering // do not add jobs to a queue with no threads XRPL_ASSERT( - (type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) || m_workers.getNumberOfThreads() > 0, + (type >= JtClient && type <= JtClientWebsocket) || workers_.getNumberOfThreads() > 0, "xrpl::JobQueue::addRefCountedJob : threads available or job " "requires no threads"); { - std::scoped_lock const lock(m_mutex); - auto result = m_jobSet.emplace(type, name, ++m_lastJob, data.load(), func); + std::scoped_lock const lock(mutex_); + auto result = jobSet_.emplace(type, name, ++lastJob_, data.load(), func); auto const& job = *result.first; JobType const type(job.getType()); - XRPL_ASSERT(type != jtINVALID, "xrpl::JobQueue::addRefCountedJob : has valid job type"); - XRPL_ASSERT(m_jobSet.contains(job), "xrpl::JobQueue::addRefCountedJob : job found"); + XRPL_ASSERT(type != JtInvalid, "xrpl::JobQueue::addRefCountedJob : has valid job type"); + XRPL_ASSERT(jobSet_.contains(job), "xrpl::JobQueue::addRefCountedJob : job found"); perfLog_.jobQueue(type); JobTypeData& data(getJobTypeData(type)); if (data.waiting + data.running < getJobLimit(type)) { - m_workers.addTask(); + workers_.addTask(); } else { @@ -119,21 +119,21 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co int JobQueue::getJobCount(JobType t) const { - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); - JobDataMap::const_iterator const c = m_jobData.find(t); + JobDataMap::const_iterator const c = jobData_.find(t); - return (c == m_jobData.end()) ? 0 : c->second.waiting; + return (c == jobData_.end()) ? 0 : c->second.waiting; } int JobQueue::getJobCountTotal(JobType t) const { - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); - JobDataMap::const_iterator const c = m_jobData.find(t); + JobDataMap::const_iterator const c = jobData_.find(t); - return (c == m_jobData.end()) ? 0 : (c->second.waiting + c->second.running); + return (c == jobData_.end()) ? 0 : (c->second.waiting + c->second.running); } int @@ -142,9 +142,9 @@ JobQueue::getJobCountGE(JobType t) const // return the number of jobs at this priority level or greater int ret = 0; - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); - for (auto const& x : m_jobData) + for (auto const& x : jobData_) { if (x.first >= t) ret += x.second.waiting; @@ -156,10 +156,10 @@ JobQueue::getJobCountGE(JobType t) const std::unique_ptr JobQueue::makeLoadEvent(JobType t, std::string const& name) { - JobDataMap::iterator const iter(m_jobData.find(t)); - XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::makeLoadEvent : valid job type input"); + JobDataMap::iterator const iter(jobData_.find(t)); + XRPL_ASSERT(iter != jobData_.end(), "xrpl::JobQueue::makeLoadEvent : valid job type input"); - if (iter == m_jobData.end()) + if (iter == jobData_.end()) return {}; return std::make_unique(iter->second.load(), name, true); @@ -169,36 +169,36 @@ void JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed) { if (isStopped()) - LogicError("JobQueue::addLoadEvents() called after JobQueue stopped"); + logicError("JobQueue::addLoadEvents() called after JobQueue stopped"); - JobDataMap::iterator const iter(m_jobData.find(t)); - XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::addLoadEvents : valid job type input"); + JobDataMap::iterator const iter(jobData_.find(t)); + XRPL_ASSERT(iter != jobData_.end(), "xrpl::JobQueue::addLoadEvents : valid job type input"); iter->second.load().addSamples(count, elapsed); } bool JobQueue::isOverloaded() { - return std::ranges::any_of(m_jobData, [](auto& entry) { return entry.second.load().isOver(); }); + return std::ranges::any_of(jobData_, [](auto& entry) { return entry.second.load().isOver(); }); } -Json::Value +json::Value JobQueue::getJson(int c) { using namespace std::chrono_literals; - Json::Value ret(Json::objectValue); + json::Value ret(json::ObjectValue); - ret["threads"] = m_workers.getNumberOfThreads(); + ret["threads"] = workers_.getNumberOfThreads(); - Json::Value priorities = Json::arrayValue; + json::Value priorities = json::ArrayValue; - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); - for (auto& x : m_jobData) + for (auto& x : jobData_) { - XRPL_ASSERT(x.first != jtINVALID, "xrpl::JobQueue::getJson : valid job type"); + XRPL_ASSERT(x.first != JtInvalid, "xrpl::JobQueue::getJson : valid job type"); - if (x.first == jtGENERIC) + if (x.first == JtGeneric) continue; JobTypeData& data(x.second); @@ -210,7 +210,7 @@ JobQueue::getJson(int c) if ((stats.count != 0) || (waiting != 0) || (stats.latencyPeak != 0ms) || (running != 0)) { - Json::Value& pri = priorities.append(Json::objectValue); + json::Value& pri = priorities.append(json::ObjectValue); pri["job_type"] = data.name(); @@ -242,20 +242,20 @@ JobQueue::getJson(int c) void JobQueue::rendezvous() { - std::unique_lock lock(m_mutex); - cv_.wait(lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); + std::unique_lock lock(mutex_); + cv_.wait(lock, [this] { return processCount_ == 0 && jobSet_.empty(); }); } JobTypeData& JobQueue::getJobTypeData(JobType type) { - JobDataMap::iterator const c(m_jobData.find(type)); - XRPL_ASSERT(c != m_jobData.end(), "xrpl::JobQueue::getJobTypeData : valid job type input"); + JobDataMap::iterator const c(jobData_.find(type)); + XRPL_ASSERT(c != jobData_.end(), "xrpl::JobQueue::getJobTypeData : valid job type input"); - // NIKB: This is ugly and I hate it. We must remove jtINVALID completely + // NIKB: This is ugly and I hate it. We must remove JtInvalid completely // and use something sane. - if (c == m_jobData.end()) - return m_invalidJobData; + if (c == jobData_.end()) + return invalidJobData_; return c->second; } @@ -265,17 +265,17 @@ JobQueue::stop() { stopping_ = true; using namespace std::chrono_literals; - jobCounter_.join("JobQueue", 1s, m_journal); + jobCounter_.join("JobQueue", 1s, journal_); { // After the JobCounter is joined, all jobs have finished executing // (i.e. returned from `Job::doJob`) and no more are being accepted, // but there may still be some threads between the return of // `Job::doJob` and the return of `JobQueue::processTask`. That is why // we must wait on the condition variable to make these assertions. - std::unique_lock lock(m_mutex); - cv_.wait(lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); - XRPL_ASSERT(m_processCount == 0, "xrpl::JobQueue::stop : all processes completed"); - XRPL_ASSERT(m_jobSet.empty(), "xrpl::JobQueue::stop : all jobs completed"); + std::unique_lock lock(mutex_); + cv_.wait(lock, [this] { return processCount_ == 0 && jobSet_.empty(); }); + XRPL_ASSERT(processCount_ == 0, "xrpl::JobQueue::stop : all processes completed"); + XRPL_ASSERT(jobSet_.empty(), "xrpl::JobQueue::stop : all jobs completed"); XRPL_ASSERT(nSuspend_ == 0, "xrpl::JobQueue::stop : no coros suspended"); stopped_ = true; } @@ -290,13 +290,13 @@ JobQueue::isStopped() const void JobQueue::getNextJob(Job& job) { - XRPL_ASSERT(!m_jobSet.empty(), "xrpl::JobQueue::getNextJob : non-empty jobs"); + XRPL_ASSERT(!jobSet_.empty(), "xrpl::JobQueue::getNextJob : non-empty jobs"); std::set::const_iterator iter; - for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter) + for (iter = jobSet_.begin(); iter != jobSet_.end(); ++iter) { JobType const type = iter->getType(); - XRPL_ASSERT(type != jtINVALID, "xrpl::JobQueue::getNextJob : valid job type"); + XRPL_ASSERT(type != JtInvalid, "xrpl::JobQueue::getNextJob : valid job type"); JobTypeData& data(getJobTypeData(type)); XRPL_ASSERT( @@ -312,15 +312,15 @@ JobQueue::getNextJob(Job& job) } } - XRPL_ASSERT(iter != m_jobSet.end(), "xrpl::JobQueue::getNextJob : found next job"); + XRPL_ASSERT(iter != jobSet_.end(), "xrpl::JobQueue::getNextJob : found next job"); job = *iter; - m_jobSet.erase(iter); + jobSet_.erase(iter); } void JobQueue::finishJob(JobType type) { - XRPL_ASSERT(type != jtINVALID, "xrpl::JobQueue::finishJob : valid input job type"); + XRPL_ASSERT(type != JtInvalid, "xrpl::JobQueue::finishJob : valid input job type"); JobTypeData& data = getJobTypeData(type); @@ -332,7 +332,7 @@ JobQueue::finishJob(JobType type) "xrpl::JobQueue::finishJob : job limit"); --data.deferred; - m_workers.addTask(); + workers_.addTask(); } --data.running; @@ -341,47 +341,47 @@ JobQueue::finishJob(JobType type) void JobQueue::processTask(int instance) { - JobType type = jtINVALID; + JobType type = JtInvalid; { using namespace std::chrono; - Job::clock_type::time_point const start_time(Job::clock_type::now()); + Job::clock_type::time_point const startTime(Job::clock_type::now()); { Job job; { - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); getNextJob(job); - ++m_processCount; + ++processCount_; } type = job.getType(); JobTypeData const& data(getJobTypeData(type)); - JLOG(m_journal.trace()) << "Doing " << data.name() << "job"; + JLOG(journal_.trace()) << "Doing " << data.name() << "job"; // The amount of time that the job was in the queue - auto const q_time = ceil(start_time - job.queue_time()); - perfLog_.jobStart(type, q_time, start_time, instance); + auto const qTime = ceil(startTime - job.queueTime()); + perfLog_.jobStart(type, qTime, startTime, instance); job.doJob(); // The amount of time it took to execute the job - auto const x_time = ceil(Job::clock_type::now() - start_time); + auto const xTime = ceil(Job::clock_type::now() - startTime); - if (x_time >= 10ms || q_time >= 10ms) + if (xTime >= 10ms || qTime >= 10ms) { - getJobTypeData(type).dequeue.notify(q_time); - getJobTypeData(type).execute.notify(x_time); + getJobTypeData(type).dequeue.notify(qTime); + getJobTypeData(type).execute.notify(xTime); } - perfLog_.jobFinish(type, x_time, instance); + perfLog_.jobFinish(type, xTime, instance); } } { - std::scoped_lock const lock(m_mutex); + std::scoped_lock const lock(mutex_); // Job should be destroyed before stopping // otherwise destructors with side effects can access // parent objects that are already destroyed. finishJob(type); - if (--m_processCount == 0 && m_jobSet.empty()) + if (--processCount_ == 0 && jobSet_.empty()) cv_.notify_all(); } @@ -393,7 +393,7 @@ int JobQueue::getJobLimit(JobType type) { JobTypeInfo const& j(JobTypes::instance().get(type)); - XRPL_ASSERT(j.type() != jtINVALID, "xrpl::JobQueue::getJobLimit : valid job type"); + XRPL_ASSERT(j.type() != JtInvalid, "xrpl::JobQueue::getJobLimit : valid job type"); return j.limit(); } diff --git a/src/libxrpl/core/detail/LoadMonitor.cpp b/src/libxrpl/core/detail/LoadMonitor.cpp index aea535fb81..95e0e7d3b9 100644 --- a/src/libxrpl/core/detail/LoadMonitor.cpp +++ b/src/libxrpl/core/detail/LoadMonitor.cpp @@ -28,11 +28,11 @@ LoadMonitor::Stats::Stats() : latencyAvg(0), latencyPeak(0) //------------------------------------------------------------------------------ LoadMonitor::LoadMonitor(beast::Journal j) - : mLatencyMSAvg(0) - , mLatencyMSPeak(0) - , mTargetLatencyAvg(0) - , mTargetLatencyPk(0) - , mLastUpdate(UptimeClock::now()) + : latencyMSAvg_(0) + , latencyMSPeak_(0) + , targetLatencyAvg_(0) + , targetLatencyPk_(0) + , lastUpdate_(UptimeClock::now()) , j_(j) { } @@ -48,18 +48,18 @@ LoadMonitor::update() { using namespace std::chrono_literals; auto now = UptimeClock::now(); - if (now == mLastUpdate) // current + if (now == lastUpdate_) // current return; // VFALCO TODO Why 8? - if ((now < mLastUpdate) || (now > (mLastUpdate + 8s))) + if ((now < lastUpdate_) || (now > (lastUpdate_ + 8s))) { // way out of date - mCounts = 0; - mLatencyEvents = 0; - mLatencyMSAvg = 0ms; - mLatencyMSPeak = 0ms; - mLastUpdate = now; + counts_ = 0; + latencyEvents_ = 0; + latencyMSAvg_ = 0ms; + latencyMSPeak_ = 0ms; + lastUpdate_ = now; return; } @@ -73,12 +73,12 @@ LoadMonitor::update() */ do { - mLastUpdate += 1s; - mCounts -= ((mCounts + 3) / 4); - mLatencyEvents -= ((mLatencyEvents + 3) / 4); - mLatencyMSAvg -= (mLatencyMSAvg / 4); - mLatencyMSPeak -= (mLatencyMSPeak / 4); - } while (mLastUpdate < now); + lastUpdate_ += 1s; + counts_ -= ((counts_ + 3) / 4); + latencyEvents_ -= ((latencyEvents_ + 3) / 4); + latencyMSAvg_ -= (latencyMSAvg_ / 4); + latencyMSPeak_ -= (latencyMSPeak_ / 4); + } while (lastUpdate_ < now); } void @@ -111,30 +111,30 @@ LoadMonitor::addSamples(int count, std::chrono::milliseconds latency) std::scoped_lock const sl(mutex_); update(); - mCounts += count; - mLatencyEvents += count; - mLatencyMSAvg += latency; - mLatencyMSPeak += latency; + counts_ += count; + latencyEvents_ += count; + latencyMSAvg_ += latency; + latencyMSPeak_ += latency; - auto const latencyPeak = mLatencyEvents * latency * 4 / count; + auto const latencyPeak = latencyEvents_ * latency * 4 / count; - if (mLatencyMSPeak < latencyPeak) - mLatencyMSPeak = latencyPeak; + if (latencyMSPeak_ < latencyPeak) + latencyMSPeak_ = latencyPeak; } void LoadMonitor::setTargetLatency(std::chrono::milliseconds avg, std::chrono::milliseconds pk) { - mTargetLatencyAvg = avg; - mTargetLatencyPk = pk; + targetLatencyAvg_ = avg; + targetLatencyPk_ = pk; } bool LoadMonitor::isOverTarget(std::chrono::milliseconds avg, std::chrono::milliseconds peak) { using namespace std::chrono_literals; - return (mTargetLatencyPk > 0ms && (peak > mTargetLatencyPk)) || - (mTargetLatencyAvg > 0ms && (avg > mTargetLatencyAvg)); + return (targetLatencyPk_ > 0ms && (peak > targetLatencyPk_)) || + (targetLatencyAvg_ > 0ms && (avg > targetLatencyAvg_)); } bool @@ -144,11 +144,11 @@ LoadMonitor::isOver() update(); - if (mLatencyEvents == 0) + if (latencyEvents_ == 0) return false; return isOverTarget( - mLatencyMSAvg / (mLatencyEvents * 4), mLatencyMSPeak / (mLatencyEvents * 4)); + latencyMSAvg_ / (latencyEvents_ * 4), latencyMSPeak_ / (latencyEvents_ * 4)); } LoadMonitor::Stats @@ -161,17 +161,17 @@ LoadMonitor::getStats() update(); - stats.count = mCounts / 4; + stats.count = counts_ / 4; - if (mLatencyEvents == 0) + if (latencyEvents_ == 0) { stats.latencyAvg = 0ms; stats.latencyPeak = 0ms; } else { - stats.latencyAvg = mLatencyMSAvg / (mLatencyEvents * 4); - stats.latencyPeak = mLatencyMSPeak / (mLatencyEvents * 4); + stats.latencyAvg = latencyMSAvg_ / (latencyEvents_ * 4); + stats.latencyPeak = latencyMSPeak_ / (latencyEvents_ * 4); } stats.isOverloaded = isOverTarget(stats.latencyAvg, stats.latencyPeak); diff --git a/src/libxrpl/core/detail/Workers.cpp b/src/libxrpl/core/detail/Workers.cpp index a6f8885a86..991c51b77a 100644 --- a/src/libxrpl/core/detail/Workers.cpp +++ b/src/libxrpl/core/detail/Workers.cpp @@ -15,13 +15,13 @@ Workers::Workers( perf::PerfLog* perfLog, std::string threadNames, int numberOfThreads) - : m_callback(callback) + : callback_(callback) , perfLog_(perfLog) - , m_threadNames(std::move(threadNames)) - , m_semaphore(0) - , m_activeCount(0) - , m_pauseCount(0) - , m_runningTaskCount(0) + , threadNames_(std::move(threadNames)) + , semaphore_(0) + , activeCount_(0) + , pauseCount_(0) + , runningTaskCount_(0) { setNumberOfThreads(numberOfThreads); } @@ -30,13 +30,13 @@ Workers::~Workers() { stop(); - deleteWorkers(m_everyone); + deleteWorkers(everyone_); } int Workers::getNumberOfThreads() const noexcept { - return m_numberOfThreads; + return numberOfThreads_; } // VFALCO NOTE if this function is called quickly to reduce then @@ -46,22 +46,22 @@ Workers::getNumberOfThreads() const noexcept void Workers::setNumberOfThreads(int numberOfThreads) { - static int instance{0}; - if (m_numberOfThreads == numberOfThreads) + static int kINSTANCE{0}; + if (numberOfThreads_ == numberOfThreads) return; if (perfLog_ != nullptr) perfLog_->resizeJobs(numberOfThreads); - if (numberOfThreads > m_numberOfThreads) + if (numberOfThreads > numberOfThreads_) { // Increasing the number of working threads - int const amount = numberOfThreads - m_numberOfThreads; + int const amount = numberOfThreads - numberOfThreads_; for (int i = 0; i < amount; ++i) { // See if we can reuse a paused worker - Worker* worker = m_paused.pop_front(); + Worker* worker = paused_.popFront(); if (worker != nullptr) { @@ -72,26 +72,26 @@ Workers::setNumberOfThreads(int numberOfThreads) } else { - worker = new Worker(*this, m_threadNames, instance++); - m_everyone.push_front(worker); + worker = new Worker(*this, threadNames_, kINSTANCE++); + everyone_.pushFront(worker); } } } else { // Decreasing the number of working threads - int const amount = m_numberOfThreads - numberOfThreads; + int const amount = numberOfThreads_ - numberOfThreads; for (int i = 0; i < amount; ++i) { - ++m_pauseCount; + ++pauseCount_; // Pausing a thread counts as one "internal task" - m_semaphore.notify(); + semaphore_.notify(); } } - m_numberOfThreads = numberOfThreads; + numberOfThreads_ = numberOfThreads; } void @@ -100,24 +100,24 @@ Workers::stop() setNumberOfThreads(0); // Wait until all workers have paused AND no tasks are actively running. - // Both conditions are needed because m_allPaused (mutex-protected) and - // m_runningTaskCount (atomic) are not synchronized under the same lock, - // so m_allPaused can momentarily be true while a task is still finishing. - std::unique_lock lk{m_mut}; - m_cv.wait(lk, [this] { return m_allPaused && numberOfCurrentlyRunningTasks() == 0; }); + // Both conditions are needed because allPaused_ (mutex-protected) and + // runningTaskCount_ (atomic) are not synchronized under the same lock, + // so allPaused_ can momentarily be true while a task is still finishing. + std::unique_lock lk{mut_}; + cv_.wait(lk, [this] { return allPaused_ && numberOfCurrentlyRunningTasks() == 0; }); lk.unlock(); } void Workers::addTask() { - m_semaphore.notify(); + semaphore_.notify(); } int Workers::numberOfCurrentlyRunningTasks() const noexcept { - return m_runningTaskCount.load(); + return runningTaskCount_.load(); } void @@ -125,7 +125,7 @@ Workers::deleteWorkers(beast::LockFreeStack& stack) { for (;;) { - Worker const* const worker = stack.pop_front(); + Worker const* const worker = stack.popFront(); if (worker != nullptr) { @@ -142,7 +142,7 @@ Workers::deleteWorkers(beast::LockFreeStack& stack) //------------------------------------------------------------------------------ Workers::Worker::Worker(Workers& workers, std::string threadName, int const instance) - : m_workers{workers}, threadName_{std::move(threadName)}, instance_{instance} + : workers_{workers}, threadName_{std::move(threadName)}, instance_{instance} { thread_ = std::thread{&Workers::Worker::run, this}; @@ -177,10 +177,10 @@ Workers::Worker::run() // Increment the count of active workers, and if // we are the first one then reset the "all paused" event // - if (++m_workers.m_activeCount == 1) + if (++workers_.activeCount_ == 1) { - std::scoped_lock const lk{m_workers.m_mut}; - m_workers.m_allPaused = false; + std::scoped_lock const lk{workers_.mut_}; + workers_.allPaused_ = false; } for (;;) @@ -190,17 +190,17 @@ Workers::Worker::run() // Acquire a task or "internal task." // - m_workers.m_semaphore.wait(); + workers_.semaphore_.wait(); // See if there's a pause request. This // counts as an "internal task." // - int pauseCount = m_workers.m_pauseCount.load(); + int pauseCount = workers_.pauseCount_.load(); if (pauseCount > 0) { // Try to decrement - pauseCount = --m_workers.m_pauseCount; + pauseCount = --workers_.pauseCount_; if (pauseCount >= 0) { @@ -209,25 +209,25 @@ Workers::Worker::run() } // Undo our decrement - ++m_workers.m_pauseCount; + ++workers_.pauseCount_; } // We couldn't pause so we must have gotten // unblocked in order to process a task. // - ++m_workers.m_runningTaskCount; - m_workers.m_callback.processTask(instance_); + ++workers_.runningTaskCount_; + workers_.callback_.processTask(instance_); // When the running task count drops to zero, wake stop() which - // may be waiting for both m_allPaused and zero running tasks. - // Locking m_mut before notify_all() prevents a lost wakeup: + // may be waiting for both allPaused_ and zero running tasks. + // Locking mut_ before notify_all() prevents a lost wakeup: // it serializes against the predicate check inside stop()'s - // cv.wait(), ensuring the notification is not missed between + // cv_.wait(), ensuring the notification is not missed between // the predicate evaluation and the actual sleep. - if (--m_workers.m_runningTaskCount == 0) + if (--workers_.runningTaskCount_ == 0) { - std::scoped_lock const lk{m_workers.m_mut}; - m_workers.m_cv.notify_all(); + std::scoped_lock const lk{workers_.mut_}; + workers_.cv_.notify_all(); } } @@ -235,16 +235,16 @@ Workers::Worker::run() // guarantee that it will eventually block on its // event object. // - m_workers.m_paused.push_front(this); + workers_.paused_.pushFront(this); // Decrement the count of active workers, and if we // are the last one then signal the "all paused" event. // - if (--m_workers.m_activeCount == 0) + if (--workers_.activeCount_ == 0) { - std::scoped_lock const lk{m_workers.m_mut}; - m_workers.m_allPaused = true; - m_workers.m_cv.notify_all(); + std::scoped_lock const lk{workers_.mut_}; + workers_.allPaused_ = true; + workers_.cv_.notify_all(); } // Set inactive thread name. diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index 8ea4e7007c..30f2c3a5b8 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -21,7 +21,7 @@ namespace xrpl { // RFC 1751 code converted to C++/Boost. // -char const* RFC1751::s_dictionary[2048] = { +char const* RFC1751::dictionary[2048] = { "A", "ABE", "ACE", "ACT", "AD", "ADA", "ADD", "AGO", "AID", "AIM", "AIR", "ALL", "ALP", "AM", "AMY", "AN", "ANA", "AND", "ANN", "ANT", "ANY", "APE", "APS", "APT", "ARC", "ARE", "ARK", "ARM", "ART", "AS", "ASH", "ASK", "AT", "ATE", "AUG", "AUK", @@ -237,10 +237,10 @@ RFC1751::btoe(std::string& strHuman, std::string const& strData) caBuffer[8] = char(p) << 6; - strHuman = std::string() + s_dictionary[extract(caBuffer, 0, 11)] + " " + - s_dictionary[extract(caBuffer, 11, 11)] + " " + s_dictionary[extract(caBuffer, 22, 11)] + - " " + s_dictionary[extract(caBuffer, 33, 11)] + " " + - s_dictionary[extract(caBuffer, 44, 11)] + " " + s_dictionary[extract(caBuffer, 55, 11)]; + strHuman = std::string() + dictionary[extract(caBuffer, 0, 11)] + " " + + dictionary[extract(caBuffer, 11, 11)] + " " + dictionary[extract(caBuffer, 22, 11)] + " " + + dictionary[extract(caBuffer, 33, 11)] + " " + dictionary[extract(caBuffer, 44, 11)] + " " + + dictionary[extract(caBuffer, 55, 11)]; } void @@ -314,7 +314,7 @@ RFC1751::wsrch(std::string const& strWord, int iMin, int iMax) { // Have a range to search. int const iMid = iMin + ((iMax - iMin) / 2); - int const iDir = strWord.compare(s_dictionary[iMid]); + int const iDir = strWord.compare(dictionary[iMid]); if (iDir == 0) { @@ -447,7 +447,7 @@ RFC1751::getWordFromBlob(void const* blob, size_t bytes) hash ^= (hash >> 11); hash += (hash << 15); - return s_dictionary[hash % (sizeof(s_dictionary) / sizeof(s_dictionary[0]))]; + return dictionary[hash % (sizeof(dictionary) / sizeof(dictionary[0]))]; } } // namespace xrpl diff --git a/src/libxrpl/crypto/csprng.cpp b/src/libxrpl/crypto/csprng.cpp index 7aef9b2831..897432fcf1 100644 --- a/src/libxrpl/crypto/csprng.cpp +++ b/src/libxrpl/crypto/csprng.cpp @@ -13,14 +13,14 @@ namespace xrpl { -csprng_engine::csprng_engine() +CsprngEngine::CsprngEngine() { // This is not strictly necessary if (RAND_poll() != 1) Throw("CSPRNG: Initial polling failed"); } -csprng_engine::~csprng_engine() +CsprngEngine::~CsprngEngine() { // This cleanup function is not needed in newer versions of OpenSSL #if (OPENSSL_VERSION_NUMBER < 0x10100000L) @@ -29,7 +29,7 @@ csprng_engine::~csprng_engine() } void -csprng_engine::mix_entropy(void* buffer, std::size_t count) +CsprngEngine::mixEntropy(void* buffer, std::size_t count) { std::array entropy{}; @@ -54,7 +54,7 @@ csprng_engine::mix_entropy(void* buffer, std::size_t count) } void -csprng_engine::operator()(void* ptr, std::size_t count) +CsprngEngine::operator()(void* ptr, std::size_t count) { // RAND_bytes is thread-safe on OpenSSL 1.1.0 and later when compiled // with thread support, so we don't need to grab a mutex. @@ -69,19 +69,19 @@ csprng_engine::operator()(void* ptr, std::size_t count) Throw("CSPRNG: Insufficient entropy"); } -csprng_engine::result_type -csprng_engine::operator()() +CsprngEngine::result_type +CsprngEngine::operator()() { result_type ret = 0; (*this)(&ret, sizeof(result_type)); return ret; } -csprng_engine& -crypto_prng() +CsprngEngine& +cryptoPrng() { - static csprng_engine engine; - return engine; + static CsprngEngine kENGINE; + return kENGINE; } } // namespace xrpl diff --git a/src/libxrpl/crypto/secure_erase.cpp b/src/libxrpl/crypto/secure_erase.cpp index 5b65b342ec..2b24da7548 100644 --- a/src/libxrpl/crypto/secure_erase.cpp +++ b/src/libxrpl/crypto/secure_erase.cpp @@ -7,7 +7,7 @@ namespace xrpl { void -secure_erase(void* dest, std::size_t bytes) +secureErase(void* dest, std::size_t bytes) { OPENSSL_cleanse(dest, bytes); } diff --git a/src/libxrpl/json/JsonPropertyStream.cpp b/src/libxrpl/json/JsonPropertyStream.cpp index ab94223956..b6a151d702 100644 --- a/src/libxrpl/json/JsonPropertyStream.cpp +++ b/src/libxrpl/json/JsonPropertyStream.cpp @@ -6,160 +6,160 @@ namespace xrpl { -JsonPropertyStream::JsonPropertyStream() : m_top(Json::objectValue) +JsonPropertyStream::JsonPropertyStream() : topValue(json::ObjectValue) { - m_stack.reserve(64); - m_stack.push_back(&m_top); + stack.reserve(64); + stack.push_back(&topValue); } -Json::Value const& +json::Value const& JsonPropertyStream::top() const { - return m_top; + return topValue; } void -JsonPropertyStream::map_begin() +JsonPropertyStream::mapBegin() { // top is array - Json::Value& top(*m_stack.back()); - Json::Value& map(top.append(Json::objectValue)); - m_stack.push_back(&map); + json::Value& top(*stack.back()); + json::Value& map(top.append(json::ObjectValue)); + stack.push_back(&map); } void -JsonPropertyStream::map_begin(std::string const& key) +JsonPropertyStream::mapBegin(std::string const& key) { // top is a map - Json::Value& top(*m_stack.back()); - Json::Value& map(top[key] = Json::objectValue); - m_stack.push_back(&map); + json::Value& top(*stack.back()); + json::Value& map(top[key] = json::ObjectValue); + stack.push_back(&map); } void -JsonPropertyStream::map_end() +JsonPropertyStream::mapEnd() { - m_stack.pop_back(); + stack.pop_back(); } void JsonPropertyStream::add(std::string const& key, short v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, unsigned short v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, int v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, unsigned int v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, long v) { - (*m_stack.back())[key] = int(v); + (*stack.back())[key] = int(v); } void JsonPropertyStream::add(std::string const& key, float v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, double v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void JsonPropertyStream::add(std::string const& key, std::string const& v) { - (*m_stack.back())[key] = v; + (*stack.back())[key] = v; } void -JsonPropertyStream::array_begin() +JsonPropertyStream::arrayBegin() { // top is array - Json::Value& top(*m_stack.back()); - Json::Value& vec(top.append(Json::arrayValue)); - m_stack.push_back(&vec); + json::Value& top(*stack.back()); + json::Value& vec(top.append(json::ArrayValue)); + stack.push_back(&vec); } void -JsonPropertyStream::array_begin(std::string const& key) +JsonPropertyStream::arrayBegin(std::string const& key) { // top is a map - Json::Value& top(*m_stack.back()); - Json::Value& vec(top[key] = Json::arrayValue); - m_stack.push_back(&vec); + json::Value& top(*stack.back()); + json::Value& vec(top[key] = json::ArrayValue); + stack.push_back(&vec); } void -JsonPropertyStream::array_end() +JsonPropertyStream::arrayEnd() { - m_stack.pop_back(); + stack.pop_back(); } void JsonPropertyStream::add(short v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(unsigned short v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(int v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(unsigned int v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(long v) { - m_stack.back()->append(int(v)); + stack.back()->append(int(v)); } void JsonPropertyStream::add(float v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(double v) { - m_stack.back()->append(v); + stack.back()->append(v); } void JsonPropertyStream::add(std::string const& v) { - m_stack.back()->append(v); + stack.back()->append(v); } } // namespace xrpl diff --git a/src/libxrpl/json/Output.cpp b/src/libxrpl/json/Output.cpp index 31d74db7e0..14b6617b2f 100644 --- a/src/libxrpl/json/Output.cpp +++ b/src/libxrpl/json/Output.cpp @@ -5,47 +5,47 @@ #include -namespace Json { +namespace json { namespace { void -outputJson(Json::Value const& value, Writer& writer) +outputJson(json::Value const& value, Writer& writer) { switch (value.type()) { - case Json::nullValue: { + case json::NullValue: { writer.output(nullptr); break; } - case Json::intValue: { + case json::IntValue: { writer.output(value.asInt()); break; } - case Json::uintValue: { + case json::UintValue: { writer.output(value.asUInt()); break; } - case Json::realValue: { + case json::RealValue: { writer.output(value.asDouble()); break; } - case Json::stringValue: { + case json::StringValue: { writer.output(value.asString()); break; } - case Json::booleanValue: { + case json::BooleanValue: { writer.output(value.asBool()); break; } - case Json::arrayValue: { - writer.startRoot(Writer::CollectionType::array); + case json::ArrayValue: { + writer.startRoot(Writer::CollectionType::Array); for (auto const& i : value) { writer.rawAppend(); @@ -55,8 +55,8 @@ outputJson(Json::Value const& value, Writer& writer) break; } - case Json::objectValue: { - writer.startRoot(Writer::CollectionType::object); + case json::ObjectValue: { + writer.startRoot(Writer::CollectionType::Object); auto members = value.getMemberNames(); for (auto const& tag : members) { @@ -72,14 +72,14 @@ outputJson(Json::Value const& value, Writer& writer) } // namespace void -outputJson(Json::Value const& value, Output const& out) +outputJson(json::Value const& value, Output const& out) { Writer writer(out); outputJson(value, writer); } std::string -jsonAsString(Json::Value const& value) +jsonAsString(json::Value const& value) { std::string s; Writer writer(stringOutput(s)); @@ -87,4 +87,4 @@ jsonAsString(Json::Value const& value) return s; } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/Writer.cpp b/src/libxrpl/json/Writer.cpp index 188f0749f0..518573ded4 100644 --- a/src/libxrpl/json/Writer.cpp +++ b/src/libxrpl/json/Writer.cpp @@ -12,11 +12,11 @@ #include #include -namespace Json { +namespace json { namespace { -std::map jsonSpecialCharacterEscape = { +std::map gJsonSpecialCharacterEscape = { {'"', "\\\""}, {'\\', "\\\\"}, {'/', "\\/"}, @@ -26,18 +26,18 @@ std::map jsonSpecialCharacterEscape = { {'\r', "\\r"}, {'\t', "\\t"}}; -size_t const jsonEscapeLength = 2; +size_t const kJSON_ESCAPE_LENGTH = 2; // All other JSON punctuation. -char const closeBrace = '}'; -char const closeBracket = ']'; -char const colon = ':'; -char const comma = ','; -char const openBrace = '{'; -char const openBracket = '['; -char const quote = '"'; +char const kCLOSE_BRACE = '}'; +char const kCLOSE_BRACKET = ']'; +char const kCOLON = ':'; +char const kCOMMA = ','; +char const kOPEN_BRACE = '{'; +char const kOPEN_BRACKET = '['; +char const kQUOTE = '"'; -auto const integralFloatsBecomeInts = false; +auto const kINTEGRAL_FLOATS_BECOME_INTS = false; size_t lengthWithoutTrailingZeros(std::string const& s) @@ -52,7 +52,7 @@ lengthWithoutTrailingZeros(std::string const& s) if (hasDecimals) return lastNonZero + 1; - if (integralFloatsBecomeInts || lastNonZero + 2 > s.size()) + if (kINTEGRAL_FLOATS_BECOME_INTS || lastNonZero + 2 > s.size()) return lastNonZero; return lastNonZero + 2; @@ -81,7 +81,7 @@ public: void start(CollectionType ct) { - char const ch = (ct == CollectionType::array) ? openBracket : openBrace; + char const ch = (ct == CollectionType::Array) ? kOPEN_BRACKET : kOPEN_BRACE; output({&ch, 1}); stack_.emplace(Collection{.type = ct}); } @@ -99,24 +99,24 @@ public: markStarted(); std::size_t position = 0, writtenUntil = 0; - output_({"e, 1}); + output_({&kQUOTE, 1}); auto data = bytes.data(); for (; position < bytes.size(); ++position) { - auto i = jsonSpecialCharacterEscape.find(data[position]); - if (i != jsonSpecialCharacterEscape.end()) + auto i = gJsonSpecialCharacterEscape.find(data[position]); + if (i != gJsonSpecialCharacterEscape.end()) { if (writtenUntil < position) { output_({data + writtenUntil, position - writtenUntil}); } - output_({i->second, jsonEscapeLength}); + output_({i->second, kJSON_ESCAPE_LENGTH}); writtenUntil = position + 1; }; } if (writtenUntil < position) output_({data + writtenUntil, position - writtenUntil}); - output_({"e, 1}); + output_({&kQUOTE, 1}); } void @@ -136,7 +136,7 @@ public: { check( false, - "Not an " + ((type == CollectionType::array ? "array: " : "object: ") + message)); + "Not an " + ((type == CollectionType::Array ? "array: " : "object: ") + message)); } if (stack_.top().isFirst) { @@ -144,7 +144,7 @@ public: } else { - output_({&comma, 1}); + output_({&kCOMMA, 1}); } } @@ -159,7 +159,7 @@ public: #endif stringOutput(tag); - output_({&colon, 1}); + output_({&kCOLON, 1}); } [[nodiscard]] bool @@ -173,8 +173,8 @@ public: { check(!empty(), "Empty stack in finish()"); - auto isArray = stack_.top().type == CollectionType::array; - auto ch = isArray ? closeBracket : closeBrace; + auto isArray = stack_.top().type == CollectionType::Array; + auto ch = isArray ? kCLOSE_BRACKET : kCLOSE_BRACE; output_({&ch, 1}); stack_.pop(); } @@ -200,7 +200,7 @@ private: struct Collection { /** What type of collection are we in? */ - Writer::CollectionType type = Writer::CollectionType::array; + Writer::CollectionType type = Writer::CollectionType::Array; /** Is this the first entry in a collection? * If false, we have to emit a , before we write the next entry. */ @@ -255,7 +255,7 @@ Writer::output(std::string const& s) } void -Writer::output(Json::Value const& value) +Writer::output(json::Value const& value) { impl_->markStarted(); outputJson(value, impl_->getOutput()); @@ -303,7 +303,7 @@ Writer::finishAll() void Writer::rawAppend() { - impl_->nextCollectionEntry(CollectionType::array, "append"); + impl_->nextCollectionEntry(CollectionType::Array, "append"); } void @@ -311,7 +311,7 @@ Writer::rawSet(std::string const& tag) { check(!tag.empty(), "Tag can't be empty"); - impl_->nextCollectionEntry(CollectionType::object, "set"); + impl_->nextCollectionEntry(CollectionType::Object, "set"); impl_->writeObjectTag(tag); } @@ -324,14 +324,14 @@ Writer::startRoot(CollectionType type) void Writer::startAppend(CollectionType type) { - impl_->nextCollectionEntry(CollectionType::array, "startAppend"); + impl_->nextCollectionEntry(CollectionType::Array, "startAppend"); impl_->start(type); } void Writer::startSet(CollectionType type, std::string const& key) { - impl_->nextCollectionEntry(CollectionType::object, "startSet"); + impl_->nextCollectionEntry(CollectionType::Object, "startSet"); impl_->writeObjectTag(key); impl_->start(type); } @@ -343,4 +343,4 @@ Writer::finish() impl_->finish(); } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/json_reader.cpp b/src/libxrpl/json/json_reader.cpp index 1bb157afc3..6574789e7b 100644 --- a/src/libxrpl/json/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -12,7 +12,7 @@ #include #include -namespace Json { +namespace json { // Implementation of class Reader // //////////////////////////////// @@ -102,9 +102,9 @@ Reader::parse(char const* beginDoc, char const* endDoc, Value& root) { // Set error location to start of doc, ideally should be first token // found in doc - token.type_ = tokenError; - token.start_ = beginDoc; - token.end_ = endDoc; + token.type = TokenError; + token.start = beginDoc; + token.end = endDoc; addError("A valid JSON document must be either an array or an object value.", token); return false; } @@ -117,41 +117,41 @@ Reader::readValue(unsigned depth) { Token token{}; skipCommentTokens(token); - if (depth > nest_limit) + if (depth > kNEST_LIMIT) return addError("Syntax error: maximum nesting depth exceeded", token); bool successful = true; - switch (token.type_) + switch (token.type) { - case tokenObjectBegin: + case TokenObjectBegin: successful = readObject(token, depth); break; - case tokenArrayBegin: + case TokenArrayBegin: successful = readArray(token, depth); break; - case tokenInteger: + case TokenInteger: successful = decodeNumber(token); break; - case tokenDouble: + case TokenDouble: successful = decodeDouble(token); break; - case tokenString: + case TokenString: successful = decodeString(token); break; - case tokenTrue: + case TokenTrue: currentValue() = true; break; - case tokenFalse: + case TokenFalse: currentValue() = false; break; - case tokenNull: + case TokenNull: currentValue() = Value(); break; @@ -168,7 +168,7 @@ Reader::skipCommentTokens(Token& token) do { readToken(token); - } while (token.type_ == tokenComment); + } while (token.type == TokenComment); } bool @@ -176,7 +176,7 @@ Reader::expectToken(TokenType type, Token& token, char const* message) { readToken(token); - if (token.type_ != type) + if (token.type != type) return addError(message, token); return true; @@ -186,35 +186,35 @@ bool Reader::readToken(Token& token) { skipSpaces(); - token.start_ = current_; + token.start = current_; Char const c = getNextChar(); bool ok = true; switch (c) { case '{': - token.type_ = tokenObjectBegin; + token.type = TokenObjectBegin; break; case '}': - token.type_ = tokenObjectEnd; + token.type = TokenObjectEnd; break; case '[': - token.type_ = tokenArrayBegin; + token.type = TokenArrayBegin; break; case ']': - token.type_ = tokenArrayEnd; + token.type = TokenArrayEnd; break; case '"': - token.type_ = tokenString; + token.type = TokenString; ok = readString(); break; case '/': - token.type_ = tokenComment; + token.type = TokenComment; ok = readComment(); break; @@ -229,34 +229,34 @@ Reader::readToken(Token& token) case '8': case '9': case '-': - token.type_ = readNumber(); + token.type = readNumber(); break; case 't': - token.type_ = tokenTrue; + token.type = TokenTrue; ok = match("rue", 3); break; case 'f': - token.type_ = tokenFalse; + token.type = TokenFalse; ok = match("alse", 4); // cspell:disable-line break; case 'n': - token.type_ = tokenNull; + token.type = TokenNull; ok = match("ull", 3); break; case ',': - token.type_ = tokenArraySeparator; + token.type = TokenArraySeparator; break; case ':': - token.type_ = tokenMemberSeparator; + token.type = TokenMemberSeparator; break; case 0: - token.type_ = tokenEndOfStream; + token.type = TokenEndOfStream; break; default: @@ -265,9 +265,9 @@ Reader::readToken(Token& token) } if (!ok) - token.type_ = tokenError; + token.type = TokenError; - token.end_ = current_; + token.end = current_; return true; } @@ -352,9 +352,9 @@ Reader::readCppStyleComment() Reader::TokenType Reader::readNumber() { - static char const extended_tokens[] = {'.', 'e', 'E', '+', '-'}; + static char const kEXTENDED_TOKENS[] = {'.', 'e', 'E', '+', '-'}; - TokenType type = tokenInteger; + TokenType type = TokenInteger; if (current_ != end_) { @@ -365,12 +365,12 @@ Reader::readNumber() { if (std::isdigit(static_cast(*current_)) == 0) { - auto ret = std::ranges::find(extended_tokens, *current_); + auto ret = std::ranges::find(kEXTENDED_TOKENS, *current_); - if (ret == std::end(extended_tokens)) + if (ret == std::end(kEXTENDED_TOKENS)) break; - type = tokenDouble; + type = TokenDouble; } ++current_; @@ -407,35 +407,35 @@ Reader::readObject(Token& tokenStart, unsigned depth) { Token tokenName{}; std::string name; - currentValue() = Value(objectValue); + currentValue() = Value(ObjectValue); while (readToken(tokenName)) { bool initialTokenOk = true; - while (tokenName.type_ == tokenComment && initialTokenOk) + while (tokenName.type == TokenComment && initialTokenOk) initialTokenOk = readToken(tokenName); if (!initialTokenOk) break; - if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object + if (tokenName.type == TokenObjectEnd && name.empty()) // empty object return true; - if (tokenName.type_ != tokenString) + if (tokenName.type != TokenString) break; name = ""; if (!decodeString(tokenName, name)) - return recoverFromError(tokenObjectEnd); + return recoverFromError(TokenObjectEnd); Token colon{}; - if (!readToken(colon) || colon.type_ != tokenMemberSeparator) + if (!readToken(colon) || colon.type != TokenMemberSeparator) { return addErrorAndRecover( - "Missing ':' after object member name", colon, tokenObjectEnd); + "Missing ':' after object member name", colon, TokenObjectEnd); } // Reject duplicate names @@ -448,34 +448,34 @@ Reader::readObject(Token& tokenStart, unsigned depth) nodes_.pop(); if (!ok) // error already set - return recoverFromError(tokenObjectEnd); + return recoverFromError(TokenObjectEnd); Token comma{}; if (!readToken(comma) || - (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator && - comma.type_ != tokenComment)) + (comma.type != TokenObjectEnd && comma.type != TokenArraySeparator && + comma.type != TokenComment)) { return addErrorAndRecover( - "Missing ',' or '}' in object declaration", comma, tokenObjectEnd); + "Missing ',' or '}' in object declaration", comma, TokenObjectEnd); } bool finalizeTokenOk = true; - while (comma.type_ == tokenComment && finalizeTokenOk) + while (comma.type == TokenComment && finalizeTokenOk) finalizeTokenOk = readToken(comma); - if (comma.type_ == tokenObjectEnd) + if (comma.type == TokenObjectEnd) return true; } - return addErrorAndRecover("Missing '}' or object member name", tokenName, tokenObjectEnd); + return addErrorAndRecover("Missing '}' or object member name", tokenName, TokenObjectEnd); } bool Reader::readArray(Token& tokenStart, unsigned depth) { - currentValue() = Value(arrayValue); + currentValue() = Value(ArrayValue); skipSpaces(); if (*current_ == ']') // empty array @@ -495,27 +495,27 @@ Reader::readArray(Token& tokenStart, unsigned depth) nodes_.pop(); if (!ok) // error already set - return recoverFromError(tokenArrayEnd); + return recoverFromError(TokenArrayEnd); Token token{}; // Accept Comment after last item in the array. ok = readToken(token); - while (token.type_ == tokenComment && ok) + while (token.type == TokenComment && ok) { ok = readToken(token); } bool const badTokenType = - (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); + (token.type != TokenArraySeparator && token.type != TokenArrayEnd); if (!ok || badTokenType) { return addErrorAndRecover( - "Missing ',' or ']' in array declaration", token, tokenArrayEnd); + "Missing ',' or ']' in array declaration", token, TokenArrayEnd); } - if (token.type_ == tokenArrayEnd) + if (token.type == TokenArrayEnd) break; } @@ -525,16 +525,16 @@ Reader::readArray(Token& tokenStart, unsigned depth) bool Reader::decodeNumber(Token& token) { - Location current = token.start_; + Location current = token.start; bool const isNegative = *current == '-'; if (isNegative) ++current; - if (current == token.end_) + if (current == token.end) { return addError( - "'" + std::string(token.start_, token.end_) + "' is not a valid number.", token); + "'" + std::string(token.start, token.end) + "' is not a valid number.", token); } // The existing Json integers are 32-bit so using a 64-bit value here avoids @@ -542,37 +542,37 @@ Reader::decodeNumber(Token& token) std::int64_t value = 0; static_assert( - sizeof(value) > sizeof(Value::maxUInt), + sizeof(value) > sizeof(Value::kMAX_U_INT), "The JSON integer overflow logic will need to be reworked."); - while (current < token.end_ && (value <= Value::maxUInt)) + while (current < token.end && (value <= Value::kMAX_U_INT)) { Char const c = *current++; if (c < '0' || c > '9') { return addError( - "'" + std::string(token.start_, token.end_) + "' is not a number.", token); + "'" + std::string(token.start, token.end) + "' is not a number.", token); } value = (value * 10) + (c - '0'); } // More tokens left -> input is larger than largest possible return value - if (current != token.end_) + if (current != token.end) { return addError( - "'" + std::string(token.start_, token.end_) + "' exceeds the allowable range.", token); + "'" + std::string(token.start, token.end) + "' exceeds the allowable range.", token); } if (isNegative) { value = -value; - if (value < Value::minInt || value > Value::maxInt) + if (value < Value::kMIN_INT || value > Value::kMAX_INT) { return addError( - "'" + std::string(token.start_, token.end_) + "' exceeds the allowable range.", + "'" + std::string(token.start, token.end) + "' exceeds the allowable range.", token); } @@ -580,15 +580,15 @@ Reader::decodeNumber(Token& token) } else { - if (value > Value::maxUInt) + if (value > Value::kMAX_U_INT) { return addError( - "'" + std::string(token.start_, token.end_) + "' exceeds the allowable range.", + "'" + std::string(token.start, token.end) + "' exceeds the allowable range.", token); } // If it's representable as a signed integer, construct it as one. - if (value <= Value::maxInt) + if (value <= Value::kMAX_INT) { currentValue() = static_cast(value); } @@ -607,7 +607,7 @@ Reader::decodeDouble(Token& token) double value = 0; int const bufferSize = 32; int count = 0; - int const length = int(token.end_ - token.start_); + int const length = int(token.end - token.start); // Sanity check to avoid buffer overflow exploits. if (length < 0) { @@ -622,17 +622,17 @@ Reader::decodeDouble(Token& token) if (length <= bufferSize) { Char buffer[bufferSize + 1]; - memcpy(buffer, token.start_, length); + memcpy(buffer, token.start, length); buffer[length] = 0; count = sscanf(buffer, format, &value); } else { - std::string const buffer(token.start_, token.end_); + std::string const buffer(token.start, token.end); count = sscanf(buffer.c_str(), format, &value); } if (count != 1) - return addError("'" + std::string(token.start_, token.end_) + "' is not a number.", token); + return addError("'" + std::string(token.start, token.end) + "' is not a number.", token); currentValue() = value; return true; } @@ -652,9 +652,9 @@ Reader::decodeString(Token& token) bool Reader::decodeString(Token& token, std::string& decoded) { - decoded.reserve(token.end_ - token.start_ - 2); - Location current = token.start_ + 1; // skip '"' - Location end = token.end_ - 1; // do not include '"' + decoded.reserve(token.end - token.start - 2); + Location current = token.start + 1; // skip '"' + Location end = token.end - 1; // do not include '"' while (current != end) { @@ -816,9 +816,9 @@ bool Reader::addError(std::string const& message, Token& token, Location extra) { ErrorInfo info; - info.token_ = token; - info.message_ = message; - info.extra_ = extra; + info.token = token; + info.message = message; + info.extra = extra; errors_.push_back(info); return false; } @@ -834,7 +834,7 @@ Reader::recoverFromError(TokenType skipUntilToken) if (!readToken(skip)) errors_.resize(errorCount); // discard errors caused by recovery - if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream) + if (skip.type == skipUntilToken || skip.type == TokenEndOfStream) break; } @@ -911,11 +911,11 @@ Reader::getFormattedErrorMessages() const for (Errors::const_iterator itError = errors_.begin(); itError != errors_.end(); ++itError) { ErrorInfo const& error = *itError; - formattedMessage += "* " + getLocationLineAndColumn(error.token_.start_) + "\n"; - formattedMessage += " " + error.message_ + "\n"; + formattedMessage += "* " + getLocationLineAndColumn(error.token.start) + "\n"; + formattedMessage += " " + error.message + "\n"; - if (error.extra_ != nullptr) - formattedMessage += "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n"; + if (error.extra != nullptr) + formattedMessage += "See " + getLocationLineAndColumn(error.extra) + " for detail.\n"; } return formattedMessage; @@ -924,14 +924,14 @@ Reader::getFormattedErrorMessages() const std::istream& operator>>(std::istream& sin, Value& root) { - Json::Reader reader; + json::Reader reader; bool const ok = reader.parse(sin, root); - // XRPL_ASSERT(ok, "Json::operator>>() : parse succeeded"); + // XRPL_ASSERT(ok, "json::operator>>() : parse succeeded"); if (!ok) xrpl::Throw(reader.getFormattedErrorMessages()); return sin; } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index 61e0a0c7ee..e7dc4b067b 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -15,9 +15,9 @@ #include #include -namespace Json { +namespace json { -Value const Value::null; +Value const Value::kNULL; class DefaultValueAllocator : public ValueAllocator { @@ -37,13 +37,13 @@ public: } char* - duplicateStringValue(char const* value, unsigned int length = unknown) override + duplicateStringValue(char const* value, unsigned int length = Unknown) override { //@todo investigate this old optimization // if ( !value || value[0] == 0 ) // return 0; - if (length == unknown) + if (length == Unknown) length = (value != nullptr) ? (unsigned int)strlen(value) : 0; char* newString = static_cast(malloc(length + 1)); @@ -64,9 +64,8 @@ public: static ValueAllocator*& valueAllocator() { - // NOLINTNEXTLINE(misc-const-correctness) - static ValueAllocator* valueAllocator = new DefaultValueAllocator; - return valueAllocator; + static ValueAllocator* kVALUE_ALLOCATOR = new DefaultValueAllocator; // NOLINT TODO + return kVALUE_ALLOCATOR; } static struct DummyValueAllocatorInitializer @@ -76,7 +75,7 @@ static struct DummyValueAllocatorInitializer valueAllocator(); // ensure valueAllocator() statics are initialized // before main(). } -} dummyValueAllocatorInitializer; +} gDummyValueAllocatorInitializer; // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// @@ -94,26 +93,26 @@ Value::CZString::CZString(int index) : cstr_(0), index_(index) } Value::CZString::CZString(char const* cstr, DuplicationPolicy allocate) - : cstr_(allocate == duplicate ? valueAllocator()->makeMemberName(cstr) : cstr), index_(allocate) + : cstr_(allocate == Duplicate ? valueAllocator()->makeMemberName(cstr) : cstr), index_(allocate) { } Value::CZString::CZString(CZString const& other) : cstr_( - other.index_ != noDuplication && other.cstr_ != 0 + other.index_ != NoDuplication && other.cstr_ != 0 ? valueAllocator()->makeMemberName(other.cstr_) : other.cstr_) , index_([&]() -> int { if (!other.cstr_) return other.index_; - return other.index_ == noDuplication ? noDuplication : duplicate; + return other.index_ == NoDuplication ? NoDuplication : Duplicate; }()) { } Value::CZString::~CZString() { - if ((cstr_ != nullptr) && index_ == duplicate) + if ((cstr_ != nullptr) && index_ == Duplicate) valueAllocator()->releaseMemberName(const_cast(cstr_)); } @@ -142,7 +141,7 @@ Value::CZString::index() const } char const* -Value::CZString::c_str() const +Value::CZString::cStr() const { return cstr_; } @@ -150,7 +149,7 @@ Value::CZString::c_str() const bool Value::CZString::isStaticString() const { - return index_ == noDuplication; + return index_ == NoDuplication; } // ////////////////////////////////////////////////////////////////// @@ -169,113 +168,113 @@ Value::Value(ValueType type) : type_(type) { switch (type) { - case nullValue: + case NullValue: break; - case intValue: - case uintValue: - value_.int_ = 0; + case IntValue: + case UintValue: + value_.intVal = 0; break; - case realValue: - value_.real_ = 0.0; + case RealValue: + value_.realVal = 0.0; break; - case stringValue: - value_.string_ = 0; + case StringValue: + value_.stringVal = 0; break; - case arrayValue: - case objectValue: - value_.map_ = new ObjectValues(); + case ArrayValue: + case ObjectValue: + value_.mapVal = new ObjectValues(); break; - case booleanValue: - value_.bool_ = false; + case BooleanValue: + value_.boolVal = false; break; // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::Value(ValueType) : invalid type"); + UNREACHABLE("json::Value::Value(ValueType) : invalid type"); // LCOV_EXCL_STOP } } -Value::Value(Int value) : type_(intValue) +Value::Value(Int value) : type_(IntValue) { - value_.int_ = value; + value_.intVal = value; } -Value::Value(UInt value) : type_(uintValue) +Value::Value(UInt value) : type_(UintValue) { - value_.uint_ = value; + value_.uintVal = value; } -Value::Value(double value) : type_(realValue) +Value::Value(double value) : type_(RealValue) { - value_.real_ = value; + value_.realVal = value; } -Value::Value(char const* value) : type_(stringValue), allocated_(true) +Value::Value(char const* value) : type_(StringValue), allocated_(true) { - value_.string_ = valueAllocator()->duplicateStringValue(value); + value_.stringVal = valueAllocator()->duplicateStringValue(value); } -Value::Value(xrpl::Number const& value) : type_(stringValue), allocated_(true) +Value::Value(xrpl::Number const& value) : type_(StringValue), allocated_(true) { auto const tmp = to_string(value); - value_.string_ = valueAllocator()->duplicateStringValue(tmp.c_str(), tmp.length()); + value_.stringVal = valueAllocator()->duplicateStringValue(tmp.c_str(), tmp.length()); } -Value::Value(std::string const& value) : type_(stringValue), allocated_(true) +Value::Value(std::string const& value) : type_(StringValue), allocated_(true) { - value_.string_ = + value_.stringVal = valueAllocator()->duplicateStringValue(value.c_str(), (unsigned int)value.length()); } -Value::Value(StaticString const& value) : type_(stringValue) +Value::Value(StaticString const& value) : type_(StringValue) { - value_.string_ = const_cast(value.c_str()); + value_.stringVal = const_cast(value.cStr()); } -Value::Value(bool value) : type_(booleanValue) +Value::Value(bool value) : type_(BooleanValue) { - value_.bool_ = value; + value_.boolVal = value; } Value::Value(Value const& other) : type_(other.type_) { switch (type_) { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: + case NullValue: + case IntValue: + case UintValue: + case RealValue: + case BooleanValue: value_ = other.value_; break; - case stringValue: - if (other.value_.string_ != nullptr) + case StringValue: + if (other.value_.stringVal != nullptr) { - value_.string_ = valueAllocator()->duplicateStringValue(other.value_.string_); + value_.stringVal = valueAllocator()->duplicateStringValue(other.value_.stringVal); allocated_ = true; } else { - value_.string_ = 0; + value_.stringVal = 0; } break; - case arrayValue: - case objectValue: - value_.map_ = new ObjectValues(*other.value_.map_); + case ArrayValue: + case ObjectValue: + value_.mapVal = new ObjectValues(*other.value_.mapVal); break; // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::Value(Value const&) : invalid type"); + UNREACHABLE("json::Value::Value(Value const&) : invalid type"); // LCOV_EXCL_STOP } } @@ -284,28 +283,28 @@ Value::~Value() { switch (type_) { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: + case NullValue: + case IntValue: + case UintValue: + case RealValue: + case BooleanValue: break; - case stringValue: + case StringValue: if (allocated_) - valueAllocator()->releaseStringValue(value_.string_); + valueAllocator()->releaseStringValue(value_.stringVal); break; - case arrayValue: - case objectValue: - if (value_.map_ != nullptr) - delete value_.map_; + case ArrayValue: + case ObjectValue: + if (value_.mapVal != nullptr) + delete value_.mapVal; break; // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::~Value : invalid type"); + UNREACHABLE("json::Value::~Value : invalid type"); // LCOV_EXCL_STOP } } @@ -321,7 +320,7 @@ Value::operator=(Value const& other) Value::Value(Value&& other) noexcept : value_(other.value_), type_(other.type_), allocated_(other.allocated_) { - other.type_ = nullValue; + other.type_ = NullValue; other.allocated_ = 0; } @@ -371,50 +370,50 @@ operator<(Value const& x, Value const& y) { if (auto signum = x.type_ - y.type_) { - if (x.type_ == intValue && y.type_ == uintValue) + if (x.type_ == IntValue && y.type_ == UintValue) { - signum = integerCmp(x.value_.int_, y.value_.uint_); + signum = integerCmp(x.value_.intVal, y.value_.uintVal); } - else if (x.type_ == uintValue && y.type_ == intValue) + else if (x.type_ == UintValue && y.type_ == IntValue) { - signum = -integerCmp(y.value_.int_, x.value_.uint_); + signum = -integerCmp(y.value_.intVal, x.value_.uintVal); } return signum < 0; } switch (x.type_) { - case nullValue: + case NullValue: return false; - case intValue: - return x.value_.int_ < y.value_.int_; + case IntValue: + return x.value_.intVal < y.value_.intVal; - case uintValue: - return x.value_.uint_ < y.value_.uint_; + case UintValue: + return x.value_.uintVal < y.value_.uintVal; - case realValue: - return x.value_.real_ < y.value_.real_; + case RealValue: + return x.value_.realVal < y.value_.realVal; - case booleanValue: - return static_cast(x.value_.bool_) < static_cast(y.value_.bool_); + case BooleanValue: + return static_cast(x.value_.boolVal) < static_cast(y.value_.boolVal); - case stringValue: - return (x.value_.string_ == 0 && (y.value_.string_ != nullptr)) || - ((y.value_.string_ != nullptr) && (x.value_.string_ != nullptr) && - strcmp(x.value_.string_, y.value_.string_) < 0); + case StringValue: + return (x.value_.stringVal == 0 && (y.value_.stringVal != nullptr)) || + ((y.value_.stringVal != nullptr) && (x.value_.stringVal != nullptr) && + strcmp(x.value_.stringVal, y.value_.stringVal) < 0); - case arrayValue: - case objectValue: { - if (int const signum = int(x.value_.map_->size()) - y.value_.map_->size()) + case ArrayValue: + case ObjectValue: { + if (int const signum = int(x.value_.mapVal->size()) - y.value_.mapVal->size()) return signum < 0; - return *x.value_.map_ < *y.value_.map_; + return *x.value_.mapVal < *y.value_.mapVal; } // LCOV_EXCL_START default: - UNREACHABLE("Json::operator<(Value, Value) : invalid type"); + UNREACHABLE("json::operator<(Value, Value) : invalid type"); // LCOV_EXCL_STOP } @@ -426,43 +425,43 @@ operator==(Value const& x, Value const& y) { if (x.type_ != y.type_) { - if (x.type_ == intValue && y.type_ == uintValue) - return integerCmp(x.value_.int_, y.value_.uint_) == 0; - if (x.type_ == uintValue && y.type_ == intValue) - return integerCmp(y.value_.int_, x.value_.uint_) == 0; + if (x.type_ == IntValue && y.type_ == UintValue) + return integerCmp(x.value_.intVal, y.value_.uintVal) == 0; + if (x.type_ == UintValue && y.type_ == IntValue) + return integerCmp(y.value_.intVal, x.value_.uintVal) == 0; return false; } switch (x.type_) { - case nullValue: + case NullValue: return true; - case intValue: - return x.value_.int_ == y.value_.int_; + case IntValue: + return x.value_.intVal == y.value_.intVal; - case uintValue: - return x.value_.uint_ == y.value_.uint_; + case UintValue: + return x.value_.uintVal == y.value_.uintVal; - case realValue: - return x.value_.real_ == y.value_.real_; + case RealValue: + return x.value_.realVal == y.value_.realVal; - case booleanValue: - return x.value_.bool_ == y.value_.bool_; + case BooleanValue: + return x.value_.boolVal == y.value_.boolVal; - case stringValue: - return x.value_.string_ == y.value_.string_ || - ((y.value_.string_ != nullptr) && (x.value_.string_ != nullptr) && - (strcmp(x.value_.string_, y.value_.string_) == 0)); + case StringValue: + return x.value_.stringVal == y.value_.stringVal || + ((y.value_.stringVal != nullptr) && (x.value_.stringVal != nullptr) && + (strcmp(x.value_.stringVal, y.value_.stringVal) == 0)); - case arrayValue: - case objectValue: - return x.value_.map_->size() == y.value_.map_->size() && - *x.value_.map_ == *y.value_.map_; + case ArrayValue: + case ObjectValue: + return x.value_.mapVal->size() == y.value_.mapVal->size() && + *x.value_.mapVal == *y.value_.mapVal; // LCOV_EXCL_START default: - UNREACHABLE("Json::operator==(Value, Value) : invalid type"); + UNREACHABLE("json::operator==(Value, Value) : invalid type"); // LCOV_EXCL_STOP } @@ -472,8 +471,8 @@ operator==(Value const& x, Value const& y) char const* Value::asCString() const { - XRPL_ASSERT(type_ == stringValue, "Json::Value::asCString : valid type"); - return value_.string_; + XRPL_ASSERT(type_ == StringValue, "json::Value::asCString : valid type"); + return value_.stringVal; } std::string @@ -481,31 +480,31 @@ Value::asString() const { switch (type_) { - case nullValue: + case NullValue: return ""; - case stringValue: - return (value_.string_ != nullptr) ? value_.string_ : ""; + case StringValue: + return (value_.stringVal != nullptr) ? value_.stringVal : ""; - case booleanValue: - return value_.bool_ ? "true" : "false"; + case BooleanValue: + return value_.boolVal ? "true" : "false"; - case intValue: - return std::to_string(value_.int_); + case IntValue: + return std::to_string(value_.intVal); - case uintValue: - return std::to_string(value_.uint_); + case UintValue: + return std::to_string(value_.uintVal); - case realValue: - return std::to_string(value_.real_); + case RealValue: + return std::to_string(value_.realVal); - case arrayValue: - case objectValue: + case ArrayValue: + case ObjectValue: JSON_ASSERT_MESSAGE(false, "Type is not convertible to string"); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asString : invalid type"); + UNREACHABLE("json::Value::asString : invalid type"); // LCOV_EXCL_STOP } @@ -517,38 +516,38 @@ Value::asInt() const { switch (type_) { - case nullValue: + case NullValue: return 0; - case intValue: - return value_.int_; + case IntValue: + return value_.intVal; - case uintValue: + case UintValue: JSON_ASSERT_MESSAGE( - value_.uint_ < (unsigned)maxInt, "integer out of signed integer range"); - return value_.uint_; + value_.uintVal < (unsigned)kMAX_INT, "integer out of signed integer range"); + return value_.uintVal; - case realValue: + case RealValue: JSON_ASSERT_MESSAGE( - (value_.real_ >= minInt && value_.real_ <= maxInt), + (value_.realVal >= kMIN_INT && value_.realVal <= kMAX_INT), "Real out of signed integer range"); - return Int(value_.real_); + return Int(value_.realVal); - case booleanValue: - return value_.bool_ ? 1 : 0; + case BooleanValue: + return value_.boolVal ? 1 : 0; - case stringValue: { - char const* const str{(value_.string_ != nullptr) ? value_.string_ : ""}; + case StringValue: { + char const* const str{(value_.stringVal != nullptr) ? value_.stringVal : ""}; return beast::lexicalCastThrow(str); } - case arrayValue: - case objectValue: + case ArrayValue: + case ObjectValue: JSON_ASSERT_MESSAGE(false, "Type is not convertible to int"); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asInt : invalid type"); + UNREACHABLE("json::Value::asInt : invalid type"); // LCOV_EXCL_STOP } @@ -560,53 +559,54 @@ Value::asAbsUInt() const { switch (type_) { - case nullValue: + case NullValue: return 0; - case intValue: { + case IntValue: { // Doing this conversion through int64 avoids overflow error for - // value_.int_ = -1 * 2^31 i.e. numeric_limits::min(). - if (value_.int_ < 0) - return static_cast(value_.int_) * -1; - return value_.int_; + // value_.intVal = -1 * 2^31 i.e. numeric_limits::min(). + if (value_.intVal < 0) + return static_cast(value_.intVal) * -1; + return value_.intVal; } - case uintValue: - return value_.uint_; + case UintValue: + return value_.uintVal; - case realValue: { - if (value_.real_ < 0) + case RealValue: { + if (value_.realVal < 0) { JSON_ASSERT_MESSAGE( - -1 * value_.real_ <= maxUInt, "Real out of unsigned integer range"); - return UInt(-1 * value_.real_); + -1 * value_.realVal <= kMAX_U_INT, "Real out of unsigned integer range"); + return UInt(-1 * value_.realVal); } - JSON_ASSERT_MESSAGE(value_.real_ <= maxUInt, "Real out of unsigned integer range"); - return UInt(value_.real_); + JSON_ASSERT_MESSAGE(value_.realVal <= kMAX_U_INT, "Real out of unsigned integer range"); + return UInt(value_.realVal); } - case booleanValue: - return value_.bool_ ? 1 : 0; + case BooleanValue: + return value_.boolVal ? 1 : 0; - case stringValue: { - char const* const str{(value_.string_ != nullptr) ? value_.string_ : ""}; + case StringValue: { + char const* const str{(value_.stringVal != nullptr) ? value_.stringVal : ""}; auto const temp = beast::lexicalCastThrow(str); if (temp < 0) { - JSON_ASSERT_MESSAGE(-1 * temp <= maxUInt, "String out of unsigned integer range"); + JSON_ASSERT_MESSAGE( + -1 * temp <= kMAX_U_INT, "String out of unsigned integer range"); return -1 * temp; } - JSON_ASSERT_MESSAGE(temp <= maxUInt, "String out of unsigned integer range"); + JSON_ASSERT_MESSAGE(temp <= kMAX_U_INT, "String out of unsigned integer range"); return temp; } - case arrayValue: - case objectValue: + case ArrayValue: + case ObjectValue: JSON_ASSERT_MESSAGE(false, "Type is not convertible to int"); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asAbsInt : invalid type"); + UNREACHABLE("json::Value::asAbsInt : invalid type"); // LCOV_EXCL_STOP } @@ -618,38 +618,38 @@ Value::asUInt() const { switch (type_) { - case nullValue: + case NullValue: return 0; - case intValue: + case IntValue: JSON_ASSERT_MESSAGE( - value_.int_ >= 0, "Negative integer can not be converted to unsigned integer"); - return value_.int_; + value_.intVal >= 0, "Negative integer can not be converted to unsigned integer"); + return value_.intVal; - case uintValue: - return value_.uint_; + case UintValue: + return value_.uintVal; - case realValue: + case RealValue: JSON_ASSERT_MESSAGE( - (value_.real_ >= 0 && value_.real_ <= maxUInt), + (value_.realVal >= 0 && value_.realVal <= kMAX_U_INT), "Real out of unsigned integer range"); - return UInt(value_.real_); + return UInt(value_.realVal); - case booleanValue: - return value_.bool_ ? 1 : 0; + case BooleanValue: + return value_.boolVal ? 1 : 0; - case stringValue: { - char const* const str{(value_.string_ != nullptr) ? value_.string_ : ""}; + case StringValue: { + char const* const str{(value_.stringVal != nullptr) ? value_.stringVal : ""}; return beast::lexicalCastThrow(str); } - case arrayValue: - case objectValue: + case ArrayValue: + case ObjectValue: JSON_ASSERT_MESSAGE(false, "Type is not convertible to uint"); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asUInt : invalid type"); + UNREACHABLE("json::Value::asUInt : invalid type"); // LCOV_EXCL_STOP } @@ -661,29 +661,29 @@ Value::asDouble() const { switch (type_) { - case nullValue: + case NullValue: return 0.0; - case intValue: - return value_.int_; + case IntValue: + return value_.intVal; - case uintValue: - return value_.uint_; + case UintValue: + return value_.uintVal; - case realValue: - return value_.real_; + case RealValue: + return value_.realVal; - case booleanValue: - return value_.bool_ ? 1.0 : 0.0; + case BooleanValue: + return value_.boolVal ? 1.0 : 0.0; - case stringValue: - case arrayValue: - case objectValue: + case StringValue: + case ArrayValue: + case ObjectValue: JSON_ASSERT_MESSAGE(false, "Type is not convertible to double"); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asDouble : invalid type"); + UNREACHABLE("json::Value::asDouble : invalid type"); // LCOV_EXCL_STOP } @@ -695,29 +695,29 @@ Value::asBool() const { switch (type_) { - case nullValue: + case NullValue: return false; - case intValue: - case uintValue: - return value_.int_ != 0; + case IntValue: + case UintValue: + return value_.intVal != 0; - case realValue: - return value_.real_ != 0.0; + case RealValue: + return value_.realVal != 0.0; - case booleanValue: - return value_.bool_; + case BooleanValue: + return value_.boolVal; - case stringValue: - return (value_.string_ != nullptr) && value_.string_[0] != 0; + case StringValue: + return (value_.stringVal != nullptr) && value_.stringVal[0] != 0; - case arrayValue: - case objectValue: - return !value_.map_->empty(); + case ArrayValue: + case ObjectValue: + return !value_.mapVal->empty(); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::asBool : invalid type"); + UNREACHABLE("json::Value::asBool : invalid type"); // LCOV_EXCL_STOP } @@ -729,45 +729,45 @@ Value::isConvertibleTo(ValueType other) const { switch (type_) { - case nullValue: + case NullValue: return true; - case intValue: - return (other == nullValue && value_.int_ == 0) || other == intValue || - (other == uintValue && value_.int_ >= 0) || other == realValue || - other == stringValue || other == booleanValue; + case IntValue: + return (other == NullValue && value_.intVal == 0) || other == IntValue || + (other == UintValue && value_.intVal >= 0) || other == RealValue || + other == StringValue || other == BooleanValue; - case uintValue: - return (other == nullValue && value_.uint_ == 0) || - (other == intValue && value_.uint_ <= (unsigned)maxInt) || other == uintValue || - other == realValue || other == stringValue || other == booleanValue; + case UintValue: + return (other == NullValue && value_.uintVal == 0) || + (other == IntValue && value_.uintVal <= (unsigned)kMAX_INT) || other == UintValue || + other == RealValue || other == StringValue || other == BooleanValue; - case realValue: - return (other == nullValue && value_.real_ == 0.0) || - (other == intValue && value_.real_ >= minInt && value_.real_ <= maxInt) || - (other == uintValue && value_.real_ >= 0 && value_.real_ <= maxUInt && - std::fabs(round(value_.real_) - value_.real_) < + case RealValue: + return (other == NullValue && value_.realVal == 0.0) || + (other == IntValue && value_.realVal >= kMIN_INT && value_.realVal <= kMAX_INT) || + (other == UintValue && value_.realVal >= 0 && value_.realVal <= kMAX_U_INT && + std::fabs(round(value_.realVal) - value_.realVal) < std::numeric_limits::epsilon()) || - other == realValue || other == stringValue || other == booleanValue; + other == RealValue || other == StringValue || other == BooleanValue; - case booleanValue: - return (other == nullValue && !value_.bool_) || other == intValue || - other == uintValue || other == realValue || other == stringValue || - other == booleanValue; + case BooleanValue: + return (other == NullValue && !value_.boolVal) || other == IntValue || + other == UintValue || other == RealValue || other == StringValue || + other == BooleanValue; - case stringValue: - return other == stringValue || - (other == nullValue && ((value_.string_ == nullptr) || value_.string_[0] == 0)); + case StringValue: + return other == StringValue || + (other == NullValue && ((value_.stringVal == nullptr) || value_.stringVal[0] == 0)); - case arrayValue: - return other == arrayValue || (other == nullValue && value_.map_->empty()); + case ArrayValue: + return other == ArrayValue || (other == NullValue && value_.mapVal->empty()); - case objectValue: - return other == objectValue || (other == nullValue && value_.map_->empty()); + case ObjectValue: + return other == ObjectValue || (other == NullValue && value_.mapVal->empty()); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::isConvertible : invalid type"); + UNREACHABLE("json::Value::isConvertible : invalid type"); // LCOV_EXCL_STOP } @@ -780,30 +780,30 @@ Value::size() const { switch (type_) { - case nullValue: - case intValue: - case uintValue: - case realValue: - case booleanValue: - case stringValue: + case NullValue: + case IntValue: + case UintValue: + case RealValue: + case BooleanValue: + case StringValue: return 0; - case arrayValue: // size of the array is highest index + 1 - if (!value_.map_->empty()) + case ArrayValue: // size of the array is highest index + 1 + if (!value_.mapVal->empty()) { - ObjectValues::const_iterator itLast = value_.map_->end(); + ObjectValues::const_iterator itLast = value_.mapVal->end(); --itLast; return (*itLast).first.index() + 1; } return 0; - case objectValue: - return Int(value_.map_->size()); + case ObjectValue: + return Int(value_.mapVal->size()); // LCOV_EXCL_START default: - UNREACHABLE("Json::Value::size : invalid type"); + UNREACHABLE("json::Value::size : invalid type"); // LCOV_EXCL_STOP } @@ -829,14 +829,14 @@ void Value::clear() { XRPL_ASSERT( - type_ == nullValue || type_ == arrayValue || type_ == objectValue, - "Json::Value::clear : valid type"); + type_ == NullValue || type_ == ArrayValue || type_ == ObjectValue, + "json::Value::clear : valid type"); switch (type_) { - case arrayValue: - case objectValue: - value_.map_->clear(); + case ArrayValue: + case ObjectValue: + value_.mapVal->clear(); break; default: @@ -848,19 +848,19 @@ Value& Value::operator[](UInt index) { XRPL_ASSERT( - type_ == nullValue || type_ == arrayValue, "Json::Value::operator[](UInt) : valid type"); + type_ == NullValue || type_ == ArrayValue, "json::Value::operator[](UInt) : valid type"); - if (type_ == nullValue) - *this = Value(arrayValue); + if (type_ == NullValue) + *this = Value(ArrayValue); CZString const key(index); - ObjectValues::iterator it = value_.map_->lower_bound(key); + ObjectValues::iterator it = value_.mapVal->lower_bound(key); - if (it != value_.map_->end() && (*it).first == key) + if (it != value_.mapVal->end() && (*it).first == key) return (*it).second; - ObjectValues::value_type const defaultValue(key, null); - it = value_.map_->insert(it, defaultValue); + ObjectValues::value_type const defaultValue(key, kNULL); + it = value_.mapVal->insert(it, defaultValue); return (*it).second; } @@ -868,17 +868,17 @@ Value const& Value::operator[](UInt index) const { XRPL_ASSERT( - type_ == nullValue || type_ == arrayValue, - "Json::Value::operator[](UInt) const : valid type"); + type_ == NullValue || type_ == ArrayValue, + "json::Value::operator[](UInt) const : valid type"); - if (type_ == nullValue) - return null; + if (type_ == NullValue) + return kNULL; CZString const key(index); - ObjectValues::const_iterator const it = value_.map_->find(key); + ObjectValues::const_iterator const it = value_.mapVal->find(key); - if (it == value_.map_->end()) - return null; + if (it == value_.mapVal->end()) + return kNULL; return (*it).second; } @@ -893,19 +893,19 @@ Value& Value::resolveReference(char const* key, bool isStatic) { XRPL_ASSERT( - type_ == nullValue || type_ == objectValue, "Json::Value::resolveReference : valid type"); + type_ == NullValue || type_ == ObjectValue, "json::Value::resolveReference : valid type"); - if (type_ == nullValue) - *this = Value(objectValue); + if (type_ == NullValue) + *this = Value(ObjectValue); - CZString const actualKey(key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy); - ObjectValues::iterator it = value_.map_->lower_bound(actualKey); + CZString const actualKey(key, isStatic ? CZString::NoDuplication : CZString::DuplicateOnCopy); + ObjectValues::iterator it = value_.mapVal->lower_bound(actualKey); - if (it != value_.map_->end() && (*it).first == actualKey) + if (it != value_.mapVal->end() && (*it).first == actualKey) return (*it).second; - ObjectValues::value_type const defaultValue(actualKey, null); - it = value_.map_->insert(it, defaultValue); + ObjectValues::value_type const defaultValue(actualKey, kNULL); + it = value_.mapVal->insert(it, defaultValue); Value& value = (*it).second; return value; } @@ -914,7 +914,7 @@ Value Value::get(UInt index, Value const& defaultValue) const { Value const* value = &((*this)[index]); - return value == &null ? defaultValue : *value; + return value == &kNULL ? defaultValue : *value; } bool @@ -927,17 +927,17 @@ Value const& Value::operator[](char const* key) const { XRPL_ASSERT( - type_ == nullValue || type_ == objectValue, - "Json::Value::operator[](const char*) const : valid type"); + type_ == NullValue || type_ == ObjectValue, + "json::Value::operator[](const char*) const : valid type"); - if (type_ == nullValue) - return null; + if (type_ == NullValue) + return kNULL; - CZString const actualKey(key, CZString::noDuplication); - ObjectValues::const_iterator const it = value_.map_->find(actualKey); + CZString const actualKey(key, CZString::NoDuplication); + ObjectValues::const_iterator const it = value_.mapVal->find(actualKey); - if (it == value_.map_->end()) - return null; + if (it == value_.mapVal->end()) + return kNULL; return (*it).second; } @@ -963,7 +963,7 @@ Value::operator[](StaticString const& key) Value const& Value::operator[](StaticString const& key) const { - return (*this)[key.c_str()]; + return (*this)[key.cStr()]; } Value& @@ -982,7 +982,7 @@ Value Value::get(char const* key, Value const& defaultValue) const { Value const* value = &((*this)[key]); - return value == &null ? defaultValue : *value; + return value == &kNULL ? defaultValue : *value; } Value @@ -995,19 +995,19 @@ Value Value::removeMember(char const* key) { XRPL_ASSERT( - type_ == nullValue || type_ == objectValue, "Json::Value::removeMember : valid type"); + type_ == NullValue || type_ == ObjectValue, "json::Value::removeMember : valid type"); - if (type_ == nullValue) - return null; + if (type_ == NullValue) + return kNULL; - CZString const actualKey(key, CZString::noDuplication); - ObjectValues::iterator const it = value_.map_->find(actualKey); + CZString const actualKey(key, CZString::NoDuplication); + ObjectValues::iterator const it = value_.mapVal->find(actualKey); - if (it == value_.map_->end()) - return null; + if (it == value_.mapVal->end()) + return kNULL; Value old(it->second); - value_.map_->erase(it); + value_.mapVal->erase(it); return old; } @@ -1020,11 +1020,11 @@ Value::removeMember(std::string const& key) bool Value::isMember(char const* key) const { - if (type_ != objectValue) + if (type_ != ObjectValue) return false; Value const* value = &((*this)[key]); - return value != &null; + return value != &kNULL; } bool @@ -1036,25 +1036,25 @@ Value::isMember(std::string const& key) const bool Value::isMember(StaticString const& key) const { - return isMember(key.c_str()); + return isMember(key.cStr()); } Value::Members Value::getMemberNames() const { XRPL_ASSERT( - type_ == nullValue || type_ == objectValue, "Json::Value::getMemberNames : valid type"); + type_ == NullValue || type_ == ObjectValue, "json::Value::getMemberNames : valid type"); - if (type_ == nullValue) + if (type_ == NullValue) return Value::Members(); Members members; - members.reserve(value_.map_->size()); - ObjectValues::const_iterator it = value_.map_->begin(); - ObjectValues::const_iterator const itEnd = value_.map_->end(); + members.reserve(value_.mapVal->size()); + ObjectValues::const_iterator it = value_.mapVal->begin(); + ObjectValues::const_iterator const itEnd = value_.mapVal->end(); for (; it != itEnd; ++it) - members.emplace_back((*it).first.c_str()); + members.emplace_back((*it).first.cStr()); return members; } @@ -1062,37 +1062,37 @@ Value::getMemberNames() const bool Value::isNull() const { - return type_ == nullValue; + return type_ == NullValue; } bool Value::isBool() const { - return type_ == booleanValue; + return type_ == BooleanValue; } bool Value::isInt() const { - return type_ == intValue; + return type_ == IntValue; } bool Value::isUInt() const { - return type_ == uintValue; + return type_ == UintValue; } bool Value::isIntegral() const { - return type_ == intValue || type_ == uintValue || type_ == booleanValue; + return type_ == IntValue || type_ == UintValue || type_ == BooleanValue; } bool Value::isDouble() const { - return type_ == realValue; + return type_ == RealValue; } bool @@ -1104,31 +1104,31 @@ Value::isNumeric() const bool Value::isString() const { - return type_ == stringValue; + return type_ == StringValue; } bool Value::isArray() const { - return type_ == arrayValue; + return type_ == ArrayValue; } bool Value::isArrayOrNull() const { - return type_ == nullValue || type_ == arrayValue; + return type_ == NullValue || type_ == ArrayValue; } bool Value::isObject() const { - return type_ == objectValue; + return type_ == ObjectValue; } bool Value::isObjectOrNull() const { - return type_ == nullValue || type_ == objectValue; + return type_ == NullValue || type_ == ObjectValue; } std::string @@ -1143,10 +1143,10 @@ Value::begin() const { switch (type_) { - case arrayValue: - case objectValue: - if (value_.map_ != nullptr) - return const_iterator(value_.map_->begin()); + case ArrayValue: + case ObjectValue: + if (value_.mapVal != nullptr) + return const_iterator(value_.mapVal->begin()); break; default: @@ -1161,10 +1161,10 @@ Value::end() const { switch (type_) { - case arrayValue: - case objectValue: - if (value_.map_ != nullptr) - return const_iterator(value_.map_->end()); + case ArrayValue: + case ObjectValue: + if (value_.mapVal != nullptr) + return const_iterator(value_.mapVal->end()); break; default: @@ -1179,10 +1179,10 @@ Value::begin() { switch (type_) { - case arrayValue: - case objectValue: - if (value_.map_ != nullptr) - return iterator(value_.map_->begin()); + case ArrayValue: + case ObjectValue: + if (value_.mapVal != nullptr) + return iterator(value_.mapVal->begin()); break; default: break; @@ -1196,10 +1196,10 @@ Value::end() { switch (type_) { - case arrayValue: - case objectValue: - if (value_.map_ != nullptr) - return iterator(value_.map_->end()); + case ArrayValue: + case ObjectValue: + if (value_.mapVal != nullptr) + return iterator(value_.mapVal->end()); break; default: break; @@ -1208,4 +1208,4 @@ Value::end() return iterator(); } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/json_valueiterator.cpp b/src/libxrpl/json/json_valueiterator.cpp index 595835d9c0..5a3a5ffcdb 100644 --- a/src/libxrpl/json/json_valueiterator.cpp +++ b/src/libxrpl/json/json_valueiterator.cpp @@ -3,7 +3,7 @@ #include #include -namespace Json { +namespace json { // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// @@ -89,12 +89,12 @@ ValueIteratorBase::key() const { Value::CZString const czString = (*current_).first; - if (czString.c_str() != nullptr) + if (czString.cStr() != nullptr) { if (czString.isStaticString()) - return Value(StaticString(czString.c_str())); + return Value(StaticString(czString.cStr())); - return Value(czString.c_str()); + return Value(czString.cStr()); } return Value(czString.index()); @@ -105,7 +105,7 @@ ValueIteratorBase::index() const { Value::CZString const czString = (*current_).first; - if (czString.c_str() == nullptr) + if (czString.cStr() == nullptr) return czString.index(); return Value::UInt(-1); @@ -114,7 +114,7 @@ ValueIteratorBase::index() const char const* ValueIteratorBase::memberName() const { - char const* name = (*current_).first.c_str(); + char const* name = (*current_).first.cStr(); return (name != nullptr) ? name : ""; } @@ -164,4 +164,4 @@ ValueIterator::operator=(SelfType const& other) return *this; } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 7846ed6ce1..6c138e1fb1 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -13,7 +13,7 @@ #include #include -namespace Json { +namespace json { static bool isControlCharacter(char ch) @@ -59,7 +59,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - XRPL_ASSERT(current >= buffer, "Json::valueToString(Int) : buffer check"); + XRPL_ASSERT(current >= buffer, "json::valueToString(Int) : buffer check"); return current; } @@ -69,7 +69,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); // NOLINT(misc-const-correctness) uintToString(value, current); - XRPL_ASSERT(current >= buffer, "Json::valueToString(UInt) : buffer check"); + XRPL_ASSERT(current >= buffer, "json::valueToString(UInt) : buffer check"); return current; } @@ -188,31 +188,31 @@ FastWriter::writeValue(Value const& value) { switch (value.type()) { - case nullValue: + case NullValue: document_ += "null"; break; - case intValue: + case IntValue: document_ += valueToString(value.asInt()); break; - case uintValue: + case UintValue: document_ += valueToString(value.asUInt()); break; - case realValue: + case RealValue: document_ += valueToString(value.asDouble()); break; - case stringValue: + case StringValue: document_ += valueToQuotedString(value.asCString()); break; - case booleanValue: + case BooleanValue: document_ += valueToString(value.asBool()); break; - case arrayValue: { + case ArrayValue: { document_ += "["; int const size = value.size(); @@ -228,7 +228,7 @@ FastWriter::writeValue(Value const& value) } break; - case objectValue: { + case ObjectValue: { Value::Members members(value.getMemberNames()); document_ += "{"; @@ -271,35 +271,35 @@ StyledWriter::writeValue(Value const& value) { switch (value.type()) { - case nullValue: + case NullValue: pushValue("null"); break; - case intValue: + case IntValue: pushValue(valueToString(value.asInt())); break; - case uintValue: + case UintValue: pushValue(valueToString(value.asUInt())); break; - case realValue: + case RealValue: pushValue(valueToString(value.asDouble())); break; - case stringValue: + case StringValue: pushValue(valueToQuotedString(value.asCString())); break; - case booleanValue: + case BooleanValue: pushValue(valueToString(value.asBool())); break; - case arrayValue: + case ArrayValue: writeArrayValue(value); break; - case objectValue: { + case ObjectValue: { Value::Members members(value.getMemberNames()); if (members.empty()) @@ -381,7 +381,7 @@ StyledWriter::writeArrayValue(Value const& value) { XRPL_ASSERT( childValues_.size() == size, - "Json::StyledWriter::writeArrayValue : child size match"); + "json::StyledWriter::writeArrayValue : child size match"); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -478,7 +478,7 @@ StyledWriter::unindent() { XRPL_ASSERT( int(indentString_.size()) >= indentSize_, - "Json::StyledWriter::unindent : maximum indent size"); + "json::StyledWriter::unindent : maximum indent size"); indentString_.resize(indentString_.size() - indentSize_); } @@ -506,35 +506,35 @@ StyledStreamWriter::writeValue(Value const& value) { switch (value.type()) { - case nullValue: + case NullValue: pushValue("null"); break; - case intValue: + case IntValue: pushValue(valueToString(value.asInt())); break; - case uintValue: + case UintValue: pushValue(valueToString(value.asUInt())); break; - case realValue: + case RealValue: pushValue(valueToString(value.asDouble())); break; - case stringValue: + case StringValue: pushValue(valueToQuotedString(value.asCString())); break; - case booleanValue: + case BooleanValue: pushValue(valueToString(value.asBool())); break; - case arrayValue: + case ArrayValue: writeArrayValue(value); break; - case objectValue: { + case ObjectValue: { Value::Members members(value.getMemberNames()); if (members.empty()) @@ -616,7 +616,7 @@ StyledStreamWriter::writeArrayValue(Value const& value) { XRPL_ASSERT( childValues_.size() == size, - "Json::StyledStreamWriter::writeArrayValue : child size match"); + "json::StyledStreamWriter::writeArrayValue : child size match"); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -714,16 +714,16 @@ StyledStreamWriter::unindent() { XRPL_ASSERT( indentString_.size() >= indentation_.size(), - "Json::StyledStreamWriter::unindent : maximum indent size"); + "json::StyledStreamWriter::unindent : maximum indent size"); indentString_.resize(indentString_.size() - indentation_.size()); } std::ostream& operator<<(std::ostream& sout, Value const& root) { - Json::StyledStreamWriter writer; + json::StyledStreamWriter writer; writer.write(sout, root); return sout; } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/json/to_string.cpp b/src/libxrpl/json/to_string.cpp index 1d1a609366..b51c8f1eb6 100644 --- a/src/libxrpl/json/to_string.cpp +++ b/src/libxrpl/json/to_string.cpp @@ -4,7 +4,7 @@ #include -namespace Json { +namespace json { std::string to_string(Value const& value) @@ -18,4 +18,4 @@ pretty(Value const& value) return StyledWriter().write(value); } -} // namespace Json +} // namespace json diff --git a/src/libxrpl/ledger/AcceptedLedgerTx.cpp b/src/libxrpl/ledger/AcceptedLedgerTx.cpp index 21baa24323..304c99ffcb 100644 --- a/src/libxrpl/ledger/AcceptedLedgerTx.cpp +++ b/src/libxrpl/ledger/AcceptedLedgerTx.cpp @@ -25,35 +25,35 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::shared_ptr const& ledger, std::shared_ptr const& txn, std::shared_ptr const& met) - : mTxn(txn) - , mMeta(txn->getTransactionID(), ledger->seq(), *met) - , mAffected(mMeta.getAffectedAccounts()) + : txn_(txn) + , meta_(txn->getTransactionID(), ledger->seq(), *met) + , affected_(meta_.getAffectedAccounts()) { XRPL_ASSERT(!ledger->open(), "xrpl::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state"); Serializer s; met->add(s); - mRawMeta = std::move(s.modData()); + rawMeta_ = std::move(s.modData()); - mJson = Json::objectValue; - mJson[jss::transaction] = mTxn->getJson(JsonOptions::none); + json_ = json::ObjectValue; + json_[jss::transaction] = txn_->getJson(JsonOptions::KNone); - mJson[jss::meta] = mMeta.getJson(JsonOptions::none); - mJson[jss::raw_meta] = strHex(mRawMeta); + json_[jss::meta] = meta_.getJson(JsonOptions::KNone); + json_[jss::raw_meta] = strHex(rawMeta_); - mJson[jss::result] = transHuman(mMeta.getResultTER()); + json_[jss::result] = transHuman(meta_.getResultTER()); - if (!mAffected.empty()) + if (!affected_.empty()) { - Json::Value& affected = (mJson[jss::affected] = Json::arrayValue); - for (auto const& account : mAffected) + json::Value& affected = (json_[jss::affected] = json::ArrayValue); + for (auto const& account : affected_) affected.append(toBase58(account)); } - if (mTxn->getTxnType() == ttOFFER_CREATE) + if (txn_->getTxnType() == ttOFFER_CREATE) { - auto const& account = mTxn->getAccountID(sfAccount); - auto const amount = mTxn->getFieldAmount(sfTakerGets); + auto const& account = txn_->getAccountID(sfAccount); + auto const amount = txn_->getFieldAmount(sfTakerGets); // If the offer create is not self funded then add the owner balance if (account != amount.getIssuer()) @@ -62,10 +62,10 @@ AcceptedLedgerTx::AcceptedLedgerTx( *ledger, account, amount, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, beast::Journal{beast::Journal::getNullSink()}); - mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText(); + json_[jss::transaction][jss::owner_funds] = ownerFunds.getText(); } } } @@ -73,8 +73,8 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::string AcceptedLedgerTx::getEscMeta() const { - XRPL_ASSERT(!mRawMeta.empty(), "xrpl::AcceptedLedgerTx::getEscMeta : metadata is set"); - return sqlBlobLiteral(mRawMeta); + XRPL_ASSERT(!rawMeta_.empty(), "xrpl::AcceptedLedgerTx::getEscMeta : metadata is set"); + return sqlBlobLiteral(rawMeta_); } } // namespace xrpl diff --git a/src/libxrpl/ledger/ApplyStateTable.cpp b/src/libxrpl/ledger/ApplyStateTable.cpp index d7cbcb06e8..f49b1d0122 100644 --- a/src/libxrpl/ledger/ApplyStateTable.cpp +++ b/src/libxrpl/ledger/ApplyStateTable.cpp @@ -43,15 +43,15 @@ ApplyStateTable::apply(RawView& to) const auto const& sle = item.second.second; switch (item.second.first) { - case Action::cache: + case Action::Cache: break; - case Action::erase: + case Action::Erase: to.rawErase(sle); break; - case Action::insert: + case Action::Insert: to.rawInsert(sle); break; - case Action::modify: + case Action::Modify: to.rawReplace(sle); break; }; @@ -66,9 +66,9 @@ ApplyStateTable::size() const { switch (item.second.first) { - case Action::erase: - case Action::insert: - case Action::modify: + case Action::Erase: + case Action::Insert: + case Action::Modify: ++ret; default: break; @@ -90,15 +90,15 @@ ApplyStateTable::visit( { switch (item.second.first) { - case Action::erase: + case Action::Erase: func(item.first, true, to.read(keylet::unchecked(item.first)), item.second.second); break; - case Action::insert: + case Action::Insert: func(item.first, false, nullptr, item.second.second); break; - case Action::modify: + case Action::Modify: func(item.first, false, to.read(keylet::unchecked(item.first)), item.second.second); break; @@ -137,15 +137,15 @@ ApplyStateTable::apply( switch (item.second.first) { default: - case Action::cache: + case Action::Cache: continue; - case Action::erase: + case Action::Erase: type = &sfDeletedNode; break; - case Action::insert: + case Action::Insert: type = &sfCreatedNode; break; - case Action::modify: + case Action::Modify: type = &sfModifiedNode; break; } @@ -169,24 +169,24 @@ ApplyStateTable::apply( { // go through the original node for // modified fields saved on modification - if (obj.getFName().shouldMeta(SField::sMD_ChangeOrig) && + if (obj.getFName().shouldMeta(SField::SMdChangeOrig) && !curNode->hasMatchingEntry(obj)) - prevs.emplace_back(obj); + prevs.emplaceBack(obj); } if (!prevs.empty()) - meta.getAffectedNode(item.first).emplace_back(std::move(prevs)); + meta.getAffectedNode(item.first).emplaceBack(std::move(prevs)); STObject finals(sfFinalFields); for (auto const& obj : *curNode) { // go through the final node for final fields - if (obj.getFName().shouldMeta(SField::sMD_Always | SField::sMD_DeleteFinal)) - finals.emplace_back(obj); + if (obj.getFName().shouldMeta(SField::SMdAlways | SField::SMdDeleteFinal)) + finals.emplaceBack(obj); } if (!finals.empty()) - meta.getAffectedNode(item.first).emplace_back(std::move(finals)); + meta.getAffectedNode(item.first).emplaceBack(std::move(finals)); } else if (type == &sfModifiedNode) { @@ -205,24 +205,24 @@ ApplyStateTable::apply( for (auto const& obj : *origNode) { // search the original node for values saved on modify - if (obj.getFName().shouldMeta(SField::sMD_ChangeOrig) && + if (obj.getFName().shouldMeta(SField::SMdChangeOrig) && !curNode->hasMatchingEntry(obj)) - prevs.emplace_back(obj); + prevs.emplaceBack(obj); } if (!prevs.empty()) - meta.getAffectedNode(item.first).emplace_back(std::move(prevs)); + meta.getAffectedNode(item.first).emplaceBack(std::move(prevs)); STObject finals(sfFinalFields); for (auto const& obj : *curNode) { // search the final node for values saved always - if (obj.getFName().shouldMeta(SField::sMD_Always | SField::sMD_ChangeNew)) - finals.emplace_back(obj); + if (obj.getFName().shouldMeta(SField::SMdAlways | SField::SMdChangeNew)) + finals.emplaceBack(obj); } if (!finals.empty()) - meta.getAffectedNode(item.first).emplace_back(std::move(finals)); + meta.getAffectedNode(item.first).emplaceBack(std::move(finals)); } else if (type == &sfCreatedNode) // if created, thread to owner(s) { @@ -240,12 +240,12 @@ ApplyStateTable::apply( { // save non-default values if (!obj.isDefault() && - obj.getFName().shouldMeta(SField::sMD_Create | SField::sMD_Always)) - news.emplace_back(obj); + obj.getFName().shouldMeta(SField::SMdCreate | SField::SMdAlways)) + news.emplaceBack(obj); } if (!news.empty()) - meta.getAffectedNode(item.first).emplace_back(std::move(news)); + meta.getAffectedNode(item.first).emplaceBack(std::move(news)); } else { @@ -269,7 +269,7 @@ ApplyStateTable::apply( // VFALCO For diagnostics do we want to show // metadata even when the base view is open? - JLOG(j.trace()) << "metadata " << meta.getJson(JsonOptions::none); + JLOG(j.trace()) << "metadata " << meta.getJson(JsonOptions::KNone); metadata = meta; } @@ -294,11 +294,11 @@ ApplyStateTable::exists(ReadView const& base, Keylet const& k) const auto const& sle = item.second; switch (item.first) { - case Action::erase: + case Action::Erase: return false; - case Action::cache: - case Action::insert: - case Action::modify: + case Action::Cache: + case Action::Insert: + case Action::Modify: break; } return k.check(*sle); @@ -320,11 +320,11 @@ ApplyStateTable::succ( if (!next) break; iter = items_.find(*next); - } while (iter != items_.end() && iter->second.first == Action::erase); + } while (iter != items_.end() && iter->second.first == Action::Erase); // Find non-deleted successor in our list for (iter = items_.upper_bound(key); iter != items_.end(); ++iter) { - if (iter->second.first != Action::erase) + if (iter->second.first != Action::Erase) { // Found both, return the lower key if (!next || next > iter->first) @@ -349,11 +349,11 @@ ApplyStateTable::read(ReadView const& base, Keylet const& k) const auto const& sle = item.second; switch (item.first) { - case Action::erase: + case Action::Erase: return nullptr; - case Action::cache: - case Action::insert: - case Action::modify: + case Action::Cache: + case Action::Insert: + case Action::Modify: break; }; if (!k.check(*sle)) @@ -376,18 +376,18 @@ ApplyStateTable::peek(ReadView const& base, Keylet const& k) iter, piecewise_construct, forward_as_tuple(sle->key()), - forward_as_tuple(Action::cache, make_shared(*sle))); + forward_as_tuple(Action::Cache, make_shared(*sle))); return iter->second.second; } auto const& item = iter->second; auto const& sle = item.second; switch (item.first) { - case Action::erase: + case Action::Erase: return nullptr; - case Action::cache: - case Action::insert: - case Action::modify: + case Action::Cache: + case Action::Insert: + case Action::Modify: break; }; if (!k.check(*sle)) @@ -406,15 +406,15 @@ ApplyStateTable::erase(ReadView const& base, std::shared_ptr const& sle) Throw("ApplyStateTable::erase: unknown SLE"); switch (item.first) { - case Action::erase: + case Action::Erase: Throw("ApplyStateTable::erase: double erase"); break; - case Action::insert: + case Action::Insert: items_.erase(iter); break; - case Action::cache: - case Action::modify: - item.first = Action::erase; + case Action::Cache: + case Action::Modify: + item.first = Action::Erase; break; } } @@ -424,21 +424,21 @@ ApplyStateTable::rawErase(ReadView const& base, std::shared_ptr const& sle) { using namespace std; auto const result = items_.emplace( - piecewise_construct, forward_as_tuple(sle->key()), forward_as_tuple(Action::erase, sle)); + piecewise_construct, forward_as_tuple(sle->key()), forward_as_tuple(Action::Erase, sle)); if (result.second) return; auto& item = result.first->second; switch (item.first) { - case Action::erase: + case Action::Erase: Throw("ApplyStateTable::rawErase: double erase"); break; - case Action::insert: + case Action::Insert: items_.erase(result.first); break; - case Action::cache: - case Action::modify: - item.first = Action::erase; + case Action::Cache: + case Action::Modify: + item.first = Action::Erase; item.second = sle; break; } @@ -455,22 +455,22 @@ ApplyStateTable::insert(ReadView const& base, std::shared_ptr const& sle) iter, piecewise_construct, forward_as_tuple(sle->key()), - forward_as_tuple(Action::insert, sle)); + forward_as_tuple(Action::Insert, sle)); return; } auto& item = iter->second; switch (item.first) { - case Action::cache: + case Action::Cache: Throw("ApplyStateTable::insert: already cached"); - case Action::insert: + case Action::Insert: Throw("ApplyStateTable::insert: already inserted"); - case Action::modify: + case Action::Modify: Throw("ApplyStateTable::insert: already modified"); - case Action::erase: + case Action::Erase: break; } - item.first = Action::modify; + item.first = Action::Modify; item.second = sle; } @@ -485,19 +485,19 @@ ApplyStateTable::replace(ReadView const& base, std::shared_ptr const& sle) iter, piecewise_construct, forward_as_tuple(sle->key()), - forward_as_tuple(Action::modify, sle)); + forward_as_tuple(Action::Modify, sle)); return; } auto& item = iter->second; switch (item.first) { - case Action::erase: + case Action::Erase: Throw("ApplyStateTable::replace: already erased"); - case Action::cache: - item.first = Action::modify; + case Action::Cache: + item.first = Action::Modify; break; - case Action::insert: - case Action::modify: + case Action::Insert: + case Action::Modify: break; } item.second = sle; @@ -514,14 +514,14 @@ ApplyStateTable::update(ReadView const& base, std::shared_ptr const& sle) Throw("ApplyStateTable::update: unknown SLE"); switch (item.first) { - case Action::erase: + case Action::Erase: Throw("ApplyStateTable::update: erased"); break; - case Action::cache: - item.first = Action::modify; + case Action::Cache: + item.first = Action::Modify; break; - case Action::insert: - case Action::modify: + case Action::Insert: + case Action::Modify: break; }; } @@ -584,7 +584,7 @@ ApplyStateTable::getForMod(ReadView const& base, key_type const& key, Mods& mods if (iter != items_.end()) { auto const& item = iter->second; - if (item.first == Action::erase) + if (item.first == Action::Erase) { // The Destination of an Escrow or a PayChannel may have been // deleted. In that case the account we're threading to will @@ -592,7 +592,7 @@ ApplyStateTable::getForMod(ReadView const& base, key_type const& key, Mods& mods JLOG(j.warn()) << "Trying to thread to deleted node"; return nullptr; } - if (item.first != Action::cache) + if (item.first != Action::Cache) return item.second; // If it's only cached, then the node is being modified only by diff --git a/src/libxrpl/ledger/ApplyView.cpp b/src/libxrpl/ledger/ApplyView.cpp index a3b138dc63..3343748a75 100644 --- a/src/libxrpl/ledger/ApplyView.cpp +++ b/src/libxrpl/ledger/ApplyView.cpp @@ -38,7 +38,7 @@ createRoot( describe(newRoot); STVector256 v; - v.push_back(key); + v.pushBack(key); newRoot->setFieldV256(sfIndexes, v); view.insert(newRoot); @@ -80,7 +80,7 @@ insertKey( if (std::ranges::find(indexes, key) != indexes.end()) Throw("dirInsert: double insertion"); // LCOV_EXCL_LINE - indexes.push_back(key); + indexes.pushBack(key); } else { @@ -125,7 +125,7 @@ insertPage( // Check whether we're out of pages. if (page == 0) return std::nullopt; - if (!view.rules().enabled(fixDirectoryLimit) && page >= dirNodeMaxPages) // Old pages limit + if (!view.rules().enabled(fixDirectoryLimit) && page >= kDIR_NODE_MAX_PAGES) // Old pages limit return std::nullopt; // We are about to create a new node; we'll link it to @@ -138,7 +138,7 @@ insertPage( // Insert the new key: STVector256 indexes; - indexes.push_back(key); + indexes.pushBack(key); node = std::make_shared(keylet::page(directory, page)); node->setFieldH256(sfRootIndex, directory.key); @@ -179,7 +179,7 @@ ApplyView::dirAdd( auto [page, node, indexes] = directory::findPreviousPage(*this, directory, root); // If there's space, we use it: - if (indexes.size() < dirNodeMaxEntries) + if (indexes.size() < kDIR_NODE_MAX_ENTRIES) { return directory::insertKey(*this, node, page, preserveOrder, indexes, key); } @@ -208,19 +208,19 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (!node->getFieldV256(sfIndexes).empty()) return false; - std::uint64_t constexpr rootPage = 0; + std::uint64_t constexpr kROOT_PAGE = 0; auto prevPage = node->getFieldU64(sfIndexPrevious); auto nextPage = node->getFieldU64(sfIndexNext); - if (nextPage == rootPage && prevPage != rootPage) + if (nextPage == kROOT_PAGE && prevPage != kROOT_PAGE) Throw("Directory chain: fwd link broken"); // LCOV_EXCL_LINE - if (prevPage == rootPage && nextPage != rootPage) + if (prevPage == kROOT_PAGE && nextPage != kROOT_PAGE) Throw("Directory chain: rev link broken"); // LCOV_EXCL_LINE - // Older versions of the code would, in some cases, allow the last page to - // be empty. Remove such pages: - if (nextPage == prevPage && nextPage != rootPage) + // Older versions of the code would, in some cases, allow the last + // page to be empty. Remove such pages: + if (nextPage == prevPage && nextPage != kROOT_PAGE) { auto last = peek(keylet::page(directory, nextPage)); @@ -230,21 +230,23 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (!last->getFieldV256(sfIndexes).empty()) return false; - // Update the first page's linked list and mark it as updated. - node->setFieldU64(sfIndexNext, rootPage); - node->setFieldU64(sfIndexPrevious, rootPage); + // Update the first page's linked list and + // mark it as updated. + node->setFieldU64(sfIndexNext, kROOT_PAGE); + node->setFieldU64(sfIndexPrevious, kROOT_PAGE); update(node); // And erase the empty last page: erase(last); - // Make sure our local values reflect the updated information: - nextPage = rootPage; - prevPage = rootPage; + // Make sure our local values reflect the + // updated information: + nextPage = kROOT_PAGE; + prevPage = kROOT_PAGE; } // If there are no other pages, erase the root: - if (nextPage == rootPage && prevPage == rootPage) + if (nextPage == kROOT_PAGE && prevPage == kROOT_PAGE) erase(node); return true; @@ -258,7 +260,7 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& if (!node) return false; - std::uint64_t constexpr rootPage = 0; + std::uint64_t constexpr kROOT_PAGE = 0; { auto entries = node->getFieldV256(sfIndexes); @@ -283,10 +285,11 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& auto prevPage = node->getFieldU64(sfIndexPrevious); auto nextPage = node->getFieldU64(sfIndexNext); - // The first page is the directory's root node and is treated specially: it - // can never be deleted even if it is empty, unless we plan on removing the - // entire directory. - if (page == rootPage) + // The first page is the directory's root node and is + // treated specially: it can never be deleted even if + // it is empty, unless we plan on removing the entire + // directory. + if (page == kROOT_PAGE) { if (nextPage == page && prevPage != page) Throw("Directory chain: fwd link broken"); // LCOV_EXCL_LINE @@ -355,32 +358,32 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const& // The page is no longer linked. Delete it. erase(node); - // Check whether the next page is the last page and, if so, whether it's - // empty. If it is, delete it. - if (nextPage != rootPage && next->getFieldU64(sfIndexNext) == rootPage && + // Check whether the next page is the last page and, if + // so, whether it's empty. If it is, delete it. + if (nextPage != kROOT_PAGE && next->getFieldU64(sfIndexNext) == kROOT_PAGE && next->getFieldV256(sfIndexes).empty()) { // Since next doesn't point to the root, it can't be pointing to prev. erase(next); // The previous page is now the last page: - prev->setFieldU64(sfIndexNext, rootPage); + prev->setFieldU64(sfIndexNext, kROOT_PAGE); update(prev); // And the root points to the last page: - auto root = peek(keylet::page(directory, rootPage)); + auto root = peek(keylet::page(directory, kROOT_PAGE)); if (!root) Throw("Directory chain: root link broken."); // LCOV_EXCL_LINE root->setFieldU64(sfIndexPrevious, prevPage); update(root); - nextPage = rootPage; + nextPage = kROOT_PAGE; } - // If we're not keeping the root, then check to see if it's left empty. - // If so, delete it as well. - if (!keepRoot && nextPage == rootPage && prevPage == rootPage) + // If we're not keeping the root, then check to see if + // it's left empty. If so, delete it as well. + if (!keepRoot && nextPage == kROOT_PAGE && prevPage == kROOT_PAGE) { if (prev->getFieldV256(sfIndexes).empty()) erase(prev); diff --git a/src/libxrpl/ledger/ApplyViewBase.cpp b/src/libxrpl/ledger/ApplyViewBase.cpp index d617279a80..e5a8e11b4c 100644 --- a/src/libxrpl/ledger/ApplyViewBase.cpp +++ b/src/libxrpl/ledger/ApplyViewBase.cpp @@ -65,31 +65,31 @@ ApplyViewBase::read(Keylet const& k) const } auto -ApplyViewBase::slesBegin() const -> std::unique_ptr +ApplyViewBase::slesBegin() const -> std::unique_ptr { return base_->slesBegin(); } auto -ApplyViewBase::slesEnd() const -> std::unique_ptr +ApplyViewBase::slesEnd() const -> std::unique_ptr { return base_->slesEnd(); } auto -ApplyViewBase::slesUpperBound(uint256 const& key) const -> std::unique_ptr +ApplyViewBase::slesUpperBound(uint256 const& key) const -> std::unique_ptr { return base_->slesUpperBound(key); } auto -ApplyViewBase::txsBegin() const -> std::unique_ptr +ApplyViewBase::txsBegin() const -> std::unique_ptr { return base_->txsBegin(); } auto -ApplyViewBase::txsEnd() const -> std::unique_ptr +ApplyViewBase::txsEnd() const -> std::unique_ptr { return base_->txsEnd(); } diff --git a/src/libxrpl/ledger/BookDirs.cpp b/src/libxrpl/ledger/BookDirs.cpp index cbe93a159b..fbe876669e 100644 --- a/src/libxrpl/ledger/BookDirs.cpp +++ b/src/libxrpl/ledger/BookDirs.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include @@ -16,10 +15,10 @@ BookDirs::BookDirs(ReadView const& view, Book const& book) : view_(&view) , root_(keylet::page(getBookBase(book)).key) , next_quality_(getQualityNext(root_)) - , key_(view_->succ(root_, next_quality_).value_or(beast::zero)) + , key_(view_->succ(root_, next_quality_).value_or(beast::kZERO)) { - XRPL_ASSERT(root_ != beast::zero, "xrpl::BookDirs::BookDirs : nonzero root"); - if (key_ != beast::zero) + XRPL_ASSERT(root_ != beast::kZERO, "xrpl::BookDirs::BookDirs : nonzero root"); + if (key_ != beast::kZERO) { if (!cdirFirst(*view_, key_, sle_, entry_, index_)) { @@ -34,7 +33,7 @@ auto BookDirs::begin() const -> BookDirs::const_iterator { auto it = BookDirs::const_iterator(*view_, root_, key_); - if (key_ != beast::zero) + if (key_ != beast::kZERO) { it.next_quality_ = next_quality_; it.sle_ = sle_; @@ -50,8 +49,6 @@ BookDirs::end() const -> BookDirs::const_iterator return BookDirs::const_iterator(*view_, root_, key_); } -beast::Journal BookDirs::const_iterator::j_ = beast::Journal{beast::Journal::getNullSink()}; - bool BookDirs::const_iterator::operator==(BookDirs::const_iterator const& other) const { @@ -68,7 +65,8 @@ BookDirs::const_iterator::operator==(BookDirs::const_iterator const& other) cons BookDirs::const_iterator::reference BookDirs::const_iterator::operator*() const { - XRPL_ASSERT(index_ != beast::zero, "xrpl::BookDirs::const_iterator::operator* : nonzero index"); + XRPL_ASSERT( + index_ != beast::kZERO, "xrpl::BookDirs::const_iterator::operator* : nonzero index"); if (!cache_) cache_ = view_->read(keylet::offer(index_)); return *cache_; @@ -77,19 +75,19 @@ BookDirs::const_iterator::operator*() const BookDirs::const_iterator& BookDirs::const_iterator::operator++() { - using beast::zero; + using beast::kZERO; - XRPL_ASSERT(index_ != zero, "xrpl::BookDirs::const_iterator::operator++ : nonzero index"); + XRPL_ASSERT(index_ != kZERO, "xrpl::BookDirs::const_iterator::operator++ : nonzero index"); if (!cdirNext(*view_, cur_key_, sle_, entry_, index_)) { if (index_ == 0) - cur_key_ = view_->succ(++cur_key_, next_quality_).value_or(zero); + cur_key_ = view_->succ(++cur_key_, next_quality_).value_or(kZERO); - if (index_ != 0 || cur_key_ == zero) + if (index_ != 0 || cur_key_ == kZERO) { cur_key_ = key_; entry_ = 0; - index_ = zero; + index_ = kZERO; } else if (!cdirFirst(*view_, cur_key_, sle_, entry_, index_)) { @@ -107,7 +105,7 @@ BookDirs::const_iterator BookDirs::const_iterator::operator++(int) { XRPL_ASSERT( - index_ != beast::zero, "xrpl::BookDirs::const_iterator::operator++(int) : nonzero index"); + index_ != beast::kZERO, "xrpl::BookDirs::const_iterator::operator++(int) : nonzero index"); const_iterator tmp(*this); ++(*this); return tmp; diff --git a/src/libxrpl/ledger/BookListeners.cpp b/src/libxrpl/ledger/BookListeners.cpp index d922dc3a67..d78da4c73e 100644 --- a/src/libxrpl/ledger/BookListeners.cpp +++ b/src/libxrpl/ledger/BookListeners.cpp @@ -13,24 +13,24 @@ namespace xrpl { void BookListeners::addSubscriber(InfoSub::ref sub) { - std::scoped_lock const sl(mLock); - mListeners[sub->getSeq()] = sub; + std::scoped_lock const sl(lock_); + listeners_[sub->getSeq()] = sub; } void BookListeners::removeSubscriber(std::uint64_t seq) { - std::scoped_lock const sl(mLock); - mListeners.erase(seq); + std::scoped_lock const sl(lock_); + listeners_.erase(seq); } void BookListeners::publish(MultiApiJson const& jvObj, hash_set& havePublished) { - std::scoped_lock const sl(mLock); - auto it = mListeners.cbegin(); + std::scoped_lock const sl(lock_); + auto it = listeners_.cbegin(); - while (it != mListeners.cend()) + while (it != listeners_.cend()) { InfoSub::pointer p = it->second.lock(); @@ -41,13 +41,13 @@ BookListeners::publish(MultiApiJson const& jvObj, hash_set& haveP { jvObj.visit( p->getApiVersion(), // - [&](Json::Value const& jv) { p->send(jv, true); }); + [&](json::Value const& jv) { p->send(jv, true); }); } ++it; } else { - it = mListeners.erase(it); + it = listeners_.erase(it); } } } diff --git a/src/libxrpl/ledger/CachedView.cpp b/src/libxrpl/ledger/CachedView.cpp index bb7ff97153..2dc28d67e0 100644 --- a/src/libxrpl/ledger/CachedView.cpp +++ b/src/libxrpl/ledger/CachedView.cpp @@ -22,9 +22,9 @@ CachedViewImpl::exists(Keylet const& k) const std::shared_ptr CachedViewImpl::read(Keylet const& k) const { - static CountedObjects::Counter hits{"CachedView::hit"}; - static CountedObjects::Counter hitsexpired{"CachedView::hitExpired"}; - static CountedObjects::Counter misses{"CachedView::miss"}; + static CountedObjects::Counter kHITS{"CachedView::hit"}; + static CountedObjects::Counter kHITSEXPIRED{"CachedView::hitExpired"}; + static CountedObjects::Counter kMISSES{"CachedView::miss"}; bool cacheHit = false; bool baseRead = false; @@ -50,15 +50,15 @@ CachedViewImpl::read(Keylet const& k) const XRPL_ASSERT(sle || baseRead, "xrpl::CachedView::read : null SLE result from base"); if (cacheHit && baseRead) { - hitsexpired.increment(); + kHITSEXPIRED.increment(); } else if (cacheHit) { - hits.increment(); + kHITS.increment(); } else { - misses.increment(); + kMISSES.increment(); } if (!cacheHit) diff --git a/src/libxrpl/ledger/CanonicalTXSet.cpp b/src/libxrpl/ledger/CanonicalTXSet.cpp index be5006d33b..bfa3d811e6 100644 --- a/src/libxrpl/ledger/CanonicalTXSet.cpp +++ b/src/libxrpl/ledger/CanonicalTXSet.cpp @@ -33,7 +33,7 @@ operator<(CanonicalTXSet::Key const& lhs, CanonicalTXSet::Key const& rhs) uint256 CanonicalTXSet::accountKey(AccountID const& account) { - uint256 ret = beast::zero; + uint256 ret = beast::kZERO; memcpy(ret.begin(), account.begin(), account.size()); ret ^= salt_; return ret; @@ -68,7 +68,7 @@ CanonicalTXSet::popAcctTransaction(std::shared_ptr const& tx) uint256 const effectiveAccount{accountKey(tx->getAccountID(sfAccount))}; auto const seqProxy = tx->getSeqProxy(); - Key const after(effectiveAccount, seqProxy, beast::zero); + Key const after(effectiveAccount, seqProxy, beast::kZERO); auto const itrNext{map_.lower_bound(after)}; if (itrNext != map_.end() && itrNext->first.getAccount() == effectiveAccount && (!itrNext->second->getSeqProxy().isSeq() || diff --git a/src/libxrpl/ledger/Dir.cpp b/src/libxrpl/ledger/Dir.cpp index bf5eaf02fd..a633257b27 100644 --- a/src/libxrpl/ledger/Dir.cpp +++ b/src/libxrpl/ledger/Dir.cpp @@ -13,7 +13,7 @@ namespace xrpl { -using const_iterator = Dir::const_iterator; +using const_iterator = Dir::ConstIterator; Dir::Dir(ReadView const& view, Keylet const& key) : view_(&view), root_(key), sle_(view_->read(root_)) @@ -23,9 +23,9 @@ Dir::Dir(ReadView const& view, Keylet const& key) } auto -Dir::begin() const -> const_iterator +Dir::begin() const -> ConstIterator { - auto it = const_iterator(*view_, root_, root_); + auto it = ConstIterator(*view_, root_, root_); if (sle_ != nullptr) { it.sle_ = sle_; @@ -41,13 +41,13 @@ Dir::begin() const -> const_iterator } auto -Dir::end() const -> const_iterator +Dir::end() const -> ConstIterator { - return const_iterator(*view_, root_, root_); + return ConstIterator(*view_, root_, root_); } bool -const_iterator::operator==(const_iterator const& other) const +const_iterator::operator==(ConstIterator const& other) const { if (view_ == nullptr || other.view_ == nullptr) return false; @@ -61,7 +61,7 @@ const_iterator::operator==(const_iterator const& other) const const_iterator::reference const_iterator::operator*() const { - XRPL_ASSERT(index_ != beast::zero, "xrpl::const_iterator::operator* : nonzero index"); + XRPL_ASSERT(index_ != beast::kZERO, "xrpl::const_iterator::operator* : nonzero index"); if (!cache_) cache_ = view_->read(keylet::child(index_)); return *cache_; @@ -70,7 +70,7 @@ const_iterator::operator*() const const_iterator& const_iterator::operator++() { - XRPL_ASSERT(index_ != beast::zero, "xrpl::const_iterator::operator++ : nonzero index"); + XRPL_ASSERT(index_ != beast::kZERO, "xrpl::const_iterator::operator++ : nonzero index"); if (++it_ != std::end(*indexes_)) { index_ = *it_; @@ -78,26 +78,26 @@ const_iterator::operator++() return *this; } - return next_page(); + return nextPage(); } const_iterator const_iterator::operator++(int) { - XRPL_ASSERT(index_ != beast::zero, "xrpl::const_iterator::operator++(int) : nonzero index"); - const_iterator tmp(*this); + XRPL_ASSERT(index_ != beast::kZERO, "xrpl::const_iterator::operator++(int) : nonzero index"); + ConstIterator tmp(*this); ++(*this); return tmp; } const_iterator& -const_iterator::next_page() +const_iterator::nextPage() { auto const next = sle_->getFieldU64(sfIndexNext); if (next == 0) { page_.key = root_.key; - index_ = beast::zero; + index_ = beast::kZERO; } else { @@ -107,7 +107,7 @@ const_iterator::next_page() indexes_ = &sle_->getFieldV256(sfIndexes); if (indexes_->empty()) { - index_ = beast::zero; + index_ = beast::kZERO; } else { @@ -120,7 +120,7 @@ const_iterator::next_page() } std::size_t -const_iterator::page_size() +const_iterator::pageSize() { return indexes_->size(); } diff --git a/src/libxrpl/ledger/Ledger.cpp b/src/libxrpl/ledger/Ledger.cpp index 6630d4f9bf..9857b49b65 100644 --- a/src/libxrpl/ledger/Ledger.cpp +++ b/src/libxrpl/ledger/Ledger.cpp @@ -46,36 +46,36 @@ namespace xrpl { -create_genesis_t const create_genesis{}; +CreateGenesisT const kCREATE_GENESIS{}; //------------------------------------------------------------------------------ -class Ledger::sles_iter_impl : public sles_type::iter_base +class Ledger::SlesIterImpl : public SlesType::iter_base { private: - SHAMap::const_iterator iter_; + SHAMap::ConstIterator iter_; public: - sles_iter_impl() = delete; - sles_iter_impl& - operator=(sles_iter_impl const&) = delete; + SlesIterImpl() = delete; + SlesIterImpl& + operator=(SlesIterImpl const&) = delete; - sles_iter_impl(sles_iter_impl const&) = default; + SlesIterImpl(SlesIterImpl const&) = default; - sles_iter_impl(SHAMap::const_iterator iter) : iter_(iter) + SlesIterImpl(SHAMap::ConstIterator iter) : iter_(iter) { } [[nodiscard]] std::unique_ptr copy() const override { - return std::make_unique(*this); + return std::make_unique(*this); } [[nodiscard]] bool equal(base_type const& impl) const override { - if (auto const p = dynamic_cast(&impl)) + if (auto const p = dynamic_cast(&impl)) return iter_ == p->iter_; return false; } @@ -86,7 +86,7 @@ public: ++iter_; } - [[nodiscard]] sles_type::value_type + [[nodiscard]] SlesType::value_type dereference() const override { SerialIter sit(iter_->slice()); @@ -96,33 +96,33 @@ public: //------------------------------------------------------------------------------ -class Ledger::txs_iter_impl : public txs_type::iter_base +class Ledger::TxsIterImpl : public TxsType::iter_base { private: bool metadata_; - SHAMap::const_iterator iter_; + SHAMap::ConstIterator iter_; public: - txs_iter_impl() = delete; - txs_iter_impl& - operator=(txs_iter_impl const&) = delete; + TxsIterImpl() = delete; + TxsIterImpl& + operator=(TxsIterImpl const&) = delete; - txs_iter_impl(txs_iter_impl const&) = default; + TxsIterImpl(TxsIterImpl const&) = default; - txs_iter_impl(bool metadata, SHAMap::const_iterator iter) : metadata_(metadata), iter_(iter) + TxsIterImpl(bool metadata, SHAMap::ConstIterator iter) : metadata_(metadata), iter_(iter) { } [[nodiscard]] std::unique_ptr copy() const override { - return std::make_unique(*this); + return std::make_unique(*this); } [[nodiscard]] bool equal(base_type const& impl) const override { - if (auto const p = dynamic_cast(&impl)) + if (auto const p = dynamic_cast(&impl)) return iter_ == p->iter_; return false; } @@ -133,7 +133,7 @@ public: ++iter_; } - [[nodiscard]] txs_type::value_type + [[nodiscard]] TxsType::value_type dereference() const override { auto const& item = *iter_; @@ -146,12 +146,12 @@ public: //------------------------------------------------------------------------------ Ledger::Ledger( - create_genesis_t, + CreateGenesisT, Rules rules, Fees const& fees, std::vector const& amendments, Family& family) - : mImmutable(false) + : immutable_(false) , txMap_(SHAMapType::TRANSACTION, family) , stateMap_(SHAMapType::STATE, family) , fees_(fees) @@ -159,15 +159,15 @@ Ledger::Ledger( , j_(beast::Journal(beast::Journal::getNullSink())) { header_.seq = 1; - header_.drops = INITIAL_XRP; - header_.closeTimeResolution = ledgerGenesisTimeResolution; + header_.drops = kINITIAL_XRP; + header_.closeTimeResolution = kLEDGER_GENESIS_TIME_RESOLUTION; - static auto const id = - calcAccountID(generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")).first); + static auto const kID = + calcAccountID(generateKeyPair(KeyType::Secp256k1, generateSeed("masterpassphrase")).first); { - auto const sle = std::make_shared(keylet::account(id)); + auto const sle = std::make_shared(keylet::account(kID)); sle->setFieldU32(sfSequence, 1); - sle->setAccountID(sfAccount, id); + sle->setAccountID(sfAccount, kID); sle->setFieldAmount(sfBalance, header_.drops); rawInsert(sle); } @@ -196,12 +196,12 @@ Ledger::Ledger( sle->at(sfReserveBase) = *f; if (auto const f = fees.increment.dropsAs()) sle->at(sfReserveIncrement) = *f; - sle->at(sfReferenceFeeUnits) = FEE_UNITS_DEPRECATED; + sle->at(sfReferenceFeeUnits) = kFEE_UNITS_DEPRECATED; } rawInsert(sle); } - stateMap_.flushDirty(NodeObjectType::hotACCOUNT_NODE); + stateMap_.flushDirty(NodeObjectType::AccountNode); setImmutable(); } @@ -213,7 +213,7 @@ Ledger::Ledger( Fees const& fees, Family& family, beast::Journal j) - : mImmutable(true) + : immutable_(true) , txMap_(SHAMapType::TRANSACTION, info.txHash, family) , stateMap_(SHAMapType::STATE, info.accountHash, family) , fees_(fees) @@ -252,7 +252,7 @@ Ledger::Ledger( // Create a new ledger that follows this one Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime) - : mImmutable(false) + : immutable_(false) , txMap_(SHAMapType::TRANSACTION, prevLedger.txMap_.family()) , stateMap_(prevLedger.stateMap_, true) , fees_(prevLedger.fees_) @@ -279,7 +279,7 @@ Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime) } Ledger::Ledger(LedgerHeader const& info, Rules rules, Family& family) - : mImmutable(true) + : immutable_(true) , txMap_(SHAMapType::TRANSACTION, info.txHash, family) , stateMap_(SHAMapType::STATE, info.accountHash, family) , rules_(std::move(rules)) @@ -295,7 +295,7 @@ Ledger::Ledger( Rules rules, Fees const& fees, Family& family) - : mImmutable(false) + : immutable_(false) , txMap_(SHAMapType::TRANSACTION, family) , stateMap_(SHAMapType::STATE, family) , fees_(fees) @@ -304,7 +304,7 @@ Ledger::Ledger( { header_.seq = ledgerSeq; header_.closeTime = closeTime; - header_.closeTimeResolution = ledgerDefaultTimeResolution; + header_.closeTimeResolution = kLEDGER_DEFAULT_TIME_RESOLUTION; setup(); } @@ -313,16 +313,16 @@ Ledger::setImmutable(bool rehash) { // Force update, since this is the only // place the hash transitions to valid - if (!mImmutable && rehash) + if (!immutable_ && rehash) { - header_.txHash = txMap_.getHash().as_uint256(); - header_.accountHash = stateMap_.getHash().as_uint256(); + header_.txHash = txMap_.getHash().asUint256(); + header_.accountHash = stateMap_.getHash().asUint256(); } if (rehash) header_.hash = calculateLedgerHash(header_); - mImmutable = true; + immutable_ = true; txMap_.setImmutable(); stateMap_.setImmutable(); setup(); @@ -339,7 +339,7 @@ Ledger::setAccepted( header_.closeTime = closeTime; header_.closeTimeResolution = closeResolution; - header_.closeFlags = correctCloseTime ? 0 : sLCF_NoConsensusTime; + header_.closeFlags = correctCloseTime ? 0 : kS_LCF_NO_CONSENSUS_TIME; setImmutable(); } @@ -347,8 +347,7 @@ bool Ledger::addSLE(SLE const& sle) { auto const s = sle.getSerializer(); - return stateMap_.addItem( - SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle.key(), s.slice())); + return stateMap_.addItem(SHAMapNodeType::TnAccountState, makeShamapitem(sle.key(), s.slice())); } //------------------------------------------------------------------------------ @@ -394,7 +393,7 @@ Ledger::exists(uint256 const& key) const std::optional Ledger::succ(uint256 const& key, std::optional const& last) const { - auto item = stateMap_.upper_bound(key); + auto item = stateMap_.upperBound(key); if (item == stateMap_.end()) return std::nullopt; if (last && item->key() >= last) @@ -405,7 +404,7 @@ Ledger::succ(uint256 const& key, std::optional const& last) const std::shared_ptr Ledger::read(Keylet const& k) const { - if (k.key == beast::zero) + if (k.key == beast::kZERO) { // LCOV_EXCL_START UNREACHABLE("xrpl::Ledger::read : zero key"); @@ -424,33 +423,33 @@ Ledger::read(Keylet const& k) const //------------------------------------------------------------------------------ auto -Ledger::slesBegin() const -> std::unique_ptr +Ledger::slesBegin() const -> std::unique_ptr { - return std::make_unique(stateMap_.begin()); + return std::make_unique(stateMap_.begin()); } auto -Ledger::slesEnd() const -> std::unique_ptr +Ledger::slesEnd() const -> std::unique_ptr { - return std::make_unique(stateMap_.end()); + return std::make_unique(stateMap_.end()); } auto -Ledger::slesUpperBound(uint256 const& key) const -> std::unique_ptr +Ledger::slesUpperBound(uint256 const& key) const -> std::unique_ptr { - return std::make_unique(stateMap_.upper_bound(key)); + return std::make_unique(stateMap_.upperBound(key)); } auto -Ledger::txsBegin() const -> std::unique_ptr +Ledger::txsBegin() const -> std::unique_ptr { - return std::make_unique(!open(), txMap_.begin()); + return std::make_unique(!open(), txMap_.begin()); } auto -Ledger::txsEnd() const -> std::unique_ptr +Ledger::txsEnd() const -> std::unique_ptr { - return std::make_unique(!open(), txMap_.end()); + return std::make_unique(!open(), txMap_.end()); } bool @@ -481,7 +480,7 @@ Ledger::digest(key_type const& key) const -> std::optional // from the NodeStore needlessly. if (!stateMap_.peekItem(key, digest)) return std::nullopt; - return digest.as_uint256(); + return digest.asUint256(); } //------------------------------------------------------------------------------ @@ -490,14 +489,14 @@ void Ledger::rawErase(std::shared_ptr const& sle) { if (!stateMap_.delItem(sle->key())) - LogicError("Ledger::rawErase: key not found"); + logicError("Ledger::rawErase: key not found"); } void Ledger::rawErase(uint256 const& key) { if (!stateMap_.delItem(key)) - LogicError("Ledger::rawErase: key not found"); + logicError("Ledger::rawErase: key not found"); } void @@ -506,8 +505,10 @@ Ledger::rawInsert(std::shared_ptr const& sle) Serializer ss; sle->add(ss); if (!stateMap_.addGiveItem( - SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) - LogicError("Ledger::rawInsert: key already exists"); + SHAMapNodeType::TnAccountState, makeShamapitem(sle->key(), ss.slice()))) + { + logicError("Ledger::rawInsert: key already exists"); + } } void @@ -516,8 +517,10 @@ Ledger::rawReplace(std::shared_ptr const& sle) Serializer ss; sle->add(ss); if (!stateMap_.updateGiveItem( - SHAMapNodeType::tnACCOUNT_STATE, make_shamapitem(sle->key(), ss.slice()))) - LogicError("Ledger::rawReplace: key not found"); + SHAMapNodeType::TnAccountState, makeShamapitem(sle->key(), ss.slice()))) + { + logicError("Ledger::rawReplace: key not found"); + } } void @@ -532,8 +535,8 @@ Ledger::rawTxInsert( Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); s.addVL(txn->peekData()); s.addVL(metaData->peekData()); - if (!txMap_.addGiveItem(SHAMapNodeType::tnTRANSACTION_MD, make_shamapitem(key, s.slice()))) - LogicError("duplicate_tx: " + to_string(key)); + if (!txMap_.addGiveItem(SHAMapNodeType::TnTransactionMd, makeShamapitem(key, s.slice()))) + logicError("duplicate_tx: " + to_string(key)); } bool @@ -552,7 +555,7 @@ Ledger::setup() catch (std::exception const& ex) { JLOG(j_.error()) << "Exception in " << __func__ << ": " << ex.what(); - Rethrow(); + rethrow(); } try @@ -614,7 +617,7 @@ Ledger::setup() catch (std::exception const& ex) { JLOG(j_.error()) << "Exception in " << __func__ << ": " << ex.what(); - Rethrow(); + rethrow(); } return ret; @@ -707,13 +710,13 @@ Ledger::updateNegativeUNL() if (hasToReEnable && v.isFieldPresent(sfPublicKey) && v.getFieldVL(sfPublicKey) == sle->getFieldVL(sfValidatorToReEnable)) continue; - newNUnl.push_back(v); + newNUnl.pushBack(v); } } if (hasToDisable) { - newNUnl.push_back(STObject::makeInnerObject(sfDisabledValidator)); + newNUnl.pushBack(STObject::makeInnerObject(sfDisabledValidator)); newNUnl.back().setFieldVL(sfPublicKey, sle->getFieldVL(sfValidatorToDisable)); newNUnl.back().setFieldU32(sfFirstLedgerSequence, seq()); } @@ -792,9 +795,9 @@ Ledger::isSensible() const return false; if (header_.accountHash.isZero()) return false; - if (header_.accountHash != stateMap_.getHash().as_uint256()) + if (header_.accountHash != stateMap_.getHash().asUint256()) return false; - if (header_.txHash != txMap_.getHash().as_uint256()) + if (header_.txHash != txMap_.getHash().asUint256()) return false; return true; } diff --git a/src/libxrpl/ledger/OpenView.cpp b/src/libxrpl/ledger/OpenView.cpp index 28da1aedcb..afe826d78d 100644 --- a/src/libxrpl/ledger/OpenView.cpp +++ b/src/libxrpl/ledger/OpenView.cpp @@ -24,14 +24,14 @@ namespace xrpl { -class OpenView::txs_iter_impl : public txs_type::iter_base +class OpenView::TxsIterImpl : public TxsType::iter_base { private: bool metadata_; txs_map::const_iterator iter_; public: - explicit txs_iter_impl(bool metadata, txs_map::const_iterator iter) + explicit TxsIterImpl(bool metadata, txs_map::const_iterator iter) : metadata_(metadata), iter_(iter) { } @@ -39,13 +39,13 @@ public: [[nodiscard]] std::unique_ptr copy() const override { - return std::make_unique(metadata_, iter_); + return std::make_unique(metadata_, iter_); } [[nodiscard]] bool equal(base_type const& impl) const override { - if (auto const p = dynamic_cast(&impl)) + if (auto const p = dynamic_cast(&impl)) return iter_ == p->iter_; return false; } @@ -79,7 +79,7 @@ OpenView::OpenView(OpenView const& rhs) : ReadView(rhs) , TxsRawView(rhs) , monotonic_resource_{std::make_unique( - initialBufferSize)} + kINITIAL_BUFFER_SIZE)} , txs_{rhs.txs_, monotonic_resource_.get()} , rules_{rhs.rules_} , header_{rhs.header_} @@ -88,13 +88,9 @@ OpenView::OpenView(OpenView const& rhs) , hold_{rhs.hold_} , open_{rhs.open_} {}; -OpenView::OpenView( - open_ledger_t, - ReadView const* base, - Rules rules, - std::shared_ptr hold) +OpenView::OpenView(OpenLedgerT, ReadView const* base, Rules rules, std::shared_ptr hold) : monotonic_resource_{ - std::make_unique(initialBufferSize)} + std::make_unique(kINITIAL_BUFFER_SIZE)} , txs_{monotonic_resource_.get()} , rules_(std::move(rules)) , header_(base->header()) @@ -110,7 +106,7 @@ OpenView::OpenView( OpenView::OpenView(ReadView const* base, std::shared_ptr hold) : monotonic_resource_{ - std::make_unique(initialBufferSize)} + std::make_unique(kINITIAL_BUFFER_SIZE)} , txs_{monotonic_resource_.get()} , rules_(base->rules()) , header_(base->header()) @@ -174,33 +170,33 @@ OpenView::read(Keylet const& k) const } auto -OpenView::slesBegin() const -> std::unique_ptr +OpenView::slesBegin() const -> std::unique_ptr { return items_.slesBegin(*base_); } auto -OpenView::slesEnd() const -> std::unique_ptr +OpenView::slesEnd() const -> std::unique_ptr { return items_.slesEnd(*base_); } auto -OpenView::slesUpperBound(uint256 const& key) const -> std::unique_ptr +OpenView::slesUpperBound(uint256 const& key) const -> std::unique_ptr { return items_.slesUpperBound(*base_, key); } auto -OpenView::txsBegin() const -> std::unique_ptr +OpenView::txsBegin() const -> std::unique_ptr { - return std::make_unique(!open(), txs_.cbegin()); + return std::make_unique(!open(), txs_.cbegin()); } auto -OpenView::txsEnd() const -> std::unique_ptr +OpenView::txsEnd() const -> std::unique_ptr { - return std::make_unique(!open(), txs_.cend()); + return std::make_unique(!open(), txs_.cend()); } bool diff --git a/src/libxrpl/ledger/PaymentSandbox.cpp b/src/libxrpl/ledger/PaymentSandbox.cpp index ef6e4be8ad..a730b247ba 100644 --- a/src/libxrpl/ledger/PaymentSandbox.cpp +++ b/src/libxrpl/ledger/PaymentSandbox.cpp @@ -321,7 +321,7 @@ PaymentSandbox::balanceHookIOU( auto adjustedAmt = std::min({amount, lastBal - delta, minBal}); adjustedAmt.get().account = amount.getIssuer(); - if (isXRP(issuer) && adjustedAmt < beast::zero) + if (isXRP(issuer) && adjustedAmt < beast::kZERO) { // A calculated negative XRP balance is not an error case. Consider a // payment snippet that credits a large XRP amount and then debits the diff --git a/src/libxrpl/ledger/RawStateTable.cpp b/src/libxrpl/ledger/RawStateTable.cpp index f267d2f691..69e2f5c0fe 100644 --- a/src/libxrpl/ledger/RawStateTable.cpp +++ b/src/libxrpl/ledger/RawStateTable.cpp @@ -17,24 +17,24 @@ namespace xrpl::detail { -class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base +class RawStateTable::SlesIterImpl : public ReadView::SlesType::iter_base { private: std::shared_ptr sle0_; - ReadView::sles_type::iterator iter0_; - ReadView::sles_type::iterator end0_; + ReadView::SlesType::Iterator iter0_; + ReadView::SlesType::Iterator end0_; std::shared_ptr sle1_; items_t::const_iterator iter1_; items_t::const_iterator end1_; public: - sles_iter_impl(sles_iter_impl const&) = default; + SlesIterImpl(SlesIterImpl const&) = default; - sles_iter_impl( + SlesIterImpl( items_t::const_iterator iter1, items_t::const_iterator end1, - ReadView::sles_type::iterator iter0, - ReadView::sles_type::iterator end0) + ReadView::SlesType::Iterator iter0, + ReadView::SlesType::Iterator end0) : iter0_(std::move(iter0)), end0_(std::move(end0)), iter1_(iter1), end1_(end1) { if (iter0_ != end0_) @@ -49,13 +49,13 @@ public: std::unique_ptr copy() const override { - return std::make_unique(*this); + return std::make_unique(*this); } bool equal(base_type const& impl) const override { - if (auto const p = dynamic_cast(&impl)) + if (auto const p = dynamic_cast(&impl)) { XRPL_ASSERT( end1_ == p->end1_ && end0_ == p->end0_, @@ -151,7 +151,7 @@ private: void skip() { - while (iter1_ != end1_ && iter1_->second.action == Action::erase && + while (iter1_ != end1_ && iter1_->second.action == Action::Erase && sle0_->key() == sle1_->key()) { inc1(); @@ -175,13 +175,13 @@ RawStateTable::apply(RawView& to) const auto const& item = elem.second; switch (item.action) { - case Action::erase: + case Action::Erase: to.rawErase(item.sle); break; - case Action::insert: + case Action::Insert: to.rawInsert(item.sle); break; - case Action::replace: + case Action::Replace: to.rawReplace(item.sle); break; } @@ -196,7 +196,7 @@ RawStateTable::exists(ReadView const& base, Keylet const& k) const if (iter == items_.end()) return base.exists(k); auto const& item = iter->second; - if (item.action == Action::erase) + if (item.action == Action::Erase) return false; if (!k.check(*item.sle)) return false; @@ -221,11 +221,11 @@ RawStateTable::succ(ReadView const& base, key_type const& key, std::optionalsecond.action == Action::erase); + } while (iter != items_.end() && iter->second.action == Action::Erase); // Find non-deleted successor in our list for (iter = items_.upper_bound(key); iter != items_.end(); ++iter) { - if (iter->second.action != Action::erase) + if (iter->second.action != Action::Erase) { // Found both, return the lower key if (!next || next > iter->first) @@ -247,20 +247,20 @@ RawStateTable::erase(std::shared_ptr const& sle) auto const result = items_.emplace( std::piecewise_construct, std::forward_as_tuple(sle->key()), - std::forward_as_tuple(Action::erase, sle)); + std::forward_as_tuple(Action::Erase, sle)); if (result.second) return; auto& item = result.first->second; switch (item.action) { - case Action::erase: + case Action::Erase: Throw("RawStateTable::erase: already erased"); break; - case Action::insert: + case Action::Insert: items_.erase(result.first); break; - case Action::replace: - item.action = Action::erase; + case Action::Replace: + item.action = Action::Erase; item.sle = sle; break; } @@ -272,20 +272,20 @@ RawStateTable::insert(std::shared_ptr const& sle) auto const result = items_.emplace( std::piecewise_construct, std::forward_as_tuple(sle->key()), - std::forward_as_tuple(Action::insert, sle)); + std::forward_as_tuple(Action::Insert, sle)); if (result.second) return; auto& item = result.first->second; switch (item.action) { - case Action::erase: - item.action = Action::replace; + case Action::Erase: + item.action = Action::Replace; item.sle = sle; break; - case Action::insert: + case Action::Insert: Throw("RawStateTable::insert: already inserted"); break; - case Action::replace: + case Action::Replace: Throw("RawStateTable::insert: already exists"); break; } @@ -297,17 +297,17 @@ RawStateTable::replace(std::shared_ptr const& sle) auto const result = items_.emplace( std::piecewise_construct, std::forward_as_tuple(sle->key()), - std::forward_as_tuple(Action::replace, sle)); + std::forward_as_tuple(Action::Replace, sle)); if (result.second) return; auto& item = result.first->second; switch (item.action) { - case Action::erase: + case Action::Erase: Throw("RawStateTable::replace: was erased"); break; - case Action::insert: - case Action::replace: + case Action::Insert: + case Action::Replace: item.sle = sle; break; } @@ -320,7 +320,7 @@ RawStateTable::read(ReadView const& base, Keylet const& k) const if (iter == items_.end()) return base.read(k); auto const& item = iter->second; - if (item.action == Action::erase) + if (item.action == Action::Erase) return nullptr; // Convert to SLE const std::shared_ptr sle = item.sle; @@ -335,25 +335,25 @@ RawStateTable::destroyXRP(XRPAmount const& fee) dropsDestroyed_ += fee; } -std::unique_ptr +std::unique_ptr RawStateTable::slesBegin(ReadView const& base) const { - return std::make_unique( + return std::make_unique( items_.begin(), items_.end(), base.sles.begin(), base.sles.end()); } -std::unique_ptr +std::unique_ptr RawStateTable::slesEnd(ReadView const& base) const { - return std::make_unique( + return std::make_unique( items_.end(), items_.end(), base.sles.end(), base.sles.end()); } -std::unique_ptr +std::unique_ptr RawStateTable::slesUpperBound(ReadView const& base, uint256 const& key) const { - return std::make_unique( - items_.upper_bound(key), items_.end(), base.sles.upper_bound(key), base.sles.end()); + return std::make_unique( + items_.upper_bound(key), items_.end(), base.sles.upperBound(key), base.sles.end()); } } // namespace xrpl::detail diff --git a/src/libxrpl/ledger/ReadView.cpp b/src/libxrpl/ledger/ReadView.cpp index 991dd95251..1877edb383 100644 --- a/src/libxrpl/ledger/ReadView.cpp +++ b/src/libxrpl/ledger/ReadView.cpp @@ -13,48 +13,48 @@ namespace xrpl { -ReadView::sles_type::sles_type(ReadView const& view) : ReadViewFwdRange(view) +ReadView::SlesType::SlesType(ReadView const& view) : ReadViewFwdRange(view) { } auto -ReadView::sles_type::begin() const -> iterator +ReadView::SlesType::begin() const -> Iterator { - return iterator(view_, view_->slesBegin()); + return Iterator(view_, view_->slesBegin()); } auto -ReadView::sles_type::end() const -> iterator +ReadView::SlesType::end() const -> Iterator { - return iterator(view_, view_->slesEnd()); + return Iterator(view_, view_->slesEnd()); } auto -ReadView::sles_type::upper_bound(key_type const& key) const -> iterator +ReadView::SlesType::upperBound(key_type const& key) const -> Iterator { - return iterator(view_, view_->slesUpperBound(key)); + return Iterator(view_, view_->slesUpperBound(key)); } -ReadView::txs_type::txs_type(ReadView const& view) : ReadViewFwdRange(view) +ReadView::TxsType::TxsType(ReadView const& view) : ReadViewFwdRange(view) { } bool -ReadView::txs_type::empty() const +ReadView::TxsType::empty() const { return begin() == end(); } auto -ReadView::txs_type::begin() const -> iterator +ReadView::TxsType::begin() const -> Iterator { - return iterator(view_, view_->txsBegin()); + return Iterator(view_, view_->txsBegin()); } auto -ReadView::txs_type::end() const -> iterator +ReadView::TxsType::end() const -> Iterator { - return iterator(view_, view_->txsEnd()); + return Iterator(view_, view_->txsEnd()); } Rules @@ -66,7 +66,7 @@ makeRulesGivenLedger(DigestAwareReadView const& ledger, Rules const& current) Rules makeRulesGivenLedger( DigestAwareReadView const& ledger, - std::unordered_set> const& presets) + std::unordered_set> const& presets) { Keylet const k = keylet::amendments(); std::optional const digest = ledger.digest(k.key); diff --git a/src/libxrpl/ledger/View.cpp b/src/libxrpl/ledger/View.cpp index 55735ec0e6..9fb03a230c 100644 --- a/src/libxrpl/ledger/View.cpp +++ b/src/libxrpl/ledger/View.cpp @@ -62,7 +62,7 @@ isVaultPseudoAccountFrozen( if (!view.rules().enabled(featureSingleAssetVault)) return false; - if (depth >= maxAssetCheckDepth) + if (depth >= kMAX_ASSET_CHECK_DEPTH) return true; // LCOV_EXCL_LINE auto const mptIssuance = view.read(keylet::mptIssuance(mptShare.getMptID())); @@ -350,7 +350,7 @@ withdrawToDestExceedsLimit( [&](Issue const& issue) -> TER { auto const& currency = issue.currency; auto const owed = creditBalance(view, to, issuer, currency); - if (owed <= beast::zero) + if (owed <= beast::kZERO) { auto const limit = creditLimit(view, to, issuer, currency); if (-owed >= limit || amount > (limit + owed)) @@ -437,8 +437,8 @@ doWithdraw( view, sourceAcct, amount.asset(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j) < amount) { // LCOV_EXCL_START @@ -463,7 +463,7 @@ cleanupOnAccountDelete( // Delete all the entries in the account directory. std::shared_ptr sleDirNode{}; unsigned int uDirEntry{0}; - uint256 dirEntry{beast::zero}; + uint256 dirEntry{beast::kZERO}; std::uint32_t deleted = 0; if (view.exists(ownerDirKeylet) && @@ -487,7 +487,7 @@ cleanupOnAccountDelete( } LedgerEntryType const nodeType{ - safe_cast(sleItem->getFieldU16(sfLedgerEntryType))}; + safeCast(sleItem->getFieldU16(sfLedgerEntryType))}; // Deleter handles the details of specific account-owned object // deletion diff --git a/src/libxrpl/ledger/helpers/AMMHelpers.cpp b/src/libxrpl/ledger/helpers/AMMHelpers.cpp index cc91dcaaf4..4cef02e056 100644 --- a/src/libxrpl/ledger/helpers/AMMHelpers.cpp +++ b/src/libxrpl/ledger/helpers/AMMHelpers.cpp @@ -47,7 +47,7 @@ ammLPTokens(STAmount const& asset1, STAmount const& asset2, Asset const& lptIssu { // AMM invariant: sqrt(asset1 * asset2) >= LPTokensBalance auto const rounding = - isFeatureEnabled(fixAMMv1_3) ? Number::rounding_mode::downward : Number::getround(); + isFeatureEnabled(fixAMMv1_3) ? Number::RoundingMode::Downward : Number::getround(); NumberRoundModeGuard const g(rounding); auto const tokens = root2(asset1 * asset2); return toSTAmount(lptIssue, tokens); @@ -78,7 +78,7 @@ lpTokensOut( // minimize tokens out auto const frac = (r - c) / (1 + c); - return multiply(lptAMMBalance, frac, Number::rounding_mode::downward); + return multiply(lptAMMBalance, frac, Number::RoundingMode::Downward); } /* Equation 4 solves equation 3 for b: @@ -114,7 +114,7 @@ ammAssetIn( // maximize deposit auto const frac = solveQuadraticEq(a, b, c); - return multiply(asset1Balance, frac, Number::rounding_mode::upward); + return multiply(asset1Balance, frac, Number::RoundingMode::Upward); } /* Equation 7: @@ -139,7 +139,7 @@ lpTokensIn( // maximize tokens in auto const frac = (c - root2(c * c - 4 * fr)) / 2; - return multiply(lptAMMBalance, frac, Number::rounding_mode::upward); + return multiply(lptAMMBalance, frac, Number::RoundingMode::Upward); } /* Equation 8 solves equation 7 for b: @@ -169,7 +169,7 @@ ammAssetOut( // minimize withdraw auto const frac = (t1 * t1 - t1 * (2 - f)) / (t1 * f - 1); - return multiply(assetBalance, frac, Number::rounding_mode::downward); + return multiply(assetBalance, frac, Number::RoundingMode::Downward); } Number @@ -183,7 +183,7 @@ adjustLPTokens(STAmount const& lptAMMBalance, STAmount const& lpTokens, IsDeposi { // Force rounding downward to ensure adjusted tokens are less or equal // to requested tokens. - saveNumberRoundMode const rm(Number::setround(Number::rounding_mode::downward)); + SaveNumberRoundMode const rm(Number::setround(Number::RoundingMode::Downward)); if (isDeposit == IsDeposit::Yes) return (lptAMMBalance + lpTokens) - lptAMMBalance; return (lpTokens - lptAMMBalance) + lptAMMBalance; @@ -205,7 +205,7 @@ adjustAmountsByLPTokens( auto const lpTokensActual = adjustLPTokens(lptAMMBalance, lpTokens, isDeposit); - if (lpTokensActual == beast::zero) + if (lpTokensActual == beast::kZERO) { auto const amount2Opt = amount2 ? std::make_optional(STAmount{}) : std::nullopt; return std::make_tuple(STAmount{}, amount2Opt, lpTokensActual); @@ -290,7 +290,7 @@ solveQuadraticEqSmallest(Number const& a, Number const& b, Number const& c) } STAmount -multiply(STAmount const& amount, Number const& frac, Number::rounding_mode rm) +multiply(STAmount const& amount, Number const& frac, Number::RoundingMode rm) { NumberRoundModeGuard const g(rm); auto const t = amount * frac; @@ -571,7 +571,7 @@ getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account) "xrpl::getTradingFee : auction present"); if (ammSle.isFieldPresent(sfAuctionSlot)) { - auto const& auctionSlot = safe_downcast(ammSle.peekAtField(sfAuctionSlot)); + auto const& auctionSlot = safeDowncast(ammSle.peekAtField(sfAuctionSlot)); // Not expired if (auto const expiration = auctionSlot[~sfExpiration]; duration_cast(view.header().parentCloseTime.time_since_epoch()).count() < @@ -644,7 +644,7 @@ deleteAMMTrustLines( if (nodeType == ltRIPPLE_STATE) { // Trustlines must have zero balance - if (sleItem->getFieldAmount(sfBalance) != beast::zero) + if (sleItem->getFieldAmount(sfBalance) != beast::kZERO) { // LCOV_EXCL_START JLOG(j.error()) << "deleteAMMObjects: deleting trustline with " @@ -681,7 +681,7 @@ deleteAMMMPTokens(Sandbox& sb, AccountID const& ammAccountID, beast::Journal j) { // MPT must have zero balance if (sleItem->getFieldU64(sfMPTAmount) != 0 || - (*sleItem)[~sfLockedAmount].value_or(0) != 0) + (*sleItem)[~sfLockedAmount].valueOr(0) != 0) { // LCOV_EXCL_START JLOG(j.error()) << "deleteAMMObjects: deleting MPT with " @@ -732,7 +732,7 @@ deleteAMMAccount(Sandbox& sb, Asset const& asset, Asset const& asset2, beast::Jo // LCOV_EXCL_STOP } - if (auto const ter = deleteAMMTrustLines(sb, ammAccountID, maxDeletableAMMTrustLines, j); + if (auto const ter = deleteAMMTrustLines(sb, ammAccountID, kMAX_DELETABLE_AMM_TRUST_LINES, j); !isTesSuccess(ter)) return ter; @@ -779,9 +779,9 @@ initializeFeeAuctionVote( STObject voteEntry = STObject::makeInnerObject(sfVoteEntry); if (tfee != 0) voteEntry.setFieldU16(sfTradingFee, tfee); - voteEntry.setFieldU32(sfVoteWeight, VOTE_WEIGHT_SCALE_FACTOR); + voteEntry.setFieldU32(sfVoteWeight, kVOTE_WEIGHT_SCALE_FACTOR); voteEntry.setAccountID(sfAccount, account); - voteSlots.push_back(voteEntry); + voteSlots.pushBack(voteEntry); ammSle->setFieldArray(sfVoteSlots, voteSlots); // AMM creator gets the auction slot for free. // AuctionSlot is created on AMMCreate and updated on AMMDeposit @@ -797,7 +797,7 @@ initializeFeeAuctionVote( auto const expiration = std::chrono::duration_cast( view.header().parentCloseTime.time_since_epoch()) .count() + - TOTAL_TIME_SLOT_SECS; + kTOTAL_TIME_SLOT_SECS; auctionSlot.setFieldU32(sfExpiration, expiration); auctionSlot.setFieldAmount(sfPrice, STAmount{lptAsset, 0}); // Set the fee @@ -809,7 +809,7 @@ initializeFeeAuctionVote( { ammSle->makeFieldAbsent(sfTradingFee); // LCOV_EXCL_LINE } - if (auto const dfee = tfee / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION) + if (auto const dfee = tfee / kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION) { auctionSlot.setFieldU16(sfDiscountedFee, dfee); } diff --git a/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp b/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp index 0663fde1f4..052c93739c 100644 --- a/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp +++ b/src/libxrpl/ledger/helpers/AccountRootHelpers.cpp @@ -88,7 +88,7 @@ xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, { auto const sle = view.read(keylet::account(id)); if (sle == nullptr) - return beast::zero; + return beast::kZERO; // Return balance minus reserve std::uint32_t const ownerCount = @@ -121,7 +121,7 @@ transferRate(ReadView const& view, AccountID const& issuer) if (sle && sle->isFieldPresent(sfTransferRate)) return Rate{sle->getFieldU32(sfTransferRate)}; - return parityRate; + return kPARITY_RATE; } void @@ -146,17 +146,17 @@ AccountID pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey) { // This number must not be changed without an amendment - constexpr std::uint16_t maxAccountAttempts = 256; - for (std::uint16_t i = 0; i < maxAccountAttempts; ++i) + constexpr std::uint16_t kMAX_ACCOUNT_ATTEMPTS = 256; + for (std::uint16_t i = 0; i < kMAX_ACCOUNT_ATTEMPTS; ++i) { - ripesha_hasher rsh; + RipeshaHasher rsh; auto const hash = sha512Half(i, view.header().parentHash, pseudoOwnerKey); rsh(hash.data(), hash.size()); - AccountID const ret{static_cast(rsh)}; + AccountID const ret{static_cast(rsh)}; if (!view.read(keylet::account(ret))) return ret; } - return beast::zero; + return beast::kZERO; } // Pseudo-account designator fields MUST be maintained by including the @@ -168,7 +168,7 @@ pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey) [[nodiscard]] std::vector const& getPseudoAccountFields() { - static std::vector const pseudoFields = []() { + static std::vector const kPSEUDO_FIELDS = []() { auto const ar = LedgerFormats::getInstance().findByType(ltACCOUNT_ROOT); if (!ar) { @@ -183,12 +183,12 @@ getPseudoAccountFields() std::vector pseudoFields; for (auto const& field : soTemplate) { - if (field.sField().shouldMeta(SField::sMD_PseudoAccount)) + if (field.sField().shouldMeta(SField::SMdPseudoAccount)) pseudoFields.emplace_back(&field.sField()); } return pseudoFields; }(); - return pseudoFields; + return kPSEUDO_FIELDS; } [[nodiscard]] bool @@ -221,7 +221,7 @@ createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const "xrpl::createPseudoAccount : valid owner field"); auto const accountId = pseudoAccountAddress(view, pseudoOwnerKey); - if (accountId == beast::zero) + if (accountId == beast::kZERO) return Unexpected(tecDUPLICATE); // Create pseudo-account. diff --git a/src/libxrpl/ledger/helpers/CredentialHelpers.cpp b/src/libxrpl/ledger/helpers/CredentialHelpers.cpp index 18cb44b461..22122216bc 100644 --- a/src/libxrpl/ledger/helpers/CredentialHelpers.cpp +++ b/src/libxrpl/ledger/helpers/CredentialHelpers.cpp @@ -126,7 +126,7 @@ checkFields(STTx const& tx, beast::Journal j) return tesSUCCESS; auto const& credentials = tx.getFieldV256(sfCredentialIDs); - if (credentials.empty() || (credentials.size() > maxCredentialsArraySize)) + if (credentials.empty() || (credentials.size() > kMAX_CREDENTIALS_ARRAY_SIZE)) { JLOG(j.trace()) << "Malformed transaction: Credentials array size is invalid: " << credentials.size(); @@ -283,7 +283,7 @@ checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j) } auto const ct = credential[sfCredentialType]; - if (ct.empty() || (ct.size() > maxCredentialTypeLength)) + if (ct.empty() || (ct.size() > kMAX_CREDENTIAL_TYPE_LENGTH)) { JLOG(j.trace()) << "Malformed transaction: " "Invalid credentialType size: " @@ -321,7 +321,7 @@ verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, b auto const type = h.getFieldVL(sfCredentialType); auto const keyletCredential = keylet::credential(account, issuer, makeSlice(type)); if (view.exists(keyletCredential)) - credentials.push_back(keyletCredential.key); + credentials.pushBack(keyletCredential.key); } bool const foundExpired = credentials::removeExpired(view, credentials, j); diff --git a/src/libxrpl/ledger/helpers/LendingHelpers.cpp b/src/libxrpl/ledger/helpers/LendingHelpers.cpp index a263791e39..28b0c8976d 100644 --- a/src/libxrpl/ledger/helpers/LendingHelpers.cpp +++ b/src/libxrpl/ledger/helpers/LendingHelpers.cpp @@ -48,15 +48,15 @@ LoanPaymentParts::operator+=(LoanPaymentParts const& other) { XRPL_ASSERT( - other.principalPaid >= beast::zero, + other.principalPaid >= beast::kZERO, "xrpl::LoanPaymentParts::operator+= : other principal " "non-negative"); XRPL_ASSERT( - other.interestPaid >= beast::zero, + other.interestPaid >= beast::kZERO, "xrpl::LoanPaymentParts::operator+= : other interest paid " "non-negative"); XRPL_ASSERT( - other.feePaid >= beast::zero, + other.feePaid >= beast::kZERO, "xrpl::LoanPaymentParts::operator+= : other fee paid " "non-negative"); @@ -83,7 +83,7 @@ Number loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval) { // Need floating point math, since we're dividing by a large number - return tenthBipsOfValue(Number(paymentInterval), interestRate) / secondsInYear; + return tenthBipsOfValue(Number(paymentInterval), interestRate) / kSECONDS_IN_YEAR; } /* Checks if a value is already rounded to the specified scale. @@ -93,8 +93,8 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval) bool isRounded(Asset const& asset, Number const& value, std::int32_t scale) { - return roundToAsset(asset, value, scale, Number::rounding_mode::downward) == - roundToAsset(asset, value, scale, Number::rounding_mode::upward); + return roundToAsset(asset, value, scale, Number::RoundingMode::Downward) == + roundToAsset(asset, value, scale, Number::RoundingMode::Upward); } namespace detail { @@ -102,12 +102,12 @@ namespace detail { void LoanStateDeltas::nonNegative() { - if (principal < beast::zero) - principal = numZero; - if (interest < beast::zero) - interest = numZero; - if (managementFee < beast::zero) - managementFee = numZero; + if (principal < beast::kZERO) + principal = kNUM_ZERO; + if (interest < beast::kZERO) + interest = kNUM_ZERO; + if (managementFee < beast::kZERO) + managementFee = kNUM_ZERO; } /* Computes (1 + periodicRate)^paymentsRemaining for amortization calculations. @@ -129,10 +129,10 @@ Number computePaymentFactor(Number const& periodicRate, std::uint32_t paymentsRemaining) { if (paymentsRemaining == 0) - return numZero; + return kNUM_ZERO; // For zero interest, payment factor is simply 1/paymentsRemaining - if (periodicRate == beast::zero) + if (periodicRate == beast::kZERO) return Number{1} / paymentsRemaining; Number const raisedRate = computeRaisedRate(periodicRate, paymentsRemaining); @@ -155,7 +155,7 @@ loanPeriodicPayment( return 0; // Interest-free loans: equal principal payments - if (periodicRate == beast::zero) + if (periodicRate == beast::kZERO) return principalOutstanding / paymentsRemaining; return principalOutstanding * computePaymentFactor(periodicRate, paymentsRemaining); @@ -173,7 +173,7 @@ loanPrincipalFromPeriodicPayment( std::uint32_t paymentsRemaining) { if (paymentsRemaining == 0) - return numZero; + return kNUM_ZERO; if (periodicRate == 0) return periodicPayment * paymentsRemaining; @@ -210,11 +210,11 @@ loanLatePaymentInterest( NetClock::time_point parentCloseTime, std::uint32_t nextPaymentDueDate) { - if (principalOutstanding == beast::zero) - return numZero; + if (principalOutstanding == beast::kZERO) + return kNUM_ZERO; if (lateInterestRate == TenthBips32{0}) - return numZero; + return kNUM_ZERO; auto const now = parentCloseTime.time_since_epoch().count(); @@ -245,11 +245,11 @@ loanAccruedInterest( std::uint32_t prevPaymentDate, std::uint32_t paymentInterval) { - if (periodicRate == beast::zero) - return numZero; + if (periodicRate == beast::kZERO) + return kNUM_ZERO; if (paymentInterval == 0) - return numZero; + return kNUM_ZERO; auto const lastPaymentDate = std::max(prevPaymentDate, startDate); auto const now = parentCloseTime.time_since_epoch().count(); @@ -257,7 +257,7 @@ loanAccruedInterest( // If the loan has been paid ahead, then "lastPaymentDate" is in the future, // and no interest has accrued. if (now <= lastPaymentDate) - return numZero; + return kNUM_ZERO; // Equation (4) from XLS-66 spec, Section A-2 Equation Glossary auto const secondsSinceLastPayment = now - lastPaymentDate; @@ -291,7 +291,7 @@ doPayment( { XRPL_ASSERT_PARTS(nextDueDateProxy, "xrpl::detail::doPayment", "Next due date proxy set"); - if (payment.specialCase == PaymentSpecialCase::final) + if (payment.specialCase == PaymentSpecialCase::Final) { XRPL_ASSERT_PARTS( principalOutstandingProxy == payment.trackedPrincipalDelta, @@ -326,7 +326,7 @@ doPayment( else { // For regular payments (not overpayments), advance the payment schedule - if (payment.specialCase != PaymentSpecialCase::extra) + if (payment.specialCase != PaymentSpecialCase::Extra) { paymentRemainingProxy -= 1; @@ -366,7 +366,7 @@ doPayment( XRPL_ASSERT_PARTS( // Use an explicit cast because the template parameter can be // ValueProxy or Number - static_cast(managementFeeOutstandingProxy) >= beast::zero, + static_cast(managementFeeOutstandingProxy) >= beast::kZERO, "xrpl::detail::doPayment", "fee outstanding stays valid"); @@ -462,20 +462,20 @@ tryOverpayment( asset, newTheoreticalState.principalOutstanding, loanScale, - Number::rounding_mode::upward), - numZero, + Number::RoundingMode::Upward), + kNUM_ZERO, roundedOldState.principalOutstanding); auto const totalValueOutstanding = std::clamp( roundToAsset( asset, principalOutstanding + newTheoreticalState.interestOutstanding(), loanScale, - Number::rounding_mode::upward), - numZero, + Number::RoundingMode::Upward), + kNUM_ZERO, roundedOldState.valueOutstanding); auto const managementFeeOutstanding = std::clamp( roundToAsset(asset, newTheoreticalState.managementFeeDue, loanScale), - numZero, + kNUM_ZERO, roundedOldState.managementFeeDue); auto const roundedNewState = @@ -497,7 +497,7 @@ tryOverpayment( // small interest amounts, that may have already been paid // off. Check what's still outstanding. This should // guarantee that the interest checks pass. - roundedNewState.interestOutstanding() != beast::zero, + roundedNewState.interestOutstanding() != beast::kZERO, paymentRemaining, newLoanProperties, j)) @@ -731,7 +731,7 @@ computeLatePayment( XRPL_ASSERT(roundedLateInterest >= 0, "xrpl::detail::computeLatePayment : valid late interest"); XRPL_ASSERT_PARTS( - periodic.specialCase != PaymentSpecialCase::extra, + periodic.specialCase != PaymentSpecialCase::Extra, "xrpl::detail::computeLatePayment", "no extra parts to this payment"); @@ -841,7 +841,7 @@ computeFullPayment( // management fee (to broker), applying proper rounding. auto const [roundedFullInterest, roundedFullManagementFee] = [&]() { auto const interest = - roundToAsset(asset, fullPaymentInterest, loanScale, Number::rounding_mode::downward); + roundToAsset(asset, fullPaymentInterest, loanScale, Number::RoundingMode::Downward); return computeInterestAndFeeParts(asset, interest, managementFeeRate, loanScale); }(); @@ -857,7 +857,7 @@ computeFullPayment( // All outstanding management fees are paid. This zeroes out the // tracked fee balance. .trackedManagementFeeDelta = managementFeeOutstanding, - .specialCase = PaymentSpecialCase::final, + .specialCase = PaymentSpecialCase::Final, }, // Untracked management fee includes: @@ -960,7 +960,7 @@ computePaymentComponents( .trackedValueDelta = totalValueOutstanding, .trackedPrincipalDelta = principalOutstanding, .trackedManagementFeeDelta = managementFeeOutstanding, - .specialCase = PaymentSpecialCase::final}; + .specialCase = PaymentSpecialCase::Final}; } // Calculate what the loan state SHOULD be after this payment (the target). @@ -1006,7 +1006,7 @@ computePaymentComponents( // periodic payment after principal is paid deltas.interest = std::min( {deltas.interest, - std::max(numZero, roundedPeriodicPayment - deltas.principal), + std::max(kNUM_ZERO, roundedPeriodicPayment - deltas.principal), currentLedgerState.interestDue}); XRPL_ASSERT_PARTS( @@ -1026,14 +1026,16 @@ computePaymentComponents( // which indicates that we're not going to take the whole payment amount, // but if so, it must be small. auto takeFrom = [](Number& component, Number& excess) { - if (excess > beast::zero) + if (excess > beast::kZERO) { auto part = std::min(component, excess); component -= part; excess -= part; } XRPL_ASSERT_PARTS( - excess >= beast::zero, "xrpl::detail::computePaymentComponents", "excess non-negative"); + excess >= beast::kZERO, + "xrpl::detail::computePaymentComponents", + "excess non-negative"); }; // Helper to reduce deltas when they collectively exceed a limit. // Order matters: we prefer to reduce interest first (most flexible), @@ -1049,7 +1051,7 @@ computePaymentComponents( // happen due to earlier caps, but handle it defensively. Number totalOverpayment = deltas.total() - currentLedgerState.valueOutstanding; - if (totalOverpayment > beast::zero) + if (totalOverpayment > beast::kZERO) { // LCOV_EXCL_START UNREACHABLE( @@ -1067,7 +1069,7 @@ computePaymentComponents( "xrpl::detail::computePaymentComponents", "shortage is rounded"); - if (shortage < beast::zero) + if (shortage < beast::kZERO) { // Deltas exceed payment amount - reduce them proportionally Number excess = -shortage; @@ -1079,7 +1081,9 @@ computePaymentComponents( // periodic payment (due to rounding or component caps). // shortage < 0 would mean we're trying to pay more than allowed (bug). XRPL_ASSERT_PARTS( - shortage >= beast::zero, "xrpl::detail::computePaymentComponents", "no shortage or excess"); + shortage >= beast::kZERO, + "xrpl::detail::computePaymentComponents", + "no shortage or excess"); // Final validation that all components are valid XRPL_ASSERT_PARTS( @@ -1088,33 +1092,33 @@ computePaymentComponents( "total value adds up"); XRPL_ASSERT_PARTS( - deltas.principal >= beast::zero && + deltas.principal >= beast::kZERO && deltas.principal <= currentLedgerState.principalOutstanding, "xrpl::detail::computePaymentComponents", "valid principal result"); XRPL_ASSERT_PARTS( - deltas.interest >= beast::zero && deltas.interest <= currentLedgerState.interestDue, + deltas.interest >= beast::kZERO && deltas.interest <= currentLedgerState.interestDue, "xrpl::detail::computePaymentComponents", "valid interest result"); XRPL_ASSERT_PARTS( - deltas.managementFee >= beast::zero && + deltas.managementFee >= beast::kZERO && deltas.managementFee <= currentLedgerState.managementFeeDue, "xrpl::detail::computePaymentComponents", "valid fee result"); XRPL_ASSERT_PARTS( - deltas.principal + deltas.interest + deltas.managementFee > beast::zero, + deltas.principal + deltas.interest + deltas.managementFee > beast::kZERO, "xrpl::detail::computePaymentComponents", "payment parts add to payment"); // Final safety clamp to ensure no value exceeds its outstanding balance return PaymentComponents{ .trackedValueDelta = - std::clamp(deltas.total(), numZero, currentLedgerState.valueOutstanding), + std::clamp(deltas.total(), kNUM_ZERO, currentLedgerState.valueOutstanding), .trackedPrincipalDelta = - std::clamp(deltas.principal, numZero, currentLedgerState.principalOutstanding), + std::clamp(deltas.principal, kNUM_ZERO, currentLedgerState.principalOutstanding), .trackedManagementFeeDelta = - std::clamp(deltas.managementFee, numZero, currentLedgerState.managementFeeDue), + std::clamp(deltas.managementFee, kNUM_ZERO, currentLedgerState.managementFeeDue), }; } @@ -1175,7 +1179,7 @@ computeOverpaymentComponents( .trackedPrincipalDelta = overpayment - roundedOverpaymentInterest - roundedOverpaymentManagementFee - overpaymentFee, .trackedManagementFeeDelta = roundedOverpaymentManagementFee, - .specialCase = detail::PaymentSpecialCase::extra}, + .specialCase = detail::PaymentSpecialCase::Extra}, // Untracked management fee is the fixed overpayment fee overpaymentFee, // Untracked interest is the penalty interest charged for overpaying. @@ -1280,7 +1284,7 @@ checkLoanGuards( // avoids dividing by 0. auto const roundedPayment = roundPeriodicPayment(vaultAsset, properties.periodicPayment, properties.loanScale); - if (roundedPayment == beast::zero) + if (roundedPayment == beast::kZERO) { JLOG(j.warn()) << "Loan Periodic payment (" << properties.periodicPayment << ") rounds to 0. "; @@ -1291,7 +1295,7 @@ checkLoanGuards( // loan can't be amortized in the specified number of payments, raise an // error { - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); if (std::int64_t const computedPayments{ properties.loanState.valueOutstanding / roundedPayment}; @@ -1338,7 +1342,7 @@ computeFullPaymentInterest( "interest"); // Equation (28) from XLS-66 spec, Section A-2 Equation Glossary - auto const prepaymentPenalty = closeInterestRate == beast::zero + auto const prepaymentPenalty = closeInterestRate == beast::kZERO ? Number{} : tenthBipsOfValue(theoreticalPrincipalOutstanding, closeInterestRate); @@ -1471,7 +1475,7 @@ computeManagementFee( std::int32_t scale) { return roundToAsset( - asset, tenthBipsOfValue(value, managementFeeRate), scale, Number::rounding_mode::downward); + asset, tenthBipsOfValue(value, managementFeeRate), scale, Number::RoundingMode::Downward); } /* @@ -1526,7 +1530,7 @@ computeLoanProperties( auto const [totalValueOutstanding, loanScale] = [&]() { // only round up if there should be interest NumberRoundModeGuard const mg( - periodicRate == 0 ? Number::rounding_mode::to_nearest : Number::rounding_mode::upward); + periodicRate == 0 ? Number::RoundingMode::ToNearest : Number::RoundingMode::Upward); // Use STAmount's internal rounding instead of roundToAsset, because // we're going to use this result to determine the scale for all the // other rounding. @@ -1555,7 +1559,7 @@ computeLoanProperties( // validate that the principal fits in it, so to allow this function to // succeed, round it here, and let the caller do the validation. auto const roundedPrincipalOutstanding = - roundToAsset(asset, principalOutstanding, loanScale, Number::rounding_mode::to_nearest); + roundToAsset(asset, principalOutstanding, loanScale, Number::RoundingMode::ToNearest); // Equation (31) from XLS-66 spec, Section A-2 Equation Glossary auto const totalInterestOutstanding = totalValueOutstanding - roundedPrincipalOutstanding; @@ -1654,7 +1658,7 @@ loanMakePayment( // ------------------------------------------------------------- // A late payment not flagged as late overrides all other options. - if (paymentType != LoanPaymentType::late && hasExpired(view, nextDueDateProxy)) + if (paymentType != LoanPaymentType::Late && hasExpired(view, nextDueDateProxy)) { // If the payment is late, and the late flag was not set, it's not // valid @@ -1669,7 +1673,7 @@ loanMakePayment( // ------------------------------------------------------------- // full payment handling - if (paymentType == LoanPaymentType::full) + if (paymentType == LoanPaymentType::Full) { TenthBips32 const closeInterestRate{loan->at(sfCloseInterestRate)}; Number const closePaymentFee = roundToAsset(asset, loan->at(sfClosePaymentFee), loanScale); @@ -1746,7 +1750,7 @@ loanMakePayment( // ------------------------------------------------------------- // late payment handling - if (paymentType == LoanPaymentType::late) + if (paymentType == LoanPaymentType::Late) { TenthBips32 const lateInterestRate{loan->at(sfLateInterestRate)}; Number const latePaymentFee = loan->at(sfLatePaymentFee); @@ -1795,7 +1799,7 @@ loanMakePayment( // regular periodic payment handling XRPL_ASSERT_PARTS( - paymentType == LoanPaymentType::regular || paymentType == LoanPaymentType::overpayment, + paymentType == LoanPaymentType::Regular || paymentType == LoanPaymentType::Overpayment, "xrpl::loanMakePayment", "regular payment type"); @@ -1805,7 +1809,7 @@ loanMakePayment( std::size_t numPayments = 0; while ((amount >= (totalPaid + periodic.totalDue)) && paymentRemainingProxy > 0 && - numPayments < loanMaximumPaymentsPerTransaction) + numPayments < kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION) { // Try to make more payments XRPL_ASSERT_PARTS( @@ -1826,13 +1830,13 @@ loanMakePayment( ++numPayments; XRPL_ASSERT_PARTS( - (periodic.specialCase == detail::PaymentSpecialCase::final) == + (periodic.specialCase == detail::PaymentSpecialCase::Final) == (paymentRemainingProxy == 0), "xrpl::loanMakePayment", "final payment is the final payment"); // Don't compute the next payment if this was the last payment - if (periodic.specialCase == detail::PaymentSpecialCase::final) + if (periodic.specialCase == detail::PaymentSpecialCase::Final) break; periodic = detail::ExtendedPaymentComponents{ @@ -1864,9 +1868,9 @@ loanMakePayment( // ------------------------------------------------------------- // overpayment handling - if (paymentType == LoanPaymentType::overpayment && loan->isFlag(lsfLoanOverpayment) && + if (paymentType == LoanPaymentType::Overpayment && loan->isFlag(lsfLoanOverpayment) && paymentRemainingProxy > 0 && totalPaid < amount && - numPayments < loanMaximumPaymentsPerTransaction) + numPayments < kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION) { TenthBips32 const overpaymentInterestRate{loan->at(sfOverpaymentInterestRate)}; TenthBips32 const overpaymentFeeRate{loan->at(sfOverpaymentFee)}; @@ -1890,7 +1894,7 @@ loanMakePayment( if (overpaymentComponents.trackedPrincipalDelta > 0) { XRPL_ASSERT_PARTS( - overpaymentComponents.untrackedInterest >= beast::zero, + overpaymentComponents.untrackedInterest >= beast::kZERO, "xrpl::loanMakePayment", "overpayment penalty did not reduce value of loan"); // Can't just use `periodicPayment` here, because it might @@ -1926,17 +1930,17 @@ loanMakePayment( // intermediate steps were rounded. XRPL_ASSERT( isRounded(asset, totalParts.principalPaid, loanScale) && - totalParts.principalPaid >= beast::zero, + totalParts.principalPaid >= beast::kZERO, "xrpl::loanMakePayment : total principal paid is valid"); XRPL_ASSERT( isRounded(asset, totalParts.interestPaid, loanScale) && - totalParts.interestPaid >= beast::zero, + totalParts.interestPaid >= beast::kZERO, "xrpl::loanMakePayment : total interest paid is valid"); XRPL_ASSERT( isRounded(asset, totalParts.valueChange, loanScale), "xrpl::loanMakePayment : loan value change is valid"); XRPL_ASSERT( - isRounded(asset, totalParts.feePaid, loanScale) && totalParts.feePaid >= beast::zero, + isRounded(asset, totalParts.feePaid, loanScale) && totalParts.feePaid >= beast::kZERO, "xrpl::loanMakePayment : fee paid is valid"); return totalParts; } diff --git a/src/libxrpl/ledger/helpers/MPTokenHelpers.cpp b/src/libxrpl/ledger/helpers/MPTokenHelpers.cpp index c3987ddb03..75fe61b34b 100644 --- a/src/libxrpl/ledger/helpers/MPTokenHelpers.cpp +++ b/src/libxrpl/ledger/helpers/MPTokenHelpers.cpp @@ -96,11 +96,11 @@ transferRate(ReadView const& view, MPTID const& issuanceID) sle && sle->isFieldPresent(sfTransferFee)) { auto const fee = sle->getFieldU16(sfTransferFee); - XRPL_ASSERT(fee <= maxTransferFee, "xrpl::transferRate : fee is too large"); + XRPL_ASSERT(fee <= kMAX_TRANSFER_FEE, "xrpl::transferRate : fee is too large"); return Rate{1'000'000'000u + (10'000 * fee)}; } - return parityRate; + return kPARITY_RATE; } [[nodiscard]] TER @@ -170,7 +170,7 @@ authorizeMPToken( auto const sleMpt = view.peek(mptokenKey); if (!sleMpt || (*sleMpt)[sfMPTAmount] != 0 || (view.rules().enabled(fixSecurity3_1_3) && - (*sleMpt)[~sfLockedAmount].value_or(0) != 0)) + (*sleMpt)[~sfLockedAmount].valueOr(0) != 0)) return tecINTERNAL; // LCOV_EXCL_LINE if (!view.dirRemove( @@ -194,7 +194,7 @@ authorizeMPToken( // items. This is similar to the reserve requirements of trust lines. std::uint32_t const uOwnerCount = sleAcct->getFieldU32(sfOwnerCount); XRPAmount const reserveCreate( - (uOwnerCount < 2) ? XRPAmount(beast::zero) + (uOwnerCount < 2) ? XRPAmount(beast::kZERO) : view.fees().accountReserve(uOwnerCount + 1)); if (priorBalance < reserveCreate) @@ -284,7 +284,7 @@ removeEmptyHolding( // accounting out of balance, so fail. Since this should be impossible // anyway, I'm not going to put any effort into it. if (mptoken->at(sfMPTAmount) != 0 || - (view.rules().enabled(fixSecurity3_1_3) && (*mptoken)[~sfLockedAmount].value_or(0) != 0)) + (view.rules().enabled(fixSecurity3_1_3) && (*mptoken)[~sfLockedAmount].valueOr(0) != 0)) return tecHAS_OBLIGATIONS; return authorizeMPToken( @@ -320,7 +320,7 @@ requireAuth( if (featureSAVEnabled) { - if (depth >= maxAssetCheckDepth) + if (depth >= kMAX_ASSET_CHECK_DEPTH) return tecINTERNAL; // LCOV_EXCL_LINE // requireAuth is recursive if the issuer is a vault pseudo-account @@ -567,7 +567,7 @@ lockEscrowMPT(ApplyView& view, AccountID const& sender, STAmount const& amount, (*sle)[sfMPTAmount] = amt - pay; // Overflow check for addition - uint64_t const locked = (*sle)[~sfLockedAmount].value_or(0); + uint64_t const locked = (*sle)[~sfLockedAmount].valueOr(0); if (!canAdd(STAmount(mptIssue, locked), STAmount(mptIssue, pay))) { // LCOV_EXCL_START @@ -591,7 +591,7 @@ lockEscrowMPT(ApplyView& view, AccountID const& sender, STAmount const& amount, // 1. Increase the Issuance EscrowedAmount // 2. DO NOT change the Issuance OutstandingAmount { - uint64_t const issuanceEscrowed = (*sleIssuance)[~sfLockedAmount].value_or(0); + uint64_t const issuanceEscrowed = (*sleIssuance)[~sfLockedAmount].valueOr(0); auto const pay = amount.mpt().value(); // Overflow check for addition @@ -839,7 +839,7 @@ checkCreateMPT( std::int64_t maxMPTAmount(SLE const& sleIssuance) { - return sleIssuance[~sfMaximumAmount].value_or(maxMPTokenAmount); + return sleIssuance[~sfMaximumAmount].value_or(kMAX_MP_TOKEN_AMOUNT); } std::int64_t diff --git a/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp b/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp index f57294a855..eb69ec93d0 100644 --- a/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp +++ b/src/libxrpl/ledger/helpers/NFTokenHelpers.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -43,8 +44,8 @@ namespace xrpl::nft { static std::shared_ptr locatePage(ReadView const& view, AccountID const& owner, uint256 const& id) { - auto const first = keylet::nftpage(keylet::nftpage_min(owner), id); - auto const last = keylet::nftpage_max(owner); + auto const first = keylet::nftpage(keylet::nftpageMin(owner), id); + auto const last = keylet::nftpageMax(owner); // This NFT can only be found in the first page with a key that's strictly // greater than `first`, so look for that, up until the maximum possible @@ -56,8 +57,8 @@ locatePage(ReadView const& view, AccountID const& owner, uint256 const& id) static std::shared_ptr locatePage(ApplyView& view, AccountID const& owner, uint256 const& id) { - auto const first = keylet::nftpage(keylet::nftpage_min(owner), id); - auto const last = keylet::nftpage_max(owner); + auto const first = keylet::nftpage(keylet::nftpageMin(owner), id); + auto const last = keylet::nftpageMax(owner); // This NFT can only be found in the first page with a key that's strictly // greater than `first`, so look for that, up until the maximum possible @@ -73,9 +74,9 @@ getPageForToken( uint256 const& id, std::function const& createCallback) { - auto const base = keylet::nftpage_min(owner); + auto const base = keylet::nftpageMin(owner); auto const first = keylet::nftpage(base, id); - auto const last = keylet::nftpage_max(owner); + auto const last = keylet::nftpageMax(owner); // This NFT can only be found in the first page with a key that's strictly // greater than `first`, so look for that, up until the maximum possible @@ -97,7 +98,7 @@ getPageForToken( STArray narr = cp->getFieldArray(sfNFTokens); // The right page still has space: we're good. - if (narr.size() != dirMaxTokensPerPage) + if (narr.size() != kDIR_MAX_TOKENS_PER_PAGE) return cp; // We need to split the page in two: the first half of the items in this @@ -114,13 +115,13 @@ getPageForToken( // any additional equivalent NFTs maximum room for expansion. // Round up the boundary until there's a non-equivalent entry. uint256 const cmp = - narr[(dirMaxTokensPerPage / 2) - 1].getFieldH256(sfNFTokenID) & nft::pageMask; + narr[(kDIR_MAX_TOKENS_PER_PAGE / 2) - 1].getFieldH256(sfNFTokenID) & nft::kPAGE_MASK; // Note that the calls to find_if_not() and (later) find_if() // rely on the fact that narr is kept in sorted order. auto splitIter = std::find_if_not( - narr.begin() + (dirMaxTokensPerPage / 2), narr.end(), [&cmp](STObject const& obj) { - return (obj.getFieldH256(sfNFTokenID) & nft::pageMask) == cmp; + narr.begin() + (kDIR_MAX_TOKENS_PER_PAGE / 2), narr.end(), [&cmp](STObject const& obj) { + return (obj.getFieldH256(sfNFTokenID) & nft::kPAGE_MASK) == cmp; }); // If we get all the way from the middle to the end with only @@ -129,7 +130,7 @@ getPageForToken( if (splitIter == narr.end()) { splitIter = std::ranges::find_if(narr, [&cmp](STObject const& obj) { - return (obj.getFieldH256(sfNFTokenID) & nft::pageMask) == cmp; + return (obj.getFieldH256(sfNFTokenID) & nft::kPAGE_MASK) == cmp; }); } @@ -142,7 +143,7 @@ getPageForToken( // equivalent tokens. This requires special handling. if (splitIter == narr.begin()) { - auto const relation{(id & nft::pageMask) <=> cmp}; + auto const relation{(id & nft::kPAGE_MASK) <=> cmp}; if (relation == 0) { // If the passed in id belongs exactly on this (full) page @@ -177,8 +178,8 @@ getPageForToken( // less than the low 96-bits of the enclosing page's index. In order to // accommodate that requirement we use an index one higher than the // largest NFT in the page. - uint256 const tokenIDForNewPage = narr.size() == dirMaxTokensPerPage - ? narr[dirMaxTokensPerPage - 1].getFieldH256(sfNFTokenID).next() + uint256 const tokenIDForNewPage = narr.size() == kDIR_MAX_TOKENS_PER_PAGE + ? narr[kDIR_MAX_TOKENS_PER_PAGE - 1].getFieldH256(sfNFTokenID).next() : carr[0].getFieldH256(sfNFTokenID); auto np = std::make_shared(keylet::nftpage(base, tokenIDForNewPage)); @@ -216,7 +217,7 @@ compareTokens(uint256 const& a, uint256 const& b) // 96-bits are identical we still need a fully deterministic sort. // So we sort on the low 96-bits first. If those are equal we sort on // the whole thing. - if (auto const lowBitsCmp{(a & nft::pageMask) <=> (b & nft::pageMask)}; lowBitsCmp != 0) + if (auto const lowBitsCmp{(a & nft::kPAGE_MASK) <=> (b & nft::kPAGE_MASK)}; lowBitsCmp != 0) return lowBitsCmp < 0; return a < b; @@ -280,7 +281,7 @@ insertToken(ApplyView& view, AccountID owner, STObject&& nft) { auto arr = page->getFieldArray(sfNFTokens); - arr.push_back(std::move(nft)); + arr.pushBack(std::move(nft)); arr.sort([](STObject const& o1, STObject const& o2) { return compareTokens(o1.getFieldH256(sfNFTokenID), o2.getFieldH256(sfNFTokenID)); @@ -313,7 +314,7 @@ mergePages(ApplyView& view, std::shared_ptr const& p1, std::shared_ptr // this it would mean that one of them can be deleted as a result of // the merge. - if (p1arr.size() + p2arr.size() > dirMaxTokensPerPage) + if (p1arr.size() + p2arr.size() > kDIR_MAX_TOKENS_PER_PAGE) return false; STArray x(p1arr.size() + p2arr.size()); @@ -444,7 +445,7 @@ removeToken( // 3. Fix up the owner count. // 4. Erase the previous page. if (view.rules().enabled(fixNFTokenPageLinks) && - ((curr->key() & nft::pageMask) == pageMask)) + ((curr->key() & nft::kPAGE_MASK) == kPAGE_MASK)) { // Copy all relevant information from prev to curr. curr->peekFieldArray(sfNFTokens) = prev->peekFieldArray(sfNFTokens); @@ -635,8 +636,8 @@ deleteTokenOffer(ApplyView& view, std::shared_ptr const& offer) auto const nftokenID = (*offer)[sfNFTokenID]; if (!view.dirRemove( - (((*offer)[sfFlags] & lsfSellNFToken) != 0u) ? keylet::nft_sells(nftokenID) - : keylet::nft_buys(nftokenID), + (((*offer)[sfFlags] & lsfSellNFToken) != 0u) ? keylet::nftSells(nftokenID) + : keylet::nftBuys(nftokenID), (*offer)[sfNFTokenOfferNode], offer->key(), false)) @@ -654,11 +655,11 @@ repairNFTokenDirectoryLinks(ApplyView& view, AccountID const& owner) { bool didRepair = false; - auto const last = keylet::nftpage_max(owner); + auto const last = keylet::nftpageMax(owner); std::shared_ptr page = view.peek(Keylet( ltNFTOKEN_PAGE, - view.succ(keylet::nftpage_min(owner).key, last.key.next()).value_or(last.key))); + view.succ(keylet::nftpageMin(owner).key, last.key.next()).value_or(last.key))); if (!page) return didRepair; @@ -787,7 +788,7 @@ tokenOfferCreatePreflight( if (!isXRP(amount)) { - if ((nftFlags & nft::flagOnlyXRP) != 0) + if ((nftFlags & nft::kFLAG_ONLY_XRP) != 0) return temBAD_AMOUNT; if (!amount) @@ -832,7 +833,7 @@ tokenOfferCreatePreclaim( std::optional const& owner, std::uint32_t txFlags) { - if (((nftFlags & nft::flagCreateTrustLines) == 0) && !amount.native() && (xferFee != 0u)) + if (((nftFlags & nft::kFLAG_CREATE_TRUST_LINES) == 0) && !amount.native() && (xferFee != 0u)) { if (!view.exists(keylet::account(nftIssuer))) return tecNO_ISSUER; @@ -854,7 +855,7 @@ tokenOfferCreatePreclaim( return tecFROZEN; } - if (nftIssuer != acctID && ((nftFlags & nft::flagTransferable) == 0)) + if (nftIssuer != acctID && ((nftFlags & nft::kFLAG_TRANSFERABLE) == 0)) { auto const root = view.read(keylet::account(nftIssuer)); XRPL_ASSERT(root, "xrpl::nft::tokenOfferCreatePreclaim : non-null account"); @@ -873,7 +874,7 @@ tokenOfferCreatePreclaim( { // We allow an IOU issuer to make a buy offer // using their own currency. - if (accountFunds(view, acctID, amount, FreezeHandling::fhZERO_IF_FROZEN, j).signum() <= 0) + if (accountFunds(view, acctID, amount, FreezeHandling::ZeroIfFrozen, j).signum() <= 0) return tecUNFUNDED_OFFER; } @@ -953,7 +954,7 @@ tokenOfferCreateApply( // Token offers are also added to the token's buy or sell offer // directory auto const offerNode = view.dirInsert( - isSellOffer ? keylet::nft_sells(nftokenID) : keylet::nft_buys(nftokenID), + isSellOffer ? keylet::nftSells(nftokenID) : keylet::nftBuys(nftokenID), offerID, [&nftokenID, isSellOffer](std::shared_ptr const& sle) { (*sle)[sfFlags] = isSellOffer ? lsfNFTokenSellOffers : lsfNFTokenBuyOffers; diff --git a/src/libxrpl/ledger/helpers/OfferHelpers.cpp b/src/libxrpl/ledger/helpers/OfferHelpers.cpp index d57066cfe2..03a1170aad 100644 --- a/src/libxrpl/ledger/helpers/OfferHelpers.cpp +++ b/src/libxrpl/ledger/helpers/OfferHelpers.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include // IWYU pragma: keep #include diff --git a/src/libxrpl/ledger/helpers/RippleStateHelpers.cpp b/src/libxrpl/ledger/helpers/RippleStateHelpers.cpp index f5a5c01060..58f44534cf 100644 --- a/src/libxrpl/ledger/helpers/RippleStateHelpers.cpp +++ b/src/libxrpl/ledger/helpers/RippleStateHelpers.cpp @@ -348,9 +348,9 @@ updateTrustLine( return false; // YYY Could skip this if rippling in reverse. - if (before > beast::zero + if (before > beast::kZERO // Sender balance was positive. - && after <= beast::zero + && after <= beast::kZERO // Sender is zero or negative. && ((flags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve)) != 0u) // Sender reserve is set. @@ -405,28 +405,28 @@ issueIOU( if (auto state = view.peek(index)) { - STAmount final_balance = state->getFieldAmount(sfBalance); + STAmount finalBalance = state->getFieldAmount(sfBalance); if (bSenderHigh) - final_balance.negate(); // Put balance in sender terms. + finalBalance.negate(); // Put balance in sender terms. - STAmount const start_balance = final_balance; + STAmount const startBalance = finalBalance; - final_balance -= amount; + finalBalance -= amount; - auto const must_delete = updateTrustLine( - view, state, bSenderHigh, issue.account, start_balance, final_balance, j); + auto const mustDelete = + updateTrustLine(view, state, bSenderHigh, issue.account, startBalance, finalBalance, j); - view.creditHookIOU(issue.account, account, amount, start_balance); + view.creditHookIOU(issue.account, account, amount, startBalance); if (bSenderHigh) - final_balance.negate(); + finalBalance.negate(); // Adjust the balance on the trust line if necessary. We do this even // if we are going to delete the line to reflect the correct balance // at the time of deletion. - state->setFieldAmount(sfBalance, final_balance); - if (must_delete) + state->setFieldAmount(sfBalance, finalBalance); + if (mustDelete) { return trustDelete( view, @@ -445,9 +445,9 @@ issueIOU( // this is unnecessarily inefficient as copying which could be avoided // is now required. Consider available options. STAmount const limit(Issue{issue.currency, account}); - STAmount final_balance = amount; + STAmount finalBalance = amount; - final_balance.get().account = noAccount(); + finalBalance.get().account = noAccount(); auto const receiverAccount = view.peek(keylet::account(account)); if (!receiverAccount) @@ -466,7 +466,7 @@ issueIOU( noRipple, false, false, - final_balance, + finalBalance, limit, 0, 0, @@ -497,29 +497,29 @@ redeemIOU( if (auto state = view.peek(keylet::line(account, issue.account, issue.currency))) { - STAmount final_balance = state->getFieldAmount(sfBalance); + STAmount finalBalance = state->getFieldAmount(sfBalance); if (bSenderHigh) - final_balance.negate(); // Put balance in sender terms. + finalBalance.negate(); // Put balance in sender terms. - STAmount const start_balance = final_balance; + STAmount const startBalance = finalBalance; - final_balance -= amount; + finalBalance -= amount; - auto const must_delete = - updateTrustLine(view, state, bSenderHigh, account, start_balance, final_balance, j); + auto const mustDelete = + updateTrustLine(view, state, bSenderHigh, account, startBalance, finalBalance, j); - view.creditHookIOU(account, issue.account, amount, start_balance); + view.creditHookIOU(account, issue.account, amount, startBalance); if (bSenderHigh) - final_balance.negate(); + finalBalance.negate(); // Adjust the balance on the trust line if necessary. We do this even // if we are going to delete the line to reflect the correct balance // at the time of deletion. - state->setFieldAmount(sfBalance, final_balance); + state->setFieldAmount(sfBalance, finalBalance); - if (must_delete) + if (mustDelete) { return trustDelete( view, @@ -698,7 +698,7 @@ removeEmptyHolding( auto const line = view.peek(keylet::line(accountID, issue)); if (!line) return accountIsIssuer ? (TER)tesSUCCESS : (TER)tecOBJECT_NOT_FOUND; - if (!accountIsIssuer && line->at(sfBalance)->iou() != beast::zero) + if (!accountIsIssuer && line->at(sfBalance)->iou() != beast::kZERO) return tecHAS_OBLIGATIONS; // Adjust the owner count(s) diff --git a/src/libxrpl/ledger/helpers/TokenHelpers.cpp b/src/libxrpl/ledger/helpers/TokenHelpers.cpp index 15b3dc0953..000f459ef6 100644 --- a/src/libxrpl/ledger/helpers/TokenHelpers.cpp +++ b/src/libxrpl/ledger/helpers/TokenHelpers.cpp @@ -165,7 +165,7 @@ getLineIfUsable( return nullptr; } - if (zeroIfFrozen == FreezeHandling::fhZERO_IF_FROZEN) + if (zeroIfFrozen == FreezeHandling::ZeroIfFrozen) { if (isFrozen(view, account, currency, issuer) || isDeepFrozen(view, account, currency, issuer)) @@ -252,12 +252,12 @@ accountHolds( return {xrpLiquid(view, account, 0, j)}; } - bool const returnSpendable = (includeFullBalance == SpendableHandling::shFULL_BALANCE); + bool const returnSpendable = (includeFullBalance == SpendableHandling::FullBalance); if (returnSpendable && account == issuer) { // If the account is the issuer, then their limit is effectively // infinite - return STAmount{Issue{currency, issuer}, STAmount::cMaxValue, STAmount::cMaxOffset}; + return STAmount{Issue{currency, issuer}, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET}; } // IOU: Return balance on trust line modulo freeze @@ -290,7 +290,7 @@ accountHolds( beast::Journal j, SpendableHandling includeFullBalance) { - bool const returnSpendable = (includeFullBalance == SpendableHandling::shFULL_BALANCE); + bool const returnSpendable = (includeFullBalance == SpendableHandling::FullBalance); STAmount amount{mptIssue}; auto const& issuer = mptIssue.getIssuer(); bool const mptokensV2 = view.rules().enabled(featureMPTokensV2); @@ -317,7 +317,7 @@ accountHolds( { amount.clear(mptIssue); } - else if (zeroIfFrozen == FreezeHandling::fhZERO_IF_FROZEN && isFrozen(view, account, mptIssue)) + else if (zeroIfFrozen == FreezeHandling::ZeroIfFrozen && isFrozen(view, account, mptIssue)) { amount.clear(mptIssue); } @@ -327,14 +327,14 @@ accountHolds( // Only if auth check is needed, as it needs to do an additional read // operation. Note featureSingleAssetVault will affect error codes. - if (zeroIfUnauthorized == AuthHandling::ahZERO_IF_UNAUTHORIZED && + if (zeroIfUnauthorized == AuthHandling::ZeroIfUnauthorized && view.rules().enabled(featureSingleAssetVault)) { if (auto const err = requireAuth(view, mptIssue, account, AuthType::StrongAuth); !isTesSuccess(err)) amount.clear(mptIssue); } - else if (zeroIfUnauthorized == AuthHandling::ahZERO_IF_UNAUTHORIZED) + else if (zeroIfUnauthorized == AuthHandling::ZeroIfUnauthorized) { auto const sleIssuance = view.read(keylet::mptIssuance(mptIssue.getMptID())); @@ -407,7 +407,7 @@ accountFunds( freezeHandling, authHandling, j, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); }); } @@ -493,8 +493,8 @@ TER requireAuth(ReadView const& view, Asset const& asset, AccountID const& account, AuthType authType) { return std::visit( - [&](TIss const& issue_) { - return requireAuth(view, issue_, account, authType); + [&](TIss const& issue) { + return requireAuth(view, issue, account, authType); }, asset.value()); } @@ -574,9 +574,9 @@ directSendNoFeeIOU( // FIXME This NEEDS to be cleaned up and simplified. It's impossible // for anyone to understand. - if (saBefore > beast::zero + if (saBefore > beast::kZERO // Sender balance was positive. - && saBalance <= beast::zero + && saBalance <= beast::kZERO // Sender is zero or negative. && ((uFlags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve)) != 0u) // Sender reserve is set. @@ -795,7 +795,7 @@ accountSendIOU( { if (view.rules().enabled(fixAMMv1_1)) { - if (saAmount < beast::zero || saAmount.holds()) + if (saAmount < beast::kZERO || saAmount.holds()) { return tecINTERNAL; // LCOV_EXCL_LINE } @@ -804,7 +804,7 @@ accountSendIOU( { // LCOV_EXCL_START XRPL_ASSERT( - saAmount >= beast::zero && !saAmount.holds(), + saAmount >= beast::kZERO && !saAmount.holds(), "xrpl::accountSendIOU : minimum amount and not MPT"); // LCOV_EXCL_STOP } @@ -833,24 +833,23 @@ accountSendIOU( TER terResult(tesSUCCESS); SLE::pointer const sender = - uSenderID != beast::zero ? view.peek(keylet::account(uSenderID)) : SLE::pointer(); + uSenderID != beast::kZERO ? view.peek(keylet::account(uSenderID)) : SLE::pointer(); SLE::pointer const receiver = - uReceiverID != beast::zero ? view.peek(keylet::account(uReceiverID)) : SLE::pointer(); + uReceiverID != beast::kZERO ? view.peek(keylet::account(uReceiverID)) : SLE::pointer(); if (auto stream = j.trace()) { - std::string sender_bal("-"); - std::string receiver_bal("-"); + std::string senderBal("-"); + std::string receiverBal("-"); if (sender) - sender_bal = sender->getFieldAmount(sfBalance).getFullText(); + senderBal = sender->getFieldAmount(sfBalance).getFullText(); if (receiver) - receiver_bal = receiver->getFieldAmount(sfBalance).getFullText(); + receiverBal = receiver->getFieldAmount(sfBalance).getFullText(); - stream << "accountSendIOU> " << to_string(uSenderID) << " (" << sender_bal << ") -> " - << to_string(uReceiverID) << " (" << receiver_bal - << ") : " << saAmount.getFullText(); + stream << "accountSendIOU> " << to_string(uSenderID) << " (" << senderBal << ") -> " + << to_string(uReceiverID) << " (" << receiverBal << ") : " << saAmount.getFullText(); } if (sender) @@ -886,18 +885,17 @@ accountSendIOU( if (auto stream = j.trace()) { - std::string sender_bal("-"); - std::string receiver_bal("-"); + std::string senderBal("-"); + std::string receiverBal("-"); if (sender) - sender_bal = sender->getFieldAmount(sfBalance).getFullText(); + senderBal = sender->getFieldAmount(sfBalance).getFullText(); if (receiver) - receiver_bal = receiver->getFieldAmount(sfBalance).getFullText(); + receiverBal = receiver->getFieldAmount(sfBalance).getFullText(); - stream << "accountSendIOU< " << to_string(uSenderID) << " (" << sender_bal << ") -> " - << to_string(uReceiverID) << " (" << receiver_bal - << ") : " << saAmount.getFullText(); + stream << "accountSendIOU< " << to_string(uSenderID) << " (" << senderBal << ") -> " + << to_string(uReceiverID) << " (" << receiverBal << ") : " << saAmount.getFullText(); } return terResult; @@ -931,16 +929,16 @@ accountSendMultiIOU( */ SLE::pointer const sender = - senderID != beast::zero ? view.peek(keylet::account(senderID)) : SLE::pointer(); + senderID != beast::kZERO ? view.peek(keylet::account(senderID)) : SLE::pointer(); if (auto stream = j.trace()) { - std::string sender_bal("-"); + std::string senderBal("-"); if (sender) - sender_bal = sender->getFieldAmount(sfBalance).getFullText(); + senderBal = sender->getFieldAmount(sfBalance).getFullText(); - stream << "accountSendMultiIOU> " << to_string(senderID) << " (" << sender_bal << ") -> " + stream << "accountSendMultiIOU> " << to_string(senderID) << " (" << senderBal << ") -> " << receivers.size() << " receivers."; } @@ -951,7 +949,7 @@ accountSendMultiIOU( auto const& receiverID = r.first; STAmount const amount{issue, r.second}; - if (amount < beast::zero) + if (amount < beast::kZERO) { return tecINTERNAL; // LCOV_EXCL_LINE } @@ -963,17 +961,17 @@ accountSendMultiIOU( continue; SLE::pointer const receiver = - receiverID != beast::zero ? view.peek(keylet::account(receiverID)) : SLE::pointer(); + receiverID != beast::kZERO ? view.peek(keylet::account(receiverID)) : SLE::pointer(); if (auto stream = j.trace()) { - std::string receiver_bal("-"); + std::string receiverBal("-"); if (receiver) - receiver_bal = receiver->getFieldAmount(sfBalance).getFullText(); + receiverBal = receiver->getFieldAmount(sfBalance).getFullText(); stream << "accountSendMultiIOU> " << to_string(senderID) << " -> " - << to_string(receiverID) << " (" << receiver_bal + << to_string(receiverID) << " (" << receiverBal << ") : " << amount.getFullText(); } @@ -992,13 +990,13 @@ accountSendMultiIOU( if (auto stream = j.trace()) { - std::string receiver_bal("-"); + std::string receiverBal("-"); if (receiver) - receiver_bal = receiver->getFieldAmount(sfBalance).getFullText(); + receiverBal = receiver->getFieldAmount(sfBalance).getFullText(); stream << "accountSendMultiIOU< " << to_string(senderID) << " -> " - << to_string(receiverID) << " (" << receiver_bal + << to_string(receiverID) << " (" << receiverBal << ") : " << amount.getFullText(); } } @@ -1019,12 +1017,12 @@ accountSendMultiIOU( if (auto stream = j.trace()) { - std::string sender_bal("-"); + std::string senderBal("-"); if (sender) - sender_bal = sender->getFieldAmount(sfBalance).getFullText(); + senderBal = sender->getFieldAmount(sfBalance).getFullText(); - stream << "accountSendMultiIOU< " << to_string(senderID) << " (" << sender_bal << ") -> " + stream << "accountSendMultiIOU< " << to_string(senderID) << " (" << senderBal << ") -> " << receivers.size() << " receivers."; } return tesSUCCESS; @@ -1193,7 +1191,7 @@ directSendNoLimitMultiMPT( // small-scale mantissa (~16 digits) can lose precision for values near // maxMPTokenAmount (19 digits). std::uint64_t totalSendAmount{0}; - std::uint64_t const maximumAmount = sle->at(~sfMaximumAmount).value_or(maxMPTokenAmount); + std::uint64_t const maximumAmount = sle->at(~sfMaximumAmount).value_or(kMAX_MP_TOKEN_AMOUNT); std::uint64_t const outstandingAmount = sle->getFieldU64(sfOutstandingAmount); // actual accumulates the total cost to the sender (includes transfer @@ -1207,7 +1205,7 @@ directSendNoLimitMultiMPT( { STAmount const amount{mptIssue, amt}; - if (amount < beast::zero) + if (amount < beast::kZERO) return tecINTERNAL; // LCOV_EXCL_LINE if (!amount || senderID == receiverID) @@ -1218,7 +1216,7 @@ directSendNoLimitMultiMPT( if (senderID == issuer) { XRPL_ASSERT_PARTS( - takeFromSender == beast::zero, + takeFromSender == beast::kZERO, "xrpl::directSendNoLimitMultiMPT", "sender == issuer, takeFromSender == zero"); @@ -1300,7 +1298,7 @@ accountSendMPT( AllowMPTOverflow allowOverflow) { XRPL_ASSERT( - saAmount >= beast::zero && saAmount.holds(), + saAmount >= beast::kZERO && saAmount.holds(), "xrpl::accountSendMPT : minimum amount and MPT"); /* If we aren't sending anything or if the sender is the same as the @@ -1402,8 +1400,8 @@ transferXRP( STAmount const& amount, beast::Journal j) { - XRPL_ASSERT(from != beast::zero, "xrpl::transferXRP : nonzero from account"); - XRPL_ASSERT(to != beast::zero, "xrpl::transferXRP : nonzero to account"); + XRPL_ASSERT(from != beast::kZERO, "xrpl::transferXRP : nonzero from account"); + XRPL_ASSERT(to != beast::kZERO, "xrpl::transferXRP : nonzero to account"); XRPL_ASSERT(from != to, "xrpl::transferXRP : sender is not receiver"); XRPL_ASSERT(amount.native(), "xrpl::transferXRP : amount is XRP"); diff --git a/src/libxrpl/ledger/helpers/VaultHelpers.cpp b/src/libxrpl/ledger/helpers/VaultHelpers.cpp index 99500b36bf..8832e0078f 100644 --- a/src/libxrpl/ledger/helpers/VaultHelpers.cpp +++ b/src/libxrpl/ledger/helpers/VaultHelpers.cpp @@ -86,7 +86,7 @@ assetsToSharesWithdraw( return shares; Number const shareTotal = issuance->at(sfOutstandingAmount); Number result = (shareTotal * assets) / assetTotal; - if (truncate == TruncateShares::yes) + if (truncate == TruncateShares::Yes) result = result.truncate(); shares = result; return shares; diff --git a/src/libxrpl/net/HTTPClient.cpp b/src/libxrpl/net/HTTPClient.cpp index 028da37fa7..afdb264916 100644 --- a/src/libxrpl/net/HTTPClient.cpp +++ b/src/libxrpl/net/HTTPClient.cpp @@ -33,7 +33,7 @@ namespace xrpl { -static std::optional httpClientSSLContext; +static std::optional gHttpClientSslContext; void HTTPClient::initializeSSLContext( @@ -42,13 +42,13 @@ HTTPClient::initializeSSLContext( bool sslVerify, beast::Journal j) { - httpClientSSLContext.emplace(sslVerifyDir, sslVerifyFile, sslVerify, j); + gHttpClientSslContext.emplace(sslVerifyDir, sslVerifyFile, sslVerify, j); } void HTTPClient::cleanupSSLContext() { - httpClientSSLContext.reset(); + gHttpClientSslContext.reset(); } //------------------------------------------------------------------------------ @@ -61,18 +61,18 @@ class HTTPClientImp : public std::enable_shared_from_this, public { public: HTTPClientImp( - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, unsigned short const port, std::size_t maxResponseSize, beast::Journal& j) - : mSocket( - io_context, - httpClientSSLContext->context()) // NOLINT(bugprone-unchecked-optional-access) - , mResolver(io_context) - , mHeader(maxClientHeaderBytes) - , mPort(port) + : socket_( + ioContext, + gHttpClientSslContext->context()) // NOLINT(bugprone-unchecked-optional-access) + , resolver_(ioContext) + , header_(kMAX_CLIENT_HEADER_BYTES) + , port_(port) , maxResponseSize_(maxResponseSize) - , mDeadline(io_context) + , deadline_(ioContext) , j_(j) { } @@ -107,11 +107,11 @@ public: int iStatus, std::string const& strData)> complete) { - mSSL = bSSL; - mDeqSites = deqSites; - mBuild = build; - mComplete = complete; - mTimeout = timeout; + ssl_ = bSSL; + deqSites_ = deqSites; + build_ = build; + complete_ = complete; + timeout_ = timeout; httpsNext(); } @@ -128,8 +128,8 @@ public: int iStatus, std::string const& strData)> complete) { - mComplete = complete; - mTimeout = timeout; + complete_ = complete; + timeout_ = timeout; request( bSSL, @@ -149,36 +149,36 @@ public: void httpsNext() { - JLOG(j_.trace()) << "Fetch: " << mDeqSites[0]; + JLOG(j_.trace()) << "Fetch: " << deqSites_[0]; auto query = std::make_shared( - mDeqSites[0], - std::to_string(mPort), + deqSites_[0], + std::to_string(port_), boost::asio::ip::resolver_query_base::numeric_service); - mQuery = query; + query_ = query; try { - mDeadline.expires_after(mTimeout); + deadline_.expires_after(timeout_); } catch (boost::system::system_error const& e) { - mShutdown = e.code(); + shutdown_ = e.code(); - JLOG(j_.trace()) << "expires_after: " << mShutdown.message(); - mDeadline.async_wait( + JLOG(j_.trace()) << "expires_after: " << shutdown_.message(); + deadline_.async_wait( std::bind( &HTTPClientImp::handleDeadline, shared_from_this(), std::placeholders::_1)); } - if (!mShutdown) + if (!shutdown_) { - JLOG(j_.trace()) << "Resolving: " << mDeqSites[0]; + JLOG(j_.trace()) << "Resolving: " << deqSites_[0]; - mResolver.async_resolve( - mQuery->host, - mQuery->port, - mQuery->flags, + resolver_.async_resolve( + query_->host, + query_->port, + query_->flags, std::bind( &HTTPClientImp::handleResolve, shared_from_this(), @@ -186,8 +186,8 @@ public: std::placeholders::_2)); } - if (mShutdown) - invokeComplete(mShutdown); + if (shutdown_) + invokeComplete(shutdown_); } void @@ -202,7 +202,7 @@ public: } else if (ecResult) { - JLOG(j_.trace()) << "Deadline error: " << mDeqSites[0] << ": " << ecResult.message(); + JLOG(j_.trace()) << "Deadline error: " << deqSites_[0] << ": " << ecResult.message(); // Can't do anything sound. std::abort(); @@ -213,14 +213,14 @@ public: // Mark us as shutting down. // XXX Use our own error code. - mShutdown = boost::system::error_code{ + shutdown_ = boost::system::error_code{ boost::system::errc::bad_address, boost::system::system_category()}; // Cancel any resolving. - mResolver.cancel(); + resolver_.cancel(); // Stop the transaction. - mSocket.async_shutdown( + socket_.asyncShutdown( std::bind( &HTTPClientImp::handleShutdown, shared_from_this(), std::placeholders::_1)); } @@ -231,7 +231,7 @@ public: { if (ecResult) { - JLOG(j_.trace()) << "Shutdown error: " << mDeqSites[0] << ": " << ecResult.message(); + JLOG(j_.trace()) << "Shutdown error: " << deqSites_[0] << ": " << ecResult.message(); } } @@ -240,27 +240,27 @@ public: boost::system::error_code const& ecResult, boost::asio::ip::tcp::resolver::results_type result) { - if (!mShutdown) + if (!shutdown_) { - mShutdown = ecResult + shutdown_ = ecResult ? ecResult - // httpClientSSLContext always initialized before use + // gHttpClientSslContext always initialized before use // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - : httpClientSSLContext->preConnectVerify(mSocket.SSLSocket(), mDeqSites[0]); + : gHttpClientSslContext->preConnectVerify(socket_.sslSocket(), deqSites_[0]); } - if (mShutdown) + if (shutdown_) { - JLOG(j_.trace()) << "Resolve error: " << mDeqSites[0] << ": " << mShutdown.message(); + JLOG(j_.trace()) << "Resolve error: " << deqSites_[0] << ": " << shutdown_.message(); - invokeComplete(mShutdown); + invokeComplete(shutdown_); } else { JLOG(j_.trace()) << "Resolve complete."; boost::asio::async_connect( - mSocket.lowest_layer(), + socket_.lowestLayer(), result, std::bind( &HTTPClientImp::handleConnect, shared_from_this(), std::placeholders::_1)); @@ -270,36 +270,36 @@ public: void handleConnect(boost::system::error_code const& ecResult) { - if (!mShutdown) - mShutdown = ecResult; + if (!shutdown_) + shutdown_ = ecResult; - if (mShutdown) + if (shutdown_) { - JLOG(j_.trace()) << "Connect error: " << mShutdown.message(); + JLOG(j_.trace()) << "Connect error: " << shutdown_.message(); } - if (!mShutdown) + if (!shutdown_) { JLOG(j_.trace()) << "Connected."; - // httpClientSSLContext always initialized before use + // gHttpClientSslContext always initialized before use // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - mShutdown = httpClientSSLContext->postConnectVerify(mSocket.SSLSocket(), mDeqSites[0]); + shutdown_ = gHttpClientSslContext->postConnectVerify(socket_.sslSocket(), deqSites_[0]); - if (mShutdown) + if (shutdown_) { - JLOG(j_.trace()) << "postConnectVerify: " << mDeqSites[0] << ": " - << mShutdown.message(); + JLOG(j_.trace()) << "postConnectVerify: " << deqSites_[0] << ": " + << shutdown_.message(); } } - if (mShutdown) + if (shutdown_) { - invokeComplete(mShutdown); + invokeComplete(shutdown_); } - else if (mSSL) + else if (ssl_) { - mSocket.async_handshake( + socket_.asyncHandshake( AutoSocket::ssl_socket::client, std::bind( &HTTPClientImp::handleRequest, shared_from_this(), std::placeholders::_1)); @@ -313,23 +313,23 @@ public: void handleRequest(boost::system::error_code const& ecResult) { - if (!mShutdown) - mShutdown = ecResult; + if (!shutdown_) + shutdown_ = ecResult; - if (mShutdown) + if (shutdown_) { - JLOG(j_.trace()) << "Handshake error:" << mShutdown.message(); + JLOG(j_.trace()) << "Handshake error:" << shutdown_.message(); - invokeComplete(mShutdown); + invokeComplete(shutdown_); } else { JLOG(j_.trace()) << "Session started."; - mBuild(mRequest, mDeqSites[0]); + build_(request_, deqSites_[0]); - mSocket.async_write( - mRequest, + socket_.asyncWrite( + request_, std::bind( &HTTPClientImp::handleWrite, shared_from_this(), @@ -339,23 +339,23 @@ public: } void - handleWrite(boost::system::error_code const& ecResult, std::size_t bytes_transferred) + handleWrite(boost::system::error_code const& ecResult, std::size_t bytesTransferred) { - if (!mShutdown) - mShutdown = ecResult; + if (!shutdown_) + shutdown_ = ecResult; - if (mShutdown) + if (shutdown_) { - JLOG(j_.trace()) << "Write error: " << mShutdown.message(); + JLOG(j_.trace()) << "Write error: " << shutdown_.message(); - invokeComplete(mShutdown); + invokeComplete(shutdown_); } else { JLOG(j_.trace()) << "Wrote."; - mSocket.async_read_until( - mHeader, + socket_.asyncReadUntil( + header_, "\r\n\r\n", std::bind( &HTTPClientImp::handleHeader, @@ -366,20 +366,20 @@ public: } void - handleHeader(boost::system::error_code const& ecResult, std::size_t bytes_transferred) + handleHeader(boost::system::error_code const& ecResult, std::size_t bytesTransferred) { std::string strHeader{ - {std::istreambuf_iterator(&mHeader)}, std::istreambuf_iterator()}; + {std::istreambuf_iterator(&header_)}, std::istreambuf_iterator()}; JLOG(j_.trace()) << "Header: \"" << strHeader << "\""; - static boost::regex const reStatus{"\\`HTTP/1\\S+ (\\d{3}) .*\\'"}; // HTTP/1.1 200 OK - static boost::regex const reSize{ + static boost::regex const kRE_STATUS{"\\`HTTP/1\\S+ (\\d{3}) .*\\'"}; // HTTP/1.1 200 OK + static boost::regex const kRE_SIZE{ "\\`.*\\r\\nContent-Length:\\s+([0-9]+).*\\'", boost::regex::icase}; - static boost::regex const reBody{"\\`.*\\r\\n\\r\\n(.*)\\'"}; + static boost::regex const kRE_BODY{"\\`.*\\r\\n\\r\\n(.*)\\'"}; boost::smatch smMatch; // Match status code. - if (!boost::regex_match(strHeader, smMatch, reStatus)) + if (!boost::regex_match(strHeader, smMatch, kRE_STATUS)) { // XXX Use our own error code. JLOG(j_.trace()) << "No status code"; @@ -389,13 +389,13 @@ public: return; } - mStatus = beast::lexicalCastThrow(std::string(smMatch[1])); + status_ = beast::lexicalCastThrow(std::string(smMatch[1])); - if (boost::regex_match(strHeader, smMatch, reBody)) // we got some body - mBody = smMatch[1]; + if (boost::regex_match(strHeader, smMatch, kRE_BODY)) // we got some body + body_ = smMatch[1]; std::size_t const responseSize = [&] { - if (boost::regex_match(strHeader, smMatch, reSize)) + if (boost::regex_match(strHeader, smMatch, kRE_SIZE)) return beast::lexicalCast(std::string(smMatch[1]), maxResponseSize_); return maxResponseSize_; }(); @@ -412,17 +412,17 @@ public: if (responseSize == 0) { // no body wanted or available - invokeComplete(ecResult, mStatus); + invokeComplete(ecResult, status_); } - else if (mBody.size() >= responseSize) + else if (body_.size() >= responseSize) { // we got the whole thing - invokeComplete(ecResult, mStatus, mBody); + invokeComplete(ecResult, status_, body_); } else { - mSocket.async_read( - mResponse.prepare(responseSize - mBody.size()), + socket_.asyncRead( + response_.prepare(responseSize - body_.size()), boost::asio::transfer_all(), std::bind( &HTTPClientImp::handleData, @@ -433,29 +433,29 @@ public: } void - handleData(boost::system::error_code const& ecResult, std::size_t bytes_transferred) + handleData(boost::system::error_code const& ecResult, std::size_t bytesTransferred) { - if (!mShutdown) - mShutdown = ecResult; + if (!shutdown_) + shutdown_ = ecResult; - if (mShutdown && mShutdown != boost::asio::error::eof) + if (shutdown_ && shutdown_ != boost::asio::error::eof) { - JLOG(j_.trace()) << "Read error: " << mShutdown.message(); + JLOG(j_.trace()) << "Read error: " << shutdown_.message(); - invokeComplete(mShutdown); + invokeComplete(shutdown_); } else { - if (mShutdown) + if (shutdown_) { JLOG(j_.trace()) << "Complete."; } else { - mResponse.commit(bytes_transferred); + response_.commit(bytesTransferred); std::string const strBody{ - {std::istreambuf_iterator(&mResponse)}, std::istreambuf_iterator()}; - invokeComplete(ecResult, mStatus, mBody + strBody); + {std::istreambuf_iterator(&response_)}, std::istreambuf_iterator()}; + invokeComplete(ecResult, status_, body_ + strBody); } } } @@ -470,7 +470,7 @@ public: boost::system::error_code ecCancel; try { - mDeadline.cancel(); + deadline_.cancel(); } catch (boost::system::system_error const& e) { @@ -478,24 +478,24 @@ public: ecCancel = e.code(); } - JLOG(j_.debug()) << "invokeComplete: Deadline popping: " << mDeqSites.size(); + JLOG(j_.debug()) << "invokeComplete: Deadline popping: " << deqSites_.size(); - if (!mDeqSites.empty()) + if (!deqSites_.empty()) { - mDeqSites.pop_front(); + deqSites_.pop_front(); } bool bAgain = true; - if (mDeqSites.empty() || !ecResult) + if (deqSites_.empty() || !ecResult) { // ecResult: !0 = had an error, last entry // iStatus: result, if no error // strData: data, if no error - bAgain = mComplete && mComplete(ecResult ? ecResult : ecCancel, iStatus, strData); + bAgain = complete_ && complete_(ecResult ? ecResult : ecCancel, iStatus, strData); } - if (!mDeqSites.empty() && bAgain) + if (!deqSites_.empty() && bAgain) { httpsNext(); } @@ -504,9 +504,9 @@ public: private: using pointer = std::shared_ptr; - bool mSSL{}; - AutoSocket mSocket; - boost::asio::ip::tcp::resolver mResolver; + bool ssl_{}; + AutoSocket socket_; + boost::asio::ip::tcp::resolver resolver_; struct Query { @@ -514,27 +514,27 @@ private: std::string port; boost::asio::ip::resolver_query_base::flags flags; }; - std::shared_ptr mQuery; + std::shared_ptr query_; - boost::asio::streambuf mRequest; - boost::asio::streambuf mHeader; - boost::asio::streambuf mResponse; - std::string mBody; - unsigned short const mPort; + boost::asio::streambuf request_; + boost::asio::streambuf header_; + boost::asio::streambuf response_; + std::string body_; + unsigned short const port_; std::size_t const maxResponseSize_; - int mStatus{}; - std::function mBuild; + int status_{}; + std::function build_; std::function< bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)> - mComplete; + complete_; - boost::asio::basic_waitable_timer mDeadline; + boost::asio::basic_waitable_timer deadline_; // If not success, we are shutting down. - boost::system::error_code mShutdown; + boost::system::error_code shutdown_; - std::deque mDeqSites; - std::chrono::seconds mTimeout{}; + std::deque deqSites_; + std::chrono::seconds timeout_{}; beast::Journal j_; }; @@ -543,7 +543,7 @@ private: void HTTPClient::get( bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::deque deqSites, unsigned short const port, std::string const& strPath, @@ -554,14 +554,14 @@ HTTPClient::get( complete, beast::Journal& j) { - auto client = std::make_shared(io_context, port, responseMax, j); + auto client = std::make_shared(ioContext, port, responseMax, j); client->get(bSSL, deqSites, strPath, timeout, complete); } void HTTPClient::get( bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::string strSite, unsigned short const port, std::string const& strPath, @@ -574,14 +574,14 @@ HTTPClient::get( { std::deque const deqSites(1, strSite); - auto client = std::make_shared(io_context, port, responseMax, j); + auto client = std::make_shared(ioContext, port, responseMax, j); client->get(bSSL, deqSites, strPath, timeout, complete); } void HTTPClient::request( bool bSSL, - boost::asio::io_context& io_context, + boost::asio::io_context& ioContext, std::string strSite, unsigned short const port, std::function setRequest, @@ -594,7 +594,7 @@ HTTPClient::request( { std::deque const deqSites(1, strSite); - auto client = std::make_shared(io_context, port, responseMax, j); + auto client = std::make_shared(ioContext, port, responseMax, j); client->request(bSSL, deqSites, setRequest, timeout, complete); } diff --git a/src/libxrpl/nodestore/BatchWriter.cpp b/src/libxrpl/nodestore/BatchWriter.cpp index b05c80ff00..28184bf174 100644 --- a/src/libxrpl/nodestore/BatchWriter.cpp +++ b/src/libxrpl/nodestore/BatchWriter.cpp @@ -14,9 +14,9 @@ namespace xrpl::NodeStore { BatchWriter::BatchWriter(Callback& callback, Scheduler& scheduler) - : m_callback(callback), m_scheduler(scheduler) + : callback_(callback), scheduler_(scheduler) { - mWriteSet.reserve(batchWritePreallocationSize); + writeSet_.reserve(BatchWritePreallocationSize); } BatchWriter::~BatchWriter() @@ -27,29 +27,29 @@ BatchWriter::~BatchWriter() void BatchWriter::store(std::shared_ptr const& object) { - std::unique_lock sl(mWriteMutex); + std::unique_lock sl(writeMutex_); // If the batch has reached its limit, we wait // until the batch writer is finished - while (mWriteSet.size() >= batchWriteLimitSize) - mWriteCondition.wait(sl); + while (writeSet_.size() >= BatchWriteLimitSize) + writeCondition_.wait(sl); - mWriteSet.push_back(object); + writeSet_.push_back(object); - if (!mWritePending) + if (!writePending_) { - mWritePending = true; + writePending_ = true; - m_scheduler.scheduleTask(*this); + scheduler_.scheduleTask(*this); } } int BatchWriter::getWriteLoad() { - std::scoped_lock const sl(mWriteMutex); + std::scoped_lock const sl(writeMutex_); - return std::max(mWriteLoad, static_cast(mWriteSet.size())); + return std::max(writeLoad_, static_cast(writeSet_.size())); } void @@ -65,20 +65,20 @@ BatchWriter::writeBatch() { std::vector> set; - set.reserve(batchWritePreallocationSize); + set.reserve(BatchWritePreallocationSize); { - std::scoped_lock const sl(mWriteMutex); + std::scoped_lock const sl(writeMutex_); - mWriteSet.swap(set); + writeSet_.swap(set); XRPL_ASSERT( - mWriteSet.empty(), "xrpl::NodeStore::BatchWriter::writeBatch : writes not set"); - mWriteLoad = set.size(); + writeSet_.empty(), "xrpl::NodeStore::BatchWriter::writeBatch : writes not set"); + writeLoad_ = set.size(); if (set.empty()) { - mWritePending = false; - mWriteCondition.notify_all(); + writePending_ = false; + writeCondition_.notify_all(); // VFALCO NOTE Fix this function to not return from the middle return; @@ -89,22 +89,22 @@ BatchWriter::writeBatch() report.writeCount = set.size(); auto const before = std::chrono::steady_clock::now(); - m_callback.writeBatch(set); + callback_.writeBatch(set); report.elapsed = std::chrono::duration_cast( std::chrono::steady_clock::now() - before); - m_scheduler.onBatchWrite(report); + scheduler_.onBatchWrite(report); } } void BatchWriter::waitForWriting() { - std::unique_lock sl(mWriteMutex); + std::unique_lock sl(writeMutex_); - while (mWritePending) - mWriteCondition.wait(sl); + while (writePending_) + writeCondition_.wait(sl); } } // namespace xrpl::NodeStore diff --git a/src/libxrpl/nodestore/Database.cpp b/src/libxrpl/nodestore/Database.cpp index fa69cba517..84941d98aa 100644 --- a/src/libxrpl/nodestore/Database.cpp +++ b/src/libxrpl/nodestore/Database.cpp @@ -38,7 +38,7 @@ Database::Database( beast::Journal journal) : j_(journal) , scheduler_(scheduler) - , earliestLedgerSeq_(get(config, "earliest_seq", XRP_LEDGER_EARLIEST_SEQ)) + , earliestLedgerSeq_(get(config, "earliest_seq", kXRP_LEDGER_EARLIEST_SEQ)) , requestBundle_(get(config, "rq_bundle", 4)) , readThreads_(std::max(1, readThreads)) { @@ -95,7 +95,7 @@ Database::Database( auto const& data = it->second; auto const seqn = data[0].first; - auto obj = fetchNodeObject(hash, seqn, FetchType::async); + auto obj = fetchNodeObject(hash, seqn, FetchType::Async); // This could be further optimized: if there are // multiple requests for sequence numbers mapping to @@ -107,7 +107,7 @@ Database::Database( req.second( (seqn == req.first) || isSameDB(req.first, seqn) ? obj - : fetchNodeObject(hash, req.first, FetchType::async)); + : fetchNodeObject(hash, req.first, FetchType::Async)); } } @@ -192,7 +192,7 @@ void Database::importInternal(Backend& dstBackend, Database& srcDB) { Batch batch; - batch.reserve(batchWritePreallocationSize); + batch.reserve(BatchWritePreallocationSize); auto storeBatch = [&, fname = __func__]() { try { @@ -211,13 +211,13 @@ Database::importInternal(Backend& dstBackend, Database& srcDB) batch.clear(); }; - srcDB.for_each([&](std::shared_ptr nodeObject) { + srcDB.forEach([&](std::shared_ptr nodeObject) { XRPL_ASSERT(nodeObject, "xrpl::NodeStore::Database::importInternal : non-null node"); if (!nodeObject) // This should never happen return; batch.emplace_back(std::move(nodeObject)); - if (batch.size() >= batchWritePreallocationSize) + if (batch.size() >= BatchWritePreallocationSize) storeBatch(); }); @@ -254,13 +254,13 @@ Database::fetchNodeObject( } void -Database::getCountsJson(Json::Value& obj) +Database::getCountsJson(json::Value& obj) { XRPL_ASSERT(obj.isObject(), "xrpl::NodeStore::Database::getCountsJson : valid input type"); { std::unique_lock const lock(readLock_); - obj["read_queue"] = static_cast(read_.size()); + obj["read_queue"] = static_cast(read_.size()); } obj["read_threads_total"] = readThreads_.load(); diff --git a/src/libxrpl/nodestore/DatabaseNodeImp.cpp b/src/libxrpl/nodestore/DatabaseNodeImp.cpp index 1bb5f32308..ef84862de6 100644 --- a/src/libxrpl/nodestore/DatabaseNodeImp.cpp +++ b/src/libxrpl/nodestore/DatabaseNodeImp.cpp @@ -48,7 +48,7 @@ DatabaseNodeImp::fetchNodeObject( bool duplicate) { std::shared_ptr nodeObject = nullptr; - Status status = Status::ok; + Status status = Status::Ok; try { @@ -58,15 +58,15 @@ DatabaseNodeImp::fetchNodeObject( { JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": Exception fetching from backend: " << e.what(); - Rethrow(); + rethrow(); } switch (status) { - case Status::ok: - case Status::notFound: + case Status::Ok: + case Status::NotFound: break; - case Status::dataCorrupt: + case Status::DataCorrupt: JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": nodestore data is corrupted"; break; default: diff --git a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp index de34af7773..24b0e2de2e 100644 --- a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp +++ b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp @@ -121,7 +121,7 @@ DatabaseRotatingImp::fetchNodeObject( bool duplicate) { auto fetch = [&](std::shared_ptr const& backend) { - Status status = Status::ok; + Status status = Status::Ok; std::shared_ptr nodeObject; try { @@ -130,15 +130,15 @@ DatabaseRotatingImp::fetchNodeObject( catch (std::exception const& e) { JLOG(j_.fatal()) << "Exception, " << e.what(); - Rethrow(); + rethrow(); } switch (status) { - case Status::ok: - case Status::notFound: + case Status::Ok: + case Status::NotFound: break; - case Status::dataCorrupt: + case Status::DataCorrupt: JLOG(j_.fatal()) << "Corrupt NodeObject #" << hash; break; default: @@ -184,7 +184,7 @@ DatabaseRotatingImp::fetchNodeObject( } void -DatabaseRotatingImp::for_each(std::function)> f) +DatabaseRotatingImp::forEach(std::function)> f) { auto [writable, archive] = [&] { std::scoped_lock const lock(mutex_); @@ -192,10 +192,10 @@ DatabaseRotatingImp::for_each(std::function)> f }(); // Iterate the writable backend - writable->for_each(f); + writable->forEach(f); // Iterate the archive backend - archive->for_each(f); + archive->forEach(f); } } // namespace xrpl::NodeStore diff --git a/src/libxrpl/nodestore/DecodedBlob.cpp b/src/libxrpl/nodestore/DecodedBlob.cpp index 437aef24da..fb7569bd8c 100644 --- a/src/libxrpl/nodestore/DecodedBlob.cpp +++ b/src/libxrpl/nodestore/DecodedBlob.cpp @@ -23,34 +23,34 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) 9...end The body of the object data */ - m_success = false; - m_key = key; - m_objectType = NodeObjectType::hotUNKNOWN; - m_objectData = nullptr; - m_dataBytes = std::max(0, valueBytes - 9); + success_ = false; + key_ = key; + objectType_ = NodeObjectType::Unknown; + objectData_ = nullptr; + dataBytes_ = std::max(0, valueBytes - 9); // VFALCO NOTE What about bytes 4 through 7 inclusive? if (valueBytes > 8) { unsigned char const* byte = static_cast(value); - m_objectType = safe_cast(byte[8]); + objectType_ = safeCast(byte[8]); } if (valueBytes > 9) { - m_objectData = static_cast(value) + 9; + objectData_ = static_cast(value) + 9; - switch (m_objectType) + switch (objectType_) { default: break; - case NodeObjectType::hotUNKNOWN: - case NodeObjectType::hotLEDGER: - case NodeObjectType::hotACCOUNT_NODE: - case NodeObjectType::hotTRANSACTION_NODE: - m_success = true; + case NodeObjectType::Unknown: + case NodeObjectType::Ledger: + case NodeObjectType::AccountNode: + case NodeObjectType::TransactionNode: + success_ = true; break; } } @@ -59,15 +59,15 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) std::shared_ptr DecodedBlob::createObject() { - XRPL_ASSERT(m_success, "xrpl::NodeStore::DecodedBlob::createObject : valid object type"); + XRPL_ASSERT(success_, "xrpl::NodeStore::DecodedBlob::createObject : valid object type"); std::shared_ptr object; - if (m_success) + if (success_) { - Blob data(m_objectData, m_objectData + m_dataBytes); + Blob data(objectData_, objectData_ + dataBytes_); - object = NodeObject::createObject(m_objectType, std::move(data), uint256::fromVoid(m_key)); + object = NodeObject::createObject(objectType_, std::move(data), uint256::fromVoid(key_)); } return object; diff --git a/src/libxrpl/nodestore/ManagerImp.cpp b/src/libxrpl/nodestore/ManagerImp.cpp index 1420bf3997..0cfda7d86a 100644 --- a/src/libxrpl/nodestore/ManagerImp.cpp +++ b/src/libxrpl/nodestore/ManagerImp.cpp @@ -26,12 +26,12 @@ namespace xrpl::NodeStore { ManagerImp& ManagerImp::instance() { - static ManagerImp _; - return _; + static ManagerImp k_; + return k_; } void -ManagerImp::missing_backend() +ManagerImp::missingBackend() { Throw( "Your xrpld.cfg is missing a [node_db] entry, " @@ -60,7 +60,7 @@ ManagerImp::ManagerImp() } std::unique_ptr -ManagerImp::make_Backend( +ManagerImp::makeBackend( Section const& parameters, std::size_t burstSize, Scheduler& scheduler, @@ -68,26 +68,27 @@ ManagerImp::make_Backend( { std::string const type{get(parameters, "type")}; if (type.empty()) - missing_backend(); + missingBackend(); auto factory{find(type)}; if (factory == nullptr) { - missing_backend(); + missingBackend(); } - return factory->createInstance(NodeObject::keyBytes, parameters, burstSize, scheduler, journal); + return factory->createInstance( + NodeObject::kKEY_BYTES, parameters, burstSize, scheduler, journal); } std::unique_ptr -ManagerImp::make_Database( +ManagerImp::makeDatabase( std::size_t burstSize, Scheduler& scheduler, int readThreads, Section const& config, beast::Journal journal) { - auto backend{make_Backend(config, burstSize, scheduler, journal)}; + auto backend{makeBackend(config, burstSize, scheduler, journal)}; backend->open(); return std::make_unique( scheduler, readThreads, std::move(backend), config, journal); diff --git a/src/libxrpl/nodestore/NodeObject.cpp b/src/libxrpl/nodestore/NodeObject.cpp index b19d5d625a..99432eb495 100644 --- a/src/libxrpl/nodestore/NodeObject.cpp +++ b/src/libxrpl/nodestore/NodeObject.cpp @@ -11,7 +11,7 @@ namespace xrpl { //------------------------------------------------------------------------------ NodeObject::NodeObject(NodeObjectType type, Blob&& data, uint256 const& hash, PrivateAccess) - : mType(type), mHash(hash), mData(std::move(data)) + : type_(type), hash_(hash), data_(std::move(data)) { } @@ -24,19 +24,19 @@ NodeObject::createObject(NodeObjectType type, Blob&& data, uint256 const& hash) NodeObjectType NodeObject::getType() const { - return mType; + return type_; } uint256 const& NodeObject::getHash() const { - return mHash; + return hash_; } Blob const& NodeObject::getData() const { - return mData; + return data_; } } // namespace xrpl diff --git a/src/libxrpl/nodestore/backend/MemoryFactory.cpp b/src/libxrpl/nodestore/backend/MemoryFactory.cpp index ef07ebe957..13c82696cb 100644 --- a/src/libxrpl/nodestore/backend/MemoryFactory.cpp +++ b/src/libxrpl/nodestore/backend/MemoryFactory.cpp @@ -69,13 +69,13 @@ public: } }; -MemoryFactory* memoryFactory = nullptr; +MemoryFactory* gMemoryFactory = nullptr; void registerMemoryFactory(Manager& manager) { - static MemoryFactory instance{manager}; - memoryFactory = &instance; + static MemoryFactory kINSTANCE{manager}; + gMemoryFactory = &kINSTANCE; } //------------------------------------------------------------------------------ @@ -112,7 +112,7 @@ public: void open(bool) override { - db_ = &memoryFactory->open(name_); + db_ = &gMemoryFactory->open(name_); } bool @@ -140,10 +140,10 @@ public: if (iter == db_->table.end()) { pObject->reset(); - return Status::notFound; + return Status::NotFound; } *pObject = iter->second; - return Status::ok; + return Status::Ok; } std::pair>, Status> @@ -155,7 +155,7 @@ public: { std::shared_ptr nObj; Status const status = fetch(h, &nObj); - if (status != Status::ok) + if (status != Status::Ok) { results.push_back({}); } @@ -165,7 +165,7 @@ public: } } - return {results, Status::ok}; + return {results, Status::Ok}; } void @@ -189,9 +189,9 @@ public: } void - for_each(std::function)> f) override + forEach(std::function)> f) override { - XRPL_ASSERT(db_, "xrpl::NodeStore::MemoryBackend::for_each : non-null database"); + XRPL_ASSERT(db_, "xrpl::NodeStore::MemoryBackend::forEach : non-null database"); for (auto const& e : db_->table) f(e.second); } diff --git a/src/libxrpl/nodestore/backend/NuDBFactory.cpp b/src/libxrpl/nodestore/backend/NuDBFactory.cpp index 18fe3c572e..db9dbcbec1 100644 --- a/src/libxrpl/nodestore/backend/NuDBFactory.cpp +++ b/src/libxrpl/nodestore/backend/NuDBFactory.cpp @@ -53,16 +53,16 @@ public: // NuDB database. We used it to identify shard databases before that code // was removed. For now, its only use is a sanity check that the database // was created by xrpld. - static constexpr std::uint64_t appnum = 1; + static constexpr std::uint64_t kAPPNUM = 1; - beast::Journal const j_; - size_t const keyBytes_; - std::size_t const burstSize_; - std::string const name_; - std::size_t const blockSize_; - nudb::store db_; - std::atomic deletePath_; - Scheduler& scheduler_; + beast::Journal const j; + size_t const keyBytes; + std::size_t const burstSize; + std::string const name; + std::size_t const blockSize; + nudb::store db; + std::atomic deletePath; + Scheduler& scheduler; NuDBBackend( size_t keyBytes, @@ -70,15 +70,15 @@ public: std::size_t burstSize, Scheduler& scheduler, beast::Journal journal) - : j_(journal) - , keyBytes_(keyBytes) - , burstSize_(burstSize) - , name_(get(keyValues, "path")) - , blockSize_(parseBlockSize(name_, keyValues, journal)) - , deletePath_(false) - , scheduler_(scheduler) + : j(journal) + , keyBytes(keyBytes) + , burstSize(burstSize) + , name(get(keyValues, "path")) + , blockSize(parseBlockSize(name, keyValues, journal)) + , deletePath(false) + , scheduler(scheduler) { - if (name_.empty()) + if (name.empty()) Throw("nodestore: Missing path in NuDB backend"); } @@ -89,16 +89,16 @@ public: Scheduler& scheduler, nudb::context& context, beast::Journal journal) - : j_(journal) - , keyBytes_(keyBytes) - , burstSize_(burstSize) - , name_(get(keyValues, "path")) - , blockSize_(parseBlockSize(name_, keyValues, journal)) - , db_(context) - , deletePath_(false) - , scheduler_(scheduler) + : j(journal) + , keyBytes(keyBytes) + , burstSize(burstSize) + , name(get(keyValues, "path")) + , blockSize(parseBlockSize(name, keyValues, journal)) + , db(context) + , deletePath(false) + , scheduler(scheduler) { - if (name_.empty()) + if (name.empty()) Throw("nodestore: Missing path in NuDB backend"); } @@ -119,30 +119,30 @@ public: std::string getName() override { - return name_; + return name; } [[nodiscard]] std::optional getBlockSize() const override { - return blockSize_; + return blockSize; } void open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override { using namespace boost::filesystem; - if (db_.is_open()) + if (db.is_open()) { // LCOV_EXCL_START UNREACHABLE( "xrpl::NodeStore::NuDBBackend::open : database is already " "open"); - JLOG(j_.error()) << "database is already open"; + JLOG(j.error()) << "database is already open"; return; // LCOV_EXCL_STOP } - auto const folder = path(name_); + auto const folder = path(name); auto const dp = (folder / "nudb.dat").string(); auto const kp = (folder / "nudb.key").string(); auto const lp = (folder / "nudb.log").string(); @@ -151,54 +151,54 @@ public: { create_directories(folder); nudb::create( - dp, kp, lp, appType, uid, salt, keyBytes_, blockSize_, 0.50, ec); + dp, kp, lp, appType, uid, salt, keyBytes, blockSize, 0.50, ec); if (ec == nudb::errc::file_exists) ec = {}; if (ec) Throw(ec); } - db_.open(dp, kp, lp, ec); + db.open(dp, kp, lp, ec); if (ec) Throw(ec); - if (db_.appnum() != appnum) + if (db.appnum() != kAPPNUM) Throw("nodestore: unknown appnum"); - db_.set_burst(burstSize_); + db.set_burst(burstSize); } bool isOpen() override { - return db_.is_open(); + return db.is_open(); } void open(bool createIfMissing) override { - open(createIfMissing, appnum, nudb::make_uid(), nudb::make_salt()); + open(createIfMissing, kAPPNUM, nudb::make_uid(), nudb::make_salt()); } void close() override { - if (db_.is_open()) + if (db.is_open()) { nudb::error_code ec; - db_.close(ec); + db.close(ec); if (ec) { // Log to make sure the nature of the error gets to the user. - JLOG(j_.fatal()) << "NuBD close() failed: " << ec.message(); + JLOG(j.fatal()) << "NuBD close() failed: " << ec.message(); Throw(ec); } - if (deletePath_) + if (deletePath) { - boost::filesystem::remove_all(name_, ec); + boost::filesystem::remove_all(name, ec); if (ec) { - JLOG(j_.fatal()) - << "Filesystem remove_all of " << name_ << " failed with: " << ec.message(); + JLOG(j.fatal()) + << "Filesystem remove_all of " << name << " failed with: " << ec.message(); } } } @@ -207,26 +207,26 @@ public: Status fetch(uint256 const& hash, std::shared_ptr* pno) override { - Status status = Status::ok; + Status status = Status::Ok; pno->reset(); nudb::error_code ec; - db_.fetch( + db.fetch( hash.data(), [&hash, pno, &status](void const* data, std::size_t size) { nudb::detail::buffer bf; - auto const result = nodeobject_decompress(data, size, bf); + auto const result = nodeobjectDecompress(data, size, bf); DecodedBlob decoded(hash.data(), result.first, result.second); if (!decoded.wasOk()) { - status = Status::dataCorrupt; + status = Status::DataCorrupt; return; } *pno = decoded.createObject(); - status = Status::ok; + status = Status::Ok; }, ec); if (ec == nudb::error::key_not_found) - return Status::notFound; + return Status::NotFound; if (ec) Throw(ec); return status; @@ -241,7 +241,7 @@ public: { std::shared_ptr nObj; Status const status = fetch(h, &nObj); - if (status != Status::ok) + if (status != Status::Ok) { results.push_back({}); } @@ -251,17 +251,17 @@ public: } } - return {results, Status::ok}; + return {results, Status::Ok}; } void - do_insert(std::shared_ptr const& no) + doInsert(std::shared_ptr const& no) { EncodedBlob const e(no); nudb::error_code ec; nudb::detail::buffer bf; - auto const result = nodeobject_compress(e.getData(), e.getSize(), bf); - db_.insert(e.getKey(), result.first, result.second, ec); + auto const result = nodeobjectCompress(e.getData(), e.getSize(), bf); + db.insert(e.getKey(), result.first, result.second, ec); if (ec && ec != nudb::error::key_exists) Throw(ec); } @@ -272,10 +272,10 @@ public: BatchWriteReport report{}; report.writeCount = 1; auto const start = std::chrono::steady_clock::now(); - do_insert(no); + doInsert(no); report.elapsed = std::chrono::duration_cast( std::chrono::steady_clock::now() - start); - scheduler_.onBatchWrite(report); + scheduler.onBatchWrite(report); } void @@ -285,10 +285,10 @@ public: report.writeCount = batch.size(); auto const start = std::chrono::steady_clock::now(); for (auto const& e : batch) - do_insert(e); + doInsert(e); report.elapsed = std::chrono::duration_cast( std::chrono::steady_clock::now() - start); - scheduler_.onBatchWrite(report); + scheduler.onBatchWrite(report); } void @@ -297,25 +297,25 @@ public: } void - for_each(std::function)> f) override + forEach(std::function)> f) override { - auto const dp = db_.dat_path(); - auto const kp = db_.key_path(); - auto const lp = db_.log_path(); + auto const dp = db.dat_path(); + auto const kp = db.key_path(); + auto const lp = db.log_path(); // auto const appnum = db_.appnum(); nudb::error_code ec; - db_.close(ec); + db.close(ec); if (ec) Throw(ec); nudb::visit( dp, [&](void const* key, - std::size_t key_bytes, + std::size_t keyBytes, void const* data, std::size_t size, nudb::error_code&) { nudb::detail::buffer bf; - auto const result = nodeobject_decompress(data, size, bf); + auto const result = nodeobjectDecompress(data, size, bf); DecodedBlob decoded(key, result.first, result.second); if (!decoded.wasOk()) { @@ -328,7 +328,7 @@ public: ec); if (ec) Throw(ec); - db_.open(dp, kp, lp, ec); + db.open(dp, kp, lp, ec); if (ec) Throw(ec); } @@ -342,24 +342,24 @@ public: void setDeletePath() override { - deletePath_ = true; + deletePath = true; } void verify() override { - auto const dp = db_.dat_path(); - auto const kp = db_.key_path(); - auto const lp = db_.log_path(); + auto const dp = db.dat_path(); + auto const kp = db.key_path(); + auto const lp = db.log_path(); nudb::error_code ec; - db_.close(ec); + db.close(ec); if (ec) Throw(ec); nudb::verify_info vi; nudb::verify(vi, dp, kp, 0, nudb::no_progress{}, ec); if (ec) Throw(ec); - db_.open(dp, kp, lp, ec); + db.open(dp, kp, lp, ec); if (ec) Throw(ec); } @@ -382,7 +382,7 @@ private: std::size_t const blockSize = defaultSize; std::string blockSizeStr; - if (!get_if_exists(keyValues, "nudb_block_size", blockSizeStr)) + if (!getIfExists(keyValues, "nudb_block_size", blockSizeStr)) { return blockSize; // Early return with default } @@ -460,7 +460,7 @@ public: void registerNuDBFactory(Manager& manager) { - static NuDBFactory const instance{manager}; + static NuDBFactory const kINSTANCE{manager}; } } // namespace xrpl::NodeStore diff --git a/src/libxrpl/nodestore/backend/NullFactory.cpp b/src/libxrpl/nodestore/backend/NullFactory.cpp index 917ee3d8d0..38f35e91ff 100644 --- a/src/libxrpl/nodestore/backend/NullFactory.cpp +++ b/src/libxrpl/nodestore/backend/NullFactory.cpp @@ -49,7 +49,7 @@ public: Status fetch(uint256 const&, std::shared_ptr*) override { - return Status::notFound; + return Status::NotFound; } std::pair>, Status> @@ -74,7 +74,7 @@ public: } void - for_each(std::function)> f) override + forEach(std::function)> f) override { } @@ -128,7 +128,7 @@ public: void registerNullFactory(Manager& manager) { - static NullFactory const instance{manager}; + static NullFactory const kINSTANCE{manager}; } } // namespace xrpl::NodeStore diff --git a/src/libxrpl/nodestore/backend/RocksDBFactory.cpp b/src/libxrpl/nodestore/backend/RocksDBFactory.cpp index be2506ec6f..7f5ac6b14e 100644 --- a/src/libxrpl/nodestore/backend/RocksDBFactory.cpp +++ b/src/libxrpl/nodestore/backend/RocksDBFactory.cpp @@ -57,7 +57,7 @@ public: struct ThreadParams { - ThreadParams(void (*f_)(void*), void* a_) : f(f_), a(a_) + ThreadParams(void (*f)(void*), void* a) : f(f), a(a) { } @@ -66,7 +66,7 @@ public: }; static void - thread_entry(void* ptr) + threadEntry(void* ptr) { ThreadParams const* const p(reinterpret_cast(ptr)); auto const f = p->f; @@ -74,8 +74,8 @@ public: void* a(p->a); delete p; - static std::atomic n; - std::size_t const id(++n); + static std::atomic kN; + std::size_t const id(++kN); beast::setCurrentThreadName("rocksdb #" + std::to_string(id)); f(a); @@ -85,7 +85,7 @@ public: StartThread(void (*f)(void*), void* a) override { ThreadParams* const p(new ThreadParams(f, a)); - EnvWrapper::StartThread(&RocksDBEnv::thread_entry, p); + EnvWrapper::StartThread(&RocksDBEnv::threadEntry, p); } }; @@ -94,16 +94,16 @@ public: class RocksDBBackend : public Backend, public BatchWriter::Callback { private: - std::atomic m_deletePath; + std::atomic deletePath_; public: - beast::Journal m_journal; - size_t const m_keyBytes; - BatchWriter m_batch; - std::string m_name; - std::unique_ptr m_db; - int fdRequired_ = 2048; - rocksdb::Options m_options; + beast::Journal journal; + size_t const keyBytes; + BatchWriter batch; + std::string name; + std::unique_ptr db; + int fdMinRequired = 2048; + rocksdb::Options options; RocksDBBackend( int keyBytes, @@ -111,90 +111,89 @@ public: Scheduler& scheduler, beast::Journal journal, RocksDBEnv* env) - : m_deletePath(false), m_journal(journal), m_keyBytes(keyBytes), m_batch(*this, scheduler) + : deletePath_(false), journal(journal), keyBytes(keyBytes), batch(*this, scheduler) { - if (!get_if_exists(keyValues, "path", m_name)) + if (!getIfExists(keyValues, "path", name)) Throw("Missing path in RocksDBFactory backend"); - rocksdb::BlockBasedTableOptions table_options; - m_options.env = env; + rocksdb::BlockBasedTableOptions tableOptions; + options.env = env; - bool const hard_set = keyValues.exists("hard_set") && get(keyValues, "hard_set"); + bool const hardSet = keyValues.exists("hard_set") && get(keyValues, "hard_set"); if (keyValues.exists("cache_mb")) { auto size = get(keyValues, "cache_mb"); - if (!hard_set && size == 256) + if (!hardSet && size == 256) size = 1024; - table_options.block_cache = rocksdb::NewLRUCache(megabytes(size)); + tableOptions.block_cache = rocksdb::NewLRUCache(megabytes(size)); } if (auto const v = get(keyValues, "filter_bits")) { - bool const filter_blocks = + bool const filterBlocks = !keyValues.exists("filter_full") || (get(keyValues, "filter_full") == 0); - table_options.filter_policy.reset(rocksdb::NewBloomFilterPolicy(v, filter_blocks)); + tableOptions.filter_policy.reset(rocksdb::NewBloomFilterPolicy(v, filterBlocks)); } - if (get_if_exists(keyValues, "open_files", m_options.max_open_files)) + if (getIfExists(keyValues, "open_files", options.max_open_files)) { - if (!hard_set && m_options.max_open_files == 2000) - m_options.max_open_files = 8000; + if (!hardSet && options.max_open_files == 2000) + options.max_open_files = 8000; - fdRequired_ = m_options.max_open_files + 128; + fdMinRequired = options.max_open_files + 128; } if (keyValues.exists("file_size_mb")) { - auto file_size_mb = get(keyValues, "file_size_mb"); + auto fileSizeMb = get(keyValues, "file_size_mb"); - if (!hard_set && file_size_mb == 8) - file_size_mb = 256; + if (!hardSet && fileSizeMb == 8) + fileSizeMb = 256; - m_options.target_file_size_base = megabytes(file_size_mb); - m_options.max_bytes_for_level_base = 5 * m_options.target_file_size_base; - m_options.write_buffer_size = 2 * m_options.target_file_size_base; + options.target_file_size_base = megabytes(fileSizeMb); + options.max_bytes_for_level_base = 5 * options.target_file_size_base; + options.write_buffer_size = 2 * options.target_file_size_base; } - get_if_exists(keyValues, "file_size_mult", m_options.target_file_size_multiplier); + getIfExists(keyValues, "file_size_mult", options.target_file_size_multiplier); if (keyValues.exists("bg_threads")) { - m_options.env->SetBackgroundThreads( - get(keyValues, "bg_threads"), rocksdb::Env::LOW); + options.env->SetBackgroundThreads(get(keyValues, "bg_threads"), rocksdb::Env::LOW); } if (keyValues.exists("high_threads")) { auto const highThreads = get(keyValues, "high_threads"); - m_options.env->SetBackgroundThreads(highThreads, rocksdb::Env::HIGH); + options.env->SetBackgroundThreads(highThreads, rocksdb::Env::HIGH); // If we have high-priority threads, presumably we want to // use them for background flushes if (highThreads > 0) - m_options.max_background_flushes = highThreads; + options.max_background_flushes = highThreads; } - m_options.compression = rocksdb::kSnappyCompression; + options.compression = rocksdb::kSnappyCompression; - get_if_exists(keyValues, "block_size", table_options.block_size); + getIfExists(keyValues, "block_size", tableOptions.block_size); if (keyValues.exists("universal_compaction") && (get(keyValues, "universal_compaction") != 0)) { - m_options.compaction_style = rocksdb::kCompactionStyleUniversal; - m_options.min_write_buffer_number_to_merge = 2; - m_options.max_write_buffer_number = 6; - m_options.write_buffer_size = 6 * m_options.target_file_size_base; + options.compaction_style = rocksdb::kCompactionStyleUniversal; + options.min_write_buffer_number_to_merge = 2; + options.max_write_buffer_number = 6; + options.write_buffer_size = 6 * options.target_file_size_base; } if (keyValues.exists("bbt_options")) { - rocksdb::ConfigOptions const config_options; + rocksdb::ConfigOptions const configOptions; auto const s = rocksdb::GetBlockBasedTableOptionsFromString( - config_options, table_options, get(keyValues, "bbt_options"), &table_options); + configOptions, tableOptions, get(keyValues, "bbt_options"), &tableOptions); if (!s.ok()) { Throw( @@ -202,12 +201,12 @@ public: } } - m_options.table_factory.reset(NewBlockBasedTableFactory(table_options)); + options.table_factory.reset(NewBlockBasedTableFactory(tableOptions)); if (keyValues.exists("options")) { auto const s = - rocksdb::GetOptionsFromString(m_options, get(keyValues, "options"), &m_options); + rocksdb::GetOptionsFromString(options, get(keyValues, "options"), &options); if (!s.ok()) { Throw( @@ -216,10 +215,10 @@ public: } std::string s1, s2; - rocksdb::GetStringFromDBOptions(&s1, m_options, "; "); - rocksdb::GetStringFromColumnFamilyOptions(&s2, m_options, "; "); - JLOG(m_journal.debug()) << "RocksDB DBOptions: " << s1; - JLOG(m_journal.debug()) << "RocksDB CFOptions: " << s2; + rocksdb::GetStringFromDBOptions(&s1, options, "; "); + rocksdb::GetStringFromColumnFamilyOptions(&s2, options, "; "); + JLOG(journal.debug()) << "RocksDB DBOptions: " << s1; + JLOG(journal.debug()) << "RocksDB CFOptions: " << s2; } ~RocksDBBackend() override @@ -230,42 +229,42 @@ public: void open(bool createIfMissing) override { - if (m_db) + if (db) { // LCOV_EXCL_START UNREACHABLE( "xrpl::NodeStore::RocksDBBackend::open : database is already " "open"); - JLOG(m_journal.error()) << "database is already open"; + JLOG(journal.error()) << "database is already open"; return; // LCOV_EXCL_STOP } - rocksdb::DB* db = nullptr; - m_options.create_if_missing = createIfMissing; - rocksdb::Status const status = rocksdb::DB::Open(m_options, m_name, &db); - if (!status.ok() || (db == nullptr)) + rocksdb::DB* localDb = nullptr; + options.create_if_missing = createIfMissing; + rocksdb::Status const status = rocksdb::DB::Open(options, name, &localDb); + if (!status.ok() || (localDb == nullptr)) { Throw( std::string("Unable to open/create RocksDB: ") + status.ToString()); } - m_db.reset(db); + db.reset(localDb); } bool isOpen() override { - return static_cast(m_db); + return static_cast(db); } void close() override { - if (m_db) + if (db) { - m_db.reset(); - if (m_deletePath) + db.reset(); + if (deletePath_) { - boost::filesystem::path const dir = m_name; + boost::filesystem::path const dir = name; boost::filesystem::remove_all(dir); } } @@ -274,7 +273,7 @@ public: std::string getName() override { - return m_name; + return name; } //-------------------------------------------------------------------------- @@ -282,17 +281,17 @@ public: Status fetch(uint256 const& hash, std::shared_ptr* pObject) override { - XRPL_ASSERT(m_db, "xrpl::NodeStore::RocksDBBackend::fetch : non-null database"); + XRPL_ASSERT(db, "xrpl::NodeStore::RocksDBBackend::fetch : non-null database"); pObject->reset(); - Status status(Status::ok); + Status status = Status::Ok; rocksdb::ReadOptions const options; - rocksdb::Slice const slice(std::bit_cast(hash.data()), m_keyBytes); + rocksdb::Slice const slice(std::bit_cast(hash.data()), keyBytes); std::string string; - rocksdb::Status const getStatus = m_db->Get(options, slice, &string); + rocksdb::Status const getStatus = db->Get(options, slice, &string); if (getStatus.ok()) { @@ -306,25 +305,25 @@ public: { // Decoding failed, probably corrupted! // - status = Status::dataCorrupt; + status = Status::DataCorrupt; } } else { if (getStatus.IsCorruption()) { - status = Status::dataCorrupt; + status = Status::DataCorrupt; } else if (getStatus.IsNotFound()) { - status = Status::notFound; + status = Status::NotFound; } else { status = static_cast( - static_cast(Status::customCode) + unsafe_cast(getStatus.code())); + static_cast(Status::CustomCode) + unsafeCast(getStatus.code())); - JLOG(m_journal.error()) << getStatus.ToString(); + JLOG(journal.error()) << getStatus.ToString(); } } @@ -340,7 +339,7 @@ public: { std::shared_ptr nObj; Status const status = fetch(h, &nObj); - if (status != Status::ok) + if (status != Status::Ok) { results.push_back({}); } @@ -350,20 +349,20 @@ public: } } - return {results, Status::ok}; + return {results, Status::Ok}; } void store(std::shared_ptr const& object) override { - m_batch.store(object); + batch.store(object); } void storeBatch(Batch const& batch) override { XRPL_ASSERT( - m_db, + db, "xrpl::NodeStore::RocksDBBackend::storeBatch : non-null " "database"); rocksdb::WriteBatch wb; @@ -373,13 +372,13 @@ public: EncodedBlob const encoded(e); wb.Put( - rocksdb::Slice(std::bit_cast(encoded.getKey()), m_keyBytes), + rocksdb::Slice(std::bit_cast(encoded.getKey()), keyBytes), rocksdb::Slice(std::bit_cast(encoded.getData()), encoded.getSize())); } rocksdb::WriteOptions const options; - auto ret = m_db->Write(options, &wb); + auto ret = db->Write(options, &wb); if (!ret.ok()) Throw("storeBatch failed: " + ret.ToString()); @@ -391,16 +390,16 @@ public: } void - for_each(std::function)> f) override + forEach(std::function)> f) override { - XRPL_ASSERT(m_db, "xrpl::NodeStore::RocksDBBackend::for_each : non-null database"); + XRPL_ASSERT(db, "xrpl::NodeStore::RocksDBBackend::forEach : non-null database"); rocksdb::ReadOptions const options; - std::unique_ptr it(m_db->NewIterator(options)); + std::unique_ptr it(db->NewIterator(options)); for (it->SeekToFirst(); it->Valid(); it->Next()) { - if (it->key().size() == m_keyBytes) + if (it->key().size() == keyBytes) { DecodedBlob decoded(it->key().data(), it->value().data(), it->value().size()); @@ -411,14 +410,14 @@ public: else { // Uh oh, corrupted data! - JLOG(m_journal.fatal()) << "Corrupt NodeObject #" << it->key().ToString(true); + JLOG(journal.fatal()) << "Corrupt NodeObject #" << it->key().ToString(true); } } else { // VFALCO NOTE What does it mean to find an // incorrectly sized key? Corruption? - JLOG(m_journal.fatal()) << "Bad key size = " << it->key().size(); + JLOG(journal.fatal()) << "Bad key size = " << it->key().size(); } } } @@ -426,13 +425,13 @@ public: int getWriteLoad() override { - return m_batch.getWriteLoad(); + return batch.getWriteLoad(); } void setDeletePath() override { - m_deletePath = true; + deletePath_ = true; } //-------------------------------------------------------------------------- @@ -447,7 +446,7 @@ public: [[nodiscard]] int fdRequired() const override { - return fdRequired_; + return fdMinRequired; } }; @@ -459,7 +458,7 @@ private: Manager& manager_; public: - RocksDBEnv m_env; + RocksDBEnv env; RocksDBFactory(Manager& manager) : manager_(manager) { @@ -480,14 +479,14 @@ public: Scheduler& scheduler, beast::Journal journal) override { - return std::make_unique(keyBytes, keyValues, scheduler, journal, &m_env); + return std::make_unique(keyBytes, keyValues, scheduler, journal, &env); } }; void registerRocksDBFactory(Manager& manager) { - static RocksDBFactory const instance{manager}; + static RocksDBFactory const kINSTANCE{manager}; } } // namespace xrpl::NodeStore diff --git a/src/libxrpl/protocol/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp index 41303e6a22..b4c44f0f36 100644 --- a/src/libxrpl/protocol/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -29,7 +29,7 @@ Currency ammLPTCurrency(Asset const& asset1, Asset const& asset2) { // AMM LPToken is 0x03 plus 19 bytes of the hash - std::int32_t constexpr AMMCurrencyCode = 0x03; + std::int32_t constexpr kAMM_CURRENCY_CODE = 0x03; auto const& [minA, maxA] = std::minmax(asset1, asset2); uint256 const hash = std::visit( [](auto&& issue1, auto&& issue2) { @@ -44,7 +44,7 @@ ammLPTCurrency(Asset const& asset1, Asset const& asset2) minA.value(), maxA.value()); Currency currency; - *currency.begin() = AMMCurrencyCode; + *currency.begin() = kAMM_CURRENCY_CODE; std::copy(hash.begin(), hash.begin() + currency.size() - 1, currency.begin() + 1); return currency; } @@ -60,7 +60,7 @@ invalidAMMAsset(Asset const& asset, std::optional> const { auto const err = asset.visit( [](MPTIssue const& issue) -> std::optional { - if (issue.getIssuer() == beast::zero) + if (issue.getIssuer() == beast::kZERO) return temBAD_MPT; return std::nullopt; }, @@ -101,7 +101,7 @@ invalidAMMAmount( { if (auto const res = invalidAMMAsset(amount.asset(), pair)) return res; - if (amount < beast::zero || (!validZero && amount == beast::zero)) + if (amount < beast::kZERO || (!validZero && amount == beast::kZERO)) return temBAD_AMOUNT; return tesSUCCESS; } @@ -113,13 +113,13 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot) // but check just to be safe auto const expiration = auctionSlot[sfExpiration]; XRPL_ASSERT( - expiration >= TOTAL_TIME_SLOT_SECS, "xrpl::ammAuctionTimeSlot : minimum expiration"); - if (expiration >= TOTAL_TIME_SLOT_SECS) + expiration >= kTOTAL_TIME_SLOT_SECS, "xrpl::ammAuctionTimeSlot : minimum expiration"); + if (expiration >= kTOTAL_TIME_SLOT_SECS) { - if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; current >= start) + if (auto const start = expiration - kTOTAL_TIME_SLOT_SECS; current >= start) { - if (auto const diff = current - start; diff < TOTAL_TIME_SLOT_SECS) - return diff / AUCTION_SLOT_INTERVAL_DURATION; + if (auto const diff = current - start; diff < kTOTAL_TIME_SLOT_SECS) + return diff / kAUCTION_SLOT_INTERVAL_DURATION; } } return std::nullopt; diff --git a/src/libxrpl/protocol/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp index ffebde2c1a..6639835b41 100644 --- a/src/libxrpl/protocol/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -35,7 +35,7 @@ private: std::vector cache_; // We use a hash function designed to resist algorithmic complexity attacks - hardened_hash<> hasher_; + HardenedHash<> hasher_; // 64 spinlocks, packed into a single 64-bit value std::atomic locks_ = 0; @@ -53,7 +53,7 @@ public: { auto const index = hasher_(id) % cache_.size(); - packed_spinlock sl(locks_, index % 64); + PackedSpinlock sl(locks_, index % 64); { std::scoped_lock const lock(sl); @@ -80,20 +80,20 @@ public: } // namespace detail -static std::unique_ptr accountIdCache; +static std::unique_ptr gAccountIdCache; void initAccountIdCache(std::size_t count) { - if (!accountIdCache && count != 0) - accountIdCache = std::make_unique(count); + if (!gAccountIdCache && count != 0) + gAccountIdCache = std::make_unique(count); } std::string toBase58(AccountID const& v) { - if (accountIdCache) - return accountIdCache->toBase58(v); + if (gAccountIdCache) + return gAccountIdCache->toBase58(v); return encodeBase58Token(TokenType::AccountID, v.data(), v.size()); } @@ -103,7 +103,7 @@ std::optional parseBase58(std::string const& s) { auto const result = decodeBase58Token(s, TokenType::AccountID); - if (result.size() != AccountID::bytes) + if (result.size() != AccountID::kBYTES) return std::nullopt; return AccountID{result}; } @@ -146,29 +146,29 @@ parseBase58(std::string const& s) AccountID calcAccountID(PublicKey const& pk) { - static_assert(AccountID::bytes == sizeof(ripesha_hasher::result_type)); + static_assert(AccountID::kBYTES == sizeof(RipeshaHasher::result_type)); - ripesha_hasher rsh; + RipeshaHasher rsh; rsh(pk.data(), pk.size()); - return AccountID{static_cast(rsh)}; + return AccountID{static_cast(rsh)}; } AccountID const& xrpAccount() { - static AccountID const account(beast::zero); - return account; + static AccountID const kACCOUNT(beast::kZERO); + return kACCOUNT; } AccountID const& noAccount() { - static AccountID const account(1); - return account; + static AccountID const kACCOUNT(1); + return kACCOUNT; } bool -to_issuer(AccountID& issuer, std::string const& s) +toIssuer(AccountID& issuer, std::string const& s) { if (issuer.parseHex(s)) return true; diff --git a/src/libxrpl/protocol/Asset.cpp b/src/libxrpl/protocol/Asset.cpp index 3d163c5c6a..57843ea6bf 100644 --- a/src/libxrpl/protocol/Asset.cpp +++ b/src/libxrpl/protocol/Asset.cpp @@ -30,7 +30,7 @@ Asset::getText() const } void -Asset::setJson(Json::Value& jv) const +Asset::setJson(json::Value& jv) const { std::visit([&](auto&& issue) { issue.setJson(jv); }, issue_); } @@ -48,7 +48,7 @@ to_string(Asset const& asset) } bool -validJSONAsset(Json::Value const& jv) +validJSONAsset(json::Value const& jv) { if (jv.isMember(jss::mpt_issuance_id)) return !(jv.isMember(jss::currency) || jv.isMember(jss::issuer)); @@ -56,7 +56,7 @@ validJSONAsset(Json::Value const& jv) } Asset -assetFromJson(Json::Value const& v) +assetFromJson(json::Value const& v) { if (!v.isMember(jss::currency) && !v.isMember(jss::mpt_issuance_id)) Throw("assetFromJson must contain currency or mpt_issuance_id"); diff --git a/src/libxrpl/protocol/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp index c732e95a87..7ea934fe3a 100644 --- a/src/libxrpl/protocol/BuildInfo.cpp +++ b/src/libxrpl/protocol/BuildInfo.cpp @@ -22,6 +22,7 @@ namespace { // and follow the format described at http://semver.org/ //------------------------------------------------------------------------------ // clang-format off +// NOLINTNEXTLINE(readability-identifier-naming) char const* const versionString = "3.2.0-b0" // clang-format on ; @@ -66,31 +67,31 @@ buildVersionString() std::string const& getVersionString() { - static std::string const value = [] { + static std::string const kVALUE = [] { std::string const s = buildVersionString(); beast::SemanticVersion v; if (!v.parse(s) || v.print() != s) - LogicError(s + ": Bad server version string"); + logicError(s + ": Bad server version string"); return s; }(); - return value; + return kVALUE; } std::string const& getFullVersionString() { - static std::string const value = systemName() + "-" + getVersionString(); - return value; + static std::string const kVALUE = systemName() + "-" + getVersionString(); + return kVALUE; } -static constexpr std::uint64_t implementationVersionIdentifier = 0x183B'0000'0000'0000LLU; -static constexpr std::uint64_t implementationVersionIdentifierMask = 0xFFFF'0000'0000'0000LLU; +static constexpr std::uint64_t kIMPLEMENTATION_VERSION_IDENTIFIER = 0x183B'0000'0000'0000LLU; +static constexpr std::uint64_t kIMPLEMENTATION_VERSION_IDENTIFIER_MASK = 0xFFFF'0000'0000'0000LLU; std::uint64_t encodeSoftwareVersion(std::string_view versionStr) { - std::uint64_t c = implementationVersionIdentifier; + std::uint64_t c = kIMPLEMENTATION_VERSION_IDENTIFIER; beast::SemanticVersion v; @@ -154,14 +155,15 @@ encodeSoftwareVersion(std::string_view versionStr) std::uint64_t getEncodedVersion() { - static std::uint64_t const cookie = {encodeSoftwareVersion(getVersionString())}; - return cookie; + static std::uint64_t const kCOOKIE = {encodeSoftwareVersion(getVersionString())}; + return kCOOKIE; } bool isXrpldVersion(std::uint64_t version) { - return (version & implementationVersionIdentifierMask) == implementationVersionIdentifier; + return (version & kIMPLEMENTATION_VERSION_IDENTIFIER_MASK) == + kIMPLEMENTATION_VERSION_IDENTIFIER; } bool diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 4e928deb75..a51bb9b56d 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -30,78 +30,78 @@ namespace detail { // status code. // clang-format off -constexpr static ErrorInfo unorderedErrorInfos[]{ - {rpcACT_MALFORMED, "actMalformed", "Account malformed."}, - {rpcACT_NOT_FOUND, "actNotFound", "Account not found."}, - {rpcALREADY_MULTISIG, "alreadyMultisig", "Already multisigned."}, - {rpcALREADY_SINGLE_SIG, "alreadySingleSig", "Already single-signed."}, - {rpcAMENDMENT_BLOCKED, "amendmentBlocked", "Amendment blocked, need upgrade.", 503}, - {rpcEXPIRED_VALIDATOR_LIST, "unlBlocked", "Validator list expired.", 503}, - {rpcATX_DEPRECATED, "deprecated", "Use the new API or specify a ledger range.", 400}, - {rpcBAD_KEY_TYPE, "badKeyType", "Bad key type.", 400}, - {rpcBAD_FEATURE, "badFeature", "Feature unknown or invalid.", 500}, - {rpcBAD_ISSUER, "badIssuer", "Issuer account malformed.", 400}, - {rpcBAD_MARKET, "badMarket", "No such market.", 404}, - {rpcBAD_SECRET, "badSecret", "Secret does not match account.", 403}, - {rpcBAD_SEED, "badSeed", "Disallowed seed.", 403}, - {rpcBAD_SYNTAX, "badSyntax", "Syntax error.", 400}, - {rpcCHANNEL_MALFORMED, "channelMalformed", "Payment channel is malformed.", 400}, - {rpcCHANNEL_AMT_MALFORMED, "channelAmtMalformed", "Payment channel amount is malformed.", 400}, - {rpcCOMMAND_MISSING, "commandMissing", "Missing command entry.", 400}, - {rpcDB_DESERIALIZATION, "dbDeserialization", "Database deserialization error.", 502}, - {rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed.", 400}, - {rpcDST_ACT_MISSING, "dstActMissing", "Destination account not provided.", 400}, - {rpcDST_ACT_NOT_FOUND, "dstActNotFound", "Destination account not found.", 404}, - {rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency/issuer is malformed.", 400}, - {rpcDST_AMT_MISSING, "dstAmtMissing", "Destination amount/currency/issuer is missing.", 400}, - {rpcDST_ISR_MALFORMED, "dstIsrMalformed", "Destination issuer is malformed.", 400}, - {rpcEXCESSIVE_LGR_RANGE, "excessiveLgrRange", "Ledger range exceeds 1000.", 400}, - {rpcFORBIDDEN, "forbidden", "Bad credentials.", 403}, - {rpcHIGH_FEE, "highFee", "Current transaction fee exceeds your limit.", 402}, - {rpcINTERNAL, "internal", "Internal error.", 500}, - {rpcINVALID_LGR_RANGE, "invalidLgrRange", "Ledger range is invalid.", 400}, - {rpcINVALID_PARAMS, "invalidParams", "Invalid parameters.", 400}, - {rpcINVALID_HOTWALLET, "invalidHotWallet", "Invalid hotwallet.", 400}, - {rpcISSUE_MALFORMED, "issueMalformed", "Issue is malformed.", 400}, - {rpcJSON_RPC, "json_rpc", "JSON-RPC transport error.", 500}, - {rpcLGR_IDXS_INVALID, "lgrIdxsInvalid", "Ledger indexes invalid.", 400}, - {rpcLGR_IDX_MALFORMED, "lgrIdxMalformed", "Ledger index malformed.", 400}, - {rpcLGR_NOT_FOUND, "lgrNotFound", "Ledger not found.", 404}, - {rpcLGR_NOT_VALIDATED, "lgrNotValidated", "Ledger not validated.", 202}, - {rpcMASTER_DISABLED, "masterDisabled", "Master key is disabled.", 403}, - {rpcNOT_ENABLED, "notEnabled", "Not enabled in configuration.", 501}, - {rpcNOT_IMPL, "notImpl", "Not implemented.", 501}, - {rpcNOT_READY, "notReady", "Not ready to handle this request.", 503}, - {rpcNOT_SUPPORTED, "notSupported", "Operation not supported.", 501}, - {rpcNO_CLOSED, "noClosed", "Closed ledger is unavailable.", 503}, - {rpcNO_CURRENT, "noCurrent", "Current ledger is unavailable.", 503}, - {rpcNOT_SYNCED, "notSynced", "Not synced to the network.", 503}, - {rpcNO_EVENTS, "noEvents", "Current transport does not support events.", 405}, - {rpcNO_NETWORK, "noNetwork", "Not synced to the network.", 503}, - {rpcWRONG_NETWORK, "wrongNetwork", "Wrong network.", 503}, - {rpcNO_PERMISSION, "noPermission", "You don't have permission for this command.", 401}, - {rpcNO_PF_REQUEST, "noPathRequest", "No pathfinding request in progress.", 404}, - {rpcOBJECT_NOT_FOUND, "objectNotFound", "The requested object was not found.", 404}, - {rpcPUBLIC_MALFORMED, "publicMalformed", "Public key is malformed.", 400}, - {rpcSENDMAX_MALFORMED, "sendMaxMalformed", "SendMax amount malformed.", 400}, - {rpcSIGNING_MALFORMED, "signingMalformed", "Signing of transaction is malformed.", 400}, - {rpcSLOW_DOWN, "slowDown", "You are placing too much load on the server.", 429}, - {rpcSRC_ACT_MALFORMED, "srcActMalformed", "Source account is malformed.", 400}, - {rpcSRC_ACT_MISSING, "srcActMissing", "Source account not provided.", 400}, - {rpcSRC_ACT_NOT_FOUND, "srcActNotFound", "Source account not found.", 404}, - {rpcDELEGATE_ACT_NOT_FOUND, "delegateActNotFound", "Delegate account not found.", 404}, - {rpcSRC_CUR_MALFORMED, "srcCurMalformed", "Source currency is malformed.", 400}, - {rpcSRC_ISR_MALFORMED, "srcIsrMalformed", "Source issuer is malformed.", 400}, - {rpcSTREAM_MALFORMED, "malformedStream", "Stream malformed.", 400}, - {rpcTOO_BUSY, "tooBusy", "The server is too busy to help you now.", 503}, - {rpcTXN_NOT_FOUND, "txnNotFound", "Transaction not found.", 404}, - {rpcUNKNOWN_COMMAND, "unknownCmd", "Unknown method.", 405}, - {rpcORACLE_MALFORMED, "oracleMalformed", "Oracle request is malformed.", 400}, - {rpcBAD_CREDENTIALS, "badCredentials", "Credentials do not exist, are not accepted, or have expired.", 400}, - {rpcTX_SIGNED, "transactionSigned", "Transaction should not be signed.", 400}, - {rpcDOMAIN_MALFORMED, "domainMalformed", "Domain is malformed.", 400}, - {rpcENTRY_NOT_FOUND, "entryNotFound", "Entry not found.", 400}, - {rpcUNEXPECTED_LEDGER_TYPE, "unexpectedLedgerType", "Unexpected ledger type.", 400}, +constexpr static ErrorInfo kUNORDERED_ERROR_INFOS[]{ + {RpcActMalformed, "actMalformed", "Account malformed."}, + {RpcActNotFound, "actNotFound", "Account not found."}, + {RpcAlreadyMultisig, "alreadyMultisig", "Already multisigned."}, + {RpcAlreadySingleSig, "alreadySingleSig", "Already single-signed."}, + {RpcAmendmentBlocked, "amendmentBlocked", "Amendment blocked, need upgrade.", 503}, + {RpcExpiredValidatorList, "unlBlocked", "Validator list expired.", 503}, + {RpcAtxDeprecated, "deprecated", "Use the new API or specify a ledger range.", 400}, + {RpcBadKeyType, "badKeyType", "Bad key type.", 400}, + {RpcBadFeature, "badFeature", "Feature unknown or invalid.", 500}, + {RpcBadIssuer, "badIssuer", "Issuer account malformed.", 400}, + {RpcBadMarket, "badMarket", "No such market.", 404}, + {RpcBadSecret, "badSecret", "Secret does not match account.", 403}, + {RpcBadSeed, "badSeed", "Disallowed seed.", 403}, + {RpcBadSyntax, "badSyntax", "Syntax error.", 400}, + {RpcChannelMalformed, "channelMalformed", "Payment channel is malformed.", 400}, + {RpcChannelAmtMalformed, "channelAmtMalformed", "Payment channel amount is malformed.", 400}, + {RpcCommandMissing, "commandMissing", "Missing command entry.", 400}, + {RpcDbDeserialization, "dbDeserialization", "Database deserialization error.", 502}, + {RpcDstActMalformed, "dstActMalformed", "Destination account is malformed.", 400}, + {RpcDstActMissing, "dstActMissing", "Destination account not provided.", 400}, + {RpcDstActNotFound, "dstActNotFound", "Destination account not found.", 404}, + {RpcDstAmtMalformed, "dstAmtMalformed", "Destination amount/currency/issuer is malformed.", 400}, + {RpcDstAmtMissing, "dstAmtMissing", "Destination amount/currency/issuer is missing.", 400}, + {RpcDstIsrMalformed, "dstIsrMalformed", "Destination issuer is malformed.", 400}, + {RpcExcessiveLgrRange, "excessiveLgrRange", "Ledger range exceeds 1000.", 400}, + {RpcForbidden, "forbidden", "Bad credentials.", 403}, + {RpcHighFee, "highFee", "Current transaction fee exceeds your limit.", 402}, + {RpcInternal, "internal", "Internal error.", 500}, + {RpcInvalidLgrRange, "invalidLgrRange", "Ledger range is invalid.", 400}, + {RpcInvalidParams, "invalidParams", "Invalid parameters.", 400}, + {RpcInvalidHotwallet, "invalidHotWallet", "Invalid hotwallet.", 400}, + {RpcIssueMalformed, "issueMalformed", "Issue is malformed.", 400}, + {RpcJsonRpc, "json_rpc", "JSON-RPC transport error.", 500}, + {RpcLgrIdxsInvalid, "lgrIdxsInvalid", "Ledger indexes invalid.", 400}, + {RpcLgrIdxMalformed, "lgrIdxMalformed", "Ledger index malformed.", 400}, + {RpcLgrNotFound, "lgrNotFound", "Ledger not found.", 404}, + {RpcLgrNotValidated, "lgrNotValidated", "Ledger not validated.", 202}, + {RpcMasterDisabled, "masterDisabled", "Master key is disabled.", 403}, + {RpcNotEnabled, "notEnabled", "Not enabled in configuration.", 501}, + {RpcNotImpl, "notImpl", "Not implemented.", 501}, + {RpcNotReady, "notReady", "Not ready to handle this request.", 503}, + {RpcNotSupported, "notSupported", "Operation not supported.", 501}, + {RpcNoClosed, "noClosed", "Closed ledger is unavailable.", 503}, + {RpcNoCurrent, "noCurrent", "Current ledger is unavailable.", 503}, + {RpcNotSynced, "notSynced", "Not synced to the network.", 503}, + {RpcNoEvents, "noEvents", "Current transport does not support events.", 405}, + {RpcNoNetwork, "noNetwork", "Not synced to the network.", 503}, + {RpcWrongNetwork, "wrongNetwork", "Wrong network.", 503}, + {RpcNoPermission, "noPermission", "You don't have permission for this command.", 401}, + {RpcNoPfRequest, "noPathRequest", "No pathfinding request in progress.", 404}, + {RpcObjectNotFound, "objectNotFound", "The requested object was not found.", 404}, + {RpcPublicMalformed, "publicMalformed", "Public key is malformed.", 400}, + {RpcSendmaxMalformed, "sendMaxMalformed", "SendMax amount malformed.", 400}, + {RpcSigningMalformed, "signingMalformed", "Signing of transaction is malformed.", 400}, + {RpcSlowDown, "slowDown", "You are placing too much load on the server.", 429}, + {RpcSrcActMalformed, "srcActMalformed", "Source account is malformed.", 400}, + {RpcSrcActMissing, "srcActMissing", "Source account not provided.", 400}, + {RpcSrcActNotFound, "srcActNotFound", "Source account not found.", 404}, + {RpcDelegateActNotFound, "delegateActNotFound", "Delegate account not found.", 404}, + {RpcSrcCurMalformed, "srcCurMalformed", "Source currency is malformed.", 400}, + {RpcSrcIsrMalformed, "srcIsrMalformed", "Source issuer is malformed.", 400}, + {RpcStreamMalformed, "malformedStream", "Stream malformed.", 400}, + {RpcTooBusy, "tooBusy", "The server is too busy to help you now.", 503}, + {RpcTxnNotFound, "txnNotFound", "Transaction not found.", 404}, + {RpcUnknownCommand, "unknownCmd", "Unknown method.", 405}, + {RpcOracleMalformed, "oracleMalformed", "Oracle request is malformed.", 400}, + {RpcBadCredentials, "badCredentials", "Credentials do not exist, are not accepted, or have expired.", 400}, + {RpcTxSigned, "transactionSigned", "Transaction should not be signed.", 400}, + {RpcDomainMalformed, "domainMalformed", "Domain is malformed.", 400}, + {RpcEntryNotFound, "entryNotFound", "Entry not found.", 400}, + {RpcUnexpectedLedgerType, "unexpectedLedgerType", "Unexpected ledger type.", 400}, }; // clang-format on @@ -115,14 +115,14 @@ sortErrorInfos(ErrorInfo const (&unordered)[N]) -> std::array for (ErrorInfo const& info : unordered) { - if (info.code <= rpcSUCCESS || info.code > rpcLAST) + if (info.code <= RpcSuccess || info.code > RpcLast) throw(std::out_of_range("Invalid error_code_i")); // The first valid code follows rpcSUCCESS immediately. - static_assert(rpcSUCCESS == 0, "Unexpected error_code_i layout."); + static_assert(RpcSuccess == 0, "Unexpected error_code_i layout."); int const index{info.code - 1}; - if (ret[index].code != rpcUNKNOWN) + if (ret[index].code != RpcUnknown) throw(std::invalid_argument("Duplicate error_code_i in list")); ret[index] = info; @@ -134,18 +134,18 @@ sortErrorInfos(ErrorInfo const (&unordered)[N]) -> std::array // It's okay for there to be missing entries; they will contain the code // rpcUNKNOWN. But other than that all entries should match their index. int codeCount{0}; - int expect{rpcBAD_SYNTAX - 1}; + int expect{RpcBadSyntax - 1}; for (ErrorInfo const& info : ret) { ++expect; - if (info.code == rpcUNKNOWN) + if (info.code == RpcUnknown) continue; if (info.code != expect) throw(std::invalid_argument("Empty error_code_i in list")); ++codeCount; } - if (expect != rpcLAST) + if (expect != RpcLast) throw(std::invalid_argument("Insufficient list entries")); if (codeCount != N) throw(std::invalid_argument("Bad handling of unorderedErrorInfos")); @@ -153,74 +153,74 @@ sortErrorInfos(ErrorInfo const (&unordered)[N]) -> std::array return ret; } -constexpr auto sortedErrorInfos{sortErrorInfos(unorderedErrorInfos)}; +constexpr auto kSORTED_ERROR_INFOS{sortErrorInfos(kUNORDERED_ERROR_INFOS)}; -constexpr ErrorInfo unknownError; +constexpr ErrorInfo kUNKNOWN_ERROR; } // namespace detail //------------------------------------------------------------------------------ void -inject_error(error_code_i code, Json::Value& json) +injectError(ErrorCodeI code, json::Value& json) { - ErrorInfo const& info(get_error_info(code)); + ErrorInfo const& info(getErrorInfo(code)); json[jss::error] = info.token; json[jss::error_code] = info.code; json[jss::error_message] = info.message; } void -inject_error(error_code_i code, std::string const& message, Json::Value& json) +injectError(ErrorCodeI code, std::string const& message, json::Value& json) { - ErrorInfo const& info(get_error_info(code)); + ErrorInfo const& info(getErrorInfo(code)); json[jss::error] = info.token; json[jss::error_code] = info.code; json[jss::error_message] = message; } ErrorInfo const& -get_error_info(error_code_i code) +getErrorInfo(ErrorCodeI code) { - if (code <= rpcSUCCESS || code > rpcLAST) - return detail::unknownError; - return detail::sortedErrorInfos[code - 1]; + if (code <= RpcSuccess || code > RpcLast) + return detail::kUNKNOWN_ERROR; + return detail::kSORTED_ERROR_INFOS[code - 1]; } -Json::Value -make_error(error_code_i code) +json::Value +makeError(ErrorCodeI code) { - Json::Value json; - inject_error(code, json); + json::Value json; + injectError(code, json); return json; } -Json::Value -make_error(error_code_i code, std::string const& message) +json::Value +makeError(ErrorCodeI code, std::string const& message) { - Json::Value json; - inject_error(code, message, json); + json::Value json; + injectError(code, message, json); return json; } bool -contains_error(Json::Value const& json) +containsError(json::Value const& json) { return json.isObject() && json.isMember(jss::error); } int -error_code_http_status(error_code_i code) +errorCodeHttpStatus(ErrorCodeI code) { - return get_error_info(code).http_status; + return getErrorInfo(code).http_status; } } // namespace RPC std::string -rpcErrorString(Json::Value const& jv) +rpcErrorString(json::Value const& jv) { - XRPL_ASSERT(RPC::contains_error(jv), "xrpl::RPC::rpcErrorString : input contains an error"); + XRPL_ASSERT(RPC::containsError(jv), "xrpl::RPC::rpcErrorString : input contains an error"); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 1686d0e52a..3862b52e27 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -23,6 +23,7 @@ namespace xrpl { inline std::size_t +// NOLINTNEXTLINE(readability-identifier-naming) hash_value(xrpl::uint256 const& feature) { std::size_t seed = 0; @@ -34,7 +35,7 @@ hash_value(xrpl::uint256 const& feature) namespace { -enum class Supported : bool { no = false, yes }; +enum class Supported : bool { No = false, Yes }; // *NOTE* // @@ -71,45 +72,45 @@ class FeatureCollections uint256 feature; Feature() = delete; - explicit Feature(std::string name_, uint256 const& feature_) - : name(std::move(name_)), feature(feature_) + explicit Feature(std::string name, uint256 const& feature) + : name(std::move(name)), feature(feature) { } // These structs are used by the `features` multi_index_container to // provide access to the features collection by size_t index, string // name, and uint256 feature identifier - struct byIndex + struct ByIndex { }; - struct byName + struct ByName { }; - struct byFeature + struct ByFeature { }; }; // Intermediate types to help with readability - template + template using feature_hashed_unique = boost::multi_index::hashed_unique< - boost::multi_index::tag, + boost::multi_index::tag, boost::multi_index::member>; // Intermediate types to help with readability using feature_indexing = boost::multi_index::indexed_by< - boost::multi_index::random_access>, - feature_hashed_unique, - feature_hashed_unique>; + boost::multi_index::random_access>, + feature_hashed_unique, + feature_hashed_unique>; // This multi_index_container provides access to the features collection by // name, index, and uint256 feature identifier - boost::multi_index::multi_index_container features; - std::map all; - std::map supported; - std::size_t upVotes = 0; - std::size_t downVotes = 0; - mutable std::atomic readOnly = false; + boost::multi_index::multi_index_container features_; + std::map all_; + std::map supported_; + std::size_t upVotes_ = 0; + std::size_t downVotes_ = 0; + mutable std::atomic readOnly_ = false; // These helper functions provide access to the features collection by name, // index, and uint256 feature identifier, so the details of @@ -117,31 +118,31 @@ class FeatureCollections Feature const& getByIndex(size_t i) const { - if (i >= features.size()) - LogicError("Invalid FeatureBitset index"); - auto const& sequence = features.get(); + if (i >= features_.size()) + logicError("Invalid FeatureBitset index"); + auto const& sequence = features_.get(); return sequence[i]; } size_t getIndex(Feature const& feature) const { - auto const& sequence = features.get(); - auto const it_to = sequence.iterator_to(feature); - return it_to - sequence.begin(); + auto const& sequence = features_.get(); + auto const itTo = sequence.iterator_to(feature); + return itTo - sequence.begin(); } Feature const* getByFeature(uint256 const& feature) const { - auto const& feature_index = features.get(); - auto const feature_it = feature_index.find(feature); - return feature_it == feature_index.end() ? nullptr : &*feature_it; + auto const& featureIndex = features_.get(); + auto const featureIt = featureIndex.find(feature); + return featureIt == featureIndex.end() ? nullptr : &*featureIt; } Feature const* getByName(std::string const& name) const { - auto const& name_index = features.get(); - auto const name_it = name_index.find(name); - return name_it == name_index.end() ? nullptr : &*name_it; + auto const& nameIndex = features_.get(); + auto const nameIt = nameIndex.find(name); + return nameIt == nameIndex.end() ? nullptr : &*nameIt; } public: @@ -170,7 +171,7 @@ public: std::map const& allAmendments() const { - return all; + return all_; } /** Amendments that this server supports. @@ -179,21 +180,21 @@ public: std::map const& supportedAmendments() const { - return supported; + return supported_; } /** Amendments that this server WON'T vote for by default. */ std::size_t numDownVotedAmendments() const { - return downVotes; + return downVotes_; } /** Amendments that this server WILL vote for by default. */ std::size_t numUpVotedAmendments() const { - return upVotes; + return upVotes_; } }; @@ -201,14 +202,14 @@ public: FeatureCollections::FeatureCollections() { - features.reserve(xrpl::detail::numFeatures); + features_.reserve(xrpl::detail::kNUM_FEATURES); } std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { XRPL_ASSERT( - readOnly.load(), "xrpl::FeatureCollections::getRegisteredFeature : startup completed"); + readOnly_.load(), "xrpl::FeatureCollections::getRegisteredFeature : startup completed"); Feature const* feature = getByName(name); if (feature != nullptr) return feature->feature; @@ -219,61 +220,62 @@ void check(bool condition, char const* logicErrorMessage) { if (!condition) - LogicError(logicErrorMessage); + logicError(logicErrorMessage); } uint256 FeatureCollections::registerFeature(std::string const& name, Supported support, VoteBehavior vote) { - check(!readOnly, "Attempting to register a feature after startup."); + check(!readOnly_, "Attempting to register a feature after startup."); check( - support == Supported::yes || vote == VoteBehavior::DefaultNo, + support == Supported::Yes || vote == VoteBehavior::DefaultNo, "Invalid feature parameters. Must be supported to be up-voted."); Feature const* i = getByName(name); if (i == nullptr) { - check(features.size() < detail::numFeatures, "More features defined than allocated."); + check(features_.size() < detail::kNUM_FEATURES, "More features defined than allocated."); auto const f = sha512Half(Slice(name.data(), name.size())); - features.emplace_back(name, f); + features_.emplace_back(name, f); auto const getAmendmentSupport = [=]() { if (vote == VoteBehavior::Obsolete) return AmendmentSupport::Retired; - return support == Supported::yes ? AmendmentSupport::Supported + return support == Supported::Yes ? AmendmentSupport::Supported : AmendmentSupport::Unsupported; }; - all.emplace(name, getAmendmentSupport()); + all_.emplace(name, getAmendmentSupport()); - if (support == Supported::yes) + if (support == Supported::Yes) { - supported.emplace(name, vote); + supported_.emplace(name, vote); if (vote == VoteBehavior::DefaultYes) { - ++upVotes; + ++upVotes_; } else { - ++downVotes; + ++downVotes_; } } - check(upVotes + downVotes == supported.size(), "Feature counting logic broke"); - check(supported.size() <= features.size(), "More supported features than defined features"); - check(features.size() == all.size(), "The 'all' features list is populated incorrectly"); + check(upVotes_ + downVotes_ == supported_.size(), "Feature counting logic broke"); + check( + supported_.size() <= features_.size(), "More supported features than defined features"); + check(features_.size() == all_.size(), "The 'all' features list is populated incorrectly"); return f; } // Each feature should only be registered once - LogicError("Duplicate feature registration"); + logicError("Duplicate feature registration"); } /** Tell FeatureCollections when registration is complete. */ bool FeatureCollections::registrationIsDone() { - readOnly = true; + readOnly_ = true; return true; } @@ -281,11 +283,11 @@ size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { XRPL_ASSERT( - readOnly.load(), "xrpl::FeatureCollections::featureToBitsetIndex : startup completed"); + readOnly_.load(), "xrpl::FeatureCollections::featureToBitsetIndex : startup completed"); Feature const* feature = getByFeature(f); if (feature == nullptr) - LogicError("Invalid Feature ID"); + logicError("Invalid Feature ID"); return getIndex(*feature); } @@ -294,7 +296,7 @@ uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { XRPL_ASSERT( - readOnly.load(), "xrpl::FeatureCollections::bitsetIndexToFeature : startup completed"); + readOnly_.load(), "xrpl::FeatureCollections::bitsetIndexToFeature : startup completed"); Feature const& feature = getByIndex(i); return feature.feature; } @@ -302,12 +304,12 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - XRPL_ASSERT(readOnly.load(), "xrpl::FeatureCollections::featureToName : startup completed"); + XRPL_ASSERT(readOnly_.load(), "xrpl::FeatureCollections::featureToName : startup completed"); Feature const* feature = getByFeature(f); return (feature != nullptr) ? feature->name : to_string(f); } -FeatureCollections featureCollections; +FeatureCollections gFeatureCollections; } // namespace @@ -315,7 +317,7 @@ FeatureCollections featureCollections; std::map const& allAmendments() { - return featureCollections.allAmendments(); + return gFeatureCollections.allAmendments(); } /** Amendments that this server supports. @@ -324,21 +326,21 @@ allAmendments() std::map const& detail::supportedAmendments() { - return featureCollections.supportedAmendments(); + return gFeatureCollections.supportedAmendments(); } /** Amendments that this server won't vote for by default. */ std::size_t detail::numDownVotedAmendments() { - return featureCollections.numDownVotedAmendments(); + return gFeatureCollections.numDownVotedAmendments(); } /** Amendments that this server will vote for by default. */ std::size_t detail::numUpVotedAmendments() { - return featureCollections.numUpVotedAmendments(); + return gFeatureCollections.numUpVotedAmendments(); } //------------------------------------------------------------------------------ @@ -346,13 +348,13 @@ detail::numUpVotedAmendments() std::optional getRegisteredFeature(std::string const& name) { - return featureCollections.getRegisteredFeature(name); + return gFeatureCollections.getRegisteredFeature(name); } uint256 registerFeature(std::string const& name, Supported support, VoteBehavior vote) { - return featureCollections.registerFeature(name, support, vote); + return gFeatureCollections.registerFeature(name, support, vote); } // Retired features are in the ledger and have no code controlled by the @@ -360,32 +362,32 @@ registerFeature(std::string const& name, Supported support, VoteBehavior vote) uint256 retireFeature(std::string const& name) { - return registerFeature(name, Supported::yes, VoteBehavior::Obsolete); + return registerFeature(name, Supported::Yes, VoteBehavior::Obsolete); } /** Tell FeatureCollections when registration is complete. */ bool registrationIsDone() { - return featureCollections.registrationIsDone(); + return gFeatureCollections.registrationIsDone(); } size_t featureToBitsetIndex(uint256 const& f) { - return featureCollections.featureToBitsetIndex(f); + return gFeatureCollections.featureToBitsetIndex(f); } uint256 bitsetIndexToFeature(size_t i) { - return featureCollections.bitsetIndexToFeature(i); + return gFeatureCollections.bitsetIndexToFeature(i); } std::string featureToName(uint256 const& f) { - return featureCollections.featureToName(f); + return gFeatureCollections.featureToName(f); } // All known amendments must be registered either here or below with the @@ -443,8 +445,7 @@ enforceValidFeatureName(auto fn) -> char const* // All of the features should now be registered, since variables in a cpp file // are initialized from top to bottom. // -// Use initialization of one final static variable to set -// featureCollections::readOnly. -[[maybe_unused]] static bool const readOnlySet = featureCollections.registrationIsDone(); +// Use initialization of one final static variable to set featureCollections::readOnly_. +[[maybe_unused]] static bool const kREAD_ONLY_SET = gFeatureCollections.registrationIsDone(); } // namespace xrpl diff --git a/src/libxrpl/protocol/IOUAmount.cpp b/src/libxrpl/protocol/IOUAmount.cpp index 69b763dbab..e4326d611e 100644 --- a/src/libxrpl/protocol/IOUAmount.cpp +++ b/src/libxrpl/protocol/IOUAmount.cpp @@ -23,8 +23,8 @@ namespace { LocalValue& getStaticSTNumberSwitchover() { - static LocalValue r{true}; - return r; + static LocalValue kR{true}; + return kR; } } // namespace @@ -43,11 +43,11 @@ setSTNumberSwitchover(bool v) /* The range for the mantissa when normalized */ // log(2^63,10) ~ 18.96 // -static std::int64_t constexpr minMantissa = STAmount::cMinValue; -static std::int64_t constexpr maxMantissa = STAmount::cMaxValue; +static std::int64_t constexpr kMIN_MANTISSA = STAmount::kMIN_VALUE; +static std::int64_t constexpr kMAX_MANTISSA = STAmount::kMAX_VALUE; /* The range for the exponent when normalized */ -static int constexpr minExponent = STAmount::cMinOffset; -static int constexpr maxExponent = STAmount::cMaxOffset; +static int constexpr kMIN_EXPONENT = STAmount::kMIN_OFFSET; +static int constexpr kMAX_EXPONENT = STAmount::kMAX_OFFSET; IOUAmount IOUAmount::fromNumber(Number const& number) @@ -56,14 +56,14 @@ IOUAmount::fromNumber(Number const& number) // to normalize, which calls fromNumber IOUAmount result{}; std::tie(result.mantissa_, result.exponent_) = - number.normalizeToRange(minMantissa, maxMantissa); + number.normalizeToRange(kMIN_MANTISSA, kMAX_MANTISSA); return result; } IOUAmount IOUAmount::minPositiveAmount() { - return IOUAmount(minMantissa, minExponent); + return IOUAmount(kMIN_MANTISSA, kMIN_EXPONENT); } void @@ -71,7 +71,7 @@ IOUAmount::normalize() { if (mantissa_ == 0) { - *this = beast::zero; + *this = beast::kZERO; return; } @@ -79,10 +79,10 @@ IOUAmount::normalize() { Number const v{mantissa_, exponent_}; *this = fromNumber(v); - if (exponent_ > maxExponent) + if (exponent_ > kMAX_EXPONENT) Throw("value overflow"); - if (exponent_ < minExponent) - *this = beast::zero; + if (exponent_ < kMIN_EXPONENT) + *this = beast::kZERO; return; } @@ -91,28 +91,28 @@ IOUAmount::normalize() if (negative) mantissa_ = -mantissa_; - while ((mantissa_ < minMantissa) && (exponent_ > minExponent)) + while ((mantissa_ < kMIN_MANTISSA) && (exponent_ > kMIN_EXPONENT)) { mantissa_ *= 10; --exponent_; } - while (mantissa_ > maxMantissa) + while (mantissa_ > kMAX_MANTISSA) { - if (exponent_ >= maxExponent) + if (exponent_ >= kMAX_EXPONENT) Throw("IOUAmount::normalize"); mantissa_ /= 10; ++exponent_; } - if ((exponent_ < minExponent) || (mantissa_ < minMantissa)) + if ((exponent_ < kMIN_EXPONENT) || (mantissa_ < kMIN_MANTISSA)) { - *this = beast::zero; + *this = beast::kZERO; return; } - if (exponent_ > maxExponent) + if (exponent_ > kMAX_EXPONENT) Throw("value overflow"); if (negative) @@ -121,19 +121,19 @@ IOUAmount::normalize() IOUAmount::IOUAmount(Number const& other) : IOUAmount(fromNumber(other)) { - if (exponent_ > maxExponent) + if (exponent_ > kMAX_EXPONENT) Throw("value overflow"); - if (exponent_ < minExponent) - *this = beast::zero; + if (exponent_ < kMIN_EXPONENT) + *this = beast::kZERO; } IOUAmount& IOUAmount::operator+=(IOUAmount const& other) { - if (other == beast::zero) + if (other == beast::kZERO) return *this; - if (*this == beast::zero) + if (*this == beast::kZERO) { *this = other; return *this; @@ -165,7 +165,7 @@ IOUAmount::operator+=(IOUAmount const& other) if (mantissa_ >= -10 && mantissa_ <= 10) { - *this = beast::zero; + *this = beast::kZERO; return *this; } @@ -190,7 +190,7 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU // A vector with the value 10^index for indexes from 0 to 29 // The largest intermediate value we expect is 2^96, which // is less than 10^29 - static auto const powerTable = [] { + static auto const kPOWER_TABLE = [] { std::vector result; result.reserve(30); // 2^96 is largest intermediate result size uint128_t cur(1); @@ -204,11 +204,11 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU // Return floor(log10(v)) // Note: Returns -1 for v == 0 - static auto log10Floor = [](uint128_t const& v) { + static auto kLOG10_FLOOR = [](uint128_t const& v) { // Find the index of the first element >= the requested element, the // index is the log of the element in the log table. - auto const l = std::ranges::lower_bound(powerTable, v); - int index = std::distance(powerTable.begin(), l); + auto const l = std::ranges::lower_bound(kPOWER_TABLE, v); + int index = std::distance(kPOWER_TABLE.begin(), l); // If we're not equal, subtract to get the floor if (*l != v) --index; @@ -216,14 +216,14 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU }; // Return ceil(log10(v)) - static auto log10Ceil = [](uint128_t const& v) { + static auto kLOG10_CEIL = [](uint128_t const& v) { // Find the index of the first element >= the requested element, the // index is the log of the element in the log table. - auto const l = std::ranges::lower_bound(powerTable, v); - return int(std::distance(powerTable.begin(), l)); + auto const l = std::ranges::lower_bound(kPOWER_TABLE, v); + return int(std::distance(kPOWER_TABLE.begin(), l)); }; - static auto const fl64 = log10Floor(std::numeric_limits::max()); + static auto const kFL64 = kLOG10_FLOOR(std::numeric_limits::max()); bool const neg = amt.mantissa() < 0; uint128_t const den128(den); @@ -244,12 +244,12 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU // and (rem/den128) is as large as possible. Scale by multiplying low // and rem by 10 and subtracting one from the exponent. We could do this // with a loop, but it's more efficient to use logarithms. - auto const roomToGrow = fl64 - log10Ceil(low); + auto const roomToGrow = kFL64 - kLOG10_CEIL(low); if (roomToGrow > 0) { exponent -= roomToGrow; - low *= powerTable[roomToGrow]; - rem *= powerTable[roomToGrow]; + low *= kPOWER_TABLE[roomToGrow]; + rem *= kPOWER_TABLE[roomToGrow]; } auto const addRem = rem / den128; low += addRem; @@ -261,14 +261,14 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU // and adding one to the exponent until the low will fit in the 64-bit // mantissa. Use logarithms to avoid looping. bool hasRem = bool(rem); - auto const mustShrink = log10Ceil(low) - fl64; + auto const mustShrink = kLOG10_CEIL(low) - kFL64; if (mustShrink > 0) { uint128_t const sav(low); exponent += mustShrink; - low /= powerTable[mustShrink]; + low /= kPOWER_TABLE[mustShrink]; if (!hasRem) - hasRem = bool(sav - low * powerTable[mustShrink]); + hasRem = bool(sav - low * kPOWER_TABLE[mustShrink]); } std::int64_t mantissa = low.convert_to(); @@ -297,7 +297,7 @@ mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU { if (!result) { - return IOUAmount(-minMantissa, minExponent); + return IOUAmount(-kMIN_MANTISSA, kMIN_EXPONENT); } // This subtraction cannot underflow because `result` is not zero return IOUAmount(result.mantissa() - 1, result.exponent()); diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 4bbf2d6f1f..b37428a6bf 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -50,53 +50,52 @@ namespace xrpl { and marked as [[deprecated]] to prevent accidental reuse. */ enum class LedgerNameSpace : std::uint16_t { - ACCOUNT = 'a', - DIR_NODE = 'd', - TRUST_LINE = 'r', - OFFER = 'o', - OWNER_DIR = 'O', - BOOK_DIR = 'B', - SKIP_LIST = 's', - ESCROW = 'u', - AMENDMENTS = 'f', - FEE_SETTINGS = 'e', - TICKET = 'T', - SIGNER_LIST = 'S', - XRP_PAYMENT_CHANNEL = 'x', - CHECK = 'C', - DEPOSIT_PREAUTH = 'p', - DEPOSIT_PREAUTH_CREDENTIALS = 'P', - NEGATIVE_UNL = 'N', - NFTOKEN_OFFER = 'q', - NFTOKEN_BUY_OFFERS = 'h', - NFTOKEN_SELL_OFFERS = 'i', - AMM = 'A', - BRIDGE = 'H', - XCHAIN_CLAIM_ID = 'Q', - XCHAIN_CREATE_ACCOUNT_CLAIM_ID = 'K', - DID = 'I', - ORACLE = 'R', - MPTOKEN_ISSUANCE = '~', - MPTOKEN = 't', - CREDENTIAL = 'D', - PERMISSIONED_DOMAIN = 'm', - DELEGATE = 'E', - VAULT = 'V', - LOAN_BROKER = 'l', // lower-case L - LOAN = 'L', + Account = 'a', + DirNode = 'd', + TrustLine = 'r', + Offer = 'o', + OwnerDir = 'O', + BookDir = 'B', + SkipList = 's', + Escrow = 'u', + Amendments = 'f', + FeeSettings = 'e', + Ticket = 'T', + SignerList = 'S', + XRPPaymentChannel = 'x', + Check = 'C', + DepositPreauth = 'p', + DepositPreauthCredentials = 'P', + NegativeUnl = 'N', + NftokenOffer = 'q', + NftokenBuyOffers = 'h', + NftokenSellOffers = 'i', + Amm = 'A', + Bridge = 'H', + XchainClaimId = 'Q', + XchainCreateAccountClaimId = 'K', + Did = 'I', + Oracle = 'R', + MPTokenIssuance = '~', + MPToken = 't', + Credential = 'D', + PermissionedDomain = 'm', + Delegate = 'E', + Vault = 'V', + LoanBroker = 'l', // lower-case L + Loan = 'L', - // No longer used or supported. Left here to reserve the space - // to avoid accidental reuse. - CONTRACT [[deprecated]] = 'c', - GENERATOR [[deprecated]] = 'g', - NICKNAME [[deprecated]] = 'n', + // No longer used or supported. Left here to reserve the space to avoid accidental reuse. + Contract [[deprecated]] = 'c', + Generator [[deprecated]] = 'g', + Nickname [[deprecated]] = 'n', }; template static uint256 indexHash(LedgerNameSpace space, Args const&... args) { - return sha512Half(safe_cast(space), args...); + return sha512Half(safeCast(space), args...); } uint256 @@ -115,21 +114,21 @@ getBookBase(Book const& book) if constexpr (std::is_same_v && std::is_same_v) { return getIndexHash( - LedgerNameSpace::BOOK_DIR, in.currency, out.currency, in.account, out.account); + LedgerNameSpace::BookDir, in.currency, out.currency, in.account, out.account); } else if constexpr (std::is_same_v && std::is_same_v) { return getIndexHash( - LedgerNameSpace::BOOK_DIR, in.currency, out.getMptID(), in.account); + LedgerNameSpace::BookDir, in.currency, out.getMptID(), in.account); } else if constexpr (std::is_same_v && std::is_same_v) { return getIndexHash( - LedgerNameSpace::BOOK_DIR, in.getMptID(), out.currency, out.account); + LedgerNameSpace::BookDir, in.getMptID(), out.currency, out.account); } else { - return getIndexHash(LedgerNameSpace::BOOK_DIR, in.getMptID(), out.getMptID()); + return getIndexHash(LedgerNameSpace::BookDir, in.getMptID(), out.getMptID()); } }, book.in.value(), @@ -144,9 +143,9 @@ getBookBase(Book const& book) uint256 getQualityNext(uint256 const& uBase) { - static constexpr uint256 nextQuality( + static constexpr uint256 kNEXT_QUALITY( "0000000000000000000000000000000000000000000000010000000000000000"); - return uBase + nextQuality; + return uBase + kNEXT_QUALITY; } std::uint64_t @@ -159,7 +158,7 @@ getQuality(uint256 const& uBase) uint256 getTicketIndex(AccountID const& account, std::uint32_t ticketSeq) { - return indexHash(LedgerNameSpace::TICKET, account, ticketSeq); + return indexHash(LedgerNameSpace::Ticket, account, ticketSeq); } uint256 @@ -186,7 +185,7 @@ namespace keylet { Keylet account(AccountID const& id) noexcept { - return Keylet{ltACCOUNT_ROOT, indexHash(LedgerNameSpace::ACCOUNT, id)}; + return Keylet{ltACCOUNT_ROOT, indexHash(LedgerNameSpace::Account, id)}; } Keylet @@ -198,8 +197,8 @@ child(uint256 const& key) noexcept Keylet const& skip() noexcept { - static Keylet const ret{ltLEDGER_HASHES, indexHash(LedgerNameSpace::SKIP_LIST)}; - return ret; + static Keylet const kRET{ltLEDGER_HASHES, indexHash(LedgerNameSpace::SkipList)}; + return kRET; } Keylet @@ -208,32 +207,32 @@ skip(LedgerIndex ledger) noexcept return { ltLEDGER_HASHES, indexHash( - LedgerNameSpace::SKIP_LIST, std::uint32_t(static_cast(ledger) >> 16))}; + LedgerNameSpace::SkipList, std::uint32_t(static_cast(ledger) >> 16))}; } Keylet const& amendments() noexcept { - static Keylet const ret{ltAMENDMENTS, indexHash(LedgerNameSpace::AMENDMENTS)}; - return ret; + static Keylet const kRET{ltAMENDMENTS, indexHash(LedgerNameSpace::Amendments)}; + return kRET; } Keylet const& fees() noexcept { - static Keylet const ret{ltFEE_SETTINGS, indexHash(LedgerNameSpace::FEE_SETTINGS)}; - return ret; + static Keylet const kRET{ltFEE_SETTINGS, indexHash(LedgerNameSpace::FeeSettings)}; + return kRET; } Keylet const& negativeUNL() noexcept { - static Keylet const ret{ltNEGATIVE_UNL, indexHash(LedgerNameSpace::NEGATIVE_UNL)}; - return ret; + static Keylet const kRET{ltNEGATIVE_UNL, indexHash(LedgerNameSpace::NegativeUnl)}; + return kRET; } Keylet -book_t::operator()(Book const& b) const +BookT::operator()(Book const& b) const { return {ltDIR_NODE, getBookBase(b)}; } @@ -258,13 +257,13 @@ line(AccountID const& id0, AccountID const& id1, Currency const& currency) noexc return { ltRIPPLE_STATE, - indexHash(LedgerNameSpace::TRUST_LINE, accounts.first, accounts.second, currency)}; + indexHash(LedgerNameSpace::TrustLine, accounts.first, accounts.second, currency)}; } Keylet offer(AccountID const& id, std::uint32_t seq) noexcept { - return {ltOFFER, indexHash(LedgerNameSpace::OFFER, id, seq)}; + return {ltOFFER, indexHash(LedgerNameSpace::Offer, id, seq)}; } Keylet @@ -286,20 +285,20 @@ quality(Keylet const& k, std::uint64_t q) noexcept } Keylet -next_t::operator()(Keylet const& k) const +NextT::operator()(Keylet const& k) const { XRPL_ASSERT(k.type == ltDIR_NODE, "xrpl::keylet::next_t::operator() : valid input type"); return {ltDIR_NODE, getQualityNext(k.key)}; } Keylet -ticket_t::operator()(AccountID const& id, std::uint32_t ticketSeq) const +TicketT::operator()(AccountID const& id, std::uint32_t ticketSeq) const { return {ltTICKET, getTicketIndex(id, ticketSeq)}; } Keylet -ticket_t::operator()(AccountID const& id, SeqProxy ticketSeq) const +TicketT::operator()(AccountID const& id, SeqProxy ticketSeq) const { return {ltTICKET, getTicketIndex(id, ticketSeq)}; } @@ -310,7 +309,7 @@ ticket_t::operator()(AccountID const& id, SeqProxy ticketSeq) const static Keylet signers(AccountID const& account, std::uint32_t page) noexcept { - return {ltSIGNER_LIST, indexHash(LedgerNameSpace::SIGNER_LIST, account, page)}; + return {ltSIGNER_LIST, indexHash(LedgerNameSpace::SignerList, account, page)}; } Keylet @@ -322,13 +321,13 @@ signers(AccountID const& account) noexcept Keylet check(AccountID const& id, std::uint32_t seq) noexcept { - return {ltCHECK, indexHash(LedgerNameSpace::CHECK, id, seq)}; + return {ltCHECK, indexHash(LedgerNameSpace::Check, id, seq)}; } Keylet depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept { - return {ltDEPOSIT_PREAUTH, indexHash(LedgerNameSpace::DEPOSIT_PREAUTH, owner, preauthorized)}; + return {ltDEPOSIT_PREAUTH, indexHash(LedgerNameSpace::DepositPreauth, owner, preauthorized)}; } // Credentials should be sorted here, use credentials::makeSorted @@ -343,7 +342,7 @@ depositPreauth( hashes.emplace_back(sha512Half(o.first, o.second)); return { - ltDEPOSIT_PREAUTH, indexHash(LedgerNameSpace::DEPOSIT_PREAUTH_CREDENTIALS, owner, hashes)}; + ltDEPOSIT_PREAUTH, indexHash(LedgerNameSpace::DepositPreauthCredentials, owner, hashes)}; } //------------------------------------------------------------------------------ @@ -357,7 +356,7 @@ unchecked(uint256 const& key) noexcept Keylet ownerDir(AccountID const& id) noexcept { - return {ltDIR_NODE, indexHash(LedgerNameSpace::OWNER_DIR, id)}; + return {ltDIR_NODE, indexHash(LedgerNameSpace::OwnerDir, id)}; } Keylet @@ -366,23 +365,23 @@ page(uint256 const& key, std::uint64_t index) noexcept if (index == 0) return {ltDIR_NODE, key}; - return {ltDIR_NODE, indexHash(LedgerNameSpace::DIR_NODE, key, index)}; + return {ltDIR_NODE, indexHash(LedgerNameSpace::DirNode, key, index)}; } Keylet escrow(AccountID const& src, std::uint32_t seq) noexcept { - return {ltESCROW, indexHash(LedgerNameSpace::ESCROW, src, seq)}; + return {ltESCROW, indexHash(LedgerNameSpace::Escrow, src, seq)}; } Keylet payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept { - return {ltPAYCHAN, indexHash(LedgerNameSpace::XRP_PAYMENT_CHANNEL, src, dst, seq)}; + return {ltPAYCHAN, indexHash(LedgerNameSpace::XRPPaymentChannel, src, dst, seq)}; } Keylet -nftpage_min(AccountID const& owner) +nftpageMin(AccountID const& owner) { std::array buf{}; std::memcpy(buf.data(), owner.data(), owner.size()); @@ -390,9 +389,9 @@ nftpage_min(AccountID const& owner) } Keylet -nftpage_max(AccountID const& owner) +nftpageMax(AccountID const& owner) { - uint256 id = nft::pageMask; + uint256 id = nft::kPAGE_MASK; std::memcpy(id.data(), owner.data(), owner.size()); return {ltNFTOKEN_PAGE, id}; } @@ -401,25 +400,25 @@ Keylet nftpage(Keylet const& k, uint256 const& token) { XRPL_ASSERT(k.type == ltNFTOKEN_PAGE, "xrpl::keylet::nftpage : valid input type"); - return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; + return {ltNFTOKEN_PAGE, (k.key & ~nft::kPAGE_MASK) + (token & nft::kPAGE_MASK)}; } Keylet nftoffer(AccountID const& owner, std::uint32_t seq) { - return {ltNFTOKEN_OFFER, indexHash(LedgerNameSpace::NFTOKEN_OFFER, owner, seq)}; + return {ltNFTOKEN_OFFER, indexHash(LedgerNameSpace::NftokenOffer, owner, seq)}; } Keylet -nft_buys(uint256 const& id) noexcept +nftBuys(uint256 const& id) noexcept { - return {ltDIR_NODE, indexHash(LedgerNameSpace::NFTOKEN_BUY_OFFERS, id)}; + return {ltDIR_NODE, indexHash(LedgerNameSpace::NftokenBuyOffers, id)}; } Keylet -nft_sells(uint256 const& id) noexcept +nftSells(uint256 const& id) noexcept { - return {ltDIR_NODE, indexHash(LedgerNameSpace::NFTOKEN_SELL_OFFERS, id)}; + return {ltDIR_NODE, indexHash(LedgerNameSpace::NftokenSellOffers, id)}; } Keylet @@ -431,7 +430,7 @@ amm(Asset const& asset1, Asset const& asset2) noexcept if constexpr (std::is_same_v && std::is_same_v) { return amm(indexHash( - LedgerNameSpace::AMM, + LedgerNameSpace::Amm, issue1.account, issue1.currency, issue2.account, @@ -440,16 +439,16 @@ amm(Asset const& asset1, Asset const& asset2) noexcept else if constexpr (std::is_same_v && std::is_same_v) { return amm(indexHash( - LedgerNameSpace::AMM, issue1.account, issue1.currency, issue2.getMptID())); + LedgerNameSpace::Amm, issue1.account, issue1.currency, issue2.getMptID())); } else if constexpr (std::is_same_v && std::is_same_v) { return amm(indexHash( - LedgerNameSpace::AMM, issue1.getMptID(), issue2.account, issue2.currency)); + LedgerNameSpace::Amm, issue1.getMptID(), issue2.account, issue2.currency)); } else if constexpr (std::is_same_v && std::is_same_v) { - return amm(indexHash(LedgerNameSpace::AMM, issue1.getMptID(), issue2.getMptID())); + return amm(indexHash(LedgerNameSpace::Amm, issue1.getMptID(), issue2.getMptID())); } }, minA.value(), @@ -465,7 +464,7 @@ amm(uint256 const& id) noexcept Keylet delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept { - return {ltDELEGATE, indexHash(LedgerNameSpace::DELEGATE, account, authorizedAccount)}; + return {ltDELEGATE, indexHash(LedgerNameSpace::Delegate, account, authorizedAccount)}; } Keylet @@ -475,7 +474,7 @@ bridge(STXChainBridge const& bridge, STXChainBridge::ChainType chainType) // there can only be one bridge per lockingChainCurrency. On the issuing // chain there can only be one bridge per issuingChainCurrency. auto const& issue = bridge.issue(chainType); - return {ltBRIDGE, indexHash(LedgerNameSpace::BRIDGE, bridge.door(chainType), issue.currency)}; + return {ltBRIDGE, indexHash(LedgerNameSpace::Bridge, bridge.door(chainType), issue.currency)}; } Keylet @@ -484,7 +483,7 @@ xChainClaimID(STXChainBridge const& bridge, std::uint64_t seq) return { ltXCHAIN_OWNED_CLAIM_ID, indexHash( - LedgerNameSpace::XCHAIN_CLAIM_ID, + LedgerNameSpace::XchainClaimId, bridge.lockingChainDoor(), bridge.lockingChainIssue(), bridge.issuingChainDoor(), @@ -498,7 +497,7 @@ xChainCreateAccountClaimID(STXChainBridge const& bridge, std::uint64_t seq) return { ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, indexHash( - LedgerNameSpace::XCHAIN_CREATE_ACCOUNT_CLAIM_ID, + LedgerNameSpace::XchainCreateAccountClaimId, bridge.lockingChainDoor(), bridge.lockingChainIssue(), bridge.issuingChainDoor(), @@ -509,13 +508,13 @@ xChainCreateAccountClaimID(STXChainBridge const& bridge, std::uint64_t seq) Keylet did(AccountID const& account) noexcept { - return {ltDID, indexHash(LedgerNameSpace::DID, account)}; + return {ltDID, indexHash(LedgerNameSpace::Did, account)}; } Keylet oracle(AccountID const& account, std::uint32_t const& documentID) noexcept { - return {ltORACLE, indexHash(LedgerNameSpace::ORACLE, account, documentID)}; + return {ltORACLE, indexHash(LedgerNameSpace::Oracle, account, documentID)}; } Keylet @@ -527,7 +526,7 @@ mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept Keylet mptIssuance(MPTID const& issuanceID) noexcept { - return {ltMPTOKEN_ISSUANCE, indexHash(LedgerNameSpace::MPTOKEN_ISSUANCE, issuanceID)}; + return {ltMPTOKEN_ISSUANCE, indexHash(LedgerNameSpace::MPTokenIssuance, issuanceID)}; } Keylet @@ -539,37 +538,37 @@ mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept Keylet mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept { - return {ltMPTOKEN, indexHash(LedgerNameSpace::MPTOKEN, issuanceKey, holder)}; + return {ltMPTOKEN, indexHash(LedgerNameSpace::MPToken, issuanceKey, holder)}; } Keylet credential(AccountID const& subject, AccountID const& issuer, Slice const& credType) noexcept { - return {ltCREDENTIAL, indexHash(LedgerNameSpace::CREDENTIAL, subject, issuer, credType)}; + return {ltCREDENTIAL, indexHash(LedgerNameSpace::Credential, subject, issuer, credType)}; } Keylet vault(AccountID const& owner, std::uint32_t seq) noexcept { - return vault(indexHash(LedgerNameSpace::VAULT, owner, seq)); + return vault(indexHash(LedgerNameSpace::Vault, owner, seq)); } Keylet loanbroker(AccountID const& owner, std::uint32_t seq) noexcept { - return loanbroker(indexHash(LedgerNameSpace::LOAN_BROKER, owner, seq)); + return loanbroker(indexHash(LedgerNameSpace::LoanBroker, owner, seq)); } Keylet loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept { - return loan(indexHash(LedgerNameSpace::LOAN, loanBrokerID, loanSeq)); + return loan(indexHash(LedgerNameSpace::Loan, loanBrokerID, loanSeq)); } Keylet permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept { - return {ltPERMISSIONED_DOMAIN, indexHash(LedgerNameSpace::PERMISSIONED_DOMAIN, account, seq)}; + return {ltPERMISSIONED_DOMAIN, indexHash(LedgerNameSpace::PermissionedDomain, account, seq)}; } Keylet diff --git a/src/libxrpl/protocol/InnerObjectFormats.cpp b/src/libxrpl/protocol/InnerObjectFormats.cpp index f4a88ec171..5c691159d7 100644 --- a/src/libxrpl/protocol/InnerObjectFormats.cpp +++ b/src/libxrpl/protocol/InnerObjectFormats.cpp @@ -13,160 +13,160 @@ InnerObjectFormats::InnerObjectFormats() add(sfSignerEntry.jsonName, sfSignerEntry.getCode(), { - {sfAccount, soeREQUIRED}, - {sfSignerWeight, soeREQUIRED}, - {sfWalletLocator, soeOPTIONAL}, + {sfAccount, SoeRequired}, + {sfSignerWeight, SoeRequired}, + {sfWalletLocator, SoeOptional}, }); add(sfSigner.jsonName, sfSigner.getCode(), { - {sfAccount, soeREQUIRED}, - {sfSigningPubKey, soeREQUIRED}, - {sfTxnSignature, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfSigningPubKey, SoeRequired}, + {sfTxnSignature, SoeRequired}, }); add(sfMajority.jsonName, sfMajority.getCode(), { - {sfAmendment, soeREQUIRED}, - {sfCloseTime, soeREQUIRED}, + {sfAmendment, SoeRequired}, + {sfCloseTime, SoeRequired}, }); add(sfDisabledValidator.jsonName, sfDisabledValidator.getCode(), { - {sfPublicKey, soeREQUIRED}, - {sfFirstLedgerSequence, soeREQUIRED}, + {sfPublicKey, SoeRequired}, + {sfFirstLedgerSequence, SoeRequired}, }); add(sfNFToken.jsonName, sfNFToken.getCode(), { - {sfNFTokenID, soeREQUIRED}, - {sfURI, soeOPTIONAL}, + {sfNFTokenID, SoeRequired}, + {sfURI, SoeOptional}, }); add(sfVoteEntry.jsonName, sfVoteEntry.getCode(), { - {sfAccount, soeREQUIRED}, - {sfTradingFee, soeDEFAULT}, - {sfVoteWeight, soeREQUIRED}, + {sfAccount, SoeRequired}, + {sfTradingFee, SoeDefault}, + {sfVoteWeight, SoeRequired}, }); add(sfAuctionSlot.jsonName, sfAuctionSlot.getCode(), - {{sfAccount, soeREQUIRED}, - {sfExpiration, soeREQUIRED}, - {sfDiscountedFee, soeDEFAULT}, - {sfPrice, soeREQUIRED}, - {sfAuthAccounts, soeOPTIONAL}}); + {{sfAccount, SoeRequired}, + {sfExpiration, SoeRequired}, + {sfDiscountedFee, SoeDefault}, + {sfPrice, SoeRequired}, + {sfAuthAccounts, SoeOptional}}); add(sfXChainClaimAttestationCollectionElement.jsonName, sfXChainClaimAttestationCollectionElement.getCode(), { - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAccount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfSignature, SoeRequired}, + {sfAmount, SoeRequired}, + {sfAccount, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, + {sfXChainClaimID, SoeRequired}, + {sfDestination, SoeOptional}, }); add(sfXChainCreateAccountAttestationCollectionElement.jsonName, sfXChainCreateAccountAttestationCollectionElement.getCode(), { - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAccount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfSignature, SoeRequired}, + {sfAmount, SoeRequired}, + {sfAccount, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, + {sfXChainAccountCreateCount, SoeRequired}, + {sfDestination, SoeRequired}, + {sfSignatureReward, SoeRequired}, }); add(sfXChainClaimProofSig.jsonName, sfXChainClaimProofSig.getCode(), { - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfAmount, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, + {sfDestination, SoeOptional}, }); add(sfXChainCreateAccountProofSig.jsonName, sfXChainCreateAccountProofSig.getCode(), { - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - {sfDestination, soeREQUIRED}, + {sfAttestationSignerAccount, SoeRequired}, + {sfPublicKey, SoeRequired}, + {sfAmount, SoeRequired}, + {sfSignatureReward, SoeRequired}, + {sfAttestationRewardAccount, SoeRequired}, + {sfWasLockingChainSend, SoeRequired}, + {sfDestination, SoeRequired}, }); add(sfAuthAccount.jsonName, sfAuthAccount.getCode(), { - {sfAccount, soeREQUIRED}, + {sfAccount, SoeRequired}, }); add(sfPriceData.jsonName, sfPriceData.getCode(), { - {sfBaseAsset, soeREQUIRED}, - {sfQuoteAsset, soeREQUIRED}, - {sfAssetPrice, soeOPTIONAL}, - {sfScale, soeDEFAULT}, + {sfBaseAsset, SoeRequired}, + {sfQuoteAsset, SoeRequired}, + {sfAssetPrice, SoeOptional}, + {sfScale, SoeDefault}, }); add(sfCredential.jsonName, sfCredential.getCode(), { - {sfIssuer, soeREQUIRED}, - {sfCredentialType, soeREQUIRED}, + {sfIssuer, SoeRequired}, + {sfCredentialType, SoeRequired}, }); - add(sfPermission.jsonName.c_str(), sfPermission.getCode(), {{sfPermissionValue, soeREQUIRED}}); + add(sfPermission.jsonName.cStr(), sfPermission.getCode(), {{sfPermissionValue, SoeRequired}}); - add(sfBatchSigner.jsonName.c_str(), + add(sfBatchSigner.jsonName.cStr(), sfBatchSigner.getCode(), - {{sfAccount, soeREQUIRED}, - {sfSigningPubKey, soeOPTIONAL}, - {sfTxnSignature, soeOPTIONAL}, - {sfSigners, soeOPTIONAL}}); + {{sfAccount, SoeRequired}, + {sfSigningPubKey, SoeOptional}, + {sfTxnSignature, SoeOptional}, + {sfSigners, SoeOptional}}); add(sfBook.jsonName, sfBook.getCode(), { - {sfBookDirectory, soeREQUIRED}, - {sfBookNode, soeREQUIRED}, + {sfBookDirectory, SoeRequired}, + {sfBookNode, SoeRequired}, }); add(sfCounterpartySignature.jsonName, sfCounterpartySignature.getCode(), { - {sfSigningPubKey, soeOPTIONAL}, - {sfTxnSignature, soeOPTIONAL}, - {sfSigners, soeOPTIONAL}, + {sfSigningPubKey, SoeOptional}, + {sfTxnSignature, SoeOptional}, + {sfSigners, SoeOptional}, }); } InnerObjectFormats const& InnerObjectFormats::getInstance() { - static InnerObjectFormats const instance; - return instance; + static InnerObjectFormats const kINSTANCE; + return kINSTANCE; } SOTemplate const* diff --git a/src/libxrpl/protocol/Issue.cpp b/src/libxrpl/protocol/Issue.cpp index d5896bbd57..33ad3a0835 100644 --- a/src/libxrpl/protocol/Issue.cpp +++ b/src/libxrpl/protocol/Issue.cpp @@ -43,7 +43,7 @@ Issue::getText() const } void -Issue::setJson(Json::Value& jv) const +Issue::setJson(json::Value& jv) const { jv[jss::currency] = to_string(currency); if (!isXRP(currency)) @@ -77,16 +77,16 @@ to_string(Issue const& ac) return to_string(ac.account) + "/" + to_string(ac.currency); } -Json::Value -to_json(Issue const& is) +json::Value +toJson(Issue const& is) { - Json::Value jv; + json::Value jv; is.setJson(jv); return jv; } Issue -issueFromJson(Json::Value const& v) +issueFromJson(json::Value const& v) { if (!v.isObject()) { @@ -99,38 +99,38 @@ issueFromJson(Json::Value const& v) Throw("issueFromJson, Issue should not have mpt_issuance_id"); } - Json::Value const curStr = v[jss::currency]; - Json::Value const issStr = v[jss::issuer]; + json::Value const curStr = v[jss::currency]; + json::Value const issStr = v[jss::issuer]; if (!curStr.isString()) { - Throw("issueFromJson currency must be a string Json value"); + Throw("issueFromJson currency must be a string Json value"); } - auto const currency = to_currency(curStr.asString()); + auto const currency = toCurrency(curStr.asString()); if (currency == badCurrency() || currency == noCurrency()) { - Throw("issueFromJson currency must be a valid currency"); + Throw("issueFromJson currency must be a valid currency"); } if (isXRP(currency)) { if (!issStr.isNull()) { - Throw("Issue, XRP should not have issuer"); + Throw("Issue, XRP should not have issuer"); } return xrpIssue(); } if (!issStr.isString()) { - Throw("issueFromJson issuer must be a string Json value"); + Throw("issueFromJson issuer must be a string Json value"); } auto const issuer = parseBase58(issStr.asString()); if (!issuer) { - Throw("issueFromJson issuer must be a valid account"); + Throw("issueFromJson issuer must be a valid account"); } return Issue{currency, *issuer}; diff --git a/src/libxrpl/protocol/LedgerFormats.cpp b/src/libxrpl/protocol/LedgerFormats.cpp index 7826435e51..99c636fbdc 100644 --- a/src/libxrpl/protocol/LedgerFormats.cpp +++ b/src/libxrpl/protocol/LedgerFormats.cpp @@ -11,12 +11,12 @@ namespace xrpl { std::vector const& LedgerFormats::getCommonFields() { - static auto const commonFields = std::vector{ - {sfLedgerIndex, soeOPTIONAL}, - {sfLedgerEntryType, soeREQUIRED}, - {sfFlags, soeREQUIRED}, + static auto const kCOMMON_FIELDS = std::vector{ + {sfLedgerIndex, SoeOptional}, + {sfLedgerEntryType, SoeRequired}, + {sfFlags, SoeRequired}, }; - return commonFields; + return kCOMMON_FIELDS; } LedgerFormats::LedgerFormats() @@ -41,8 +41,8 @@ LedgerFormats::LedgerFormats() LedgerFormats const& LedgerFormats::getInstance() { - static LedgerFormats const instance; - return instance; + static LedgerFormats const kINSTANCE; + return kINSTANCE; } } // namespace xrpl diff --git a/src/libxrpl/protocol/LedgerHeader.cpp b/src/libxrpl/protocol/LedgerHeader.cpp index f6a99be28a..9ddd6e180d 100644 --- a/src/libxrpl/protocol/LedgerHeader.cpp +++ b/src/libxrpl/protocol/LedgerHeader.cpp @@ -61,7 +61,7 @@ calculateLedgerHash(LedgerHeader const& info) { // VFALCO This has to match addRaw in View.h. return sha512Half( - HashPrefix::ledgerMaster, + HashPrefix::LedgerMaster, std::uint32_t(info.seq), std::uint64_t(info.drops.drops()), info.parentHash, diff --git a/src/libxrpl/protocol/MPTIssue.cpp b/src/libxrpl/protocol/MPTIssue.cpp index dac2f4e5fe..e9ec852d1d 100644 --- a/src/libxrpl/protocol/MPTIssue.cpp +++ b/src/libxrpl/protocol/MPTIssue.cpp @@ -44,15 +44,15 @@ MPTIssue::getText() const } void -MPTIssue::setJson(Json::Value& jv) const +MPTIssue::setJson(json::Value& jv) const { jv[jss::mpt_issuance_id] = to_string(mptID_); } -Json::Value -to_json(MPTIssue const& mptIssue) +json::Value +toJson(MPTIssue const& mptIssue) { - Json::Value jv; + json::Value jv; mptIssue.setJson(jv); return jv; } @@ -64,7 +64,7 @@ to_string(MPTIssue const& mptIssue) } MPTIssue -mptIssueFromJson(Json::Value const& v) +mptIssueFromJson(json::Value const& v) { if (!v.isObject()) { @@ -78,17 +78,17 @@ mptIssueFromJson(Json::Value const& v) Throw("mptIssueFromJson, MPTIssue should not have currency or issuer"); } - Json::Value const& idStr = v[jss::mpt_issuance_id]; + json::Value const& idStr = v[jss::mpt_issuance_id]; if (!idStr.isString()) { - Throw("mptIssueFromJson MPTID must be a string Json value"); + Throw("mptIssueFromJson MPTID must be a string Json value"); } MPTID id; if (!id.parseHex(idStr.asString())) { - Throw("mptIssueFromJson MPTID is invalid"); + Throw("mptIssueFromJson MPTID is invalid"); } return MPTIssue{id}; diff --git a/src/libxrpl/protocol/NFTSyntheticSerializer.cpp b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp index 9982f05b0f..4f0a2d5071 100644 --- a/src/libxrpl/protocol/NFTSyntheticSerializer.cpp +++ b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp @@ -13,7 +13,7 @@ namespace xrpl::RPC { void insertNFTSyntheticInJson( - Json::Value& response, + json::Value& response, std::shared_ptr const& transaction, TxMeta const& transactionMeta) { diff --git a/src/libxrpl/protocol/NFTokenID.cpp b/src/libxrpl/protocol/NFTokenID.cpp index fc32a7b4e8..b7822caf01 100644 --- a/src/libxrpl/protocol/NFTokenID.cpp +++ b/src/libxrpl/protocol/NFTokenID.cpp @@ -134,7 +134,7 @@ getNFTokenIDFromDeletedOffer(TxMeta const& transactionMeta) void insertNFTokenID( - Json::Value& response, + json::Value& response, std::shared_ptr const& transaction, TxMeta const& transactionMeta) { @@ -159,7 +159,7 @@ insertNFTokenID( { std::vector const result = getNFTokenIDFromDeletedOffer(transactionMeta); - response[jss::nftoken_ids] = Json::Value(Json::arrayValue); + response[jss::nftoken_ids] = json::Value(json::ArrayValue); for (auto const& nftID : result) response[jss::nftoken_ids].append(to_string(nftID)); } diff --git a/src/libxrpl/protocol/NFTokenOfferID.cpp b/src/libxrpl/protocol/NFTokenOfferID.cpp index c1d426eef0..ee39222bfa 100644 --- a/src/libxrpl/protocol/NFTokenOfferID.cpp +++ b/src/libxrpl/protocol/NFTokenOfferID.cpp @@ -52,7 +52,7 @@ getOfferIDFromCreatedOffer(TxMeta const& transactionMeta) void insertNFTokenOfferID( - Json::Value& response, + json::Value& response, std::shared_ptr const& transaction, TxMeta const& transactionMeta) { diff --git a/src/libxrpl/protocol/Permissions.cpp b/src/libxrpl/protocol/Permissions.cpp index 21efe7a8cf..4222c63fea 100644 --- a/src/libxrpl/protocol/Permissions.cpp +++ b/src/libxrpl/protocol/Permissions.cpp @@ -92,8 +92,8 @@ Permission::Permission() Permission const& Permission::getInstance() { - static Permission const instance; - return instance; + static Permission const kINSTANCE; + return kINSTANCE; } std::optional @@ -182,7 +182,7 @@ Permission::isDelegable(std::uint32_t const& permissionValue, Rules const& rules if (txFeaturesIt->second != uint256{} && !rules.enabled(txFeaturesIt->second)) return false; - if (it->second == Delegation::notDelegable) + if (it->second == Delegation::NotDelegable) return false; return true; diff --git a/src/libxrpl/protocol/Protocol.cpp b/src/libxrpl/protocol/Protocol.cpp index 6f86f49fc6..14230e78bd 100644 --- a/src/libxrpl/protocol/Protocol.cpp +++ b/src/libxrpl/protocol/Protocol.cpp @@ -4,12 +4,12 @@ namespace xrpl { bool isVotingLedger(LedgerIndex seq) { - return seq % FLAG_LEDGER_INTERVAL == 0; + return seq % kFLAG_LEDGER_INTERVAL == 0; } bool isFlagLedger(LedgerIndex seq) { - return seq % FLAG_LEDGER_INTERVAL == 0; + return seq % kFLAG_LEDGER_INTERVAL == 0; } } // namespace xrpl diff --git a/src/libxrpl/protocol/PublicKey.cpp b/src/libxrpl/protocol/PublicKey.cpp index 54430ed5d5..ad88e60fe7 100644 --- a/src/libxrpl/protocol/PublicKey.cpp +++ b/src/libxrpl/protocol/PublicKey.cpp @@ -88,9 +88,9 @@ sliceToHex(Slice const& slice) } for (int i = 0; i < slice.size(); ++i) { - constexpr char hex[] = "0123456789ABCDEF"; - s += hex[((slice[i] & 0xf0) >> 4)]; - s += hex[((slice[i] & 0x0f) >> 0)]; + constexpr char kHEX[] = "0123456789ABCDEF"; + s += kHEX[((slice[i] & 0xf0) >> 4)]; + s += kHEX[((slice[i] & 0x0f) >> 0)]; } return s; } @@ -117,7 +117,8 @@ ecdsaCanonicality(Slice const& sig) boost::multiprecision::unchecked, void>>; - static uint264 const G("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"); + static uint264 const kG( + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"); // NOLINT(readability-identifier-naming) // The format of a signature should be: // <30> [ <02> ] [ <02> ] @@ -131,20 +132,20 @@ ecdsaCanonicality(Slice const& sig) if (!r || !s || !p.empty()) return std::nullopt; - uint264 const R(sliceToHex(*r)); - if (R >= G) + uint264 const rNum(sliceToHex(*r)); + if (rNum >= kG) return std::nullopt; - uint264 const S(sliceToHex(*s)); - if (S >= G) + uint264 const sNum(sliceToHex(*s)); + if (sNum >= kG) return std::nullopt; // (R,S) and (R,G-S) are canonical, // but is fully canonical when S <= G-S - auto const Sp = G - S; - if (S > Sp) - return ECDSACanonicality::canonical; - return ECDSACanonicality::fullyCanonical; + auto const Sp = kG - sNum; // NOLINT(readability-identifier-naming) + if (sNum > Sp) + return ECDSACanonicality::Canonical; + return ECDSACanonicality::FullyCanonical; } static bool @@ -153,6 +154,7 @@ ed25519Canonical(Slice const& sig) if (sig.size() != 64) return false; // Big-endian Order, the Ed25519 subgroup order + // NOLINTNEXTLINE(readability-identifier-naming) std::uint8_t const Order[] = { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xDE, 0xF9, 0xDE, 0xA2, 0xF7, @@ -161,7 +163,7 @@ ed25519Canonical(Slice const& sig) // Take the second half of signature // and byte-reverse it to big-endian. auto const le = sig.data() + 32; - std::uint8_t S[32]; + std::uint8_t S[32]; // NOLINT(readability-identifier-naming) std::reverse_copy(le, le + 32, S); // Must be less than Order return std::lexicographical_compare(S, S + 32, Order, Order + 32); @@ -171,21 +173,21 @@ ed25519Canonical(Slice const& sig) PublicKey::PublicKey(Slice const& slice) { - if (slice.size() < size_) + if (slice.size() < kSIZE) { - LogicError( + logicError( "PublicKey::PublicKey - Input slice cannot be an undersized " "buffer"); } if (!publicKeyType(slice)) - LogicError("PublicKey::PublicKey invalid type"); - std::memcpy(buf_, slice.data(), size_); + logicError("PublicKey::PublicKey invalid type"); + std::memcpy(buf_, slice.data(), kSIZE); } PublicKey::PublicKey(PublicKey const& other) { - std::memcpy(buf_, other.buf_, size_); + std::memcpy(buf_, other.buf_, kSIZE); } PublicKey& @@ -193,7 +195,7 @@ PublicKey::operator=(PublicKey const& other) { if (this != &other) { - std::memcpy(buf_, other.buf_, size_); + std::memcpy(buf_, other.buf_, kSIZE); } return *this; @@ -207,10 +209,10 @@ publicKeyType(Slice const& slice) if (slice.size() == 33) { if (slice[0] == 0xED) - return KeyType::ed25519; + return KeyType::Ed25519; if (slice[0] == 0x02 || slice[0] == 0x03) - return KeyType::secp256k1; + return KeyType::Secp256k1; } return std::nullopt; @@ -223,45 +225,45 @@ verifyDigest( Slice const& sig, bool mustBeFullyCanonical) noexcept { - if (publicKeyType(publicKey) != KeyType::secp256k1) - LogicError("sign: secp256k1 required for digest signing"); + if (publicKeyType(publicKey) != KeyType::Secp256k1) + logicError("sign: secp256k1 required for digest signing"); auto const canonicality = ecdsaCanonicality(sig); if (!canonicality) return false; - if (mustBeFullyCanonical && (*canonicality != ECDSACanonicality::fullyCanonical)) + if (mustBeFullyCanonical && (*canonicality != ECDSACanonicality::FullyCanonical)) return false; - secp256k1_pubkey pubkey_imp; + secp256k1_pubkey pubkeyImp; if (secp256k1_ec_pubkey_parse( secp256k1Context(), - &pubkey_imp, + &pubkeyImp, reinterpret_cast(publicKey.data()), publicKey.size()) != 1) return false; - secp256k1_ecdsa_signature sig_imp; + secp256k1_ecdsa_signature sigImp; if (secp256k1_ecdsa_signature_parse_der( secp256k1Context(), - &sig_imp, + &sigImp, reinterpret_cast(sig.data()), sig.size()) != 1) return false; - if (*canonicality != ECDSACanonicality::fullyCanonical) + if (*canonicality != ECDSACanonicality::FullyCanonical) { - secp256k1_ecdsa_signature sig_norm; - if (secp256k1_ecdsa_signature_normalize(secp256k1Context(), &sig_norm, &sig_imp) != 1) + secp256k1_ecdsa_signature sigNorm; + if (secp256k1_ecdsa_signature_normalize(secp256k1Context(), &sigNorm, &sigImp) != 1) return false; return secp256k1_ecdsa_verify( secp256k1Context(), - &sig_norm, + &sigNorm, reinterpret_cast(digest.data()), - &pubkey_imp) == 1; + &pubkeyImp) == 1; } return secp256k1_ecdsa_verify( secp256k1Context(), - &sig_imp, + &sigImp, reinterpret_cast(digest.data()), - &pubkey_imp) == 1; + &pubkeyImp) == 1; } bool @@ -269,11 +271,11 @@ verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept { if (auto const type = publicKeyType(publicKey)) { - if (*type == KeyType::secp256k1) + if (*type == KeyType::Secp256k1) { return verifyDigest(publicKey, sha512Half(m), sig); } - if (*type == KeyType::ed25519) + if (*type == KeyType::Ed25519) { if (!ed25519Canonical(sig)) return false; @@ -291,11 +293,11 @@ verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept NodeID calcNodeID(PublicKey const& pk) { - static_assert(NodeID::bytes == sizeof(ripesha_hasher::result_type)); + static_assert(NodeID::kBYTES == sizeof(RipeshaHasher::result_type)); - ripesha_hasher h; + RipeshaHasher h; h(pk.data(), pk.size()); - return NodeID{static_cast(h)}; + return NodeID{static_cast(h)}; } } // namespace xrpl diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index 5f38f2219b..d3997cf2db 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -1,26 +1,28 @@ #include +#include #include #include #include #include +#include namespace xrpl { -Quality::Quality(std::uint64_t value) : m_value(value) +Quality::Quality(std::uint64_t value) : value_(value) { } -Quality::Quality(Amounts const& amount) : m_value(getRate(amount.out, amount.in)) +Quality::Quality(Amounts const& amount) : value_(getRate(amount.out, amount.in)) { } Quality& Quality::operator++() { - XRPL_ASSERT(m_value > 0, "xrpl::Quality::operator++() : minimum value"); - --m_value; + XRPL_ASSERT(value_ > 0, "xrpl::Quality::operator++() : minimum value"); + --value_; return *this; } @@ -36,9 +38,9 @@ Quality& Quality::operator--() { XRPL_ASSERT( - m_value < std::numeric_limits::max(), + value_ < std::numeric_limits::max(), "xrpl::Quality::operator--() : maximum value"); - ++m_value; + ++value_; return *this; } @@ -52,7 +54,7 @@ Quality::operator--(int) template static Amounts -ceil_in_impl(Amounts const& amount, STAmount const& limit, bool roundUp, Quality const& quality) +ceilInImpl(Amounts const& amount, STAmount const& limit, bool roundUp, Quality const& quality) { if (amount.in > limit) { @@ -68,20 +70,20 @@ ceil_in_impl(Amounts const& amount, STAmount const& limit, bool roundUp, Quality } Amounts -Quality::ceil_in(Amounts const& amount, STAmount const& limit) const +Quality::ceilIn(Amounts const& amount, STAmount const& limit) const { - return ceil_in_impl(amount, limit, /* roundUp */ true, *this); + return ceilInImpl(amount, limit, /* roundUp */ true, *this); } Amounts -Quality::ceil_in_strict(Amounts const& amount, STAmount const& limit, bool roundUp) const +Quality::ceilInStrict(Amounts const& amount, STAmount const& limit, bool roundUp) const { - return ceil_in_impl(amount, limit, roundUp, *this); + return ceilInImpl(amount, limit, roundUp, *this); } template static Amounts -ceil_out_impl(Amounts const& amount, STAmount const& limit, bool roundUp, Quality const& quality) +ceilOutImpl(Amounts const& amount, STAmount const& limit, bool roundUp, Quality const& quality) { if (amount.out > limit) { @@ -97,43 +99,42 @@ ceil_out_impl(Amounts const& amount, STAmount const& limit, bool roundUp, Qualit } Amounts -Quality::ceil_out(Amounts const& amount, STAmount const& limit) const +Quality::ceilOut(Amounts const& amount, STAmount const& limit) const { - return ceil_out_impl(amount, limit, /* roundUp */ true, *this); + return ceilOutImpl(amount, limit, /* roundUp */ true, *this); } Amounts -Quality::ceil_out_strict(Amounts const& amount, STAmount const& limit, bool roundUp) const +Quality::ceilOutStrict(Amounts const& amount, STAmount const& limit, bool roundUp) const { - return ceil_out_impl(amount, limit, roundUp, *this); + return ceilOutImpl(amount, limit, roundUp, *this); } Quality -composed_quality(Quality const& lhs, Quality const& rhs) +composedQuality(Quality const& lhs, Quality const& rhs) { - STAmount const lhs_rate(lhs.rate()); - XRPL_ASSERT(lhs_rate != beast::zero, "xrpl::composed_quality : nonzero left input"); + STAmount const lhsRate(lhs.rate()); + XRPL_ASSERT(lhsRate != beast::kZERO, "xrpl::composed_quality : nonzero left input"); - STAmount const rhs_rate(rhs.rate()); - XRPL_ASSERT(rhs_rate != beast::zero, "xrpl::composed_quality : nonzero right input"); + STAmount const rhsRate(rhs.rate()); + XRPL_ASSERT(rhsRate != beast::kZERO, "xrpl::composed_quality : nonzero right input"); - STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.asset(), true)); + STAmount const rate(mulRound(lhsRate, rhsRate, lhsRate.asset(), true)); - std::uint64_t const stored_exponent(rate.exponent() + 100); - std::uint64_t const stored_mantissa(rate.mantissa()); + std::uint64_t const storedExponent(rate.exponent() + 100); + std::uint64_t const storedMantissa(rate.mantissa()); XRPL_ASSERT( - (stored_exponent > 0) && (stored_exponent <= 255), - "xrpl::composed_quality : valid exponent"); + (storedExponent > 0) && (storedExponent <= 255), "xrpl::composed_quality : valid exponent"); - return Quality((stored_exponent << (64 - 8)) | stored_mantissa); + return Quality((storedExponent << (64 - 8)) | storedMantissa); } Quality Quality::round(int digits) const { // Modulus for mantissa - static std::uint64_t const mod[17] = { + static std::uint64_t const kMOD[17] = { /* 0 */ 10000000000000000, /* 1 */ 1000000000000000, /* 2 */ 100000000000000, @@ -153,10 +154,10 @@ Quality::round(int digits) const /* 16 */ 1, }; - auto exponent = m_value >> (64 - 8); - auto mantissa = m_value & 0x00ffffffffffffffULL; - mantissa += mod[digits] - 1; - mantissa -= (mantissa % mod[digits]); + auto exponent = value_ >> (64 - 8); + auto mantissa = value_ & 0x00ffffffffffffffULL; + mantissa += kMOD[digits] - 1; + mantissa -= (mantissa % kMOD[digits]); return Quality{(exponent << (64 - 8)) | mantissa}; } diff --git a/src/libxrpl/protocol/QualityFunction.cpp b/src/libxrpl/protocol/QualityFunction.cpp index b460eb212f..2e9eb5745a 100644 --- a/src/libxrpl/protocol/QualityFunction.cpp +++ b/src/libxrpl/protocol/QualityFunction.cpp @@ -13,7 +13,7 @@ namespace xrpl { QualityFunction::QualityFunction(Quality const& quality, QualityFunction::CLOBLikeTag) : m_(0), b_(0), quality_(quality) { - if (quality.rate() <= beast::zero) + if (quality.rate() <= beast::kZERO) Throw("QualityFunction quality rate is 0."); b_ = 1 / quality.rate(); } @@ -30,9 +30,9 @@ QualityFunction::combine(QualityFunction const& qf) std::optional QualityFunction::outFromAvgQ(Quality const& quality) { - if (m_ != 0 && quality.rate() != beast::zero) + if (m_ != 0 && quality.rate() != beast::kZERO) { - saveNumberRoundMode const rm(Number::setround(Number::rounding_mode::upward)); + SaveNumberRoundMode const rm(Number::setround(Number::RoundingMode::Upward)); auto const out = (1 / quality.rate() - b_) / m_; if (out <= 0) return std::nullopt; diff --git a/src/libxrpl/protocol/RPCErr.cpp b/src/libxrpl/protocol/RPCErr.cpp index 99836f5e0f..66aef1470c 100644 --- a/src/libxrpl/protocol/RPCErr.cpp +++ b/src/libxrpl/protocol/RPCErr.cpp @@ -9,17 +9,17 @@ namespace xrpl { struct RPCErr; // VFALCO NOTE Deprecated function -Json::Value -rpcError(error_code_i iError) +json::Value +rpcError(ErrorCodeI iError) { - Json::Value jvResult(Json::objectValue); - RPC::inject_error(iError, jvResult); + json::Value jvResult(json::ObjectValue); + RPC::injectError(iError, jvResult); return jvResult; } // VFALCO NOTE Deprecated function bool -isRpcError(Json::Value jvResult) +isRpcError(json::Value jvResult) { return jvResult.isObject() && jvResult.isMember(jss::error); } diff --git a/src/libxrpl/protocol/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp index 490474fdb1..27b17068e3 100644 --- a/src/libxrpl/protocol/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -9,12 +9,12 @@ namespace xrpl { -Rate const parityRate(QUALITY_ONE); +Rate const kPARITY_RATE(QUALITY_ONE); namespace detail { STAmount -as_amount(Rate const& rate) +asAmount(Rate const& rate) { return {noIssue(), rate.value, -9, false}; } @@ -35,10 +35,10 @@ multiply(STAmount const& amount, Rate const& rate) { XRPL_ASSERT(rate.value, "xrpl::nft::multiply : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) return amount; - return multiply(amount, detail::as_amount(rate), amount.asset()); + return multiply(amount, detail::asAmount(rate), amount.asset()); } STAmount @@ -46,10 +46,10 @@ multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp) { XRPL_ASSERT(rate.value, "xrpl::nft::multiplyRound : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) return amount; - return mulRound(amount, detail::as_amount(rate), amount.asset(), roundUp); + return mulRound(amount, detail::asAmount(rate), amount.asset(), roundUp); } STAmount @@ -57,12 +57,12 @@ multiplyRound(STAmount const& amount, Rate const& rate, Asset const& asset, bool { XRPL_ASSERT(rate.value, "xrpl::nft::multiplyRound(Issue) : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) { return amount; } - return mulRound(amount, detail::as_amount(rate), asset, roundUp); + return mulRound(amount, detail::asAmount(rate), asset, roundUp); } STAmount @@ -70,10 +70,10 @@ divide(STAmount const& amount, Rate const& rate) { XRPL_ASSERT(rate.value, "xrpl::nft::divide : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) return amount; - return divide(amount, detail::as_amount(rate), amount.asset()); + return divide(amount, detail::asAmount(rate), amount.asset()); } STAmount @@ -81,10 +81,10 @@ divideRound(STAmount const& amount, Rate const& rate, bool roundUp) { XRPL_ASSERT(rate.value, "xrpl::nft::divideRound : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) return amount; - return divRound(amount, detail::as_amount(rate), amount.asset(), roundUp); + return divRound(amount, detail::asAmount(rate), amount.asset(), roundUp); } STAmount @@ -92,10 +92,10 @@ divideRound(STAmount const& amount, Rate const& rate, Asset const& asset, bool r { XRPL_ASSERT(rate.value, "xrpl::nft::divideRound(Issue) : nonzero rate input"); - if (rate == parityRate) + if (rate == kPARITY_RATE) return amount; - return divRound(amount, detail::as_amount(rate), asset, roundUp); + return divRound(amount, detail::asAmount(rate), asset, roundUp); } } // namespace xrpl diff --git a/src/libxrpl/protocol/Rules.cpp b/src/libxrpl/protocol/Rules.cpp index cf261a631b..2c971749b6 100644 --- a/src/libxrpl/protocol/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -21,8 +21,8 @@ namespace { LocalValue>& getCurrentTransactionRulesRef() { - static LocalValue> r; - return r; + static LocalValue> kR; + return kR; } } // namespace @@ -41,8 +41,8 @@ setCurrentTransactionRules(std::optional r) bool const enableLargeNumbers = !r || (r->enabled(featureSingleAssetVault) || r->enabled(featureLendingProtocol)); Number::setMantissaScale( - enableLargeNumbers ? MantissaRange::mantissa_scale::large - : MantissaRange::mantissa_scale::small); + enableLargeNumbers ? MantissaRange::MantissaScale::Large + : MantissaRange::MantissaScale::Small); *getCurrentTransactionRulesRef() = std::move(r); } @@ -50,17 +50,17 @@ setCurrentTransactionRules(std::optional r) class Rules::Impl { private: - std::unordered_set> set_; + std::unordered_set> set_; std::optional digest_; - std::unordered_set> const& presets_; + std::unordered_set> const& presets_; public: - explicit Impl(std::unordered_set> const& presets) : presets_(presets) + explicit Impl(std::unordered_set> const& presets) : presets_(presets) { } Impl( - std::unordered_set> const& presets, + std::unordered_set> const& presets, std::optional const& digest, STVector256 const& amendments) : digest_(digest), presets_(presets) @@ -69,7 +69,7 @@ public: set_.insert(amendments.begin(), amendments.end()); } - [[nodiscard]] std::unordered_set> const& + [[nodiscard]] std::unordered_set> const& presets() const { return presets_; @@ -98,20 +98,20 @@ public: } }; -Rules::Rules(std::unordered_set> const& presets) +Rules::Rules(std::unordered_set> const& presets) : impl_(std::make_shared(presets)) { } Rules::Rules( - std::unordered_set> const& presets, + std::unordered_set> const& presets, std::optional const& digest, STVector256 const& amendments) : impl_(std::make_shared(presets, digest, amendments)) { } -std::unordered_set> const& +std::unordered_set> const& Rules::presets() const { return impl_->presets(); diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index fd6d39bbb0..4193bb3e27 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -8,22 +8,22 @@ namespace xrpl { // Storage for static const members. -SField::IsSigning const SField::notSigning; +SField::IsSigning const SField::kNOT_SIGNING; int SField::num = 0; std::unordered_map SField::knownCodeToField; std::unordered_map SField::knownNameToField; // Give only this translation unit permission to construct SFields -struct SField::private_access_tag_t +struct SField::PrivateAccessTagT { - explicit private_access_tag_t() = default; + explicit PrivateAccessTagT() = default; }; -static SField::private_access_tag_t access; +static SField::PrivateAccessTagT access; template template -TypedField::TypedField(private_access_tag_t pat, Args&&... args) +TypedField::TypedField(PrivateAccessTagT pat, Args&&... args) : SField(pat, std::forward(args)...) { } @@ -53,12 +53,12 @@ TypedField::TypedField(private_access_tag_t pat, Args&&... args) ##__VA_ARGS__); // SFields which, for historical reasons, do not follow naming conventions. -SField const sfInvalid(access, -1, ""); -SField const sfGeneric(access, 0, "Generic"); +SField const kSF_INVALID(access, -1, ""); +SField const kSF_GENERIC(access, 0, "Generic"); // The following two fields aren't used anywhere, but they break tests/have // downstream effects. -SField const sfHash(access, STI_UINT256, 257, "hash"); -SField const sfIndex(access, STI_UINT256, 258, "index"); +SField const kSF_HASH(access, STI_UINT256, 257, "hash"); +SField const kSF_INDEX(access, STI_UINT256, 258, "index"); #include @@ -68,13 +68,13 @@ SField const sfIndex(access, STI_UINT256, 258, "index"); #pragma pop_macro("UNTYPED_SFIELD") SField::SField( - private_access_tag_t, + PrivateAccessTagT, SerializedTypeID tid, int fv, char const* fn, int meta, IsSigning signing) - : fieldCode(field_code(tid, fv)) + : fieldCodeMem(fieldCode(tid, fv)) , fieldType(tid) , fieldValue(fv) , fieldName(fn) @@ -84,30 +84,31 @@ SField::SField( , jsonName(fieldName.c_str()) { XRPL_ASSERT( - !knownCodeToField.contains(fieldCode), + !knownCodeToField.contains(fieldCodeMem), "xrpl::SField::SField(tid,fv,fn,meta,signing) : fieldCode is unique"); XRPL_ASSERT( !knownNameToField.contains(fieldName), "xrpl::SField::SField(tid,fv,fn,meta,signing) : fieldName is unique"); - knownCodeToField[fieldCode] = this; + knownCodeToField[fieldCodeMem] = this; knownNameToField[fieldName] = this; } -SField::SField(private_access_tag_t, int fc, char const* fn) - : fieldCode(fc) +SField::SField(PrivateAccessTagT, int fc, char const* fn) + : fieldCodeMem(fc) , fieldType(STI_UNKNOWN) , fieldValue(0) , fieldName(fn) - , fieldMeta(sMD_Never) + , fieldMeta(SMdNever) , fieldNum(++num) - , signingField(IsSigning::yes) + , signingField(IsSigning::Yes) , jsonName(fieldName.c_str()) { XRPL_ASSERT( - !knownCodeToField.contains(fieldCode), "xrpl::SField::SField(fc,fn) : fieldCode is unique"); + !knownCodeToField.contains(fieldCodeMem), + "xrpl::SField::SField(fc,fn) : fieldCode is unique"); XRPL_ASSERT( !knownNameToField.contains(fieldName), "xrpl::SField::SField(fc,fn) : fieldName is unique"); - knownCodeToField[fieldCode] = this; + knownCodeToField[fieldCodeMem] = this; knownNameToField[fieldName] = this; } @@ -120,20 +121,20 @@ SField::getField(int code) { return *(it->second); } - return sfInvalid; + return kSF_INVALID; } int SField::compare(SField const& f1, SField const& f2) { // -1 = f1 comes before f2, 0 = illegal combination, 1 = f1 comes after f2 - if ((f1.fieldCode <= 0) || (f2.fieldCode <= 0)) + if ((f1.fieldCodeMem <= 0) || (f2.fieldCodeMem <= 0)) return 0; - if (f1.fieldCode < f2.fieldCode) + if (f1.fieldCodeMem < f2.fieldCodeMem) return -1; - if (f2.fieldCode < f1.fieldCode) + if (f2.fieldCodeMem < f1.fieldCodeMem) return 1; return 0; @@ -148,7 +149,7 @@ SField::getField(std::string const& fieldName) { return *(it->second); } - return sfInvalid; + return kSF_INVALID; } } // namespace xrpl diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index 4266b55c98..f561c9f930 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -17,11 +17,11 @@ namespace xrpl { -STAccount::STAccount() : value_(beast::zero), default_(true) +STAccount::STAccount() : value_(beast::kZERO), default_(true) { } -STAccount::STAccount(SField const& n) : STBase(n), value_(beast::zero), default_(true) +STAccount::STAccount(SField const& n) : STBase(n), value_(beast::kZERO), default_(true) { } @@ -35,11 +35,11 @@ STAccount::STAccount(SField const& n, Buffer const& v) : STAccount(n) // STVar::STVar (SerialIter&, SField const&) // which throws. If STVar can throw in its constructor, then so can // STAccount. - if (v.size() != uint160::bytes) + if (v.size() != uint160::kBYTES) Throw("Invalid STAccount size"); default_ = false; - memcpy(value_.begin(), v.data(), uint160::bytes); + memcpy(value_.begin(), v.data(), uint160::kBYTES); } STAccount::STAccount(SerialIter& sit, SField const& name) : STAccount(name, sit.getVLBuffer()) @@ -77,7 +77,7 @@ STAccount::add(Serializer& s) const // Preserve the serialization behavior of an STBlob: // o If we are default (all zeros) serialize as an empty blob. // o Otherwise serialize 160 bits. - int const size = isDefault() ? 0 : uint160::bytes; + int const size = isDefault() ? 0 : uint160::kBYTES; s.addVL(value_.data(), size); } diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 654bcf1be4..25857d387e 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -47,9 +47,9 @@ namespace xrpl { -static std::uint64_t const tenTo14 = 100000000000000ull; -static std::uint64_t const tenTo14m1 = tenTo14 - 1; -static std::uint64_t const tenTo17 = tenTo14 * 1000; +static std::uint64_t const kTEN_TO14 = 100000000000000ull; +static std::uint64_t const kTEN_TO14M1 = kTEN_TO14 - 1; +static std::uint64_t const kTEN_TO17 = kTEN_TO14 * 1000; //------------------------------------------------------------------------------ static std::int64_t @@ -88,11 +88,11 @@ areComparable(STAmount const& v1, STAmount const& v2) { return std::visit( [&](TIss1 const& issue1, TIss2 const& issue2) { - if constexpr (is_issue_v && is_issue_v) + if constexpr (kIS_ISSUE_V && kIS_ISSUE_V) { return v1.native() == v2.native() && issue1.currency == issue2.currency; } - else if constexpr (is_mptissue_v && is_mptissue_v) + else if constexpr (kIS_MPTISSUE_V && kIS_MPTISSUE_V) { return issue1 == issue2; } @@ -105,32 +105,32 @@ areComparable(STAmount const& v1, STAmount const& v2) v2.asset().value()); } -static_assert(INITIAL_XRP.drops() == STAmount::cMaxNativeN); +static_assert(kINITIAL_XRP.drops() == STAmount::kMAX_NATIVE_N); STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name) { std::uint64_t value = sit.get64(); // native or MPT - if ((value & cIssuedCurrency) == 0) + if ((value & kISSUED_CURRENCY) == 0) { - if ((value & cMPToken) != 0) + if ((value & kMP_TOKEN) != 0) { // is MPT - mOffset = 0; - mIsNegative = (value & cPositive) == 0; - mValue = (value << 8) | sit.get8(); - mAsset = sit.get192(); + offset_ = 0; + isNegative_ = (value & kPOSITIVE) == 0; + value_ = (value << 8) | sit.get8(); + asset_ = sit.get192(); return; } // else is XRP - mAsset = xrpIssue(); + asset_ = xrpIssue(); // positive - if ((value & cPositive) != 0) + if ((value & kPOSITIVE) != 0) { - mValue = value & cValueMask; - mOffset = 0; - mIsNegative = false; + value_ = value & kVALUE_MASK; + offset_ = 0; + isNegative_ = false; return; } @@ -138,9 +138,9 @@ STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name) if (value == 0) Throw("negative zero is not canonical"); - mValue = value & cValueMask; - mOffset = 0; - mIsNegative = true; + value_ = value & kVALUE_MASK; + offset_ = 0; + isNegative_ = true; return; } @@ -165,15 +165,16 @@ STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name) bool const isNegative = (offset & 256) == 0; offset = (offset & 255) - 97; // center the range - if (value < cMinValue || value > cMaxValue || offset < cMinOffset || offset > cMaxOffset) + if (value < kMIN_VALUE || value > kMAX_VALUE || offset < kMIN_OFFSET || + offset > kMAX_OFFSET) { Throw("invalid currency value"); } - mAsset = issue; - mValue = value; - mOffset = offset; - mIsNegative = isNegative; + asset_ = issue; + value_ = value; + offset_ = offset; + isNegative_ = isNegative; canonicalize(); return; } @@ -181,37 +182,37 @@ STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name) if (offset != 512) Throw("invalid currency value"); - mAsset = issue; - mValue = 0; - mOffset = 0; - mIsNegative = false; + asset_ = issue; + value_ = 0; + offset_ = 0; + isNegative_ = false; canonicalize(); } STAmount::STAmount(SField const& name, std::int64_t mantissa) - : STBase(name), mAsset(xrpIssue()), mOffset(0) + : STBase(name), asset_(xrpIssue()), offset_(0) { set(mantissa); } STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative) - : STBase(name), mAsset(xrpIssue()), mValue(mantissa), mOffset(0), mIsNegative(negative) + : STBase(name), asset_(xrpIssue()), value_(mantissa), offset_(0), isNegative_(negative) { XRPL_ASSERT( - mValue <= std::numeric_limits::max(), + value_ <= std::numeric_limits::max(), "xrpl::STAmount::STAmount(SField, std::uint64_t, bool) : maximum " "mantissa input"); } STAmount::STAmount(SField const& name, STAmount const& from) : STBase(name) - , mAsset(from.mAsset) - , mValue(from.mValue) - , mOffset(from.mOffset) - , mIsNegative(from.mIsNegative) + , asset_(from.asset_) + , value_(from.value_) + , offset_(from.offset_) + , isNegative_(from.isNegative_) { XRPL_ASSERT( - mValue <= std::numeric_limits::max(), + value_ <= std::numeric_limits::max(), "xrpl::STAmount::STAmount(SField, STAmount) : maximum input"); canonicalize(); } @@ -219,24 +220,24 @@ STAmount::STAmount(SField const& name, STAmount const& from) //------------------------------------------------------------------------------ STAmount::STAmount(std::uint64_t mantissa, bool negative) - : mAsset(xrpIssue()), mValue(mantissa), mOffset(0), mIsNegative(mantissa != 0 && negative) + : asset_(xrpIssue()), value_(mantissa), offset_(0), isNegative_(mantissa != 0 && negative) { XRPL_ASSERT( - mValue <= std::numeric_limits::max(), + value_ <= std::numeric_limits::max(), "xrpl::STAmount::STAmount(std::uint64_t, bool) : maximum mantissa " "input"); } STAmount::STAmount(XRPAmount const& amount) - : mAsset(xrpIssue()), mOffset(0), mIsNegative(amount < beast::zero) + : asset_(xrpIssue()), offset_(0), isNegative_(amount < beast::kZERO) { - if (mIsNegative) + if (isNegative_) { - mValue = unsafe_cast(-amount.drops()); + value_ = unsafeCast(-amount.drops()); } else { - mValue = unsafe_cast(amount.drops()); + value_ = unsafeCast(amount.drops()); } canonicalize(); @@ -271,10 +272,10 @@ STAmount::xrp() const if (!native()) Throw("Cannot return non-native STAmount as XRPAmount"); - auto drops = static_cast(mValue); - XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::xrp : amount is canonical"); + auto drops = static_cast(value_); + XRPL_ASSERT(offset_ == 0, "xrpl::STAmount::xrp : amount is canonical"); - if (mIsNegative) + if (isNegative_) drops = -drops; return XRPAmount{drops}; @@ -286,10 +287,10 @@ STAmount::iou() const if (integral()) Throw("Cannot return non-IOU STAmount as IOUAmount"); - auto mantissa = static_cast(mValue); - auto exponent = mOffset; + auto mantissa = static_cast(value_); + auto exponent = offset_; - if (mIsNegative) + if (isNegative_) mantissa = -mantissa; return {mantissa, exponent}; @@ -301,10 +302,10 @@ STAmount::mpt() const if (!holds()) Throw("Cannot return STAmount as MPTAmount"); - auto value = static_cast(mValue); - XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::mpt : amount is canonical"); + auto value = static_cast(value_); + XRPL_ASSERT(offset_ == 0, "xrpl::STAmount::mpt : amount is canonical"); - if (mIsNegative) + if (isNegative_) value = -value; return MPTAmount{value}; @@ -314,15 +315,15 @@ STAmount& STAmount::operator=(IOUAmount const& iou) { XRPL_ASSERT(integral() == false, "xrpl::STAmount::operator=(IOUAmount) : is not integral"); - mOffset = iou.exponent(); - mIsNegative = iou < beast::zero; - if (mIsNegative) + offset_ = iou.exponent(); + isNegative_ = iou < beast::kZERO; + if (isNegative_) { - mValue = static_cast(-iou.mantissa()); + value_ = static_cast(-iou.mantissa()); } else { - mValue = static_cast(iou.mantissa()); + value_ = static_cast(iou.mantissa()); } return *this; } @@ -333,14 +334,14 @@ STAmount::operator=(Number const& number) if (!getCurrentTransactionRules() || isFeatureEnabled(featureSingleAssetVault) || isFeatureEnabled(featureLendingProtocol)) { - *this = fromNumber(mAsset, number); + *this = fromNumber(asset_, number); } else { auto const originalMantissa = number.mantissa(); - mIsNegative = originalMantissa < 0; - mValue = mIsNegative ? -originalMantissa : originalMantissa; - mOffset = number.exponent(); + isNegative_ = originalMantissa < 0; + value_ = isNegative_ ? -originalMantissa : originalMantissa; + offset_ = number.exponent(); } canonicalize(); return *this; @@ -372,10 +373,10 @@ operator+(STAmount const& v1, STAmount const& v2) if (!areComparable(v1, v2)) Throw("Can't add amounts that are't comparable!"); - if (v2 == beast::zero) + if (v2 == beast::kZERO) return v1; - if (v1 == beast::zero) + if (v1 == beast::kZERO) { // Result must be in terms of v1 currency and issuer. return {v1.getFName(), v1.asset(), v2.mantissa(), v2.exponent(), v2.negative()}; @@ -384,7 +385,7 @@ operator+(STAmount const& v1, STAmount const& v2) if (v1.native()) return {v1.getFName(), getSNValue(v1) + getSNValue(v2)}; if (v1.holds()) - return {v1.mAsset, v1.mpt().value() + v2.mpt().value()}; + return {v1.asset_, v1.mpt().value() + v2.mpt().value()}; if (getSTNumberSwitchover()) { @@ -437,12 +438,12 @@ operator-(STAmount const& v1, STAmount const& v2) //------------------------------------------------------------------------------ -std::uint64_t const STAmount::uRateOne = getRate(STAmount(1), STAmount(1)); +std::uint64_t const STAmount::kU_RATE_ONE = getRate(STAmount(1), STAmount(1)); void STAmount::setIssue(Asset const& asset) { - mAsset = asset; + asset_ = asset; } // Convert an offer into an index amount so they sort by rate. @@ -457,13 +458,13 @@ STAmount::setIssue(Asset const& asset) std::uint64_t getRate(STAmount const& offerOut, STAmount const& offerIn) { - if (offerOut == beast::zero) + if (offerOut == beast::kZERO) return 0; try { STAmount const r = divide(offerIn, offerOut, noIssue()); - if (r == beast::zero) // offer is too good + if (r == beast::kZERO) // offer is too good return 0; XRPL_ASSERT( (r.exponent() >= -100) && (r.exponent() <= 155), @@ -504,45 +505,45 @@ canAdd(STAmount const& a, STAmount const& b) return false; // special case: adding anything to zero is always fine - if (a == beast::zero || b == beast::zero) + if (a == beast::kZERO || b == beast::kZERO) return true; // XRP case (overflow & underflow check) if (isXRP(a) && isXRP(b)) { - XRPAmount const A = a.xrp(); - XRPAmount const B = b.xrp(); + XRPAmount const aVal = a.xrp(); + XRPAmount const bVal = b.xrp(); return !( - (B > XRPAmount{0} && - A > XRPAmount{std::numeric_limits::max()} - B) || - (B < XRPAmount{0} && - A < XRPAmount{std::numeric_limits::min()} - B)); + (bVal > XRPAmount{0} && + aVal > XRPAmount{std::numeric_limits::max()} - bVal) || + (bVal < XRPAmount{0} && + aVal < XRPAmount{std::numeric_limits::min()} - bVal)); } // IOU case (precision check) auto const ret = std::visit( [&]( TIss1 const&, TIss2 const&) -> std::optional { - if constexpr (is_issue_v && is_issue_v) + if constexpr (kIS_ISSUE_V && kIS_ISSUE_V) { - static STAmount const one{IOUAmount{1, 0}, noIssue()}; - static STAmount const maxLoss{IOUAmount{1, -4}, noIssue()}; - STAmount const lhs = divide((a - b) + b, a, noIssue()) - one; - STAmount const rhs = divide((b - a) + a, b, noIssue()) - one; - return ((rhs.negative() ? -rhs : rhs) + (lhs.negative() ? -lhs : lhs)) <= maxLoss; + static STAmount const kONE{IOUAmount{1, 0}, noIssue()}; + static STAmount const kMAX_LOSS{IOUAmount{1, -4}, noIssue()}; + STAmount const lhs = divide((a - b) + b, a, noIssue()) - kONE; + STAmount const rhs = divide((b - a) + a, b, noIssue()) - kONE; + return ((rhs.negative() ? -rhs : rhs) + (lhs.negative() ? -lhs : lhs)) <= kMAX_LOSS; } // MPT (overflow & underflow check) - if constexpr (is_mptissue_v && is_mptissue_v) + if constexpr (kIS_MPTISSUE_V && kIS_MPTISSUE_V) { - MPTAmount const A = a.mpt(); - MPTAmount const B = b.mpt(); + MPTAmount const aVal = a.mpt(); + MPTAmount const bVal = b.mpt(); return !( - (B > MPTAmount{0} && - A > MPTAmount{std::numeric_limits::max()} - B) || - (B < MPTAmount{0} && - A < MPTAmount{std::numeric_limits::min()} - B)); + (bVal > MPTAmount{0} && + aVal > MPTAmount{std::numeric_limits::max()} - bVal) || + (bVal < MPTAmount{0} && + aVal < MPTAmount{std::numeric_limits::min()} - bVal)); } return std::nullopt; }, @@ -581,21 +582,21 @@ canSubtract(STAmount const& a, STAmount const& b) return false; // Special case: subtracting zero is always fine - if (b == beast::zero) + if (b == beast::kZERO) return true; // XRP case (underflow & overflow check) if (isXRP(a) && isXRP(b)) { - XRPAmount const A = a.xrp(); - XRPAmount const B = b.xrp(); + XRPAmount const aVal = a.xrp(); + XRPAmount const bVal = b.xrp(); // Check for underflow - if (B > XRPAmount{0} && A < B) + if (bVal > XRPAmount{0} && aVal < bVal) return false; // Check for overflow - if (B < XRPAmount{0} && - A > XRPAmount{std::numeric_limits::max()} + B) + if (bVal < XRPAmount{0} && + aVal > XRPAmount{std::numeric_limits::max()} + bVal) return false; return true; @@ -605,24 +606,24 @@ canSubtract(STAmount const& a, STAmount const& b) auto const ret = std::visit( [&]( TIss1 const&, TIss2 const&) -> std::optional { - if constexpr (is_issue_v && is_issue_v) + if constexpr (kIS_ISSUE_V && kIS_ISSUE_V) { return true; } // MPT case (underflow & overflow check) - if constexpr (is_mptissue_v && is_mptissue_v) + if constexpr (kIS_MPTISSUE_V && kIS_MPTISSUE_V) { - MPTAmount const A = a.mpt(); - MPTAmount const B = b.mpt(); + MPTAmount const aVal = a.mpt(); + MPTAmount const bVal = b.mpt(); // Underflow check - if (B > MPTAmount{0} && A < B) + if (bVal > MPTAmount{0} && aVal < bVal) return false; // Overflow check - if (B < MPTAmount{0} && - A > MPTAmount{std::numeric_limits::max()} + B) + if (bVal < MPTAmount{0} && + aVal > MPTAmount{std::numeric_limits::max()} + bVal) return false; return true; } @@ -639,16 +640,16 @@ canSubtract(STAmount const& a, STAmount const& b) } void -STAmount::setJson(Json::Value& elem) const +STAmount::setJson(json::Value& elem) const { - elem = Json::objectValue; + elem = json::ObjectValue; if (!native()) { // It is an error for currency or issuer not to be specified for valid // json. elem[jss::value] = getText(); - mAsset.setJson(elem); + asset_.setJson(elem); } else { @@ -674,7 +675,7 @@ STAmount::getFullText() const std::string ret; ret.reserve(64); - ret = getText() + "/" + mAsset.getText(); + ret = getText() + "/" + asset_.getText(); return ret; } @@ -682,94 +683,94 @@ std::string STAmount::getText() const { // keep full internal accuracy, but make more human friendly if possible - if (*this == beast::zero) + if (*this == beast::kZERO) return "0"; - std::string const raw_value(std::to_string(mValue)); + std::string const rawValue(std::to_string(value_)); std::string ret; - if (mIsNegative) + if (isNegative_) ret.append(1, '-'); - bool const scientific((mOffset != 0) && ((mOffset < -25) || (mOffset > -5))); + bool const scientific((offset_ != 0) && ((offset_ < -25) || (offset_ > -5))); - if (native() || mAsset.holds() || scientific) + if (native() || asset_.holds() || scientific) { - ret.append(raw_value); + ret.append(rawValue); if (scientific) { ret.append(1, 'e'); - ret.append(std::to_string(mOffset)); + ret.append(std::to_string(offset_)); } return ret; } - XRPL_ASSERT(mOffset + 43 > 0, "xrpl::STAmount::getText : minimum offset"); + XRPL_ASSERT(offset_ + 43 > 0, "xrpl::STAmount::getText : minimum offset"); - size_t const pad_prefix = 27; - size_t const pad_suffix = 23; + size_t const padPrefix = 27; + size_t const padSuffix = 23; std::string val; - val.reserve(raw_value.length() + pad_prefix + pad_suffix); - val.append(pad_prefix, '0'); - val.append(raw_value); - val.append(pad_suffix, '0'); + val.reserve(rawValue.length() + padPrefix + padSuffix); + val.append(padPrefix, '0'); + val.append(rawValue); + val.append(padSuffix, '0'); - size_t const offset(mOffset + 43); + size_t const offset(offset_ + 43); - auto pre_from(val.begin()); - auto const pre_to(val.begin() + offset); + auto preFrom(val.begin()); + auto const preTo(val.begin() + offset); - auto const post_from(val.begin() + offset); - auto post_to(val.end()); + auto const postFrom(val.begin() + offset); + auto postTo(val.end()); // Crop leading zeroes. Take advantage of the fact that there's always a // fixed amount of leading zeroes and skip them. - if (std::distance(pre_from, pre_to) > pad_prefix) - pre_from += pad_prefix; + if (std::distance(preFrom, preTo) > padPrefix) + preFrom += padPrefix; - XRPL_ASSERT(post_to >= post_from, "xrpl::STAmount::getText : first distance check"); + XRPL_ASSERT(postTo >= postFrom, "xrpl::STAmount::getText : first distance check"); - pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); + preFrom = std::find_if(preFrom, preTo, [](char c) { return c != '0'; }); // Crop trailing zeroes. Take advantage of the fact that there's always a // fixed amount of trailing zeroes and skip them. - if (std::distance(post_from, post_to) > pad_suffix) - post_to -= pad_suffix; + if (std::distance(postFrom, postTo) > padSuffix) + postTo -= padSuffix; - XRPL_ASSERT(post_to >= post_from, "xrpl::STAmount::getText : second distance check"); + XRPL_ASSERT(postTo >= postFrom, "xrpl::STAmount::getText : second distance check"); - post_to = std::find_if( - std::make_reverse_iterator(post_to), - std::make_reverse_iterator(post_from), - [](char c) { return c != '0'; }) - .base(); + postTo = std::find_if( + std::make_reverse_iterator(postTo), + std::make_reverse_iterator(postFrom), + [](char c) { return c != '0'; }) + .base(); // Assemble the output: - if (pre_from == pre_to) + if (preFrom == preTo) { ret.append(1, '0'); } else { - ret.append(pre_from, pre_to); + ret.append(preFrom, preTo); } - if (post_to != post_from) + if (postTo != postFrom) { ret.append(1, '.'); - ret.append(post_from, post_to); + ret.append(postFrom, postTo); } return ret; } -Json::Value +json::Value STAmount::getJson(JsonOptions) const { - Json::Value elem; + json::Value elem; setJson(elem); return elem; } @@ -777,44 +778,44 @@ STAmount::getJson(JsonOptions) const void STAmount::add(Serializer& s) const { - mAsset.visit( + asset_.visit( [&](MPTIssue const& issue) { - auto u8 = static_cast(cMPToken >> 56); - if (!mIsNegative) - u8 |= static_cast(cPositive >> 56); + auto u8 = static_cast(kMP_TOKEN >> 56); + if (!isNegative_) + u8 |= static_cast(kPOSITIVE >> 56); s.add8(u8); - s.add64(mValue); + s.add64(value_); s.addBitString(issue.getMptID()); }, [&](Issue const& issue) { if (native()) { - XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::add : zero offset"); + XRPL_ASSERT(offset_ == 0, "xrpl::STAmount::add : zero offset"); - if (!mIsNegative) + if (!isNegative_) { - s.add64(mValue | cPositive); + s.add64(value_ | kPOSITIVE); } else { - s.add64(mValue); + s.add64(value_); } } else { - if (*this == beast::zero) + if (*this == beast::kZERO) { - s.add64(cIssuedCurrency); + s.add64(kISSUED_CURRENCY); } - else if (mIsNegative) // 512 = not native + else if (isNegative_) // 512 = not native { - s.add64(mValue | (static_cast(mOffset + 512 + 97) << (64 - 10))); + s.add64(value_ | (static_cast(offset_ + 512 + 97) << (64 - 10))); } else // 256 = positive { s.add64( - mValue | - (static_cast(mOffset + 512 + 256 + 97) << (64 - 10))); + value_ | + (static_cast(offset_ + 512 + 256 + 97) << (64 - 10))); } s.addBitString(issue.currency); s.addBitString(issue.account); @@ -832,27 +833,27 @@ STAmount::isEquivalent(STBase const& t) const bool STAmount::isDefault() const { - return (mValue == 0) && native(); + return (value_ == 0) && native(); } //------------------------------------------------------------------------------ -// amount = mValue * [10 ^ mOffset] +// amount = value_ * [10 ^ offset_] // Representation range is 10^80 - 10^(-80). // // On the wire: // - high bit is 0 for XRP, 1 for issued currency // - next bit is 1 for positive, 0 for negative (except 0 issued currency, which // is a special case of 0x8000000000000000 -// - for issued currencies, the next 8 bits are (mOffset+97). +// - for issued currencies, the next 8 bits are (offset_+97). // The +97 is so that this value is always positive. // - The remaining bits are significant digits (mantissa) // That's 54 bits for issued currency and 62 bits for native // (but XRP only needs 57 bits for the max value of 10^17 drops) // -// mValue is zero if the amount is zero, otherwise it's within the range +// value_ is zero if the amount is zero, otherwise it's within the range // 10^15 to (10^16 - 1) inclusive. -// mOffset is in the range -96 to +80. +// offset_ is in the range -96 to +80. void STAmount::canonicalize() { @@ -860,34 +861,34 @@ STAmount::canonicalize() { // native and MPT currency amounts should always have an offset of zero // log(2^64,10) ~ 19.2 - if (mValue == 0 || mOffset <= -20) + if (value_ == 0 || offset_ <= -20) { - mValue = 0; - mOffset = 0; - mIsNegative = false; + value_ = 0; + offset_ = 0; + isNegative_ = false; return; } // log(cMaxNativeN, 10) == 17 - if (native() && mOffset > 17) + if (native() && offset_ > 17) Throw("Native currency amount out of range"); // log(maxMPTokenAmount, 10) ~ 18.96 - if (mAsset.holds() && mOffset > 18) + if (asset_.holds() && offset_ > 18) Throw("MPT amount out of range"); if (getSTNumberSwitchover()) { - Number const num(mIsNegative, mValue, mOffset, Number::unchecked{}); + Number const num(isNegative_, value_, offset_, Number::Unchecked{}); auto set = [&](auto const& val) { auto const value = val.value(); - mIsNegative = value < 0; - mValue = mIsNegative ? -value : value; + isNegative_ = value < 0; + value_ = isNegative_ ? -value : value; }; if (native()) { set(XRPAmount{num}); } - else if (mAsset.holds()) + else if (asset_.holds()) { set(MPTAmount{num}); } @@ -895,39 +896,39 @@ STAmount::canonicalize() { Throw("Unknown integral asset type"); } - mOffset = 0; + offset_ = 0; } else { - while (mOffset < 0) + while (offset_ < 0) { - mValue /= 10; - ++mOffset; + value_ /= 10; + ++offset_; } - while (mOffset > 0) + while (offset_ > 0) { // N.B. do not move the overflow check to after the // multiplication - if (native() && mValue > cMaxNativeN) + if (native() && value_ > kMAX_NATIVE_N) { Throw("Native currency amount out of range"); } - else if (!native() && mValue > maxMPTokenAmount) + else if (!native() && value_ > kMAX_MP_TOKEN_AMOUNT) { Throw("MPT amount out of range"); } - mValue *= 10; - --mOffset; + value_ *= 10; + --offset_; } } - if (native() && mValue > cMaxNativeN) + if (native() && value_ > kMAX_NATIVE_N) { Throw("Native currency amount out of range"); } - else if (!native() && mValue > maxMPTokenAmount) + else if (!native() && value_ > kMAX_MP_TOKEN_AMOUNT) { Throw("MPT amount out of range"); } @@ -941,47 +942,47 @@ STAmount::canonicalize() return; } - if (mValue == 0) + if (value_ == 0) { - mOffset = -100; - mIsNegative = false; + offset_ = -100; + isNegative_ = false; return; } - while ((mValue < cMinValue) && (mOffset > cMinOffset)) + while ((value_ < kMIN_VALUE) && (offset_ > kMIN_OFFSET)) { - mValue *= 10; - --mOffset; + value_ *= 10; + --offset_; } - while (mValue > cMaxValue) + while (value_ > kMAX_VALUE) { - if (mOffset >= cMaxOffset) + if (offset_ >= kMAX_OFFSET) Throw("value overflow"); - mValue /= 10; - ++mOffset; + value_ /= 10; + ++offset_; } - if ((mOffset < cMinOffset) || (mValue < cMinValue)) + if ((offset_ < kMIN_OFFSET) || (value_ < kMIN_VALUE)) { - mValue = 0; - mIsNegative = false; - mOffset = -100; + value_ = 0; + isNegative_ = false; + offset_ = -100; return; } - if (mOffset > cMaxOffset) + if (offset_ > kMAX_OFFSET) Throw("value overflow"); XRPL_ASSERT( - (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)), + (value_ == 0) || ((value_ >= kMIN_VALUE) && (value_ <= kMAX_VALUE)), "xrpl::STAmount::canonicalize : value inside range"); XRPL_ASSERT( - (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)), + (value_ == 0) || ((offset_ >= kMIN_OFFSET) && (offset_ <= kMAX_OFFSET)), "xrpl::STAmount::canonicalize : offset inside range"); XRPL_ASSERT( - (mValue != 0) || (mOffset != -100), "xrpl::STAmount::canonicalize : value or offset set"); + (value_ != 0) || (offset_ != -100), "xrpl::STAmount::canonicalize : value or offset set"); } void @@ -989,13 +990,13 @@ STAmount::set(std::int64_t v) { if (v < 0) { - mIsNegative = true; - mValue = static_cast(-v); + isNegative_ = true; + value_ = static_cast(-v); } else { - mIsNegative = false; - mValue = static_cast(v); + isNegative_ = false; + value_ = static_cast(v); } } @@ -1023,13 +1024,13 @@ amountFromString(Asset const& asset, std::string const& amount) } STAmount -amountFromJson(SField const& name, Json::Value const& v) +amountFromJson(SField const& name, json::Value const& v) { Asset asset; - Json::Value value; - Json::Value currencyOrMPTID; - Json::Value issuer; + json::Value value; + json::Value currencyOrMPTID; + json::Value issuer; bool isMPT = false; if (v.isNull()) @@ -1055,9 +1056,9 @@ amountFromJson(SField const& name, Json::Value const& v) } else if (v.isArray()) { - value = v.get(Json::UInt(0), 0); - currencyOrMPTID = v.get(Json::UInt(1), Json::nullValue); - issuer = v.get(Json::UInt(2), Json::nullValue); + value = v.get(json::UInt(0), 0); + currencyOrMPTID = v.get(json::UInt(1), json::NullValue); + issuer = v.get(json::UInt(2), json::NullValue); } else if (v.isString()) { @@ -1103,9 +1104,9 @@ amountFromJson(SField const& name, Json::Value const& v) else { Issue issue; - if (!to_currency(issue.currency, currencyOrMPTID.asString())) + if (!toCurrency(issue.currency, currencyOrMPTID.asString())) Throw("invalid currency"); - if (!issuer.isString() || !to_issuer(issue.account, issuer.asString())) + if (!issuer.isString() || !toIssuer(issue.account, issuer.asString())) Throw("invalid issuer"); if (issue.native()) Throw("invalid issuer"); @@ -1147,11 +1148,11 @@ amountFromJson(SField const& name, Json::Value const& v) } bool -amountFromJsonNoThrow(STAmount& result, Json::Value const& jvSource) +amountFromJsonNoThrow(STAmount& result, json::Value const& jvSource) { try { - result = amountFromJson(sfGeneric, jvSource); + result = amountFromJson(kSF_GENERIC, jvSource); return true; } catch (std::exception const& e) @@ -1219,7 +1220,7 @@ operator-(STAmount const& value) value.mantissa(), value.exponent(), !value.negative(), - STAmount::unchecked{}); + STAmount::Unchecked{}); } //------------------------------------------------------------------------------ @@ -1249,7 +1250,7 @@ muldiv(std::uint64_t multiplier, std::uint64_t multiplicand, std::uint64_t divis } static std::uint64_t -muldiv_round( +muldivRound( std::uint64_t multiplier, std::uint64_t multiplicand, std::uint64_t divisor, @@ -1274,10 +1275,10 @@ muldiv_round( STAmount divide(STAmount const& num, STAmount const& den, Asset const& asset) { - if (den == beast::zero) + if (den == beast::kZERO) Throw("division by zero"); - if (num == beast::zero) + if (num == beast::kZERO) return {asset}; std::uint64_t numVal = num.mantissa(); @@ -1287,7 +1288,7 @@ divide(STAmount const& num, STAmount const& den, Asset const& asset) if (num.integral()) { - while (numVal < STAmount::cMinValue) + while (numVal < STAmount::kMIN_VALUE) { // Need to bring into range numVal *= 10; @@ -1297,7 +1298,7 @@ divide(STAmount const& num, STAmount const& den, Asset const& asset) if (den.integral()) { - while (denVal < STAmount::cMinValue) + while (denVal < STAmount::kMIN_VALUE) { denVal *= 10; --denOffset; @@ -1311,7 +1312,7 @@ divide(STAmount const& num, STAmount const& den, Asset const& asset) // is in the range of 10^16 to 10^15. return STAmount( asset, - muldiv(numVal, tenTo17, denVal) + 5, + muldiv(numVal, kTEN_TO17, denVal) + 5, numOffset - denOffset - 17, num.negative() != den.negative()); } @@ -1319,7 +1320,7 @@ divide(STAmount const& num, STAmount const& den, Asset const& asset) STAmount multiply(STAmount const& v1, STAmount const& v2, Asset const& asset) { - if (v1 == beast::zero || v2 == beast::zero) + if (v1 == beast::kZERO || v2 == beast::kZERO) return STAmount(asset); if (v1.native() && v2.native() && asset.native()) @@ -1362,7 +1363,7 @@ multiply(STAmount const& v1, STAmount const& v2, Asset const& asset) if (v1.integral()) { - while (value1 < STAmount::cMinValue) + while (value1 < STAmount::kMIN_VALUE) { value1 *= 10; --offset1; @@ -1371,7 +1372,7 @@ multiply(STAmount const& v1, STAmount const& v2, Asset const& asset) if (v2.integral()) { - while (value2 < STAmount::cMinValue) + while (value2 < STAmount::kMIN_VALUE) { value2 *= 10; --offset2; @@ -1384,7 +1385,7 @@ multiply(STAmount const& v1, STAmount const& v2, Asset const& asset) // precision, by scaling the result to 10^16 to 10^18. return STAmount( asset, - muldiv(value1, value2, tenTo14) + 7, + muldiv(value1, value2, kTEN_TO14) + 7, offset1 + offset2 + 14, v1.negative() != v2.negative()); } @@ -1430,9 +1431,9 @@ canonicalizeRound(bool integral, std::uint64_t& value, int& offset, bool) ++offset; } } - else if (value > STAmount::cMaxValue) + else if (value > STAmount::kMAX_VALUE) { - while (value > (10 * STAmount::cMaxValue)) + while (value > (10 * STAmount::kMAX_VALUE)) { value /= 10; ++offset; @@ -1472,9 +1473,9 @@ canonicalizeRoundStrict(bool integral, std::uint64_t& value, int& offset, bool r ++offset; } } - else if (value > STAmount::cMaxValue) + else if (value > STAmount::kMAX_VALUE) { - while (value > (10 * STAmount::cMaxValue)) + while (value > (10 * STAmount::kMAX_VALUE)) { value /= 10; ++offset; @@ -1486,14 +1487,14 @@ canonicalizeRoundStrict(bool integral, std::uint64_t& value, int& offset, bool r } STAmount -roundToScale(STAmount const& value, std::int32_t scale, Number::rounding_mode rounding) +roundToScale(STAmount const& value, std::int32_t scale, Number::RoundingMode rounding) { // Nothing to do for integral types. if (value.integral()) return value; // Nothing to do for zero. - if (value == beast::zero) + if (value == beast::kZERO) return value; // If the value's exponent is greater than or equal to the scale, then @@ -1502,7 +1503,7 @@ roundToScale(STAmount const& value, std::int32_t scale, Number::rounding_mode ro if (value.exponent() >= scale) return value; - STAmount const referenceValue{value.asset(), STAmount::cMinValue, scale, value.negative()}; + STAmount const referenceValue{value.asset(), STAmount::kMIN_VALUE, scale, value.negative()}; NumberRoundModeGuard const mg(rounding); // With an IOU, the the result of addition will be truncated to the @@ -1519,7 +1520,7 @@ namespace { class DontAffectNumberRoundMode { public: - explicit DontAffectNumberRoundMode(Number::rounding_mode mode) noexcept + explicit DontAffectNumberRoundMode(Number::RoundingMode mode) noexcept { } @@ -1539,7 +1540,7 @@ template static STAmount divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool roundUp) { - if (den == beast::zero) + if (den == beast::kZERO) Throw("division by zero"); - if (num == beast::zero) + if (num == beast::kZERO) return {asset}; std::uint64_t numVal = num.mantissa(), denVal = den.mantissa(); @@ -1664,7 +1665,7 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool if (num.integral()) { - while (numVal < STAmount::cMinValue) + while (numVal < STAmount::kMIN_VALUE) { numVal *= 10; --numOffset; @@ -1673,7 +1674,7 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool if (den.integral()) { - while (denVal < STAmount::cMinValue) + while (denVal < STAmount::kMIN_VALUE) { denVal *= 10; --denOffset; @@ -1691,7 +1692,7 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool // We round away from zero if we're rounding up or // truncate if we're rounding down. std::uint64_t amount = - muldiv_round(numVal, tenTo17, denVal, (resultNegative != roundUp) ? denVal - 1 : 0); + muldivRound(numVal, kTEN_TO17, denVal, (resultNegative != roundUp) ? denVal - 1 : 0); int offset = numOffset - denOffset - 17; @@ -1702,8 +1703,8 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool // If appropriate, tell Number the rounding mode we are using. // Note that "roundUp == true" actually means "round away from zero". // Otherwise, round toward zero. - using enum Number::rounding_mode; - MightSaveRound const savedRound(roundUp ^ resultNegative ? upward : downward); + using enum Number::RoundingMode; + MightSaveRound const savedRound(roundUp ^ resultNegative ? Upward : Downward); return STAmount(asset, amount, offset, resultNegative); }(); @@ -1718,8 +1719,8 @@ divRoundImpl(STAmount const& num, STAmount const& den, Asset const& asset, bool else { // return the smallest value above zero - amount = STAmount::cMinValue; - offset = STAmount::cMinOffset; + amount = STAmount::kMIN_VALUE; + offset = STAmount::kMIN_OFFSET; } return STAmount(asset, amount, offset, resultNegative); } diff --git a/src/libxrpl/protocol/STArray.cpp b/src/libxrpl/protocol/STArray.cpp index 8e841c1fbb..537cb36630 100644 --- a/src/libxrpl/protocol/STArray.cpp +++ b/src/libxrpl/protocol/STArray.cpp @@ -127,15 +127,15 @@ STArray::getText() const return r; } -Json::Value +json::Value STArray::getJson(JsonOptions p) const { - Json::Value v = Json::arrayValue; + json::Value v = json::ArrayValue; for (auto const& object : v_) { if (object.getSType() != STI_NOTPRESENT) { - Json::Value& inner = v.append(Json::objectValue); + json::Value& inner = v.append(json::ObjectValue); inner[object.getFName().getJsonName()] = object.getJson(p); } } diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index b3558e1b08..ec6131482f 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -12,13 +12,13 @@ namespace xrpl { -STBase::STBase() : fName(&sfGeneric) +STBase::STBase() : fName_(&kSF_GENERIC) { } -STBase::STBase(SField const& n) : fName(&n) +STBase::STBase(SField const& n) : fName_(&n) { - XRPL_ASSERT(fName, "xrpl::STBase::STBase : field is set"); + XRPL_ASSERT(fName_, "xrpl::STBase::STBase : field is set"); } STBase& @@ -27,8 +27,8 @@ STBase::operator=(STBase const& t) if (this == &t) return *this; - if (!fName->isUseful()) - fName = t.fName; + if (!fName_->isUseful()) + fName_ = t.fName_; return *this; } @@ -69,9 +69,9 @@ STBase::getFullText() const if (getSType() != STI_NOTPRESENT) { - if (fName->hasName()) + if (fName_->hasName()) { - ret = fName->fieldName; + ret = fName_->fieldName; ret += " = "; } @@ -87,7 +87,7 @@ STBase::getText() const return std::string(); } -Json::Value +json::Value STBase::getJson(JsonOptions /*options*/) const { return getText(); @@ -118,21 +118,21 @@ STBase::isDefault() const void STBase::setFName(SField const& n) { - fName = &n; - XRPL_ASSERT(fName, "xrpl::STBase::setFName : field is set"); + fName_ = &n; + XRPL_ASSERT(fName_, "xrpl::STBase::setFName : field is set"); } SField const& STBase::getFName() const { - return *fName; + return *fName_; } void STBase::addFieldID(Serializer& s) const { - XRPL_ASSERT(fName->isBinary(), "xrpl::STBase::addFieldID : field is binary"); - s.addFieldID(fName->fieldType, fName->fieldValue); + XRPL_ASSERT(fName_->isBinary(), "xrpl::STBase::addFieldID : field is binary"); + s.addFieldID(fName_->fieldType, fName_->fieldValue); } //------------------------------------------------------------------------------ diff --git a/src/libxrpl/protocol/STCurrency.cpp b/src/libxrpl/protocol/STCurrency.cpp index dc47624402..9b761864d9 100644 --- a/src/libxrpl/protocol/STCurrency.cpp +++ b/src/libxrpl/protocol/STCurrency.cpp @@ -41,7 +41,7 @@ STCurrency::getText() const return to_string(currency_); } -Json::Value +json::Value STCurrency::getJson(JsonOptions) const { return to_string(currency_); @@ -85,14 +85,14 @@ STCurrency::move(std::size_t n, void* buf) } STCurrency -currencyFromJson(SField const& name, Json::Value const& v) +currencyFromJson(SField const& name, json::Value const& v) { if (!v.isString()) { Throw("currencyFromJson currency must be a string Json value"); } - auto const currency = to_currency(v.asString()); + auto const currency = toCurrency(v.asString()); if (currency == badCurrency() || currency == noCurrency()) { Throw("currencyFromJson currency must be a valid currency"); diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 0530a784d9..d17dd49fe5 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace xrpl { @@ -52,7 +53,7 @@ STUInt8::getText() const } template <> -Json::Value +json::Value STUInt8::getJson(JsonOptions) const { if (getFName() == sfTransactionResult) @@ -91,7 +92,7 @@ STUInt16::getText() const { if (getFName() == sfLedgerEntryType) { - auto item = LedgerFormats::getInstance().findByType(safe_cast(value_)); + auto item = LedgerFormats::getInstance().findByType(safeCast(value_)); if (item != nullptr) return item->getName(); @@ -99,7 +100,7 @@ STUInt16::getText() const if (getFName() == sfTransactionType) { - auto item = TxFormats::getInstance().findByType(safe_cast(value_)); + auto item = TxFormats::getInstance().findByType(safeCast(value_)); if (item != nullptr) return item->getName(); @@ -109,12 +110,12 @@ STUInt16::getText() const } template <> -Json::Value +json::Value STUInt16::getJson(JsonOptions) const { if (getFName() == sfLedgerEntryType) { - auto item = LedgerFormats::getInstance().findByType(safe_cast(value_)); + auto item = LedgerFormats::getInstance().findByType(safeCast(value_)); if (item != nullptr) return item->getName(); @@ -122,7 +123,7 @@ STUInt16::getJson(JsonOptions) const if (getFName() == sfTransactionType) { - auto item = TxFormats::getInstance().findByType(safe_cast(value_)); + auto item = TxFormats::getInstance().findByType(safeCast(value_)); if (item != nullptr) return item->getName(); @@ -160,7 +161,7 @@ STUInt32::getText() const } template <> -Json::Value +json::Value STUInt32::getJson(JsonOptions) const { if (getFName() == sfPermissionValue) @@ -196,7 +197,7 @@ STUInt64::getText() const } template <> -Json::Value +json::Value STUInt64::getJson(JsonOptions) const { auto convertToString = [](uint64_t const value, int const base) { @@ -208,7 +209,7 @@ STUInt64::getJson(JsonOptions) const return str; }; - if (auto const& fName = getFName(); fName.shouldMeta(SField::sMD_BaseTen)) + if (auto const& fName = getFName(); fName.shouldMeta(SField::SMdBaseTen)) { return convertToString(value_, 10); // Convert to base 10 } @@ -239,7 +240,7 @@ STInt32::getText() const } template <> -Json::Value +json::Value STInt32::getJson(JsonOptions) const { return value_; diff --git a/src/libxrpl/protocol/STIssue.cpp b/src/libxrpl/protocol/STIssue.cpp index 10f0ff4c32..c0019c334f 100644 --- a/src/libxrpl/protocol/STIssue.cpp +++ b/src/libxrpl/protocol/STIssue.cpp @@ -78,10 +78,10 @@ STIssue::getText() const return asset_.getText(); } -Json::Value +json::Value STIssue::getJson(JsonOptions) const { - Json::Value jv; + json::Value jv; asset_.setJson(jv); return jv; } @@ -132,7 +132,7 @@ STIssue::move(std::size_t n, void* buf) } STIssue -issueFromJson(SField const& name, Json::Value const& v) +issueFromJson(SField const& name, json::Value const& v) { return STIssue{name, assetFromJson(v)}; } diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index 1f4d9acfd4..8bec23d319 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -38,7 +38,7 @@ STLedgerEntry::STLedgerEntry(Keylet const& k) : STObject(sfLedgerEntry), key_(k. { Throw( "Attempt to create a SLE of unknown type " + - std::to_string(safe_cast(k.type))); + std::to_string(safeCast(k.type))); } set(format->getSOTemplate()); @@ -63,7 +63,7 @@ void STLedgerEntry::setSLEType() { auto format = LedgerFormats::getInstance().findByType( - safe_cast(getFieldU16(sfLedgerEntryType))); + safeCast(getFieldU16(sfLedgerEntryType))); if (format == nullptr) Throw("invalid ledger entry type"); @@ -114,10 +114,10 @@ STLedgerEntry::getText() const return str(boost::format("{ %s, %s }") % to_string(key_) % STObject::getText()); } -Json::Value +json::Value STLedgerEntry::getJson(JsonOptions options) const { - Json::Value ret(STObject::getJson(options)); + json::Value ret(STObject::getJson(options)); ret[jss::index] = to_string(key_); @@ -133,12 +133,13 @@ STLedgerEntry::getJson(JsonOptions options) const bool STLedgerEntry::isThreadedType(Rules const& rules) const { - static constexpr std::array newPreviousTxnIDTypes = { + static constexpr std::array kNEW_PREVIOUS_TXN_ID_TYPES = { ltDIR_NODE, ltAMENDMENTS, ltFEE_SETTINGS, ltNEGATIVE_UNL, ltAMM}; // Exclude PrevTxnID/PrevTxnLgrSeq if the fixPreviousTxnID amendment is not // enabled and the ledger object type is in the above set bool const excludePrevTxnID = !rules.enabled(fixPreviousTxnID) && - (std::count(newPreviousTxnIDTypes.cbegin(), newPreviousTxnIDTypes.cend(), type_) != 0); + (std::count( + kNEW_PREVIOUS_TXN_ID_TYPES.cbegin(), kNEW_PREVIOUS_TXN_ID_TYPES.cend(), type_) != 0); return !excludePrevTxnID && getFieldIndex(sfPreviousTxnID) != -1; } diff --git a/src/libxrpl/protocol/STNumber.cpp b/src/libxrpl/protocol/STNumber.cpp index d506751f86..f6481a4d5d 100644 --- a/src/libxrpl/protocol/STNumber.cpp +++ b/src/libxrpl/protocol/STNumber.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ STNumber::associateAsset(Asset const& a) STTakesAsset::associateAsset(a); XRPL_ASSERT_PARTS( - getFName().shouldMeta(SField::sMD_NeedsAsset), + getFName().shouldMeta(SField::SMdNeedsAsset), "STNumber::associateAsset", "field needs asset"); @@ -75,7 +76,7 @@ STNumber::add(Serializer& s) const auto const exponent = value.exponent(); SField const& field = getFName(); - if (field.shouldMeta(SField::sMD_NeedsAsset)) + if (field.shouldMeta(SField::SMdNeedsAsset)) { // asset is defined in the STTakesAsset base class if (asset_) @@ -95,7 +96,7 @@ STNumber::add(Serializer& s) const // Json. Regardless, the only time we should be serializing an // STNumber is when the scale is large. XRPL_ASSERT_PARTS( - Number::getMantissaScale() == MantissaRange::mantissa_scale::large, + Number::getMantissaScale() == MantissaRange::MantissaScale::Large, "xrpl::STNumber::add", "STNumber only used with large mantissa scale"); #endif @@ -159,7 +160,7 @@ operator<<(std::ostream& out, STNumber const& rhs) NumberParts partsFromString(std::string const& number) { - static boost::regex const reNumber( + static boost::regex const kRE_NUMBER( "^" // the beginning of the string "([-+]?)" // (optional) + or - character "(0|[1-9][0-9]*)" // a number (no leading zeroes, unless 0) @@ -170,7 +171,7 @@ partsFromString(std::string const& number) boost::smatch match; - if (!boost::regex_match(number, match, reNumber)) + if (!boost::regex_match(number, match, kRE_NUMBER)) Throw("'" + number + "' is not a number"); // Match fields: @@ -217,7 +218,7 @@ partsFromString(std::string const& number) } STNumber -numberFromJson(SField const& field, Json::Value const& value) +numberFromJson(SField const& field, json::Value const& value) { NumberParts parts; @@ -257,7 +258,7 @@ numberFromJson(SField const& field, Json::Value const& value) } return STNumber{ - field, Number{parts.negative, parts.mantissa, parts.exponent, Number::normalized{}}}; + field, Number{parts.negative, parts.mantissa, parts.exponent, Number::Normalized{}}}; } } // namespace xrpl diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index 9f032a0962..6bce2f0ab2 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -43,7 +43,7 @@ namespace xrpl { STObject::STObject(STObject&& other) - : STBase(other.getFName()), v_(std::move(other.v_)), mType(other.mType) + : STBase(other.getFName()), v_(std::move(other.v_)), type_(other.type_) { } @@ -119,14 +119,14 @@ STObject::isDefault() const void STObject::add(Serializer& s) const { - add(s, WhichFields::withAllFields); // just inner elements + add(s, WhichFields::WithAllFields); // just inner elements } STObject& STObject::operator=(STObject&& other) { setFName(other.getFName()); - mType = other.mType; + type_ = other.type_; v_ = std::move(other.v_); return *this; } @@ -136,17 +136,17 @@ STObject::set(SOTemplate const& type) { v_.clear(); v_.reserve(type.size()); - mType = &type; + type_ = &type; for (auto const& elem : type) { - if (elem.style() != soeREQUIRED) + if (elem.style() != SoeRequired) { - v_.emplace_back(detail::nonPresentObject, elem.sField()); + v_.emplace_back(detail::gNonPresentObject, elem.sField()); } else { - v_.emplace_back(detail::defaultObject, elem.sField()); + v_.emplace_back(detail::gDefaultObject, elem.sField()); } } } @@ -162,7 +162,7 @@ STObject::applyTemplate(SOTemplate const& type) Throw(text); }; - mType = &type; + type_ = &type; decltype(v_) v; v.reserve(type.size()); for (auto const& e : type) @@ -171,7 +171,7 @@ STObject::applyTemplate(SOTemplate const& type) v_, [&](detail::STVar const& b) { return b.get().getFName() == e.sField(); }); if (iter != v_.end()) { - if ((e.style() == soeDEFAULT) && iter->get().isDefault()) + if ((e.style() == SoeDefault) && iter->get().isDefault()) { throwFieldErr(e.sField().fieldName, "may not be explicitly set to default."); } @@ -180,11 +180,11 @@ STObject::applyTemplate(SOTemplate const& type) } else { - if (e.style() == soeREQUIRED) + if (e.style() == SoeRequired) { throwFieldErr(e.sField().fieldName, "is required but missing."); } - v.emplace_back(detail::nonPresentObject, e.sField()); + v.emplace_back(detail::gNonPresentObject, e.sField()); } } for (auto const& e : v_) @@ -258,7 +258,7 @@ STObject::set(SerialIter& sit, int depth) // We want to ensure that the deserialized object does not contain any // duplicate fields. This is a key invariant: - auto const sf = getSortedFields(*this, WhichFields::withAllFields); + auto const sf = getSortedFields(*this, WhichFields::WithAllFields); auto const dup = std::ranges::adjacent_find(sf, [](STBase const* lhs, STBase const* rhs) { return lhs->getFName() == rhs->getFName(); @@ -345,7 +345,7 @@ STObject::isEquivalent(STBase const& t) const if (v == nullptr) return false; - if (mType != nullptr && v->mType == mType) + if (type_ != nullptr && v->type_ == type_) { return std::ranges::equal( begin(), end(), v->begin(), v->end(), [](STBase const& st1, STBase const& st2) { @@ -353,8 +353,8 @@ STObject::isEquivalent(STBase const& t) const }); } - auto const sf1 = getSortedFields(*this, WhichFields::withAllFields); - auto const sf2 = getSortedFields(*v, WhichFields::withAllFields); + auto const sf1 = getSortedFields(*this, WhichFields::WithAllFields); + auto const sf2 = getSortedFields(*v, WhichFields::WithAllFields); return std::ranges::equal(sf1, sf2, [](STBase const* st1, STBase const* st2) { return (st1->getSType() == st2->getSType()) && st1->isEquivalent(*st2); @@ -366,7 +366,7 @@ STObject::getHash(HashPrefix prefix) const { Serializer s; s.add32(prefix); - add(s, WhichFields::withAllFields); + add(s, WhichFields::WithAllFields); return s.getSHA512Half(); } @@ -375,15 +375,15 @@ STObject::getSigningHash(HashPrefix prefix) const { Serializer s; s.add32(prefix); - add(s, WhichFields::omitSigningFields); + add(s, WhichFields::OmitSigningFields); return s.getSHA512Half(); } int STObject::getFieldIndex(SField const& field) const { - if (mType != nullptr) - return mType->getIndex(field); + if (type_ != nullptr) + return type_->getIndex(field); int i = 0; for (auto const& elem : v_) @@ -442,7 +442,7 @@ STObject::getPField(SField const& field, bool createOkay) if (index == -1) { if (createOkay && isFree()) - return getPIndex(emplace_back(detail::defaultObject, field)); + return getPIndex(emplaceBack(detail::gDefaultObject, field)); return nullptr; } @@ -524,7 +524,7 @@ STObject::makeFieldPresent(SField const& field) if (!isFree()) throwFieldNotFound(field); - return getPIndex(emplace_back(detail::nonPresentObject, field)); + return getPIndex(emplaceBack(detail::gNonPresentObject, field)); } STBase* f = getPIndex(index); // NOLINT(misc-const-correctness) @@ -532,7 +532,7 @@ STObject::makeFieldPresent(SField const& field) if (f->getSType() != STI_NOTPRESENT) return f; - v_[index] = detail::STVar(detail::defaultObject, f->getFName()); + v_[index] = detail::STVar(detail::gDefaultObject, f->getFName()); return getPIndex(index); } @@ -548,7 +548,7 @@ STObject::makeFieldAbsent(SField const& field) if (f.getSType() == STI_NOTPRESENT) return; - v_[index] = detail::STVar(detail::nonPresentObject, f.getFName()); + v_[index] = detail::STVar(detail::gNonPresentObject, f.getFName()); } bool @@ -572,7 +572,7 @@ STObject::delField(int index) SOEStyle STObject::getStyle(SField const& field) const { - return (mType != nullptr) ? mType->style(field) : soeINVALID; + return (type_ != nullptr) ? type_->style(field) : SoeInvalid; } unsigned char @@ -646,22 +646,22 @@ STObject::getFieldVL(SField const& field) const STAmount const& STObject::getFieldAmount(SField const& field) const { - static STAmount const empty{}; - return getFieldByConstRef(field, empty); + static STAmount const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } STPathSet const& STObject::getFieldPathSet(SField const& field) const { - static STPathSet const empty{}; - return getFieldByConstRef(field, empty); + static STPathSet const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } STVector256 const& STObject::getFieldV256(SField const& field) const { - static STVector256 const empty{}; - return getFieldByConstRef(field, empty); + static STVector256 const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } STObject @@ -677,22 +677,22 @@ STObject::getFieldObject(SField const& field) const STArray const& STObject::getFieldArray(SField const& field) const { - static STArray const empty{}; - return getFieldByConstRef(field, empty); + static STArray const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } STCurrency const& STObject::getFieldCurrency(SField const& field) const { - static STCurrency const empty{}; - return getFieldByConstRef(field, empty); + static STCurrency const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } STNumber const& STObject::getFieldNumber(SField const& field) const { - static STNumber const empty{}; - return getFieldByConstRef(field, empty); + static STNumber const kEMPTY{}; + return getFieldByConstRef(field, kEMPTY); } void @@ -831,10 +831,10 @@ STObject::setFieldObject(SField const& field, STObject const& v) setFieldUsingAssignment(field, v); } -Json::Value +json::Value STObject::getJson(JsonOptions options) const { - Json::Value ret(Json::objectValue); + json::Value ret(json::ObjectValue); for (auto const& elem : v_) { @@ -927,7 +927,7 @@ STObject::getSortedFields(STObject const& objToSort, WhichFields whichFields) // Sort the fields by fieldCode. std::ranges::sort(sf, [](STBase const* lhs, STBase const* rhs) { - return lhs->getFName().fieldCode < rhs->getFName().fieldCode; + return lhs->getFName().fieldCodeMem < rhs->getFName().fieldCodeMem; }); return sf; diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index 01a52c88ec..f6ebde4e52 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -51,7 +51,7 @@ namespace xrpl { namespace STParsedJSONDetail { template constexpr std::enable_if_t && std::is_signed_v, U> -to_unsigned(S value) +toUnsigned(S value) { if (value < 0 || std::numeric_limits::max() < value) Throw("Value out of range"); @@ -60,7 +60,7 @@ to_unsigned(S value) template constexpr std::enable_if_t && std::is_unsigned_v, U1> -to_unsigned(U2 value) +toUnsigned(U2 value) { if (std::numeric_limits::max() < value) Throw("Value out of range"); @@ -69,7 +69,7 @@ to_unsigned(U2 value) // LCOV_EXCL_START static inline std::string -make_name(std::string const& object, std::string const& field) +makeName(std::string const& object, std::string const& field) { if (field.empty()) return object; @@ -77,102 +77,100 @@ make_name(std::string const& object, std::string const& field) return object + "." + field; } -static inline Json::Value -not_an_object(std::string const& object, std::string const& field) +static inline json::Value +notAnObject(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' is not a JSON object."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' is not a JSON object."); } -static inline Json::Value -not_an_object(std::string const& object) +static inline json::Value +notAnObject(std::string const& object) { - return not_an_object(object, ""); + return notAnObject(object, ""); } -static inline Json::Value -not_an_array(std::string const& object) +static inline json::Value +notAnArray(std::string const& object) { - return RPC::make_error(rpcINVALID_PARAMS, "Field '" + object + "' is not a JSON array."); + return RPC::makeError(RpcInvalidParams, "Field '" + object + "' is not a JSON array."); } -static inline Json::Value -unknown_field(std::string const& object, std::string const& field) +static inline json::Value +unknownField(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' is unknown."); + return RPC::makeError(RpcInvalidParams, "Field '" + makeName(object, field) + "' is unknown."); } -static inline Json::Value -out_of_range(std::string const& object, std::string const& field) +static inline json::Value +outOfRange(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' is out of range."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' is out of range."); } -static inline Json::Value -bad_type(std::string const& object, std::string const& field) +static inline json::Value +badType(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' has bad type."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' has bad type."); } -static inline Json::Value -invalid_data(std::string const& object, std::string const& field) +static inline json::Value +invalidData(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' has invalid data."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' has invalid data."); } -static inline Json::Value -invalid_data(std::string const& object) +static inline json::Value +invalidData(std::string const& object) { - return invalid_data(object, ""); + return invalidData(object, ""); } -static inline Json::Value -array_expected(std::string const& object, std::string const& field) +static inline json::Value +arrayExpected(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' must be a JSON array."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a JSON array."); } -static inline Json::Value -string_expected(std::string const& object, std::string const& field) +static inline json::Value +stringExpected(std::string const& object, std::string const& field) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + make_name(object, field) + "' must be a string."); + return RPC::makeError( + RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a string."); } -static inline Json::Value -too_deep(std::string const& object) +static inline json::Value +tooDeep(std::string const& object) { - return RPC::make_error( - rpcINVALID_PARAMS, "Field '" + object + "' exceeds nesting depth limit."); + return RPC::makeError(RpcInvalidParams, "Field '" + object + "' exceeds nesting depth limit."); } -static inline Json::Value -singleton_expected(std::string const& object, unsigned int index) +static inline json::Value +singletonExpected(std::string const& object, unsigned int index) { - return RPC::make_error( - rpcINVALID_PARAMS, + return RPC::makeError( + RpcInvalidParams, "Field '" + object + "[" + std::to_string(index) + "]' must be an object with a single key/object value."); } -static inline Json::Value -template_mismatch(SField const& sField) +static inline json::Value +templateMismatch(SField const& sField) { - return RPC::make_error( - rpcINVALID_PARAMS, + return RPC::makeError( + RpcInvalidParams, "Object '" + sField.getName() + "' contents did not meet requirements for that type."); } -static inline Json::Value -non_object_in_array(std::string const& item, Json::UInt index) +static inline json::Value +nonObjectInArray(std::string const& item, json::UInt index) { - return RPC::make_error( - rpcINVALID_PARAMS, + return RPC::makeError( + RpcInvalidParams, "Item '" + item + "' at index " + std::to_string(index) + " is not an object. Arrays may only contain objects."); } @@ -182,11 +180,11 @@ template static std::optional parseUnsigned( SField const& field, - std::string const& json_name, + std::string const& jsonName, std::string const& fieldName, SField const* name, - Json::Value const& value, - Json::Value& error) + json::Value const& value, + json::Value& error) { std::optional ret; @@ -194,30 +192,30 @@ parseUnsigned( { if (value.isString()) { - ret = detail::make_stvar( + ret = detail::makeStvar( field, - safe_cast( + safeCast( beast::lexicalCastThrow(value.asString()))); } else if (value.isInt()) { - ret = detail::make_stvar( - field, to_unsigned(value.asInt())); + ret = detail::makeStvar( + field, toUnsigned(value.asInt())); } else if (value.isUInt()) { - ret = detail::make_stvar( - field, to_unsigned(value.asUInt())); + ret = detail::makeStvar( + field, toUnsigned(value.asUInt())); } else { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -228,11 +226,11 @@ template static std::optional parseUint16( SField const& field, - std::string const& json_name, + std::string const& jsonName, std::string const& fieldName, SField const* name, - Json::Value const& value, - Json::Value& error) + json::Value const& value, + json::Value& error) { std::optional ret; @@ -246,40 +244,39 @@ parseUint16( { if (field == sfTransactionType) { - ret = detail::make_stvar( + ret = detail::makeStvar( field, - safe_cast(static_cast( + safeCast(static_cast( TxFormats::getInstance().findTypeByName(strValue)))); - if (*name == sfGeneric) + if (*name == kSF_GENERIC) name = &sfTransaction; } else if (field == sfLedgerEntryType) { - ret = detail::make_stvar( + ret = detail::makeStvar( field, - safe_cast(static_cast( + safeCast(static_cast( LedgerFormats::getInstance().findTypeByName(strValue)))); - if (*name == sfGeneric) + if (*name == kSF_GENERIC) name = &sfLedgerEntry; } else { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } } } if (!ret) { - return parseUnsigned( - field, json_name, fieldName, name, value, error); + return parseUnsigned(field, jsonName, fieldName, name, value, error); } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -290,11 +287,11 @@ template static std::optional parseUint32( SField const& field, - std::string const& json_name, + std::string const& jsonName, std::string const& fieldName, SField const* name, - Json::Value const& value, - Json::Value& error) + json::Value const& value, + json::Value& error) { std::optional ret; @@ -309,32 +306,31 @@ parseUint32( Permission::getInstance().getGranularValue(strValue); if (granularPermission) { - ret = detail::make_stvar(field, *granularPermission); + ret = detail::makeStvar(field, *granularPermission); } else { auto const& txType = TxFormats::getInstance().findTypeByName(strValue); - ret = detail::make_stvar( + ret = detail::makeStvar( field, Permission::getInstance().txToPermissionType(txType)); } } else { - ret = detail::make_stvar( + ret = detail::makeStvar( field, - safe_cast( + safeCast( beast::lexicalCastThrow(value.asString()))); } } if (!ret) { - return parseUnsigned( - field, json_name, fieldName, name, value, error); + return parseUnsigned(field, jsonName, fieldName, name, value, error); } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -345,21 +341,21 @@ parseUint32( // recurse. Everything represented here is a leaf-type. static std::optional parseLeaf( - std::string const& json_name, + std::string const& jsonName, std::string const& fieldName, SField const* name, - Json::Value const& value, - Json::Value& error) + json::Value const& value, + json::Value& error) { std::optional ret; auto const& field = SField::getField(fieldName); // checked in parseObject - if (field == sfInvalid) + if (field == kSF_INVALID) { // LCOV_EXCL_START - error = unknown_field(json_name, fieldName); + error = unknownField(jsonName, fieldName); return ret; // LCOV_EXCL_STOP } @@ -369,8 +365,8 @@ parseLeaf( case STI_UINT8: try { - constexpr auto minValue = std::numeric_limits::min(); - constexpr auto maxValue = std::numeric_limits::max(); + constexpr auto kMIN_VALUE = std::numeric_limits::min(); + constexpr auto kMAX_VALUE = std::numeric_limits::max(); if (value.isString()) { std::string const strValue = value.asString(); @@ -381,71 +377,71 @@ parseLeaf( { auto ter = transCode(strValue); - if (!ter || TERtoInt(*ter) < minValue || TERtoInt(*ter) > maxValue) + if (!ter || TERtoInt(*ter) < kMIN_VALUE || TERtoInt(*ter) > kMAX_VALUE) { - error = out_of_range(json_name, fieldName); + error = outOfRange(jsonName, fieldName); return ret; } - ret = detail::make_stvar( + ret = detail::makeStvar( field, static_cast(TERtoInt(*ter))); } else { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } } else { - ret = detail::make_stvar( + ret = detail::makeStvar( field, beast::lexicalCastThrow(strValue)); } } else if (value.isInt()) { - if (value.asInt() < minValue || value.asInt() > maxValue) + if (value.asInt() < kMIN_VALUE || value.asInt() > kMAX_VALUE) { - error = out_of_range(json_name, fieldName); + error = outOfRange(jsonName, fieldName); return ret; } - ret = detail::make_stvar( - field, static_cast(value.asInt())); + ret = + detail::makeStvar(field, static_cast(value.asInt())); } else if (value.isUInt()) { - if (value.asUInt() > maxValue) + if (value.asUInt() > kMAX_VALUE) { - error = out_of_range(json_name, fieldName); + error = outOfRange(jsonName, fieldName); return ret; } - ret = detail::make_stvar( + ret = detail::makeStvar( field, static_cast(value.asUInt())); } else { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } break; case STI_UINT16: - ret = parseUint16(field, json_name, fieldName, name, value, error); + ret = parseUint16(field, jsonName, fieldName, name, value, error); if (!ret) return ret; break; case STI_UINT32: - ret = parseUint32(field, json_name, fieldName, name, value, error); + ret = parseUint32(field, jsonName, fieldName, name, value, error); if (!ret) return ret; @@ -460,7 +456,7 @@ parseLeaf( std::uint64_t val = 0; - bool const useBase10 = field.shouldMeta(SField::sMD_BaseTen); + bool const useBase10 = field.shouldMeta(SField::SMdBaseTen); // if the field is amount, serialize as base 10 auto [p, ec] = std::from_chars( @@ -469,27 +465,27 @@ parseLeaf( if (ec != std::errc() || (p != str.data() + str.size())) Throw("invalid data"); - ret = detail::make_stvar(field, val); + ret = detail::makeStvar(field, val); } else if (value.isInt()) { - ret = detail::make_stvar( - field, to_unsigned(value.asInt())); + ret = detail::makeStvar( + field, toUnsigned(value.asInt())); } else if (value.isUInt()) { - ret = detail::make_stvar( - field, safe_cast(value.asUInt())); + ret = + detail::makeStvar(field, safeCast(value.asUInt())); } else { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -498,7 +494,7 @@ parseLeaf( case STI_UINT128: { if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -508,21 +504,21 @@ parseLeaf( { if (!s.empty()) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } num.zero(); } - ret = detail::make_stvar(field, num); + ret = detail::makeStvar(field, num); break; } case STI_UINT160: { if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -532,21 +528,21 @@ parseLeaf( { if (!s.empty()) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } num.zero(); } - ret = detail::make_stvar(field, num); + ret = detail::makeStvar(field, num); break; } case STI_UINT192: { if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -556,21 +552,21 @@ parseLeaf( { if (!s.empty()) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } num.zero(); } - ret = detail::make_stvar(field, num); + ret = detail::makeStvar(field, num); break; } case STI_UINT256: { if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -580,14 +576,14 @@ parseLeaf( { if (!s.empty()) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } num.zero(); } - ret = detail::make_stvar(field, num); + ret = detail::makeStvar(field, num); break; } @@ -596,7 +592,7 @@ parseLeaf( { if (value.isString()) { - ret = detail::make_stvar( + ret = detail::makeStvar( field, beast::lexicalCastThrow(value.asString())); } else if (value.isInt()) @@ -605,7 +601,7 @@ parseLeaf( // library ever supports larger ints // In such case, we will need additional bounds checks here static_assert(std::is_same_v); - ret = detail::make_stvar(field, value.asInt()); + ret = detail::makeStvar(field, value.asInt()); } else if (value.isUInt()) { @@ -613,20 +609,20 @@ parseLeaf( if (uintValue > static_cast(std::numeric_limits::max())) { - error = out_of_range(json_name, fieldName); + error = outOfRange(jsonName, fieldName); return ret; } - ret = detail::make_stvar(field, static_cast(uintValue)); + ret = detail::makeStvar(field, static_cast(uintValue)); } else { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -635,7 +631,7 @@ parseLeaf( case STI_VL: if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -643,7 +639,7 @@ parseLeaf( { if (auto vBlob = strUnHex(value.asString())) { - ret = detail::make_stvar(field, vBlob->data(), vBlob->size()); + ret = detail::makeStvar(field, vBlob->data(), vBlob->size()); } else { @@ -652,7 +648,7 @@ parseLeaf( } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -661,11 +657,11 @@ parseLeaf( case STI_AMOUNT: try { - ret = detail::make_stvar(amountFromJson(field, value)); + ret = detail::makeStvar(amountFromJson(field, value)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -674,11 +670,11 @@ parseLeaf( case STI_NUMBER: try { - ret = detail::make_stvar(numberFromJson(field, value)); + ret = detail::makeStvar(numberFromJson(field, value)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -687,25 +683,25 @@ parseLeaf( case STI_VECTOR256: if (!value.isArrayOrNull()) { - error = array_expected(json_name, fieldName); + error = arrayExpected(jsonName, fieldName); return ret; } try { STVector256 tail(field); - for (Json::UInt i = 0; value.isValidIndex(i); ++i) + for (json::UInt i = 0; value.isValidIndex(i); ++i) { uint256 s; if (!s.parseHex(value[i].asString())) Throw("invalid data"); - tail.push_back(s); + tail.pushBack(s); } - ret = detail::make_stvar(std::move(tail)); + ret = detail::makeStvar(std::move(tail)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -714,7 +710,7 @@ parseLeaf( case STI_PATHSET: if (!value.isArrayOrNull()) { - error = array_expected(json_name, fieldName); + error = arrayExpected(jsonName, fieldName); return ret; } @@ -722,7 +718,7 @@ parseLeaf( { STPathSet tail(field); - for (Json::UInt i = 0; value.isValidIndex(i); ++i) + for (json::UInt i = 0; value.isValidIndex(i); ++i) { STPath p; @@ -730,45 +726,45 @@ parseLeaf( { std::stringstream ss; ss << fieldName << "[" << i << "]"; - error = array_expected(json_name, ss.str()); + error = arrayExpected(jsonName, ss.str()); return ret; } - for (Json::UInt j = 0; value[i].isValidIndex(j); ++j) + for (json::UInt j = 0; value[i].isValidIndex(j); ++j) { std::stringstream ss; ss << fieldName << "[" << i << "][" << j << "]"; - std::string const element_name(json_name + "." + ss.str()); + std::string const elementName(jsonName + "." + ss.str()); // each element in this path has some combination of // account, asset, or issuer - Json::Value pathEl = value[i][j]; + json::Value pathEl = value[i][j]; if (!pathEl.isObject()) { - error = not_an_object(element_name); + error = notAnObject(elementName); return ret; } if (pathEl.isMember(jss::currency) && pathEl.isMember(jss::mpt_issuance_id)) { - error = RPC::make_error(rpcINVALID_PARAMS, "Invalid Asset."); + error = RPC::makeError(RpcInvalidParams, "Invalid Asset."); return ret; } bool const isMPT = pathEl.isMember(jss::mpt_issuance_id); auto const assetName = isMPT ? jss::mpt_issuance_id : jss::currency; - Json::Value const& account = pathEl[jss::account]; - Json::Value const& asset = pathEl[assetName]; - Json::Value const& issuer = pathEl[jss::issuer]; + json::Value const& account = pathEl[jss::account]; + json::Value const& asset = pathEl[assetName]; + json::Value const& issuer = pathEl[jss::issuer]; bool hasAsset = false; AccountID uAccount, uIssuer; PathAsset uAsset; if (!account && !asset && !issuer) { - error = invalid_data(element_name); + error = invalidData(elementName); return ret; } @@ -777,7 +773,7 @@ parseLeaf( // human account id if (!account.isString()) { - error = string_expected(element_name, jss::account.c_str()); + error = stringExpected(elementName, jss::account.cStr()); return ret; } @@ -788,7 +784,7 @@ parseLeaf( auto const a = parseBase58(account.asString()); if (!a) { - error = invalid_data(element_name, jss::account.c_str()); + error = invalidData(elementName, jss::account.cStr()); return ret; } uAccount = *a; @@ -800,7 +796,7 @@ parseLeaf( // human asset if (!asset.isString()) { - error = string_expected(element_name, assetName.c_str()); + error = stringExpected(elementName, assetName.cStr()); return ret; } @@ -811,12 +807,12 @@ parseLeaf( MPTID u; if (!u.parseHex(asset.asString())) { - error = invalid_data(element_name, assetName.c_str()); + error = invalidData(elementName, assetName.cStr()); return ret; } - if (getMPTIssuer(u) == beast::zero) + if (getMPTIssuer(u) == beast::kZERO) { - error = invalid_data(element_name, jss::account.c_str()); + error = invalidData(elementName, jss::account.cStr()); return ret; } uAsset = u; @@ -826,9 +822,9 @@ parseLeaf( Currency currency; if (!currency.parseHex(asset.asString())) { - if (!to_currency(currency, asset.asString())) + if (!toCurrency(currency, asset.asString())) { - error = invalid_data(element_name, assetName.c_str()); + error = invalidData(elementName, assetName.cStr()); return ret; } } @@ -841,7 +837,7 @@ parseLeaf( // human account id if (!issuer.isString()) { - error = string_expected(element_name, jss::issuer.c_str()); + error = stringExpected(elementName, jss::issuer.cStr()); return ret; } @@ -850,7 +846,7 @@ parseLeaf( auto const a = parseBase58(issuer.asString()); if (!a) { - error = invalid_data(element_name, jss::issuer.c_str()); + error = invalidData(elementName, jss::issuer.cStr()); return ret; } uIssuer = *a; @@ -858,21 +854,21 @@ parseLeaf( if (isMPT && uIssuer != getMPTIssuer(uAsset.get())) { - error = invalid_data(element_name, jss::issuer.c_str()); + error = invalidData(elementName, jss::issuer.cStr()); return ret; } } - p.emplace_back(uAccount, uAsset, uIssuer, hasAsset); + p.emplaceBack(uAccount, uAsset, uIssuer, hasAsset); } - tail.push_back(p); + tail.pushBack(p); } - ret = detail::make_stvar(std::move(tail)); + ret = detail::makeStvar(std::move(tail)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } @@ -881,7 +877,7 @@ parseLeaf( case STI_ACCOUNT: { if (!value.isString()) { - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } @@ -890,17 +886,17 @@ parseLeaf( try { if (AccountID account; account.parseHex(strValue)) - return detail::make_stvar(field, account); + return detail::makeStvar(field, account); if (auto result = parseBase58(strValue)) - return detail::make_stvar(field, *result); + return detail::makeStvar(field, *result); - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } } @@ -909,11 +905,11 @@ parseLeaf( case STI_ISSUE: try { - ret = detail::make_stvar(issueFromJson(field, value)); + ret = detail::makeStvar(issueFromJson(field, value)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } break; @@ -921,11 +917,11 @@ parseLeaf( case STI_XCHAIN_BRIDGE: try { - ret = detail::make_stvar(STXChainBridge(field, value)); + ret = detail::makeStvar(STXChainBridge(field, value)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } break; @@ -933,51 +929,51 @@ parseLeaf( case STI_CURRENCY: try { - ret = detail::make_stvar(currencyFromJson(field, value)); + ret = detail::makeStvar(currencyFromJson(field, value)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return ret; } break; default: - error = bad_type(json_name, fieldName); + error = badType(jsonName, fieldName); return ret; } return ret; } -static int const maxDepth = 64; +static int const kMAX_DEPTH = 64; // Forward declaration since parseObject() and parseArray() call each other. static std::optional parseArray( - std::string const& json_name, - Json::Value const& json, + std::string const& jsonName, + json::Value const& json, SField const& inName, int depth, - Json::Value& error); + json::Value& error); static std::optional parseObject( - std::string const& json_name, - Json::Value const& json, + std::string const& jsonName, + json::Value const& json, SField const& inName, int depth, - Json::Value& error) + json::Value& error) { if (!json.isObjectOrNull()) { - error = not_an_object(json_name); + error = notAnObject(jsonName); return std::nullopt; } - if (depth > maxDepth) + if (depth > kMAX_DEPTH) { - error = too_deep(json_name); + error = tooDeep(jsonName); return std::nullopt; } @@ -987,13 +983,13 @@ parseObject( for (auto const& fieldName : json.getMemberNames()) { - Json::Value const& value = json[fieldName]; + json::Value const& value = json[fieldName]; auto const& field = SField::getField(fieldName); - if (field == sfInvalid) + if (field == kSF_INVALID) { - error = unknown_field(json_name, fieldName); + error = unknownField(jsonName, fieldName); return std::nullopt; } @@ -1006,21 +1002,21 @@ parseObject( case STI_VALIDATION: if (!value.isObject()) { - error = not_an_object(json_name, fieldName); + error = notAnObject(jsonName, fieldName); return std::nullopt; } try { - auto ret = parseObject( - json_name + "." + fieldName, value, field, depth + 1, error); + auto ret = + parseObject(jsonName + "." + fieldName, value, field, depth + 1, error); if (!ret) return std::nullopt; - data.emplace_back(std::move(*ret)); + data.emplaceBack(std::move(*ret)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return std::nullopt; } @@ -1031,14 +1027,14 @@ parseObject( try { auto array = - parseArray(json_name + "." + fieldName, value, field, depth + 1, error); + parseArray(jsonName + "." + fieldName, value, field, depth + 1, error); if (!array.has_value()) return std::nullopt; - data.emplace_back(std::move(*array)); + data.emplaceBack(std::move(*array)); } catch (std::exception const&) { - error = invalid_data(json_name, fieldName); + error = invalidData(jsonName, fieldName); return std::nullopt; } @@ -1046,12 +1042,12 @@ parseObject( // Everything else (types that don't recurse). default: { - auto leaf = parseLeaf(json_name, fieldName, &inName, value, error); + auto leaf = parseLeaf(jsonName, fieldName, &inName, value, error); if (!leaf) return std::nullopt; - data.emplace_back(std::move(*leaf)); + data.emplaceBack(std::move(*leaf)); } break; @@ -1065,33 +1061,33 @@ parseObject( } catch (STObject::FieldErr const& e) { - std::cerr << "template_mismatch: " << e.what() << "\n"; - error = template_mismatch(inName); + std::cerr << "templateMismatch: " << e.what() << "\n"; + error = templateMismatch(inName); } catch (std::exception const&) { - error = invalid_data(json_name); + error = invalidData(jsonName); } return std::nullopt; } static std::optional parseArray( - std::string const& json_name, - Json::Value const& json, + std::string const& jsonName, + json::Value const& json, SField const& inName, int depth, - Json::Value& error) + json::Value& error) { if (!json.isArrayOrNull()) { - error = not_an_array(json_name); + error = notAnArray(jsonName); return std::nullopt; } - if (depth > maxDepth) + if (depth > kMAX_DEPTH) { - error = too_deep(json_name); + error = tooDeep(jsonName); return std::nullopt; } @@ -1099,7 +1095,7 @@ parseArray( { STArray tail(inName); - for (Json::UInt i = 0; json.isValidIndex(i); ++i) + for (json::UInt i = 0; json.isValidIndex(i); ++i) { bool const isObjectOrNull(json[i].isObjectOrNull()); bool const singleKey(isObjectOrNull ? json[i].size() == 1 : true); @@ -1107,7 +1103,7 @@ parseArray( if (!isObjectOrNull || !singleKey) { // null values are !singleKey - error = singleton_expected(json_name, i); + error = singletonExpected(jsonName, i); return std::nullopt; } @@ -1118,16 +1114,16 @@ parseArray( ; auto const& nameField(SField::getField(memberName)); - if (nameField == sfInvalid) + if (nameField == kSF_INVALID) { - error = unknown_field(json_name, memberName); + error = unknownField(jsonName, memberName); return std::nullopt; } - Json::Value const objectFields(json[i][memberName]); + json::Value const objectFields(json[i][memberName]); std::stringstream ss; - ss << json_name << "." << "[" << i << "]." << memberName; + ss << jsonName << "." << "[" << i << "]." << memberName; auto ret = parseObject(ss.str(), objectFields, nameField, depth + 1, error); if (!ret) @@ -1140,18 +1136,18 @@ parseArray( if (ret->getFName().fieldType != STI_OBJECT) { ss << "Field type: " << ret->getFName().fieldType << " "; - error = non_object_in_array(ss.str(), i); + error = nonObjectInArray(ss.str(), i); return std::nullopt; } - tail.push_back(std::move(*ret)); + tail.pushBack(std::move(*ret)); } - return detail::make_stvar(std::move(tail)); + return detail::makeStvar(std::move(tail)); } catch (std::exception const&) { - error = invalid_data(json_name); + error = invalidData(jsonName); return std::nullopt; } } @@ -1160,10 +1156,10 @@ parseArray( //------------------------------------------------------------------------------ -STParsedJSONObject::STParsedJSONObject(std::string const& name, Json::Value const& json) +STParsedJSONObject::STParsedJSONObject(std::string const& name, json::Value const& json) { using namespace STParsedJSONDetail; - object = parseObject(name, json, sfGeneric, 0, error); + object = parseObject(name, json, kSF_GENERIC, 0, error); } } // namespace xrpl diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index 04c8d3c8da..8c4b139792 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -21,33 +21,33 @@ namespace xrpl { std::size_t -STPathElement::get_hash(STPathElement const& element) +STPathElement::getHash(STPathElement const& element) { - std::size_t hash_account = 2654435761; - std::size_t hash_currency = 2654435761; - std::size_t hash_issuer = 2654435761; + std::size_t hashAccount = 2654435761; + std::size_t hashCurrency = 2654435761; + std::size_t hashIssuer = 2654435761; // NIKB NOTE: This doesn't have to be a secure hash as speed is more // important. We don't even really need to fully hash the whole // base_uint here, as a few bytes would do for our use. for (auto const x : element.getAccountID()) - hash_account += (hash_account * 257) ^ x; + hashAccount += (hashAccount * 257) ^ x; - // Check pathAsset type instead of element's mType - // In some cases mType might be account but the asset + // Check pathAsset type instead of element's type_ + // In some cases type_ might be account but the asset // is still set to either MPT or currency (see Pathfinder::addLink()) element.getPathAsset().visit( - [&](MPTID const& mpt) { hash_currency += beast::uhash<>{}(mpt); }, + [&](MPTID const& mpt) { hashCurrency += beast::Uhash<>{}(mpt); }, [&](Currency const& currency) { for (auto const x : currency) - hash_currency += (hash_currency * 509) ^ x; + hashCurrency += (hashCurrency * 509) ^ x; }); for (auto const x : element.getIssuerID()) - hash_issuer += (hash_issuer * 911) ^ x; + hashIssuer += (hashIssuer * 911) ^ x; - return (hash_account ^ hash_currency ^ hash_issuer); + return (hashAccount ^ hashCurrency ^ hashIssuer); } STPathSet::STPathSet(SerialIter& sit, SField const& name) : STBase(name) @@ -57,7 +57,7 @@ STPathSet::STPathSet(SerialIter& sit, SField const& name) : STBase(name) { int const iType = sit.get8(); - if (iType == STPathElement::typeNone || iType == STPathElement::typeBoundary) + if (iType == STPathElement::TypeNone || iType == STPathElement::TypeBoundary) { if (path.empty()) { @@ -65,23 +65,23 @@ STPathSet::STPathSet(SerialIter& sit, SField const& name) : STBase(name) Throw("empty path"); } - push_back(path); + pushBack(path); path.clear(); - if (iType == STPathElement::typeNone) + if (iType == STPathElement::TypeNone) return; } - else if ((iType & ~STPathElement::typeAll) != 0) + else if ((iType & ~STPathElement::TypeAll) != 0) { JLOG(debugLog().error()) << "Bad path element " << iType << " in pathset"; Throw("bad path element"); } else { - auto const hasAccount = (iType & STPathElement::typeAccount) != 0u; - auto const hasCurrency = (iType & STPathElement::typeCurrency) != 0u; - auto const hasIssuer = (iType & STPathElement::typeIssuer) != 0u; - auto const hasMPT = (iType & STPathElement::typeMPT) != 0u; + auto const hasAccount = (iType & STPathElement::TypeAccount) != 0u; + auto const hasCurrency = (iType & STPathElement::TypeCurrency) != 0u; + auto const hasIssuer = (iType & STPathElement::TypeIssuer) != 0u; + auto const hasMPT = (iType & STPathElement::TypeMpt) != 0u; AccountID account; PathAsset asset; @@ -121,18 +121,18 @@ STPathSet::move(std::size_t n, void* buf) bool STPathSet::assembleAdd(STPath const& base, STPathElement const& tail) { // assemble base+tail and add it to the set if it's not a duplicate - value.push_back(base); + value_.push_back(base); - std::vector::reverse_iterator it = value.rbegin(); + std::vector::reverse_iterator it = value_.rbegin(); STPath& newPath = *it; - newPath.push_back(tail); + newPath.pushBack(tail); - while (++it != value.rend()) + while (++it != value_.rend()) { if (*it == newPath) { - value.pop_back(); + value_.pop_back(); return false; } } @@ -143,19 +143,19 @@ bool STPathSet::isEquivalent(STBase const& t) const { STPathSet const* v = dynamic_cast(&t); - return (v != nullptr) && (value == v->value); + return (v != nullptr) && (value_ == v->value_); } bool STPathSet::isDefault() const { - return value.empty(); + return value_.empty(); } bool STPath::hasSeen(AccountID const& account, PathAsset const& asset, AccountID const& issuer) const { - for (auto& p : mPath) + for (auto& p : path_) { if (p.getAccountID() == account && p.getPathAsset() == asset && p.getIssuerID() == issuer) return true; @@ -164,32 +164,32 @@ STPath::hasSeen(AccountID const& account, PathAsset const& asset, AccountID cons return false; } -Json::Value +json::Value STPath::getJson(JsonOptions) const { - Json::Value ret(Json::arrayValue); + json::Value ret(json::ArrayValue); - for (auto const& it : mPath) + for (auto const& it : path_) { - Json::Value elem(Json::objectValue); + json::Value elem(json::ObjectValue); auto const iType = it.getNodeType(); elem[jss::type] = iType; - if ((iType & STPathElement::typeAccount) != 0u) + if ((iType & STPathElement::TypeAccount) != 0u) elem[jss::account] = to_string(it.getAccountID()); XRPL_ASSERT( - ((iType & STPathElement::typeCurrency) == 0u) || - ((iType & STPathElement::typeMPT) == 0u), + ((iType & STPathElement::TypeCurrency) == 0u) || + ((iType & STPathElement::TypeMpt) == 0u), "xrpl::STPath::getJson : not type Currency and MPT"); - if ((iType & STPathElement::typeCurrency) != 0u) + if ((iType & STPathElement::TypeCurrency) != 0u) elem[jss::currency] = to_string(it.getCurrency()); - if ((iType & STPathElement::typeMPT) != 0u) + if ((iType & STPathElement::TypeMpt) != 0u) elem[jss::mpt_issuance_id] = to_string(it.getMPTID()); - if ((iType & STPathElement::typeIssuer) != 0u) + if ((iType & STPathElement::TypeIssuer) != 0u) elem[jss::issuer] = to_string(it.getIssuerID()); ret.append(elem); @@ -198,11 +198,11 @@ STPath::getJson(JsonOptions) const return ret; } -Json::Value +json::Value STPathSet::getJson(JsonOptions options) const { - Json::Value ret(Json::arrayValue); - for (auto const& it : value) + json::Value ret(json::ArrayValue); + for (auto const& it : value_) ret.append(it.getJson(options)); return ret; @@ -221,10 +221,10 @@ STPathSet::add(Serializer& s) const XRPL_ASSERT(getFName().fieldType == STI_PATHSET, "xrpl::STPathSet::add : valid field type"); bool first = true; - for (auto const& spPath : value) + for (auto const& spPath : value_) { if (!first) - s.add8(STPathElement::typeBoundary); + s.add8(STPathElement::TypeBoundary); for (auto const& speElement : spPath) { @@ -232,23 +232,23 @@ STPathSet::add(Serializer& s) const s.add8(iType); - if ((iType & STPathElement::typeAccount) != 0u) + if ((iType & STPathElement::TypeAccount) != 0u) s.addBitString(speElement.getAccountID()); - if ((iType & STPathElement::typeMPT) != 0u) + if ((iType & STPathElement::TypeMpt) != 0u) s.addBitString(speElement.getMPTID()); - if ((iType & STPathElement::typeCurrency) != 0u) + if ((iType & STPathElement::TypeCurrency) != 0u) s.addBitString(speElement.getCurrency()); - if ((iType & STPathElement::typeIssuer) != 0u) + if ((iType & STPathElement::TypeIssuer) != 0u) s.addBitString(speElement.getIssuerID()); } first = false; } - s.add8(STPathElement::typeNone); + s.add8(STPathElement::TypeNone); } } // namespace xrpl diff --git a/src/libxrpl/protocol/STTakesAsset.cpp b/src/libxrpl/protocol/STTakesAsset.cpp index 1d37c65fc1..de7de002b0 100644 --- a/src/libxrpl/protocol/STTakesAsset.cpp +++ b/src/libxrpl/protocol/STTakesAsset.cpp @@ -17,7 +17,7 @@ associateAsset(SLE& sle, Asset const& asset) { STBase& entry = sle.getIndex(i); SField const& field = entry.getFName(); - if (field.shouldMeta(SField::sMD_NeedsAsset)) + if (field.shouldMeta(SField::SMdNeedsAsset)) { auto const type = entry.getSType(); // If the field is not set or present, skip it. @@ -29,10 +29,10 @@ associateAsset(SLE& sle, Asset const& asset) auto& ta = entry.downcast(); auto const style = sle.getStyle(ta.getFName()); XRPL_ASSERT_PARTS( - style != soeINVALID, "xrpl::associateAsset", "valid template element style"); + style != SoeInvalid, "xrpl::associateAsset", "valid template element style"); XRPL_ASSERT_PARTS( - style != soeDEFAULT || !ta.isDefault(), + style != SoeDefault || !ta.isDefault(), "xrpl::associateAsset", "non-default value"); ta.associateAsset(asset); @@ -41,7 +41,7 @@ associateAsset(SLE& sle, Asset const& asset) // value, but it won't know anything about how the value relates to // the SLE. If the template element is soeDEFAULT, and the value // changed to the default value, remove the field. - if (style == soeDEFAULT && ta.isDefault()) + if (style == SoeDefault && ta.isDefault()) sle.makeFieldAbsent(field); } } diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index 0dd567e6cc..d335988ac3 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -61,7 +61,7 @@ getTxFormat(TxType type) { Throw( "Invalid transaction type " + - std::to_string(safe_cast>(type))); + std::to_string(safeCast>(type))); } return format; @@ -69,25 +69,25 @@ getTxFormat(TxType type) STTx::STTx(STObject&& object) : STObject(std::move(object)) { - tx_type_ = safe_cast(getFieldU16(sfTransactionType)); + tx_type_ = safeCast(getFieldU16(sfTransactionType)); applyTemplate(getTxFormat(tx_type_)->getSOTemplate()); // may throw - tid_ = getHash(HashPrefix::transactionID); + tid_ = getHash(HashPrefix::TransactionId); } STTx::STTx(SerialIter& sit) : STObject(sfTransaction) { int const length = sit.getBytesLeft(); - if ((length < txMinSizeBytes) || (length > txMaxSizeBytes)) + if ((length < kTX_MIN_SIZE_BYTES) || (length > kTX_MAX_SIZE_BYTES)) Throw("Transaction length invalid"); if (set(sit)) Throw("Transaction contains an object terminator"); - tx_type_ = safe_cast(getFieldU16(sfTransactionType)); + tx_type_ = safeCast(getFieldU16(sfTransactionType)); applyTemplate(getTxFormat(tx_type_)->getSOTemplate()); // May throw - tid_ = getHash(HashPrefix::transactionID); + tid_ = getHash(HashPrefix::TransactionId); } STTx::STTx(TxType type, std::function assembler) : STObject(sfTransaction) @@ -99,12 +99,12 @@ STTx::STTx(TxType type, std::function assembler) : STObject(sfT assembler(*this); - tx_type_ = safe_cast(getFieldU16(sfTransactionType)); + tx_type_ = safeCast(getFieldU16(sfTransactionType)); if (tx_type_ != type) - LogicError("Transaction type was mutated during assembly"); + logicError("Transaction type was mutated during assembly"); - tid_ = getHash(HashPrefix::transactionID); + tid_ = getHash(HashPrefix::TransactionId); } STBase* @@ -165,7 +165,7 @@ static Blob getSigningData(STTx const& that) { Serializer s; - s.add32(HashPrefix::txSign); + s.add32(HashPrefix::TxSign); that.addWithoutSigningFields(s); return s.getData(); } @@ -173,7 +173,7 @@ getSigningData(STTx const& that) uint256 STTx::getSigningHash() const { - return STObject::getSigningHash(HashPrefix::txSign); + return STObject::getSigningHash(HashPrefix::TxSign); } Blob @@ -203,7 +203,7 @@ STTx::getSeqProxy() const return SeqProxy::sequence(seq); } - return SeqProxy{SeqProxy::Type::ticket, *ticketSeq}; + return SeqProxy{SeqProxy::Type::Ticket, *ticketSeq}; } std::uint32_t @@ -245,7 +245,7 @@ STTx::sign( { setFieldVL(sfTxnSignature, sig); } - tid_ = getHash(HashPrefix::transactionID); + tid_ = getHash(HashPrefix::TransactionId); } Expected @@ -312,38 +312,38 @@ STTx::checkBatchSign(Rules const& rules) const return Unexpected("Internal batch signature check failure."); } -Json::Value +json::Value STTx::getJson(JsonOptions options) const { - Json::Value ret = STObject::getJson(JsonOptions::none); - if (!(options & JsonOptions::disable_API_prior_V2)) + json::Value ret = STObject::getJson(JsonOptions::KNone); + if (!(options & JsonOptions::KDisableApiPriorV2)) ret[jss::hash] = to_string(getTransactionID()); return ret; } -Json::Value +json::Value STTx::getJson(JsonOptions options, bool binary) const { - bool const V1 = !(options & JsonOptions::disable_API_prior_V2); + bool const v1 = !(options & JsonOptions::KDisableApiPriorV2); if (binary) { Serializer const s = STObject::getSerializer(); std::string const dataBin = strHex(s.peekData()); - if (V1) + if (v1) { - Json::Value ret(Json::objectValue); + json::Value ret(json::ObjectValue); ret[jss::tx] = dataBin; ret[jss::hash] = to_string(getTransactionID()); return ret; } - return Json::Value{dataBin}; + return json::Value{dataBin}; } - Json::Value ret = STObject::getJson(JsonOptions::none); - if (V1) + json::Value ret = STObject::getJson(JsonOptions::KNone); + if (v1) ret[jss::hash] = to_string(getTransactionID()); return ret; @@ -352,13 +352,13 @@ STTx::getJson(JsonOptions options, bool binary) const std::string const& STTx::getMetaSQLInsertReplaceHeader() { - static std::string const sql = + static std::string const kSQL = "INSERT OR REPLACE INTO Transactions " "(TransID, TransType, FromAcct, FromSeq, LedgerSeq, Status, RawTxn, " "TxnMeta)" " VALUES "; - return sql; + return kSQL; } std::string @@ -366,7 +366,7 @@ STTx::getMetaSQL(std::uint32_t inLedger, std::string const& escapedMetaData) con { Serializer s; add(s); - return getMetaSQL(s, inLedger, TxnSql::txnSqlValidated, escapedMetaData); + return getMetaSQL(s, inLedger, TxnSql::Validated, escapedMetaData); } // VFALCO This could be a free function elsewhere @@ -377,16 +377,16 @@ STTx::getMetaSQL( TxnSql status, std::string const& escapedMetaData) const { - static boost::format const bfTrans("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)"); + static boost::format const kBF_TRANS("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)"); std::string rTxn = sqlBlobLiteral(rawTxn.peekData()); auto format = TxFormats::getInstance().findByType(tx_type_); XRPL_ASSERT(format, "xrpl::STTx::getMetaSQL : non-null type format"); return str( - boost::format(bfTrans) % to_string(getTransactionID()) % format->getName() % + boost::format(kBF_TRANS) % to_string(getTransactionID()) % format->getName() % toBase58(getAccountID(sfAccount)) % getFieldU32(sfSequence) % inLedger % - safe_cast(status) % rTxn % escapedMetaData); + safeCast(status) % rTxn % escapedMetaData); } static Expected @@ -454,11 +454,11 @@ multiSignHelper( STArray const& signers{sigObject.getFieldArray(sfSigners)}; // There are well known bounds that the number of signers must be within. - if (signers.size() < STTx::minMultiSigners || signers.size() > STTx::maxMultiSigners) + if (signers.size() < STTx::kMIN_MULTI_SIGNERS || signers.size() > STTx::kMAX_MULTI_SIGNERS) return Unexpected("Invalid Signers array size."); // Signers must be in sorted order by AccountID. - AccountID lastAccountID(beast::zero); + AccountID lastAccountID(beast::kZERO); for (auto const& signer : signers) { @@ -582,7 +582,7 @@ STTx::getBatchTransactionIDs() const if (batchTxnIds_.empty()) { for (STObject const& rb : getFieldArray(sfRawTransactions)) - batchTxnIds_.push_back(rb.getHash(HashPrefix::transactionID)); + batchTxnIds_.push_back(rb.getHash(HashPrefix::TransactionId)); } XRPL_ASSERT( @@ -652,7 +652,7 @@ isMemoOkay(STObject const& st, std::string& reason) // The only allowed characters for MemoType and MemoFormat are the // characters allowed in URLs per RFC 3986: alphanumerics and the // following symbols: -._~:/?#[]@!$&'()*+,;=% - static constexpr std::array const allowedSymbols = []() { + static constexpr std::array const kALLOWED_SYMBOLS = []() { std::array a{}; std::string_view const symbols( @@ -668,7 +668,7 @@ isMemoOkay(STObject const& st, std::string& reason) for (unsigned char const c : *optData) { - if (allowedSymbols[c] == 0) + if (kALLOWED_SYMBOLS[c] == 0) { reason = "The MemoType and MemoFormat fields may only " @@ -703,19 +703,19 @@ invalidMPTAmountInTx(STObject const& tx) auto const txType = tx[~sfTransactionType]; if (!txType) return false; - if (auto const* item = TxFormats::getInstance().findByType(safe_cast(*txType))) + if (auto const* item = TxFormats::getInstance().findByType(safeCast(*txType))) { for (auto const& e : item->getSOTemplate()) { - if (tx.isFieldPresent(e.sField()) && e.supportMPT() != soeMPTNone) + if (tx.isFieldPresent(e.sField()) && e.supportMPT() != SoeMptNone) { if (auto const& field = tx.peekAtField(e.sField()); (field.getSType() == STI_AMOUNT && - safe_downcast(field).holds()) || + safeDowncast(field).holds()) || (field.getSType() == STI_ISSUE && - safe_downcast(field).holds())) + safeDowncast(field).holds())) { - if (e.supportMPT() != soeMPTSupported) + if (e.supportMPT() != SoeMptSupported) return true; } } @@ -731,14 +731,14 @@ isRawTransactionOkay(STObject const& st, std::string& reason) return true; if (st.isFieldPresent(sfBatchSigners) && - st.getFieldArray(sfBatchSigners).size() > maxBatchTxCount) + st.getFieldArray(sfBatchSigners).size() > kMAX_BATCH_TX_COUNT) { reason = "Batch Signers array exceeds max entries."; return false; } auto const& rawTxns = st.getFieldArray(sfRawTransactions); - if (rawTxns.size() > maxBatchTxCount) + if (rawTxns.size() > kMAX_BATCH_TX_COUNT) { reason = "Raw Transactions array exceeds max entries."; return false; @@ -747,7 +747,7 @@ isRawTransactionOkay(STObject const& st, std::string& reason) { try { - TxType const tt = safe_cast(raw.getFieldU16(sfTransactionType)); + TxType const tt = safeCast(raw.getFieldU16(sfTransactionType)); if (tt == ttBATCH) { reason = "Raw Transactions may not contain batch transactions."; @@ -812,7 +812,7 @@ isPseudoTx(STObject const& tx) if (!t) return false; - auto const tt = safe_cast(*t); + auto const tt = safeCast(*t); return tt == ttAMENDMENT || tt == ttFEE || tt == ttUNL_MODIFY; } diff --git a/src/libxrpl/protocol/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp index 14349d3f85..dd4b8a0fee 100644 --- a/src/libxrpl/protocol/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -37,37 +38,37 @@ STValidation::validationFormat() // it relies on the SField's below being initialized, and we can't // guarantee the initialization order. // clang-format off - static SOTemplate const format{ - {sfFlags, soeREQUIRED}, - {sfLedgerHash, soeREQUIRED}, - {sfLedgerSequence, soeREQUIRED}, - {sfCloseTime, soeOPTIONAL}, - {sfLoadFee, soeOPTIONAL}, - {sfAmendments, soeOPTIONAL}, - {sfBaseFee, soeOPTIONAL}, - {sfReserveBase, soeOPTIONAL}, - {sfReserveIncrement, soeOPTIONAL}, - {sfSigningTime, soeREQUIRED}, - {sfSigningPubKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfConsensusHash, soeOPTIONAL}, - {sfCookie, soeDEFAULT}, - {sfValidatedHash, soeOPTIONAL}, - {sfServerVersion, soeOPTIONAL}, + static SOTemplate const kFORMAT{ + {sfFlags, SoeRequired}, + {sfLedgerHash, SoeRequired}, + {sfLedgerSequence, SoeRequired}, + {sfCloseTime, SoeOptional}, + {sfLoadFee, SoeOptional}, + {sfAmendments, SoeOptional}, + {sfBaseFee, SoeOptional}, + {sfReserveBase, SoeOptional}, + {sfReserveIncrement, SoeOptional}, + {sfSigningTime, SoeRequired}, + {sfSigningPubKey, SoeRequired}, + {sfSignature, SoeRequired}, + {sfConsensusHash, SoeOptional}, + {sfCookie, SoeDefault}, + {sfValidatedHash, SoeOptional}, + {sfServerVersion, SoeOptional}, // featureXRPFees - {sfBaseFeeDrops, soeOPTIONAL}, - {sfReserveBaseDrops, soeOPTIONAL}, - {sfReserveIncrementDrops, soeOPTIONAL}, + {sfBaseFeeDrops, SoeOptional}, + {sfReserveBaseDrops, SoeOptional}, + {sfReserveIncrementDrops, SoeOptional}, }; // clang-format on - return format; + return kFORMAT; }; uint256 STValidation::getSigningHash() const { - return STObject::getSigningHash(HashPrefix::validation); + return STObject::getSigningHash(HashPrefix::Validation); } uint256 @@ -100,14 +101,14 @@ STValidation::isValid() const noexcept if (!valid_) { XRPL_ASSERT( - publicKeyType(getSignerPublic()) == KeyType::secp256k1, + publicKeyType(getSignerPublic()) == KeyType::Secp256k1, "xrpl::STValidation::isValid : valid key type"); valid_ = verifyDigest( getSignerPublic(), getSigningHash(), makeSlice(getFieldVL(sfSignature)), - (getFlags() & vfFullyCanonicalSig) != 0u); + (getFlags() & kVF_FULLY_CANONICAL_SIG) != 0u); } return valid_.value(); @@ -116,7 +117,7 @@ STValidation::isValid() const noexcept bool STValidation::isFull() const noexcept { - return (getFlags() & vfFullValidation) != 0; + return (getFlags() & kVF_FULL_VALIDATION) != 0; } Blob diff --git a/src/libxrpl/protocol/STVar.cpp b/src/libxrpl/protocol/STVar.cpp index 652328f613..8e45d3c75b 100644 --- a/src/libxrpl/protocol/STVar.cpp +++ b/src/libxrpl/protocol/STVar.cpp @@ -25,8 +25,8 @@ namespace xrpl::detail { -defaultObject_t defaultObject; -nonPresentObject_t nonPresentObject; +DefaultObjectT gDefaultObject; +NonPresentObjectT gNonPresentObject; //------------------------------------------------------------------------------ @@ -38,19 +38,19 @@ STVar::~STVar() STVar::STVar(STVar const& other) { if (other.p_ != nullptr) - p_ = other.p_->copy(max_size, &d_); + p_ = other.p_->copy(kMAX_SIZE, &d_); } STVar::STVar(STVar&& other) { - if (other.on_heap()) + if (other.onHeap()) { p_ = other.p_; other.p_ = nullptr; } else { - p_ = other.p_->move(max_size, &d_); + p_ = other.p_->move(kMAX_SIZE, &d_); } } @@ -62,7 +62,7 @@ STVar::operator=(STVar const& rhs) destroy(); if (rhs.p_ != nullptr) { - p_ = rhs.p_->copy(max_size, &d_); + p_ = rhs.p_->copy(kMAX_SIZE, &d_); } else { @@ -79,25 +79,25 @@ STVar::operator=(STVar&& rhs) if (&rhs != this) { destroy(); - if (rhs.on_heap()) + if (rhs.onHeap()) { p_ = rhs.p_; rhs.p_ = nullptr; } else { - p_ = rhs.p_->move(max_size, &d_); + p_ = rhs.p_->move(kMAX_SIZE, &d_); } } return *this; } -STVar::STVar(defaultObject_t, SField const& name) : STVar(name.fieldType, name) +STVar::STVar(DefaultObjectT, SField const& name) : STVar(name.fieldType, name) { } -STVar::STVar(nonPresentObject_t, SField const& name) : STVar(STI_NOTPRESENT, name) +STVar::STVar(NonPresentObjectT, SField const& name) : STVar(STI_NOTPRESENT, name) { } @@ -119,7 +119,7 @@ STVar::STVar(SerializedTypeID id, SField const& name) void STVar::destroy() { - if (on_heap()) + if (onHeap()) { delete p_; } @@ -149,8 +149,9 @@ STVar::constructST(SerializedTypeID id, int depth, Args&&... args) } else { - constexpr bool alwaysFalse = !std::is_same_v, std::tuple>; - static_assert(alwaysFalse, "Invalid STVar constructor arguments"); + constexpr bool kALWAYS_FALSE = + !std::is_same_v, std::tuple>; + static_assert(kALWAYS_FALSE, "Invalid STVar constructor arguments"); } }; diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index 038f88c226..d720067508 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -27,10 +27,10 @@ STVector256::STVector256(SerialIter& sit, SField const& name) : STBase(name) auto const cnt = slice.size() / uint256::size(); - mValue.reserve(cnt); + value_.reserve(cnt); for (std::size_t i = 0; i != cnt; ++i) - mValue.emplace_back(slice.substr(i * uint256::size(), uint256::size())); + value_.emplace_back(slice.substr(i * uint256::size(), uint256::size())); } STBase* @@ -54,7 +54,7 @@ STVector256::getSType() const bool STVector256::isDefault() const { - return mValue.empty(); + return value_.empty(); } void @@ -62,22 +62,22 @@ STVector256::add(Serializer& s) const { XRPL_ASSERT(getFName().isBinary(), "xrpl::STVector256::add : field is binary"); XRPL_ASSERT(getFName().fieldType == STI_VECTOR256, "xrpl::STVector256::add : valid field type"); - s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8)); + s.addVL(value_.begin(), value_.end(), value_.size() * (256 / 8)); } bool STVector256::isEquivalent(STBase const& t) const { STVector256 const* v = dynamic_cast(&t); - return (v != nullptr) && (mValue == v->mValue); + return (v != nullptr) && (value_ == v->value_); } -Json::Value +json::Value STVector256::getJson(JsonOptions) const { - Json::Value ret(Json::arrayValue); + json::Value ret(json::ArrayValue); - for (auto const& vEntry : mValue) + for (auto const& vEntry : value_) ret.append(to_string(vEntry)); return ret; diff --git a/src/libxrpl/protocol/STXChainBridge.cpp b/src/libxrpl/protocol/STXChainBridge.cpp index a29bf3b6f9..35f47f891e 100644 --- a/src/libxrpl/protocol/STXChainBridge.cpp +++ b/src/libxrpl/protocol/STXChainBridge.cpp @@ -51,11 +51,11 @@ STXChainBridge::STXChainBridge(STObject const& o) { } -STXChainBridge::STXChainBridge(Json::Value const& v) : STXChainBridge{sfXChainBridge, v} +STXChainBridge::STXChainBridge(json::Value const& v) : STXChainBridge{sfXChainBridge, v} { } -STXChainBridge::STXChainBridge(SField const& name, Json::Value const& v) : STBase{name} +STXChainBridge::STXChainBridge(SField const& name, json::Value const& v) : STBase{name} { if (!v.isObject()) { @@ -63,12 +63,12 @@ STXChainBridge::STXChainBridge(SField const& name, Json::Value const& v) : STBas "STXChainBridge can only be specified with a 'object' Json value"); } - auto checkExtra = [](Json::Value const& v) { - static auto const bridgeJson = xrpl::STXChainBridge().getJson(xrpl::JsonOptions::none); + auto checkExtra = [](json::Value const& v) { + static auto const kBRIDGE_JSON = xrpl::STXChainBridge().getJson(xrpl::JsonOptions::KNone); for (auto it = v.begin(); it != v.end(); ++it) { std::string const name = it.memberName(); - if (!bridgeJson.isMember(name)) + if (!kBRIDGE_JSON.isMember(name)) { Throw("STXChainBridge extra field detected: " + name); } @@ -77,10 +77,10 @@ STXChainBridge::STXChainBridge(SField const& name, Json::Value const& v) : STBas }; checkExtra(v); - Json::Value const& lockingChainDoorStr = v[jss::LockingChainDoor]; - Json::Value const& lockingChainIssue = v[jss::LockingChainIssue]; - Json::Value const& issuingChainDoorStr = v[jss::IssuingChainDoor]; - Json::Value const& issuingChainIssue = v[jss::IssuingChainIssue]; + json::Value const& lockingChainDoorStr = v[jss::LockingChainDoor]; + json::Value const& lockingChainIssue = v[jss::LockingChainIssue]; + json::Value const& issuingChainDoorStr = v[jss::IssuingChainDoor]; + json::Value const& issuingChainIssue = v[jss::IssuingChainIssue]; if (!lockingChainDoorStr.isString()) { @@ -126,10 +126,10 @@ STXChainBridge::add(Serializer& s) const issuingChainIssue_.add(s); } -Json::Value +json::Value STXChainBridge::getJson(JsonOptions jo) const { - Json::Value v; + json::Value v; v[jss::LockingChainDoor] = lockingChainDoor_.getJson(jo); v[jss::LockingChainIssue] = lockingChainIssue_.getJson(jo); v[jss::IssuingChainDoor] = issuingChainDoor_.getJson(jo); diff --git a/src/libxrpl/protocol/SecretKey.cpp b/src/libxrpl/protocol/SecretKey.cpp index 19ec3267ae..d5fe54867a 100644 --- a/src/libxrpl/protocol/SecretKey.cpp +++ b/src/libxrpl/protocol/SecretKey.cpp @@ -32,7 +32,7 @@ namespace xrpl { SecretKey::~SecretKey() { - secure_erase(buf_, sizeof(buf_)); + secureErase(buf_, sizeof(buf_)); } SecretKey::SecretKey(std::array const& key) @@ -43,12 +43,12 @@ SecretKey::SecretKey(std::array const& key) SecretKey::SecretKey(Slice const& slice) { if (slice.size() != sizeof(buf_)) - LogicError("SecretKey::SecretKey: invalid size"); + logicError("SecretKey::SecretKey: invalid size"); std::memcpy(buf_, slice.data(), sizeof(buf_)); } std::string -SecretKey::to_string() const +SecretKey::toString() const { return strHex(*this); } @@ -56,7 +56,7 @@ SecretKey::to_string() const namespace detail { void -copy_uint32(std::uint8_t* out, std::uint32_t v) +copyUint32(std::uint8_t* out, std::uint32_t v) { *out++ = v >> 24; *out++ = (v >> 16) & 0xff; @@ -84,13 +84,13 @@ deriveDeterministicRootKey(Seed const& seed) // more iterations loop a few times. for (std::uint32_t seq = 0; seq != 128; ++seq) { - copy_uint32(buf.data() + 16, seq); + copyUint32(buf.data() + 16, seq); auto const ret = sha512Half(buf); if (secp256k1_ec_seckey_verify(secp256k1Context(), ret.data()) == 1) { - secure_erase(buf.data(), buf.size()); + secureErase(buf.data(), buf.size()); return ret; } } @@ -137,19 +137,19 @@ private: std::array buf{}; std::ranges::copy(generator_, buf.begin()); - copy_uint32(buf.data() + 33, seq); + copyUint32(buf.data() + 33, seq); // The odds that this loop executes more than once are negligible // but we impose a maximum limit just in case. for (std::uint32_t subseq = 0; subseq != 128; ++subseq) { - copy_uint32(buf.data() + 37, subseq); + copyUint32(buf.data() + 37, subseq); - auto const ret = sha512Half_s(buf); + auto const ret = sha512HalfS(buf); if (secp256k1_ec_seckey_verify(secp256k1Context(), ret.data()) == 1) { - secure_erase(buf.data(), buf.size()); + secureErase(buf.data(), buf.size()); return ret; } } @@ -162,19 +162,19 @@ public: { secp256k1_pubkey pubkey; if (secp256k1_ec_pubkey_create(secp256k1Context(), &pubkey, root_.data()) != 1) - LogicError("derivePublicKey: secp256k1_ec_pubkey_create failed"); + logicError("derivePublicKey: secp256k1_ec_pubkey_create failed"); auto len = generator_.size(); if (secp256k1_ec_pubkey_serialize( secp256k1Context(), generator_.data(), &len, &pubkey, SECP256K1_EC_COMPRESSED) != 1) - LogicError("derivePublicKey: secp256k1_ec_pubkey_serialize failed"); + logicError("derivePublicKey: secp256k1_ec_pubkey_serialize failed"); } ~Generator() { - secure_erase(root_.data(), root_.size()); - secure_erase(generator_.data(), generator_.size()); + secureErase(root_.data(), root_.size()); + secureErase(generator_.data(), generator_.size()); } /** Generate the nth key pair. */ @@ -188,14 +188,14 @@ public: if (secp256k1_ec_seckey_tweak_add(secp256k1Context(), rpk.data(), tweak.data()) == 1) { SecretKey const sk{Slice{rpk.data(), rpk.size()}}; - secure_erase(rpk.data(), rpk.size()); + secureErase(rpk.data(), rpk.size()); return sk; } - LogicError("Unable to add a tweak!"); + logicError("Unable to add a tweak!"); }(); - return {derivePublicKey(KeyType::secp256k1, gsk), gsk}; + return {derivePublicKey(KeyType::Secp256k1, gsk), gsk}; } }; @@ -204,24 +204,24 @@ public: Buffer signDigest(PublicKey const& pk, SecretKey const& sk, uint256 const& digest) { - if (publicKeyType(pk.slice()) != KeyType::secp256k1) - LogicError("sign: secp256k1 required for digest signing"); + if (publicKeyType(pk.slice()) != KeyType::Secp256k1) + logicError("sign: secp256k1 required for digest signing"); BOOST_ASSERT(sk.size() == 32); - secp256k1_ecdsa_signature sig_imp; + secp256k1_ecdsa_signature sigImp; if (secp256k1_ecdsa_sign( secp256k1Context(), - &sig_imp, + &sigImp, reinterpret_cast(digest.data()), reinterpret_cast(sk.data()), secp256k1_nonce_function_rfc6979, nullptr) != 1) - LogicError("sign: secp256k1_ecdsa_sign failed"); + logicError("sign: secp256k1_ecdsa_sign failed"); unsigned char sig[72]; size_t len = sizeof(sig); - if (secp256k1_ecdsa_signature_serialize_der(secp256k1Context(), sig, &len, &sig_imp) != 1) - LogicError("sign: secp256k1_ecdsa_signature_serialize_der failed"); + if (secp256k1_ecdsa_signature_serialize_der(secp256k1Context(), sig, &len, &sigImp) != 1) + logicError("sign: secp256k1_ecdsa_signature_serialize_der failed"); return Buffer{sig, len}; } @@ -231,39 +231,39 @@ sign(PublicKey const& pk, SecretKey const& sk, Slice const& m) { auto const type = publicKeyType(pk.slice()); if (!type) - LogicError("sign: invalid type"); + logicError("sign: invalid type"); switch (*type) { - case KeyType::ed25519: { + case KeyType::Ed25519: { Buffer b(64); ed25519_sign(m.data(), m.size(), sk.data(), pk.data() + 1, b.data()); return b; } - case KeyType::secp256k1: { + case KeyType::Secp256k1: { sha512_half_hasher h; h(m.data(), m.size()); auto const digest = sha512_half_hasher::result_type(h); - secp256k1_ecdsa_signature sig_imp; + secp256k1_ecdsa_signature sigImp; if (secp256k1_ecdsa_sign( secp256k1Context(), - &sig_imp, + &sigImp, reinterpret_cast(digest.data()), reinterpret_cast(sk.data()), secp256k1_nonce_function_rfc6979, nullptr) != 1) - LogicError("sign: secp256k1_ecdsa_sign failed"); + logicError("sign: secp256k1_ecdsa_sign failed"); unsigned char sig[72]; size_t len = sizeof(sig); - if (secp256k1_ecdsa_signature_serialize_der(secp256k1Context(), sig, &len, &sig_imp) != + if (secp256k1_ecdsa_signature_serialize_der(secp256k1Context(), sig, &len, &sigImp) != 1) - LogicError("sign: secp256k1_ecdsa_signature_serialize_der failed"); + logicError("sign: secp256k1_ecdsa_signature_serialize_der failed"); return Buffer{sig, len}; } default: - LogicError("sign: invalid type"); + logicError("sign: invalid type"); } } @@ -271,32 +271,32 @@ SecretKey randomSecretKey() { std::uint8_t buf[32]; - beast::rngfill(buf, sizeof(buf), crypto_prng()); + beast::rngfill(buf, sizeof(buf), cryptoPrng()); SecretKey const sk(Slice{buf, sizeof(buf)}); - secure_erase(buf, sizeof(buf)); + secureErase(buf, sizeof(buf)); return sk; } SecretKey generateSecretKey(KeyType type, Seed const& seed) { - if (type == KeyType::ed25519) + if (type == KeyType::Ed25519) { - auto key = sha512Half_s(Slice(seed.data(), seed.size())); + auto key = sha512HalfS(Slice(seed.data(), seed.size())); SecretKey const sk{Slice{key.data(), key.size()}}; - secure_erase(key.data(), key.size()); + secureErase(key.data(), key.size()); return sk; } - if (type == KeyType::secp256k1) + if (type == KeyType::Secp256k1) { auto key = detail::deriveDeterministicRootKey(seed); SecretKey const sk{Slice{key.data(), key.size()}}; - secure_erase(key.data(), key.size()); + secureErase(key.data(), key.size()); return sk; } - LogicError("generateSecretKey: unknown key type"); + logicError("generateSecretKey: unknown key type"); } PublicKey @@ -304,30 +304,30 @@ derivePublicKey(KeyType type, SecretKey const& sk) { switch (type) { - case KeyType::secp256k1: { - secp256k1_pubkey pubkey_imp; + case KeyType::Secp256k1: { + secp256k1_pubkey pubkeyImp; if (secp256k1_ec_pubkey_create( secp256k1Context(), - &pubkey_imp, + &pubkeyImp, reinterpret_cast(sk.data())) != 1) - LogicError("derivePublicKey: secp256k1_ec_pubkey_create failed"); + logicError("derivePublicKey: secp256k1_ec_pubkey_create failed"); unsigned char pubkey[33]; std::size_t len = sizeof(pubkey); if (secp256k1_ec_pubkey_serialize( - secp256k1Context(), pubkey, &len, &pubkey_imp, SECP256K1_EC_COMPRESSED) != 1) - LogicError("derivePublicKey: secp256k1_ec_pubkey_serialize failed"); + secp256k1Context(), pubkey, &len, &pubkeyImp, SECP256K1_EC_COMPRESSED) != 1) + logicError("derivePublicKey: secp256k1_ec_pubkey_serialize failed"); return PublicKey{Slice{pubkey, len}}; } - case KeyType::ed25519: { + case KeyType::Ed25519: { unsigned char buf[33]; buf[0] = 0xED; ed25519_publickey(sk.data(), &buf[1]); return PublicKey(Slice{buf, sizeof(buf)}); } default: - LogicError("derivePublicKey: bad key type"); + logicError("derivePublicKey: bad key type"); }; } @@ -336,12 +336,12 @@ generateKeyPair(KeyType type, Seed const& seed) { switch (type) { - case KeyType::secp256k1: { + case KeyType::Secp256k1: { detail::Generator const g(seed); return g(0); } default: - case KeyType::ed25519: { + case KeyType::Ed25519: { auto const sk = generateSecretKey(type, seed); return {derivePublicKey(type, sk), sk}; } diff --git a/src/libxrpl/protocol/Seed.cpp b/src/libxrpl/protocol/Seed.cpp index 0fe525a613..f15d4dcff0 100644 --- a/src/libxrpl/protocol/Seed.cpp +++ b/src/libxrpl/protocol/Seed.cpp @@ -25,20 +25,20 @@ namespace xrpl { Seed::~Seed() { - secure_erase(buf_.data(), buf_.size()); + secureErase(buf_.data(), buf_.size()); } Seed::Seed(Slice const& slice) { if (slice.size() != buf_.size()) - LogicError("Seed::Seed: invalid size"); + logicError("Seed::Seed: invalid size"); std::memcpy(buf_.data(), slice.data(), buf_.size()); } Seed::Seed(uint128 const& seed) { if (seed.size() != buf_.size()) - LogicError("Seed::Seed: invalid size"); + logicError("Seed::Seed: invalid size"); std::memcpy(buf_.data(), seed.data(), buf_.size()); } @@ -48,9 +48,9 @@ Seed randomSeed() { std::array buffer{}; - beast::rngfill(buffer.data(), buffer.size(), crypto_prng()); + beast::rngfill(buffer.data(), buffer.size(), cryptoPrng()); Seed const seed(makeSlice(buffer)); - secure_erase(buffer.data(), buffer.size()); + secureErase(buffer.data(), buffer.size()); return seed; } diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index 576e3f3e5f..d500919df9 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -24,9 +24,9 @@ namespace xrpl { int Serializer::add16(std::uint16_t i) { - int const ret = mData.size(); - mData.push_back(static_cast(i >> 8)); - mData.push_back(static_cast(i & 0xff)); + int const ret = data_.size(); + data_.push_back(static_cast(i >> 8)); + data_.push_back(static_cast(i & 0xff)); return ret; } @@ -37,7 +37,7 @@ Serializer::add32(HashPrefix p) // integral parts of the protocol and unlikely to ever change. static_assert(std::is_same_v>); - return add32(safe_cast(p)); + return add32(safeCast(p)); } template <> @@ -74,39 +74,39 @@ Serializer::addInteger(std::int32_t i) int Serializer::addRaw(Blob const& vector) { - int const ret = mData.size(); - mData.insert(mData.end(), vector.begin(), vector.end()); + int const ret = data_.size(); + data_.insert(data_.end(), vector.begin(), vector.end()); return ret; } int Serializer::addRaw(Slice slice) { - int const ret = mData.size(); - mData.insert(mData.end(), slice.begin(), slice.end()); + int const ret = data_.size(); + data_.insert(data_.end(), slice.begin(), slice.end()); return ret; } int Serializer::addRaw(Serializer const& s) { - int const ret = mData.size(); - mData.insert(mData.end(), s.begin(), s.end()); + int const ret = data_.size(); + data_.insert(data_.end(), s.begin(), s.end()); return ret; } int Serializer::addRaw(void const* ptr, int len) { - int const ret = mData.size(); - mData.insert(mData.end(), (char const*)ptr, ((char const*)ptr) + len); + int const ret = data_.size(); + data_.insert(data_.end(), (char const*)ptr, ((char const*)ptr) + len); return ret; } int Serializer::addFieldID(int type, int name) { - int const ret = mData.size(); + int const ret = data_.size(); XRPL_ASSERT( (type > 0) && (type < 256) && (name > 0) && (name < 256), "xrpl::Serializer::addFieldID : inputs inside range"); @@ -114,28 +114,29 @@ Serializer::addFieldID(int type, int name) if (type < 16) { if (name < 16) - { // common type, common name - mData.push_back(static_cast((type << 4) | name)); + { + // common type, common name + data_.push_back(static_cast((type << 4) | name)); } else { // common type, uncommon name - mData.push_back(static_cast(type << 4)); - mData.push_back(static_cast(name)); + data_.push_back(static_cast(type << 4)); + data_.push_back(static_cast(name)); } } else if (name < 16) { // uncommon type, common name - mData.push_back(static_cast(name)); - mData.push_back(static_cast(type)); + data_.push_back(static_cast(name)); + data_.push_back(static_cast(type)); } else { // uncommon type, uncommon name - mData.push_back(static_cast(0)); - mData.push_back(static_cast(type)); - mData.push_back(static_cast(name)); + data_.push_back(static_cast(0)); + data_.push_back(static_cast(type)); + data_.push_back(static_cast(name)); } return ret; @@ -144,35 +145,35 @@ Serializer::addFieldID(int type, int name) int Serializer::add8(unsigned char byte) { - int const ret = mData.size(); - mData.push_back(byte); + int const ret = data_.size(); + data_.push_back(byte); return ret; } bool Serializer::get8(int& byte, int offset) const { - if (offset >= mData.size()) + if (offset >= data_.size()) return false; - byte = mData[offset]; + byte = data_[offset]; return true; } bool Serializer::chop(int bytes) { - if (bytes > mData.size()) + if (bytes > data_.size()) return false; - mData.resize(mData.size() - bytes); + data_.resize(data_.size() - bytes); return true; } uint256 Serializer::getSHA512Half() const { - return sha512Half(makeSlice(mData)); + return sha512Half(makeSlice(data_)); } int @@ -181,7 +182,7 @@ Serializer::addVL(Blob const& vector) int const ret = addEncoded(vector.size()); addRaw(vector); XRPL_ASSERT( - mData.size() == (ret + vector.size() + encodeLengthLength(vector.size())), + data_.size() == (ret + vector.size() + encodeLengthLength(vector.size())), "xrpl::Serializer::addVL : size matches expected"); return ret; } diff --git a/src/libxrpl/protocol/Sign.cpp b/src/libxrpl/protocol/Sign.cpp index bee034d60e..9e7ef7f999 100644 --- a/src/libxrpl/protocol/Sign.cpp +++ b/src/libxrpl/protocol/Sign.cpp @@ -81,7 +81,7 @@ Serializer startMultiSigningData(STObject const& obj) { Serializer s; - s.add32(HashPrefix::txMultiSign); + s.add32(HashPrefix::TxMultiSign); obj.addWithoutSigningFields(s); return s; } diff --git a/src/libxrpl/protocol/TER.cpp b/src/libxrpl/protocol/TER.cpp index 1e3f64cc22..3654547dd2 100644 --- a/src/libxrpl/protocol/TER.cpp +++ b/src/libxrpl/protocol/TER.cpp @@ -22,7 +22,7 @@ transResults() static std::unordered_map< TERUnderlyingType, - std::pair> const results + std::pair> const kRESULTS { MAKE_ERROR(tecAMM_BALANCE, "AMM has invalid balance."), MAKE_ERROR(tecAMM_INVALID_TOKENS, "AMM invalid LP tokens."), @@ -223,7 +223,7 @@ transResults() #undef MAKE_ERROR - return results; + return kRESULTS; } bool @@ -262,7 +262,7 @@ transHuman(TER code) std::optional transCode(std::string const& token) { - static auto const results = [] { + static auto const kRESULTS = [] { auto& byTer = transResults(); auto range = boost::make_iterator_range(byTer.begin(), byTer.end()); auto tRange = boost::adaptors::transform( @@ -272,9 +272,9 @@ transCode(std::string const& token) return byToken; }(); - auto const r = results.find(token); + auto const r = kRESULTS.find(token); - if (r == results.end()) + if (r == kRESULTS.end()) return std::nullopt; return TER::fromInt(r->second); diff --git a/src/libxrpl/protocol/TxFormats.cpp b/src/libxrpl/protocol/TxFormats.cpp index a2a7c5facf..083889622c 100644 --- a/src/libxrpl/protocol/TxFormats.cpp +++ b/src/libxrpl/protocol/TxFormats.cpp @@ -12,26 +12,26 @@ namespace xrpl { std::vector const& TxFormats::getCommonFields() { - static auto const commonFields = std::vector{ - {sfTransactionType, soeREQUIRED}, - {sfFlags, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfAccount, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfPreviousTxnID, soeOPTIONAL}, // emulate027 - {sfLastLedgerSequence, soeOPTIONAL}, - {sfAccountTxnID, soeOPTIONAL}, - {sfFee, soeREQUIRED}, - {sfOperationLimit, soeOPTIONAL}, - {sfMemos, soeOPTIONAL}, - {sfSigningPubKey, soeREQUIRED}, - {sfTicketSequence, soeOPTIONAL}, - {sfTxnSignature, soeOPTIONAL}, - {sfSigners, soeOPTIONAL}, // submit_multisigned - {sfNetworkID, soeOPTIONAL}, - {sfDelegate, soeOPTIONAL}, + static auto const kCOMMON_FIELDS = std::vector{ + {sfTransactionType, SoeRequired}, + {sfFlags, SoeOptional}, + {sfSourceTag, SoeOptional}, + {sfAccount, SoeRequired}, + {sfSequence, SoeRequired}, + {sfPreviousTxnID, SoeOptional}, // emulate027 + {sfLastLedgerSequence, SoeOptional}, + {sfAccountTxnID, SoeOptional}, + {sfFee, SoeRequired}, + {sfOperationLimit, SoeOptional}, + {sfMemos, SoeOptional}, + {sfSigningPubKey, SoeRequired}, + {sfTicketSequence, SoeOptional}, + {sfTxnSignature, SoeOptional}, + {sfSigners, SoeOptional}, // submit_multisigned + {sfNetworkID, SoeOptional}, + {sfDelegate, SoeOptional}, }; - return commonFields; + return kCOMMON_FIELDS; } TxFormats::TxFormats() @@ -56,8 +56,8 @@ TxFormats::TxFormats() TxFormats const& TxFormats::getInstance() { - static TxFormats const instance; - return instance; + static TxFormats const kINSTANCE; + return kINSTANCE; } } // namespace xrpl diff --git a/src/libxrpl/protocol/TxMeta.cpp b/src/libxrpl/protocol/TxMeta.cpp index 08069ca83d..0373706e84 100644 --- a/src/libxrpl/protocol/TxMeta.cpp +++ b/src/libxrpl/protocol/TxMeta.cpp @@ -73,7 +73,7 @@ TxMeta::setAffectedNode(uint256 const& node, SField const& type, std::uint16_t n } } - nodes_.push_back(STObject(type)); + nodes_.pushBack(STObject(type)); STObject& obj = nodes_.back(); XRPL_ASSERT(obj.getFName() == type, "xrpl::TxMeta::setAffectedNode : field type match"); @@ -154,7 +154,7 @@ TxMeta::getAffectedNode(SLE::ref node, SField const& type) if (n.getFieldH256(sfLedgerIndex) == index) return n; } - nodes_.push_back(STObject(type)); + nodes_.pushBack(STObject(type)); STObject& obj = nodes_.back(); XRPL_ASSERT( @@ -187,7 +187,7 @@ TxMeta::getAsObject() const XRPL_ASSERT(result_ != 255, "xrpl::TxMeta::getAsObject : result_ is set"); metaData.setFieldU8(sfTransactionResult, result_); metaData.setFieldU32(sfTransactionIndex, index_); - metaData.emplace_back(nodes_); + metaData.emplaceBack(nodes_); if (deliveredAmount_.has_value()) metaData.setFieldAmount(sfDeliveredAmount, *deliveredAmount_); diff --git a/src/libxrpl/protocol/UintTypes.cpp b/src/libxrpl/protocol/UintTypes.cpp index 4206ec8cf5..adef5e2c14 100644 --- a/src/libxrpl/protocol/UintTypes.cpp +++ b/src/libxrpl/protocol/UintTypes.cpp @@ -18,41 +18,41 @@ namespace detail { // Characters we are willing to allow in the ASCII representation of a // three-letter currency code. -constexpr std::string_view isoCharSet = +constexpr std::string_view kISO_CHAR_SET = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" "<>(){}[]|?!@#$%^&*"; // The location (in bytes) of the 3 digit currency inside a 160-bit value -constexpr std::size_t isoCodeOffset = 12; +constexpr std::size_t kISO_CODE_OFFSET = 12; // The length of an ISO-4217 like code -constexpr std::size_t isoCodeLength = 3; +constexpr std::size_t kISO_CODE_LENGTH = 3; } // namespace detail std::string to_string(Currency const& currency) { - if (currency == beast::zero) + if (currency == beast::kZERO) return systemCurrencyCode(); if (currency == noCurrency()) return "1"; - static constexpr Currency sIsoBits("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF"); + static constexpr Currency kS_ISO_BITS("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF"); - if ((currency & sIsoBits).isZero()) + if ((currency & kS_ISO_BITS).isZero()) { std::string const iso( - currency.data() + detail::isoCodeOffset, - currency.data() + detail::isoCodeOffset + detail::isoCodeLength); + currency.data() + detail::kISO_CODE_OFFSET, + currency.data() + detail::kISO_CODE_OFFSET + detail::kISO_CODE_LENGTH); // Specifying the system currency code using ISO-style representation // is not allowed. if ((iso != systemCurrencyCode()) && - (iso.find_first_not_of(detail::isoCharSet) == std::string::npos)) + (iso.find_first_not_of(detail::kISO_CHAR_SET) == std::string::npos)) { return iso; } @@ -62,23 +62,23 @@ to_string(Currency const& currency) } bool -to_currency(Currency& currency, std::string const& code) +toCurrency(Currency& currency, std::string const& code) { if (code.empty() || (code.compare(systemCurrencyCode()) == 0)) { - currency = beast::zero; + currency = beast::kZERO; return true; } // Handle ISO-4217-like 3-digit character codes. - if (code.size() == detail::isoCodeLength) + if (code.size() == detail::kISO_CODE_LENGTH) { - if (code.find_first_not_of(detail::isoCharSet) != std::string::npos) + if (code.find_first_not_of(detail::kISO_CHAR_SET) != std::string::npos) return false; - currency = beast::zero; + currency = beast::kZERO; - std::ranges::copy(code, currency.begin() + detail::isoCodeOffset); + std::ranges::copy(code, currency.begin() + detail::kISO_CODE_OFFSET); return true; } @@ -87,10 +87,10 @@ to_currency(Currency& currency, std::string const& code) } Currency -to_currency(std::string const& code) +toCurrency(std::string const& code) { Currency currency; - if (!to_currency(currency, code)) + if (!toCurrency(currency, code)) currency = noCurrency(); return currency; } @@ -98,22 +98,22 @@ to_currency(std::string const& code) Currency const& xrpCurrency() { - static Currency const currency(beast::zero); - return currency; + static Currency const kCURRENCY(beast::kZERO); + return kCURRENCY; } Currency const& noCurrency() { - static Currency const currency(1); - return currency; + static Currency const kCURRENCY(1); + return kCURRENCY; } Currency const& badCurrency() { - static Currency const currency(0x5852500000000000); - return currency; + static Currency const kCURRENCY(0x5852500000000000); + return kCURRENCY; } } // namespace xrpl diff --git a/src/libxrpl/protocol/XChainAttestations.cpp b/src/libxrpl/protocol/XChainAttestations.cpp index 8d3e62b31e..f89ad6a52c 100644 --- a/src/libxrpl/protocol/XChainAttestations.cpp +++ b/src/libxrpl/protocol/XChainAttestations.cpp @@ -27,20 +27,20 @@ namespace xrpl { namespace Attestations { AttestationBase::AttestationBase( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_) - : attestationSignerAccount{attestationSignerAccount_} - , publicKey{publicKey_} - , signature{std::move(signature_)} - , sendingAccount{sendingAccount_} - , sendingAmount{std::move(sendingAmount_)} - , rewardAccount{rewardAccount_} - , wasLockingChainSend{wasLockingChainSend_} + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend) + : attestationSignerAccount{attestationSignerAccount} + , publicKey{publicKey} + , signature{std::move(signature)} + , sendingAccount{sendingAccount} + , sendingAmount{std::move(sendingAmount)} + , rewardAccount{rewardAccount} + , wasLockingChainSend{wasLockingChainSend} { } @@ -90,14 +90,14 @@ AttestationBase::AttestationBase(STObject const& o) { } -AttestationBase::AttestationBase(Json::Value const& v) - : attestationSignerAccount{Json::getOrThrow(v, sfAttestationSignerAccount)} - , publicKey{Json::getOrThrow(v, sfPublicKey)} - , signature{Json::getOrThrow(v, sfSignature)} - , sendingAccount{Json::getOrThrow(v, sfAccount)} - , sendingAmount{Json::getOrThrow(v, sfAmount)} - , rewardAccount{Json::getOrThrow(v, sfAttestationRewardAccount)} - , wasLockingChainSend{Json::getOrThrow(v, sfWasLockingChainSend)} +AttestationBase::AttestationBase(json::Value const& v) + : attestationSignerAccount{json::getOrThrow(v, sfAttestationSignerAccount)} + , publicKey{json::getOrThrow(v, sfPublicKey)} + , signature{json::getOrThrow(v, sfSignature)} + , sendingAccount{json::getOrThrow(v, sfAccount)} + , sendingAmount{json::getOrThrow(v, sfAmount)} + , rewardAccount{json::getOrThrow(v, sfAttestationRewardAccount)} + , wasLockingChainSend{json::getOrThrow(v, sfWasLockingChainSend)} { } @@ -114,52 +114,52 @@ AttestationBase::addHelper(STObject& o) const } AttestationClaim::AttestationClaim( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t claimID_, - std::optional const& dst_) + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t claimId, + std::optional const& dst) : AttestationBase( - attestationSignerAccount_, - publicKey_, - std::move(signature_), - sendingAccount_, - sendingAmount_, - rewardAccount_, - wasLockingChainSend_) - , claimID{claimID_} - , dst{dst_} + attestationSignerAccount, + publicKey, + std::move(signature), + sendingAccount, + sendingAmount, + rewardAccount, + wasLockingChainSend) + , claimID{claimId} + , dst{dst} { } AttestationClaim::AttestationClaim( STXChainBridge const& bridge, - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - SecretKey const& secretKey_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t claimID_, - std::optional const& dst_) + AccountID attestationSignerAccount, + PublicKey const& publicKey, + SecretKey const& secretKey, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t claimId, + std::optional const& dst) : AttestationClaim{ - attestationSignerAccount_, - publicKey_, + attestationSignerAccount, + publicKey, Buffer{}, - sendingAccount_, - sendingAmount_, - rewardAccount_, - wasLockingChainSend_, - claimID_, - dst_} + sendingAccount, + sendingAmount, + rewardAccount, + wasLockingChainSend, + claimId, + dst} { auto const toSign = message(bridge); - signature = sign(publicKey_, secretKey_, makeSlice(toSign)); + signature = sign(publicKey, secretKey, makeSlice(toSign)); } AttestationClaim::AttestationClaim(STObject const& o) @@ -167,11 +167,11 @@ AttestationClaim::AttestationClaim(STObject const& o) { } -AttestationClaim::AttestationClaim(Json::Value const& v) - : AttestationBase{v}, claimID{Json::getOrThrow(v, sfXChainClaimID)} +AttestationClaim::AttestationClaim(json::Value const& v) + : AttestationBase{v}, claimID{json::getOrThrow(v, sfXChainClaimID)} { if (v.isMember(sfDestination.getJsonName())) - dst = Json::getOrThrow(v, sfDestination); + dst = json::getOrThrow(v, sfDestination); } STObject @@ -195,7 +195,7 @@ AttestationClaim::message( std::uint64_t claimID, std::optional const& dst) { - STObject o{sfGeneric}; + STObject o{kSF_GENERIC}; // Serialize in SField order to make python serializers easier to write o[sfXChainClaimID] = claimID; o[sfAmount] = sendingAmount; @@ -247,65 +247,65 @@ AttestationCreateAccount::AttestationCreateAccount(STObject const& o) { } -AttestationCreateAccount::AttestationCreateAccount(Json::Value const& v) +AttestationCreateAccount::AttestationCreateAccount(json::Value const& v) : AttestationBase{v} - , createCount{Json::getOrThrow(v, sfXChainAccountCreateCount)} - , toCreate{Json::getOrThrow(v, sfDestination)} - , rewardAmount{Json::getOrThrow(v, sfSignatureReward)} + , createCount{json::getOrThrow(v, sfXChainAccountCreateCount)} + , toCreate{json::getOrThrow(v, sfDestination)} + , rewardAmount{json::getOrThrow(v, sfSignatureReward)} { } AttestationCreateAccount::AttestationCreateAccount( - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - Buffer signature_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - STAmount rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t createCount_, - AccountID const& toCreate_) + AccountID attestationSignerAccount, + PublicKey const& publicKey, + Buffer signature, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + STAmount rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t createCount, + AccountID const& toCreate) : AttestationBase( - attestationSignerAccount_, - publicKey_, - std::move(signature_), - sendingAccount_, - sendingAmount_, - rewardAccount_, - wasLockingChainSend_) - , createCount{createCount_} - , toCreate{toCreate_} - , rewardAmount{std::move(rewardAmount_)} + attestationSignerAccount, + publicKey, + std::move(signature), + sendingAccount, + sendingAmount, + rewardAccount, + wasLockingChainSend) + , createCount{createCount} + , toCreate{toCreate} + , rewardAmount{std::move(rewardAmount)} { } AttestationCreateAccount::AttestationCreateAccount( STXChainBridge const& bridge, - AccountID attestationSignerAccount_, - PublicKey const& publicKey_, - SecretKey const& secretKey_, - AccountID const& sendingAccount_, - STAmount const& sendingAmount_, - STAmount const& rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::uint64_t createCount_, - AccountID const& toCreate_) + AccountID attestationSignerAccount, + PublicKey const& publicKey, + SecretKey const& secretKey, + AccountID const& sendingAccount, + STAmount const& sendingAmount, + STAmount const& rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::uint64_t createCount, + AccountID const& toCreate) : AttestationCreateAccount{ - attestationSignerAccount_, - publicKey_, + attestationSignerAccount, + publicKey, Buffer{}, - sendingAccount_, - sendingAmount_, - rewardAmount_, - rewardAccount_, - wasLockingChainSend_, - createCount_, - toCreate_} + sendingAccount, + sendingAmount, + rewardAmount, + rewardAccount, + wasLockingChainSend, + createCount, + toCreate} { auto const toSign = message(bridge); - signature = sign(publicKey_, secretKey_, makeSlice(toSign)); + signature = sign(publicKey, secretKey, makeSlice(toSign)); } STObject @@ -332,7 +332,7 @@ AttestationCreateAccount::message( std::uint64_t createCount, AccountID const& dst) { - STObject o{sfGeneric}; + STObject o{kSF_GENERIC}; // Serialize in SField order to make python serializers easier to write o[sfXChainAccountCreateCount] = createCount; o[sfAmount] = sendingAmount; @@ -387,39 +387,39 @@ operator==(AttestationCreateAccount const& lhs, AttestationCreateAccount const& } // namespace Attestations -SField const& XChainClaimAttestation::ArrayFieldName{sfXChainClaimAttestations}; -SField const& XChainCreateAccountAttestation::ArrayFieldName{sfXChainCreateAccountAttestations}; +SField const& XChainClaimAttestation::arrayFieldName{sfXChainClaimAttestations}; +SField const& XChainCreateAccountAttestation::arrayFieldName{sfXChainCreateAccountAttestations}; XChainClaimAttestation::XChainClaimAttestation( - AccountID const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - std::optional const& dst_) - : keyAccount(keyAccount_) - , publicKey(publicKey_) - , amount(sfAmount, amount_) - , rewardAccount(rewardAccount_) - , wasLockingChainSend(wasLockingChainSend_) - , dst(dst_) + AccountID const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + std::optional const& dst) + : keyAccount(keyAccount) + , publicKey(publicKey) + , amount(sfAmount, amount) + , rewardAccount(rewardAccount) + , wasLockingChainSend(wasLockingChainSend) + , dst(dst) { } XChainClaimAttestation::XChainClaimAttestation( - STAccount const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - STAccount const& rewardAccount_, - bool wasLockingChainSend_, - std::optional const& dst_) + STAccount const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + STAccount const& rewardAccount, + bool wasLockingChainSend, + std::optional const& dst) : XChainClaimAttestation{ - keyAccount_.value(), - publicKey_, - amount_, - rewardAccount_.value(), - wasLockingChainSend_, - dst_ ? std::optional{dst_->value()} : std::nullopt} + keyAccount.value(), + publicKey, + amount, + rewardAccount.value(), + wasLockingChainSend, + dst ? std::optional{dst->value()} : std::nullopt} { } @@ -432,17 +432,17 @@ XChainClaimAttestation::XChainClaimAttestation(STObject const& o) o[sfWasLockingChainSend] != 0, o[~sfDestination]} {}; -XChainClaimAttestation::XChainClaimAttestation(Json::Value const& v) +XChainClaimAttestation::XChainClaimAttestation(json::Value const& v) : XChainClaimAttestation{ - Json::getOrThrow(v, sfAttestationSignerAccount), - Json::getOrThrow(v, sfPublicKey), - Json::getOrThrow(v, sfAmount), - Json::getOrThrow(v, sfAttestationRewardAccount), - Json::getOrThrow(v, sfWasLockingChainSend), + json::getOrThrow(v, sfAttestationSignerAccount), + json::getOrThrow(v, sfPublicKey), + json::getOrThrow(v, sfAmount), + json::getOrThrow(v, sfAttestationRewardAccount), + json::getOrThrow(v, sfWasLockingChainSend), std::nullopt} { if (v.isMember(sfDestination.getJsonName())) - dst = Json::getOrThrow(v, sfDestination); + dst = json::getOrThrow(v, sfDestination); }; XChainClaimAttestation::XChainClaimAttestation( @@ -500,29 +500,29 @@ AttestationMatch XChainClaimAttestation::match(XChainClaimAttestation::MatchFields const& rhs) const { if (std::tie(amount, wasLockingChainSend) != std::tie(rhs.amount, rhs.wasLockingChainSend)) - return AttestationMatch::nonDstMismatch; + return AttestationMatch::NonDstMismatch; if (dst != rhs.dst) - return AttestationMatch::matchExceptDst; - return AttestationMatch::match; + return AttestationMatch::MatchExceptDst; + return AttestationMatch::Match; } //------------------------------------------------------------------------------ XChainCreateAccountAttestation::XChainCreateAccountAttestation( - AccountID const& keyAccount_, - PublicKey const& publicKey_, - STAmount const& amount_, - STAmount const& rewardAmount_, - AccountID const& rewardAccount_, - bool wasLockingChainSend_, - AccountID const& dst_) - : keyAccount(keyAccount_) - , publicKey(publicKey_) - , amount(sfAmount, amount_) - , rewardAmount(sfSignatureReward, rewardAmount_) - , rewardAccount(rewardAccount_) - , wasLockingChainSend(wasLockingChainSend_) - , dst(dst_) + AccountID const& keyAccount, + PublicKey const& publicKey, + STAmount const& amount, + STAmount const& rewardAmount, + AccountID const& rewardAccount, + bool wasLockingChainSend, + AccountID const& dst) + : keyAccount(keyAccount) + , publicKey(publicKey) + , amount(sfAmount, amount) + , rewardAmount(sfSignatureReward, rewardAmount) + , rewardAccount(rewardAccount) + , wasLockingChainSend(wasLockingChainSend) + , dst(dst) { } @@ -536,15 +536,15 @@ XChainCreateAccountAttestation::XChainCreateAccountAttestation(STObject const& o o[sfWasLockingChainSend] != 0, o[sfDestination]} {}; -XChainCreateAccountAttestation ::XChainCreateAccountAttestation(Json::Value const& v) +XChainCreateAccountAttestation ::XChainCreateAccountAttestation(json::Value const& v) : XChainCreateAccountAttestation{ - Json::getOrThrow(v, sfAttestationSignerAccount), - Json::getOrThrow(v, sfPublicKey), - Json::getOrThrow(v, sfAmount), - Json::getOrThrow(v, sfSignatureReward), - Json::getOrThrow(v, sfAttestationRewardAccount), - Json::getOrThrow(v, sfWasLockingChainSend), - Json::getOrThrow(v, sfDestination)} + json::getOrThrow(v, sfAttestationSignerAccount), + json::getOrThrow(v, sfPublicKey), + json::getOrThrow(v, sfAmount), + json::getOrThrow(v, sfSignatureReward), + json::getOrThrow(v, sfAttestationRewardAccount), + json::getOrThrow(v, sfWasLockingChainSend), + json::getOrThrow(v, sfDestination)} { } @@ -591,10 +591,10 @@ XChainCreateAccountAttestation::match(XChainCreateAccountAttestation::MatchField { if (std::tie(amount, rewardAmount, wasLockingChainSend) != std::tie(rhs.amount, rhs.rewardAmount, rhs.wasLockingChainSend)) - return AttestationMatch::nonDstMismatch; + return AttestationMatch::NonDstMismatch; if (dst != rhs.dst) - return AttestationMatch::matchExceptDst; - return AttestationMatch::match; + return AttestationMatch::MatchExceptDst; + return AttestationMatch::Match; } bool @@ -656,7 +656,7 @@ XChainAttestationsBase::end() } template -XChainAttestationsBase::XChainAttestationsBase(Json::Value const& v) +XChainAttestationsBase::XChainAttestationsBase(json::Value const& v) { if (!v.isObject()) { @@ -668,7 +668,7 @@ XChainAttestationsBase::XChainAttestationsBase(Json::Value const& attestations_ = [&] { auto const jAtts = v[jss::attestations]; - if (jAtts.size() > maxAttestations) + if (jAtts.size() > kMAX_ATTESTATIONS) Throw("XChainAttestationsBase exceeded max number of attestations"); std::vector r; @@ -682,7 +682,7 @@ XChainAttestationsBase::XChainAttestationsBase(Json::Value const& template XChainAttestationsBase::XChainAttestationsBase(STArray const& arr) { - if (arr.size() > maxAttestations) + if (arr.size() > kMAX_ATTESTATIONS) Throw("XChainAttestationsBase exceeded max number of attestations"); attestations_.reserve(arr.size()); @@ -694,9 +694,9 @@ template STArray XChainAttestationsBase::toSTArray() const { - STArray r{TAttestation::ArrayFieldName, attestations_.size()}; + STArray r{TAttestation::arrayFieldName, attestations_.size()}; for (auto const& e : attestations_) - r.emplace_back(e.toSTObject()); + r.emplaceBack(e.toSTObject()); return r; } diff --git a/src/libxrpl/protocol/digest.cpp b/src/libxrpl/protocol/digest.cpp index 0e03882c3c..2e1b2b25cf 100644 --- a/src/libxrpl/protocol/digest.cpp +++ b/src/libxrpl/protocol/digest.cpp @@ -7,21 +7,21 @@ namespace xrpl { -openssl_ripemd160_hasher::openssl_ripemd160_hasher() +OpensslRipemd160Hasher::OpensslRipemd160Hasher() { - static_assert(sizeof(decltype(openssl_ripemd160_hasher::ctx_)) == sizeof(RIPEMD160_CTX), ""); + static_assert(sizeof(decltype(OpensslRipemd160Hasher::ctx_)) == sizeof(RIPEMD160_CTX), ""); auto const ctx = reinterpret_cast(ctx_); RIPEMD160_Init(ctx); } void -openssl_ripemd160_hasher::operator()(void const* data, std::size_t size) noexcept +OpensslRipemd160Hasher::operator()(void const* data, std::size_t size) noexcept { auto const ctx = reinterpret_cast(ctx_); RIPEMD160_Update(ctx, data, size); } -openssl_ripemd160_hasher:: +OpensslRipemd160Hasher:: operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); @@ -32,21 +32,21 @@ operator result_type() noexcept //------------------------------------------------------------------------------ -openssl_sha512_hasher::openssl_sha512_hasher() +OpensslSha512Hasher::OpensslSha512Hasher() { - static_assert(sizeof(decltype(openssl_sha512_hasher::ctx_)) == sizeof(SHA512_CTX), ""); + static_assert(sizeof(decltype(OpensslSha512Hasher::ctx_)) == sizeof(SHA512_CTX), ""); auto const ctx = reinterpret_cast(ctx_); SHA512_Init(ctx); } void -openssl_sha512_hasher::operator()(void const* data, std::size_t size) noexcept +OpensslSha512Hasher::operator()(void const* data, std::size_t size) noexcept { auto const ctx = reinterpret_cast(ctx_); SHA512_Update(ctx, data, size); } -openssl_sha512_hasher:: +OpensslSha512Hasher:: operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); @@ -57,21 +57,21 @@ operator result_type() noexcept //------------------------------------------------------------------------------ -openssl_sha256_hasher::openssl_sha256_hasher() +OpensslSha256Hasher::OpensslSha256Hasher() { - static_assert(sizeof(decltype(openssl_sha256_hasher::ctx_)) == sizeof(SHA256_CTX), ""); + static_assert(sizeof(decltype(OpensslSha256Hasher::ctx_)) == sizeof(SHA256_CTX), ""); auto const ctx = reinterpret_cast(ctx_); SHA256_Init(ctx); } void -openssl_sha256_hasher::operator()(void const* data, std::size_t size) noexcept +OpensslSha256Hasher::operator()(void const* data, std::size_t size) noexcept { auto const ctx = reinterpret_cast(ctx_); SHA256_Update(ctx, data, size); } -openssl_sha256_hasher:: +OpensslSha256Hasher:: operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); diff --git a/src/libxrpl/protocol/tokens.cpp b/src/libxrpl/protocol/tokens.cpp index 3cb0e3f3dd..91063d3fa6 100644 --- a/src/libxrpl/protocol/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -122,15 +122,15 @@ coefficients sizes greatly speeds up the multi-precision computations. namespace xrpl { -static constexpr char const* alphabetForward = +static constexpr char const* kALPHABET_FORWARD = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"; -static constexpr std::array const alphabetReverse = []() { +static constexpr std::array const kALPHABET_REVERSE = []() { std::array map{}; for (auto& m : map) m = -1; - for (int i = 0, j = 0; alphabetForward[i] != 0; ++i) - map[static_cast(alphabetForward[i])] = j++; + for (int i = 0, j = 0; kALPHABET_FORWARD[i] != 0; ++i) + map[static_cast(kALPHABET_FORWARD[i])] = j++; return map; }(); @@ -199,7 +199,7 @@ namespace b58_ref { namespace detail { std::string -encodeBase58(void const* message, std::size_t size, void* temp, std::size_t temp_size) +encodeBase58(void const* message, std::size_t size, void* temp, std::size_t tempSize) { auto pbegin = reinterpret_cast(message); auto const pend = pbegin + size; @@ -213,7 +213,7 @@ encodeBase58(void const* message, std::size_t size, void* temp, std::size_t temp } auto const b58begin = reinterpret_cast(temp); - auto const b58end = b58begin + temp_size; + auto const b58end = b58begin + tempSize; std::fill(b58begin, b58end, 0); @@ -239,9 +239,9 @@ encodeBase58(void const* message, std::size_t size, void* temp, std::size_t temp // Translate the result into a string. std::string str; str.reserve(zeroes + (b58end - iter)); - str.assign(zeroes, alphabetForward[0]); + str.assign(zeroes, kALPHABET_FORWARD[0]); while (iter != b58end) - str += alphabetForward[*(iter++)]; + str += kALPHABET_FORWARD[*(iter++)]; return str; } @@ -252,7 +252,7 @@ decodeBase58(std::string const& s) auto remain = s.size(); // Skip and count leading zeroes int zeroes = 0; - while (remain > 0 && alphabetReverse[*psz] == 0) + while (remain > 0 && kALPHABET_REVERSE[*psz] == 0) { ++zeroes; ++psz; @@ -267,7 +267,7 @@ decodeBase58(std::string const& s) std::vector b256((remain * 733 / 1000) + 1); while (remain > 0) { - auto carry = alphabetReverse[*psz]; + auto carry = kALPHABET_REVERSE[*psz]; if (carry == -1) return {}; // Apply "b256 = b256 * 58 + carry". @@ -308,7 +308,7 @@ encodeBase58Token(TokenType type, void const* token, std::size_t size) // Lay the data out as // - buf[0] = safe_cast>(type); + buf[0] = safeCast>(type); if (size != 0u) std::memcpy(buf.data() + 1, token, size); checksum(buf.data() + 1 + size, buf.data(), 1 + size); @@ -326,7 +326,7 @@ decodeBase58Token(std::string const& s, TokenType type) return {}; // The type must match. - if (type != safe_cast(static_cast(ret[0]))) + if (type != safeCast(static_cast(ret[0]))) return {}; // And the checksum must as well. @@ -347,16 +347,16 @@ namespace b58_fast { namespace detail { // Note: both the input and output will be BIG ENDIAN B58Result> -b256_to_b58_be(std::span input, std::span out) +b256ToB58Be(std::span input, std::span out) { // Max valid input is 38 bytes: // (33 bytes for nodepublic + 1 byte token + 4 bytes checksum) if (input.size() > 38) { - return Unexpected(TokenCodecErrc::inputTooLarge); + return Unexpected(TokenCodecErrc::InputTooLarge); }; - auto count_leading_zeros = [](std::span const& col) -> std::size_t { + auto countLeadingZeros = [](std::span const& col) -> std::size_t { std::size_t count = 0; for (auto const& c : col) { @@ -369,106 +369,106 @@ b256_to_b58_be(std::span input, std::span out) return count; }; - auto const input_zeros = count_leading_zeros(input); - input = input.subspan(input_zeros); + auto const inputZeros = countLeadingZeros(input); + input = input.subspan(inputZeros); // Allocate enough base 2^64 coeff for encoding 38 bytes // log(2^(38*8),2^64)) ~= 4.75. So 5 coeff are enough - std::array base_2_64_coeff_buf{}; - std::span const base_2_64_coeff = [&]() -> std::span { + std::array base264CoeffBuf{}; + std::span const base264Coeff = [&]() -> std::span { // convert input from big endian to native u64, lowest coeff first - std::size_t num_coeff = 0; - for (int i = 0; i < base_2_64_coeff_buf.size(); ++i) + std::size_t numCoeff = 0; + for (int i = 0; i < base264CoeffBuf.size(); ++i) { if (i * 8 >= input.size()) { break; } - auto const src_i_end = input.size() - (i * 8); - if (src_i_end >= 8) + auto const srcIEnd = input.size() - (i * 8); + if (srcIEnd >= 8) { - std::memcpy(&base_2_64_coeff_buf[num_coeff], &input[src_i_end - 8], 8); - boost::endian::big_to_native_inplace(base_2_64_coeff_buf[num_coeff]); + std::memcpy(&base264CoeffBuf[numCoeff], &input[srcIEnd - 8], 8); + boost::endian::big_to_native_inplace(base264CoeffBuf[numCoeff]); } else { std::uint64_t be = 0; - for (int bi = 0; bi < src_i_end; ++bi) + for (int bi = 0; bi < srcIEnd; ++bi) { be <<= 8; be |= input[bi]; } - base_2_64_coeff_buf[num_coeff] = be; + base264CoeffBuf[numCoeff] = be; }; - num_coeff += 1; + numCoeff += 1; } - return std::span(base_2_64_coeff_buf.data(), num_coeff); + return std::span(base264CoeffBuf.data(), numCoeff); }(); // Allocate enough base 58^10 coeff for encoding 38 bytes // log(2^(38*8),58^10)) ~= 5.18. So 6 coeff are enough - std::array base_58_10_coeff{}; - constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10; - std::size_t num_58_10_coeffs = 0; - std::size_t cur_2_64_end = base_2_64_coeff.size(); + std::array base5810Coeff{}; + constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10; + std::size_t num5810Coeffs = 0; + std::size_t cur264End = base264Coeff.size(); // compute the base 58^10 coeffs - while (cur_2_64_end > 0) + while (cur264End > 0) { - base_58_10_coeff[num_58_10_coeffs] = xrpl::b58_fast::detail::inplace_bigint_div_rem( - base_2_64_coeff.subspan(0, cur_2_64_end), B_58_10); - num_58_10_coeffs += 1; - if (base_2_64_coeff[cur_2_64_end - 1] == 0) + base5810Coeff[num5810Coeffs] = + xrpl::b58_fast::detail::inplaceBigintDivRem(base264Coeff.subspan(0, cur264End), kB5810); + num5810Coeffs += 1; + if (base264Coeff[cur264End - 1] == 0) { - cur_2_64_end -= 1; + cur264End -= 1; } } // Translate the result into the alphabet // Put all the zeros at the beginning, then all the values from the output - std::fill(out.begin(), out.begin() + input_zeros, ::xrpl::alphabetForward[0]); + std::fill(out.begin(), out.begin() + inputZeros, ::xrpl::kALPHABET_FORWARD[0]); // iterate through the base 58^10 coeff // convert to base 58 big endian then // convert to alphabet big endian - bool skip_zeros = true; - auto out_index = input_zeros; - for (int i = num_58_10_coeffs - 1; i >= 0; --i) + bool skipZeros = true; + auto outIndex = inputZeros; + for (int i = num5810Coeffs - 1; i >= 0; --i) { - if (skip_zeros && base_58_10_coeff[i] == 0) + if (skipZeros && base5810Coeff[i] == 0) { continue; } - static constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10; - if (base_58_10_coeff[i] >= B_58_10) + static constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10; + if (base5810Coeff[i] >= kB5810) { - return Unexpected(TokenCodecErrc::inputTooLarge); + return Unexpected(TokenCodecErrc::InputTooLarge); } - std::array const b58_be = - xrpl::b58_fast::detail::b58_10_to_b58_be(base_58_10_coeff[i]); - std::size_t to_skip = 0; - std::span const b58_be_s{b58_be.data(), b58_be.size()}; - if (skip_zeros) + std::array const b58Be = + xrpl::b58_fast::detail::b5810ToB58Be(base5810Coeff[i]); + std::size_t toSkip = 0; + std::span const b58BeS{b58Be.data(), b58Be.size()}; + if (skipZeros) { - to_skip = count_leading_zeros(b58_be_s); - skip_zeros = false; - if (out.size() < ((i + 1) * 10) - to_skip) + toSkip = countLeadingZeros(b58BeS); + skipZeros = false; + if (out.size() < ((i + 1) * 10) - toSkip) { - return Unexpected(TokenCodecErrc::outputTooSmall); + return Unexpected(TokenCodecErrc::OutputTooSmall); } } - for (auto b58_coeff : b58_be_s.subspan(to_skip)) + for (auto b58Coeff : b58BeS.subspan(toSkip)) { - out[out_index] = ::xrpl::alphabetForward[b58_coeff]; - out_index += 1; + out[outIndex] = ::xrpl::kALPHABET_FORWARD[b58Coeff]; + outIndex += 1; } } - return out.subspan(0, out_index); + return out.subspan(0, outIndex); } // Note the input is BIG ENDIAN (some fn in this module use little endian) B58Result> -b58_to_b256_be(std::string_view input, std::span out) +b58ToB256Be(std::string_view input, std::span out) { // Convert from b58 to b 58^10 @@ -476,18 +476,18 @@ b58_to_b256_be(std::string_view input, std::span out) // log(2^(38*8),58) ~= 51.9 if (input.size() > 52) { - return Unexpected(TokenCodecErrc::inputTooLarge); + return Unexpected(TokenCodecErrc::InputTooLarge); }; if (out.size() < 8) { - return Unexpected(TokenCodecErrc::outputTooSmall); + return Unexpected(TokenCodecErrc::OutputTooSmall); } - auto count_leading_zeros = [&](auto const& col) -> std::size_t { + auto countLeadingZeros = [&](auto const& col) -> std::size_t { std::size_t count = 0; for (auto const& c : col) { - if (c != ::xrpl::alphabetForward[0]) + if (c != ::xrpl::kALPHABET_FORWARD[0]) { return count; } @@ -496,139 +496,139 @@ b58_to_b256_be(std::string_view input, std::span out) return count; }; - auto const input_zeros = count_leading_zeros(input); + auto const inputZeros = countLeadingZeros(input); // Allocate enough base 58^10 coeff for encoding 38 bytes // (33 bytes for nodepublic + 1 byte token + 4 bytes checksum) // log(2^(38*8),58^10)) ~= 5.18. So 6 coeff are enough - std::array b_58_10_coeff{}; - auto [num_full_coeffs, partial_coeff_len] = xrpl::b58_fast::detail::div_rem(input.size(), 10); - auto const num_partial_coeffs = (partial_coeff_len != 0u) ? 1 : 0; - auto const num_b_58_10_coeffs = num_full_coeffs + num_partial_coeffs; + std::array b5810Coeff{}; + auto [num_full_coeffs, partial_coeff_len] = xrpl::b58_fast::detail::divRem(input.size(), 10); + auto const numPartialCoeffs = (partial_coeff_len != 0u) ? 1 : 0; + auto const numB5810Coeffs = num_full_coeffs + numPartialCoeffs; XRPL_ASSERT( - num_b_58_10_coeffs <= b_58_10_coeff.size(), + numB5810Coeffs <= b5810Coeff.size(), "xrpl::b58_fast::detail::b58_to_b256_be : maximum coeff"); for (unsigned char const c : input.substr(0, partial_coeff_len)) { - auto cur_val = ::xrpl::alphabetReverse[c]; - if (cur_val < 0) + auto curVal = ::xrpl::kALPHABET_REVERSE[c]; + if (curVal < 0) { - return Unexpected(TokenCodecErrc::invalidEncodingChar); + return Unexpected(TokenCodecErrc::InvalidEncodingChar); } - b_58_10_coeff[0] *= 58; - b_58_10_coeff[0] += cur_val; + b5810Coeff[0] *= 58; + b5810Coeff[0] += curVal; } for (int i = 0; i < 10; ++i) { for (int j = 0; j < num_full_coeffs; ++j) { unsigned char const c = input[partial_coeff_len + (j * 10) + i]; - auto cur_val = ::xrpl::alphabetReverse[c]; - if (cur_val < 0) + auto curVal = ::xrpl::kALPHABET_REVERSE[c]; + if (curVal < 0) { - return Unexpected(TokenCodecErrc::invalidEncodingChar); + return Unexpected(TokenCodecErrc::InvalidEncodingChar); } - b_58_10_coeff[num_partial_coeffs + j] *= 58; - b_58_10_coeff[num_partial_coeffs + j] += cur_val; + b5810Coeff[numPartialCoeffs + j] *= 58; + b5810Coeff[numPartialCoeffs + j] += curVal; } } - constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10; + constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10; // log(2^(38*8),2^64) ~= 4.75) std::array result{}; - result[0] = b_58_10_coeff[0]; - std::size_t cur_result_size = 1; - for (int i = 1; i < num_b_58_10_coeffs; ++i) + result[0] = b5810Coeff[0]; + std::size_t curResultSize = 1; + for (int i = 1; i < numB5810Coeffs; ++i) { - std::uint64_t const c = b_58_10_coeff[i]; + std::uint64_t const c = b5810Coeff[i]; { - auto code = xrpl::b58_fast::detail::inplace_bigint_mul( - std::span(&result[0], cur_result_size + 1), B_58_10); - if (code != TokenCodecErrc::success) + auto code = xrpl::b58_fast::detail::inplaceBigintMul( + std::span(&result[0], curResultSize + 1), kB5810); + if (code != TokenCodecErrc::Success) { return Unexpected(code); } } { - auto code = xrpl::b58_fast::detail::inplace_bigint_add( - std::span(&result[0], cur_result_size + 1), c); - if (code != TokenCodecErrc::success) + auto code = xrpl::b58_fast::detail::inplaceBigintAdd( + std::span(&result[0], curResultSize + 1), c); + if (code != TokenCodecErrc::Success) { return Unexpected(code); } } - if (result[cur_result_size] != 0) + if (result[curResultSize] != 0) { - cur_result_size += 1; + curResultSize += 1; } } - std::fill(out.begin(), out.begin() + input_zeros, 0); - auto cur_out_i = input_zeros; + std::fill(out.begin(), out.begin() + inputZeros, 0); + auto curOutI = inputZeros; // Don't write leading zeros to the output for the most significant // coeff { - std::uint64_t const c = result[cur_result_size - 1]; - auto skip_zero = true; + std::uint64_t const c = result[curResultSize - 1]; + auto skipZero = true; // start and end of output range for (int i = 0; i < 8; ++i) { std::uint8_t const b = (c >> (8 * (7 - i))) & 0xff; - if (skip_zero) + if (skipZero) { if (b == 0) { continue; } - skip_zero = false; + skipZero = false; } - out[cur_out_i] = b; - cur_out_i += 1; + out[curOutI] = b; + curOutI += 1; } } - if ((cur_out_i + (8 * (cur_result_size - 1))) > out.size()) + if ((curOutI + (8 * (curResultSize - 1))) > out.size()) { - return Unexpected(TokenCodecErrc::outputTooSmall); + return Unexpected(TokenCodecErrc::OutputTooSmall); } - for (int i = cur_result_size - 2; i >= 0; --i) + for (int i = curResultSize - 2; i >= 0; --i) { auto c = result[i]; boost::endian::native_to_big_inplace(c); - memcpy(&out[cur_out_i], &c, 8); - cur_out_i += 8; + memcpy(&out[curOutI], &c, 8); + curOutI += 8; } - return out.subspan(0, cur_out_i); + return out.subspan(0, curOutI); } } // namespace detail B58Result> encodeBase58Token( - TokenType token_type, + TokenType tokenType, std::span input, std::span out) { - constexpr std::size_t tmpBufSize = 128; - std::array buf{}; - if (input.size() > tmpBufSize - 5) + constexpr std::size_t kTMP_BUF_SIZE = 128; + std::array buf{}; + if (input.size() > kTMP_BUF_SIZE - 5) { - return Unexpected(TokenCodecErrc::inputTooLarge); + return Unexpected(TokenCodecErrc::InputTooLarge); } if (input.empty()) { - return Unexpected(TokenCodecErrc::inputTooSmall); + return Unexpected(TokenCodecErrc::InputTooSmall); } // - buf[0] = static_cast(token_type); + buf[0] = static_cast(tokenType); // buf[1..=input.len()] = input; memcpy(&buf[1], input.data(), input.size()); - size_t const checksum_i = input.size() + 1; + size_t const checksumI = input.size() + 1; // buf[checksum_i..checksum_i + 4] = checksum - checksum(buf.data() + checksum_i, buf.data(), checksum_i); + checksum(buf.data() + checksumI, buf.data(), checksumI); std::span const b58Span(buf.data(), input.size() + 5); - return detail::b256_to_b58_be(b58Span, out); + return detail::b256ToB58Be(b58Span, out); } // Convert from base 58 to base 256, largest coefficients first // The input is encoded in XRPL format, with the token in the first @@ -639,7 +639,7 @@ B58Result> decodeBase58Token(TokenType type, std::string_view s, std::span outBuf) { std::array tmpBuf{}; - auto const decodeResult = detail::b58_to_b256_be(s, std::span(tmpBuf.data(), tmpBuf.size())); + auto const decodeResult = detail::b58ToB256Be(s, std::span(tmpBuf.data(), tmpBuf.size())); if (!decodeResult) return decodeResult; @@ -648,23 +648,23 @@ decodeBase58Token(TokenType type, std::string_view s, std::span ou // Reject zero length tokens if (ret.size() < 6) - return Unexpected(TokenCodecErrc::inputTooSmall); + return Unexpected(TokenCodecErrc::InputTooSmall); // The type must match. if (type != static_cast(static_cast(ret[0]))) - return Unexpected(TokenCodecErrc::mismatchedTokenType); + return Unexpected(TokenCodecErrc::MismatchedTokenType); // And the checksum must as well. std::array guard{}; checksum(guard.data(), ret.data(), ret.size() - guard.size()); if (!std::equal(guard.rbegin(), guard.rend(), ret.rbegin())) { - return Unexpected(TokenCodecErrc::mismatchedChecksum); + return Unexpected(TokenCodecErrc::MismatchedChecksum); } std::size_t const outSize = ret.size() - 1 - guard.size(); if (outBuf.size() < outSize) - return Unexpected(TokenCodecErrc::outputTooSmall); + return Unexpected(TokenCodecErrc::OutputTooSmall); // Skip the leading type byte and the trailing checksum. std::copy(ret.begin() + 1, ret.begin() + outSize + 1, outBuf.begin()); return outBuf.subspan(0, outSize); diff --git a/src/libxrpl/rdb/DatabaseCon.cpp b/src/libxrpl/rdb/DatabaseCon.cpp index cc7692de78..ac27a080c5 100644 --- a/src/libxrpl/rdb/DatabaseCon.cpp +++ b/src/libxrpl/rdb/DatabaseCon.cpp @@ -58,19 +58,19 @@ public: } }; -CheckpointersCollection checkpointers; +CheckpointersCollection gCheckpointers; std::shared_ptr checkpointerFromId(std::uintptr_t id) { - return checkpointers.fromId(id); + return gCheckpointers.fromId(id); } DatabaseCon::~DatabaseCon() { if (checkpointer_) { - checkpointers.erase(checkpointer_->id()); + gCheckpointers.erase(checkpointer_->id()); std::weak_ptr const wk(checkpointer_); checkpointer_.reset(); @@ -94,7 +94,7 @@ DatabaseCon::setupCheckpointing(JobQueue* q, ServiceRegistry& registry) { if (q == nullptr) Throw("No JobQueue"); - checkpointer_ = checkpointers.create(session_, *q, registry); + checkpointer_ = gCheckpointers.create(session_, *q, registry); } } // namespace xrpl diff --git a/src/libxrpl/rdb/SociDB.cpp b/src/libxrpl/rdb/SociDB.cpp index 1d69f1c984..541933b3b0 100644 --- a/src/libxrpl/rdb/SociDB.cpp +++ b/src/libxrpl/rdb/SociDB.cpp @@ -32,7 +32,7 @@ namespace xrpl { -static auto checkpointPageCount = 1000; +static auto gCheckpointPageCount = 1000; namespace detail { @@ -246,7 +246,7 @@ public: // If the Job is not added to the JobQueue then we're not running_. if (!jobQueue_.addJob( - jtWAL, + JtWal, "WAL", // If the owning DatabaseCon is destroyed, no need to checkpoint // or keep the checkpointer alive so use a weak_ptr to this. @@ -305,7 +305,7 @@ protected: static int sqliteWALHook(void* cpId, sqlite_api::sqlite3* conn, char const* dbName, int walSize) { - if (walSize >= checkpointPageCount) + if (walSize >= gCheckpointPageCount) { if (auto checkpointer = checkpointerFromId(reinterpret_cast(cpId))) { diff --git a/src/libxrpl/resource/Charge.cpp b/src/libxrpl/resource/Charge.cpp index 8626115c4c..e174c13522 100644 --- a/src/libxrpl/resource/Charge.cpp +++ b/src/libxrpl/resource/Charge.cpp @@ -8,53 +8,53 @@ namespace xrpl::Resource { -Charge::Charge(value_type cost, std::string label) : m_cost(cost), m_label(std::move(label)) +Charge::Charge(value_type cost, std::string label) : cost_(cost), label_(std::move(label)) { } std::string const& Charge::label() const { - return m_label; + return label_; } Charge::value_type Charge::cost() const { - return m_cost; + return cost_; } std::string -Charge::to_string() const +Charge::toString() const { std::stringstream ss; - ss << m_label << " ($" << m_cost << ")"; + ss << label_ << " ($" << cost_ << ")"; return ss.str(); } std::ostream& operator<<(std::ostream& os, Charge const& v) { - os << v.to_string(); + os << v.toString(); return os; } bool Charge::operator==(Charge const& c) const { - return c.m_cost == m_cost; + return c.cost_ == cost_; } std::strong_ordering Charge::operator<=>(Charge const& c) const { - return m_cost <=> c.m_cost; + return cost_ <=> c.cost_; } Charge Charge::operator*(value_type m) const { - return Charge(m_cost * m, m_label); + return Charge(cost_ * m, label_); } } // namespace xrpl::Resource diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index c57344bd8f..58d5775a31 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -14,27 +14,27 @@ namespace xrpl::Resource { -Consumer::Consumer(Logic& logic, Entry& entry) : m_logic(&logic), m_entry(&entry) +Consumer::Consumer(Logic& logic, Entry& entry) : logic_(&logic), entry_(&entry) { } -Consumer::Consumer() : m_logic(nullptr), m_entry(nullptr) +Consumer::Consumer() : logic_(nullptr), entry_(nullptr) { } -Consumer::Consumer(Consumer const& other) : m_logic(other.m_logic), m_entry(nullptr) +Consumer::Consumer(Consumer const& other) : logic_(other.logic_), entry_(nullptr) { - if ((m_logic != nullptr) && (other.m_entry != nullptr)) + if ((logic_ != nullptr) && (other.entry_ != nullptr)) { - m_entry = other.m_entry; - m_logic->acquire(*m_entry); + entry_ = other.entry_; + logic_->acquire(*entry_); } } Consumer::~Consumer() { - if ((m_logic != nullptr) && (m_entry != nullptr)) - m_logic->release(*m_entry); + if ((logic_ != nullptr) && (entry_ != nullptr)) + logic_->release(*entry_); } Consumer& @@ -44,33 +44,33 @@ Consumer::operator=(Consumer const& other) return *this; // remove old ref - if ((m_logic != nullptr) && (m_entry != nullptr)) - m_logic->release(*m_entry); + if ((logic_ != nullptr) && (entry_ != nullptr)) + logic_->release(*entry_); - m_logic = other.m_logic; - m_entry = other.m_entry; + logic_ = other.logic_; + entry_ = other.entry_; // add new ref - if ((m_logic != nullptr) && (m_entry != nullptr)) - m_logic->acquire(*m_entry); + if ((logic_ != nullptr) && (entry_ != nullptr)) + logic_->acquire(*entry_); return *this; } std::string -Consumer::to_string() const +Consumer::toString() const { - if (m_logic == nullptr) + if (logic_ == nullptr) return "(none)"; - return m_entry->to_string(); + return entry_->toString(); } bool Consumer::isUnlimited() const { - if (m_entry != nullptr) - return m_entry->isUnlimited(); + if (entry_ != nullptr) + return entry_->isUnlimited(); return false; } @@ -78,9 +78,9 @@ Consumer::isUnlimited() const Disposition Consumer::disposition() const { - Disposition d = Disposition::ok; - if ((m_logic != nullptr) && (m_entry != nullptr)) - d = m_logic->charge(*m_entry, Charge(0)); + Disposition d = Disposition::Ok; + if ((logic_ != nullptr) && (entry_ != nullptr)) + d = logic_->charge(*entry_, Charge(0)); return d; } @@ -88,10 +88,10 @@ Consumer::disposition() const Disposition Consumer::charge(Charge const& what, std::string const& context) { - Disposition d = Disposition::ok; + Disposition d = Disposition::Ok; - if ((m_logic != nullptr) && (m_entry != nullptr) && !m_entry->isUnlimited()) - d = m_logic->charge(*m_entry, what, context); + if ((logic_ != nullptr) && (entry_ != nullptr) && !entry_->isUnlimited()) + d = logic_->charge(*entry_, what, context); return d; } @@ -99,18 +99,18 @@ Consumer::charge(Charge const& what, std::string const& context) bool Consumer::warn() { - XRPL_ASSERT(m_entry, "xrpl::Resource::Consumer::warn : non-null entry"); - return m_logic->warn(*m_entry); + XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::warn : non-null entry"); + return logic_->warn(*entry_); } bool Consumer::disconnect(beast::Journal const& j) { - XRPL_ASSERT(m_entry, "xrpl::Resource::Consumer::disconnect : non-null entry"); - bool const d = m_logic->disconnect(*m_entry); + XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::disconnect : non-null entry"); + bool const d = logic_->disconnect(*entry_); if (d) { - JLOG(j.debug()) << "disconnecting " << m_entry->to_string(); + JLOG(j.debug()) << "disconnecting " << entry_->toString(); } return d; } @@ -118,27 +118,27 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - XRPL_ASSERT(m_entry, "xrpl::Resource::Consumer::balance : non-null entry"); - return m_logic->balance(*m_entry); + XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::balance : non-null entry"); + return logic_->balance(*entry_); } Entry& Consumer::entry() { - XRPL_ASSERT(m_entry, "xrpl::Resource::Consumer::entry : non-null entry"); - return *m_entry; + XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::entry : non-null entry"); + return *entry_; } void Consumer::setPublicKey(PublicKey const& publicKey) { - m_entry->publicKey = publicKey; + entry_->publicKey = publicKey; } std::ostream& operator<<(std::ostream& os, Consumer const& v) { - os << v.to_string(); + os << v.toString(); return os; } diff --git a/src/libxrpl/resource/Fees.cpp b/src/libxrpl/resource/Fees.cpp index e9f47b3e7d..8c9b72987f 100644 --- a/src/libxrpl/resource/Fees.cpp +++ b/src/libxrpl/resource/Fees.cpp @@ -4,24 +4,24 @@ namespace xrpl::Resource { -Charge const feeMalformedRequest(200, "malformed request"); -Charge const feeRequestNoReply(10, "unsatisfiable request"); -Charge const feeInvalidSignature(2000, "invalid signature"); -Charge const feeUselessData(150, "useless data"); -Charge const feeInvalidData(400, "invalid data"); +Charge const kFEE_MALFORMED_REQUEST(200, "malformed request"); +Charge const kFEE_REQUEST_NO_REPLY(10, "unsatisfiable request"); +Charge const kFEE_INVALID_SIGNATURE(2000, "invalid signature"); +Charge const kFEE_USELESS_DATA(150, "useless data"); +Charge const kFEE_INVALID_DATA(400, "invalid data"); -Charge const feeMalformedRPC(100, "malformed RPC"); -Charge const feeReferenceRPC(20, "reference RPC"); -Charge const feeExceptionRPC(100, "exceptioned RPC"); -Charge const feeMediumBurdenRPC(400, "medium RPC"); -Charge const feeHeavyBurdenRPC(3000, "heavy RPC"); +Charge const kFEE_MALFORMED_RPC(100, "malformed RPC"); +Charge const kFEE_REFERENCE_RPC(20, "reference RPC"); +Charge const kFEE_EXCEPTION_RPC(100, "exceptioned RPC"); +Charge const kFEE_MEDIUM_BURDEN_RPC(400, "medium RPC"); +Charge const kFEE_HEAVY_BURDEN_RPC(3000, "heavy RPC"); -Charge const feeTrivialPeer(1, "trivial peer request"); -Charge const feeModerateBurdenPeer(250, "moderate peer request"); -Charge const feeHeavyBurdenPeer(2000, "heavy peer request"); +Charge const kFEE_TRIVIAL_PEER(1, "trivial peer request"); +Charge const kFEE_MODERATE_BURDEN_PEER(250, "moderate peer request"); +Charge const kFEE_HEAVY_BURDEN_PEER(2000, "heavy peer request"); -Charge const feeWarning(4000, "received warning"); -Charge const feeDrop(6000, "dropped"); +Charge const kFEE_WARNING(4000, "received warning"); +Charge const kFEE_DROP(6000, "dropped"); // See also Resource::Logic::charge for log level cutoff values diff --git a/src/libxrpl/resource/ResourceManager.cpp b/src/libxrpl/resource/ResourceManager.cpp index e3f0ae8583..e3b4d9cc5c 100644 --- a/src/libxrpl/resource/ResourceManager.cpp +++ b/src/libxrpl/resource/ResourceManager.cpp @@ -77,11 +77,11 @@ public: if (ec) { journal_.warn() << "forwarded for (" << forwardedFor << ") from proxy " - << address.to_string() + << address.toString() << " doesn't convert to IP endpoint: " << ec.message(); return newInboundEndpoint(address); } - return newInboundEndpoint(beast::IPAddressConversion::from_asio(proxiedIp)); + return newInboundEndpoint(beast::IPAddressConversion::fromAsio(proxiedIp)); } Consumer @@ -110,13 +110,13 @@ public: //-------------------------------------------------------------------------- - Json::Value + json::Value getJson() override { return logic_.getJson(); } - Json::Value + json::Value getJson(int threshold) override { return logic_.getJson(threshold); @@ -159,7 +159,7 @@ Manager::~Manager() = default; //------------------------------------------------------------------------------ std::unique_ptr -make_Manager(beast::insight::Collector::ptr const& collector, beast::Journal journal) +makeManager(beast::insight::Collector::ptr const& collector, beast::Journal journal) { return std::make_unique(collector, journal); } diff --git a/src/libxrpl/server/InfoSub.cpp b/src/libxrpl/server/InfoSub.cpp index c426d44646..87b48296a1 100644 --- a/src/libxrpl/server/InfoSub.cpp +++ b/src/libxrpl/server/InfoSub.cpp @@ -21,48 +21,48 @@ namespace xrpl { // code assumes this node is synced (and will continue to do so until // there's a functional network. -InfoSub::InfoSub(Source& source) : m_source(source), mSeq(assign_id()) +InfoSub::InfoSub(Source& source) : source_(source), seq_(assignId()) { } InfoSub::InfoSub(Source& source, Consumer consumer) - : m_consumer(consumer), m_source(source), mSeq(assign_id()) + : consumer_(consumer), source_(source), seq_(assignId()) { } InfoSub::~InfoSub() { - m_source.unsubTransactions(mSeq); - m_source.unsubRTTransactions(mSeq); - m_source.unsubLedger(mSeq); - m_source.unsubManifests(mSeq); - m_source.unsubServer(mSeq); - m_source.unsubValidations(mSeq); - m_source.unsubPeerStatus(mSeq); - m_source.unsubConsensus(mSeq); + source_.unsubTransactions(seq_); + source_.unsubRTTransactions(seq_); + source_.unsubLedger(seq_); + source_.unsubManifests(seq_); + source_.unsubServer(seq_); + source_.unsubValidations(seq_); + source_.unsubPeerStatus(seq_); + source_.unsubConsensus(seq_); // Use the internal unsubscribe so that it won't call // back to us and modify its own parameter if (!realTimeSubscriptions_.empty()) - m_source.unsubAccountInternal(mSeq, realTimeSubscriptions_, true); + source_.unsubAccountInternal(seq_, realTimeSubscriptions_, true); if (!normalSubscriptions_.empty()) - m_source.unsubAccountInternal(mSeq, normalSubscriptions_, false); + source_.unsubAccountInternal(seq_, normalSubscriptions_, false); for (auto const& account : accountHistorySubscriptions_) - m_source.unsubAccountHistoryInternal(mSeq, account, false); + source_.unsubAccountHistoryInternal(seq_, account, false); } Resource::Consumer& InfoSub::getConsumer() { - return m_consumer; + return consumer_; } std::uint64_t InfoSub::getSeq() const { - return mSeq; + return seq_; } void @@ -73,7 +73,7 @@ InfoSub::onSendEmpty() void InfoSub::insertSubAccountInfo(AccountID const& account, bool rt) { - std::scoped_lock const sl(mLock); + std::scoped_lock const sl(lock_); if (rt) { @@ -88,7 +88,7 @@ InfoSub::insertSubAccountInfo(AccountID const& account, bool rt) void InfoSub::deleteSubAccountInfo(AccountID const& account, bool rt) { - std::scoped_lock const sl(mLock); + std::scoped_lock const sl(lock_); if (rt) { @@ -103,14 +103,14 @@ InfoSub::deleteSubAccountInfo(AccountID const& account, bool rt) bool InfoSub::insertSubAccountHistory(AccountID const& account) { - std::scoped_lock const sl(mLock); + std::scoped_lock const sl(lock_); return accountHistorySubscriptions_.insert(account).second; } void InfoSub::deleteSubAccountHistory(AccountID const& account) { - std::scoped_lock const sl(mLock); + std::scoped_lock const sl(lock_); accountHistorySubscriptions_.erase(account); } diff --git a/src/libxrpl/server/JSONRPCUtil.cpp b/src/libxrpl/server/JSONRPCUtil.cpp index 280aeeeebc..f38ff280ac 100644 --- a/src/libxrpl/server/JSONRPCUtil.cpp +++ b/src/libxrpl/server/JSONRPCUtil.cpp @@ -20,18 +20,18 @@ getHTTPHeaderTimestamp() char buffer[96]; time_t now = 0; time(&now); - struct tm now_gmt{}; + struct tm nowGmt{}; #ifndef _MSC_VER - gmtime_r(&now, &now_gmt); + gmtime_r(&now, &nowGmt); #else - gmtime_s(&now_gmt, &now); + gmtime_s(&nowGmt, &now); #endif - strftime(buffer, sizeof(buffer), "Date: %a, %d %b %Y %H:%M:%S +0000\r\n", &now_gmt); + strftime(buffer, sizeof(buffer), "Date: %a, %d %b %Y %H:%M:%S +0000\r\n", &nowGmt); return std::string(buffer); } void -HTTPReply(int nStatus, std::string const& content, Json::Output const& output, beast::Journal j) +httpReply(int nStatus, std::string const& content, json::Output const& output, beast::Journal j) { JLOG(j.trace()) << "HTTP Reply " << nStatus << " " << content; diff --git a/src/libxrpl/server/LoadFeeTrack.cpp b/src/libxrpl/server/LoadFeeTrack.cpp index 2fa7e1beba..085e846145 100644 --- a/src/libxrpl/server/LoadFeeTrack.cpp +++ b/src/libxrpl/server/LoadFeeTrack.cpp @@ -27,9 +27,9 @@ LoadFeeTrack::raiseLocalFee() localTxnLoadFee_ = std::max(localTxnLoadFee_, remoteTxnLoadFee_); // Increase slowly - localTxnLoadFee_ += (localTxnLoadFee_ / lftFeeIncFraction); + localTxnLoadFee_ += (localTxnLoadFee_ / kLFT_FEE_INC_FRACTION); - localTxnLoadFee_ = std::min(localTxnLoadFee_, lftFeeMax); + localTxnLoadFee_ = std::min(localTxnLoadFee_, kLFT_FEE_MAX); if (origFee == localTxnLoadFee_) return false; @@ -46,9 +46,9 @@ LoadFeeTrack::lowerLocalFee() raiseCount_ = 0; // Reduce slowly - localTxnLoadFee_ -= (localTxnLoadFee_ / lftFeeDecFraction); + localTxnLoadFee_ -= (localTxnLoadFee_ / kLFT_FEE_DEC_FRACTION); - localTxnLoadFee_ = std::max(localTxnLoadFee_, lftNormalFee); + localTxnLoadFee_ = std::max(localTxnLoadFee_, kLFT_NORMAL_FEE); if (origFee == localTxnLoadFee_) return false; @@ -78,7 +78,7 @@ scaleFeeLoad(XRPAmount fee, LoadFeeTrack const& feeTrack, Fees const& fees, bool // fee = fee * feeFactor / (lftNormalFee); // without overflow, and as accurately as possible - auto const result = mulDiv(fee, feeFactor, safe_cast(feeTrack.getLoadBase())); + auto const result = mulDiv(fee, feeFactor, safeCast(feeTrack.getLoadBase())); if (!result) Throw("scaleFeeLoad"); return *result; diff --git a/src/libxrpl/server/Manifest.cpp b/src/libxrpl/server/Manifest.cpp index 0108b78782..fd38d02d6b 100644 --- a/src/libxrpl/server/Manifest.cpp +++ b/src/libxrpl/server/Manifest.cpp @@ -62,37 +62,37 @@ deserializeManifest(Slice s, beast::Journal journal) if (s.empty()) return std::nullopt; - static SOTemplate const manifestFormat{ + static SOTemplate const kMANIFEST_FORMAT{ // A manifest must include: // - the master public key - {sfPublicKey, soeREQUIRED}, + {sfPublicKey, SoeRequired}, // - a signature with that public key - {sfMasterSignature, soeREQUIRED}, + {sfMasterSignature, SoeRequired}, // - a sequence number - {sfSequence, soeREQUIRED}, + {sfSequence, SoeRequired}, // It may, optionally, contain: // - a version number which defaults to 0 - {sfVersion, soeDEFAULT}, + {sfVersion, SoeDefault}, // - a domain name - {sfDomain, soeOPTIONAL}, + {sfDomain, SoeOptional}, // - an ephemeral signing key that can be changed as necessary - {sfSigningPubKey, soeOPTIONAL}, + {sfSigningPubKey, SoeOptional}, // - a signature using the ephemeral signing key, if it is present - {sfSignature, soeOPTIONAL}, + {sfSignature, SoeOptional}, }; try { SerialIter sit{s}; - STObject st{sit, sfGeneric}; + STObject st{sit, kSF_GENERIC}; - st.applyTemplate(manifestFormat); + st.applyTemplate(kMANIFEST_FORMAT); // We only understand "version 0" manifests at this time: if (st.isFieldPresent(sfVersion) && st.getFieldU16(sfVersion) != 0) @@ -193,7 +193,7 @@ logMftAct( bool Manifest::verify() const { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); SerialIter sit(serialized.data(), serialized.size()); st.set(sit); @@ -204,19 +204,19 @@ Manifest::verify() const // Signing key and signature are not required for // master key revocations - if (!revoked() && !xrpl::verify(st, HashPrefix::manifest, *signingKey)) + if (!revoked() && !xrpl::verify(st, HashPrefix::Manifest, *signingKey)) return false; - return xrpl::verify(st, HashPrefix::manifest, masterKey, sfMasterSignature); + return xrpl::verify(st, HashPrefix::Manifest, masterKey, sfMasterSignature); } uint256 Manifest::hash() const { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); SerialIter sit(serialized.data(), serialized.size()); st.set(sit); - return st.getHash(HashPrefix::manifest); + return st.getHash(HashPrefix::Manifest); } bool @@ -240,7 +240,7 @@ Manifest::revoked(std::uint32_t sequence) std::optional Manifest::getSignature() const { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); SerialIter sit(serialized.data(), serialized.size()); st.set(sit); if (!get(st, sfSignature)) @@ -251,7 +251,7 @@ Manifest::getSignature() const Blob Manifest::getMasterSignature() const { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); SerialIter sit(serialized.data(), serialized.size()); st.set(sit); return st.getFieldVL(sfMasterSignature); @@ -274,15 +274,15 @@ loadValidatorToken(std::vector const& blob, beast::Journal journal) for (auto const& line : blob) tokenStr += boost::algorithm::trim_copy(line); - tokenStr = base64_decode(tokenStr); + tokenStr = base64Decode(tokenStr); - Json::Reader r; - Json::Value token; + json::Reader r; + json::Value token; if (r.parse(tokenStr, token)) { - auto const m = token.get("manifest", Json::Value{}); - auto const k = token.get("validation_secret_key", Json::Value{}); + auto const m = token.get("manifest", json::Value{}); + auto const k = token.get("validation_secret_key", json::Value{}); if (m.isString() && k.isString()) { @@ -398,14 +398,14 @@ ManifestCache::applyManifest(Manifest m) // doesn't have the latest data. if (auto stream = j_.debug()) logMftAct(stream, "Stale", m.masterKey, m.sequence, iter->second.sequence); - return ManifestDisposition::stale; + return ManifestDisposition::Stale; } if (checkSignature && !m.verify()) { if (auto stream = j_.warn()) logMftAct(stream, "Invalid", m.masterKey, m.sequence); - return ManifestDisposition::invalid; + return ManifestDisposition::Invalid; } // If the master key associated with a manifest is or might be @@ -427,7 +427,7 @@ ManifestCache::applyManifest(Manifest m) JLOG(j_.warn()) << to_string(m) << ": Master key already used as ephemeral key for " << toBase58(TokenType::NodePublic, x->second); - return ManifestDisposition::badMasterKey; + return ManifestDisposition::BadMasterKey; } if (!revoked) @@ -438,7 +438,7 @@ ManifestCache::applyManifest(Manifest m) << ": is not revoked and the manifest has no " "signing key. Hence, the manifest is " "invalid"; - return ManifestDisposition::invalid; + return ManifestDisposition::Invalid; } // Sanity check: the ephemeral key of this manifest should not be @@ -450,7 +450,7 @@ ManifestCache::applyManifest(Manifest m) << ": Ephemeral key already used as ephemeral key for " << toBase58(TokenType::NodePublic, x->second); - return ManifestDisposition::badEphemeralKey; + return ManifestDisposition::BadEphemeralKey; } if (auto const x = map_.find(*m.signingKey); x != map_.end()) @@ -458,7 +458,7 @@ ManifestCache::applyManifest(Manifest m) JLOG(j_.warn()) << to_string(m) << ": Ephemeral key used as master key for " << to_string(x->second); - return ManifestDisposition::badEphemeralKey; + return ManifestDisposition::BadEphemeralKey; } } @@ -506,7 +506,7 @@ ManifestCache::applyManifest(Manifest m) // Something has changed. Keep track of it. seq_++; - return ManifestDisposition::accepted; + return ManifestDisposition::Accepted; } // An ephemeral key was revoked and superseded by a new key. This is @@ -530,7 +530,7 @@ ManifestCache::applyManifest(Manifest m) // Something has changed. Keep track of it. seq_++; - return ManifestDisposition::accepted; + return ManifestDisposition::Accepted; } void @@ -551,7 +551,7 @@ ManifestCache::load( if (!configManifest.empty()) { - auto mo = deserializeManifest(base64_decode(configManifest)); + auto mo = deserializeManifest(base64Decode(configManifest)); if (!mo) { JLOG(j_.error()) << "Malformed validator_token in config"; @@ -563,7 +563,7 @@ ManifestCache::load( JLOG(j_.warn()) << "Configured manifest revokes public key"; } - if (applyManifest(std::move(*mo)) == ManifestDisposition::invalid) + if (applyManifest(std::move(*mo)) == ManifestDisposition::Invalid) { JLOG(j_.error()) << "Manifest in config was rejected"; return false; @@ -583,9 +583,9 @@ ManifestCache::load( for (auto const& line : configRevocation) revocationStr += boost::algorithm::trim_copy(line); - auto mo = deserializeManifest(base64_decode(revocationStr)); + auto mo = deserializeManifest(base64Decode(revocationStr)); - if (!mo || !mo->revoked() || applyManifest(std::move(*mo)) == ManifestDisposition::invalid) + if (!mo || !mo->revoked() || applyManifest(std::move(*mo)) == ManifestDisposition::Invalid) { JLOG(j_.error()) << "Invalid validator key revocation in config"; return false; diff --git a/src/libxrpl/server/Port.cpp b/src/libxrpl/server/Port.cpp index 99466446d6..228b65df43 100644 --- a/src/libxrpl/server/Port.cpp +++ b/src/libxrpl/server/Port.cpp @@ -61,7 +61,7 @@ operator<<(std::ostream& os, Port const& p) if (!p.secure_gateway_nets_v4.empty() || !p.secure_gateway_nets_v6.empty()) { - os << "secure_gateway nets:"; + os << "secureGateway nets:"; for (auto const& net : p.secure_gateway_nets_v4) { os << net.to_string(); @@ -106,10 +106,10 @@ populate( { // First, check to see if 0.0.0.0 or ipv6 equivalent was configured, // which means all IP addresses. - auto const addr = beast::IP::Endpoint::from_string_checked(ip); + auto const addr = beast::IP::Endpoint::fromStringChecked(ip); if (addr) { - if (is_unspecified(*addr)) + if (isUnspecified(*addr)) { nets4.push_back(boost::asio::ip::make_network_v4("0.0.0.0/0")); nets6.push_back(boost::asio::ip::make_network_v6("::/0")); @@ -121,8 +121,8 @@ populate( // be unset). We need this to be a subnet, so append // the number of network bits to make a subnet of 1, // depending on type. - v4 = addr->is_v4(); - std::string addressString = addr->to_string(); + v4 = addr->isV4(); + std::string addressString = addr->toString(); if (v4) { addressString += "/32"; @@ -191,7 +191,7 @@ populate( } void -parse_Port(ParsedPort& port, Section const& section, std::ostream& log) +parsePort(ParsedPort& port, Section const& section, std::ostream& log) { port.name = section.name(); { @@ -206,7 +206,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) { log << "Invalid value '" << *optResult << "' for key 'ip' in [" << section.name() << "]"; - Rethrow(); + rethrow(); } } } @@ -227,7 +227,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) { log << "Invalid value '" << *optResult << "' for key " << "'port' in [" << section.name() << "]"; - Rethrow(); + rethrow(); } } } @@ -236,7 +236,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) auto const optResult = section.get("protocol"); if (optResult) { - for (auto const& s : beast::rfc2616::split_commas(optResult->begin(), optResult->end())) + for (auto const& s : beast::rfc2616::splitCommas(optResult->begin(), optResult->end())) port.protocol.insert(s); } } @@ -248,13 +248,13 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) { try { - port.limit = safe_cast(beast::lexicalCastThrow(lim)); + port.limit = safeCast(beast::lexicalCastThrow(lim)); } catch (std::exception const&) { log << "Invalid value '" << lim << "' for key " << "'limit' in [" << section.name() << "]"; - Rethrow(); + rethrow(); } } } @@ -275,7 +275,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) { log << "Invalid value '" << *optResult << "' for key " << "'send_queue_limit' in [" << section.name() << "]"; - Rethrow(); + rethrow(); } } else @@ -287,7 +287,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) populate(section, "admin", log, port.admin_nets_v4, port.admin_nets_v6); populate( - section, "secure_gateway", log, port.secure_gateway_nets_v4, port.secure_gateway_nets_v6); + section, "secureGateway", log, port.secure_gateway_nets_v4, port.secure_gateway_nets_v6); set(port.user, "user", section); set(port.password, "password", section); @@ -298,15 +298,15 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) set(port.ssl_chain, "ssl_chain", section); set(port.ssl_ciphers, "ssl_ciphers", section); - port.pmd_options.server_enable = section.value_or("permessage_deflate", true); - port.pmd_options.client_max_window_bits = section.value_or("client_max_window_bits", 15); - port.pmd_options.server_max_window_bits = section.value_or("server_max_window_bits", 15); + port.pmd_options.server_enable = section.valueOr("permessage_deflate", true); + port.pmd_options.client_max_window_bits = section.valueOr("client_max_window_bits", 15); + port.pmd_options.server_max_window_bits = section.valueOr("server_max_window_bits", 15); port.pmd_options.client_no_context_takeover = - section.value_or("client_no_context_takeover", false); + section.valueOr("client_no_context_takeover", false); port.pmd_options.server_no_context_takeover = - section.value_or("server_no_context_takeover", false); - port.pmd_options.compLevel = section.value_or("compress_level", 8); - port.pmd_options.memLevel = section.value_or("memory_level", 4); + section.valueOr("server_no_context_takeover", false); + port.pmd_options.compLevel = section.valueOr("compress_level", 8); + port.pmd_options.memLevel = section.valueOr("memory_level", 4); } } // namespace xrpl diff --git a/src/libxrpl/server/Vacuum.cpp b/src/libxrpl/server/Vacuum.cpp index d0e430ead9..140ef04def 100644 --- a/src/libxrpl/server/Vacuum.cpp +++ b/src/libxrpl/server/Vacuum.cpp @@ -20,7 +20,7 @@ namespace xrpl { bool doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j) { - boost::filesystem::path const dbPath = setup.dataDir / TxDBName; + boost::filesystem::path const dbPath = setup.dataDir / kTX_DB_NAME; uintmax_t const dbSize = file_size(dbPath); XRPL_ASSERT(dbSize != static_cast(-1), "xrpl::doVacuumDB : file_size succeeded"); @@ -34,14 +34,14 @@ doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j) return false; } - auto txnDB = std::make_unique(setup, TxDBName, setup.txPragma, TxDBInit, j); + auto txnDB = std::make_unique(setup, kTX_DB_NAME, setup.txPragma, kTX_DB_INIT, j); auto& session = txnDB->getSession(); std::uint32_t pageSize = 0; // Only the most trivial databases will fit in memory on typical // (recommended) hardware. Force temp files to be written to disk // regardless of the config settings. - session << boost::format(CommonDBPragmaTemp) % "file"; + session << boost::format(kCOMMON_DB_PRAGMA_TEMP) % "file"; session << "PRAGMA page_size;", soci::into(pageSize); std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl; diff --git a/src/libxrpl/server/Wallet.cpp b/src/libxrpl/server/Wallet.cpp index 7906867654..ee579c7b9f 100644 --- a/src/libxrpl/server/Wallet.cpp +++ b/src/libxrpl/server/Wallet.cpp @@ -40,7 +40,7 @@ makeWalletDB(DatabaseCon::Setup const& setup, beast::Journal j) { // wallet database return std::make_unique( - setup, WalletDBName, std::array(), WalletDBInit, j); + setup, kWALLET_DB_NAME, std::array(), kWALLET_DB_INIT, j); } std::unique_ptr @@ -48,14 +48,14 @@ makeTestWalletDB(DatabaseCon::Setup const& setup, std::string const& dbname, bea { // wallet database return std::make_unique( - setup, dbname.data(), std::array(), WalletDBInit, j); + setup, dbname.data(), std::array(), kWALLET_DB_INIT, j); } void getManifests( soci::session& session, std::string const& dbTable, - ManifestCache& mCache, + ManifestCache& cache, beast::Journal j) { // Load manifests stored in database @@ -75,7 +75,7 @@ getManifests( continue; } - mCache.applyManifest(std::move(*mo)); + cache.applyManifest(std::move(*mo)); } else { @@ -151,13 +151,13 @@ getNodeIdentity(soci::session& session) auto const pk = parseBase58(TokenType::NodePublic, pubKO.value_or("")); // Only use if the public and secret keys are a pair - if (sk && pk && (*pk == derivePublicKey(KeyType::secp256k1, *sk))) + if (sk && pk && (*pk == derivePublicKey(KeyType::Secp256k1, *sk))) return {*pk, *sk}; } } // If a valid identity wasn't found, we randomly generate a new one: - auto [newpublicKey, newsecretKey] = randomKeyPair(KeyType::secp256k1); + auto [newpublicKey, newsecretKey] = randomKeyPair(KeyType::Secp256k1); session << str( boost::format( @@ -169,10 +169,10 @@ getNodeIdentity(soci::session& session) return {newpublicKey, newsecretKey}; } -std::unordered_set, KeyEqual> +std::unordered_set, KeyEqual> getPeerReservationTable(soci::session& session, beast::Journal j) { - std::unordered_set, KeyEqual> table; + std::unordered_set, KeyEqual> table; // These values must be boost::optionals (not std) because SOCI expects // boost::optionals. boost::optional valPubKey, valDesc; @@ -253,13 +253,13 @@ void readAmendments( soci::session& session, std::function amendment_hash, - boost::optional amendment_name, + boost::optional amendmentHash, + boost::optional amendmentName, boost::optional vote)> const& callback) { // lambda that converts the internally stored int to an AmendmentVote. auto intToVote = [](boost::optional const& dbVote) -> boost::optional { - return safe_cast(dbVote.value_or(1)); + return safeCast(dbVote.value_or(1)); }; soci::transaction const tr(session); @@ -269,18 +269,18 @@ readAmendments( "( PARTITION BY AmendmentHash ORDER BY ROWID DESC ) " "as rnk FROM FeatureVotes ) WHERE rnk = 1"; // SOCI requires boost::optional (not std::optional) as parameters. - boost::optional amendment_hash; - boost::optional amendment_name; - boost::optional vote_to_veto; + boost::optional amendmentHash; + boost::optional amendmentName; + boost::optional voteToVeto; soci::statement st = (session.prepare << sql, - soci::into(amendment_hash), - soci::into(amendment_name), - soci::into(vote_to_veto)); + soci::into(amendmentHash), + soci::into(amendmentName), + soci::into(voteToVeto)); st.execute(); while (st.fetch()) { - callback(amendment_hash, amendment_name, intToVote(vote_to_veto)); + callback(amendmentHash, amendmentName, intToVote(voteToVeto)); } } @@ -297,7 +297,7 @@ voteAmendment( "('"; sql += to_string(amendment); sql += "', '" + name; - sql += "', '" + std::to_string(safe_cast(vote)) + "');"; + sql += "', '" + std::to_string(safeCast(vote)) + "');"; session << sql; tr.commit(); } diff --git a/src/libxrpl/shamap/SHAMap.cpp b/src/libxrpl/shamap/SHAMap.cpp index 837724babe..795c097118 100644 --- a/src/libxrpl/shamap/SHAMap.cpp +++ b/src/libxrpl/shamap/SHAMap.cpp @@ -43,16 +43,16 @@ namespace xrpl { [[nodiscard]] intr_ptr::SharedPtr makeTypedLeaf(SHAMapNodeType type, boost::intrusive_ptr item, std::uint32_t owner) { - if (type == SHAMapNodeType::tnTRANSACTION_NM) - return intr_ptr::make_shared(std::move(item), owner); + if (type == SHAMapNodeType::TnTransactionNm) + return intr_ptr::makeShared(std::move(item), owner); - if (type == SHAMapNodeType::tnTRANSACTION_MD) - return intr_ptr::make_shared(std::move(item), owner); + if (type == SHAMapNodeType::TnTransactionMd) + return intr_ptr::makeShared(std::move(item), owner); - if (type == SHAMapNodeType::tnACCOUNT_STATE) - return intr_ptr::make_shared(std::move(item), owner); + if (type == SHAMapNodeType::TnAccountState) + return intr_ptr::makeShared(std::move(item), owner); - LogicError( + logicError( "Attempt to create leaf node of unknown type " + std::to_string(static_cast>(type))); } @@ -60,7 +60,7 @@ makeTypedLeaf(SHAMapNodeType type, boost::intrusive_ptr item, SHAMap::SHAMap(SHAMapType t, Family& f) : f_(f), journal_(f.journal()), state_(SHAMapState::Modifying), type_(t) { - root_ = intr_ptr::make_shared(cowid_); + root_ = intr_ptr::makeShared(cowid_); } // The `hash` parameter is unused. It is part of the interface so it's clear @@ -70,7 +70,7 @@ SHAMap::SHAMap(SHAMapType t, Family& f) SHAMap::SHAMap(SHAMapType t, uint256 const& hash, Family& f) : f_(f), journal_(f.journal()), state_(SHAMapState::Synching), type_(t) { - root_ = intr_ptr::make_shared(cowid_); + root_ = intr_ptr::makeShared(cowid_); } SHAMap::SHAMap(SHAMap const& other, bool isMutable) @@ -114,7 +114,7 @@ SHAMap::dirtyUp( while (!stack.empty()) { - auto node = intr_ptr::dynamic_pointer_cast(stack.top().first); + auto node = intr_ptr::dynamicPointerCast(stack.top().first); SHAMapNodeID const nodeID = stack.top().second; stack.pop(); XRPL_ASSERT(node, "xrpl::SHAMap::dirtyUp : non-null node"); @@ -142,7 +142,7 @@ SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const if (stack != nullptr) stack->emplace(inNode, nodeID); - auto const inner = intr_ptr::static_pointer_cast(inNode); + auto const inner = intr_ptr::staticPointerCast(inNode); auto const branch = selectBranch(nodeID, id); if (inner->isEmptyBranch(branch)) return nullptr; @@ -153,7 +153,7 @@ SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const if (stack != nullptr) stack->emplace(inNode, nodeID); - return safe_downcast(inNode.get()); + return safeDowncast(inNode.get()); } SHAMapLeafNode* @@ -169,7 +169,7 @@ intr_ptr::SharedPtr SHAMap::fetchNodeFromDB(SHAMapHash const& hash) const { XRPL_ASSERT(backed_, "xrpl::SHAMap::fetchNodeFromDB : is backed"); - auto obj = f_.db().fetchNodeObject(hash.as_uint256(), ledgerSeq_); + auto obj = f_.db().fetchNodeObject(hash.asUint256(), ledgerSeq_); return finishFetch(hash, obj); } @@ -185,7 +185,7 @@ SHAMap::finishFetch(SHAMapHash const& hash, std::shared_ptr const& o if (full_) { full_ = false; - f_.missingNodeAcquireBySeq(ledgerSeq_, hash.as_uint256()); + f_.missingNodeAcquireBySeq(ledgerSeq_, hash.asUint256()); } return {}; } @@ -352,7 +352,7 @@ SHAMap::descend( { XRPL_ASSERT(parent->isInner(), "xrpl::SHAMap::descend : valid parent input"); XRPL_ASSERT( - (branch >= 0) && (branch < branchFactor), "xrpl::SHAMap::descend : valid branch input"); + (branch >= 0) && (branch < kBRANCH_FACTOR), "xrpl::SHAMap::descend : valid branch input"); XRPL_ASSERT( !parent->isEmptyBranch(branch), "xrpl::SHAMap::descend : parent branch is non-empty"); @@ -398,7 +398,7 @@ SHAMap::descendAsync( if (!ptr && backed_) { f_.db().asyncFetch( - hash.as_uint256(), + hash.asUint256(), ledgerSeq_, [this, hash, cb{std::move(callback)}](std::shared_ptr const& object) { auto node = finishFetch(hash, object); @@ -425,7 +425,7 @@ SHAMap::unshareNode(intr_ptr::SharedPtr node, SHAMapNodeID const& nodeID) { // have a CoW XRPL_ASSERT(state_ != SHAMapState::Immutable, "xrpl::SHAMap::unshareNode : not immutable"); - node = intr_ptr::static_pointer_cast(node->clone(cowid_)); + node = intr_ptr::staticPointerCast(node->clone(cowid_)); if (nodeID.isRoot()) root_ = node; } @@ -442,11 +442,11 @@ SHAMap::belowHelper( auto& [init, cmp, incr] = loopParams; if (node->isLeaf()) { - auto n = intr_ptr::static_pointer_cast(node); - stack.push({node, {leafDepth, n->peekItem()->key()}}); + auto n = intr_ptr::staticPointerCast(node); + stack.push({node, {kLEAF_DEPTH, n->peekItem()->key()}}); return n.get(); } - auto inner = intr_ptr::static_pointer_cast(node); + auto inner = intr_ptr::staticPointerCast(node); if (stack.empty()) { stack.emplace(inner, SHAMapNodeID{}); @@ -463,11 +463,11 @@ SHAMap::belowHelper( XRPL_ASSERT(!stack.empty(), "xrpl::SHAMap::belowHelper : non-empty stack"); if (node->isLeaf()) { - auto n = intr_ptr::static_pointer_cast(node); - stack.push({n, {leafDepth, n->peekItem()->key()}}); + auto n = intr_ptr::staticPointerCast(node); + stack.push({n, {kLEAF_DEPTH, n->peekItem()->key()}}); return n.get(); } - inner = intr_ptr::static_pointer_cast(node); + inner = intr_ptr::staticPointerCast(node); stack.emplace(inner, stack.top().second.getChildNodeID(branch)); i = init; // descend and reset loop } @@ -482,7 +482,7 @@ SHAMapLeafNode* SHAMap::lastBelow(intr_ptr::SharedPtr node, SharedPtrNodeStack& stack, int branch) const { - auto init = branchFactor - 1; + auto init = kBRANCH_FACTOR - 1; auto cmp = [](int i) { return i >= 0; }; auto incr = [](int& i) { --i; }; @@ -493,12 +493,12 @@ SHAMap::firstBelow(intr_ptr::SharedPtr node, SharedPtrNodeStack& const { auto init = 0; - auto cmp = [](int i) { return i <= branchFactor; }; + auto cmp = [](int i) { return i <= kBRANCH_FACTOR; }; auto incr = [](int& i) { ++i; }; return belowHelper(node, stack, branch, {init, cmp, incr}); } -static boost::intrusive_ptr const no_item; +static boost::intrusive_ptr const kNO_ITEM; boost::intrusive_ptr const& SHAMap::onlyBelow(SHAMapTreeNode* node) const @@ -508,13 +508,13 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const while (!node->isLeaf()) { SHAMapTreeNode* nextNode = nullptr; - auto inner = safe_downcast(node); - for (int i = 0; i < branchFactor; ++i) + auto inner = safeDowncast(node); + for (int i = 0; i < kBRANCH_FACTOR; ++i) { if (!inner->isEmptyBranch(i)) { if (nextNode != nullptr) - return no_item; + return kNO_ITEM; nextNode = descendThrow(inner, i); } @@ -524,7 +524,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const { // LCOV_EXCL_START UNREACHABLE("xrpl::SHAMap::onlyBelow : no next node"); - return no_item; + return kNO_ITEM; // LCOV_EXCL_STOP } @@ -533,7 +533,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const // An inner node must have at least one leaf // below it, unless it's the root_ - auto const leaf = safe_downcast(node); + auto const leaf = safeDowncast(node); XRPL_ASSERT( leaf->peekItem() || (leaf == root_.get()), "xrpl::SHAMap::onlyBelow : valid inner node"); return leaf->peekItem(); @@ -563,8 +563,8 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const { auto [node, nodeID] = stack.top(); XRPL_ASSERT(!node->isLeaf(), "xrpl::SHAMap::peekNextItem : another node is not leaf"); - auto inner = intr_ptr::static_pointer_cast(node); - for (auto i = selectBranch(nodeID, id) + 1; i < branchFactor; ++i) + auto inner = intr_ptr::staticPointerCast(node); + for (auto i = selectBranch(nodeID, id) + 1; i < kBRANCH_FACTOR; ++i) { if (!inner->isEmptyBranch(i)) { @@ -588,7 +588,7 @@ SHAMap::peekItem(uint256 const& id) const SHAMapLeafNode const* leaf = findKey(id); if (leaf == nullptr) - return no_item; + return kNO_ITEM; return leaf->peekItem(); } @@ -599,14 +599,14 @@ SHAMap::peekItem(uint256 const& id, SHAMapHash& hash) const SHAMapLeafNode const* leaf = findKey(id); if (leaf == nullptr) - return no_item; + return kNO_ITEM; hash = leaf->getHash(); return leaf->peekItem(); } -SHAMap::const_iterator -SHAMap::upper_bound(uint256 const& id) const +SHAMap::ConstIterator +SHAMap::upperBound(uint256 const& id) const { SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -615,14 +615,14 @@ SHAMap::upper_bound(uint256 const& id) const auto [node, nodeID] = stack.top(); if (node->isLeaf()) { - auto leaf = safe_downcast(node.get()); + auto leaf = safeDowncast(node.get()); if (leaf->peekItem()->key() > id) - return const_iterator(this, leaf->peekItem().get(), std::move(stack)); + return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } else { - auto inner = intr_ptr::static_pointer_cast(node); - for (auto branch = selectBranch(nodeID, id) + 1; branch < branchFactor; ++branch) + auto inner = intr_ptr::staticPointerCast(node); + for (auto branch = selectBranch(nodeID, id) + 1; branch < kBRANCH_FACTOR; ++branch) { if (!inner->isEmptyBranch(branch)) { @@ -630,7 +630,7 @@ SHAMap::upper_bound(uint256 const& id) const auto leaf = firstBelow(node, stack, branch); if (leaf == nullptr) Throw(type_, id); - return const_iterator(this, leaf->peekItem().get(), std::move(stack)); + return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } } } @@ -638,8 +638,8 @@ SHAMap::upper_bound(uint256 const& id) const } return end(); } -SHAMap::const_iterator -SHAMap::lower_bound(uint256 const& id) const +SHAMap::ConstIterator +SHAMap::lowerBound(uint256 const& id) const { SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -648,13 +648,13 @@ SHAMap::lower_bound(uint256 const& id) const auto [node, nodeID] = stack.top(); if (node->isLeaf()) { - auto leaf = safe_downcast(node.get()); + auto leaf = safeDowncast(node.get()); if (leaf->peekItem()->key() < id) - return const_iterator(this, leaf->peekItem().get(), std::move(stack)); + return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } else { - auto inner = intr_ptr::static_pointer_cast(node); + auto inner = intr_ptr::staticPointerCast(node); for (int branch = selectBranch(nodeID, id) - 1; branch >= 0; --branch) { if (!inner->isEmptyBranch(branch)) @@ -663,7 +663,7 @@ SHAMap::lower_bound(uint256 const& id) const auto leaf = lastBelow(node, stack, branch); if (leaf == nullptr) Throw(type_, id); - return const_iterator(this, leaf->peekItem().get(), std::move(stack)); + return ConstIterator(this, leaf->peekItem().get(), std::move(stack)); } } } @@ -691,7 +691,7 @@ SHAMap::delItem(uint256 const& id) if (stack.empty()) Throw(type_, id); - auto leaf = intr_ptr::dynamic_pointer_cast(stack.top().first); + auto leaf = intr_ptr::dynamicPointerCast(stack.top().first); stack.pop(); if (!leaf || (leaf->peekItem()->key() != id)) @@ -706,7 +706,7 @@ SHAMap::delItem(uint256 const& id) while (!stack.empty()) { - auto node = intr_ptr::static_pointer_cast(stack.top().first); + auto node = intr_ptr::staticPointerCast(stack.top().first); SHAMapNodeID const nodeID = stack.top().second; stack.pop(); @@ -737,7 +737,7 @@ SHAMap::delItem(uint256 const& id) if (item) { - for (int i = 0; i < branchFactor; ++i) + for (int i = 0; i < kBRANCH_FACTOR; ++i) { if (!node->isEmptyBranch(i)) { @@ -768,7 +768,7 @@ bool SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr item) { XRPL_ASSERT(state_ != SHAMapState::Immutable, "xrpl::SHAMap::addGiveItem : not immutable"); - XRPL_ASSERT(type != SHAMapNodeType::tnINNER, "xrpl::SHAMap::addGiveItem : valid type input"); + XRPL_ASSERT(type != SHAMapNodeType::TnInner, "xrpl::SHAMap::addGiveItem : valid type input"); // add the specified item, does not update uint256 const tag = item->key(); @@ -784,7 +784,7 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr if (node->isLeaf()) { - auto leaf = intr_ptr::static_pointer_cast(node); + auto leaf = intr_ptr::staticPointerCast(node); if (leaf->peekItem()->key() == tag) return false; } @@ -792,7 +792,7 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr if (node->isInner()) { // easy case, we end on an inner node - auto inner = intr_ptr::static_pointer_cast(node); + auto inner = intr_ptr::staticPointerCast(node); int const branch = selectBranch(nodeID, tag); XRPL_ASSERT( inner->isEmptyBranch(branch), "xrpl::SHAMap::addGiveItem : inner branch is empty"); @@ -802,12 +802,12 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr { // this is a leaf node that has to be made an inner node holding two // items - auto leaf = intr_ptr::static_pointer_cast(node); + auto leaf = intr_ptr::staticPointerCast(node); auto otherItem = leaf->peekItem(); XRPL_ASSERT( otherItem && (tag != otherItem->key()), "xrpl::SHAMap::addGiveItem : non-null item"); - node = intr_ptr::make_shared(node->cowid()); + node = intr_ptr::makeShared(node->cowid()); unsigned int b1 = 0, b2 = 0; @@ -818,13 +818,13 @@ SHAMap::addGiveItem(SHAMapNodeType type, boost::intrusive_ptr // we need a new inner node, since both go on same branch at this // level nodeID = nodeID.getChildNodeID(b1); - node = intr_ptr::make_shared(cowid_); + node = intr_ptr::makeShared(cowid_); } // we can add the two leaf nodes here XRPL_ASSERT(node->isInner(), "xrpl::SHAMap::addGiveItem : node is inner"); - auto inner = safe_downcast(node.get()); + auto inner = safeDowncast(node.get()); inner->setChild(b1, makeTypedLeaf(type, std::move(item), cowid_)); inner->setChild(b2, makeTypedLeaf(type, std::move(otherItem), cowid_)); } @@ -865,7 +865,7 @@ SHAMap::updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr(type_, tag); - auto node = intr_ptr::dynamic_pointer_cast(stack.top().first); + auto node = intr_ptr::dynamicPointerCast(stack.top().first); auto nodeID = stack.top().second; stack.pop(); @@ -947,7 +947,7 @@ SHAMap::writeNode(NodeObjectType t, intr_ptr::SharedPtr node) co Serializer s; node->serializeWithPrefix(s); - f_.db().store(t, std::move(s.modData()), node->getHash().as_uint256(), ledgerSeq_); + f_.db().store(t, std::move(s.modData()), node->getHash().asUint256(), ledgerSeq_); return node; } @@ -966,7 +966,7 @@ SHAMap::preFlushNode(intr_ptr::SharedPtr node) const { // Node is not uniquely ours, so unshare it before // possibly modifying it - node = intr_ptr::static_pointer_cast(node->clone(cowid_)); + node = intr_ptr::staticPointerCast(node->clone(cowid_)); } return node; } @@ -975,7 +975,7 @@ int SHAMap::unshare() { // Don't share nodes with parent map - return walkSubTree(false, NodeObjectType::hotUNKNOWN); + return walkSubTree(false, NodeObjectType::Unknown); } int @@ -1007,11 +1007,11 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) return 1; } - auto node = intr_ptr::static_pointer_cast(root_); + auto node = intr_ptr::staticPointerCast(root_); if (node->isEmpty()) { // replace empty root with a new empty root - root_ = intr_ptr::make_shared(0); + root_ = intr_ptr::makeShared(0); return 1; } @@ -1027,7 +1027,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // We can't flush an inner node until we flush its children while (true) { - while (pos < branchFactor) + while (pos < kBRANCH_FACTOR) { if (node->isEmptyBranch(pos)) { @@ -1051,7 +1051,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // save our place and work on this node stack.emplace(std::move(node), branch); - node = intr_ptr::static_pointer_cast(child); + node = intr_ptr::staticPointerCast(child); pos = 0; } else @@ -1082,7 +1082,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) node->unshare(); if (doWrite) - node = intr_ptr::static_pointer_cast(writeNode(t, std::move(node))); + node = intr_ptr::staticPointerCast(writeNode(t, std::move(node))); ++flushed; @@ -1130,8 +1130,8 @@ SHAMap::dump(bool hash) const if (node->isInner()) { - auto inner = safe_downcast(node); - for (int i = 0; i < branchFactor; ++i) + auto inner = safeDowncast(node); + for (int i = 0; i < kBRANCH_FACTOR; ++i) { if (!inner->isEmptyBranch(i)) { @@ -1158,7 +1158,7 @@ SHAMap::dump(bool hash) const intr_ptr::SharedPtr SHAMap::cacheLookup(SHAMapHash const& hash) const { - auto ret = f_.getTreeNodeCache()->fetch(hash.as_uint256()); + auto ret = f_.getTreeNodeCache()->fetch(hash.asUint256()); XRPL_ASSERT(!ret || !ret->cowid(), "xrpl::SHAMap::cacheLookup : not found or zero cowid"); return ret; } @@ -1170,7 +1170,7 @@ SHAMap::canonicalize(SHAMapHash const& hash, intr_ptr::SharedPtr XRPL_ASSERT(node->cowid() == 0, "xrpl::SHAMap::canonicalize : valid node input"); XRPL_ASSERT(node->getHash() == hash, "xrpl::SHAMap::canonicalize : node hash do match"); - f_.getTreeNodeCache()->canonicalize_replace_client(hash.as_uint256(), node); + f_.getTreeNodeCache()->canonicalizeReplaceClient(hash.asUint256(), node); } void diff --git a/src/libxrpl/shamap/SHAMapDelta.cpp b/src/libxrpl/shamap/SHAMapDelta.cpp index e80f28d25f..b1aeac18e8 100644 --- a/src/libxrpl/shamap/SHAMapDelta.cpp +++ b/src/libxrpl/shamap/SHAMapDelta.cpp @@ -53,7 +53,7 @@ SHAMap::walkBranch( if (node->isInner()) { // This is an inner node, add all non-empty branches - auto inner = safe_downcast(node); + auto inner = safeDowncast(node); for (int i = 0; i < 16; ++i) { if (!inner->isEmptyBranch(i)) @@ -63,7 +63,7 @@ SHAMap::walkBranch( else { // This is a leaf node, process its item - auto item = safe_downcast(node)->peekItem(); + auto item = safeDowncast(node)->peekItem(); if (emptyBranch || (item->key() != otherMapItem->key())) { @@ -160,8 +160,8 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const if (ourNode->isLeaf() && otherNode->isLeaf()) { // two leaves - auto ours = safe_downcast(ourNode); - auto other = safe_downcast(otherNode); + auto ours = safeDowncast(ourNode); + auto other = safeDowncast(otherNode); if (ours->peekItem()->key() == other->peekItem()->key()) { if (ours->peekItem()->slice() != other->peekItem()->slice()) @@ -189,22 +189,22 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const } else if (ourNode->isInner() && otherNode->isLeaf()) { - auto ours = safe_downcast(ourNode); - auto other = safe_downcast(otherNode); + auto ours = safeDowncast(ourNode); + auto other = safeDowncast(otherNode); if (!walkBranch(ours, other->peekItem(), true, differences, maxCount)) return false; } else if (ourNode->isLeaf() && otherNode->isInner()) { - auto ours = safe_downcast(ourNode); - auto other = safe_downcast(otherNode); + auto ours = safeDowncast(ourNode); + auto other = safeDowncast(otherNode); if (!otherMap.walkBranch(other, ours->peekItem(), false, differences, maxCount)) return false; } else if (ourNode->isInner() && otherNode->isInner()) { - auto ours = safe_downcast(ourNode); - auto other = safe_downcast(otherNode); + auto ours = safeDowncast(ourNode); + auto other = safeDowncast(otherNode); for (int i = 0; i < 16; ++i) { if (ours->getChildHash(i) != other->getChildHash(i)) @@ -250,7 +250,7 @@ SHAMap::walkMap(std::vector& missingNodes, int maxMissing) co using StackEntry = intr_ptr::SharedPtr; std::stack> nodeStack; - nodeStack.push(intr_ptr::static_pointer_cast(root_)); + nodeStack.push(intr_ptr::staticPointerCast(root_)); while (!nodeStack.empty()) { @@ -266,7 +266,7 @@ SHAMap::walkMap(std::vector& missingNodes, int maxMissing) co if (nextNode) { if (nextNode->isInner()) - nodeStack.push(intr_ptr::static_pointer_cast(nextNode)); + nodeStack.push(intr_ptr::staticPointerCast(nextNode)); } else { @@ -288,7 +288,7 @@ SHAMap::walkMapParallel(std::vector& missingNodes, int maxMis using StackEntry = intr_ptr::SharedPtr; std::array, 16> topChildren; { - auto const& innerRoot = intr_ptr::static_pointer_cast(root_); + auto const& innerRoot = intr_ptr::staticPointerCast(root_); for (int i = 0; i < 16; ++i) { if (!innerRoot->isEmptyBranch(i)) @@ -312,7 +312,7 @@ SHAMap::walkMapParallel(std::vector& missingNodes, int maxMis if (!child || !child->isInner()) continue; - nodeStacks[rootChildIndex].push(intr_ptr::static_pointer_cast(child)); + nodeStacks[rootChildIndex].push(intr_ptr::staticPointerCast(child)); JLOG(journal_.debug()) << "starting worker " << rootChildIndex; workers.emplace_back( @@ -339,7 +339,7 @@ SHAMap::walkMapParallel(std::vector& missingNodes, int maxMis if (nextNode->isInner()) { nodeStack.push( - intr_ptr::static_pointer_cast(nextNode)); + intr_ptr::staticPointerCast(nextNode)); } } else diff --git a/src/libxrpl/shamap/SHAMapInnerNode.cpp b/src/libxrpl/shamap/SHAMapInnerNode.cpp index 38300beadb..a0adc10a61 100644 --- a/src/libxrpl/shamap/SHAMapInnerNode.cpp +++ b/src/libxrpl/shamap/SHAMapInnerNode.cpp @@ -74,7 +74,7 @@ SHAMapInnerNode::clone(std::uint32_t cowid) const { auto const branchCount = getBranchCount(); auto const thisIsSparse = !hashesAndChildren_.isDense(); - auto p = intr_ptr::make_shared(cowid, branchCount); + auto p = intr_ptr::makeShared(cowid, branchCount); p->hash_ = hash_; p->isBranch_ = isBranch_; p->fullBelowGen_ = fullBelowGen_; @@ -98,7 +98,7 @@ SHAMapInnerNode::clone(std::uint32_t cowid) const [&](auto branchNum, auto indexNum) { cloneHashes[branchNum] = thisHashes[indexNum]; }); } - spinlock sl(lock_); + Spinlock sl(lock_); std::scoped_lock const lock(sl); if (thisIsSparse) @@ -122,18 +122,18 @@ intr_ptr::SharedPtr SHAMapInnerNode::makeFullInner(Slice data, SHAMapHash const& hash, bool hashValid) { // A full inner node is serialized as 16 256-bit hashes, back to back: - if (data.size() != branchFactor * uint256::bytes) + if (data.size() != kBRANCH_FACTOR * uint256::kBYTES) Throw("Invalid FI node"); - auto ret = intr_ptr::make_shared(0, branchFactor); + auto ret = intr_ptr::makeShared(0, kBRANCH_FACTOR); SerialIter si(data); auto hashes = ret->hashesAndChildren_.getHashes(); - for (int i = 0; i < branchFactor; ++i) + for (int i = 0; i < kBRANCH_FACTOR; ++i) { - hashes[i].as_uint256() = si.getBitString<256>(); + hashes[i].asUint256() = si.getBitString<256>(); if (hashes[i].isNonZero()) ret->isBranch_ |= (1 << i); @@ -158,14 +158,14 @@ SHAMapInnerNode::makeCompressedInner(Slice data) { // A compressed inner node is serialized as a series of 33 byte chunks, // representing a one byte "position" and a 256-bit hash: - constexpr std::size_t chunkSize = uint256::bytes + 1; + constexpr std::size_t kCHUNK_SIZE = uint256::kBYTES + 1; - if (auto const s = data.size(); (s % chunkSize != 0) || (s > chunkSize * branchFactor)) + if (auto const s = data.size(); (s % kCHUNK_SIZE != 0) || (s > kCHUNK_SIZE * kBRANCH_FACTOR)) Throw("Invalid CI node"); SerialIter si(data); - auto ret = intr_ptr::make_shared(0, branchFactor); + auto ret = intr_ptr::makeShared(0, kBRANCH_FACTOR); auto hashes = ret->hashesAndChildren_.getHashes(); @@ -174,10 +174,10 @@ SHAMapInnerNode::makeCompressedInner(Slice data) auto const hash = si.getBitString<256>(); auto const pos = si.get8(); - if (pos >= branchFactor) + if (pos >= kBRANCH_FACTOR) Throw("invalid CI node"); - hashes[pos].as_uint256() = hash; + hashes[pos].asUint256() = hash; if (hashes[pos].isNonZero()) ret->isBranch_ |= (1 << pos); @@ -196,7 +196,7 @@ SHAMapInnerNode::updateHash() { sha512_half_hasher h; using beast::hash_append; - hash_append(h, HashPrefix::innerNode); + hash_append(h, HashPrefix::InnerNode); iterChildren([&](SHAMapHash const& hh) { hash_append(h, hh); }); nh = static_cast(h); } @@ -228,15 +228,15 @@ SHAMapInnerNode::serializeForWire(Serializer& s) const // compressed node auto hashes = hashesAndChildren_.getHashes(); iterNonEmptyChildIndexes([&](auto branchNum, auto indexNum) { - s.addBitString(hashes[indexNum].as_uint256()); + s.addBitString(hashes[indexNum].asUint256()); s.add8(branchNum); }); - s.add8(wireTypeCompressedInner); + s.add8(kWIRE_TYPE_COMPRESSED_INNER); } else { - iterChildren([&](SHAMapHash const& hh) { s.addBitString(hh.as_uint256()); }); - s.add8(wireTypeInner); + iterChildren([&](SHAMapHash const& hh) { s.addBitString(hh.asUint256()); }); + s.add8(kWIRE_TYPE_INNER); } } @@ -245,8 +245,8 @@ SHAMapInnerNode::serializeWithPrefix(Serializer& s) const { XRPL_ASSERT(!isEmpty(), "xrpl::SHAMapInnerNode::serializeWithPrefix : is non-empty"); - s.add32(HashPrefix::innerNode); - iterChildren([&](SHAMapHash const& hh) { s.addBitString(hh.as_uint256()); }); + s.add32(HashPrefix::InnerNode); + iterChildren([&](SHAMapHash const& hh) { s.addBitString(hh.asUint256()); }); } std::string @@ -268,7 +268,7 @@ void SHAMapInnerNode::setChild(int m, intr_ptr::SharedPtr child) { XRPL_ASSERT( - (m >= 0) && (m < branchFactor), "xrpl::SHAMapInnerNode::setChild : valid branch input"); + (m >= 0) && (m < kBRANCH_FACTOR), "xrpl::SHAMapInnerNode::setChild : valid branch input"); XRPL_ASSERT(cowid_, "xrpl::SHAMapInnerNode::setChild : nonzero cowid"); XRPL_ASSERT(child.get() != this, "xrpl::SHAMapInnerNode::setChild : valid child input"); @@ -310,7 +310,7 @@ void SHAMapInnerNode::shareChild(int m, intr_ptr::SharedPtr const& child) { XRPL_ASSERT( - (m >= 0) && (m < branchFactor), "xrpl::SHAMapInnerNode::shareChild : valid branch input"); + (m >= 0) && (m < kBRANCH_FACTOR), "xrpl::SHAMapInnerNode::shareChild : valid branch input"); XRPL_ASSERT(cowid_, "xrpl::SHAMapInnerNode::shareChild : nonzero cowid"); XRPL_ASSERT(child, "xrpl::SHAMapInnerNode::shareChild : non-null child input"); XRPL_ASSERT(child.get() != this, "xrpl::SHAMapInnerNode::shareChild : valid child input"); @@ -324,7 +324,7 @@ SHAMapTreeNode* SHAMapInnerNode::getChildPointer(int branch) { XRPL_ASSERT( - branch >= 0 && branch < branchFactor, + branch >= 0 && branch < kBRANCH_FACTOR, "xrpl::SHAMapInnerNode::getChildPointer : valid branch input"); XRPL_ASSERT( !isEmptyBranch(branch), "xrpl::SHAMapInnerNode::getChildPointer : non-empty branch input"); @@ -332,7 +332,7 @@ SHAMapInnerNode::getChildPointer(int branch) auto const index = *getChildIndex(branch); // NOLINT(bugprone-unchecked-optional-access) assert above - packed_spinlock sl(lock_, index); + PackedSpinlock sl(lock_, index); std::scoped_lock const lock(sl); return hashesAndChildren_.getChildren()[index].get(); } @@ -341,14 +341,14 @@ intr_ptr::SharedPtr SHAMapInnerNode::getChild(int branch) { XRPL_ASSERT( - branch >= 0 && branch < branchFactor, + branch >= 0 && branch < kBRANCH_FACTOR, "xrpl::SHAMapInnerNode::getChild : valid branch input"); XRPL_ASSERT(!isEmptyBranch(branch), "xrpl::SHAMapInnerNode::getChild : non-empty branch input"); auto const index = *getChildIndex(branch); // NOLINT(bugprone-unchecked-optional-access) assert above - packed_spinlock sl(lock_, index); + PackedSpinlock sl(lock_, index); std::scoped_lock const lock(sl); return hashesAndChildren_.getChildren()[index]; } @@ -357,18 +357,19 @@ SHAMapHash const& SHAMapInnerNode::getChildHash(int m) const { XRPL_ASSERT( - (m >= 0) && (m < branchFactor), "xrpl::SHAMapInnerNode::getChildHash : valid branch input"); + (m >= 0) && (m < kBRANCH_FACTOR), + "xrpl::SHAMapInnerNode::getChildHash : valid branch input"); if (auto const i = getChildIndex(m)) return hashesAndChildren_.getHashes()[*i]; - return zeroSHAMapHash; + return kZERO_SHA_MAP_HASH; } intr_ptr::SharedPtr SHAMapInnerNode::canonicalizeChild(int branch, intr_ptr::SharedPtr node) { XRPL_ASSERT( - branch >= 0 && branch < branchFactor, + branch >= 0 && branch < kBRANCH_FACTOR, "xrpl::SHAMapInnerNode::canonicalizeChild : valid branch input"); XRPL_ASSERT(node != nullptr, "xrpl::SHAMapInnerNode::canonicalizeChild : valid node input"); XRPL_ASSERT( @@ -382,7 +383,7 @@ SHAMapInnerNode::canonicalizeChild(int branch, intr_ptr::SharedPtr= 1, "xrpl::SHAMapInnerNode::invariants : minimum count"); diff --git a/src/libxrpl/shamap/SHAMapLeafNode.cpp b/src/libxrpl/shamap/SHAMapLeafNode.cpp index 58646503aa..ce41a64e56 100644 --- a/src/libxrpl/shamap/SHAMapLeafNode.cpp +++ b/src/libxrpl/shamap/SHAMapLeafNode.cpp @@ -63,15 +63,15 @@ SHAMapLeafNode::getString(SHAMapNodeID const& id) const auto const type = getType(); - if (type == SHAMapNodeType::tnTRANSACTION_NM) + if (type == SHAMapNodeType::TnTransactionNm) { ret += ",txn\n"; } - else if (type == SHAMapNodeType::tnTRANSACTION_MD) + else if (type == SHAMapNodeType::TnTransactionMd) { ret += ",txn+md\n"; } - else if (type == SHAMapNodeType::tnACCOUNT_STATE) + else if (type == SHAMapNodeType::TnAccountState) { ret += ",as\n"; } diff --git a/src/libxrpl/shamap/SHAMapNodeID.cpp b/src/libxrpl/shamap/SHAMapNodeID.cpp index 6116a997b6..f7caf8ae02 100644 --- a/src/libxrpl/shamap/SHAMapNodeID.cpp +++ b/src/libxrpl/shamap/SHAMapNodeID.cpp @@ -18,35 +18,35 @@ depthMask(unsigned int depth) { // Need to be named before converting // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) - enum { mask_size = 65 }; + enum { MaskSize = 65 }; - struct masks_t + struct MasksT { - uint256 entry[mask_size]; + uint256 entry[MaskSize]; - masks_t() + MasksT() { uint256 selector; - for (int i = 0; i < mask_size - 1; i += 2) + for (int i = 0; i < MaskSize - 1; i += 2) { entry[i] = selector; *(selector.begin() + (i / 2)) = 0xF0; entry[i + 1] = selector; *(selector.begin() + (i / 2)) = 0xFF; } - entry[mask_size - 1] = selector; + entry[MaskSize - 1] = selector; } }; - static masks_t const masks; - return masks.entry[depth]; + static MasksT const kMASKS; + return kMASKS.entry[depth]; } // canonicalize the hash to a node ID for this depth SHAMapNodeID::SHAMapNodeID(unsigned int depth, uint256 const& hash) : id_(hash), depth_(depth) { XRPL_ASSERT( - depth <= SHAMap::leafDepth, "xrpl::SHAMapNodeID::SHAMapNodeID : maximum depth input"); + depth <= SHAMap::kLEAF_DEPTH, "xrpl::SHAMapNodeID::SHAMapNodeID : maximum depth input"); XRPL_ASSERT( id_ == (id_ & depthMask(depth)), "xrpl::SHAMapNodeID::SHAMapNodeID : hash and depth inputs do match"); @@ -65,7 +65,7 @@ SHAMapNodeID SHAMapNodeID::getChildNodeID(unsigned int m) const { XRPL_ASSERT( - m < SHAMap::branchFactor, "xrpl::SHAMapNodeID::getChildNodeID : valid branch input"); + m < SHAMap::kBRANCH_FACTOR, "xrpl::SHAMapNodeID::getChildNodeID : valid branch input"); // A SHAMap has exactly 65 levels, so nodes must not exceed that // depth; if they do, this breaks the invariant of never allowing @@ -76,9 +76,9 @@ SHAMapNodeID::getChildNodeID(unsigned int m) const // entries at that depth are leaf nodes and have no children and even // constructing a child node from them would break the above invariant. XRPL_ASSERT( - depth_ <= SHAMap::leafDepth, "xrpl::SHAMapNodeID::getChildNodeID : maximum leaf depth"); + depth_ <= SHAMap::kLEAF_DEPTH, "xrpl::SHAMapNodeID::getChildNodeID : maximum leaf depth"); - if (depth_ >= SHAMap::leafDepth) + if (depth_ >= SHAMap::kLEAF_DEPTH) Throw("Request for child node ID of " + to_string(*this)); if (id_ != (id_ & depthMask(depth_))) @@ -97,7 +97,7 @@ deserializeSHAMapNodeID(void const* data, std::size_t size) if (size == 33) { unsigned int const depth = *(static_cast(data) + 32); - if (depth <= SHAMap::leafDepth) + if (depth <= SHAMap::kLEAF_DEPTH) { auto const id = uint256::fromVoid(data); @@ -124,7 +124,7 @@ selectBranch(SHAMapNodeID const& id, uint256 const& hash) branch >>= 4; } - XRPL_ASSERT(branch < SHAMap::branchFactor, "xrpl::selectBranch : maximum result"); + XRPL_ASSERT(branch < SHAMap::kBRANCH_FACTOR, "xrpl::selectBranch : maximum result"); return branch; } diff --git a/src/libxrpl/shamap/SHAMapSync.cpp b/src/libxrpl/shamap/SHAMapSync.cpp index e7f3447642..348928f863 100644 --- a/src/libxrpl/shamap/SHAMapSync.cpp +++ b/src/libxrpl/shamap/SHAMapSync.cpp @@ -38,7 +38,7 @@ SHAMap::visitLeaves( { visitNodes([&leafFunction](SHAMapTreeNode& node) { if (!node.isInner()) - leafFunction(safe_downcast(node).peekItem()); + leafFunction(safeDowncast(node).peekItem()); return true; }); } @@ -57,7 +57,7 @@ SHAMap::visitNodes(std::function const& function) const using StackEntry = std::pair>; std::stack> stack; - auto node = intr_ptr::static_pointer_cast(root_); + auto node = intr_ptr::staticPointerCast(root_); int pos = 0; while (true) @@ -87,7 +87,7 @@ SHAMap::visitNodes(std::function const& function) const } // descend to the child's first position - node = intr_ptr::static_pointer_cast(child); + node = intr_ptr::staticPointerCast(child); pos = 0; } } @@ -123,7 +123,7 @@ SHAMap::visitDifferences( if (root_->isLeaf()) { - auto leaf = intr_ptr::static_pointer_cast(root_); + auto leaf = intr_ptr::staticPointerCast(root_); if ((have == nullptr) || !have->hasLeafNode(leaf->peekItem()->key(), leaf->getHash())) function(*root_); return; @@ -132,7 +132,7 @@ SHAMap::visitDifferences( using StackEntry = std::pair; std::stack> stack; - stack.emplace(safe_downcast(root_.get()), SHAMapNodeID{}); + stack.emplace(safeDowncast(root_.get()), SHAMapNodeID{}); while (!stack.empty()) { @@ -155,12 +155,12 @@ SHAMap::visitDifferences( if (next->isInner()) { if ((have == nullptr) || !have->hasInnerNode(childID, childHash)) - stack.emplace(safe_downcast(next), childID); + stack.emplace(safeDowncast(next), childID); } else if ( (have == nullptr) || !have->hasLeafNode( - safe_downcast(next)->peekItem()->key(), childHash)) + safeDowncast(next)->peekItem()->key(), childHash)) { if (!function(*next)) return; @@ -175,7 +175,7 @@ SHAMap::visitDifferences( // children, descending the SHAMap until we complete the // processing of a node. void -SHAMap::gmn_ProcessNodes(MissingNodes& mn, MissingNodes::StackEntry& se) +SHAMap::gmnProcessNodes(MissingNodes& mn, MissingNodes::StackEntry& se) { SHAMapInnerNode*& node = std::get<0>(se); SHAMapNodeID& nodeID = std::get<1>(se); @@ -191,53 +191,51 @@ SHAMap::gmn_ProcessNodes(MissingNodes& mn, MissingNodes::StackEntry& se) auto const& childHash = node->getChildHash(branch); - if (mn.missingHashes_.contains(childHash)) + if (mn.missingHashes.contains(childHash)) { // we already know this child node is missing fullBelow = false; } - else if (!backed_ || !f_.getFullBelowCache()->touch_if_exists(childHash.as_uint256())) + else if (!backed_ || !f_.getFullBelowCache()->touchIfExists(childHash.asUint256())) { bool pending = false; auto d = descendAsync( node, branch, - mn.filter_, + mn.filter, pending, [node, nodeID, branch, &mn]( intr_ptr::SharedPtr found, SHAMapHash const&) { // a read completed asynchronously - std::unique_lock const lock{mn.deferLock_}; - mn.finishedReads_.emplace_back(node, nodeID, branch, std::move(found)); - mn.deferCondVar_.notify_one(); + std::unique_lock const lock{mn.deferLock}; + mn.finishedReads.emplace_back(node, nodeID, branch, std::move(found)); + mn.deferCondVar.notify_one(); }); if (pending) { fullBelow = false; - ++mn.deferred_; + ++mn.deferred; } else if (d == nullptr) { // node is not in database fullBelow = false; // for now, not known full below - mn.missingHashes_.insert(childHash); - mn.missingNodes_.emplace_back( - nodeID.getChildNodeID(branch), childHash.as_uint256()); + mn.missingHashes.insert(childHash); + mn.missingNodes.emplace_back(nodeID.getChildNodeID(branch), childHash.asUint256()); - if (--mn.max_ <= 0) + if (--mn.max <= 0) return; } - else if ( - d->isInner() && !safe_downcast(d)->isFullBelow(mn.generation_)) + else if (d->isInner() && !safeDowncast(d)->isFullBelow(mn.generation)) { - mn.stack_.push(se); + mn.stack.push(se); // Switch to processing the child node - node = safe_downcast(d); + node = safeDowncast(d); nodeID = nodeID.getChildNodeID(branch); - firstChild = rand_int(255); + firstChild = randInt(255); currentChild = 0; fullBelow = true; } @@ -249,10 +247,10 @@ SHAMap::gmn_ProcessNodes(MissingNodes& mn, MissingNodes::StackEntry& se) if (fullBelow) { // No partial node encountered below this node - node->setFullBelowGen(mn.generation_); + node->setFullBelowGen(mn.generation); if (backed_) { - f_.getFullBelowCache()->insert(node->getHash().as_uint256()); + f_.getFullBelowCache()->insert(node->getHash().asUint256()); } } @@ -262,20 +260,20 @@ SHAMap::gmn_ProcessNodes(MissingNodes& mn, MissingNodes::StackEntry& se) // Wait for deferred reads to finish and // process their results void -SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) +SHAMap::gmnProcessDeferredReads(MissingNodes& mn) { // Process all deferred reads int complete = 0; - while (complete != mn.deferred_) + while (complete != mn.deferred) { std::tuple> deferredNode; { - std::unique_lock lock{mn.deferLock_}; + std::unique_lock lock{mn.deferLock}; - while (mn.finishedReads_.size() <= complete) - mn.deferCondVar_.wait(lock); - deferredNode = std::move(mn.finishedReads_[complete++]); + while (mn.finishedReads.size() <= complete) + mn.deferCondVar.wait(lock); + deferredNode = std::move(mn.finishedReads[complete++]); } auto parent = std::get<0>(deferredNode); @@ -290,18 +288,18 @@ SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) // When we finish this stack, we need to restart // with the parent of this node - mn.resumes_[parent] = parentID; + mn.resumes[parent] = parentID; } - else if ((mn.max_ > 0) && (mn.missingHashes_.insert(nodeHash).second)) + else if ((mn.max > 0) && (mn.missingHashes.insert(nodeHash).second)) { - mn.missingNodes_.emplace_back(parentID.getChildNodeID(branch), nodeHash.as_uint256()); - --mn.max_; + mn.missingNodes.emplace_back(parentID.getChildNodeID(branch), nodeHash.asUint256()); + --mn.max; } } - mn.finishedReads_.clear(); - mn.finishedReads_.reserve(mn.maxDefer_); - mn.deferred_ = 0; + mn.finishedReads.clear(); + mn.finishedReads.reserve(mn.maxDefer); + mn.deferred = 0; } /** Get a list of node IDs and hashes for nodes that are part of this SHAMap @@ -321,10 +319,10 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) f_.getFullBelowCache()->getGeneration()); if (!root_->isInner() || - intr_ptr::static_pointer_cast(root_)->isFullBelow(mn.generation_)) + intr_ptr::staticPointerCast(root_)->isFullBelow(mn.generation)) { clearSynching(); - return std::move(mn.missingNodes_); + return std::move(mn.missingNodes); } // Start at the root. @@ -334,7 +332,7 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // that the two threads will produce different request sets (which is // more efficient than sending identical requests). MissingNodes::StackEntry pos{ - safe_downcast(root_.get()), SHAMapNodeID(), rand_int(255), 0, true}; + safeDowncast(root_.get()), SHAMapNodeID(), randInt(255), 0, true}; auto& node = std::get<0>(pos); auto& nextChild = std::get<3>(pos); auto& fullBelow = std::get<4>(pos); @@ -342,20 +340,20 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // Traverse the map without blocking do { - while ((node != nullptr) && (mn.deferred_ <= mn.maxDefer_)) + while ((node != nullptr) && (mn.deferred <= mn.maxDefer)) { - gmn_ProcessNodes(mn, pos); + gmnProcessNodes(mn, pos); - if (mn.max_ <= 0) + if (mn.max <= 0) break; - if ((node == nullptr) && !mn.stack_.empty()) + if ((node == nullptr) && !mn.stack.empty()) { // Pick up where we left off with this node's parent bool const was = fullBelow; // was full below - pos = mn.stack_.top(); - mn.stack_.pop(); + pos = mn.stack.top(); + mn.stack.pop(); if (nextChild == 0) { // This is a node we are processing for the first time @@ -372,32 +370,32 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // We have either emptied the stack or // posted as many deferred reads as we can - if (mn.deferred_ != 0) - gmn_ProcessDeferredReads(mn); + if (mn.deferred != 0) + gmnProcessDeferredReads(mn); - if (mn.max_ <= 0) - return std::move(mn.missingNodes_); + if (mn.max <= 0) + return std::move(mn.missingNodes); if (node == nullptr) { // We weren't in the middle of processing a node - if (mn.stack_.empty() && !mn.resumes_.empty()) + if (mn.stack.empty() && !mn.resumes.empty()) { // Recheck nodes we could not finish before - for (auto const& [innerNode, nodeId] : mn.resumes_) + for (auto const& [innerNode, nodeId] : mn.resumes) { - if (!innerNode->isFullBelow(mn.generation_)) - mn.stack_.emplace(innerNode, nodeId, rand_int(255), 0, true); + if (!innerNode->isFullBelow(mn.generation)) + mn.stack.emplace(innerNode, nodeId, randInt(255), 0, true); } - mn.resumes_.clear(); + mn.resumes.clear(); } - if (!mn.stack_.empty()) + if (!mn.stack.empty()) { // Resume at the top of the stack - pos = mn.stack_.top(); - mn.stack_.pop(); + pos = mn.stack.top(); + mn.stack.pop(); XRPL_ASSERT(node, "xrpl::SHAMap::getMissingNodes : second non-null node"); } } @@ -408,10 +406,10 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) } while (node != nullptr); - if (mn.missingNodes_.empty()) + if (mn.missingNodes.empty()) clearSynching(); - return std::move(mn.missingNodes_); + return std::move(mn.missingNodes); } bool @@ -430,7 +428,7 @@ SHAMap::getNodeFat( while ((node != nullptr) && node->isInner() && (nodeID.getDepth() < wanted.getDepth())) { int const branch = selectBranch(nodeID, wanted.getNodeID()); - auto inner = safe_downcast(node); + auto inner = safeDowncast(node); if (inner->isEmptyBranch(branch)) return false; node = descendThrow(inner, branch); @@ -444,7 +442,7 @@ SHAMap::getNodeFat( return false; } - if (node->isInner() && safe_downcast(node)->isEmpty()) + if (node->isInner() && safeDowncast(node)->isEmpty()) { JLOG(journal_.warn()) << "peer requests empty node"; return false; @@ -469,7 +467,7 @@ SHAMap::getNodeFat( { // We descend inner nodes with only a single child // without decrementing the depth - auto inner = safe_downcast(node); + auto inner = safeDowncast(node); int const bc = inner->getBranchCount(); if ((depth > 0) || (bc == 1)) @@ -561,12 +559,12 @@ SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncF auto currNode = root_.get(); while (currNode->isInner() && - !safe_downcast(currNode)->isFullBelow(generation) && + !safeDowncast(currNode)->isFullBelow(generation) && (currNodeID.getDepth() < node.getDepth())) { int const branch = selectBranch(currNodeID, node.getNodeID()); XRPL_ASSERT(branch >= 0, "xrpl::SHAMap::addKnownNode : valid branch"); - auto inner = safe_downcast(currNode); + auto inner = safeDowncast(currNode); if (inner->isEmptyBranch(branch)) { JLOG(journal_.warn()) << "Add known node for empty branch" << node; @@ -574,7 +572,7 @@ SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncF } auto childHash = inner->getChildHash(branch); - if (f_.getFullBelowCache()->touch_if_exists(childHash.as_uint256())) + if (f_.getFullBelowCache()->touchIfExists(childHash.asUint256())) { return SHAMapAddNode::duplicate(); } @@ -601,7 +599,7 @@ SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncF if (newNode->isLeaf()) { auto const& actualKey = - safe_downcast(newNode.get())->peekItem()->key(); + safeDowncast(newNode.get())->peekItem()->key(); // Validate that this leaf belongs at the target position auto const expectedNodeID = SHAMapNodeID::createID(node.getDepth(), actualKey); @@ -617,8 +615,8 @@ SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncF // Inner nodes must be at a level strictly less than 64 // but leaf nodes (while notionally at level 64) can be // at any depth up to and including 64: - if ((currNodeID.getDepth() > leafDepth) || - (newNode->isInner() && currNodeID.getDepth() == leafDepth)) + if ((currNodeID.getDepth() > kLEAF_DEPTH) || + (newNode->isInner() && currNodeID.getDepth() == kLEAF_DEPTH)) { // Map is provably invalid state_ = SHAMapState::Invalid; @@ -683,8 +681,8 @@ SHAMap::deepCompare(SHAMap& other) const { if (!otherNode->isLeaf()) return false; - auto& nodePeek = safe_downcast(node)->peekItem(); - auto& otherNodePeek = safe_downcast(otherNode)->peekItem(); + auto& nodePeek = safeDowncast(node)->peekItem(); + auto& otherNodePeek = safeDowncast(otherNode)->peekItem(); if (nodePeek->key() != otherNodePeek->key()) return false; if (nodePeek->slice() != otherNodePeek->slice()) @@ -694,22 +692,22 @@ SHAMap::deepCompare(SHAMap& other) const { if (!otherNode->isInner()) return false; - auto node_inner = safe_downcast(node); - auto other_inner = safe_downcast(otherNode); + auto nodeInner = safeDowncast(node); + auto otherInner = safeDowncast(otherNode); for (int i = 0; i < 16; ++i) { - if (node_inner->isEmptyBranch(i)) + if (nodeInner->isEmptyBranch(i)) { - if (!other_inner->isEmptyBranch(i)) + if (!otherInner->isEmptyBranch(i)) return false; } else { - if (other_inner->isEmptyBranch(i)) + if (otherInner->isEmptyBranch(i)) return false; - auto next = descend(node_inner, i); - auto otherNext = other.descend(other_inner, i); + auto next = descend(nodeInner, i); + auto otherNext = other.descend(otherInner, i); if ((next == nullptr) || (otherNext == nullptr)) { JLOG(journal_.warn()) << "unable to fetch inner node"; @@ -735,7 +733,7 @@ SHAMap::hasInnerNode(SHAMapNodeID const& targetNodeID, SHAMapHash const& targetN while (node->isInner() && (nodeID.getDepth() < targetNodeID.getDepth())) { int const branch = selectBranch(nodeID, targetNodeID.getNodeID()); - auto inner = safe_downcast(node); + auto inner = safeDowncast(node); if (inner->isEmptyBranch(branch)) return false; @@ -760,7 +758,7 @@ SHAMap::hasLeafNode(uint256 const& tag, SHAMapHash const& targetNodeHash) const do { int const branch = selectBranch(nodeID, tag); - auto inner = safe_downcast(node); + auto inner = safeDowncast(node); if (inner->isEmptyBranch(branch)) return false; // Dead end, node must not be here @@ -788,7 +786,7 @@ SHAMap::getProofPath(uint256 const& key) const } if (auto const& node = stack.top().first; !node || node->isInner() || - intr_ptr::static_pointer_cast(node)->peekItem()->key() != key) + intr_ptr::staticPointerCast(node)->peekItem()->key() != key) { JLOG(journal_.debug()) << "no path to " << key; return {}; @@ -831,7 +829,7 @@ SHAMap::verifyProofPath(uint256 const& rootHash, uint256 const& key, std::vector if (node->isInner()) { auto nodeId = SHAMapNodeID::createID(depth, key); - hash = safe_downcast(node.get()) + hash = safeDowncast(node.get()) ->getChildHash(selectBranch(nodeId, key)); } else diff --git a/src/libxrpl/shamap/SHAMapTreeNode.cpp b/src/libxrpl/shamap/SHAMapTreeNode.cpp index 6fc7bd81e4..ac405f3286 100644 --- a/src/libxrpl/shamap/SHAMapTreeNode.cpp +++ b/src/libxrpl/shamap/SHAMapTreeNode.cpp @@ -28,12 +28,12 @@ namespace xrpl { intr_ptr::SharedPtr SHAMapTreeNode::makeTransaction(Slice data, SHAMapHash const& hash, bool hashValid) { - auto item = make_shamapitem(sha512Half(HashPrefix::transactionID, data), data); + auto item = makeShamapitem(sha512Half(HashPrefix::TransactionId, data), data); if (hashValid) - return intr_ptr::make_shared(std::move(item), 0, hash); + return intr_ptr::makeShared(std::move(item), 0, hash); - return intr_ptr::make_shared(std::move(item), 0); + return intr_ptr::makeShared(std::move(item), 0); } intr_ptr::SharedPtr @@ -43,21 +43,21 @@ SHAMapTreeNode::makeTransactionWithMeta(Slice data, SHAMapHash const& hash, bool uint256 tag; - if (s.size() < tag.bytes) + if (s.size() < tag.kBYTES) Throw("Short TXN+MD node"); // FIXME: improve this interface so that the above check isn't needed - if (!s.getBitString(tag, s.size() - tag.bytes)) + if (!s.getBitString(tag, s.size() - tag.kBYTES)) Throw("Short TXN+MD node (" + std::to_string(s.size()) + ")"); - s.chop(tag.bytes); + s.chop(tag.kBYTES); - auto item = make_shamapitem(tag, s.slice()); + auto item = makeShamapitem(tag, s.slice()); if (hashValid) - return intr_ptr::make_shared(std::move(item), 0, hash); + return intr_ptr::makeShared(std::move(item), 0, hash); - return intr_ptr::make_shared(std::move(item), 0); + return intr_ptr::makeShared(std::move(item), 0); } intr_ptr::SharedPtr @@ -67,24 +67,24 @@ SHAMapTreeNode::makeAccountState(Slice data, SHAMapHash const& hash, bool hashVa uint256 tag; - if (s.size() < tag.bytes) + if (s.size() < tag.kBYTES) Throw("short AS node"); // FIXME: improve this interface so that the above check isn't needed - if (!s.getBitString(tag, s.size() - tag.bytes)) + if (!s.getBitString(tag, s.size() - tag.kBYTES)) Throw("Short AS node (" + std::to_string(s.size()) + ")"); - s.chop(tag.bytes); + s.chop(tag.kBYTES); if (tag.isZero()) Throw("Invalid AS node"); - auto item = make_shamapitem(tag, s.slice()); + auto item = makeShamapitem(tag, s.slice()); if (hashValid) - return intr_ptr::make_shared(std::move(item), 0, hash); + return intr_ptr::makeShared(std::move(item), 0, hash); - return intr_ptr::make_shared(std::move(item), 0); + return intr_ptr::makeShared(std::move(item), 0); } intr_ptr::SharedPtr @@ -95,24 +95,24 @@ SHAMapTreeNode::makeFromWire(Slice rawNode) auto const type = rawNode[rawNode.size() - 1]; - rawNode.remove_suffix(1); + rawNode.removeSuffix(1); bool const hashValid = false; SHAMapHash const hash; - if (type == wireTypeTransaction) + if (type == kWIRE_TYPE_TRANSACTION) return makeTransaction(rawNode, hash, hashValid); - if (type == wireTypeAccountState) + if (type == kWIRE_TYPE_ACCOUNT_STATE) return makeAccountState(rawNode, hash, hashValid); - if (type == wireTypeInner) + if (type == kWIRE_TYPE_INNER) return SHAMapInnerNode::makeFullInner(rawNode, hash, hashValid); - if (type == wireTypeCompressedInner) + if (type == kWIRE_TYPE_COMPRESSED_INNER) return SHAMapInnerNode::makeCompressedInner(rawNode); - if (type == wireTypeTransactionWithMeta) + if (type == kWIRE_TYPE_TRANSACTION_WITH_META) return makeTransactionWithMeta(rawNode, hash, hashValid); Throw("wire: Unknown type (" + std::to_string(type) + ")"); @@ -126,30 +126,29 @@ SHAMapTreeNode::makeFromPrefix(Slice rawNode, SHAMapHash const& hash) // FIXME: Use SerialIter::get32? // Extract the prefix - auto const type = safe_cast( - (safe_cast(rawNode[0]) << 24) + - (safe_cast(rawNode[1]) << 16) + (safe_cast(rawNode[2]) << 8) + - (safe_cast(rawNode[3]))); + auto const type = safeCast( + (safeCast(rawNode[0]) << 24) + (safeCast(rawNode[1]) << 16) + + (safeCast(rawNode[2]) << 8) + (safeCast(rawNode[3]))); - rawNode.remove_prefix(4); + rawNode.removePrefix(4); bool const hashValid = true; - if (type == HashPrefix::transactionID) + if (type == HashPrefix::TransactionId) return makeTransaction(rawNode, hash, hashValid); - if (type == HashPrefix::leafNode) + if (type == HashPrefix::LeafNode) return makeAccountState(rawNode, hash, hashValid); - if (type == HashPrefix::innerNode) + if (type == HashPrefix::InnerNode) return SHAMapInnerNode::makeFullInner(rawNode, hash, hashValid); - if (type == HashPrefix::txNode) + if (type == HashPrefix::TxNode) return makeTransactionWithMeta(rawNode, hash, hashValid); Throw( "prefix: unknown type (" + - std::to_string(safe_cast>(type)) + ")"); + std::to_string(safeCast>(type)) + ")"); } std::string diff --git a/src/libxrpl/tx/ApplyContext.cpp b/src/libxrpl/tx/ApplyContext.cpp index 43facecb24..94d35cf5d9 100644 --- a/src/libxrpl/tx/ApplyContext.cpp +++ b/src/libxrpl/tx/ApplyContext.cpp @@ -26,25 +26,25 @@ namespace xrpl { ApplyContext::ApplyContext( - ServiceRegistry& registry_, + ServiceRegistry& registry, OpenView& base, std::optional const& parentBatchId, - STTx const& tx_, - TER preclaimResult_, - XRPAmount baseFee_, + STTx const& tx, + TER preclaimResult, + XRPAmount baseFee, ApplyFlags flags, - beast::Journal journal_) - : registry(registry_) - , tx(tx_) - , preclaimResult(preclaimResult_) - , baseFee(baseFee_) - , journal(journal_) + beast::Journal journal) + : registry(registry) + , tx(tx) + , preclaimResult(preclaimResult) + , baseFee(baseFee) + , journal(journal) , base_(base) , flags_(flags) , parentBatchId_(parentBatchId) { XRPL_ASSERT( - parentBatchId.has_value() == ((flags_ & tapBATCH) == tapBATCH), + parentBatchId.has_value() == ((flags_ & TapBatch) == TapBatch), "Parent Batch ID should be set if batch apply flag is set"); view_.emplace(&base_, flags_); } @@ -59,7 +59,7 @@ std::optional ApplyContext::apply(TER ter) { // NOLINTNEXTLINE(bugprone-unchecked-optional-access) view_ emplaced in constructor - return view_->apply(base_, tx, ter, parentBatchId_, (flags_ & tapDRY_RUN) != 0u, journal); + return view_->apply(base_, tx, ter, parentBatchId_, (flags_ & TapDryRun) != 0u, journal); } std::size_t @@ -124,7 +124,7 @@ ApplyContext::checkInvariantsHelper( if (!std::all_of(finalizers.cbegin(), finalizers.cend(), [](auto const& b) { return b; })) { JLOG(journal.fatal()) << "Transaction has failed one or more global invariants: " - << to_string(tx.getJson(JsonOptions::none)); + << to_string(tx.getJson(JsonOptions::KNone)); return failInvariantCheck(result); } @@ -133,7 +133,7 @@ ApplyContext::checkInvariantsHelper( { JLOG(journal.fatal()) << "Transaction caused an exception in a global invariant" << ", ex: " << ex.what() - << ", tx: " << to_string(tx.getJson(JsonOptions::none)); + << ", tx: " << to_string(tx.getJson(JsonOptions::KNone)); return failInvariantCheck(result); } diff --git a/src/libxrpl/tx/SignerEntries.cpp b/src/libxrpl/tx/SignerEntries.cpp index a1883024d9..d425c86ca6 100644 --- a/src/libxrpl/tx/SignerEntries.cpp +++ b/src/libxrpl/tx/SignerEntries.cpp @@ -28,7 +28,7 @@ SignerEntries::deserialize(STObject const& obj, beast::Journal journal, std::str } std::vector accountVec; - accountVec.reserve(STTx::maxMultiSigners); + accountVec.reserve(STTx::kMAX_MULTI_SIGNERS); STArray const& sEntries(obj.getFieldArray(sfSignerEntries)); for (STObject const& sEntry : sEntries) diff --git a/src/libxrpl/tx/Transactor.cpp b/src/libxrpl/tx/Transactor.cpp index 9791ee4c9b..79dec33c66 100644 --- a/src/libxrpl/tx/Transactor.cpp +++ b/src/libxrpl/tx/Transactor.cpp @@ -89,7 +89,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask) auto const txID = ctx.tx.getTransactionID(); - if (txID == beast::zero) + if (txID == beast::kZERO) { JLOG(ctx.j.warn()) << "applyTransaction: transaction id may not be zero"; return temINVALID; @@ -126,7 +126,7 @@ preflightCheckSigningKey(STObject const& sigObject, beast::Journal j) std::optional preflightCheckSimulateKeys(ApplyFlags flags, STObject const& sigObject, beast::Journal j) { - if ((flags & tapDRY_RUN) != 0u) // simulation + if ((flags & TapDryRun) != 0u) // simulation { std::optional const signature = sigObject[~sfTxnSignature]; if (signature && !signature->empty()) @@ -182,7 +182,7 @@ Transactor::preflight1(PreflightContext const& ctx, std::uint32_t flagMask) return ret; auto const id = ctx.tx.getAccountID(sfAccount); - if (id == beast::zero) + if (id == beast::kZERO) { JLOG(ctx.j.warn()) << "preflight1: bad account id"; return temBAD_SRC_ACCOUNT; @@ -260,7 +260,7 @@ Transactor::preflight2(PreflightContext const& ctx) Transactor::Transactor(ApplyContext& ctx) : ctx_(ctx) - , sink_(ctx.journal, to_short_string(ctx.tx.getTransactionID()) + " ") + , sink_(ctx.journal, toShortString(ctx.tx.getTransactionID()) + " ") , j_(sink_) , account_(ctx.tx.getAccountID(sfAccount)) { @@ -348,7 +348,7 @@ Transactor::minimumFee( Fees const& fees, ApplyFlags flags) { - return scaleFeeLoad(baseFee, registry.getFeeTrack(), fees, (flags & tapUNLIMITED) != 0u); + return scaleFeeLoad(baseFee, registry.getFeeTrack(), fees, (flags & TapUnlimited) != 0u); } TER @@ -359,16 +359,16 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) auto const feePaid = ctx.tx[sfFee].xrp(); - if ((ctx.flags & tapBATCH) != 0u) + if ((ctx.flags & TapBatch) != 0u) { - if (feePaid == beast::zero) + if (feePaid == beast::kZERO) return tesSUCCESS; JLOG(ctx.j.trace()) << "Batch: Fee must be zero."; return temBAD_FEE; // LCOV_EXCL_LINE } - if (!isLegalAmount(feePaid) || feePaid < beast::zero) + if (!isLegalAmount(feePaid) || feePaid < beast::kZERO) return temBAD_FEE; // Only check fee is sufficient when the ledger is open. @@ -384,7 +384,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) } } - if (feePaid == beast::zero) + if (feePaid == beast::kZERO) return tesSUCCESS; auto const id = ctx.tx.getFeePayer(); @@ -406,7 +406,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) JLOG(ctx.j.trace()) << "Insufficient balance:" << " balance=" << to_string(balance) << " paid=" << to_string(feePaid); - if ((balance > beast::zero) && !ctx.view.open()) + if ((balance > beast::kZERO) && !ctx.view.open()) { // Closed ledger, non-zero balance, less than fee return tecINSUFF_FEE; @@ -452,10 +452,10 @@ Transactor::checkSeqProxy(ReadView const& view, STTx const& tx, beast::Journal j return terNO_ACCOUNT; } - SeqProxy const t_seqProx = tx.getSeqProxy(); - SeqProxy const a_seq = SeqProxy::sequence((*sle)[sfSequence]); + SeqProxy const tSeqProx = tx.getSeqProxy(); + SeqProxy const aSeq = SeqProxy::sequence((*sle)[sfSequence]); - if (t_seqProx.isSeq()) + if (tSeqProx.isSeq()) { if (tx.isFieldPresent(sfTicketSequence)) { @@ -463,39 +463,39 @@ Transactor::checkSeqProxy(ReadView const& view, STTx const& tx, beast::Journal j "and a non-zero Sequence number"; return temSEQ_AND_TICKET; } - if (t_seqProx != a_seq) + if (tSeqProx != aSeq) { - if (a_seq < t_seqProx) + if (aSeq < tSeqProx) { JLOG(j.trace()) << "applyTransaction: has future sequence number " - << "a_seq=" << a_seq << " t_seq=" << t_seqProx; + << "a_seq=" << aSeq << " t_seq=" << tSeqProx; return terPRE_SEQ; } // It's an already-used sequence number. JLOG(j.trace()) << "applyTransaction: has past sequence number " - << "a_seq=" << a_seq << " t_seq=" << t_seqProx; + << "a_seq=" << aSeq << " t_seq=" << tSeqProx; return tefPAST_SEQ; } } - else if (t_seqProx.isTicket()) + else if (tSeqProx.isTicket()) { // Bypass the type comparison. Apples and oranges. - if (a_seq.value() <= t_seqProx.value()) + if (aSeq.value() <= tSeqProx.value()) { // If the Ticket number is greater than or equal to the // account sequence there's the possibility that the // transaction to create the Ticket has not hit the ledger // yet. Allow a retry. JLOG(j.trace()) << "applyTransaction: has future ticket id " - << "a_seq=" << a_seq << " t_seq=" << t_seqProx; + << "a_seq=" << aSeq << " t_seq=" << tSeqProx; return terPRE_TICKET; } // Transaction can never succeed if the Ticket is not in the ledger. - if (!view.exists(keylet::ticket(id, t_seqProx))) + if (!view.exists(keylet::kTICKET(id, tSeqProx))) { JLOG(j.trace()) << "applyTransaction: ticket already used or never created " - << "a_seq=" << a_seq << " t_seq=" << t_seqProx; + << "a_seq=" << aSeq << " t_seq=" << tSeqProx; return tefNO_TICKET; } } @@ -557,7 +557,7 @@ Transactor::ticketDelete( { // Delete the Ticket, adjust the account root ticket count, and // reduce the owner count. - SLE::pointer const sleTicket = view.peek(keylet::ticket(ticketIndex)); + SLE::pointer const sleTicket = view.peek(keylet::kTICKET(ticketIndex)); if (!sleTicket) { // LCOV_EXCL_START @@ -617,7 +617,7 @@ Transactor::ticketDelete( void Transactor::preCompute() { - XRPL_ASSERT(account_ != beast::zero, "xrpl::Transactor::preCompute : nonzero account"); + XRPL_ASSERT(account_ != beast::kZERO, "xrpl::Transactor::preCompute : nonzero account"); } TER @@ -632,7 +632,7 @@ Transactor::apply() // sle must exist except for transactions // that allow zero account. XRPL_ASSERT( - sle != nullptr || account_ == beast::zero, + sle != nullptr || account_ == beast::kZERO, "xrpl::Transactor::apply : non-null SLE or zero account"); if (sle) @@ -690,7 +690,7 @@ Transactor::checkSign( return tesSUCCESS; } - if (((flags & tapDRY_RUN) != 0u) && pkSigner.empty() && !sigObject.isFieldPresent(sfSigners)) + if (((flags & TapDryRun) != 0u) && pkSigner.empty() && !sigObject.isFieldPresent(sfSigners)) { // simulate: skip signature validation when neither SigningPubKey nor // Signers are provided @@ -881,7 +881,7 @@ Transactor::checkMultiSign( } XRPL_ASSERT( - (flags & tapDRY_RUN) || !spk.empty(), + (flags & TapDryRun) || !spk.empty(), "xrpl::Transactor::checkMultiSign : non-empty signer or " "simulation"); AccountID const signingAcctIDFromPubKey = @@ -979,7 +979,7 @@ removeUnfundedOffers(ApplyView& view, std::vector const& offers, beast: { // offer is unfunded offerDelete(view, sleOffer, viewJ); - if (++removed == unfundedOfferRemoveLimit) + if (++removed == kUNFUNDED_OFFER_REMOVE_LIMIT) return; } } @@ -998,7 +998,7 @@ removeExpiredNFTokenOffers( if (auto const offer = view.peek(keylet::nftoffer(index))) { nft::deleteTokenOffer(view, offer); - if (++removed == expiredOfferRemoveLimit) + if (++removed == kEXPIRED_OFFER_REMOVE_LIMIT) return; } } @@ -1020,7 +1020,7 @@ removeDeletedTrustLines( std::vector const& trustLines, beast::Journal viewJ) { - if (trustLines.size() > maxDeletableAMMTrustLines) + if (trustLines.size() > kMAX_DELETABLE_AMM_TRUST_LINES) { JLOG(viewJ.error()) << "removeDeletedTrustLines: deleted trustlines exceed max " << trustLines.size(); @@ -1072,17 +1072,17 @@ Transactor::reset(XRPAmount fee) // The account should never be missing from the ledger. But if it // is missing then we can't very well charge it a fee, can we? if (!txnAcct) - return {tefINTERNAL, beast::zero}; + return {tefINTERNAL, beast::kZERO}; auto const payerSle = view().peek(keylet::account(ctx_.tx.getFeePayer())); if (!payerSle) - return {tefINTERNAL, beast::zero}; // LCOV_EXCL_LINE + return {tefINTERNAL, beast::kZERO}; // LCOV_EXCL_LINE auto const balance = payerSle->getFieldAmount(sfBalance).xrp(); // balance should have already been checked in checkFee / preFlight. XRPL_ASSERT( - balance != beast::zero && (!view().open() || balance >= fee), + balance != beast::kZERO && (!view().open() || balance >= fee), "xrpl::Transactor::reset : valid balance"); // We retry/reject the transaction if the account balance is zero or @@ -1135,7 +1135,7 @@ Transactor::checkTransactionInvariants(TER result, XRPAmount fee) { JLOG(ctx_.journal.fatal()) << // "Transaction has failed one or more transaction invariants, tx: " << // - to_string(ctx_.tx.getJson(JsonOptions::none)); + to_string(ctx_.tx.getJson(JsonOptions::KNone)); return tecINVARIANT_FAILED; } } @@ -1145,7 +1145,7 @@ Transactor::checkTransactionInvariants(TER result, XRPAmount fee) "Exception while checking transaction invariants: " << // ex.what() << // ", tx: " << // - to_string(ctx_.tx.getJson(JsonOptions::none)); + to_string(ctx_.tx.getJson(JsonOptions::KNone)); return tecINVARIANT_FAILED; } @@ -1198,8 +1198,8 @@ Transactor::operator()() { // LCOV_EXCL_START JLOG(j_.fatal()) << "Transaction serdes mismatch"; - JLOG(j_.fatal()) << ctx_.tx.getJson(JsonOptions::none); - JLOG(j_.fatal()) << s2.getJson(JsonOptions::none); + JLOG(j_.fatal()) << ctx_.tx.getJson(JsonOptions::KNone); + JLOG(j_.fatal()) << s2.getJson(JsonOptions::KNone); UNREACHABLE("xrpl::Transactor::operator() : transaction serdes mismatch"); // LCOV_EXCL_STOP } @@ -1226,10 +1226,10 @@ Transactor::operator()() bool applied = isTesSuccess(result); auto fee = ctx_.tx.getFieldAmount(sfFee).xrp(); - if (ctx_.size() > oversizeMetaDataCap) + if (ctx_.size() > kOVERSIZE_META_DATA_CAP) result = tecOVERSIZE; - if (isTecClaim(result) && ((view().flags() & tapFAIL_HARD) != 0u)) + if (isTecClaim(result) && ((view().flags() & TapFailHard) != 0u)) { // If the tapFAIL_HARD flag is set, a tec result // must not do anything @@ -1381,21 +1381,21 @@ Transactor::operator()() // The transactor and invariant checkers guarantee that this will // *never* trigger but if it, somehow, happens, don't allow a tx // that charges a negative fee. - if (fee < beast::zero) + if (fee < beast::kZERO) Throw("fee charged is negative!"); // Charge whatever fee they specified. The fee has already been // deducted from the balance of the account that issued the // transaction. We just need to account for it in the ledger // header. - if (!view().open() && fee != beast::zero) + if (!view().open() && fee != beast::kZERO) ctx_.destroyXRP(fee); // Once we call apply, we will no longer be able to look at view() metadata = ctx_.apply(result); } - if ((ctx_.flags() & tapDRY_RUN) != 0u) + if ((ctx_.flags() & TapDryRun) != 0u) { applied = false; } diff --git a/src/libxrpl/tx/apply.cpp b/src/libxrpl/tx/apply.cpp index 65c9649035..228d15778f 100644 --- a/src/libxrpl/tx/apply.cpp +++ b/src/libxrpl/tx/apply.cpp @@ -27,10 +27,10 @@ namespace xrpl { // These are the same flags defined as HashRouterFlags::PRIVATE1-4 in // HashRouter.h -constexpr HashRouterFlags SF_SIGBAD = HashRouterFlags::PRIVATE1; // Signature is bad -constexpr HashRouterFlags SF_SIGGOOD = HashRouterFlags::PRIVATE2; // Signature is good -constexpr HashRouterFlags SF_LOCALBAD = HashRouterFlags::PRIVATE3; // Local checks failed -constexpr HashRouterFlags SF_LOCALGOOD = HashRouterFlags::PRIVATE4; // Local checks passed +constexpr HashRouterFlags kSF_SIGBAD = HashRouterFlags::PRIVATE1; // Signature is bad +constexpr HashRouterFlags kSF_SIGGOOD = HashRouterFlags::PRIVATE2; // Signature is good +constexpr HashRouterFlags kSF_LOCALBAD = HashRouterFlags::PRIVATE3; // Local checks failed +constexpr HashRouterFlags kSF_LOCALGOOD = HashRouterFlags::PRIVATE4; // Local checks passed //------------------------------------------------------------------------------ @@ -57,41 +57,41 @@ checkValidity(HashRouter& router, STTx const& tx, Rules const& rules) std::string reason; if (!passesLocalChecks(tx, reason)) { - router.setFlags(id, SF_LOCALBAD); + router.setFlags(id, kSF_LOCALBAD); return {Validity::SigGoodOnly, reason}; } - router.setFlags(id, SF_SIGGOOD); + router.setFlags(id, kSF_SIGGOOD); return {Validity::Valid, ""}; } } - if (any(flags & SF_SIGBAD)) + if (any(flags & kSF_SIGBAD)) { // Signature is known bad return {Validity::SigBad, "Transaction has bad signature."}; } - if (!any(flags & SF_SIGGOOD)) + if (!any(flags & kSF_SIGGOOD)) { auto const sigVerify = tx.checkSign(rules); if (!sigVerify) { - router.setFlags(id, SF_SIGBAD); + router.setFlags(id, kSF_SIGBAD); return {Validity::SigBad, sigVerify.error()}; } - router.setFlags(id, SF_SIGGOOD); + router.setFlags(id, kSF_SIGGOOD); } // Signature is now known good - if (any(flags & SF_LOCALBAD)) + if (any(flags & kSF_LOCALBAD)) { // ...but the local checks // are known bad. return {Validity::SigGoodOnly, "Local checks failed."}; } - if (any(flags & SF_LOCALGOOD)) + if (any(flags & kSF_LOCALGOOD)) { // ...and the local checks // are known good. @@ -102,10 +102,10 @@ checkValidity(HashRouter& router, STTx const& tx, Rules const& rules) std::string reason; if (!passesLocalChecks(tx, reason)) { - router.setFlags(id, SF_LOCALBAD); + router.setFlags(id, kSF_LOCALBAD); return {Validity::SigGoodOnly, reason}; } - router.setFlags(id, SF_LOCALGOOD); + router.setFlags(id, kSF_LOCALGOOD); return {Validity::Valid, ""}; } @@ -116,10 +116,10 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity) switch (validity) { case Validity::Valid: - flags |= SF_LOCALGOOD; + flags |= kSF_LOCALGOOD; [[fallthrough]]; case Validity::SigGoodOnly: - flags |= SF_SIGGOOD; + flags |= kSF_SIGGOOD; [[fallthrough]]; case Validity::SigBad: // would be silly to call directly @@ -173,9 +173,9 @@ applyBatchTransactions( auto const mode = batchTxn.getFlags(); auto applyOneTransaction = [®istry, &j, &parentBatchId, &batchView](STTx const& tx) { - OpenView perTxBatchView(batch_view, batchView); + OpenView perTxBatchView(kBATCH_VIEW, batchView); - auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, tapBATCH, j); + auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, TapBatch, j); XRPL_ASSERT( ret.applied == (isTesSuccess(ret.ter) || isTecClaim(ret.ter)), "Inner transaction should not be applied"); @@ -231,7 +231,7 @@ applyTransaction( { // Returns false if the transaction has need not be retried. if (retryAssured) - flags = flags | tapRETRY; + flags = flags | TapRetry; JLOG(j.debug()) << "TXN " << txn.getTransactionID() << (retryAssured ? "/retry" : "/final"); @@ -247,7 +247,7 @@ applyTransaction( // its inner transactions as necessary. if (isTesSuccess(result.ter) && txn.getTxnType() == ttBATCH) { - OpenView wholeBatchView(batch_view, view); + OpenView wholeBatchView(kBATCH_VIEW, view); if (applyBatchTransactions(registry, wholeBatchView, txn, j)) wholeBatchView.apply(view); diff --git a/src/libxrpl/tx/applySteps.cpp b/src/libxrpl/tx/applySteps.cpp index a0667719c1..7833341808 100644 --- a/src/libxrpl/tx/applySteps.cpp +++ b/src/libxrpl/tx/applySteps.cpp @@ -56,7 +56,7 @@ struct UnknownTxnType : std::exception // throw an "UnknownTxnType" exception on error template auto -with_txn_type(Rules const& rules, TxType txnType, F&& f) +withTxnType(Rules const& rules, TxType txnType, F&& f) { // These global updates really should have been for every Transaction // step: preflight, preclaim, calculateBaseFee, and doApply. Unfortunately, @@ -84,7 +84,7 @@ with_txn_type(Rules const& rules, TxType txnType, F&& f) else { // Without those features enabled, always use the old number rules. - mantissaScaleGuard.emplace(MantissaRange::mantissa_scale::small); + mantissaScaleGuard.emplace(MantissaRange::MantissaScale::Small); } switch (txnType) @@ -106,7 +106,7 @@ with_txn_type(Rules const& rules, TxType txnType, F&& f) } } // namespace -// Templates so preflight does the right thing with T::ConsequencesFactory. +// Templates so preflight does the right thing with T::kCONSEQUENCES_FACTORY. // // This could be done more easily using if constexpr, but Visual Studio // 2017 doesn't handle if constexpr correctly. So once we're no longer @@ -117,40 +117,40 @@ with_txn_type(Rules const& rules, TxType txnType, F&& f) // template - requires(T::ConsequencesFactory == Transactor::Normal) + requires(T::kCONSEQUENCES_FACTORY == Transactor::Normal) TxConsequences -consequences_helper(PreflightContext const& ctx) +consequencesHelper(PreflightContext const& ctx) { return TxConsequences(ctx.tx); }; // For Transactor::Blocker template - requires(T::ConsequencesFactory == Transactor::Blocker) + requires(T::kCONSEQUENCES_FACTORY == Transactor::Blocker) TxConsequences -consequences_helper(PreflightContext const& ctx) +consequencesHelper(PreflightContext const& ctx) { - return TxConsequences(ctx.tx, TxConsequences::Category::blocker); + return TxConsequences(ctx.tx, TxConsequences::Category::Blocker); }; // For Transactor::Custom template - requires(T::ConsequencesFactory == Transactor::Custom) + requires(T::kCONSEQUENCES_FACTORY == Transactor::Custom) TxConsequences -consequences_helper(PreflightContext const& ctx) +consequencesHelper(PreflightContext const& ctx) { return T::makeTxConsequences(ctx); }; static std::pair -invoke_preflight(PreflightContext const& ctx) +invokePreflight(PreflightContext const& ctx) { try { - return with_txn_type(ctx.rules, ctx.tx.getTxnType(), [&]() { + return withTxnType(ctx.rules, ctx.tx.getTxnType(), [&]() { auto const tec = Transactor::invokePreflight(ctx); return std::make_pair( - tec, isTesSuccess(tec) ? consequences_helper(ctx) : TxConsequences{tec}); + tec, isTesSuccess(tec) ? consequencesHelper(ctx) : TxConsequences{tec}); }); } catch (UnknownTxnType const& e) @@ -165,13 +165,13 @@ invoke_preflight(PreflightContext const& ctx) } static TER -invoke_preclaim(PreclaimContext const& ctx) +invokePreclaim(PreclaimContext const& ctx) { try { // use name hiding to accomplish compile-time polymorphism of static // class functions for Transactor and derived classes. - return with_txn_type(ctx.view.rules(), ctx.tx.getTxnType(), [&]() -> TER { + return withTxnType(ctx.view.rules(), ctx.tx.getTxnType(), [&]() -> TER { // preclaim functionality is divided into two sections: // 1. Up to and including the signature check: returns NotTEC. // All transaction checks before and including checkSign @@ -186,7 +186,7 @@ invoke_preclaim(PreclaimContext const& ctx) // a flagged a failure. auto const id = ctx.tx.getAccountID(sfAccount); - if (id != beast::zero) + if (id != beast::kZERO) { if (NotTEC const preSigResult = [&]() -> NotTEC { if (NotTEC const result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j)) @@ -240,11 +240,11 @@ invoke_preclaim(PreclaimContext const& ctx) * logs an error and returns an XRPAmount of zero. */ static XRPAmount -invoke_calculateBaseFee(ReadView const& view, STTx const& tx) +invokeCalculateBaseFee(ReadView const& view, STTx const& tx) { try { - return with_txn_type(view.rules(), tx.getTxnType(), [&]() { + return withTxnType(view.rules(), tx.getTxnType(), [&]() { return T::calculateBaseFee(view, tx); }); } @@ -259,8 +259,8 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx) TxConsequences::TxConsequences(NotTEC pfResult) : isBlocker_(false) - , fee_(beast::zero) - , potentialSpend_(beast::zero) + , fee_(beast::kZERO) + , potentialSpend_(beast::kZERO) , seqProx_(SeqProxy::sequence(0)) , sequencesConsumed_(0) { @@ -270,8 +270,8 @@ TxConsequences::TxConsequences(NotTEC pfResult) TxConsequences::TxConsequences(STTx const& tx) : isBlocker_(false) - , fee_(tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp() : beast::zero) - , potentialSpend_(beast::zero) + , fee_(tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp() : beast::kZERO) + , potentialSpend_(beast::kZERO) , seqProx_(tx.getSeqProxy()) , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0) { @@ -279,7 +279,7 @@ TxConsequences::TxConsequences(STTx const& tx) TxConsequences::TxConsequences(STTx const& tx, Category category) : TxConsequences(tx) { - isBlocker_ = (category == Category::blocker); + isBlocker_ = (category == TxConsequences::Category::Blocker); } TxConsequences::TxConsequences(STTx const& tx, XRPAmount potentialSpend) : TxConsequences(tx) @@ -293,11 +293,11 @@ TxConsequences::TxConsequences(STTx const& tx, std::uint32_t sequencesConsumed) } static ApplyResult -invoke_apply(ApplyContext& ctx) +invokeApply(ApplyContext& ctx) { try { - return with_txn_type(ctx.view().rules(), ctx.tx.getTxnType(), [&]() { + return withTxnType(ctx.view().rules(), ctx.tx.getTxnType(), [&]() { T p(ctx); return p(); }); @@ -319,7 +319,7 @@ invoke_apply(ApplyContext& ctx) std::unique_ptr makeTransactor(ApplyContext& ctx) { - return with_txn_type( + return withTxnType( ctx.view().rules(), ctx.tx.getTxnType(), [&]() -> std::unique_ptr { return std::make_unique(ctx); }); @@ -336,7 +336,7 @@ preflight( PreflightContext const pfCtx(registry, tx, rules, flags, j); try { - return {pfCtx, invoke_preflight(pfCtx)}; + return {pfCtx, invokePreflight(pfCtx)}; } catch (std::exception const& e) { @@ -357,7 +357,7 @@ preflight( PreflightContext const pfCtx(registry, tx, parentBatchId, rules, flags, j); try { - return {pfCtx, invoke_preflight(pfCtx)}; + return {pfCtx, invokePreflight(pfCtx)}; } catch (std::exception const& e) { @@ -417,7 +417,7 @@ preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, Open { if (!isTesSuccess(ctx->preflightResult)) return {*ctx, ctx->preflightResult}; - return {*ctx, invoke_preclaim(*ctx)}; + return {*ctx, invokePreclaim(*ctx)}; } catch (std::exception const& e) { @@ -429,7 +429,7 @@ preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, Open XRPAmount calculateBaseFee(ReadView const& view, STTx const& tx) { - return invoke_calculateBaseFee(view, tx); + return invokeCalculateBaseFee(view, tx); } XRPAmount @@ -460,7 +460,7 @@ doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenVie calculateBaseFee(view, preclaimResult.tx), preclaimResult.flags, preclaimResult.j); - return invoke_apply(ctx); + return invokeApply(ctx); } catch (std::exception const& e) { diff --git a/src/libxrpl/tx/invariants/AMMInvariant.cpp b/src/libxrpl/tx/invariants/AMMInvariant.cpp index af60f3fc55..6469799eb6 100644 --- a/src/libxrpl/tx/invariants/AMMInvariant.cpp +++ b/src/libxrpl/tx/invariants/AMMInvariant.cpp @@ -69,11 +69,11 @@ validBalances( ValidAMM::ZeroAllowed zeroAllowed) { bool const positive = - amount > beast::zero && amount2 > beast::zero && lptAMMBalance > beast::zero; + amount > beast::kZERO && amount2 > beast::kZERO && lptAMMBalance > beast::kZERO; if (zeroAllowed == ValidAMM::ZeroAllowed::Yes) { return positive || - (amount == beast::zero && amount2 == beast::zero && lptAMMBalance == beast::zero); + (amount == beast::kZERO && amount2 == beast::kZERO && lptAMMBalance == beast::kZERO); } return positive; } @@ -111,7 +111,7 @@ ValidAMM::finalizeBid(bool enforce, beast::Journal const& j) const // LPTokens are burnt, therefore there should be fewer LPTokens else if ( lptAMMBalanceBefore_ && lptAMMBalanceAfter_ && - (*lptAMMBalanceAfter_ > *lptAMMBalanceBefore_ || *lptAMMBalanceAfter_ <= beast::zero)) + (*lptAMMBalanceAfter_ > *lptAMMBalanceBefore_ || *lptAMMBalanceAfter_ <= beast::kZERO)) { // LCOV_EXCL_START JLOG(j.error()) << "AMMBid invariant failed: " << *lptAMMBalanceBefore_ << " " @@ -146,8 +146,8 @@ ValidAMM::finalizeCreate( *ammAccount_, tx[sfAmount].asset(), tx[sfAmount2].asset(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j); // Create invariant: // sqrt(amount * amount2) == LPTokens @@ -214,8 +214,8 @@ ValidAMM::generalInvariant( *ammAccount_, tx[sfAsset], tx[sfAsset2], - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j); // Deposit and Withdrawal invariant: // sqrt(amount * amount2) >= LPTokens @@ -227,16 +227,16 @@ ValidAMM::generalInvariant( bool const strongInvariantCheck = poolProductMean >= *lptAMMBalanceAfter_; // Allow for a small relative error if strongInvariantCheck fails auto weakInvariantCheck = [&]() { - return *lptAMMBalanceAfter_ != beast::zero && + return *lptAMMBalanceAfter_ != beast::kZERO && withinRelativeDistance(poolProductMean, Number{*lptAMMBalanceAfter_}, Number{1, -11}); }; if (!nonNegativeBalances || (!strongInvariantCheck && !weakInvariantCheck())) { JLOG(j.error()) << "AMM " << tx.getTxnType() - << " invariant failed: " << tx.getHash(HashPrefix::transactionID) << " " + << " invariant failed: " << tx.getHash(HashPrefix::TransactionId) << " " << ammPoolChanged_ << " " << amount << " " << amount2 << " " << poolProductMean << " " << lptAMMBalanceAfter_->getText() << " " - << ((*lptAMMBalanceAfter_ == beast::zero) + << ((*lptAMMBalanceAfter_ == beast::kZERO) ? Number{1} : ((*lptAMMBalanceAfter_ - poolProductMean) / poolProductMean)); return false; diff --git a/src/libxrpl/tx/invariants/FreezeInvariant.cpp b/src/libxrpl/tx/invariants/FreezeInvariant.cpp index bf9ef81396..eaaeb7fc6f 100644 --- a/src/libxrpl/tx/invariants/FreezeInvariant.cpp +++ b/src/libxrpl/tx/invariants/FreezeInvariant.cpp @@ -272,7 +272,7 @@ TransfersNotFrozen::validateFrozenState( } // AMMClawbacks are allowed to override some freeze rules - if ((!isAMMLine || globalFreeze) && hasPrivilege(tx, overrideFreeze)) + if ((!isAMMLine || globalFreeze) && hasPrivilege(tx, OverrideFreeze)) { JLOG(j.debug()) << "Invariant check allowing funds to be moved " << (change.balanceChangeSign > 0 ? "to" : "from") diff --git a/src/libxrpl/tx/invariants/InvariantCheck.cpp b/src/libxrpl/tx/invariants/InvariantCheck.cpp index 2f12c7ce1e..4f25a91bdf 100644 --- a/src/libxrpl/tx/invariants/InvariantCheck.cpp +++ b/src/libxrpl/tx/invariants/InvariantCheck.cpp @@ -89,7 +89,7 @@ TransactionFeeCheck::finalize( // We should never charge a fee that's greater than or equal to the // entire XRP supply. - if (fee >= INITIAL_XRP) + if (fee >= kINITIAL_XRP) { JLOG(j.fatal()) << "Invariant failed: fee paid exceeds system limit: " << fee.drops(); return false; @@ -205,7 +205,7 @@ XRPBalanceChecks::visitEntry( // Can't have more than the number of drops instantiated // in the genesis ledger. - if (drops > INITIAL_XRP) + if (drops > kINITIAL_XRP) return true; // Can't have a negative balance (0 is OK) @@ -249,10 +249,10 @@ NoBadOffers::visitEntry( { auto isBad = [](STAmount const& pays, STAmount const& gets) { // An offer should never be negative - if (pays < beast::zero) + if (pays < beast::kZERO) return true; - if (gets < beast::zero) + if (gets < beast::kZERO) return true; // Can't have an XRP to XRP offer: @@ -298,7 +298,7 @@ NoZeroEscrow::visitEntry( if (amount.xrp() <= XRPAmount{0}) return true; - if (amount.xrp() >= INITIAL_XRP) + if (amount.xrp() >= kINITIAL_XRP) return true; } else @@ -306,7 +306,7 @@ NoZeroEscrow::visitEntry( return amount.asset().visit( [&](Issue const& issue) { // IOU case - if (amount <= beast::zero) + if (amount <= beast::kZERO) return true; if (badCurrency() == issue.currency) @@ -318,10 +318,10 @@ NoZeroEscrow::visitEntry( // MPT case , [&](MPTIssue const&) { - if (amount <= beast::zero) + if (amount <= beast::kZERO) return true; - if (amount.mpt() > MPTAmount{maxMPTokenAmount}) + if (amount.mpt() > MPTAmount{kMAX_MP_TOKEN_AMOUNT}) return true; // LCOV_EXCL_LINE return false; @@ -337,7 +337,7 @@ NoZeroEscrow::visitEntry( bad_ |= isBad((*after)[sfAmount]); auto checkAmount = [this](std::int64_t amount) { - if (amount > maxMPTokenAmount || amount < 0) + if (amount > kMAX_MP_TOKEN_AMOUNT || amount < 0) bad_ |= true; }; @@ -414,7 +414,7 @@ AccountRootsNotDeleted::finalize( // transaction when the total AMM LP Tokens balance goes to 0. // A successful AccountDelete or AMMDelete MUST delete exactly // one account root. - if (hasPrivilege(tx, mustDeleteAcct) && isTesSuccess(result)) + if (hasPrivilege(tx, MustDeleteAcct) && isTesSuccess(result)) { if (accountsDeleted_ == 1) return true; @@ -433,7 +433,7 @@ AccountRootsNotDeleted::finalize( // A successful AMMWithdraw/AMMClawback MAY delete one account root // when the total AMM LP Tokens balance goes to 0. Not every AMM withdraw // deletes the AMM account, accountsDeleted_ is set if it is deleted. - if (hasPrivilege(tx, mayDeleteAcct) && isTesSuccess(result) && accountsDeleted_ == 1) + if (hasPrivilege(tx, MayDeleteAcct) && isTesSuccess(result) && accountsDeleted_ == 1) return true; if (accountsDeleted_ == 0) @@ -501,7 +501,7 @@ AccountRootsDeletedClean::finalize( { auto const accountID = before->getAccountID(sfAccount); // An account should not be deleted with a balance - if (after->at(sfBalance) != beast::zero) + if (after->at(sfBalance) != beast::kZERO) { JLOG(j.fatal()) << "Invariant failed: account deletion left " "behind a non-zero balance"; @@ -525,7 +525,7 @@ AccountRootsDeletedClean::finalize( return false; } // Simple types - for (auto const& [keyletfunc, _1, _2] : directAccountKeylets) + for (auto const& [keyletfunc, _1, _2] : kDIRECT_ACCOUNT_KEYLETS) { // TODO: use '_' for both unused variables above once we are in C++26 if (objectExists(std::invoke(keyletfunc, accountID)) && enforce) @@ -537,8 +537,8 @@ AccountRootsDeletedClean::finalize( // checked above as entries in directAccountKeylets. This uses // view.succ() to check for any NFT pages in between the two // endpoints. - Keylet const first = keylet::nftpage_min(accountID); - Keylet const last = keylet::nftpage_max(accountID); + Keylet const first = keylet::nftpageMin(accountID); + Keylet const last = keylet::nftpageMax(accountID); std::optional key = view.succ(first.key, last.key.next()); @@ -746,14 +746,14 @@ ValidNewAccountRoot::finalize( } // From this point on we know exactly one account was created. - if (hasPrivilege(tx, createAcct | createPseudoAcct) && isTesSuccess(result)) + if (hasPrivilege(tx, CreateAcct | CreatePseudoAcct) && isTesSuccess(result)) { bool const pseudoAccount = (pseudoAccount_ && (view.rules().enabled(featureSingleAssetVault) || view.rules().enabled(featureLendingProtocol))); - if (pseudoAccount && !hasPrivilege(tx, createPseudoAcct)) + if (pseudoAccount && !hasPrivilege(tx, CreatePseudoAcct)) { JLOG(j.fatal()) << "Invariant failed: pseudo-account created by a " "wrong transaction type"; @@ -796,10 +796,10 @@ ValidClawback::visitEntry( std::shared_ptr const&) { if (before && before->getType() == ltRIPPLE_STATE) - trustlinesChanged++; + trustlinesChanged_++; if (before && before->getType() == ltMPTOKEN) - mptokensChanged++; + mptokensChanged_++; } bool @@ -815,20 +815,20 @@ ValidClawback::finalize( if (isTesSuccess(result)) { - if (trustlinesChanged > 1) + if (trustlinesChanged_ > 1) { JLOG(j.fatal()) << "Invariant failed: more than one trustline changed."; return false; } - if (mptokensChanged > 1) + if (mptokensChanged_ > 1) { JLOG(j.fatal()) << "Invariant failed: more than one mptokens changed."; return false; } bool const mptV2Enabled = view.rules().enabled(featureMPTokensV2); - if (trustlinesChanged == 1 || (mptV2Enabled && mptokensChanged == 1)) + if (trustlinesChanged_ == 1 || (mptV2Enabled && mptokensChanged_ == 1)) { AccountID const issuer = tx.getAccountID(sfAccount); STAmount const& amount = tx.getFieldAmount(sfAmount); @@ -836,15 +836,15 @@ ValidClawback::finalize( STAmount const holderBalance = amount.asset().visit( [&](Issue const& issue) { return accountHolds( - view, holder, issue.currency, issuer, FreezeHandling::fhIGNORE_FREEZE, j); + view, holder, issue.currency, issuer, FreezeHandling::IgnoreFreeze, j); }, [&](MPTIssue const& issue) { return accountHolds( view, issuer, issue, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j); }); @@ -857,14 +857,14 @@ ValidClawback::finalize( } else { - if (trustlinesChanged != 0) + if (trustlinesChanged_ != 0) { JLOG(j.fatal()) << "Invariant failed: some trustlines were changed " "despite failure of the transaction."; return false; } - if (mptokensChanged != 0) + if (mptokensChanged_ != 0) { JLOG(j.fatal()) << "Invariant failed: some mptokens were changed " "despite failure of the transaction."; @@ -991,7 +991,9 @@ NoModifiedUnmodifiableFields::finalize( ReadView const& view, beast::Journal const& j) { - static auto const fieldChanged = [](auto const& before, auto const& after, auto const& field) { + static auto const kFIELD_CHANGED = [](auto const& before, + auto const& after, + auto const& field) { bool const beforeField = before->isFieldPresent(field); bool const afterField = after->isFieldPresent(field); return beforeField != afterField || (afterField && before->at(field) != after->at(field)); @@ -1012,17 +1014,17 @@ NoModifiedUnmodifiableFields::finalize( * potential issues even when the amendment is disabled. */ enforce = view.rules().enabled(featureLendingProtocol); - bad = fieldChanged(before, after, sfLedgerEntryType) || - fieldChanged(before, after, sfLedgerIndex) || - fieldChanged(before, after, sfSequence) || - fieldChanged(before, after, sfOwnerNode) || - fieldChanged(before, after, sfVaultNode) || - fieldChanged(before, after, sfVaultID) || - fieldChanged(before, after, sfAccount) || - fieldChanged(before, after, sfOwner) || - fieldChanged(before, after, sfManagementFeeRate) || - fieldChanged(before, after, sfCoverRateMinimum) || - fieldChanged(before, after, sfCoverRateLiquidation); + bad = kFIELD_CHANGED(before, after, sfLedgerEntryType) || + kFIELD_CHANGED(before, after, sfLedgerIndex) || + kFIELD_CHANGED(before, after, sfSequence) || + kFIELD_CHANGED(before, after, sfOwnerNode) || + kFIELD_CHANGED(before, after, sfVaultNode) || + kFIELD_CHANGED(before, after, sfVaultID) || + kFIELD_CHANGED(before, after, sfAccount) || + kFIELD_CHANGED(before, after, sfOwner) || + kFIELD_CHANGED(before, after, sfManagementFeeRate) || + kFIELD_CHANGED(before, after, sfCoverRateMinimum) || + kFIELD_CHANGED(before, after, sfCoverRateLiquidation); break; case ltLOAN: /* @@ -1031,26 +1033,26 @@ NoModifiedUnmodifiableFields::finalize( * potential issues even when the amendment is disabled. */ enforce = view.rules().enabled(featureLendingProtocol); - bad = fieldChanged(before, after, sfLedgerEntryType) || - fieldChanged(before, after, sfLedgerIndex) || - fieldChanged(before, after, sfSequence) || - fieldChanged(before, after, sfOwnerNode) || - fieldChanged(before, after, sfLoanBrokerNode) || - fieldChanged(before, after, sfLoanBrokerID) || - fieldChanged(before, after, sfBorrower) || - fieldChanged(before, after, sfLoanOriginationFee) || - fieldChanged(before, after, sfLoanServiceFee) || - fieldChanged(before, after, sfLatePaymentFee) || - fieldChanged(before, after, sfClosePaymentFee) || - fieldChanged(before, after, sfOverpaymentFee) || - fieldChanged(before, after, sfInterestRate) || - fieldChanged(before, after, sfLateInterestRate) || - fieldChanged(before, after, sfCloseInterestRate) || - fieldChanged(before, after, sfOverpaymentInterestRate) || - fieldChanged(before, after, sfStartDate) || - fieldChanged(before, after, sfPaymentInterval) || - fieldChanged(before, after, sfGracePeriod) || - fieldChanged(before, after, sfLoanScale); + bad = kFIELD_CHANGED(before, after, sfLedgerEntryType) || + kFIELD_CHANGED(before, after, sfLedgerIndex) || + kFIELD_CHANGED(before, after, sfSequence) || + kFIELD_CHANGED(before, after, sfOwnerNode) || + kFIELD_CHANGED(before, after, sfLoanBrokerNode) || + kFIELD_CHANGED(before, after, sfLoanBrokerID) || + kFIELD_CHANGED(before, after, sfBorrower) || + kFIELD_CHANGED(before, after, sfLoanOriginationFee) || + kFIELD_CHANGED(before, after, sfLoanServiceFee) || + kFIELD_CHANGED(before, after, sfLatePaymentFee) || + kFIELD_CHANGED(before, after, sfClosePaymentFee) || + kFIELD_CHANGED(before, after, sfOverpaymentFee) || + kFIELD_CHANGED(before, after, sfInterestRate) || + kFIELD_CHANGED(before, after, sfLateInterestRate) || + kFIELD_CHANGED(before, after, sfCloseInterestRate) || + kFIELD_CHANGED(before, after, sfOverpaymentInterestRate) || + kFIELD_CHANGED(before, after, sfStartDate) || + kFIELD_CHANGED(before, after, sfPaymentInterval) || + kFIELD_CHANGED(before, after, sfGracePeriod) || + kFIELD_CHANGED(before, after, sfLoanScale); break; default: /* @@ -1063,8 +1065,8 @@ NoModifiedUnmodifiableFields::finalize( * was added. */ enforce = view.rules().enabled(featureLendingProtocol); - bad = fieldChanged(before, after, sfLedgerEntryType) || - fieldChanged(before, after, sfLedgerIndex); + bad = kFIELD_CHANGED(before, after, sfLedgerEntryType) || + kFIELD_CHANGED(before, after, sfLedgerIndex); } XRPL_ASSERT( !bad || enforce, diff --git a/src/libxrpl/tx/invariants/LoanBrokerInvariant.cpp b/src/libxrpl/tx/invariants/LoanBrokerInvariant.cpp index b72f821f50..b98d769393 100644 --- a/src/libxrpl/tx/invariants/LoanBrokerInvariant.cpp +++ b/src/libxrpl/tx/invariants/LoanBrokerInvariant.cpp @@ -187,8 +187,8 @@ ValidLoanBroker::finalize( view, after->at(sfAccount), vaultAsset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j); if (after->at(sfCoverAvailable) < pseudoBalance) { diff --git a/src/libxrpl/tx/invariants/LoanInvariant.cpp b/src/libxrpl/tx/invariants/LoanInvariant.cpp index 7aea36296e..e3dff3dde9 100644 --- a/src/libxrpl/tx/invariants/LoanInvariant.cpp +++ b/src/libxrpl/tx/invariants/LoanInvariant.cpp @@ -44,9 +44,9 @@ ValidLoan::finalize( // https://github.com/Tapanito/XRPL-Standards/blob/xls-66-lending-protocol/XLS-0066d-lending-protocol/README.md#3223-invariants // If `Loan.PaymentRemaining = 0` then the loan MUST be fully paid off if (after->at(sfPaymentRemaining) == 0 && - (after->at(sfTotalValueOutstanding) != beast::zero || - after->at(sfPrincipalOutstanding) != beast::zero || - after->at(sfManagementFeeOutstanding) != beast::zero)) + (after->at(sfTotalValueOutstanding) != beast::kZERO || + after->at(sfPrincipalOutstanding) != beast::kZERO || + after->at(sfManagementFeeOutstanding) != beast::kZERO)) { JLOG(j.fatal()) << "Invariant failed: Loan with zero payments " "remaining has not been paid off"; @@ -55,9 +55,9 @@ ValidLoan::finalize( // If `Loan.PaymentRemaining != 0` then the loan MUST NOT be fully paid // off if (after->at(sfPaymentRemaining) != 0 && - after->at(sfTotalValueOutstanding) == beast::zero && - after->at(sfPrincipalOutstanding) == beast::zero && - after->at(sfManagementFeeOutstanding) == beast::zero) + after->at(sfTotalValueOutstanding) == beast::kZERO && + after->at(sfPrincipalOutstanding) == beast::kZERO && + after->at(sfManagementFeeOutstanding) == beast::kZERO) { JLOG(j.fatal()) << "Invariant failed: Fully paid off Loan still has payments remaining"; return false; diff --git a/src/libxrpl/tx/invariants/MPTInvariant.cpp b/src/libxrpl/tx/invariants/MPTInvariant.cpp index 97db4aa385..9b8838f145 100644 --- a/src/libxrpl/tx/invariants/MPTInvariant.cpp +++ b/src/libxrpl/tx/invariants/MPTInvariant.cpp @@ -62,7 +62,7 @@ bool ValidMPTIssuance::finalize( STTx const& tx, TER const result, - XRPAmount const _fee, + XRPAmount const fee, ReadView const& view, beast::Journal const& j) const { @@ -85,7 +85,7 @@ ValidMPTIssuance::finalize( } auto const txnType = tx.getTxnType(); - if (hasPrivilege(tx, createMPTIssuance)) + if (hasPrivilege(tx, CreateMptIssuance)) { if (mptIssuancesCreated_ == 0) { @@ -106,7 +106,7 @@ ValidMPTIssuance::finalize( return mptIssuancesCreated_ == 1 && mptIssuancesDeleted_ == 0; } - if (hasPrivilege(tx, destroyMPTIssuance)) + if (hasPrivilege(tx, DestroyMptIssuance)) { if (mptIssuancesDeleted_ == 0) { @@ -133,7 +133,7 @@ ValidMPTIssuance::finalize( // non-amendment-gated side effects. bool const enforceEscrowFinish = (txnType == ttESCROW_FINISH) && (rules.enabled(featureSingleAssetVault) || lendingProtocolEnabled); - if (hasPrivilege(tx, mustAuthorizeMPT | mayAuthorizeMPT) || enforceEscrowFinish) + if (hasPrivilege(tx, MustAuthorizeMpt | MayAuthorizeMpt) || enforceEscrowFinish) { bool const submittedByIssuer = tx.isFieldPresent(sfHolder); @@ -149,7 +149,7 @@ ValidMPTIssuance::finalize( "succeeded but deleted issuances"; return false; } - if (mptV2Enabled && hasPrivilege(tx, mayAuthorizeMPT) && + if (mptV2Enabled && hasPrivilege(tx, MayAuthorizeMpt) && (txnType == ttAMM_WITHDRAW || txnType == ttAMM_CLAWBACK)) { if (submittedByIssuer && txnType == ttAMM_WITHDRAW && mptokensCreated_ > 0) @@ -184,7 +184,7 @@ ValidMPTIssuance::finalize( return false; } else if ( - !submittedByIssuer && hasPrivilege(tx, mustAuthorizeMPT) && + !submittedByIssuer && hasPrivilege(tx, MustAuthorizeMpt) && (mptokensCreated_ + mptokensDeleted_ != 1)) { // if the holder submitted this tx, then a mptoken must be @@ -197,7 +197,7 @@ ValidMPTIssuance::finalize( return true; } - if (hasPrivilege(tx, mayCreateMPT)) + if (hasPrivilege(tx, MayCreateMpt)) { bool const submittedByIssuer = tx.isFieldPresent(sfHolder); @@ -252,7 +252,7 @@ ValidMPTIssuance::finalize( return true; } - if (hasPrivilege(tx, mayDeleteMPT) && + if (hasPrivilege(tx, MayDeleteMpt) && ((txnType == ttAMM_DELETE && mptokensDeleted_ <= 2) || mptokensDeleted_ == 1) && mptokensCreated_ == 0 && mptIssuancesCreated_ == 0 && mptIssuancesDeleted_ == 0) return true; @@ -299,7 +299,7 @@ ValidMPTPayment::visitEntry( if (type == ltMPTOKEN_ISSUANCE) { auto const outstanding = sle[sfOutstandingAmount]; - if (outstanding > maxMPTokenAmount) + if (outstanding > kMAX_MP_TOKEN_AMOUNT) { overflow_ = true; return false; @@ -310,8 +310,8 @@ ValidMPTPayment::visitEntry( { auto const mptAmt = sle[sfMPTAmount]; auto const lockedAmt = sle[~sfLockedAmount].value_or(0); - if (mptAmt > maxMPTokenAmount || lockedAmt > maxMPTokenAmount || - lockedAmt > (maxMPTokenAmount - mptAmt)) + if (mptAmt > kMAX_MP_TOKEN_AMOUNT || lockedAmt > kMAX_MP_TOKEN_AMOUNT || + lockedAmt > (kMAX_MP_TOKEN_AMOUNT - mptAmt)) { overflow_ = true; return false; @@ -361,20 +361,21 @@ ValidMPTPayment::finalize( return !enforce; } - auto const signedMax = static_cast(maxMPTokenAmount); + auto const signedMax = static_cast(kMAX_MP_TOKEN_AMOUNT); for (auto const& [id, data] : data_) { (void)id; - constexpr auto iBefore = static_cast(Order::Before); - constexpr auto iAfter = static_cast(Order::After); + constexpr auto kI_BEFORE = static_cast(Order::Before); + constexpr auto kI_AFTER = static_cast(Order::After); bool const addOverflows = - (data.mptAmount > 0 && data.outstanding[iBefore] > (signedMax - data.mptAmount)) || - (data.mptAmount < 0 && data.outstanding[iBefore] < (-signedMax - data.mptAmount)); + (data.mptAmount > 0 && + data.outstanding[kI_BEFORE] > (signedMax - data.mptAmount)) || + (data.mptAmount < 0 && data.outstanding[kI_BEFORE] < (-signedMax - data.mptAmount)); if (addOverflows || - data.outstanding[iAfter] != (data.outstanding[iBefore] + data.mptAmount)) + data.outstanding[kI_AFTER] != (data.outstanding[kI_BEFORE] + data.mptAmount)) { JLOG(j.fatal()) << "Invariant failed: invalid OutstandingAmount balance " - << data.outstanding[iBefore] << " " << data.outstanding[iAfter] + << data.outstanding[kI_BEFORE] << " " << data.outstanding[kI_AFTER] << " " << data.mptAmount; return !enforce; } diff --git a/src/libxrpl/tx/invariants/NFTInvariant.cpp b/src/libxrpl/tx/invariants/NFTInvariant.cpp index 90511b6d04..da415d2ad8 100644 --- a/src/libxrpl/tx/invariants/NFTInvariant.cpp +++ b/src/libxrpl/tx/invariants/NFTInvariant.cpp @@ -31,16 +31,16 @@ ValidNFTokenPage::visitEntry( std::shared_ptr const& before, std::shared_ptr const& after) { - static constexpr uint256 const& pageBits = nft::pageMask; - static constexpr uint256 const accountBits = ~pageBits; + static constexpr uint256 const& kPAGE_BITS = nft::kPAGE_MASK; + static constexpr uint256 const kACCOUNT_BITS = ~kPAGE_BITS; if ((before && before->getType() != ltNFTOKEN_PAGE) || (after && after->getType() != ltNFTOKEN_PAGE)) return; auto check = [this, isDelete](std::shared_ptr const& sle) { - uint256 const account = sle->key() & accountBits; - uint256 const hiLimit = sle->key() & pageBits; + uint256 const account = sle->key() & kACCOUNT_BITS; + uint256 const hiLimit = sle->key() & kPAGE_BITS; std::optional const prev = (*sle)[~sfPreviousPageMin]; // Make sure that any page links... @@ -48,19 +48,19 @@ ValidNFTokenPage::visitEntry( // 2. The page is correctly ordered between links. if (prev) { - if (account != (*prev & accountBits)) + if (account != (*prev & kACCOUNT_BITS)) badLink_ = true; - if (hiLimit <= (*prev & pageBits)) + if (hiLimit <= (*prev & kPAGE_BITS)) badLink_ = true; } if (auto const next = (*sle)[~sfNextPageMin]) { - if (account != (*next & accountBits)) + if (account != (*next & kACCOUNT_BITS)) badLink_ = true; - if (hiLimit >= (*next & pageBits)) + if (hiLimit >= (*next & kPAGE_BITS)) badLink_ = true; } @@ -69,12 +69,12 @@ ValidNFTokenPage::visitEntry( // An NFTokenPage should never contain too many tokens or be empty. if (std::size_t const nftokenCount = nftokens.size(); - (!isDelete && nftokenCount == 0) || nftokenCount > dirMaxTokensPerPage) + (!isDelete && nftokenCount == 0) || nftokenCount > kDIR_MAX_TOKENS_PER_PAGE) invalidSize_ = true; // If prev is valid, use it to establish a lower bound for // page entries. If prev is not valid the lower bound is zero. - uint256 const loLimit = prev ? *prev & pageBits : uint256(beast::zero); + uint256 const loLimit = prev ? *prev & kPAGE_BITS : uint256(beast::kZERO); // Also verify that all NFTokenIDs in the page are sorted. uint256 loCmp = loLimit; @@ -87,7 +87,7 @@ ValidNFTokenPage::visitEntry( // None of the NFTs on this page should belong on lower or // higher pages. - if (uint256 const tokenPageBits = tokenID & pageBits; + if (uint256 const tokenPageBits = tokenID & kPAGE_BITS; tokenPageBits < loLimit || tokenPageBits >= hiLimit) badEntry_ = true; @@ -104,7 +104,7 @@ ValidNFTokenPage::visitEntry( // While an account's NFToken directory contains any NFTokens, the last // NFTokenPage (with 96 bits of 1 in the low part of the index) should // never be deleted. - if (isDelete && (before->key() & nft::pageMask) == nft::pageMask && + if (isDelete && (before->key() & nft::kPAGE_MASK) == nft::kPAGE_MASK && before->isFieldPresent(sfPreviousPageMin)) { deletedFinalPage_ = true; @@ -121,7 +121,7 @@ ValidNFTokenPage::visitEntry( // 2. This is not the last page in the directory // Then we have identified a corruption in the links between the // NFToken pages in the NFToken directory. - if ((before->key() & nft::pageMask) != nft::pageMask && + if ((before->key() & nft::kPAGE_MASK) != nft::kPAGE_MASK && before->isFieldPresent(sfNextPageMin) && !after->isFieldPresent(sfNextPageMin)) { deletedLink_ = true; @@ -194,14 +194,14 @@ NFTokenCountTracking::visitEntry( { if (before && before->getType() == ltACCOUNT_ROOT) { - beforeMintedTotal += (*before)[~sfMintedNFTokens].value_or(0); - beforeBurnedTotal += (*before)[~sfBurnedNFTokens].value_or(0); + beforeMintedTotal_ += (*before)[~sfMintedNFTokens].value_or(0); + beforeBurnedTotal_ += (*before)[~sfBurnedNFTokens].value_or(0); } if (after && after->getType() == ltACCOUNT_ROOT) { - afterMintedTotal += (*after)[~sfMintedNFTokens].value_or(0); - afterBurnedTotal += (*after)[~sfBurnedNFTokens].value_or(0); + afterMintedTotal_ += (*after)[~sfMintedNFTokens].value_or(0); + afterBurnedTotal_ += (*after)[~sfBurnedNFTokens].value_or(0); } } @@ -213,16 +213,16 @@ NFTokenCountTracking::finalize( ReadView const& view, beast::Journal const& j) const { - if (!hasPrivilege(tx, changeNFTCounts)) + if (!hasPrivilege(tx, ChangeNftCounts)) { - if (beforeMintedTotal != afterMintedTotal) + if (beforeMintedTotal_ != afterMintedTotal_) { JLOG(j.fatal()) << "Invariant failed: the number of minted tokens " "changed without a mint transaction!"; return false; } - if (beforeBurnedTotal != afterBurnedTotal) + if (beforeBurnedTotal_ != afterBurnedTotal_) { JLOG(j.fatal()) << "Invariant failed: the number of burned tokens " "changed without a burn transaction!"; @@ -234,21 +234,21 @@ NFTokenCountTracking::finalize( if (tx.getTxnType() == ttNFTOKEN_MINT) { - if (isTesSuccess(result) && beforeMintedTotal >= afterMintedTotal) + if (isTesSuccess(result) && beforeMintedTotal_ >= afterMintedTotal_) { JLOG(j.fatal()) << "Invariant failed: successful minting didn't increase " "the number of minted tokens."; return false; } - if (!isTesSuccess(result) && beforeMintedTotal != afterMintedTotal) + if (!isTesSuccess(result) && beforeMintedTotal_ != afterMintedTotal_) { JLOG(j.fatal()) << "Invariant failed: failed minting changed the " "number of minted tokens."; return false; } - if (beforeBurnedTotal != afterBurnedTotal) + if (beforeBurnedTotal_ != afterBurnedTotal_) { JLOG(j.fatal()) << "Invariant failed: minting changed the number of " "burned tokens."; @@ -260,7 +260,7 @@ NFTokenCountTracking::finalize( { if (isTesSuccess(result)) { - if (beforeBurnedTotal >= afterBurnedTotal) + if (beforeBurnedTotal_ >= afterBurnedTotal_) { JLOG(j.fatal()) << "Invariant failed: successful burning didn't increase " "the number of burned tokens."; @@ -268,14 +268,14 @@ NFTokenCountTracking::finalize( } } - if (!isTesSuccess(result) && beforeBurnedTotal != afterBurnedTotal) + if (!isTesSuccess(result) && beforeBurnedTotal_ != afterBurnedTotal_) { JLOG(j.fatal()) << "Invariant failed: failed burning changed the " "number of burned tokens."; return false; } - if (beforeMintedTotal != afterMintedTotal) + if (beforeMintedTotal_ != afterMintedTotal_) { JLOG(j.fatal()) << "Invariant failed: burning changed the number of " "minted tokens."; diff --git a/src/libxrpl/tx/invariants/PermissionedDomainInvariant.cpp b/src/libxrpl/tx/invariants/PermissionedDomainInvariant.cpp index 3c6f67a8d6..784a2503ca 100644 --- a/src/libxrpl/tx/invariants/PermissionedDomainInvariant.cpp +++ b/src/libxrpl/tx/invariants/PermissionedDomainInvariant.cpp @@ -36,21 +36,21 @@ ValidPermissionedDomain::visitEntry( auto const sorted = credentials::makeSorted(credentials); SleStatus ss{ - .credentialsSize_ = credentials.size(), - .isSorted_ = false, - .isUnique_ = !sorted.empty(), - .isDelete_ = isDel}; + .credentialsSize = credentials.size(), + .isSorted = false, + .isUnique = !sorted.empty(), + .isDelete = isDel}; // If array have duplicates then all the other checks are invalid - if (ss.isUnique_) + if (ss.isUnique) { unsigned i = 0; for (auto const& cred : sorted) { auto const& credTx = credentials[i++]; - ss.isSorted_ = + ss.isSorted = (cred.first == credTx[sfIssuer]) && (cred.second == credTx[sfCredentialType]); - if (!ss.isSorted_) + if (!ss.isSorted) break; } } @@ -70,29 +70,29 @@ ValidPermissionedDomain::finalize( beast::Journal const& j) { auto check = [](SleStatus const& sleStatus, beast::Journal const& j) { - if (!sleStatus.credentialsSize_) + if (!sleStatus.credentialsSize) { JLOG(j.fatal()) << "Invariant failed: permissioned domain with " "no rules."; return false; } - if (sleStatus.credentialsSize_ > maxPermissionedDomainCredentialsArraySize) + if (sleStatus.credentialsSize > kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE) { JLOG(j.fatal()) << "Invariant failed: permissioned domain bad " "credentials size " - << sleStatus.credentialsSize_; + << sleStatus.credentialsSize; return false; } - if (!sleStatus.isUnique_) + if (!sleStatus.isUnique) { JLOG(j.fatal()) << "Invariant failed: permissioned domain credentials " "aren't unique"; return false; } - if (!sleStatus.isSorted_) + if (!sleStatus.isSorted) { JLOG(j.fatal()) << "Invariant failed: permissioned domain credentials " "aren't sorted"; @@ -129,7 +129,7 @@ ValidPermissionedDomain::finalize( } auto const& sleStatus = sleStatus_[0]; - if (sleStatus.isDelete_) + if (sleStatus.isDelete) { JLOG(j.fatal()) << "Invariant failed: domain object " "deleted by PermissionedDomainSet"; @@ -145,7 +145,7 @@ ValidPermissionedDomain::finalize( return false; } - if (!sleStatus_[0].isDelete_) + if (!sleStatus_[0].isDelete) { JLOG(j.fatal()) << "Invariant failed: domain object " "modified, but not deleted by " diff --git a/src/libxrpl/tx/invariants/VaultInvariant.cpp b/src/libxrpl/tx/invariants/VaultInvariant.cpp index c0d082e14e..0dad8c18a0 100644 --- a/src/libxrpl/tx/invariants/VaultInvariant.cpp +++ b/src/libxrpl/tx/invariants/VaultInvariant.cpp @@ -58,7 +58,7 @@ ValidVault::Shares::make(SLE const& from) ValidVault::Shares self; self.share = MPTIssue(makeMptID(from.getFieldU32(sfSequence), from.getAccountID(sfIssuer))); self.sharesTotal = from.at(sfOutstandingAmount); - self.sharesMaximum = from[~sfMaximumAmount].value_or(maxMPTokenAmount); + self.sharesMaximum = from[~sfMaximumAmount].value_or(kMAX_MP_TOKEN_AMOUNT); return self; } @@ -81,7 +81,7 @@ ValidVault::visitEntry( // validation. It is used to validate that the change in account // balances matches the change in vault balances, stored to deltas_ at the // end of this function. - DeltaInfo balanceDelta{.delta = numZero, .scale = std::nullopt}; + DeltaInfo balanceDelta{.delta = kNUM_ZERO, .scale = std::nullopt}; std::int8_t sign = 0; if (before) @@ -201,7 +201,7 @@ ValidVault::finalize( if (afterVault_.empty() && beforeVault_.empty()) { - if (hasPrivilege(tx, mustModifyVault)) + if (hasPrivilege(tx, MustModifyVault)) { JLOG(j.fatal()) << // "Invariant failed: vault operation succeeded without modifying " @@ -212,7 +212,7 @@ ValidVault::finalize( return true; // Not a vault operation } - if (!(hasPrivilege(tx, mustModifyVault) || hasPrivilege(tx, mayModifyVault))) + if (!(hasPrivilege(tx, MustModifyVault) || hasPrivilege(tx, MayModifyVault))) { JLOG(j.fatal()) << // "Invariant failed: vault updated by a wrong transaction type"; @@ -279,13 +279,13 @@ ValidVault::finalize( "shares outstanding"; result = false; } - if (beforeVault.assetsTotal != zero) + if (beforeVault.assetsTotal != kZERO) { JLOG(j.fatal()) << "Invariant failed: deleted vault must have no " "assets outstanding"; result = false; } - if (beforeVault.assetsAvailable != zero) + if (beforeVault.assetsAvailable != kZERO) { JLOG(j.fatal()) << "Invariant failed: deleted vault must have no " "assets available"; @@ -348,13 +348,13 @@ ValidVault::finalize( if (updatedShares->sharesTotal == 0) { - if (afterVault.assetsTotal != zero) + if (afterVault.assetsTotal != kZERO) { JLOG(j.fatal()) << "Invariant failed: updated zero sized " "vault must have no assets outstanding"; result = false; } - if (afterVault.assetsAvailable != zero) + if (afterVault.assetsAvailable != kZERO) { JLOG(j.fatal()) << "Invariant failed: updated zero sized " "vault must have no assets available"; @@ -369,7 +369,7 @@ ValidVault::finalize( result = false; } - if (afterVault.assetsAvailable < zero) + if (afterVault.assetsAvailable < kZERO) { JLOG(j.fatal()) << "Invariant failed: assets available must be positive"; result = false; @@ -389,13 +389,13 @@ ValidVault::finalize( result = false; } - if (afterVault.assetsTotal < zero) + if (afterVault.assetsTotal < kZERO) { JLOG(j.fatal()) << "Invariant failed: assets outstanding must be positive"; result = false; } - if (afterVault.assetsMaximum < zero) + if (afterVault.assetsMaximum < kZERO) { JLOG(j.fatal()) << "Invariant failed: assets maximum must be positive"; result = false; @@ -482,7 +482,7 @@ ValidVault::finalize( return ret; ret->delta += fee.drops(); - if (ret->delta == zero) + if (ret->delta == kZERO) return std::nullopt; return ret; @@ -519,8 +519,8 @@ ValidVault::finalize( result = false; } - if (afterVault.assetsAvailable != zero || afterVault.assetsTotal != zero || - afterVault.lossUnrealized != zero || updatedShares->sharesTotal != 0) + if (afterVault.assetsAvailable != kZERO || afterVault.assetsTotal != kZERO || + afterVault.lossUnrealized != kZERO || updatedShares->sharesTotal != 0) { JLOG(j.fatal()) // << "Invariant failed: created vault must be empty"; @@ -586,7 +586,7 @@ ValidVault::finalize( result = false; } - if (afterVault.assetsMaximum > zero && + if (afterVault.assetsMaximum > kZERO && afterVault.assetsTotal > afterVault.assetsMaximum) { JLOG(j.fatal()) << // @@ -652,7 +652,7 @@ ValidVault::finalize( result = false; } - if (vaultDeltaAssets <= zero) + if (vaultDeltaAssets <= kZERO) { JLOG(j.fatal()) << // "Invariant failed: deposit must increase vault balance"; @@ -685,7 +685,7 @@ ValidVault::finalize( auto const localVaultDeltaAssets = roundToAsset(vaultAsset, vaultDeltaAssets, localMinScale); - if (accountDeltaAssets >= zero) + if (accountDeltaAssets >= kZERO) { JLOG(j.fatal()) << // "Invariant failed: deposit must decrease depositor " @@ -702,7 +702,7 @@ ValidVault::finalize( } } - if (afterVault.assetsMaximum > zero && + if (afterVault.assetsMaximum > kZERO && afterVault.assetsTotal > afterVault.assetsMaximum) { JLOG(j.fatal()) << // @@ -721,7 +721,7 @@ ValidVault::finalize( } // We don't need to round shares, they are integral MPT auto const& accountDeltaShares = *maybeAccDeltaShares; - if (accountDeltaShares.delta <= zero) + if (accountDeltaShares.delta <= kZERO) { JLOG(j.fatal()) << // "Invariant failed: deposit must increase depositor " @@ -730,7 +730,7 @@ ValidVault::finalize( } auto const maybeVaultDeltaShares = deltaShares(afterVault.pseudoId); - if (!maybeVaultDeltaShares || maybeVaultDeltaShares->delta == zero) + if (!maybeVaultDeltaShares || maybeVaultDeltaShares->delta == kZERO) { JLOG(j.fatal()) << // "Invariant failed: deposit must change vault shares"; @@ -796,7 +796,7 @@ ValidVault::finalize( auto const vaultPseudoDeltaAssets = roundToAsset(vaultAsset, maybeVaultDeltaAssets->delta, minScale); - if (vaultPseudoDeltaAssets >= zero) + if (vaultPseudoDeltaAssets >= kZERO) { JLOG(j.fatal()) << "Invariant failed: withdrawal must " "decrease vault balance"; @@ -841,7 +841,7 @@ ValidVault::finalize( auto const roundedDestinationDelta = roundToAsset(vaultAsset, destinationDelta.delta, localMinScale); - if (roundedDestinationDelta <= zero) + if (roundedDestinationDelta <= kZERO) { JLOG(j.fatal()) << // "Invariant failed: withdrawal must increase " @@ -870,7 +870,7 @@ ValidVault::finalize( return false; } - if (accountDeltaShares->delta >= zero) + if (accountDeltaShares->delta >= kZERO) { JLOG(j.fatal()) << // "Invariant failed: withdrawal must decrease depositor " @@ -880,7 +880,7 @@ ValidVault::finalize( // We don't need to round shares, they are integral MPT auto const vaultDeltaShares = deltaShares(afterVault.pseudoId); - if (!vaultDeltaShares || vaultDeltaShares->delta == zero) + if (!vaultDeltaShares || vaultDeltaShares->delta == kZERO) { JLOG(j.fatal()) << // "Invariant failed: withdrawal must change vault shares"; @@ -950,7 +950,7 @@ ValidVault::finalize( computeCoarsestScale({*maybeVaultDeltaAssets, totalDelta, availableDelta}); auto const vaultDeltaAssets = roundToAsset(vaultAsset, maybeVaultDeltaAssets->delta, minScale); - if (vaultDeltaAssets >= zero) + if (vaultDeltaAssets >= kZERO) { JLOG(j.fatal()) << // "Invariant failed: clawback must decrease vault " @@ -995,7 +995,7 @@ ValidVault::finalize( "Invariant failed: clawback must change holder shares"; return false; // That's all we can do } - if (maybeAccountDeltaShares->delta >= zero) + if (maybeAccountDeltaShares->delta >= kZERO) { JLOG(j.fatal()) << // "Invariant failed: clawback must decrease holder " @@ -1005,7 +1005,7 @@ ValidVault::finalize( // We don't need to round shares, they are integral MPT auto const vaultDeltaShares = deltaShares(afterVault.pseudoId); - if (!vaultDeltaShares || vaultDeltaShares->delta == zero) + if (!vaultDeltaShares || vaultDeltaShares->delta == kZERO) { JLOG(j.fatal()) << // "Invariant failed: clawback must change vault shares"; @@ -1067,7 +1067,7 @@ ValidVault::computeCoarsestScale(std::vector const& numbers) numbers, [](auto const& a, auto const& b) -> bool { return a.scale < b.scale; }); XRPL_ASSERT_PARTS( max->scale, "xrpl::ValidVault::computeCoarsestScale", "scale set for destinationDelta"); - return max->scale.value_or(STAmount::cMaxOffset); + return max->scale.value_or(STAmount::kMAX_OFFSET); } } // namespace xrpl diff --git a/src/libxrpl/tx/paths/AMMLiquidity.cpp b/src/libxrpl/tx/paths/AMMLiquidity.cpp index 0a4cfadb69..87eb29f104 100644 --- a/src/libxrpl/tx/paths/AMMLiquidity.cpp +++ b/src/libxrpl/tx/paths/AMMLiquidity.cpp @@ -54,7 +54,7 @@ AMMLiquidity::fetchBalances(ReadView const& view) const auto const amountIn = ammAccountHolds(view, ammAccountID_, assetIn_); auto const amountOut = ammAccountHolds(view, ammAccountID_, assetOut_); // This should not happen. - if (amountIn < beast::zero || amountOut < beast::zero) + if (amountIn < beast::kZERO || amountOut < beast::kZERO) Throw("AMMLiquidity: invalid balances"); return TAmounts{get(amountIn), get(amountOut)}; @@ -68,17 +68,19 @@ AMMLiquidity::generateFibSeqOffer(TAmounts const& balances cur.in = toAmount( getAsset(balances.in), - InitialFibSeqPct * initialBalances_.in, - Number::rounding_mode::upward); + kINITIAL_FIB_SEQ_PCT * initialBalances_.in, + Number::RoundingMode::Upward); cur.out = swapAssetIn(initialBalances_, cur.in, tradingFee_); if (ammContext_.curIters() == 0) return cur; - constexpr std::uint32_t fib[AMMContext::MaxIterations] = { - 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, - 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, - 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269}; + // clang-format off + constexpr std::uint32_t kFIB[AMMContext::kMAX_ITERATIONS] = { + 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, + 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, + 196418, 317811, 514229, 832040, 1346269}; + // clang-format on XRPL_ASSERT( !ammContext_.maxItersReached(), @@ -86,8 +88,8 @@ AMMLiquidity::generateFibSeqOffer(TAmounts const& balances cur.out = toAmount( getAsset(balances.out), - cur.out * fib[ammContext_.curIters() - 1], - Number::rounding_mode::downward); + cur.out * kFIB[ammContext_.curIters() - 1], + Number::RoundingMode::Downward); // swapAssetOut() returns negative in this case if (cur.out >= balances.out) Throw("AMMLiquidity: generateFibSeqOffer exceeds the balance"); @@ -104,19 +106,19 @@ maxAmount() { if constexpr (std::is_same_v) { - return XRPAmount(STAmount::cMaxNative); + return XRPAmount(STAmount::kMAX_NATIVE); } else if constexpr (std::is_same_v) { - return IOUAmount(STAmount::cMaxValue / 2, STAmount::cMaxOffset); + return IOUAmount(STAmount::kMAX_VALUE / 2, STAmount::kMAX_OFFSET); } else if constexpr (std::is_same_v) { - return STAmount(STAmount::cMaxValue / 2, STAmount::cMaxOffset); + return STAmount(STAmount::kMAX_VALUE / 2, STAmount::kMAX_OFFSET); } else if constexpr (std::is_same_v) { - return MPTAmount(maxMPTokenAmount); + return MPTAmount(kMAX_MP_TOKEN_AMOUNT); } } @@ -125,7 +127,7 @@ T maxOut(T const& out, Asset const& asset) { Number const res = out * Number{99, -2}; - return toAmount(asset, res, Number::rounding_mode::downward); + return toAmount(asset, res, Number::RoundingMode::Downward); } } // namespace @@ -161,7 +163,7 @@ AMMLiquidity::getOffer(ReadView const& view, std::optional c auto const balances = fetchBalances(view); // Frozen accounts - if (balances.in == beast::zero || balances.out == beast::zero) + if (balances.in == beast::kZERO || balances.out == beast::kZERO) { JLOG(j_.debug()) << "AMMLiquidity::getOffer, frozen accounts"; return std::nullopt; @@ -237,7 +239,7 @@ AMMLiquidity::getOffer(ReadView const& view, std::optional c if (offer) { - if (offer->amount().in > beast::zero && offer->amount().out > beast::zero) + if (offer->amount().in > beast::kZERO && offer->amount().out > beast::kZERO) { JLOG(j_.trace()) << "AMMLiquidity::getOffer, created " << to_string(offer->amount().in) << "/" << assetIn_ << " " << to_string(offer->amount().out) << "/" diff --git a/src/libxrpl/tx/paths/AMMOffer.cpp b/src/libxrpl/tx/paths/AMMOffer.cpp index 0a41411492..3a7bd8f1df 100644 --- a/src/libxrpl/tx/paths/AMMOffer.cpp +++ b/src/libxrpl/tx/paths/AMMOffer.cpp @@ -94,7 +94,7 @@ AMMOffer::limitOut( { // It turns out that the ceil_out implementation has some slop in // it, which ceil_out_strict removes. - return quality().ceil_out_strict(offerAmount, limit, roundUp); + return quality().ceilOutStrict(offerAmount, limit, roundUp); } // Change the offer size according to the conservation function. The offer // quality is increased in this case, but it doesn't matter since there is @@ -112,9 +112,9 @@ AMMOffer::limitIn(TAmounts const& offerAmount, TIn const& { if (auto const& rules = getCurrentTransactionRules(); rules && rules->enabled(fixReducedOffersV2)) - return quality().ceil_in_strict(offerAmount, limit, roundUp); + return quality().ceilInStrict(offerAmount, limit, roundUp); - return quality().ceil_in(offerAmount, limit); + return quality().ceilIn(offerAmount, limit); } return {limit, swapAssetIn(balances_, limit, ammLiquidity_.tradingFee())}; } diff --git a/src/libxrpl/tx/paths/BookStep.cpp b/src/libxrpl/tx/paths/BookStep.cpp index 480a702dc9..113155e530 100644 --- a/src/libxrpl/tx/paths/BookStep.cpp +++ b/src/libxrpl/tx/paths/BookStep.cpp @@ -55,9 +55,9 @@ template class BookStep : public StepImp> { protected: - enum class OfferType { AMM, CLOB }; + enum class OfferType { Amm, Clob }; - static constexpr uint32_t MaxOffersToConsume{1000}; + static constexpr uint32_t kMAX_OFFERS_TO_CONSUME{1000}; Book book_; AccountID strandSrc_; AccountID strandDst_; @@ -86,7 +86,7 @@ protected: TIn in; TOut out; - Cache(TIn const& in_, TOut const& out_) : in(in_), out(out_) + Cache(TIn const& in, TOut const& out) : in(in), out(out) { } }; @@ -104,7 +104,7 @@ private: , strandDeliver_(ctx.strandDeliver) { if (auto const ammSle = ctx.view.read(keylet::amm(in, out)); - ammSle && ammSle->getFieldAmount(sfLPTokenBalance) != beast::zero) + ammSle && ammSle->getFieldAmount(sfLPTokenBalance) != beast::kZERO) { ammLiquidity_.emplace( ctx.view, @@ -143,7 +143,7 @@ public: [[nodiscard]] DebtDirection debtDirection(ReadView const& sb, StrandDirection dir) const override { - return ownerPaysTransferFee_ ? DebtDirection::issues : DebtDirection::redeems; + return ownerPaysTransferFee_ ? DebtDirection::Issues : DebtDirection::Redeems; } [[nodiscard]] std::optional @@ -350,15 +350,15 @@ public: // Calculate amount that goes to the taker and the amount charged the // offer owner auto const trIn = - redeems(prevStepDir) ? this->rate(v, this->book_.in, this->strandDst_) : parityRate; + redeems(prevStepDir) ? this->rate(v, this->book_.in, this->strandDst_) : kPARITY_RATE; // Always charge the transfer fee, even if the owner is the issuer, // unless the fee is waived auto const trOut = (this->ownerPaysTransferFee_ && waiveFee == WaiveTransferFee::No) ? this->rate(v, this->book_.out, this->strandDst_) - : parityRate; + : kPARITY_RATE; Quality const q1{getRate(STAmount(trOut.value), STAmount(trIn.value))}; - return composed_quality(q1, ofrQ); + return composedQuality(q1, ofrQ); } [[nodiscard]] std::string @@ -530,19 +530,19 @@ public: { return ofrQ; } - if (offerType == OfferType::CLOB || + if (offerType == OfferType::Clob || (this->ammLiquidity_ && this->ammLiquidity_->multiPath())) { return ofrQ; } auto const trIn = - redeems(prevStepDir) ? this->rate(v, this->book_.in, this->strandDst_) : parityRate; + redeems(prevStepDir) ? this->rate(v, this->book_.in, this->strandDst_) : kPARITY_RATE; // AMM doesn't pay the transfer fee on the out amount - auto const trOut = parityRate; + auto const trOut = kPARITY_RATE; Quality const q1{getRate(STAmount(trOut.value), STAmount(trIn.value))}; - return composed_quality(q1, ofrQ); + return composedQuality(q1, ofrQ); } [[nodiscard]] std::string @@ -571,13 +571,13 @@ template std::pair, DebtDirection> BookStep::qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const { - auto const dir = this->debtDirection(v, StrandDirection::forward); + auto const dir = this->debtDirection(v, StrandDirection::Forward); std::optional> const res = tipOfferQuality(v); if (!res) return {std::nullopt, dir}; - auto const waiveFee = (std::get(*res) == OfferType::AMM) ? WaiveTransferFee::Yes + auto const waiveFee = (std::get(*res) == OfferType::Amm) ? WaiveTransferFee::Yes : WaiveTransferFee::No; Quality const q = static_cast(this)->adjustQualityWithFees( @@ -589,7 +589,7 @@ template std::pair, DebtDirection> BookStep::getQualityFunc(ReadView const& v, DebtDirection prevStepDir) const { - auto const dir = this->debtDirection(v, StrandDirection::forward); + auto const dir = this->debtDirection(v, StrandDirection::Forward); std::optional const res = tipOfferQualityF(v); if (!res) @@ -598,10 +598,10 @@ BookStep::getQualityFunc(ReadView const& v, DebtDirection p // AMM if (!res->isConst()) { - auto static const qOne = Quality{STAmount::uRateOne}; + auto static const kQ_ONE = Quality{STAmount::kU_RATE_ONE}; auto const q = static_cast(this)->adjustQualityWithFees( - v, qOne, prevStepDir, WaiveTransferFee::Yes, OfferType::AMM, v.rules()); - if (q == qOne) + v, kQ_ONE, prevStepDir, WaiveTransferFee::Yes, OfferType::Amm, v.rules()); + if (q == kQ_ONE) return {res, dir}; QualityFunction qf{q, QualityFunction::CLOBLikeTag{}}; qf.combine(*res); @@ -615,7 +615,7 @@ BookStep::getQualityFunc(ReadView const& v, DebtDirection p // always has quality set prevStepDir, WaiveTransferFee::No, - OfferType::CLOB, + OfferType::Clob, v.rules()); return {QualityFunction{q, QualityFunction::CLOBLikeTag{}}, dir}; } @@ -700,7 +700,7 @@ BookStep::forEachOffer( std::uint32_t const trOut = ownerPaysTransferFee_ ? rate(sb, book_.out, this->strandDst_).value : QUALITY_ONE; - typename FlowOfferStream::StepCounter counter(MaxOffersToConsume, j_); + typename FlowOfferStream::StepCounter counter(kMAX_OFFERS_TO_CONSUME, j_); FlowOfferStream offers(sb, afView, book_, sb.parentCloseTime(), counter, j_); @@ -802,8 +802,8 @@ BookStep::forEachOffer( sb, issuer, assetIn, // STAmount{0}, but the default is not used - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_)); if (stpAmt.in > available) { @@ -915,7 +915,7 @@ std::optional>> BookStep::tip(ReadView const& view) const { // This can be simplified (and sped up) if directories are never empty. - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); BookTip bt(sb, book_); auto const lobQuality = bt.step(j_) ? std::optional(bt.quality()) : std::nullopt; // Multi-path offer generates an offer with the quality @@ -960,10 +960,10 @@ BookStep::tipOfferQuality(ReadView const& view) const } if (auto const q = std::get_if(&(*res))) { - return std::make_pair(*q, OfferType::CLOB); + return std::make_pair(*q, OfferType::Clob); } - return std::make_pair(std::get>(*res).quality(), OfferType::AMM); + return std::make_pair(std::get>(*res).quality(), OfferType::Amm); } template @@ -989,7 +989,7 @@ sum(TCollection const& col) { using TResult = std::decay_t; if (col.empty()) - return TResult{beast::zero}; + return TResult{beast::kZERO}; return std::accumulate(col.begin() + 1, col.end(), *col.begin()); }; @@ -1003,7 +1003,7 @@ BookStep::revImp( { cache_.reset(); - TAmounts result(beast::zero, beast::zero); + TAmounts result(beast::kZERO, beast::kZERO); auto remainingOut = out; @@ -1022,7 +1022,7 @@ BookStep::revImp( TOut const& ownerGives, std::uint32_t transferRateIn, std::uint32_t transferRateOut) mutable -> bool { - if (remainingOut <= beast::zero) + if (remainingOut <= beast::kZERO) return false; if (stpAmt.out <= remainingOut) @@ -1048,7 +1048,7 @@ BookStep::revImp( transferRateIn, transferRateOut, remainingOut); - remainingOut = beast::zero; + remainingOut = beast::kZERO; savedIns.insert(stpAdjAmt.in); savedOuts.insert(remainingOut); result.in = sum(savedIns); @@ -1060,23 +1060,23 @@ BookStep::revImp( // will still be funded after consuming remainingOut but that is // not always the case. If the mantissas of two IOU amounts differ // by less than ten, then subtracting them leaves a zero. - return offer.fully_consumed(); + return offer.fullyConsumed(); }; { auto const prevStepDebtDir = [&] { if (prevStep_) - return prevStep_->debtDirection(sb, StrandDirection::reverse); - return DebtDirection::issues; + return prevStep_->debtDirection(sb, StrandDirection::Reverse); + return DebtDirection::Issues; }(); auto const r = forEachOffer(sb, afView, prevStepDebtDir, eachOffer); boost::container::flat_set const toRm = std::move(std::get<0>(r)); std::uint32_t const offersConsumed = std::get<1>(r); offersUsed_ = offersConsumed; - SetUnion(ofrsToRm, toRm); + setUnion(ofrsToRm, toRm); // Too many iterations, mark this strand as inactive - if (offersConsumed >= MaxOffersToConsume) + if (offersConsumed >= kMAX_OFFERS_TO_CONSUME) { inactive_ = true; } @@ -1089,8 +1089,8 @@ BookStep::revImp( // LCOV_EXCL_START JLOG(j_.error()) << "BookStep remainingOut < 0 " << to_string(remainingOut); UNREACHABLE("xrpl::BookStep::revImp : remaining less than zero"); - cache_.emplace(beast::zero, beast::zero); - return {beast::zero, beast::zero}; + cache_.emplace(beast::kZERO, beast::kZERO); + return {beast::kZERO, beast::kZERO}; // LCOV_EXCL_STOP } case 0: { @@ -1114,7 +1114,7 @@ BookStep::fwdImp( { XRPL_ASSERT(cache_, "xrpl::BookStep::fwdImp : cache is set"); - TAmounts result(beast::zero, beast::zero); + TAmounts result(beast::kZERO, beast::kZERO); auto remainingIn = in; @@ -1133,7 +1133,7 @@ BookStep::fwdImp( std::uint32_t transferRateOut) mutable -> bool { XRPL_ASSERT(cache_, "xrpl::BookStep::fwdImp::eachOffer : cache is set"); - if (remainingIn <= beast::zero) + if (remainingIn <= beast::kZERO) return false; bool processMore = true; @@ -1222,23 +1222,23 @@ BookStep::fwdImp( // subtracting them leaves a result of zero. This can cause the check // for (stpAmt.in > remainingIn) to incorrectly think an offer will be // funded after subtracting remainingIn. - return processMore || offer.fully_consumed(); + return processMore || offer.fullyConsumed(); }; { auto const prevStepDebtDir = [&] { if (prevStep_) - return prevStep_->debtDirection(sb, StrandDirection::forward); - return DebtDirection::issues; + return prevStep_->debtDirection(sb, StrandDirection::Forward); + return DebtDirection::Issues; }(); auto const r = forEachOffer(sb, afView, prevStepDebtDir, eachOffer); boost::container::flat_set const toRm = std::move(std::get<0>(r)); std::uint32_t const offersConsumed = std::get<1>(r); offersUsed_ = offersConsumed; - SetUnion(ofrsToRm, toRm); + setUnion(ofrsToRm, toRm); // Too many iterations, mark this strand as inactive (dry) - if (offersConsumed >= MaxOffersToConsume) + if (offersConsumed >= kMAX_OFFERS_TO_CONSUME) { inactive_ = true; } @@ -1251,8 +1251,8 @@ BookStep::fwdImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingIn < 0 " << to_string(remainingIn); UNREACHABLE("xrpl::BookStep::fwdImp : remaining less than zero"); - cache_.emplace(beast::zero, beast::zero); - return {beast::zero, beast::zero}; + cache_.emplace(beast::kZERO, beast::kZERO); + return {beast::kZERO, beast::kZERO}; // LCOV_EXCL_STOP } case 0: { @@ -1276,7 +1276,7 @@ BookStep::validFwd( if (!cache_) { JLOG(j_.trace()) << "Expected valid cache in validFwd"; - return {false, EitherAmount(TOut(beast::zero))}; + return {false, EitherAmount(TOut(beast::kZERO))}; } auto const savCache = *cache_; @@ -1288,7 +1288,7 @@ BookStep::validFwd( } catch (FlowException const&) { - return {false, EitherAmount(TOut(beast::zero))}; + return {false, EitherAmount(TOut(beast::kZERO))}; } // NOLINTBEGIN(bugprone-unchecked-optional-access) fwdImp sets cache_ on success @@ -1387,7 +1387,7 @@ BookStep::rate( { auto const& issuer = asset.getIssuer(); if (isXRP(issuer) || issuer == dstAccount) - return parityRate; + return kPARITY_RATE; return asset.visit( [&](Issue const&) { return transferRate(view, issuer); }, [&](MPTIssue const& issue) { return transferRate(view, issue.getMptID()); }); @@ -1488,11 +1488,11 @@ bookStepEqual(Step const& step, xrpl::Book const& book) template static std::pair> -make_BookStepHelper(StrandContext const& ctx, Asset const& in, Asset const& out) +makeBookStepHelper(StrandContext const& ctx, Asset const& in, Asset const& out) { TER ter = tefINTERNAL; std::unique_ptr r; - if (ctx.offerCrossing != OfferCrossing::no) + if (ctx.offerCrossing != OfferCrossing::No) { auto offerCrossingStep = std::make_unique>(ctx, in, out); ter = offerCrossingStep->check(ctx); @@ -1511,52 +1511,52 @@ make_BookStepHelper(StrandContext const& ctx, Asset const& in, Asset const& out) } std::pair> -make_BookStepII(StrandContext const& ctx, Issue const& in, Issue const& out) +makeBookStepIi(StrandContext const& ctx, Issue const& in, Issue const& out) { - return make_BookStepHelper(ctx, in, out); + return makeBookStepHelper(ctx, in, out); } std::pair> -make_BookStepIX(StrandContext const& ctx, Issue const& in) +makeBookStepIx(StrandContext const& ctx, Issue const& in) { - return make_BookStepHelper(ctx, in, xrpIssue()); + return makeBookStepHelper(ctx, in, xrpIssue()); } std::pair> -make_BookStepXI(StrandContext const& ctx, Issue const& out) +makeBookStepXi(StrandContext const& ctx, Issue const& out) { - return make_BookStepHelper(ctx, xrpIssue(), out); + return makeBookStepHelper(ctx, xrpIssue(), out); } // MPT's std::pair> -make_BookStepMM(StrandContext const& ctx, MPTIssue const& in, MPTIssue const& out) +makeBookStepMm(StrandContext const& ctx, MPTIssue const& in, MPTIssue const& out) { - return make_BookStepHelper(ctx, in, out); + return makeBookStepHelper(ctx, in, out); } std::pair> -make_BookStepMI(StrandContext const& ctx, MPTIssue const& in, Issue const& out) +makeBookStepMi(StrandContext const& ctx, MPTIssue const& in, Issue const& out) { - return make_BookStepHelper(ctx, in, out); + return makeBookStepHelper(ctx, in, out); } std::pair> -make_BookStepIM(StrandContext const& ctx, Issue const& in, MPTIssue const& out) +makeBookStepIm(StrandContext const& ctx, Issue const& in, MPTIssue const& out) { - return make_BookStepHelper(ctx, in, out); + return makeBookStepHelper(ctx, in, out); } std::pair> -make_BookStepMX(StrandContext const& ctx, MPTIssue const& in) +makeBookStepMx(StrandContext const& ctx, MPTIssue const& in) { - return make_BookStepHelper(ctx, in, xrpIssue()); + return makeBookStepHelper(ctx, in, xrpIssue()); } std::pair> -make_BookStepXM(StrandContext const& ctx, MPTIssue const& out) +makeBookStepXm(StrandContext const& ctx, MPTIssue const& out) { - return make_BookStepHelper(ctx, xrpIssue(), out); + return makeBookStepHelper(ctx, xrpIssue(), out); } } // namespace xrpl diff --git a/src/libxrpl/tx/paths/BookTip.cpp b/src/libxrpl/tx/paths/BookTip.cpp index 7c6dd85ee3..5be512aa84 100644 --- a/src/libxrpl/tx/paths/BookTip.cpp +++ b/src/libxrpl/tx/paths/BookTip.cpp @@ -13,19 +13,19 @@ namespace xrpl { BookTip::BookTip(ApplyView& view, Book const& book) - : view_(view), m_book(getBookBase(book)), m_end(getQualityNext(m_book)) + : view_(view), book_(getBookBase(book)), end_(getQualityNext(book_)) { } bool BookTip::step(beast::Journal j) { - if (m_valid) + if (valid_) { - if (m_entry) + if (entry_) { - offerDelete(view_, m_entry, j); - m_entry = nullptr; + offerDelete(view_, entry_, j); + entry_ = nullptr; } } @@ -34,33 +34,33 @@ BookTip::step(beast::Journal j) // See if there's an entry at or worse than current quality. Notice // that the quality is encoded only in the index of the first page // of a directory. - auto const first_page = view_.succ(m_book, m_end); + auto const firstPage = view_.succ(book_, end_); - if (!first_page) + if (!firstPage) return false; unsigned int di = 0; std::shared_ptr dir; - if (dirFirst(view_, *first_page, dir, di, m_index)) + if (dirFirst(view_, *firstPage, dir, di, index_)) { - m_dir = dir->key(); - m_entry = view_.peek(keylet::offer(m_index)); - m_quality = Quality(getQuality(*first_page)); - m_valid = true; + dir_ = dir->key(); + entry_ = view_.peek(keylet::offer(index_)); + quality_ = Quality(getQuality(*firstPage)); + valid_ = true; // Next query should start before this directory - m_book = *first_page; + book_ = *firstPage; // The quality immediately before the next quality - --m_book; + --book_; break; } // There should never be an empty directory but just in case, // we handle that case by advancing to the next directory. - m_book = *first_page; + book_ = *firstPage; } return true; diff --git a/src/libxrpl/tx/paths/DirectStep.cpp b/src/libxrpl/tx/paths/DirectStep.cpp index c2ad818b73..7373f8a341 100644 --- a/src/libxrpl/tx/paths/DirectStep.cpp +++ b/src/libxrpl/tx/paths/DirectStep.cpp @@ -55,11 +55,11 @@ protected: DebtDirection srcDebtDir; Cache( - IOUAmount const& in_, - IOUAmount const& srcToDst_, - IOUAmount const& out_, - DebtDirection srcDebtDir_) - : in(in_), srcToDst(srcToDst_), out(out_), srcDebtDir(srcDebtDir_) + IOUAmount const& in, + IOUAmount const& srcToDst, + IOUAmount const& out, + DebtDirection srcDebtDir) + : in(in), srcToDst(srcToDst), out(out), srcDebtDir(srcDebtDir) { } }; @@ -350,7 +350,7 @@ DirectIPaymentStep::quality(ReadView const& sb, QualityDirection qDir) const return QUALITY_ONE; auto const& field = [&, this]() -> SF_UINT32 const& { - if (qDir == QualityDirection::in) + if (qDir == QualityDirection::In) { // compute dst quality in if (this->dst_ < this->src_) @@ -409,7 +409,7 @@ DirectIOfferCrossingStep::maxFlow(ReadView const& sb, IOUAmount const& desired) // "dstQIn" is always QUALITY_ONE for offer crossing. if (isLast_) - return {desired, DebtDirection::issues}; + return {desired, DebtDirection::Issues}; return maxPaymentFlow(sb); } @@ -430,7 +430,7 @@ DirectIPaymentStep::check(StrandContext const& ctx, std::shared_ptr c auto const authField = (src_ > dst_) ? lsfHighAuth : lsfLowAuth; if ((((*sleSrc)[sfFlags] & lsfRequireAuth) != 0u) && - (((*sleLine)[sfFlags] & authField) == 0u) && (*sleLine)[sfBalance] == beast::zero) + (((*sleLine)[sfFlags] & authField) == 0u) && (*sleLine)[sfBalance] == beast::kZERO) { JLOG(j_.debug()) << "DirectStepI: can't receive IOUs from issuer without auth." << " src: " << src_; @@ -451,7 +451,7 @@ DirectIPaymentStep::check(StrandContext const& ctx, std::shared_ptr c { auto const owed = creditBalance(ctx.view, dst_, src_, currency_); - if (owed <= beast::zero) + if (owed <= beast::kZERO) { auto const limit = creditLimit(ctx.view, dst_, src_, currency_); if (-owed >= limit) @@ -480,25 +480,24 @@ std::pair DirectStepI::maxPaymentFlow(ReadView const& sb) const { auto const srcOwed = toAmount( - accountHolds(sb, src_, currency_, dst_, FreezeHandling::fhIGNORE_FREEZE, j_)); + accountHolds(sb, src_, currency_, dst_, FreezeHandling::IgnoreFreeze, j_)); if (srcOwed.signum() > 0) - return {srcOwed, DebtDirection::redeems}; + return {srcOwed, DebtDirection::Redeems}; // srcOwed is negative or zero - return {creditLimit2(sb, dst_, src_, currency_) + srcOwed, DebtDirection::issues}; + return {creditLimit2(sb, dst_, src_, currency_) + srcOwed, DebtDirection::Issues}; } template DebtDirection DirectStepI::debtDirection(ReadView const& sb, StrandDirection dir) const { - if (dir == StrandDirection::forward && cache_) + if (dir == StrandDirection::Forward && cache_) return cache_->srcDebtDir; - auto const srcOwed = - accountHolds(sb, src_, currency_, dst_, FreezeHandling::fhIGNORE_FREEZE, j_); - return srcOwed.signum() > 0 ? DebtDirection::redeems : DebtDirection::issues; + auto const srcOwed = accountHolds(sb, src_, currency_, dst_, FreezeHandling::IgnoreFreeze, j_); + return srcOwed.signum() > 0 ? DebtDirection::Redeems : DebtDirection::Issues; } template @@ -513,7 +512,7 @@ DirectStepI::revImp( auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, out); - auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); + auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::Reverse); XRPL_ASSERT( static_cast(this)->verifyDstQualityIn(dstQIn), "xrpl::DirectStepI : valid destination quality"); @@ -529,8 +528,8 @@ DirectStepI::revImp( { JLOG(j_.trace()) << "DirectStepI::rev: dry"; cache_.emplace( - IOUAmount(beast::zero), IOUAmount(beast::zero), IOUAmount(beast::zero), srcDebtDir); - return {beast::zero, beast::zero}; + IOUAmount(beast::kZERO), IOUAmount(beast::kZERO), IOUAmount(beast::kZERO), srcDebtDir); + return {beast::kZERO, beast::kZERO}; } IOUAmount const srcToDst = mulRatio(out, QUALITY_ONE, dstQIn, /*roundUp*/ true); @@ -629,7 +628,7 @@ DirectStepI::fwdImp( auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); - auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::forward); + auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::Forward); Issue const srcToDstIss(currency_, redeems(srcDebtDir) ? dst_ : src_); @@ -642,8 +641,8 @@ DirectStepI::fwdImp( { JLOG(j_.trace()) << "DirectStepI::fwd: dry"; cache_.emplace( - IOUAmount(beast::zero), IOUAmount(beast::zero), IOUAmount(beast::zero), srcDebtDir); - return {beast::zero, beast::zero}; + IOUAmount(beast::kZERO), IOUAmount(beast::kZERO), IOUAmount(beast::kZERO), srcDebtDir); + return {beast::kZERO, beast::kZERO}; } IOUAmount const srcToDst = mulRatio(in, QUALITY_ONE, srcQOut, /*roundUp*/ false); @@ -691,7 +690,7 @@ DirectStepI::validFwd(PaymentSandbox& sb, ApplyView& afView, EitherAmo if (!cache_) { JLOG(j_.trace()) << "Expected valid cache in validFwd"; - return {false, EitherAmount(IOUAmount(beast::zero))}; + return {false, EitherAmount(IOUAmount(beast::kZERO))}; } auto const savCache = *cache_; @@ -709,7 +708,7 @@ DirectStepI::validFwd(PaymentSandbox& sb, ApplyView& afView, EitherAmo } catch (FlowException const&) { - return {false, EitherAmount(IOUAmount(beast::zero))}; + return {false, EitherAmount(IOUAmount(beast::kZERO))}; } // NOLINTBEGIN(bugprone-unchecked-optional-access) fwdImp sets cache_ on success @@ -744,7 +743,7 @@ DirectStepI::qualitiesSrcRedeems(ReadView const& sb) const return {QUALITY_ONE, QUALITY_ONE}; auto const prevStepQIn = prevStep_->lineQualityIn(sb); - auto srcQOut = static_cast(this)->quality(sb, QualityDirection::out); + auto srcQOut = static_cast(this)->quality(sb, QualityDirection::Out); if (prevStepQIn > srcQOut) srcQOut = prevStepQIn; @@ -766,7 +765,7 @@ DirectStepI::qualitiesSrcIssues(ReadView const& sb, DebtDirection prev std::uint32_t const srcQOut = redeems(prevStepDebtDirection) ? transferRate(sb, src_).value : QUALITY_ONE; - auto dstQIn = static_cast(this)->quality(sb, QualityDirection::in); + auto dstQIn = static_cast(this)->quality(sb, QualityDirection::In); if (isLast_ && dstQIn > QUALITY_ONE) dstQIn = QUALITY_ONE; @@ -789,7 +788,7 @@ DirectStepI::qualities( auto const prevStepDebtDirection = [&] { if (prevStep_) return prevStep_->debtDirection(sb, strandDir); - return DebtDirection::issues; + return DebtDirection::Issues; }(); return qualitiesSrcIssues(sb, prevStepDebtDirection); } @@ -799,14 +798,14 @@ std::uint32_t DirectStepI::lineQualityIn(ReadView const& v) const { // dst quality in - return static_cast(this)->quality(v, QualityDirection::in); + return static_cast(this)->quality(v, QualityDirection::In); } template std::pair, DebtDirection> DirectStepI::qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const { - auto const dir = this->debtDirection(v, StrandDirection::forward); + auto const dir = this->debtDirection(v, StrandDirection::Forward); auto const [srcQOut, dstQIn] = redeems(dir) ? qualitiesSrcRedeems(v) : qualitiesSrcIssues(v, prevStepDir); @@ -923,7 +922,7 @@ directStepEqual( //------------------------------------------------------------------------------ std::pair> -make_DirectStepI( +makeDirectStepI( StrandContext const& ctx, AccountID const& src, AccountID const& dst, @@ -931,7 +930,7 @@ make_DirectStepI( { TER ter = tefINTERNAL; std::unique_ptr r; - if (ctx.offerCrossing != OfferCrossing::no) + if (ctx.offerCrossing != OfferCrossing::No) { auto offerCrossingStep = std::make_unique(ctx, src, dst, c); ter = offerCrossingStep->check(ctx); diff --git a/src/libxrpl/tx/paths/Flow.cpp b/src/libxrpl/tx/paths/Flow.cpp index 32ca39ec22..39a9e83e69 100644 --- a/src/libxrpl/tx/paths/Flow.cpp +++ b/src/libxrpl/tx/paths/Flow.cpp @@ -125,7 +125,7 @@ flow( // represented by different types, use templates to tell `flow` about the // amount types. return std::visit( - [&, &strands_ = strands](TIn const&, TOut const&) { + [&, &strands = strands](TIn const&, TOut const&) { using TIn_ = typename TIn::amount_type; using TOut_ = typename TOut::amount_type; return finishFlow( @@ -134,7 +134,7 @@ flow( dstAsset, flow( sb, - strands_, + strands, get(deliver), partialPayment, offerCrossing, diff --git a/src/libxrpl/tx/paths/MPTEndpointStep.cpp b/src/libxrpl/tx/paths/MPTEndpointStep.cpp index 3dbc4e30cf..25c9062e47 100644 --- a/src/libxrpl/tx/paths/MPTEndpointStep.cpp +++ b/src/libxrpl/tx/paths/MPTEndpointStep.cpp @@ -56,11 +56,11 @@ protected: DebtDirection srcDebtDir; Cache( - MPTAmount const& in_, - MPTAmount const& srcToDst_, - MPTAmount const& out_, - DebtDirection srcDebtDir_) - : in(in_), srcToDst(srcToDst_), out(out_), srcDebtDir(srcDebtDir_) + MPTAmount const& in, + MPTAmount const& srcToDst, + MPTAmount const& out, + DebtDirection srcDebtDir) + : in(in), srcToDst(srcToDst), out(out), srcDebtDir(srcDebtDir) { } }; @@ -383,14 +383,9 @@ MPTEndpointPaymentStep::check(StrandContext const& ctx, std::shared_ptr MPTEndpointStep::maxPaymentFlow(ReadView const& sb) const { auto const maxFlow = accountFunds( - sb, src_, mptIssue_, FreezeHandling::fhIGNORE_FREEZE, AuthHandling::ahIGNORE_AUTH, j_); + sb, src_, mptIssue_, FreezeHandling::IgnoreFreeze, AuthHandling::IgnoreAuth, j_); // From a holder to an issuer if (src_ != mptIssue_.getIssuer()) - return {toAmount(maxFlow), DebtDirection::redeems}; + return {toAmount(maxFlow), DebtDirection::Redeems}; // From an issuer to a holder if (auto const sle = sb.read(keylet::mptIssuance(mptIssue_))) @@ -442,7 +437,7 @@ MPTEndpointStep::maxPaymentFlow(ReadView const& sb) const // If issuer is the source account, and it is direct payment then // MPTEndpointStep is the only step. Provide available maxFlow. if (prevStep_ == nullptr) - return {toAmount(maxFlow), DebtDirection::issues}; + return {toAmount(maxFlow), DebtDirection::Issues}; // MPTEndpointStep is the last step. It's always issuing in // this case. Can't infer at this point what the maxFlow is, because @@ -450,20 +445,20 @@ MPTEndpointStep::maxPaymentFlow(ReadView const& sb) const // to temporarily overflow. Let the previous step figure out how // to limit the flow. std::int64_t const maxAmount = maxMPTAmount(*sle); - return {MPTAmount{maxAmount}, DebtDirection::issues}; + return {MPTAmount{maxAmount}, DebtDirection::Issues}; } - return {MPTAmount{0}, DebtDirection::issues}; + return {MPTAmount{0}, DebtDirection::Issues}; } template DebtDirection MPTEndpointStep::debtDirection(ReadView const& sb, StrandDirection dir) const { - if (dir == StrandDirection::forward && cache_) + if (dir == StrandDirection::Forward && cache_) return cache_->srcDebtDir; - return (src_ == mptIssue_.getIssuer()) ? DebtDirection::issues : DebtDirection::redeems; + return (src_ == mptIssue_.getIssuer()) ? DebtDirection::Issues : DebtDirection::Redeems; } template @@ -478,7 +473,7 @@ MPTEndpointStep::revImp( auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxPaymentFlow(sb); - auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); + auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::Reverse); (void)dstQIn; MPTIssue const srcToDstIss(mptIssue_); @@ -492,12 +487,12 @@ MPTEndpointStep::revImp( { JLOG(j_.trace()) << "MPTEndpointStep::rev: dry"; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } if (auto const err = static_cast(this)->checkCreateMPT(sb, srcDebtDir); !isTesSuccess(err)) - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; // Don't have to factor in dstQIn since it is always QUALITY_ONE MPTAmount const srcToDst = out; @@ -517,7 +512,7 @@ MPTEndpointStep::revImp( { JLOG(j_.trace()) << "MPTEndpointStep::rev: error " << ter; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } JLOG(j_.trace()) << "MPTEndpointStep::rev: Non-limiting" << " srcRedeems: " << redeems(srcDebtDir) << " in: " << to_string(in) @@ -542,7 +537,7 @@ MPTEndpointStep::revImp( { JLOG(j_.trace()) << "MPTEndpointStep::rev: error " << ter; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } JLOG(j_.trace()) << "MPTEndpointStep::rev: Limiting" << " srcRedeems: " << redeems(srcDebtDir) << " in: " << to_string(in) @@ -609,7 +604,7 @@ MPTEndpointStep::fwdImp( auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxPaymentFlow(sb); - auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::forward); + auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::Forward); (void)dstQIn; MPTIssue const srcToDstIss(mptIssue_); @@ -623,12 +618,12 @@ MPTEndpointStep::fwdImp( { JLOG(j_.trace()) << "MPTEndpointStep::fwd: dry"; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } if (auto const err = static_cast(this)->checkCreateMPT(sb, srcDebtDir); !isTesSuccess(err)) - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; MPTAmount const srcToDst = mulRatio(in, QUALITY_ONE, srcQOut, /*roundUp*/ false); @@ -648,7 +643,7 @@ MPTEndpointStep::fwdImp( { JLOG(j_.trace()) << "MPTEndpointStep::fwd: error " << ter; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } JLOG(j_.trace()) << "MPTEndpointStep::fwd: Non-limiting" << " srcRedeems: " << redeems(srcDebtDir) << " in: " << to_string(in) @@ -672,7 +667,7 @@ MPTEndpointStep::fwdImp( { JLOG(j_.trace()) << "MPTEndpointStep::fwd: error " << ter; resetCache(srcDebtDir); - return {beast::zero, beast::zero}; + return {beast::kZERO, beast::kZERO}; } JLOG(j_.trace()) << "MPTEndpointStep::fwd: Limiting" << " srcRedeems: " << redeems(srcDebtDir) << " in: " << to_string(actualIn) @@ -689,7 +684,7 @@ MPTEndpointStep::validFwd(PaymentSandbox& sb, ApplyView& afView, Eithe if (!cache_) { JLOG(j_.trace()) << "Expected valid cache in validFwd"; - return {false, EitherAmount(MPTAmount(beast::zero))}; + return {false, EitherAmount(MPTAmount(beast::kZERO))}; } auto const savCache = *cache_; @@ -706,7 +701,7 @@ MPTEndpointStep::validFwd(PaymentSandbox& sb, ApplyView& afView, Eithe } catch (FlowException const&) { - return {false, EitherAmount(MPTAmount(beast::zero))}; + return {false, EitherAmount(MPTAmount(beast::kZERO))}; } // NOLINTBEGIN(bugprone-unchecked-optional-access) fwdImp sets cache_ on success @@ -785,7 +780,7 @@ MPTEndpointStep::qualities( auto const prevStepDebtDirection = [&] { if (prevStep_ != nullptr) return prevStep_->debtDirection(sb, strandDir); - return DebtDirection::issues; + return DebtDirection::Issues; }(); return qualitiesSrcIssues(sb, prevStepDebtDirection); } @@ -802,7 +797,7 @@ template std::pair, DebtDirection> MPTEndpointStep::qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const { - auto const dir = this->debtDirection(v, StrandDirection::forward); + auto const dir = this->debtDirection(v, StrandDirection::Forward); auto const [srcQOut, dstQIn] = redeems(dir) ? qualitiesSrcRedeems(v) : qualitiesSrcIssues(v, prevStepDir); @@ -898,13 +893,13 @@ template void MPTEndpointStep::resetCache(xrpl::DebtDirection dir) { - cache_.emplace(MPTAmount(beast::zero), MPTAmount(beast::zero), MPTAmount(beast::zero), dir); + cache_.emplace(MPTAmount(beast::kZERO), MPTAmount(beast::kZERO), MPTAmount(beast::kZERO), dir); } //------------------------------------------------------------------------------ std::pair> -make_MPTEndpointStep( +makeMptEndpointStep( StrandContext const& ctx, AccountID const& src, AccountID const& dst, @@ -912,7 +907,7 @@ make_MPTEndpointStep( { TER ter = tefINTERNAL; std::unique_ptr r; - if (ctx.offerCrossing != OfferCrossing::no) + if (ctx.offerCrossing != OfferCrossing::No) { auto offerCrossingStep = std::make_unique(ctx, src, dst, mpt); ter = offerCrossingStep->check(ctx); diff --git a/src/libxrpl/tx/paths/OfferStream.cpp b/src/libxrpl/tx/paths/OfferStream.cpp index 67f9a294b7..b5ac45503a 100644 --- a/src/libxrpl/tx/paths/OfferStream.cpp +++ b/src/libxrpl/tx/paths/OfferStream.cpp @@ -138,10 +138,10 @@ TOfferStreamBase::shouldRmSmallIncreasedQOffer() const // Consider removing the offer if: // o `TakerPays` is XRP (because of XRP drops granularity) or // o `TakerPays` and `TakerGets` are both IOU and `TakerPays`<`TakerGets` - constexpr bool const inIsXRP = std::is_same_v; - constexpr bool const outIsXRP = std::is_same_v; + constexpr bool const kIN_IS_XRP = std::is_same_v; + constexpr bool const kOUT_IS_XRP = std::is_same_v; - if constexpr (outIsXRP) + if constexpr (kOUT_IS_XRP) { // If `TakerGets` is XRP, the worst this offer's quality can change is // to about 10^-81 `TakerPays` and 1 drop `TakerGets`. This will be @@ -156,7 +156,7 @@ TOfferStreamBase::shouldRmSmallIncreasedQOffer() const TAmounts const ofrAmts{ toAmount(offer_.amount().in), toAmount(offer_.amount().out)}; - if constexpr (!inIsXRP && !outIsXRP) + if constexpr (!kIN_IS_XRP && !kOUT_IS_XRP) { if (Number(ofrAmts.in) >= Number(ofrAmts.out)) return false; @@ -171,7 +171,7 @@ TOfferStreamBase::shouldRmSmallIncreasedQOffer() const // // It turns out we can prevent order book blocking by rounding down // the ceil_out() result. - return offer_.quality().ceil_out_strict(ofrAmts, ownerFunds, /* roundUp */ false); + return offer_.quality().ceilOutStrict(ofrAmts, ownerFunds, /* roundUp */ false); } return ofrAmts; }(); @@ -266,26 +266,26 @@ TOfferStreamBase::step() offer_.owner(), amount.out, offer_.assetOut(), - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, j_); // Check for unfunded offer - if (*ownerFunds_ <= beast::zero) + if (*ownerFunds_ <= beast::kZERO) { // If the owner's balance in the pristine view is the same, // we haven't modified the balance and therefore the // offer is "found unfunded" versus "became unfunded" - auto const original_funds = accountFundsHelper( + auto const originalFunds = accountFundsHelper( cancelView_, offer_.owner(), amount.out, offer_.assetOut(), - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, j_); - if (original_funds == *ownerFunds_) + if (originalFunds == *ownerFunds_) { permRmOffer(entry->key()); JLOG(j_.trace()) << "Removing unfunded offer " << entry->key(); @@ -301,16 +301,16 @@ TOfferStreamBase::step() if (shouldRmSmallIncreasedQOffer()) { - auto const original_funds = accountFundsHelper( + auto const originalFunds = accountFundsHelper( cancelView_, offer_.owner(), amount.out, offer_.assetOut(), - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, j_); - if (original_funds == *ownerFunds_) + if (originalFunds == *ownerFunds_) { permRmOffer(entry->key()); JLOG(j_.trace()) << "Removing tiny offer due to reduced quality " << entry->key(); diff --git a/src/libxrpl/tx/paths/PaySteps.cpp b/src/libxrpl/tx/paths/PaySteps.cpp index d3fe366616..68bd501d87 100644 --- a/src/libxrpl/tx/paths/PaySteps.cpp +++ b/src/libxrpl/tx/paths/PaySteps.cpp @@ -57,7 +57,7 @@ checkNear(IOUAmount const& expected, IOUAmount const& actual) static bool isXRPAccount(STPathElement const& pe) { - if (pe.getNodeType() != STPathElement::typeAccount) + if (pe.getNodeType() != STPathElement::TypeAccount) return false; return isXRP(pe.getAccountID()); }; @@ -72,13 +72,13 @@ toStep( auto& j = ctx.j; if (ctx.isFirst && e1->isAccount() && - ((e1->getNodeType() & STPathElement::typeCurrency) != 0u) && e1->getPathAsset().isXRP()) + ((e1->getNodeType() & STPathElement::TypeCurrency) != 0u) && e1->getPathAsset().isXRP()) { - return make_XRPEndpointStep(ctx, e1->getAccountID()); + return makeXrpEndpointStep(ctx, e1->getAccountID()); } if (ctx.isLast && isXRPAccount(*e1) && e2->isAccount()) - return make_XRPEndpointStep(ctx, e2->getAccountID()); + return makeXrpEndpointStep(ctx, e2->getAccountID()); // MPTEndpointStep is created in following cases: // 1 Direct payment between an issuer and a holder @@ -99,12 +99,11 @@ toStep( { return curAsset.visit( [&](MPTIssue const& issue) { - return make_MPTEndpointStep( + return makeMptEndpointStep( ctx, e1->getAccountID(), e2->getAccountID(), issue.getMptID()); }, [&](Issue const& issue) { - return make_DirectStepI( - ctx, e1->getAccountID(), e2->getAccountID(), issue.currency); + return makeDirectStepI(ctx, e1->getAccountID(), e2->getAccountID(), issue.currency); }); } @@ -119,12 +118,12 @@ toStep( } XRPL_ASSERT( - (e2->getNodeType() & STPathElement::typeAsset) || - (e2->getNodeType() & STPathElement::typeIssuer), + (e2->getNodeType() & STPathElement::TypeAsset) || + (e2->getNodeType() & STPathElement::TypeIssuer), "xrpl::toStep : currency or issuer"); PathAsset const outAsset = - ((e2->getNodeType() & STPathElement::typeAsset) != 0u) ? e2->getPathAsset() : curAsset; - auto const outIssuer = ((e2->getNodeType() & STPathElement::typeIssuer) != 0u) + ((e2->getNodeType() & STPathElement::TypeAsset) != 0u) ? e2->getPathAsset() : curAsset; + auto const outIssuer = ((e2->getNodeType() & STPathElement::TypeIssuer) != 0u) ? e2->getIssuerID() : curAsset.getIssuer(); @@ -139,30 +138,30 @@ toStep( if (outAsset.isXRP()) { return curAsset.visit( - [&](MPTIssue const& issue) { return make_BookStepMX(ctx, issue); }, - [&](Issue const& issue) { return make_BookStepIX(ctx, issue); }); + [&](MPTIssue const& issue) { return makeBookStepMx(ctx, issue); }, + [&](Issue const& issue) { return makeBookStepIx(ctx, issue); }); } if (isXRP(curAsset)) { return outAsset.visit( - [&](MPTID const& mpt) { return make_BookStepXM(ctx, mpt); }, - [&](Currency const& currency) { return make_BookStepXI(ctx, {currency, outIssuer}); }); + [&](MPTID const& mpt) { return makeBookStepXm(ctx, mpt); }, + [&](Currency const& currency) { return makeBookStepXi(ctx, {currency, outIssuer}); }); } return curAsset.visit( [&](MPTIssue const& issue) { return outAsset.visit( [&](Currency const& currency) { - return make_BookStepMI(ctx, issue, {currency, outIssuer}); + return makeBookStepMi(ctx, issue, {currency, outIssuer}); }, - [&](MPTID const& mpt) { return make_BookStepMM(ctx, issue, mpt); }); + [&](MPTID const& mpt) { return makeBookStepMm(ctx, issue, mpt); }); }, [&](Issue const& issue) { return outAsset.visit( - [&](MPTID const& mpt) { return make_BookStepIM(ctx, issue, mpt); }, + [&](MPTID const& mpt) { return makeBookStepIm(ctx, issue, mpt); }, [&](Currency const& currency) { - return make_BookStepII(ctx, issue, {currency, outIssuer}); + return makeBookStepIi(ctx, issue, {currency, outIssuer}); }); }); } @@ -190,9 +189,9 @@ toStrand( (dst == noAccount()) || (deliver.getIssuer() == noAccount())) return {temBAD_PATH, Strand{}}; - if ((deliver.holds() && deliver.getIssuer() == beast::zero) || + if ((deliver.holds() && deliver.getIssuer() == beast::kZERO) || (sendMaxAsset && sendMaxAsset->holds() && - sendMaxAsset->getIssuer() == beast::zero)) + sendMaxAsset->getIssuer() == beast::kZERO)) return {temBAD_PATH, Strand{}}; for (std::size_t i = 0; i < path.size(); ++i) @@ -200,14 +199,14 @@ toStrand( auto const& pe = path[i]; auto const t = pe.getNodeType(); - if (((t & ~STPathElement::typeAll) != 0u) || (t == 0u)) + if (((t & ~STPathElement::TypeAll) != 0u) || (t == 0u)) return {temBAD_PATH, Strand{}}; - bool const hasAccount = (t & STPathElement::typeAccount) != 0u; - bool const hasIssuer = (t & STPathElement::typeIssuer) != 0u; - bool const hasCurrency = (t & STPathElement::typeCurrency) != 0u; - bool const hasMPT = (t & STPathElement::typeMPT) != 0u; - bool const hasAsset = (t & STPathElement::typeAsset) != 0u; + bool const hasAccount = (t & STPathElement::TypeAccount) != 0u; + bool const hasIssuer = (t & STPathElement::TypeIssuer) != 0u; + bool const hasCurrency = (t & STPathElement::TypeCurrency) != 0u; + bool const hasMPT = (t & STPathElement::TypeMpt) != 0u; + bool const hasAsset = (t & STPathElement::TypeAsset) != 0u; if (hasAccount && (hasIssuer || hasCurrency)) return {temBAD_PATH, Strand{}}; @@ -252,7 +251,7 @@ toStrand( // Currency or MPT auto hasAsset = [](STPathElement const pe) { - return pe.getNodeType() & STPathElement::typeAsset; + return pe.getNodeType() & STPathElement::TypeAsset; }; std::vector normPath; @@ -264,10 +263,10 @@ toStrand( // transaction, as defined by the transaction's Account field. The Asset // is either SendMax or Deliver. auto const t = [&]() { - auto const t = STPathElement::typeAccount | STPathElement::typeIssuer; + auto const t = STPathElement::TypeAccount | STPathElement::TypeIssuer; return curAsset.visit( - [&](MPTIssue const&) { return t | STPathElement::typeMPT; }, - [&](Issue const&) { return t | STPathElement::typeCurrency; }); + [&](MPTIssue const&) { return t | STPathElement::TypeMpt; }, + [&](Issue const&) { return t | STPathElement::TypeCurrency; }); }(); // If MPT then the issuer is the actual issuer, it is never the source // account. @@ -294,7 +293,7 @@ toStrand( STPathElement const& lastAsset = *std::ranges::find_if(std::ranges::reverse_view(normPath), hasAsset); if (lastAsset.getPathAsset() != deliver || - (offerCrossing != OfferCrossing::no && + (offerCrossing != OfferCrossing::No && lastAsset.getIssuerID() != deliver.getIssuer())) { normPath.emplace_back(std::nullopt, deliver, deliver.getIssuer()); @@ -409,16 +408,15 @@ toStrand( } using ImpliedStepRet = std::pair>; - auto getImpliedStep = [&](AccountID const& src_, - AccountID const& dst_, - Asset const& asset_) -> ImpliedStepRet { - return asset_.visit( + auto getImpliedStep = + [&](AccountID const& src, AccountID const& dst, Asset const& asset) -> ImpliedStepRet { + return asset.visit( [&](MPTIssue const&) -> ImpliedStepRet { JLOG(j.error()) << "MPT is invalid with rippling"; return {temBAD_PATH, nullptr}; }, [&](Issue const& issue) -> ImpliedStepRet { - return make_DirectStepI(ctx(), src_, dst_, issue.currency); + return makeDirectStepI(ctx(), src, dst, issue.currency); }); }; @@ -437,7 +435,7 @@ toStrand( return {msr.first, Strand{}}; result.push_back(std::move(msr.second)); impliedPE.emplace( - STPathElement::typeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount()); + STPathElement::TypeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount()); cur = &*impliedPE; } } @@ -452,7 +450,7 @@ toStrand( return {msr.first, Strand{}}; result.push_back(std::move(msr.second)); impliedPE.emplace( - STPathElement::typeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount()); + STPathElement::TypeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount()); cur = &*impliedPE; } } @@ -469,7 +467,7 @@ toStrand( return {temBAD_PATH, Strand{}}; // Last step. insert xrp endpoint step - auto msr = make_XRPEndpointStep(ctx(), next->getAccountID()); + auto msr = makeXrpEndpointStep(ctx(), next->getAccountID()); if (!isTesSuccess(msr.first)) return {msr.first, Strand{}}; result.push_back(std::move(msr.second)); @@ -664,7 +662,7 @@ toStrands( { lastFailTer = ter; JLOG(j.trace()) << "failed to add path: ter: " << ter - << "path: " << p.getJson(JsonOptions::none); + << "path: " << p.getJson(JsonOptions::KNone); if (isTemMalformed(ter)) return {ter, std::vector{}}; } @@ -686,40 +684,40 @@ toStrands( } StrandContext::StrandContext( - ReadView const& view_, - std::vector> const& strand_, + ReadView const& view, + std::vector> const& strand, // A strand may not include an inner node that // replicates the source or destination. - AccountID const& strandSrc_, - AccountID const& strandDst_, - Asset const& strandDeliver_, - std::optional const& limitQuality_, - bool isLast_, - bool ownerPaysTransferFee_, - OfferCrossing offerCrossing_, - bool isDefaultPath_, - std::array, 2>& seenDirectAssets_, - boost::container::flat_set& seenBookOuts_, - AMMContext& ammContext_, - std::optional const& domainID_, - beast::Journal j_) - : view(view_) - , strandSrc(strandSrc_) - , strandDst(strandDst_) - , strandDeliver(strandDeliver_) - , limitQuality(limitQuality_) - , isFirst(strand_.empty()) - , isLast(isLast_) - , ownerPaysTransferFee(ownerPaysTransferFee_) - , offerCrossing(offerCrossing_) - , isDefaultPath(isDefaultPath_) - , strandSize(strand_.size()) - , prevStep(!strand_.empty() ? strand_.back().get() : nullptr) - , seenDirectAssets(seenDirectAssets_) - , seenBookOuts(seenBookOuts_) - , ammContext(ammContext_) - , domainID(domainID_) - , j(j_) + AccountID const& strandSrc, + AccountID const& strandDst, + Asset const& strandDeliver, + std::optional const& limitQuality, + bool isLast, + bool ownerPaysTransferFee, + OfferCrossing offerCrossing, + bool isDefaultPath, + std::array, 2>& seenDirectAssets, + boost::container::flat_set& seenBookOuts, + AMMContext& ammContext, + std::optional const& domainId, + beast::Journal j) + : view(view) + , strandSrc(strandSrc) + , strandDst(strandDst) + , strandDeliver(strandDeliver) + , limitQuality(limitQuality) + , isFirst(strand.empty()) + , isLast(isLast) + , ownerPaysTransferFee(ownerPaysTransferFee) + , offerCrossing(offerCrossing) + , isDefaultPath(isDefaultPath) + , strandSize(strand.size()) + , prevStep(!strand.empty() ? strand.back().get() : nullptr) + , seenDirectAssets(seenDirectAssets) + , seenBookOuts(seenBookOuts) + , ammContext(ammContext) + , domainID(domainId) + , j(j) { } diff --git a/src/libxrpl/tx/paths/RippleCalc.cpp b/src/libxrpl/tx/paths/RippleCalc.cpp index 773a9bac3d..06e386344d 100644 --- a/src/libxrpl/tx/paths/RippleCalc.cpp +++ b/src/libxrpl/tx/paths/RippleCalc.cpp @@ -59,13 +59,13 @@ RippleCalc::rippleCalculate( bool const partialPayment = (pInputs == nullptr) ? false : pInputs->partialPaymentAllowed; auto const limitQuality = [&]() -> std::optional { - if (pInputs && pInputs->limitQuality && saMaxAmountReq > beast::zero) + if (pInputs && pInputs->limitQuality && saMaxAmountReq > beast::kZERO) return Quality{Amounts(saMaxAmountReq, saDstAmountReq)}; return std::nullopt; }(); auto const sendMax = [&]() -> std::optional { - if (saMaxAmountReq >= beast::zero || + if (saMaxAmountReq >= beast::kZERO || !equalTokens(saMaxAmountReq.asset(), saDstAmountReq.asset()) || saMaxAmountReq.getIssuer() != uSrcAccountID) { @@ -85,7 +85,7 @@ RippleCalc::rippleCalculate( defaultPaths, partialPayment, false, - OfferCrossing::no, + OfferCrossing::No, limitQuality, sendMax, domainID, diff --git a/src/libxrpl/tx/paths/XRPEndpointStep.cpp b/src/libxrpl/tx/paths/XRPEndpointStep.cpp index 2310f72f34..244e1cffea 100644 --- a/src/libxrpl/tx/paths/XRPEndpointStep.cpp +++ b/src/libxrpl/tx/paths/XRPEndpointStep.cpp @@ -88,7 +88,7 @@ public: [[nodiscard]] DebtDirection debtDirection(ReadView const& sb, StrandDirection dir) const override { - return DebtDirection::issues; + return DebtDirection::Issues; } [[nodiscard]] std::pair, DebtDirection> @@ -253,7 +253,7 @@ template std::pair, DebtDirection> XRPEndpointStep::qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const { - return {Quality{STAmount::uRateOne}, this->debtDirection(v, StrandDirection::forward)}; + return {Quality{STAmount::kU_RATE_ONE}, this->debtDirection(v, StrandDirection::Forward)}; } template @@ -272,7 +272,7 @@ XRPEndpointStep::revImp( auto& receiver = isLast_ ? acc_ : xrpAccount(); auto ter = accountSend(sb, sender, receiver, toSTAmount(result), j_); if (!isTesSuccess(ter)) - return {XRPAmount{beast::zero}, XRPAmount{beast::zero}}; + return {XRPAmount{beast::kZERO}, XRPAmount{beast::kZERO}}; cache_.emplace(result); return {result, result}; @@ -295,7 +295,7 @@ XRPEndpointStep::fwdImp( auto& receiver = isLast_ ? acc_ : xrpAccount(); auto ter = accountSend(sb, sender, receiver, toSTAmount(result), j_); if (!isTesSuccess(ter)) - return {XRPAmount{beast::zero}, XRPAmount{beast::zero}}; + return {XRPAmount{beast::kZERO}, XRPAmount{beast::kZERO}}; cache_.emplace(result); return {result, result}; @@ -308,7 +308,7 @@ XRPEndpointStep::validFwd(PaymentSandbox& sb, ApplyView& afView, Eithe if (!cache_) { JLOG(j_.error()) << "Expected valid cache in validFwd"; - return {false, EitherAmount(XRPAmount(beast::zero))}; + return {false, EitherAmount(XRPAmount(beast::kZERO))}; } XRPL_ASSERT(in.holds(), "xrpl::XRPEndpointStep::validFwd : input is XRP"); @@ -392,11 +392,11 @@ xrpEndpointStepEqual(Step const& step, AccountID const& acc) //------------------------------------------------------------------------------ std::pair> -make_XRPEndpointStep(StrandContext const& ctx, AccountID const& acc) +makeXrpEndpointStep(StrandContext const& ctx, AccountID const& acc) { TER ter = tefINTERNAL; std::unique_ptr r; - if (ctx.offerCrossing != OfferCrossing::no) + if (ctx.offerCrossing != OfferCrossing::No) { auto offerCrossingStep = std::make_unique(ctx, acc); ter = offerCrossingStep->check(ctx); diff --git a/src/libxrpl/tx/transactors/account/AccountDelete.cpp b/src/libxrpl/tx/transactors/account/AccountDelete.cpp index b687ed0bd7..f9d1913dff 100644 --- a/src/libxrpl/tx/transactors/account/AccountDelete.cpp +++ b/src/libxrpl/tx/transactors/account/AccountDelete.cpp @@ -261,8 +261,8 @@ AccountDelete::preclaim(PreclaimContext const& ctx) return tecHAS_OBLIGATIONS; // If the account owns any NFTs it cannot be deleted. - Keylet const first = keylet::nftpage_min(account); - Keylet const last = keylet::nftpage_max(account); + Keylet const first = keylet::nftpageMin(account); + Keylet const last = keylet::nftpageMax(account); auto const cp = ctx.view.read( Keylet(ltNFTOKEN_PAGE, ctx.view.succ(first.key, last.key.next()).value_or(last.key))); @@ -275,8 +275,8 @@ AccountDelete::preclaim(PreclaimContext const& ctx) // // We look at the account's Sequence rather than the transaction's // Sequence in preparation for Tickets. - constexpr std::uint32_t seqDelta{255}; - if ((*sleAccount)[sfSequence] + seqDelta > ctx.view.seq()) + constexpr std::uint32_t kSEQ_DELTA{255}; + if ((*sleAccount)[sfSequence] + kSEQ_DELTA > ctx.view.seq()) return tecTOO_SOON; // We don't allow an account to be deleted if @@ -291,7 +291,7 @@ AccountDelete::preclaim(PreclaimContext const& ctx) // NFTokenSequence of this NFToken is the same as the one that the // authorized minter minted in a previous ledger. if ((*sleAccount)[~sfFirstNFTokenSequence].value_or(0) + - (*sleAccount)[~sfMintedNFTokens].value_or(0) + seqDelta > + (*sleAccount)[~sfMintedNFTokens].value_or(0) + kSEQ_DELTA > ctx.view.seq()) return tecTOO_SOON; @@ -303,7 +303,7 @@ AccountDelete::preclaim(PreclaimContext const& ctx) std::shared_ptr sleDirNode{}; unsigned int uDirEntry{0}; - uint256 dirEntry{beast::zero}; + uint256 dirEntry{beast::kZERO}; // Account has no directory at all. This _should_ have been caught // by the dirIsEmpty() check earlier, but it's okay to catch it here. @@ -326,14 +326,14 @@ AccountDelete::preclaim(PreclaimContext const& ctx) // LCOV_EXCL_STOP } - LedgerEntryType const nodeType{safe_cast((*sleItem)[sfLedgerEntryType])}; + LedgerEntryType const nodeType{safeCast((*sleItem)[sfLedgerEntryType])}; if (nonObligationDeleter(nodeType) == nullptr) return tecHAS_OBLIGATIONS; // We found a deletable directory entry. Count it. If we find too // many deletable directory entries then bail out. - if (++deletableDirEntryCount > maxDeletableDirEntries) + if (++deletableDirEntryCount > kMAX_DELETABLE_DIR_ENTRIES) return tefTOO_BIG; } while (cdirNext(ctx.view, ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry)); diff --git a/src/libxrpl/tx/transactors/account/AccountSet.cpp b/src/libxrpl/tx/transactors/account/AccountSet.cpp index e8555ecc04..da24640bfa 100644 --- a/src/libxrpl/tx/transactors/account/AccountSet.cpp +++ b/src/libxrpl/tx/transactors/account/AccountSet.cpp @@ -39,19 +39,19 @@ AccountSet::makeTxConsequences(PreflightContext const& ctx) auto getTxConsequencesCategory = [](STTx const& tx) { if (std::uint32_t const uTxFlags = tx.getFlags(); uTxFlags & (tfRequireAuth | tfOptionalAuth)) - return TxConsequences::Category::blocker; + return TxConsequences::Category::Blocker; if (auto const uSetFlag = tx[~sfSetFlag]; uSetFlag && (*uSetFlag == asfRequireAuth || *uSetFlag == asfDisableMaster || *uSetFlag == asfAccountTxnID)) - return TxConsequences::Category::blocker; + return TxConsequences::Category::Blocker; if (auto const uClearFlag = tx[~sfClearFlag]; uClearFlag && (*uClearFlag == asfRequireAuth || *uClearFlag == asfDisableMaster || *uClearFlag == asfAccountTxnID)) - return TxConsequences::Category::blocker; + return TxConsequences::Category::Blocker; - return TxConsequences::Category::normal; + return TxConsequences::Category::Normal; }; return TxConsequences{ctx.tx, getTxConsequencesCategory(ctx.tx)}; @@ -143,7 +143,7 @@ AccountSet::preflight(PreflightContext const& ctx) { auto uTickSize = tx[sfTickSize]; if ((uTickSize != 0u) && - ((uTickSize < Quality::minTickSize) || (uTickSize > Quality::maxTickSize))) + ((uTickSize < Quality::kMIN_TICK_SIZE) || (uTickSize > Quality::kMAX_TICK_SIZE))) { JLOG(j.trace()) << "Malformed transaction: Bad tick size."; return temBAD_TICK_SIZE; @@ -159,7 +159,7 @@ AccountSet::preflight(PreflightContext const& ctx) } } - if (auto const domain = tx[~sfDomain]; domain && domain->size() > maxDomainLength) + if (auto const domain = tx[~sfDomain]; domain && domain->size() > kMAX_DOMAIN_LENGTH) { JLOG(j.trace()) << "domain too long"; return telBAD_DOMAIN; @@ -250,7 +250,7 @@ AccountSet::preclaim(PreclaimContext const& ctx) if (!dirIsEmpty(ctx.view, keylet::ownerDir(id))) { JLOG(ctx.j.trace()) << "Retry: Owner directory not empty."; - return ((ctx.flags & tapRETRY) != 0u) ? TER{terOWNERS} : TER{tecOWNERS}; + return ((ctx.flags & TapRetry) != 0u) ? TER{terOWNERS} : TER{tecOWNERS}; } } @@ -574,7 +574,7 @@ AccountSet::doApply() if (tx.isFieldPresent(sfTickSize)) { auto uTickSize = tx[sfTickSize]; - if ((uTickSize == 0) || (uTickSize == Quality::maxTickSize)) + if ((uTickSize == 0) || (uTickSize == Quality::kMAX_TICK_SIZE)) { JLOG(j_.trace()) << "unset tick size"; sle->makeFieldAbsent(sfTickSize); diff --git a/src/libxrpl/tx/transactors/account/SignerListSet.cpp b/src/libxrpl/tx/transactors/account/SignerListSet.cpp index ee4cf583f4..3060abe6df 100644 --- a/src/libxrpl/tx/transactors/account/SignerListSet.cpp +++ b/src/libxrpl/tx/transactors/account/SignerListSet.cpp @@ -37,7 +37,7 @@ namespace xrpl { // We're prepared for there to be multiple signer lists in the future, // but we don't need them yet. So for the time being we're manually // setting the sfSignerListID to zero in all cases. -static std::uint32_t const DEFAULT_SIGNER_LIST_ID = 0; +static std::uint32_t const kDEFAULT_SIGNER_LIST_ID = 0; std::tuple, SignerListSet::Operation> SignerListSet::determineOperation(STTx const& tx, ApplyFlags flags, beast::Journal j) @@ -46,7 +46,7 @@ SignerListSet::determineOperation(STTx const& tx, ApplyFlags flags, beast::Journ // the list. A zero quorum means we're destroying the list. auto const quorum = tx[sfSignerQuorum]; std::vector sign; - Operation op = Operation::unknown; + Operation op = Operation::Unknown; bool const hasSignerEntries(tx.isFieldPresent(sfSignerEntries)); if ((quorum != 0u) && hasSignerEntries) @@ -60,11 +60,11 @@ SignerListSet::determineOperation(STTx const& tx, ApplyFlags flags, beast::Journ // Save deserialized list for later. sign = std::move(*signers); - op = Operation::set; + op = Operation::Set; } else if ((quorum == 0) && !hasSignerEntries) { - op = Operation::destroy; + op = Operation::Destroy; } return std::make_tuple(tesSUCCESS, quorum, sign, op); @@ -85,14 +85,14 @@ SignerListSet::preflight(PreflightContext const& ctx) if (!isTesSuccess(std::get<0>(result))) return std::get<0>(result); - if (std::get<3>(result) == Operation::unknown) + if (std::get<3>(result) == Operation::Unknown) { // Neither a set nor a destroy. Malformed. JLOG(ctx.j.trace()) << "Malformed transaction: Invalid signer set list format."; return temMALFORMED; } - if (std::get<3>(result) == Operation::set) + if (std::get<3>(result) == Operation::Set) { // Validate our settings. auto const account = ctx.tx.getAccountID(sfAccount); @@ -113,10 +113,10 @@ SignerListSet::doApply() // Perform the operation preCompute() decided on. switch (do_) { - case Operation::set: + case Operation::Set: return replaceSignerList(); - case Operation::destroy: + case Operation::Destroy: return destroySignerList(); default: @@ -137,7 +137,7 @@ SignerListSet::preCompute() isTesSuccess(std::get<0>(result)), "xrpl::SignerListSet::preCompute : result is tesSUCCESS"); XRPL_ASSERT( - std::get<3>(result) != Operation::unknown, + std::get<3>(result) != Operation::Unknown, "xrpl::SignerListSet::preCompute : result is known operation"); quorum_ = std::get<1>(result); @@ -168,10 +168,10 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) // be in the range from 1 to 32. // We've got a lot of room to grow. XRPL_ASSERT( - entryCount >= STTx::minMultiSigners, + entryCount >= STTx::kMIN_MULTI_SIGNERS, "xrpl::signerCountBasedOwnerCountDelta : minimum signers"); XRPL_ASSERT( - entryCount <= STTx::maxMultiSigners, + entryCount <= STTx::kMAX_MULTI_SIGNERS, "xrpl::signerCountBasedOwnerCountDelta : maximum signers"); return 2 + static_cast(entryCount); } @@ -249,7 +249,7 @@ SignerListSet::validateQuorumAndSignerEntries( // Reject if there are too many or too few entries in the list. { std::size_t const signerCount = signers.size(); - if (signerCount < STTx::minMultiSigners || signerCount > STTx::maxMultiSigners) + if (signerCount < STTx::kMIN_MULTI_SIGNERS || signerCount > STTx::kMAX_MULTI_SIGNERS) { JLOG(j.trace()) << "Too many or too few signers in signer list."; return temMALFORMED; @@ -318,10 +318,10 @@ SignerListSet::replaceSignerList() // Compute new reserve. Verify the account has funds to meet the reserve. std::uint32_t const oldOwnerCount{(*sle)[sfOwnerCount]}; - constexpr int addedOwnerCount = 1; + constexpr int kADDED_OWNER_COUNT = 1; std::uint32_t const flags{lsfOneOwnerCount}; - XRPAmount const newReserve{view().fees().accountReserve(oldOwnerCount + addedOwnerCount)}; + XRPAmount const newReserve{view().fees().accountReserve(oldOwnerCount + kADDED_OWNER_COUNT)}; // We check the reserve against the starting balance because we want to // allow dipping into the reserve to pay fees. This behavior is consistent @@ -349,7 +349,7 @@ SignerListSet::replaceSignerList() // If we succeeded, the new entry counts against the // creator's reserve. - adjustOwnerCount(view(), sle, addedOwnerCount, viewJ); + adjustOwnerCount(view(), sle, kADDED_OWNER_COUNT, viewJ); return tesSUCCESS; } @@ -381,7 +381,7 @@ SignerListSet::writeSignersToSLE(SLE::pointer const& ledgerEntry, std::uint32_t ledgerEntry->setAccountID(sfOwner, account_); } ledgerEntry->setFieldU32(sfSignerQuorum, quorum_); - ledgerEntry->setFieldU32(sfSignerListID, DEFAULT_SIGNER_LIST_ID); + ledgerEntry->setFieldU32(sfSignerListID, kDEFAULT_SIGNER_LIST_ID); if (flags != 0u) // Only set flags if they are non-default (default is zero). ledgerEntry->setFieldU32(sfFlags, flags); @@ -389,7 +389,7 @@ SignerListSet::writeSignersToSLE(SLE::pointer const& ledgerEntry, std::uint32_t STArray toLedger(signers_.size()); for (auto const& entry : signers_) { - toLedger.push_back(STObject::makeInnerObject(sfSignerEntry)); + toLedger.pushBack(STObject::makeInnerObject(sfSignerEntry)); STObject& obj = toLedger.back(); obj.reserve(2); obj[sfAccount] = entry.account; diff --git a/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp b/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp index 461c4ee207..09e5a7284a 100644 --- a/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp +++ b/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp @@ -184,7 +184,7 @@ checkAttestationPublicKey( // must attest to this destination, if it is `ignore` then the `dst` of the // attestations are not checked (as for a `claim` transaction) -enum class CheckDst { check, ignore }; +enum class CheckDst { Check, Ignore }; template Expected, TER> claimHelper( @@ -199,7 +199,7 @@ claimHelper( // Remove attestations that are not valid signers. They may be no longer // part of the signers list, or their master key may have been disabled, // or their regular key may have changed - attestations.erase_if([&](auto const& a) { + attestations.eraseIf([&](auto const& a) { return checkAttestationPublicKey(view, signersList, a.keyAccount, a.publicKey, j) != tesSUCCESS; }); @@ -215,7 +215,7 @@ claimHelper( // attestation transaction. The dst does not need to match if the // claimHelper is being run using an explicit claim transaction. using enum AttestationMatch; - if (matchR == nonDstMismatch || (checkDst == CheckDst::check && matchR != match)) + if (matchR == NonDstMismatch || (checkDst == CheckDst::Check && matchR != Match)) continue; auto i = signersList.find(a.keyAccount); if (i == signersList.end()) @@ -314,7 +314,7 @@ onNewAttestations( } else { - attestations.emplace_back(*att); + attestations.emplaceBack(*att); changed = true; } } @@ -323,7 +323,7 @@ onNewAttestations( attestations, view, typename TAttestation::MatchFields{*attBegin}, - CheckDst::check, + CheckDst::Check, quorum, signersList, j); @@ -349,19 +349,19 @@ onClaim( { XChainClaimAttestation::MatchFields const toMatch{ sendingAmount, wasLockingChainSend, std::nullopt}; - return claimHelper(attestations, view, toMatch, CheckDst::ignore, quorum, signersList, j); + return claimHelper(attestations, view, toMatch, CheckDst::Ignore, quorum, signersList, j); } -enum class CanCreateDstPolicy { no, yes }; +enum class CanCreateDstPolicy { No, Yes }; -enum class DepositAuthPolicy { normal, dstCanBypass }; +enum class DepositAuthPolicy { Normal, DstCanBypass }; // Allow the fee to dip into the reserve. To support this, information about the // submitting account needs to be fed to the transfer helper. struct TransferHelperSubmittingAccountInfo { AccountID account; - STAmount preFeeBalance_; + STAmount preFeeBalance; STAmount postFeeBalance; }; @@ -415,7 +415,7 @@ transferHelper( // transaction, that's the dst account sending funds to itself. It // can bypass deposit auth. bool const canBypassDepositAuth = - dst == claimOwner && depositAuthPolicy == DepositAuthPolicy::dstCanBypass; + dst == claimOwner && depositAuthPolicy == DepositAuthPolicy::DstCanBypass; if (!canBypassDepositAuth && ((sleDst->getFlags() & lsfDepositAuth) != 0u) && !psb.exists(keylet::depositPreauth(dst, src))) @@ -423,7 +423,7 @@ transferHelper( return tecNO_PERMISSION; } } - else if (!amt.native() || canCreate == CanCreateDstPolicy::no) + else if (!amt.native() || canCreate == CanCreateDstPolicy::No) { return tecNO_DST; } @@ -447,7 +447,7 @@ transferHelper( if (!submittingAccountInfo || submittingAccountInfo->account != src || submittingAccountInfo->postFeeBalance != curBal) return curBal; - return submittingAccountInfo->preFeeBalance_; + return submittingAccountInfo->preFeeBalance; }(); if (availableBalance < amt + reserve) @@ -459,7 +459,7 @@ transferHelper( auto sleDst = psb.peek(dstK); if (!sleDst) { - if (canCreate == CanCreateDstPolicy::no) + if (canCreate == CanCreateDstPolicy::No) { // Already checked, but OK to check again return tecNO_DST; @@ -495,7 +495,7 @@ transferHelper( /*default path*/ true, /*partial payment*/ false, /*owner pays transfer fee*/ true, - /*offer crossing*/ OfferCrossing::no, + /*offer crossing*/ OfferCrossing::No, /*limit quality*/ std::nullopt, /*sendmax*/ std::nullopt, /*domain id*/ std::nullopt, @@ -513,9 +513,9 @@ transferHelper( */ enum class OnTransferFail { /** Remove the claim even if the transfer fails */ - removeClaim, + RemoveClaim, /** Keep the claim if the transfer fails */ - keepClaim + KeepClaim }; struct FinalizeClaimHelperResult @@ -638,12 +638,12 @@ finalizeClaimHelper( dstTag, claimOwner, thisChainAmount, - CanCreateDstPolicy::yes, + CanCreateDstPolicy::Yes, depositAuthPolicy, std::nullopt, j); - if (!isTesSuccess(*result.mainFundsTer) && onTransferFail == OnTransferFail::keepClaim) + if (!isTesSuccess(*result.mainFundsTer) && onTransferFail == OnTransferFail::KeepClaim) { return result; } @@ -657,10 +657,10 @@ finalizeClaimHelper( // if the transfer failed, distribute the pool for "OnTransferFail" // cases (the attesters did their job) STAmount const share = [&] { - auto const round_mode = innerSb.rules().enabled(fixXChainRewardRounding) - ? Number::rounding_mode::downward + auto const roundMode = innerSb.rules().enabled(fixXChainRewardRounding) + ? Number::RoundingMode::Downward : Number::getround(); - saveNumberRoundMode const _{Number::setround(round_mode)}; + SaveNumberRoundMode const _{Number::setround(roundMode)}; STAmount const den{rewardAccounts.size()}; return divide(rewardPool, den, rewardPool.asset()); @@ -676,8 +676,8 @@ finalizeClaimHelper( // claim owner is not relevant to distributing rewards /*claimOwner*/ std::nullopt, share, - CanCreateDstPolicy::no, - DepositAuthPolicy::normal, + CanCreateDstPolicy::No, + DepositAuthPolicy::Normal, std::nullopt, j); @@ -698,7 +698,7 @@ finalizeClaimHelper( }(); if (!isTesSuccess(*result.rewardTer) && - (onTransferFail == OnTransferFail::keepClaim || *result.rewardTer == tecINTERNAL)) + (onTransferFail == OnTransferFail::KeepClaim || *result.rewardTer == tecINTERNAL)) { return result; } @@ -793,9 +793,9 @@ readOrpeekBridge(F&& getter, STXChainBridge const& bridgeSpec) } return nullptr; }; - if (auto r = tryGet(STXChainBridge::ChainType::locking)) + if (auto r = tryGet(STXChainBridge::ChainType::Locking)) return r; - return tryGet(STXChainBridge::ChainType::issuing); + return tryGet(STXChainBridge::ChainType::Issuing); } std::shared_ptr @@ -927,8 +927,8 @@ applyClaimAttestations( *rewardAccounts, srcChain, claimIDKeylet, - OnTransferFail::keepClaim, - DepositAuthPolicy::normal, + OnTransferFail::KeepClaim, + DepositAuthPolicy::Normal, j); auto const rTer = r.ter(); @@ -981,7 +981,7 @@ applyCreateAccountAttestations( { return tecXCHAIN_ACCOUNT_CREATE_PAST; } - if (attBegin->createCount >= claimCount + xbridgeMaxAccountCreateClaims) + if (attBegin->createCount >= claimCount + kXBRIDGE_MAX_ACCOUNT_CREATE_CLAIMS) { // Limit the number of claims on the account return tecXCHAIN_ACCOUNT_CREATE_TOO_MANY; @@ -1099,8 +1099,8 @@ applyCreateAccountAttestations( *rewardAccounts, srcChain, claimIDKeylet, - OnTransferFail::removeClaim, - DepositAuthPolicy::normal, + OnTransferFail::RemoveClaim, + DepositAuthPolicy::Normal, j); auto const rTer = r.ter(); @@ -1237,7 +1237,7 @@ attestationDoApply(ApplyContext& ctx) struct ScopeResult { - STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::locking; + STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::Locking; std::unordered_map signersList; std::uint32_t quorum{}; AccountID thisDoor; @@ -1257,15 +1257,15 @@ attestationDoApply(ApplyContext& ctx) Keylet const bridgeK{ltBRIDGE, sleBridge->key()}; AccountID const thisDoor = (*sleBridge)[sfAccount]; - STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::locking; + STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::Locking; { if (thisDoor == bridgeSpec.lockingChainDoor()) { - dstChain = STXChainBridge::ChainType::locking; + dstChain = STXChainBridge::ChainType::Locking; } else if (thisDoor == bridgeSpec.issuingChainDoor()) { - dstChain = STXChainBridge::ChainType::issuing; + dstChain = STXChainBridge::ChainType::Issuing; } else { @@ -1369,9 +1369,9 @@ XChainCreateBridge::preflight(PreflightContext const& ctx) // Issuing account must be the root account for XRP (which presumably // owns all the XRP). This is done so the issuing account can't "run // out" of wrapped tokens. - static auto const rootAccount = calcAccountID( - generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")).first); - if (bridgeSpec.issuingChainDoor() != rootAccount) + static auto const kROOT_ACCOUNT = calcAccountID( + generateKeyPair(KeyType::Secp256k1, generateSeed("masterpassphrase")).first); + if (bridgeSpec.issuingChainDoor() != kROOT_ACCOUNT) { return temXCHAIN_BRIDGE_BAD_ISSUES; } @@ -1409,8 +1409,8 @@ XChainCreateBridge::preclaim(PreclaimContext const& ctx) return ctx.view.exists(keylet::bridge(bridgeSpec, ct)); }; - if (hasBridge(STXChainBridge::ChainType::issuing) || - hasBridge(STXChainBridge::ChainType::locking)) + if (hasBridge(STXChainBridge::ChainType::Issuing) || + hasBridge(STXChainBridge::ChainType::Locking)) { return tecDUPLICATE; } @@ -1736,15 +1736,15 @@ XChainClaim::doApply() AccountID const thisDoor = (*sleBridge)[sfAccount]; - STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::locking; + STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::Locking; { if (thisDoor == bridgeSpec.lockingChainDoor()) { - dstChain = STXChainBridge::ChainType::locking; + dstChain = STXChainBridge::ChainType::Locking; } else if (thisDoor == bridgeSpec.issuingChainDoor()) { - dstChain = STXChainBridge::ChainType::issuing; + dstChain = STXChainBridge::ChainType::Issuing; } else { @@ -1771,7 +1771,7 @@ XChainClaim::doApply() curAtts, psb, sendingAmount, - /*wasLockingChainSend*/ srcChain == STXChainBridge::ChainType::locking, + /*wasLockingChainSend*/ srcChain == STXChainBridge::ChainType::Locking, quorum, signersList, ctx_.journal); @@ -1806,8 +1806,8 @@ XChainClaim::doApply() rewardAccounts, srcChain, claimIDKeylet, - OnTransferFail::keepClaim, - DepositAuthPolicy::dstCanBypass, + OnTransferFail::KeepClaim, + DepositAuthPolicy::DstCanBypass, ctx_.journal); if (!r.isTesSuccess()) return r.ter(); @@ -1826,7 +1826,7 @@ XChainCommit::makeTxConsequences(PreflightContext const& ctx) auto const amount = ctx.tx[sfAmount]; if (amount.native() && amount.signum() > 0) return amount.xrp(); - return XRPAmount{beast::zero}; + return XRPAmount{beast::kZERO}; }(); return TxConsequences{ctx.tx, maxSpend}; @@ -1921,7 +1921,7 @@ XChainCommit::doApply() // Support dipping into reserves to pay the fee TransferHelperSubmittingAccountInfo submittingAccountInfo{ .account = account_, - .preFeeBalance_ = preFeeBalance_, + .preFeeBalance = preFeeBalance_, .postFeeBalance = (*sleAccount)[sfBalance]}; auto const thTer = transferHelper( @@ -1931,8 +1931,8 @@ XChainCommit::doApply() /*dstTag*/ std::nullopt, /*claimOwner*/ std::nullopt, amount, - CanCreateDstPolicy::no, - DepositAuthPolicy::normal, + CanCreateDstPolicy::No, + DepositAuthPolicy::Normal, submittingAccountInfo, ctx_.journal); @@ -2149,15 +2149,15 @@ XChainCreateAccountCommit::preclaim(PreclaimContext const& ctx) return tecXCHAIN_SELF_COMMIT; } - STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::locking; + STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::Locking; { if (thisDoor == bridgeSpec.lockingChainDoor()) { - srcChain = STXChainBridge::ChainType::locking; + srcChain = STXChainBridge::ChainType::Locking; } else if (thisDoor == bridgeSpec.issuingChainDoor()) { - srcChain = STXChainBridge::ChainType::issuing; + srcChain = STXChainBridge::ChainType::Issuing; } else { @@ -2197,7 +2197,7 @@ XChainCreateAccountCommit::doApply() // Support dipping into reserves to pay the fee TransferHelperSubmittingAccountInfo submittingAccountInfo{ - .account = account_, .preFeeBalance_ = preFeeBalance_, .postFeeBalance = (*sle)[sfBalance]}; + .account = account_, .preFeeBalance = preFeeBalance_, .postFeeBalance = (*sle)[sfBalance]}; STAmount const toTransfer = amount + reward; auto const thTer = transferHelper( psb, @@ -2206,8 +2206,8 @@ XChainCreateAccountCommit::doApply() /*dstTag*/ std::nullopt, /*claimOwner*/ std::nullopt, toTransfer, - CanCreateDstPolicy::yes, - DepositAuthPolicy::normal, + CanCreateDstPolicy::Yes, + DepositAuthPolicy::Normal, submittingAccountInfo, ctx_.journal); diff --git a/src/libxrpl/tx/transactors/check/CheckCash.cpp b/src/libxrpl/tx/transactors/check/CheckCash.cpp index 31bca0aa32..34288425a5 100644 --- a/src/libxrpl/tx/transactors/check/CheckCash.cpp +++ b/src/libxrpl/tx/transactors/check/CheckCash.cpp @@ -164,8 +164,8 @@ CheckCash::preclaim(PreclaimContext const& ctx) ctx.view, sleCheck->at(sfAccount), value, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j)}; // Note that src will have one reserve's worth of additional XRP @@ -213,13 +213,13 @@ CheckCash::preclaim(PreclaimContext const& ctx) // determined by a lexicographical "greater than" // comparison employing strict weak ordering. // Determine which entry we need to access. - bool const canonical_gt(dstId > issuerId); + bool const canonicalGt(dstId > issuerId); - bool const is_authorized( + bool const isAuthorized( (sleTrustLine->at(sfFlags) & - (canonical_gt ? lsfLowAuth : lsfHighAuth)) != 0u); + (canonicalGt ? lsfLowAuth : lsfHighAuth)) != 0u); - if (!is_authorized) + if (!isAuthorized) { JLOG(ctx.j.warn()) << "Can't receive IOUs from " "issuer without auth."; @@ -372,10 +372,12 @@ CheckCash::doApply() return optDeliverMin->asset().visit( [&](Issue const&) { return STAmount( - optDeliverMin->asset(), STAmount::cMaxValue / 2, STAmount::cMaxOffset); + optDeliverMin->asset(), + STAmount::kMAX_VALUE / 2, + STAmount::kMAX_OFFSET); }, [&](MPTIssue const&) { - return STAmount(optDeliverMin->asset(), maxMPTokenAmount / 2); + return STAmount(optDeliverMin->asset(), kMAX_MP_TOKEN_AMOUNT / 2); }); }; STAmount const flowDeliver{ @@ -474,7 +476,7 @@ CheckCash::doApply() // Set the trust line limit to the highest possible // value while flow runs. STAmount const bigAmount( - trustLineIssue, STAmount::cMaxValue, STAmount::cMaxOffset); + trustLineIssue, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET); sleTrustLine->at(tweakedLimit) = bigAmount; return std::nullopt; @@ -505,7 +507,7 @@ CheckCash::doApply() return *err; // Make sure the tweaked limits are restored when we leave // scope. - scope_exit const fixup([&psb, &trustLineKey, destLow, &savedLimit]() { + ScopeExit const fixup([&psb, &trustLineKey, destLow, &savedLimit]() { if (trustLineKey) { SF_AMOUNT const& tweakedLimit = destLow ? sfLowLimit : sfHighLimit; @@ -524,7 +526,7 @@ CheckCash::doApply() true, // default path static_cast(optDeliverMin), // partial payment true, // owner pays transfer fee - OfferCrossing::no, + OfferCrossing::No, std::nullopt, sleCheck->getFieldAmount(sfSendMax), std::nullopt, // check does not support domain diff --git a/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp b/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp index 4f1bd80f26..0dd21d3bd5 100644 --- a/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp +++ b/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp @@ -43,7 +43,7 @@ CredentialAccept::preflight(PreflightContext const& ctx) } auto const credType = ctx.tx[sfCredentialType]; - if (credType.empty() || (credType.size() > maxCredentialTypeLength)) + if (credType.empty() || (credType.size() > kMAX_CREDENTIAL_TYPE_LENGTH)) { JLOG(ctx.j.trace()) << "Malformed transaction: invalid size of CredentialType."; return temMALFORMED; diff --git a/src/libxrpl/tx/transactors/credentials/CredentialCreate.cpp b/src/libxrpl/tx/transactors/credentials/CredentialCreate.cpp index 402bddcfdd..e54c48287f 100644 --- a/src/libxrpl/tx/transactors/credentials/CredentialCreate.cpp +++ b/src/libxrpl/tx/transactors/credentials/CredentialCreate.cpp @@ -62,14 +62,14 @@ CredentialCreate::preflight(PreflightContext const& ctx) } auto const uri = tx[~sfURI]; - if (uri && (uri->empty() || (uri->size() > maxCredentialURILength))) + if (uri && (uri->empty() || (uri->size() > kMAX_CREDENTIAL_URI_LENGTH))) { JLOG(j.trace()) << "Malformed transaction: invalid size of URI."; return temMALFORMED; } auto const credType = tx[sfCredentialType]; - if (credType.empty() || (credType.size() > maxCredentialTypeLength)) + if (credType.empty() || (credType.size() > kMAX_CREDENTIAL_TYPE_LENGTH)) { JLOG(j.trace()) << "Malformed transaction: invalid size of CredentialType."; return temMALFORMED; diff --git a/src/libxrpl/tx/transactors/credentials/CredentialDelete.cpp b/src/libxrpl/tx/transactors/credentials/CredentialDelete.cpp index acff3c6aa0..42880bfdf8 100644 --- a/src/libxrpl/tx/transactors/credentials/CredentialDelete.cpp +++ b/src/libxrpl/tx/transactors/credentials/CredentialDelete.cpp @@ -52,7 +52,7 @@ CredentialDelete::preflight(PreflightContext const& ctx) } auto const credType = ctx.tx[sfCredentialType]; - if (credType.empty() || (credType.size() > maxCredentialTypeLength)) + if (credType.empty() || (credType.size() > kMAX_CREDENTIAL_TYPE_LENGTH)) { JLOG(ctx.j.trace()) << "Malformed transaction: invalid size of CredentialType."; return temMALFORMED; diff --git a/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp b/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp index c211231902..baf208a305 100644 --- a/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp +++ b/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp @@ -25,7 +25,7 @@ NotTEC DelegateSet::preflight(PreflightContext const& ctx) { auto const& permissions = ctx.tx.getFieldArray(sfPermissions); - if (permissions.size() > permissionMaxSize) + if (permissions.size() > kPERMISSION_MAX_SIZE) return temARRAY_TOO_LARGE; // can not authorize self diff --git a/src/libxrpl/tx/transactors/dex/AMMBid.cpp b/src/libxrpl/tx/transactors/dex/AMMBid.cpp index 69fd6a651b..d4783c783b 100644 --- a/src/libxrpl/tx/transactors/dex/AMMBid.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMBid.cpp @@ -77,7 +77,7 @@ AMMBid::preflight(PreflightContext const& ctx) if (ctx.tx.isFieldPresent(sfAuthAccounts)) { auto const authAccounts = ctx.tx.getFieldArray(sfAuthAccounts); - if (authAccounts.size() > AUCTION_SLOT_MAX_AUTH_ACCOUNTS) + if (authAccounts.size() > kAUCTION_SLOT_MAX_AUTH_ACCOUNTS) { JLOG(ctx.j.debug()) << "AMM Bid: Invalid number of AuthAccounts."; return temMALFORMED; @@ -113,7 +113,7 @@ AMMBid::preclaim(PreclaimContext const& ctx) } auto const lpTokensBalance = (*ammSle)[sfLPTokenBalance]; - if (lpTokensBalance == beast::zero) + if (lpTokensBalance == beast::kZERO) return tecAMM_EMPTY; if (ctx.tx.isFieldPresent(sfAuthAccounts)) @@ -130,7 +130,7 @@ AMMBid::preclaim(PreclaimContext const& ctx) auto const lpTokens = ammLPHolds(ctx.view, *ammSle, ctx.tx[sfAccount], ctx.j); // Not LP - if (lpTokens == beast::zero) + if (lpTokens == beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Bid: account is not LP."; return tecAMM_INVALID_TOKENS; @@ -177,15 +177,15 @@ AMMBid::preclaim(PreclaimContext const& ctx) } static std::pair -applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Journal j_) +applyBid(ApplyContext& ctx, Sandbox& sb, AccountID const& account, beast::Journal j) { using namespace std::chrono; - auto const ammSle = sb.peek(keylet::amm(ctx_.tx[sfAsset], ctx_.tx[sfAsset2])); + auto const ammSle = sb.peek(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2])); if (!ammSle) return {tecINTERNAL, false}; STAmount const lptAMMBalance = (*ammSle)[sfLPTokenBalance]; - auto const lpTokens = ammLPHolds(sb, *ammSle, account_, ctx_.journal); - auto const& rules = ctx_.view().rules(); + auto const lpTokens = ammLPHolds(sb, *ammSle, account, ctx.journal); + auto const& rules = ctx.view().rules(); if (!rules.enabled(fixInnerObjTemplate)) { if (!ammSle->isFieldPresent(sfAuctionSlot)) @@ -199,14 +199,14 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour } auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot); auto const current = - duration_cast(ctx_.view().header().parentCloseTime.time_since_epoch()).count(); + duration_cast(ctx.view().header().parentCloseTime.time_since_epoch()).count(); // Auction slot discounted fee - auto const discountedFee = (*ammSle)[sfTradingFee] / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION; + auto const discountedFee = (*ammSle)[sfTradingFee] / kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION; auto const tradingFee = getFee((*ammSle)[sfTradingFee]); // Min price - auto const minSlotPrice = lptAMMBalance * tradingFee / AUCTION_SLOT_MIN_FEE_FRACTION; + auto const minSlotPrice = lptAMMBalance * tradingFee / kAUCTION_SLOT_MIN_FEE_FRACTION; - std::uint32_t constexpr tailingSlot = AUCTION_SLOT_TIME_INTERVALS - 1; + std::uint32_t constexpr kTAILING_SLOT = kAUCTION_SLOT_TIME_INTERVALS - 1; // If seated then it is the current slot-holder time slot, otherwise // the auction slot is not owned. Slot range is in {0-19} @@ -216,12 +216,12 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour auto validOwner = [&](AccountID const& account) { // Valid range is 0-19 but the tailing slot pays MinSlotPrice // and doesn't refund so the check is < instead of <= to optimize. - return timeSlot && *timeSlot < tailingSlot && sb.read(keylet::account(account)); + return timeSlot && *timeSlot < kTAILING_SLOT && sb.read(keylet::account(account)); }; auto updateSlot = [&](std::uint32_t fee, Number const& minPrice, Number const& burn) -> TER { - auctionSlot.setAccountID(sfAccount, account_); - auctionSlot.setFieldU32(sfExpiration, current + TOTAL_TIME_SLOT_SECS); + auctionSlot.setAccountID(sfAccount, account); + auctionSlot.setFieldU32(sfExpiration, current + kTOTAL_TIME_SLOT_SECS); if (fee != 0) { auctionSlot.setFieldU16(sfDiscountedFee, fee); @@ -231,9 +231,9 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour auctionSlot.makeFieldAbsent(sfDiscountedFee); } auctionSlot.setFieldAmount(sfPrice, toSTAmount(lpTokens.asset(), minPrice)); - if (ctx_.tx.isFieldPresent(sfAuthAccounts)) + if (ctx.tx.isFieldPresent(sfAuthAccounts)) { - auctionSlot.setFieldArray(sfAuthAccounts, ctx_.tx.getFieldArray(sfAuthAccounts)); + auctionSlot.setFieldArray(sfAuthAccounts, ctx.tx.getFieldArray(sfAuthAccounts)); } else { @@ -246,15 +246,15 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour { // This error case should never occur. // LCOV_EXCL_START - JLOG(ctx_.journal.fatal()) + JLOG(ctx.journal.fatal()) << "AMM Bid: LP Token burn exceeds AMM balance " << burn << " " << lptAMMBalance; return tecINTERNAL; // LCOV_EXCL_STOP } - auto res = redeemIOU(sb, account_, saBurn, lpTokens.get(), ctx_.journal); + auto res = redeemIOU(sb, account, saBurn, lpTokens.get(), ctx.journal); if (!isTesSuccess(res)) { - JLOG(ctx_.journal.debug()) << "AMM Bid: failed to redeem."; + JLOG(ctx.journal.debug()) << "AMM Bid: failed to redeem."; return res; } ammSle->setFieldAmount(sfLPTokenBalance, lptAMMBalance - saBurn); @@ -264,8 +264,8 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour TER res = tesSUCCESS; - auto const bidMin = ctx_.tx[~sfBidMin]; - auto const bidMax = ctx_.tx[~sfBidMax]; + auto const bidMin = ctx.tx[~sfBidMin]; + auto const bidMax = ctx.tx[~sfBidMax]; auto getPayPrice = [&](Number const& computedPrice) -> Expected { auto const payPrice = [&]() -> std::optional { @@ -274,8 +274,8 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour { if (computedPrice <= *bidMax) return std::max(computedPrice, Number(*bidMin)); - JLOG(ctx_.journal.debug()) << "AMM Bid: not in range " << computedPrice << " " - << *bidMin << " " << *bidMax; + JLOG(ctx.journal.debug()) << "AMM Bid: not in range " << computedPrice << " " + << *bidMin << " " << *bidMax; return std::nullopt; } // Bidder pays max(bidPrice, computedPrice) @@ -287,7 +287,7 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour { if (computedPrice <= *bidMax) return computedPrice; - JLOG(ctx_.journal.debug()) + JLOG(ctx.journal.debug()) << "AMM Bid: not in range " << computedPrice << " " << *bidMax; return std::nullopt; } @@ -322,15 +322,15 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour STAmount const pricePurchased = auctionSlot[sfPrice]; XRPL_ASSERT(timeSlot, "xrpl::applyBid : timeSlot is set"); // NOLINTBEGIN(bugprone-unchecked-optional-access) - auto const fractionUsed = (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS; + auto const fractionUsed = (Number(*timeSlot) + 1) / kAUCTION_SLOT_TIME_INTERVALS; auto const fractionRemaining = Number(1) - fractionUsed; auto const computedPrice = [&]() -> Number { - auto const p1_05 = Number(105, -2); + auto const p105 = Number(105, -2); // First interval slot price if (*timeSlot == 0) - return pricePurchased * p1_05 + minSlotPrice; + return pricePurchased * p105 + minSlotPrice; // Other intervals slot price - return pricePurchased * p1_05 * (1 - power(fractionUsed, 60)) + minSlotPrice; + return pricePurchased * p105 * (1 - power(fractionUsed, 60)) + minSlotPrice; }(); // NOLINTEND(bugprone-unchecked-optional-access) @@ -345,19 +345,15 @@ applyBid(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jour if (refund > *payPrice) { // This error case should never occur. - JLOG(ctx_.journal.fatal()) + JLOG(ctx.journal.fatal()) << "AMM Bid: refund exceeds payPrice " << refund << " " << *payPrice; return {tecINTERNAL, false}; } res = accountSend( - sb, - account_, - auctionSlot[sfAccount], - toSTAmount(lpTokens.asset(), refund), - ctx_.journal); + sb, account, auctionSlot[sfAccount], toSTAmount(lpTokens.asset(), refund), ctx.journal); if (!isTesSuccess(res)) { - JLOG(ctx_.journal.debug()) << "AMM Bid: failed to refund."; + JLOG(ctx.journal.debug()) << "AMM Bid: failed to refund."; return {res, false}; } diff --git a/src/libxrpl/tx/transactors/dex/AMMClawback.cpp b/src/libxrpl/tx/transactors/dex/AMMClawback.cpp index 20ec184670..112d290e72 100644 --- a/src/libxrpl/tx/transactors/dex/AMMClawback.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMClawback.cpp @@ -94,7 +94,7 @@ AMMClawback::preflight(PreflightContext const& ctx) return temBAD_AMOUNT; } - if (clawAmount && *clawAmount <= beast::zero) + if (clawAmount && *clawAmount <= beast::kZERO) return temBAD_AMOUNT; return tesSUCCESS; @@ -191,7 +191,7 @@ AMMClawback::applyGuts(Sandbox& sb) { // retrieve LP token balance inside the amendment gate to avoid inconsistent error behavior auto const lpTokenBalance = ammLPHolds(sb, *ammSle, holder, j_); - if (lpTokenBalance == beast::zero) + if (lpTokenBalance == beast::kZERO) return tecAMM_BALANCE; if (auto const res = verifyAndAdjustLPTokenBalance(sb, lpTokenBalance, ammSle, holder); @@ -204,8 +204,8 @@ AMMClawback::applyGuts(Sandbox& sb) *ammSle, asset, asset2, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx_.journal); if (!expected) @@ -220,7 +220,7 @@ AMMClawback::applyGuts(Sandbox& sb) // calling a second time on purpose since `verifyAndAdjustLPTokenBalance` rounds and may adjust // the balance auto const holdLPtokens = ammLPHolds(sb, *ammSle, holder, j_); - if (holdLPtokens == beast::zero) + if (holdLPtokens == beast::kZERO) return tecAMM_BALANCE; if (!clawAmount) @@ -239,8 +239,8 @@ AMMClawback::applyGuts(Sandbox& sb) holdLPtokens, holdLPtokens, 0, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, WithdrawAll::Yes, preFeeBalance_, ctx_.journal); @@ -327,8 +327,8 @@ AMMClawback::equalWithdrawMatchingOneAmount( holdLPtokens, holdLPtokens, 0, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, WithdrawAll::Yes, preFeeBalance_, ctx_.journal); @@ -340,7 +340,7 @@ AMMClawback::equalWithdrawMatchingOneAmount( auto tokensAdj = getRoundedLPTokens(rules, lptAMMBalance, frac, IsDeposit::No); // LCOV_EXCL_START - if (tokensAdj == beast::zero) + if (tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}, STAmount{}, std::nullopt}; // LCOV_EXCL_STOP @@ -360,8 +360,8 @@ AMMClawback::equalWithdrawMatchingOneAmount( lptAMMBalance, tokensAdj, 0, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, WithdrawAll::No, preFeeBalance_, ctx_.journal); @@ -380,8 +380,8 @@ AMMClawback::equalWithdrawMatchingOneAmount( lptAMMBalance, toSTAmount(lptAMMBalance.asset(), lptAMMBalance * frac), 0, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, WithdrawAll::No, preFeeBalance_, ctx_.journal); diff --git a/src/libxrpl/tx/transactors/dex/AMMCreate.cpp b/src/libxrpl/tx/transactors/dex/AMMCreate.cpp index 47363531d4..c90ea0a6ab 100644 --- a/src/libxrpl/tx/transactors/dex/AMMCreate.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMCreate.cpp @@ -76,7 +76,7 @@ AMMCreate::preflight(PreflightContext const& ctx) return err; } - if (ctx.tx[sfTradingFee] > TRADING_FEE_THRESHOLD) + if (ctx.tx[sfTradingFee] > kTRADING_FEE_THRESHOLD) { JLOG(ctx.j.debug()) << "AMM Instance: invalid trading fee."; return temBAD_FEE; @@ -146,7 +146,7 @@ AMMCreate::preclaim(PreclaimContext const& ctx) // Check the reserve for LPToken trustline STAmount const xrpBalance = xrpLiquid(ctx.view, accountID, 1, ctx.j); // Insufficient reserve - if (xrpBalance <= beast::zero) + if (xrpBalance <= beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Instance: insufficient reserves"; return tecINSUF_RESERVE_LINE; @@ -159,8 +159,8 @@ AMMCreate::preclaim(PreclaimContext const& ctx) ctx.view, accountID, amount, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j) < amount; }; @@ -187,7 +187,7 @@ AMMCreate::preclaim(PreclaimContext const& ctx) { if (auto const accountId = pseudoAccountAddress(ctx.view, keylet::amm(amount.asset(), amount2.asset()).key); - accountId == beast::zero) + accountId == beast::kZERO) return terADDRESS_COLLISION; } @@ -236,10 +236,10 @@ AMMCreate::preclaim(PreclaimContext const& ctx) } static std::pair -applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Journal j_) +applyCreate(ApplyContext& ctx, Sandbox& sb, AccountID const& account, beast::Journal j) { - auto const amount = ctx_.tx[sfAmount]; - auto const amount2 = ctx_.tx[sfAmount2]; + auto const amount = ctx.tx[sfAmount]; + auto const amount2 = ctx.tx[sfAmount2]; auto const ammKeylet = keylet::amm(amount.asset(), amount2.asset()); @@ -248,17 +248,17 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J // AMM account already exists (should not happen) if (!maybeAccount) { - JLOG(j_.error()) << "AMM Instance: failed to create pseudo account."; + JLOG(j.error()) << "AMM Instance: failed to create pseudo account."; return {maybeAccount.error(), false}; } - auto& account = *maybeAccount; - auto const accountId = (*account)[sfAccount]; + auto& acc = *maybeAccount; + auto const accountId = (*acc)[sfAccount]; // LP Token already exists. (should not happen) auto const lptIss = ammLPTIssue(amount.asset(), amount2.asset(), accountId); if (sb.read(keylet::line(accountId, lptIss))) { - JLOG(j_.error()) << "AMM Instance: LP Token already exists."; + JLOG(j.error()) << "AMM Instance: LP Token already exists."; return {tecDUPLICATE, false}; } @@ -279,21 +279,21 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J ammSle->setFieldIssue(sfAsset, STIssue{sfAsset, asset1}); ammSle->setFieldIssue(sfAsset2, STIssue{sfAsset2, asset2}); // AMM creator gets the auction slot and the voting slot. - initializeFeeAuctionVote(ctx_.view(), ammSle, account_, lptIss, ctx_.tx[sfTradingFee]); + initializeFeeAuctionVote(ctx.view(), ammSle, account, lptIss, ctx.tx[sfTradingFee]); // Add owner directory to link the root account and AMM object. if (auto ter = dirLink(sb, accountId, ammSle); ter) { - JLOG(j_.debug()) << "AMM Instance: failed to insert owner dir"; + JLOG(j.debug()) << "AMM Instance: failed to insert owner dir"; return {ter, false}; } sb.insert(ammSle); // Send LPT to LP. - auto res = accountSend(sb, accountId, account_, lpTokens, ctx_.journal); + auto res = accountSend(sb, accountId, account, lpTokens, ctx.journal); if (!isTesSuccess(res)) { - JLOG(j_.debug()) << "AMM Instance: failed to send LPT " << lpTokens; + JLOG(j.debug()) << "AMM Instance: failed to send LPT " << lpTokens; return {res, false}; } @@ -306,7 +306,7 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J auto const& mptID = mptIssue.getMptID(); std::uint32_t flags = lsfMPTAMM; if (auto const err = - requireAuth(ctx_.view(), mptIssue, accountId, AuthType::WeakAuth); + requireAuth(ctx.view(), mptIssue, accountId, AuthType::WeakAuth); !isTesSuccess(err)) { if (err == tecNO_AUTH) @@ -324,12 +324,12 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J // Don't adjust AMM owner count. // It's irrelevant for pseudo-account like AMM. return accountSend( - sb, account_, accountId, amount, ctx_.journal, WaiveTransferFee::Yes); + sb, account, accountId, amount, ctx.journal, WaiveTransferFee::Yes); }, // Set AMM flag on AMM trustline [&](Issue const& issue) -> TER { if (auto const res = accountSend( - sb, account_, accountId, amount, ctx_.journal, WaiveTransferFee::Yes)) + sb, account, accountId, amount, ctx.journal, WaiveTransferFee::Yes)) return res; // Set AMM flag on AMM trustline if (!isXRP(amount)) @@ -352,7 +352,7 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J res = sendAndInitTrustOrMPT(amount); if (!isTesSuccess(res)) { - JLOG(j_.debug()) << "AMM Instance: failed to send " << amount; + JLOG(j.debug()) << "AMM Instance: failed to send " << amount; return {res, false}; } @@ -360,17 +360,17 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J res = sendAndInitTrustOrMPT(amount2); if (!isTesSuccess(res)) { - JLOG(j_.debug()) << "AMM Instance: failed to send " << amount2; + JLOG(j.debug()) << "AMM Instance: failed to send " << amount2; return {res, false}; } - JLOG(j_.debug()) << "AMM Instance: success " << accountId << " " << ammKeylet.key << " " - << lpTokens << " " << amount << " " << amount2; + JLOG(j.debug()) << "AMM Instance: success " << accountId << " " << ammKeylet.key << " " + << lpTokens << " " << amount << " " << amount2; auto addOrderBook = [&](Asset const& assetIn, Asset const& assetOut, std::uint64_t uRate) { Book const book{assetIn, assetOut, std::nullopt}; - auto const dir = keylet::quality(keylet::book(book), uRate); + auto const dir = keylet::quality(keylet::kBOOK(book), uRate); if (auto const bookExisted = static_cast(sb.read(dir)); !bookExisted) - ctx_.registry.get().getOrderBookDB().addOrderBook(book); + ctx.registry.get().getOrderBookDB().addOrderBook(book); }; addOrderBook(amount.asset(), amount2.asset(), getRate(amount2, amount)); addOrderBook(amount2.asset(), amount.asset(), getRate(amount, amount2)); diff --git a/src/libxrpl/tx/transactors/dex/AMMDelete.cpp b/src/libxrpl/tx/transactors/dex/AMMDelete.cpp index 6d2c7b07c3..0ca7fd7c34 100644 --- a/src/libxrpl/tx/transactors/dex/AMMDelete.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMDelete.cpp @@ -46,7 +46,7 @@ AMMDelete::preclaim(PreclaimContext const& ctx) } auto const lpTokensBalance = (*ammSle)[sfLPTokenBalance]; - if (lpTokensBalance != beast::zero) + if (lpTokensBalance != beast::kZERO) return tecAMM_NOT_EMPTY; return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/dex/AMMDeposit.cpp b/src/libxrpl/tx/transactors/dex/AMMDeposit.cpp index 344e3535da..d2995c309f 100644 --- a/src/libxrpl/tx/transactors/dex/AMMDeposit.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMDeposit.cpp @@ -124,7 +124,7 @@ AMMDeposit::preflight(PreflightContext const& ctx) return temBAD_AMM_TOKENS; } - if (lpTokens && *lpTokens <= beast::zero) + if (lpTokens && *lpTokens <= beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Deposit: invalid LPTokens"; return temBAD_AMM_TOKENS; @@ -166,7 +166,7 @@ AMMDeposit::preflight(PreflightContext const& ctx) } } - if (tradingFee > TRADING_FEE_THRESHOLD) + if (tradingFee > kTRADING_FEE_THRESHOLD) { JLOG(ctx.j.debug()) << "AMM Deposit: invalid trading fee."; return temBAD_FEE; @@ -192,17 +192,17 @@ AMMDeposit::preclaim(PreclaimContext const& ctx) *ammSle, std::nullopt, std::nullopt, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j); if (!expected) return expected.error(); // LCOV_EXCL_LINE auto const [amountBalance, amount2Balance, lptAMMBalance] = *expected; if ((ctx.tx.getFlags() & tfTwoAssetIfEmpty) != 0u) { - if (lptAMMBalance != beast::zero) + if (lptAMMBalance != beast::kZERO) return tecAMM_NOT_EMPTY; - if (amountBalance != beast::zero || amount2Balance != beast::zero) + if (amountBalance != beast::kZERO || amount2Balance != beast::kZERO) { // LCOV_EXCL_START JLOG(ctx.j.debug()) << "AMM Deposit: tokens balance is not zero."; @@ -212,10 +212,10 @@ AMMDeposit::preclaim(PreclaimContext const& ctx) } else { - if (lptAMMBalance == beast::zero) + if (lptAMMBalance == beast::kZERO) return tecAMM_EMPTY; - if (amountBalance <= beast::zero || amount2Balance <= beast::zero || - lptAMMBalance < beast::zero) + if (amountBalance <= beast::kZERO || amount2Balance <= beast::kZERO || + lptAMMBalance < beast::kZERO) { // LCOV_EXCL_START JLOG(ctx.j.debug()) << "AMM Deposit: reserves or tokens balance is zero."; @@ -246,8 +246,8 @@ AMMDeposit::preclaim(PreclaimContext const& ctx) ctx.view, accountID, deposit, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j) >= deposit ? TER(tesSUCCESS) : tecUNFUNDED_AMM; @@ -357,11 +357,11 @@ AMMDeposit::preclaim(PreclaimContext const& ctx) // Check the reserve for LPToken trustline if not LP. // We checked above but need to check again if depositing IOU only. - if (ammLPHolds(ctx.view, *ammSle, accountID, ctx.j) == beast::zero) + if (ammLPHolds(ctx.view, *ammSle, accountID, ctx.j) == beast::kZERO) { STAmount const xrpBalance = xrpLiquid(ctx.view, accountID, 1, ctx.j); // Insufficient reserve - if (xrpBalance <= beast::zero) + if (xrpBalance <= beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Instance: insufficient reserves"; return tecINSUF_RESERVE_LINE; @@ -395,13 +395,13 @@ AMMDeposit::applyGuts(Sandbox& sb) *ammSle, amount ? amount->asset() : std::optional{}, amount2 ? amount2->asset() : std::optional{}, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx_.journal); if (!expected) return {expected.error(), false}; // LCOV_EXCL_LINE auto const [amountBalance, amount2Balance, lptAMMBalance] = *expected; - auto const tfee = (lptAMMBalance == beast::zero) + auto const tfee = (lptAMMBalance == beast::kZERO) ? ctx_.tx[~sfTradingFee].value_or(0) : getTradingFee(ctx_.view(), *ammSle, account_); @@ -468,12 +468,12 @@ AMMDeposit::applyGuts(Sandbox& sb) if (isTesSuccess(result)) { XRPL_ASSERT( - newLPTokenBalance > beast::zero, + newLPTokenBalance > beast::kZERO, "xrpl::AMMDeposit::applyGuts : valid new LP token balance"); ammSle->setFieldAmount(sfLPTokenBalance, newLPTokenBalance); // LP depositing into AMM empty state gets the auction slot // and the voting - if (lptAMMBalance == beast::zero) + if (lptAMMBalance == beast::kZERO) initializeFeeAuctionVote(sb, ammSle, account_, lptAMMBalance.asset(), tfee); sb.update(ammSle); @@ -513,7 +513,7 @@ AMMDeposit::deposit( // Check account has sufficient funds. // Return true if it does, false otherwise. auto checkBalance = [&](auto const& depositAmount) -> TER { - if (depositAmount <= beast::zero) + if (depositAmount <= beast::kZERO) return temBAD_AMOUNT; if (isXRP(depositAmount)) { @@ -528,8 +528,8 @@ AMMDeposit::deposit( view, account_, depositAmount, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx_.journal) >= depositAmount) { return tesSUCCESS; @@ -547,7 +547,7 @@ AMMDeposit::deposit( tfee, IsDeposit::Yes); - if (lpTokensDepositActual <= beast::zero) + if (lpTokensDepositActual <= beast::kZERO) { JLOG(ctx_.journal.debug()) << "AMM Deposit: adjusted tokens zero"; return {tecAMM_INVALID_TOKENS, STAmount{}}; @@ -642,7 +642,7 @@ AMMDeposit::equalDepositTokens( try { auto const tokensAdj = adjustLPTokensOut(view.rules(), lptAMMBalance, lpTokensDeposit); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; auto const frac = divide(tokensAdj, lptAMMBalance, lptAMMBalance.asset()); // amounts factor in the adjusted tokens @@ -714,7 +714,7 @@ AMMDeposit::equalDepositLimit( { auto frac = Number{amount} / amountBalance; auto tokensAdj = getRoundedLPTokens(view.rules(), lptAMMBalance, frac, IsDeposit::Yes); - if (tokensAdj == beast::zero) + if (tokensAdj == beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -743,7 +743,7 @@ AMMDeposit::equalDepositLimit( } frac = Number{amount2} / amount2Balance; tokensAdj = getRoundedLPTokens(view.rules(), lptAMMBalance, frac, IsDeposit::Yes); - if (tokensAdj == beast::zero) + if (tokensAdj == beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -793,7 +793,7 @@ AMMDeposit::singleDeposit( { auto const tokens = adjustLPTokensOut( view.rules(), lptAMMBalance, lpTokensOut(amountBalance, amount, lptAMMBalance, tfee)); - if (tokens == beast::zero) + if (tokens == beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -805,7 +805,7 @@ AMMDeposit::singleDeposit( // factor in the adjusted tokens auto const [tokensAdj, amountDepositAdj] = adjustAssetInByTokens(view.rules(), amountBalance, amount, lptAMMBalance, tokens, tfee); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // LCOV_EXCL_LINE return deposit( view, @@ -839,7 +839,7 @@ AMMDeposit::singleDepositTokens( std::uint16_t tfee) { auto const tokensAdj = adjustLPTokensOut(view.rules(), lptAMMBalance, lpTokensDeposit); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // the adjusted tokens are factored in auto const amountDeposit = ammAssetIn(amountBalance, lptAMMBalance, tokensAdj, tfee); @@ -894,11 +894,11 @@ AMMDeposit::singleDepositEPrice( STAmount const& ePrice, std::uint16_t tfee) { - if (amount != beast::zero) + if (amount != beast::kZERO) { auto const tokens = adjustLPTokensOut( view.rules(), lptAMMBalance, lpTokensOut(amountBalance, amount, lptAMMBalance, tfee)); - if (tokens <= beast::zero) + if (tokens <= beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -910,7 +910,7 @@ AMMDeposit::singleDepositEPrice( // factor in the adjusted tokens auto const [tokensAdj, amountDepositAdj] = adjustAssetInByTokens(view.rules(), amountBalance, amount, lptAMMBalance, tokens, tfee); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // LCOV_EXCL_LINE auto const ep = Number{amountDepositAdj} / tokensAdj; if (ep <= ePrice) @@ -958,7 +958,7 @@ AMMDeposit::singleDepositEPrice( auto amtProdCb = [&] { return f1 * solveQuadraticEq(a1, b1, c1); }; auto const amountDeposit = getRoundedAsset(view.rules(), amtNoRoundCb, amountBalance, amtProdCb, IsDeposit::Yes); - if (amountDeposit <= beast::zero) + if (amountDeposit <= beast::kZERO) return {tecAMM_FAILED, STAmount{}}; auto tokNoRoundCb = [&] { return amountDeposit / ePrice; }; auto tokProdCb = [&] { return amountDeposit / ePrice; }; @@ -967,7 +967,7 @@ AMMDeposit::singleDepositEPrice( // factor in the adjusted tokens auto const [tokensAdj, amountDepositAdj] = adjustAssetInByTokens( view.rules(), amountBalance, amountDeposit, lptAMMBalance, tokens, tfee); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // LCOV_EXCL_LINE return deposit( diff --git a/src/libxrpl/tx/transactors/dex/AMMVote.cpp b/src/libxrpl/tx/transactors/dex/AMMVote.cpp index e411a3a53a..4ab3653792 100644 --- a/src/libxrpl/tx/transactors/dex/AMMVote.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMVote.cpp @@ -47,7 +47,7 @@ AMMVote::preflight(PreflightContext const& ctx) return res; } - if (ctx.tx[sfTradingFee] > TRADING_FEE_THRESHOLD) + if (ctx.tx[sfTradingFee] > kTRADING_FEE_THRESHOLD) { JLOG(ctx.j.debug()) << "AMM Vote: invalid trading fee."; return temBAD_FEE; @@ -65,12 +65,12 @@ AMMVote::preclaim(PreclaimContext const& ctx) JLOG(ctx.j.debug()) << "AMM Vote: Invalid asset pair."; return terNO_AMM; } - if (ammSle->getFieldAmount(sfLPTokenBalance) == beast::zero) + if (ammSle->getFieldAmount(sfLPTokenBalance) == beast::kZERO) { return tecAMM_EMPTY; } if (auto const lpTokensNew = ammLPHolds(ctx.view, *ammSle, ctx.tx[sfAccount], ctx.j); - lpTokensNew == beast::zero) + lpTokensNew == beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Vote: account is not LP."; return tecAMM_INVALID_TOKENS; @@ -80,14 +80,14 @@ AMMVote::preclaim(PreclaimContext const& ctx) } static std::pair -applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Journal j_) +applyVote(ApplyContext& ctx, Sandbox& sb, AccountID const& account, beast::Journal j) { - auto const feeNew = ctx_.tx[sfTradingFee]; - auto ammSle = sb.peek(keylet::amm(ctx_.tx[sfAsset], ctx_.tx[sfAsset2])); + auto const feeNew = ctx.tx[sfTradingFee]; + auto ammSle = sb.peek(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2])); if (!ammSle) return {tecINTERNAL, false}; STAmount const lptAMMBalance = (*ammSle)[sfLPTokenBalance]; - auto const lpTokensNew = ammLPHolds(sb, *ammSle, account_, ctx_.journal); + auto const lpTokensNew = ammLPHolds(sb, *ammSle, account, ctx.journal); std::optional minTokens; std::size_t minPos{0}; AccountID minAccount{0}; @@ -104,17 +104,17 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou // has the vote entry. for (auto const& entry : ammSle->getFieldArray(sfVoteSlots)) { - auto const account = entry[sfAccount]; - auto lpTokens = ammLPHolds(sb, *ammSle, account, ctx_.journal); - if (lpTokens == beast::zero) + auto const entryAccount = entry[sfAccount]; + auto lpTokens = ammLPHolds(sb, *ammSle, entryAccount, ctx.journal); + if (lpTokens == beast::kZERO) { - JLOG(j_.debug()) << "AMMVote::applyVote, account " << account << " is not LP"; + JLOG(j.debug()) << "AMMVote::applyVote, account " << entryAccount << " is not LP"; continue; } auto feeVal = entry[sfTradingFee]; STObject newEntry = STObject::makeInnerObject(sfVoteEntry); // The account already has the vote entry. - if (account == account_) + if (entryAccount == account) { lpTokens = lpTokensNew; feeVal = feeNew; @@ -123,26 +123,27 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou // Keep running numerator/denominator to calculate the updated fee. num += feeVal * lpTokens; den += lpTokens; - newEntry.setAccountID(sfAccount, account); + newEntry.setAccountID(sfAccount, entryAccount); if (feeVal != 0) newEntry.setFieldU16(sfTradingFee, feeVal); newEntry.setFieldU32( sfVoteWeight, - static_cast(Number(lpTokens) * VOTE_WEIGHT_SCALE_FACTOR / lptAMMBalance)); + static_cast( + Number(lpTokens) * kVOTE_WEIGHT_SCALE_FACTOR / lptAMMBalance)); // Find an entry with the least tokens/fee. Make the order deterministic // if the tokens/fees are equal. if (!minTokens || (lpTokens < *minTokens || (lpTokens == *minTokens && - (feeVal < minFee || (feeVal == minFee && account < minAccount))))) + (feeVal < minFee || (feeVal == minFee && entryAccount < minAccount))))) { minTokens = lpTokens; minPos = updatedVoteSlots.size(); - minAccount = account; + minAccount = entryAccount; minFee = feeVal; } - updatedVoteSlots.push_back(std::move(newEntry)); + updatedVoteSlots.pushBack(std::move(newEntry)); } // The account doesn't have the vote entry. @@ -155,8 +156,8 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou newEntry.setFieldU32( sfVoteWeight, static_cast( - Number(lpTokensNew) * VOTE_WEIGHT_SCALE_FACTOR / lptAMMBalance)); - newEntry.setAccountID(sfAccount, account_); + Number(lpTokensNew) * kVOTE_WEIGHT_SCALE_FACTOR / lptAMMBalance)); + newEntry.setAccountID(sfAccount, account); num += feeNew * lpTokensNew; den += lpTokensNew; if (minPos) @@ -165,12 +166,12 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou } else { - updatedVoteSlots.push_back(std::move(newEntry)); + updatedVoteSlots.pushBack(std::move(newEntry)); } }; // Add new entry if the number of the vote entries // is less than Max. - if (updatedVoteSlots.size() < VOTE_MAX_SLOTS) + if (updatedVoteSlots.size() < kVOTE_MAX_SLOTS) { update(); // Add the entry if the account has more tokens than @@ -182,7 +183,7 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou { auto const entry = updatedVoteSlots.begin() + minPos; // Remove the least token vote entry. - num -= Number((*entry)[~sfTradingFee].value_or(0)) * *minTokens; + num -= Number((*entry)[~sfTradingFee].valueOr(0)) * *minTokens; den -= *minTokens; update(minPos); } @@ -191,13 +192,13 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou // Update anyway to refresh the slots. else { - JLOG(j_.debug()) << "AMMVote::applyVote, insufficient tokens to " - "override other votes"; + JLOG(j.debug()) << "AMMVote::applyVote, insufficient tokens to " + "override other votes"; } } XRPL_ASSERT( - !ctx_.view().rules().enabled(fixInnerObjTemplate) || ammSle->isFieldPresent(sfAuctionSlot), + !ctx.view().rules().enabled(fixInnerObjTemplate) || ammSle->isFieldPresent(sfAuctionSlot), "xrpl::applyVote : has auction slot"); // Update the vote entries and the trading/discounted fee. @@ -208,7 +209,7 @@ applyVote(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::Jou if (ammSle->isFieldPresent(sfAuctionSlot)) { auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot); - if (auto const discountedFee = fee / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION) + if (auto const discountedFee = fee / kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION) { auctionSlot.setFieldU16(sfDiscountedFee, discountedFee); } diff --git a/src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp b/src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp index 6ab78f9cb9..bae9d098a3 100644 --- a/src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp +++ b/src/libxrpl/tx/transactors/dex/AMMWithdraw.cpp @@ -134,7 +134,7 @@ AMMWithdraw::preflight(PreflightContext const& ctx) return temBAD_AMM_TOKENS; } - if (lpTokens && *lpTokens <= beast::zero) + if (lpTokens && *lpTokens <= beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Withdraw: invalid tokens."; return temBAD_AMM_TOKENS; @@ -205,16 +205,16 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx) *ammSle, amount ? amount->asset() : std::optional{}, amount2 ? amount2->asset() : std::optional{}, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j); if (!expected) return expected.error(); auto const [amountBalance, amount2Balance, lptAMMBalance] = *expected; - if (lptAMMBalance == beast::zero) + if (lptAMMBalance == beast::kZERO) return tecAMM_EMPTY; - if (amountBalance <= beast::zero || amount2Balance <= beast::zero || - lptAMMBalance < beast::zero) + if (amountBalance <= beast::kZERO || amount2Balance <= beast::kZERO || + lptAMMBalance < beast::kZERO) { // LCOV_EXCL_START JLOG(ctx.j.debug()) << "AMM Withdraw: reserves or tokens balance is zero."; @@ -273,7 +273,7 @@ AMMWithdraw::preclaim(PreclaimContext const& ctx) auto const lpTokens = ammLPHolds(ctx.view, *ammSle, ctx.tx[sfAccount], ctx.j); auto const lpTokensWithdraw = tokensWithdraw(lpTokens, ctx.tx[~sfLPTokenIn], ctx.tx.getFlags()); - if (lpTokens <= beast::zero) + if (lpTokens <= beast::kZERO) { JLOG(ctx.j.debug()) << "AMM Withdraw: tokens balance is zero."; return tecAMM_BALANCE; @@ -340,8 +340,8 @@ AMMWithdraw::applyGuts(Sandbox& sb) *ammSle, amount ? amount->asset() : std::optional{}, amount2 ? amount2->asset() : std::optional{}, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx_.journal); if (!expected) return {expected.error(), false}; @@ -465,8 +465,8 @@ AMMWithdraw::withdraw( lpTokensAMMBalance, lpTokensWithdraw, tfee, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, isWithdrawAll(ctx_.tx), preFeeBalance_, j_); @@ -517,7 +517,7 @@ AMMWithdraw::withdraw( return std::make_tuple(amountWithdraw, amount2Withdraw, lpTokensWithdraw); }(); - if (lpTokensWithdrawActual <= beast::zero || lpTokensWithdrawActual > lpTokens) + if (lpTokensWithdrawActual <= beast::kZERO || lpTokensWithdrawActual > lpTokens) { JLOG(journal.debug()) << "AMM Withdraw: failed to withdraw, invalid LP tokens: " << lpTokensWithdrawActual << " " << lpTokens << " " @@ -576,10 +576,10 @@ AMMWithdraw::withdraw( // or all balances are non-zero. if (view.rules().enabled(featureMPTokensV2)) { - bool const newBalanceZero = (curBalance - amountWithdrawActual) == beast::zero; + bool const newBalanceZero = (curBalance - amountWithdrawActual) == beast::kZERO; bool const newBalance2Zero = - (curBalance2 - amount2WithdrawActual.value_or(curBalance2.asset())) == beast::zero; - bool const newLPTokensZero = (lpTokensAMMBalance - lpTokensWithdrawActual) == beast::zero; + (curBalance2 - amount2WithdrawActual.value_or(curBalance2.asset())) == beast::kZERO; + bool const newLPTokensZero = (lpTokensAMMBalance - lpTokensWithdrawActual) == beast::kZERO; // newBalance2Zero can be zero if that side of the pool is frozen. // ignore newBalance2Zero if one-sided withdrawal. bool const valid = [&]() { @@ -600,13 +600,13 @@ AMMWithdraw::withdraw( } // Check the reserve in case a trustline or MPT has to be created - bool const enabledFixAMMv1_2 = view.rules().enabled(fixAMMv1_2); + bool const enabledFixAmMv12 = view.rules().enabled(fixAMMv1_2); // If seated after a call to sufficientReserve() then MPToken must be // authorized std::optional mptokenKey; auto sufficientReserve = [&](Asset const& asset) -> TER { mptokenKey = std::nullopt; - if (!enabledFixAMMv1_2 || isXRP(asset)) + if (!enabledFixAmMv12 || isXRP(asset)) return tesSUCCESS; bool const isIssue = asset.holds(); bool const assetNotExists = [&] { @@ -629,11 +629,11 @@ AMMWithdraw::withdraw( // See also TrustSet::doApply() and MPTokenAuthorize::authorize() XRPAmount const reserve( - (ownerCount < 2) ? XRPAmount(beast::zero) + (ownerCount < 2) ? XRPAmount(beast::kZERO) : view.fees().accountReserve(ownerCount + 1)); - auto const balance_ = isIssue ? std::max(priorBalance, balance.xrp()) : priorBalance; - if (balance_ < reserve) + auto const balanceAdj = isIssue ? std::max(priorBalance, balance.xrp()) : priorBalance; + if (balanceAdj < reserve) return tecINSUFFICIENT_RESERVE; // Update owner count. @@ -756,8 +756,8 @@ AMMWithdraw::equalWithdrawTokens( lpTokens, lpTokensWithdraw, tfee, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, isWithdrawAll(ctx_.tx), preFeeBalance_, ctx_.journal); @@ -775,7 +775,7 @@ AMMWithdraw::deleteAMMAccountIfEmpty( { TER ter; bool updateBalance = true; - if (lpTokenBalance == beast::zero) + if (lpTokenBalance == beast::kZERO) { ter = deleteAMMAccount(sb, asset1, asset2, journal); if (!isTesSuccess(ter) && ter != tecINCOMPLETE) @@ -838,7 +838,7 @@ AMMWithdraw::equalWithdrawTokens( auto const tokensAdj = adjustLPTokensIn(view.rules(), lptAMMBalance, lpTokensWithdraw, withdrawAll); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}, STAmount{}, std::nullopt}; // the adjusted tokens are factored in auto const frac = divide(tokensAdj, lptAMMBalance, noIssue()); @@ -850,7 +850,7 @@ AMMWithdraw::equalWithdrawTokens( // of LP tokens is likely too small and results in one-sided pool // withdrawal due to round off. Fail so the user withdraws // more tokens. - if (amountWithdraw == beast::zero || amount2Withdraw == beast::zero) + if (amountWithdraw == beast::kZERO || amount2Withdraw == beast::kZERO) return {tecAMM_FAILED, STAmount{}, STAmount{}, STAmount{}}; return withdraw( @@ -918,7 +918,7 @@ AMMWithdraw::equalWithdrawLimit( { auto frac = Number{amount} / amountBalance; auto tokensAdj = getRoundedLPTokens(view.rules(), lptAMMBalance, frac, IsDeposit::No); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // factor in the adjusted tokens frac = adjustFracByTokens(view.rules(), lptAMMBalance, tokensAdj, frac); @@ -940,7 +940,7 @@ AMMWithdraw::equalWithdrawLimit( frac = Number{amount2} / amount2Balance; auto amountWithdraw = getRoundedAsset(view.rules(), amountBalance, frac, IsDeposit::No); tokensAdj = getRoundedLPTokens(view.rules(), lptAMMBalance, frac, IsDeposit::No); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // LCOV_EXCL_LINE // factor in the adjusted tokens frac = adjustFracByTokens(view.rules(), lptAMMBalance, tokensAdj, frac); @@ -989,7 +989,7 @@ AMMWithdraw::singleWithdraw( lptAMMBalance, lpTokensIn(amountBalance, amount, lptAMMBalance, tfee), isWithdrawAll(ctx_.tx)); - if (tokens == beast::zero) + if (tokens == beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -1001,7 +1001,7 @@ AMMWithdraw::singleWithdraw( // factor in the adjusted tokens auto const [tokensAdj, amountWithdrawAdj] = adjustAssetOutByTokens(view.rules(), amountBalance, amount, lptAMMBalance, tokens, tfee); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // LCOV_EXCL_LINE return withdraw( view, @@ -1038,11 +1038,11 @@ AMMWithdraw::singleWithdrawTokens( { auto const tokensAdj = adjustLPTokensIn(view.rules(), lptAMMBalance, lpTokensWithdraw, isWithdrawAll(ctx_.tx)); - if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::zero) + if (view.rules().enabled(fixAMMv1_3) && tokensAdj == beast::kZERO) return {tecAMM_INVALID_TOKENS, STAmount{}}; // the adjusted tokens are factored in auto const amountWithdraw = ammAssetOut(amountBalance, lptAMMBalance, tokensAdj, tfee); - if (amount == beast::zero || amountWithdraw >= amount) + if (amount == beast::kZERO || amountWithdraw >= amount) { return withdraw( view, @@ -1107,7 +1107,7 @@ AMMWithdraw::singleWithdrawEPrice( auto tokProdCb = [&] { return (lptAMMBalance + ae * (f - 2)) / (lptAMMBalance * f - ae); }; auto const tokensAdj = getRoundedLPTokens(view.rules(), tokNoRoundCb, lptAMMBalance, tokProdCb, IsDeposit::No); - if (tokensAdj <= beast::zero) + if (tokensAdj <= beast::kZERO) { if (!view.rules().enabled(fixAMMv1_3)) { @@ -1121,7 +1121,7 @@ AMMWithdraw::singleWithdrawEPrice( // the adjusted tokens are factored in auto const amountWithdraw = getRoundedAsset(view.rules(), amtNoRoundCb, amount, amtProdCb, IsDeposit::No); - if (amount == beast::zero || amountWithdraw >= amount) + if (amount == beast::kZERO || amountWithdraw >= amount) { return withdraw( view, diff --git a/src/libxrpl/tx/transactors/dex/OfferCreate.cpp b/src/libxrpl/tx/transactors/dex/OfferCreate.cpp index 1ce48145f3..b69ed766c5 100644 --- a/src/libxrpl/tx/transactors/dex/OfferCreate.cpp +++ b/src/libxrpl/tx/transactors/dex/OfferCreate.cpp @@ -57,7 +57,7 @@ OfferCreate::makeTxConsequences(PreflightContext const& ctx) { auto calculateMaxXRPSpend = [](STTx const& tx) -> XRPAmount { auto const& amount{tx[sfTakerGets]}; - return amount.native() ? amount.xrp() : beast::zero; + return amount.native() ? amount.xrp() : beast::kZERO; }; return TxConsequences{ctx.tx, calculateMaxXRPSpend(ctx.tx)}; @@ -130,7 +130,7 @@ OfferCreate::preflight(PreflightContext const& ctx) JLOG(j.debug()) << "Malformed offer: redundant (XRP for XRP)"; return temBAD_OFFER; } - if (saTakerPays <= beast::zero || saTakerGets <= beast::zero) + if (saTakerPays <= beast::kZERO || saTakerGets <= beast::kZERO) { JLOG(j.debug()) << "Malformed offer: bad amount"; return temBAD_OFFER; @@ -196,9 +196,9 @@ OfferCreate::preclaim(PreclaimContext const& ctx) ctx.view, id, saTakerGets, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, - viewJ) <= beast::zero) + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, + viewJ) <= beast::kZERO) { JLOG(ctx.j.debug()) << "delay: Offers must be at least partially funded."; return tecUNFUNDED_OFFER; @@ -262,7 +262,7 @@ OfferCreate::checkAcceptAsset( JLOG(j.debug()) << "delay: can't receive IOUs from non-existent issuer: " << to_string(asset.getIssuer()); - return ((flags & tapRETRY) != 0u) ? TER{terNO_ACCOUNT} : TER{tecNO_ISSUER}; + return ((flags & TapRetry) != 0u) ? TER{terNO_ACCOUNT} : TER{tecNO_ISSUER}; } // An account cannot create a trustline to itself, so no line can exist @@ -280,24 +280,24 @@ OfferCreate::checkAcceptAsset( if (!trustLine) { - return ((flags & tapRETRY) != 0u) ? TER{terNO_LINE} : TER{tecNO_LINE}; + return ((flags & TapRetry) != 0u) ? TER{terNO_LINE} : TER{tecNO_LINE}; } // Entries have a canonical representation, determined by a // lexicographical "greater than" comparison employing // strict weak ordering. Determine which entry we need to // access. - bool const canonical_gt(id > issuer); + bool const canonicalGt(id > issuer); - bool const is_authorized( - ((*trustLine)[sfFlags] & (canonical_gt ? lsfLowAuth : lsfHighAuth)) != 0u); + bool const isAuthorized( + ((*trustLine)[sfFlags] & (canonicalGt ? lsfLowAuth : lsfHighAuth)) != 0u); - if (!is_authorized) + if (!isAuthorized) { JLOG(j.debug()) << "delay: can't receive IOUs from " "issuer without auth."; - return ((flags & tapRETRY) != 0u) ? TER{terNO_AUTH} : TER{tecNO_AUTH}; + return ((flags & TapRetry) != 0u) ? TER{terNO_AUTH} : TER{tecNO_AUTH}; } } @@ -346,13 +346,13 @@ OfferCreate::flowCross( psb, account_, takerAmount.in, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, j_); // Allow unfunded MPT issuer auto const disallowUnfunded = !inStartBalance.holds() || inStartBalance.getIssuer() != account_; - if (disallowUnfunded && inStartBalance <= beast::zero) + if (disallowUnfunded && inStartBalance <= beast::kZERO) { // The account balance can't cover even part of the offer. JLOG(j_.debug()) << "Not crossing: taker is unfunded."; @@ -396,16 +396,16 @@ OfferCreate::flowCross( if (!takerAmount.in.native() && !takerAmount.out.native()) { STPath path; - path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt); - paths.emplace_back(std::move(path)); + path.emplaceBack(std::nullopt, xrpCurrency(), std::nullopt); + paths.emplaceBack(std::move(path)); } // Special handling for the tfSell flag. STAmount deliver = takerAmount.out; auto const& deliverAsset = deliver.asset(); - OfferCrossing offerCrossing = OfferCrossing::yes; + OfferCrossing offerCrossing = OfferCrossing::Yes; if ((txFlags & tfSell) != 0u) { - offerCrossing = OfferCrossing::sell; + offerCrossing = OfferCrossing::Sell; // We are selling, so we will accept *more* than the offer // specified. Since we don't know how much they might offer, // we allow delivery of the largest possible amount. @@ -413,7 +413,7 @@ OfferCreate::flowCross( [&](Issue const& issue) { if (issue.native()) { - deliver = STAmount{STAmount::cMaxNative}; + deliver = STAmount{STAmount::kMAX_NATIVE}; } // We can't use the maximum possible currency here because // there might be a gateway transfer rate to account for. @@ -422,10 +422,12 @@ OfferCreate::flowCross( else { deliver = - STAmount{deliverAsset, STAmount::cMaxValue / 2, STAmount::cMaxOffset}; + STAmount{deliverAsset, STAmount::kMAX_VALUE / 2, STAmount::kMAX_OFFSET}; } }, - [&](MPTIssue const&) { deliver = STAmount{deliverAsset, maxMPTokenAmount / 2}; }); + [&](MPTIssue const&) { + deliver = STAmount{deliverAsset, kMAX_MP_TOKEN_AMOUNT / 2}; + }); } // Call the payment engine's flow() to do the actual work. @@ -461,11 +463,11 @@ OfferCreate::flowCross( psb, account_, takerAmount.in, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, j_); - if (disallowUnfunded && takerInBalance <= beast::zero) + if (disallowUnfunded && takerInBalance <= beast::kZERO) { // If offer crossing exhausted the account's funds don't // create the offer. @@ -496,8 +498,8 @@ OfferCreate::flowCross( afterCross.in -= nonGatewayAmountIn; // It's possible that the divRound will cause our subtract - // to go slightly negative. So limit afterCross.in to zero. - if (afterCross.in < beast::zero) + // to go slightly negative. So limit afterCross.in to beast::kZERO. + if (afterCross.in < beast::kZERO) { // We should verify that the difference *is* small, but // what is a good threshold to check? @@ -514,9 +516,9 @@ OfferCreate::flowCross( // Quality. afterCross.out -= result.actualAmountOut; XRPL_ASSERT( - afterCross.out >= beast::zero, + afterCross.out >= beast::kZERO, "xrpl::OfferCreate::flowCross : minimum offer"); - if (afterCross.out < beast::zero) + if (afterCross.out < beast::kZERO) afterCross.out.clear(); afterCross.in = mulRound(afterCross.out, rate, takerAmount.in.asset(), true); } @@ -534,7 +536,7 @@ OfferCreate::flowCross( } std::string -OfferCreate::format_amount(STAmount const& amount) +OfferCreate::formatAmount(STAmount const& amount) { std::string txt = amount.getText(); txt += "/"; @@ -562,7 +564,7 @@ OfferCreate::applyHybrid( // if offer is hybrid, need to also place into open offer dir Book const book{saTakerPays.asset(), saTakerGets.asset(), std::nullopt}; - auto dir = keylet::quality(keylet::book(book), getRate(saTakerGets, saTakerPays)); + auto dir = keylet::quality(keylet::kBOOK(book), getRate(saTakerGets, saTakerPays)); bool const bookExists = sb.exists(dir); auto const bookNode = sb.dirAppend(dir, offerKey, [&](SLE::ref sle) { @@ -581,7 +583,7 @@ OfferCreate::applyHybrid( auto bookInfo = STObject::makeInnerObject(sfBook); bookInfo.setFieldH256(sfBookDirectory, dir.key); bookInfo.setFieldU64(sfBookNode, *bookNode); - bookArr.push_back(std::move(bookInfo)); + bookArr.pushBack(std::move(bookInfo)); if (!bookExists) ctx_.registry.get().getOrderBookDB().addOrderBook(book); @@ -593,7 +595,7 @@ OfferCreate::applyHybrid( std::pair OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) { - using beast::zero; + using beast::kZERO; std::uint32_t const uTxFlags = ctx_.tx.getFlags(); @@ -654,7 +656,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) auto const& uPaysIssuerID = saTakerPays.getIssuer(); auto const& uGetsIssuerID = saTakerGets.getIssuer(); - std::uint8_t uTickSize = Quality::maxTickSize; + std::uint8_t uTickSize = Quality::kMAX_TICK_SIZE; // Not XRP or MPT if (!saTakerPays.integral()) { @@ -669,7 +671,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) if (sle && sle->isFieldPresent(sfTickSize)) uTickSize = std::min(uTickSize, (*sle)[sfTickSize]); } - if (uTickSize < Quality::maxTickSize) + if (uTickSize < Quality::kMAX_TICK_SIZE) { auto const rate = Quality{saTakerGets, saTakerPays}.round(uTickSize).rate(); @@ -705,18 +707,18 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) if (auto stream = j_.trace()) { stream << " mode: " << (bPassive ? "passive " : "") << (bSell ? "sell" : "buy"); - stream << " in: " << format_amount(takerAmount.in); - stream << " out: " << format_amount(takerAmount.out); + stream << " in: " << formatAmount(takerAmount.in); + stream << " out: " << formatAmount(takerAmount.out); } // The amount of the offer that is unfilled after crossing has been // performed. It may be equal to the original amount (didn't cross), // empty (fully crossed), or something in-between. - Amounts place_offer; + Amounts placeOffer; PaymentSandbox psbFlow{&sb}; PaymentSandbox psbCancelFlow{&sbCancel}; - std::tie(result, place_offer) = flowCross(psbFlow, psbCancelFlow, takerAmount, domainID); + std::tie(result, placeOffer) = flowCross(psbFlow, psbCancelFlow, takerAmount, domainID); psbFlow.apply(sb); psbCancelFlow.apply(sbCancel); @@ -730,8 +732,8 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) if (auto stream = j_.trace()) { stream << "Cross result: " << transToken(result); - stream << " in: " << format_amount(place_offer.in); - stream << " out: " << format_amount(place_offer.out); + stream << " in: " << formatAmount(placeOffer.in); + stream << " out: " << formatAmount(placeOffer.out); } if (result == tecFAILED_PROCESSING && sb.open()) @@ -744,26 +746,26 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) } XRPL_ASSERT( - saTakerGets.asset() == place_offer.in.asset(), + saTakerGets.asset() == placeOffer.in.asset(), "xrpl::OfferCreate::applyGuts : taker gets issue match"); XRPL_ASSERT( - saTakerPays.asset() == place_offer.out.asset(), + saTakerPays.asset() == placeOffer.out.asset(), "xrpl::OfferCreate::applyGuts : taker pays issue match"); - if (takerAmount != place_offer) + if (takerAmount != placeOffer) crossed = true; // The offer that we need to place after offer crossing should // never be negative. If it is, something went very very wrong. - if (place_offer.in < zero || place_offer.out < zero) + if (placeOffer.in < kZERO || placeOffer.out < kZERO) { JLOG(j_.fatal()) << "Cross left offer negative!" - << " in: " << format_amount(place_offer.in) - << " out: " << format_amount(place_offer.out); + << " in: " << formatAmount(placeOffer.in) + << " out: " << formatAmount(placeOffer.out); return {tefINTERNAL, true}; } - if (place_offer.in == zero || place_offer.out == zero) + if (placeOffer.in == kZERO || placeOffer.out == kZERO) { JLOG(j_.debug()) << "Offer fully crossed!"; return {result, true}; @@ -772,12 +774,12 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) // We now need to adjust the offer to reflect the amount left after // crossing. We reverse in and out here, since during crossing we // were the taker. - saTakerPays = place_offer.out; - saTakerGets = place_offer.in; + saTakerPays = placeOffer.out; + saTakerGets = placeOffer.in; } XRPL_ASSERT( - saTakerPays > zero && saTakerGets > zero, + saTakerPays > beast::kZERO && saTakerGets > beast::kZERO, "xrpl::OfferCreate::applyGuts : taker pays and gets positive"); if (!isTesSuccess(result)) @@ -842,11 +844,11 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) } // We need to place the remainder of the offer into its order book. - auto const offer_index = keylet::offer(account_, offerSequence); + auto const offerIndex = keylet::offer(account_, offerSequence); // Add offer to owner's directory. auto const ownerNode = - sb.dirInsert(keylet::ownerDir(account_), offer_index, describeOwnerDir(account_)); + sb.dirInsert(keylet::ownerDir(account_), offerIndex, describeOwnerDir(account_)); if (!ownerNode) { @@ -876,7 +878,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) // Hybrid domain offer - BookDirectory points to domain directory, // and AdditionalBooks field stores one entry that points to the open // directory - auto dir = keylet::quality(keylet::book(book), uRate); + auto dir = keylet::quality(keylet::kBOOK(book), uRate); bool const bookExisted = static_cast(sb.peek(dir)); auto setBookDir = [&](SLE::ref sle, std::optional const& maybeDomain) { @@ -897,7 +899,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) sle->setFieldH256(sfDomainID, *maybeDomain); }; - auto const bookNode = sb.dirAppend(dir, offer_index, [&](SLE::ref sle) { + auto const bookNode = sb.dirAppend(dir, offerIndex, [&](SLE::ref sle) { // sets domainID on book directory if it's a domain offer setBookDir(sle, domainID); }); @@ -910,7 +912,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) // LCOV_EXCL_STOP } - auto sleOffer = std::make_shared(offer_index); + auto sleOffer = std::make_shared(offerIndex); sleOffer->setAccountID(sfAccount, account_); sleOffer->setFieldU32(sfSequence, offerSequence); sleOffer->setFieldH256(sfBookDirectory, dir.key); @@ -931,7 +933,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel) if (bHybrid) { auto const res = - applyHybrid(sb, sleOffer, offer_index, saTakerPays, saTakerGets, setBookDir); + applyHybrid(sb, sleOffer, offerIndex, saTakerPays, saTakerGets, setBookDir); if (!isTesSuccess(res)) return {res, true}; // LCOV_EXCL_LINE } diff --git a/src/libxrpl/tx/transactors/did/DIDSet.cpp b/src/libxrpl/tx/transactors/did/DIDSet.cpp index 3aa9966570..69bb9dd839 100644 --- a/src/libxrpl/tx/transactors/did/DIDSet.cpp +++ b/src/libxrpl/tx/transactors/did/DIDSet.cpp @@ -55,8 +55,9 @@ DIDSet::preflight(PreflightContext const& ctx) return false; }; - if (isTooLong(sfURI, maxDIDURILength) || isTooLong(sfDIDDocument, maxDIDDocumentLength) || - isTooLong(sfData, maxDIDDataLength)) + if (isTooLong(sfURI, kMAX_DIDURI_LENGTH) || + isTooLong(sfDIDDocument, kMAX_DID_DOCUMENT_LENGTH) || + isTooLong(sfData, kMAX_DID_DATA_LENGTH)) return temMALFORMED; return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp b/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp index edc07fa0f7..9a48123201 100644 --- a/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp +++ b/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp @@ -183,7 +183,7 @@ EscrowCancel::doApply() [&](T const&) { return escrowUnlockApplyHelper( ctx_.view(), - parityRate, + kPARITY_RATE, slep, preFeeBalance_, amount, diff --git a/src/libxrpl/tx/transactors/escrow/EscrowCreate.cpp b/src/libxrpl/tx/transactors/escrow/EscrowCreate.cpp index c112d3b349..d5bbe17325 100644 --- a/src/libxrpl/tx/transactors/escrow/EscrowCreate.cpp +++ b/src/libxrpl/tx/transactors/escrow/EscrowCreate.cpp @@ -78,7 +78,7 @@ TxConsequences EscrowCreate::makeTxConsequences(PreflightContext const& ctx) { auto const amount = ctx.tx[sfAmount]; - return TxConsequences{ctx.tx, isXRP(amount) ? amount.xrp() : beast::zero}; + return TxConsequences{ctx.tx, isXRP(amount) ? amount.xrp() : beast::kZERO}; } template @@ -90,7 +90,7 @@ NotTEC escrowCreatePreflightHelper(PreflightContext const& ctx) { STAmount const amount = ctx.tx[sfAmount]; - if (amount.native() || amount <= beast::zero) + if (amount.native() || amount <= beast::kZERO) return temBAD_AMOUNT; if (badCurrency() == amount.get().currency) @@ -107,7 +107,7 @@ escrowCreatePreflightHelper(PreflightContext const& ctx) return temDISABLED; auto const amount = ctx.tx[sfAmount]; - if (amount.native() || amount.mpt() > MPTAmount{maxMPTokenAmount} || amount <= beast::zero) + if (amount.native() || amount.mpt() > MPTAmount{kMAX_MP_TOKEN_AMOUNT} || amount <= beast::kZERO) return temBAD_AMOUNT; return tesSUCCESS; @@ -130,7 +130,7 @@ EscrowCreate::preflight(PreflightContext const& ctx) } else { - if (amount <= beast::zero) + if (amount <= beast::kZERO) return temBAD_AMOUNT; } @@ -205,11 +205,11 @@ escrowCreatePreclaimHelper( STAmount const balance = (*sleRippleState)[sfBalance]; // If balance is positive, issuer must have higher address than account - if (balance > beast::zero && issuer < account) + if (balance > beast::kZERO && issuer < account) return tecNO_PERMISSION; // LCOV_EXCL_LINE // If balance is negative, issuer must have lower address than account - if (balance < beast::zero && issuer > account) + if (balance < beast::kZERO && issuer > account) return tecNO_PERMISSION; // LCOV_EXCL_LINE // If the issuer has requireAuth set, check if the account is authorized @@ -229,10 +229,10 @@ escrowCreatePreclaimHelper( return tecFROZEN; STAmount const spendableAmount = accountHolds( - ctx.view, account, issue.currency, issuer, FreezeHandling::fhIGNORE_FREEZE, ctx.j); + ctx.view, account, issue.currency, issuer, FreezeHandling::IgnoreFreeze, ctx.j); // If the balance is less than or equal to 0, return tecINSUFFICIENT_FUNDS - if (spendableAmount <= beast::zero) + if (spendableAmount <= beast::kZERO) return tecINSUFFICIENT_FUNDS; // If the spendable amount is less than the amount, return @@ -308,12 +308,12 @@ escrowCreatePreclaimHelper( ctx.view, account, amount.get(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j); // If the balance is less than or equal to 0, return tecINSUFFICIENT_FUNDS - if (spendableAmount <= beast::zero) + if (spendableAmount <= beast::kZERO) return tecINSUFFICIENT_FUNDS; // If the spendable amount is less than the amount, return @@ -467,7 +467,7 @@ EscrowCreate::doApply() if (ctx_.view().rules().enabled(featureTokenEscrow) && !isXRP(amount)) { auto const xferRate = transferRate(ctx_.view(), amount); - if (xferRate != parityRate) + if (xferRate != kPARITY_RATE) (*slep)[sfTransferRate] = xferRate.value; } diff --git a/src/libxrpl/tx/transactors/escrow/EscrowFinish.cpp b/src/libxrpl/tx/transactors/escrow/EscrowFinish.cpp index c8697fbaa8..116466a1a3 100644 --- a/src/libxrpl/tx/transactors/escrow/EscrowFinish.cpp +++ b/src/libxrpl/tx/transactors/escrow/EscrowFinish.cpp @@ -39,8 +39,8 @@ namespace xrpl { // During an EscrowFinish, the transaction must specify both // a condition and a fulfillment. We track whether that // fulfillment matches and validates the condition. -constexpr HashRouterFlags SF_CF_INVALID = HashRouterFlags::PRIVATE5; -constexpr HashRouterFlags SF_CF_VALID = HashRouterFlags::PRIVATE6; +constexpr HashRouterFlags kSF_CF_INVALID = HashRouterFlags::PRIVATE5; +constexpr HashRouterFlags kSF_CF_VALID = HashRouterFlags::PRIVATE6; //------------------------------------------------------------------------------ @@ -98,15 +98,15 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx) // If we haven't checked the condition, check it // now. Whether it passes or not isn't important // in preflight. - if (!any(flags & (SF_CF_INVALID | SF_CF_VALID))) + if (!any(flags & (kSF_CF_INVALID | kSF_CF_VALID))) { if (checkCondition(*fb, *cb)) { - router.setFlags(id, SF_CF_VALID); + router.setFlags(id, kSF_CF_VALID); } else { - router.setFlags(id, SF_CF_INVALID); + router.setFlags(id, kSF_CF_INVALID); } } } @@ -261,7 +261,7 @@ EscrowFinish::doApply() // It's unlikely that the results of the check will // expire from the hash router, but if it happens, // simply re-run the check. - if (cb && !any(flags & (SF_CF_INVALID | SF_CF_VALID))) + if (cb && !any(flags & (kSF_CF_INVALID | kSF_CF_VALID))) { // LCOV_EXCL_START auto const fb = ctx_.tx[~sfFulfillment]; @@ -271,11 +271,11 @@ EscrowFinish::doApply() if (checkCondition(*fb, *cb)) { - flags = SF_CF_VALID; + flags = kSF_CF_VALID; } else { - flags = SF_CF_INVALID; + flags = kSF_CF_INVALID; } ctx_.registry.get().getHashRouter().setFlags(id, flags); @@ -284,7 +284,7 @@ EscrowFinish::doApply() // If the check failed, then simply return an error // and don't look at anything else. - if (any(flags & SF_CF_INVALID)) + if (any(flags & kSF_CF_INVALID)) return tecCRYPTOCONDITION_ERROR; // Check against condition in the ledger entry: @@ -353,7 +353,7 @@ EscrowFinish::doApply() Rate lockedRate = slep->isFieldPresent(sfTransferRate) ? xrpl::Rate(slep->getFieldU32(sfTransferRate)) - : parityRate; + : kPARITY_RATE; auto const issuer = amount.getIssuer(); bool const createAsset = destID == account_; if (auto const ret = std::visit( diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverClawback.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverClawback.cpp index 6dc57479e6..14bc5f7a51 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverClawback.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverClawback.cpp @@ -48,7 +48,7 @@ LoanBrokerCoverClawback::preflight(PreflightContext const& ctx) if (!brokerID && !amount) return temINVALID; - if (brokerID && *brokerID == beast::zero) + if (brokerID && *brokerID == beast::kZERO) return temINVALID; if (amount) @@ -58,7 +58,7 @@ LoanBrokerCoverClawback::preflight(PreflightContext const& ctx) return temBAD_AMOUNT; // Zero is OK, and indicates "take it all" (down to the minimum cover) - if (*amount < beast::zero) + if (*amount < beast::kZERO) return temBAD_AMOUNT; // This should be redundant @@ -75,7 +75,7 @@ LoanBrokerCoverClawback::preflight(PreflightContext const& ctx) // broker's pseudo-account, but we don't know yet whether it is, so // use a generic placeholder name. auto const holder = amount->getIssuer(); - if (holder == account || holder == beast::zero) + if (holder == account || holder == beast::kZERO) return temINVALID; } } @@ -164,20 +164,20 @@ determineClawAmount( { auto const maxClawAmount = [&]() { // Always round the minimum required up - NumberRoundModeGuard const mg1(Number::rounding_mode::upward); + NumberRoundModeGuard const mg1(Number::RoundingMode::Upward); auto const minRequiredCover = tenthBipsOfValue(sleBroker[sfDebtTotal], TenthBips32(sleBroker[sfCoverRateMinimum])); // The subtraction probably won't round, but round down if it does. - NumberRoundModeGuard const mg2(Number::rounding_mode::downward); + NumberRoundModeGuard const mg2(Number::RoundingMode::Downward); return sleBroker[sfCoverAvailable] - minRequiredCover; }(); - if (maxClawAmount <= beast::zero) + if (maxClawAmount <= beast::kZERO) return Unexpected(tecINSUFFICIENT_FUNDS); // Use the vaultAsset here, because it will be the right type in all // circumstances. The amount may be an IOU indicating the pseudo-account's // asset, which is correct, but not what is needed here. - if (!amount || *amount == beast::zero) + if (!amount || *amount == beast::kZERO) return STAmount{vaultAsset, maxClawAmount}; Number const magnitude{*amount}; if (magnitude > maxClawAmount) @@ -298,8 +298,8 @@ LoanBrokerCoverClawback::preclaim(PreclaimContext const& ctx) ctx.view, brokerPseudoAccountID, vaultAsset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j) < clawAmount) return tecINTERNAL; // tecINSUFFICIENT_FUNDS; LCOV_EXCL_LINE diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverDeposit.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverDeposit.cpp index 9b43269ec3..a8fa91b648 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverDeposit.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverDeposit.cpp @@ -27,11 +27,11 @@ LoanBrokerCoverDeposit::checkExtraFeatures(PreflightContext const& ctx) NotTEC LoanBrokerCoverDeposit::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanBrokerID] == beast::zero) + if (ctx.tx[sfLoanBrokerID] == beast::kZERO) return temINVALID; auto const dstAmount = ctx.tx[sfAmount]; - if (dstAmount <= beast::zero) + if (dstAmount <= beast::kZERO) return temBAD_AMOUNT; if (!isLegalNet(dstAmount)) @@ -91,10 +91,10 @@ LoanBrokerCoverDeposit::preclaim(PreclaimContext const& ctx) ctx.view, account, vaultAsset, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j, - SpendableHandling::shFULL_BALANCE) < amount) + SpendableHandling::FullBalance) < amount) return tecINSUFFICIENT_FUNDS; return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.cpp index 06f2e518ab..ca4136be0a 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.cpp @@ -32,11 +32,11 @@ LoanBrokerCoverWithdraw::checkExtraFeatures(PreflightContext const& ctx) NotTEC LoanBrokerCoverWithdraw::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanBrokerID] == beast::zero) + if (ctx.tx[sfLoanBrokerID] == beast::kZERO) return temINVALID; auto const dstAmount = ctx.tx[sfAmount]; - if (dstAmount <= beast::zero) + if (dstAmount <= beast::kZERO) return temBAD_AMOUNT; if (!isLegalNet(dstAmount)) @@ -44,7 +44,7 @@ LoanBrokerCoverWithdraw::preflight(PreflightContext const& ctx) if (auto const destination = ctx.tx[~sfDestination]) { - if (*destination == beast::zero) + if (*destination == beast::kZERO) { return temMALFORMED; } @@ -133,7 +133,7 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx) auto const minimumCover = [&]() { // Always round the minimum required up. // Applies to `tenthBipsOfValue` as well as `roundToAsset`. - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); return roundToAsset( vaultAsset, tenthBipsOfValue(currentDebtTotal, TenthBips32(sleBroker->at(sfCoverRateMinimum))), @@ -148,8 +148,8 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx) ctx.view, pseudoAccountID, vaultAsset, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j) < amount) return tecINSUFFICIENT_FUNDS; diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp index 8343b6e931..0d6d6e6cd6 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerDelete.cpp @@ -30,7 +30,7 @@ LoanBrokerDelete::checkExtraFeatures(PreflightContext const& ctx) NotTEC LoanBrokerDelete::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanBrokerID] == beast::zero) + if (ctx.tx[sfLoanBrokerID] == beast::kZERO) return temINVALID; return tesSUCCESS; @@ -75,16 +75,16 @@ LoanBrokerDelete::preclaim(PreclaimContext const& ctx) Asset const asset = vault->at(sfAsset); - if (auto const debtTotal = sleBroker->at(sfDebtTotal); debtTotal != beast::zero) + if (auto const debtTotal = sleBroker->at(sfDebtTotal); debtTotal != beast::kZERO) { // Any remaining debt should have been wiped out by the last Loan // Delete. This check is purely defensive. auto const scale = getAssetsTotalScale(vault); auto const rounded = - roundToAsset(asset, debtTotal, scale, Number::rounding_mode::towards_zero); + roundToAsset(asset, debtTotal, scale, Number::RoundingMode::TowardsZero); - if (rounded != beast::zero) + if (rounded != beast::kZERO) { // LCOV_EXCL_START JLOG(ctx.j.warn()) << "LoanBrokerDelete: Debt total is " << debtTotal @@ -97,7 +97,7 @@ LoanBrokerDelete::preclaim(PreclaimContext const& ctx) auto const coverAvailable = STAmount{asset, sleBroker->at(sfCoverAvailable)}; // If there are assets in the cover, broker will receive them on deletion. // So we need to check if the broker owner is deep frozen for that asset. - if (coverAvailable > beast::zero) + if (coverAvailable > beast::kZERO) { if (auto const ret = checkDeepFrozen(ctx.view, brokerOwner, asset)) { diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp index 561890abbf..bf00a344a7 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp @@ -38,15 +38,15 @@ LoanBrokerSet::preflight(PreflightContext const& ctx) auto const& tx = ctx.tx; if (auto const data = tx[~sfData]; - data && !data->empty() && !validDataLength(tx[~sfData], maxDataPayloadLength)) + data && !data->empty() && !validDataLength(tx[~sfData], kMAX_DATA_PAYLOAD_LENGTH)) return temINVALID; - if (!validNumericRange(tx[~sfManagementFeeRate], maxManagementFeeRate)) + if (!validNumericRange(tx[~sfManagementFeeRate], kMAX_MANAGEMENT_FEE_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfCoverRateMinimum], maxCoverRate)) + if (!validNumericRange(tx[~sfCoverRateMinimum], kMAX_COVER_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfCoverRateLiquidation], maxCoverRate)) + if (!validNumericRange(tx[~sfCoverRateLiquidation], kMAX_COVER_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfDebtMaximum], Number(maxMPTokenAmount), Number(0))) + if (!validNumericRange(tx[~sfDebtMaximum], Number(kMAX_MP_TOKEN_AMOUNT), Number(0))) return temINVALID; if (tx.isFieldPresent(sfLoanBrokerID)) @@ -57,13 +57,13 @@ LoanBrokerSet::preflight(PreflightContext const& ctx) tx.isFieldPresent(sfCoverRateLiquidation)) return temINVALID; - if (tx[sfLoanBrokerID] == beast::zero) + if (tx[sfLoanBrokerID] == beast::kZERO) return temINVALID; } if (auto const vaultID = tx.at(~sfVaultID)) { - if (*vaultID == beast::zero) + if (*vaultID == beast::kZERO) return temINVALID; } @@ -83,9 +83,9 @@ LoanBrokerSet::preflight(PreflightContext const& ctx) std::vector> const& LoanBrokerSet::getValueFields() { - static std::vector> const valueFields{~sfDebtMaximum}; + static std::vector> const kVALUE_FIELDS{~sfDebtMaximum}; - return valueFields; + return kVALUE_FIELDS; } TER diff --git a/src/libxrpl/tx/transactors/lending/LoanDelete.cpp b/src/libxrpl/tx/transactors/lending/LoanDelete.cpp index 875af3a03b..ff33bfb9fb 100644 --- a/src/libxrpl/tx/transactors/lending/LoanDelete.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanDelete.cpp @@ -29,7 +29,7 @@ LoanDelete::checkExtraFeatures(PreflightContext const& ctx) NotTEC LoanDelete::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanID] == beast::zero) + if (ctx.tx[sfLoanID] == beast::kZERO) return temINVALID; return tesSUCCESS; @@ -117,14 +117,14 @@ LoanDelete::doApply() if (brokerSle->at(sfOwnerCount) == 0) { auto debtTotalProxy = brokerSle->at(sfDebtTotal); - if (*debtTotalProxy != beast::zero) + if (*debtTotalProxy != beast::kZERO) { XRPL_ASSERT_PARTS( roundToAsset( vaultSle->at(sfAsset), debtTotalProxy, getAssetsTotalScale(vaultSle), - Number::rounding_mode::towards_zero) == beast::zero, + Number::RoundingMode::TowardsZero) == beast::kZERO, "xrpl::LoanDelete::doApply", "last loan, remaining debt rounds to zero"); debtTotalProxy = 0; diff --git a/src/libxrpl/tx/transactors/lending/LoanManage.cpp b/src/libxrpl/tx/transactors/lending/LoanManage.cpp index de3de6ca25..d1cd5de505 100644 --- a/src/libxrpl/tx/transactors/lending/LoanManage.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanManage.cpp @@ -45,7 +45,7 @@ LoanManage::getFlagsMask(PreflightContext const& ctx) NotTEC LoanManage::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanID] == beast::zero) + if (ctx.tx[sfLoanID] == beast::kZERO) return temINVALID; // Flags are mutually exclusive @@ -167,7 +167,7 @@ LoanManage::defaultLoan( TenthBips32 const coverRateLiquidation{brokerSle->at(sfCoverRateLiquidation)}; auto const defaultCovered = [&]() { // Always round the minimum required up. - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); auto const minimumCover = tenthBipsOfValue(brokerDebtTotalProxy.value(), coverRateMinimum); // Round the liquidation amount up, too auto const covered = roundToAsset( @@ -207,7 +207,7 @@ LoanManage::defaultLoan( } auto const vaultDefaultRounded = roundToAsset( - vaultAsset, vaultDefaultAmount, vaultScale, Number::rounding_mode::downward); + vaultAsset, vaultDefaultAmount, vaultScale, Number::RoundingMode::Downward); vaultTotalProxy -= vaultDefaultRounded; // Increase the Asset Available of the Vault by liquidated First-Loss // Capital and any unclaimed funds amount: @@ -418,7 +418,7 @@ LoanManage::doApply() return impairLoan(view, loanSle, vaultSle, vaultAsset, j_); if (tx.isFlag(tfLoanUnimpair)) return unimpairLoan(view, loanSle, vaultSle, vaultAsset, j_); - // Noop, as described above. + // NoOp, as described above. return tesSUCCESS; }(); diff --git a/src/libxrpl/tx/transactors/lending/LoanPay.cpp b/src/libxrpl/tx/transactors/lending/LoanPay.cpp index f24fdc19b3..b8d73bfd65 100644 --- a/src/libxrpl/tx/transactors/lending/LoanPay.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanPay.cpp @@ -48,10 +48,10 @@ LoanPay::getFlagsMask(PreflightContext const& ctx) NotTEC LoanPay::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfLoanID] == beast::zero) + if (ctx.tx[sfLoanID] == beast::kZERO) return temINVALID; - if (ctx.tx[sfAmount] <= beast::zero) + if (ctx.tx[sfAmount] <= beast::kZERO) return temBAD_AMOUNT; // The loan payment flags are all mutually exclusive. If more than one is @@ -96,7 +96,7 @@ LoanPay::calculateBaseFee(ReadView const& view, STTx const& tx) return normalCost; } - if (loanSle->at(sfPaymentRemaining) <= loanPaymentsPerFeeIncrement) + if (loanSle->at(sfPaymentRemaining) <= kLOAN_PAYMENTS_PER_FEE_INCREMENT) { // If there are fewer than loanPaymentsPerFeeIncrement payments left to // pay, we can skip the computations. @@ -139,16 +139,16 @@ LoanPay::calculateBaseFee(ReadView const& view, STTx const& tx) // If making an overpayment, count it as a full payment because it will do // about the same amount of work, if not more. NumberRoundModeGuard const mg( - tx.isFlag(tfLoanOverpayment) ? Number::rounding_mode::upward - : Number::rounding_mode::downward); + tx.isFlag(tfLoanOverpayment) ? Number::RoundingMode::Upward + : Number::RoundingMode::Downward); // Estimate how many payments will be made Number const numPaymentEstimate = static_cast(amount / regularPayment); // Charge one base fee per paymentsPerFeeIncrement payments, rounding up. - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); auto const feeIncrements = std::max( std::int64_t(1), - static_cast(numPaymentEstimate / loanPaymentsPerFeeIncrement)); + static_cast(numPaymentEstimate / kLOAN_PAYMENTS_PER_FEE_INCREMENT)); return feeIncrements * normalCost; } @@ -242,10 +242,10 @@ LoanPay::preclaim(PreclaimContext const& ctx) ctx.view, account, asset, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); balance < amount) { JLOG(ctx.j.warn()) << "Payment amount too large. Amount: " << to_string(amount.getJson()) @@ -300,7 +300,7 @@ LoanPay::doApply() // Round the minimum required cover up to be conservative. This ensures // CoverAvailable never drops below the theoretical minimum, protecting // the broker's solvency. - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); return coverAvailableProxy >= roundToAsset( asset, tenthBipsOfValue(debtTotalProxy.value(), coverRateMinimum), loanScale) && @@ -340,12 +340,12 @@ LoanPay::doApply() LoanPaymentType const paymentType = [&tx]() { // preflight already checked that at most one flag is set. if (tx.isFlag(tfLoanLatePayment)) - return LoanPaymentType::late; + return LoanPaymentType::Late; if (tx.isFlag(tfLoanFullPayment)) - return LoanPaymentType::full; + return LoanPaymentType::Full; if (tx.isFlag(tfLoanOverpayment)) - return LoanPaymentType::overpayment; - return LoanPaymentType::regular; + return LoanPaymentType::Overpayment; + return LoanPaymentType::Regular; }(); Expected const paymentParts = @@ -406,7 +406,7 @@ LoanPay::doApply() auto const totalPaidToVaultRaw = paymentParts->principalPaid + paymentParts->interestPaid; auto const totalPaidToVaultRounded = - roundToAsset(asset, totalPaidToVaultRaw, vaultScale, Number::rounding_mode::downward); + roundToAsset(asset, totalPaidToVaultRaw, vaultScale, Number::RoundingMode::Downward); XRPL_ASSERT_PARTS( !asset.integral() || totalPaidToVaultRaw == totalPaidToVaultRounded, "xrpl::LoanPay::doApply", @@ -449,8 +449,8 @@ LoanPay::doApply() view, vaultPseudoAccount, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_); XRPL_ASSERT_PARTS( @@ -513,39 +513,38 @@ LoanPay::doApply() view, account_, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); auto const vaultBalanceBefore = account_ == vaultPseudoAccount ? STAmount{asset, 0} : accountHolds( view, vaultPseudoAccount, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_, - SpendableHandling::shFULL_BALANCE); - auto const brokerBalanceBefore = account_ == brokerPayee - ? STAmount{asset, 0} - : accountHolds( - view, - brokerPayee, - asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); + auto const brokerBalanceBefore = account_ == brokerPayee ? STAmount{asset, 0} + : accountHolds( + view, + brokerPayee, + asset, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, + j_, + SpendableHandling::FullBalance); #endif - if (totalPaidToVaultRounded != beast::zero) + if (totalPaidToVaultRounded != beast::kZERO) { if (auto const ter = requireAuth(view, asset, vaultPseudoAccount, AuthType::StrongAuth)) return ter; } - if (totalPaidToBroker != beast::zero) + if (totalPaidToBroker != beast::kZERO) { if (brokerPayee == account_) { @@ -578,8 +577,8 @@ LoanPay::doApply() view, vaultPseudoAccount, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_); XRPL_ASSERT_PARTS( assetsAvailableAfter == pseudoAccountBalanceAfter, @@ -590,30 +589,29 @@ LoanPay::doApply() view, account_, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); auto const vaultBalanceAfter = account_ == vaultPseudoAccount ? STAmount{asset, 0} : accountHolds( view, vaultPseudoAccount, asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, j_, - SpendableHandling::shFULL_BALANCE); - auto const brokerBalanceAfter = account_ == brokerPayee - ? STAmount{asset, 0} - : accountHolds( - view, - brokerPayee, - asset, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_, - SpendableHandling::shFULL_BALANCE); + SpendableHandling::FullBalance); + auto const brokerBalanceAfter = account_ == brokerPayee ? STAmount{asset, 0} + : accountHolds( + view, + brokerPayee, + asset, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, + j_, + SpendableHandling::FullBalance); XRPL_ASSERT_PARTS( accountBalanceBefore + vaultBalanceBefore + brokerBalanceBefore == @@ -621,13 +619,13 @@ LoanPay::doApply() "xrpl::LoanPay::doApply", "funds are conserved (with rounding)"); XRPL_ASSERT_PARTS( - accountBalanceAfter >= beast::zero, "xrpl::LoanPay::doApply", "positive account balance"); + accountBalanceAfter >= beast::kZERO, "xrpl::LoanPay::doApply", "positive account balance"); XRPL_ASSERT_PARTS( accountBalanceAfter < accountBalanceBefore || account_ == asset.getIssuer(), "xrpl::LoanPay::doApply", "account balance decreased"); XRPL_ASSERT_PARTS( - vaultBalanceAfter >= beast::zero && brokerBalanceAfter >= beast::zero, + vaultBalanceAfter >= beast::kZERO && brokerBalanceAfter >= beast::kZERO, "xrpl::LoanPay::doApply", "positive vault and broker balances"); XRPL_ASSERT_PARTS( diff --git a/src/libxrpl/tx/transactors/lending/LoanSet.cpp b/src/libxrpl/tx/transactors/lending/LoanSet.cpp index 757ec0ec66..9503eeef03 100644 --- a/src/libxrpl/tx/transactors/lending/LoanSet.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanSet.cpp @@ -85,7 +85,7 @@ LoanSet::preflight(PreflightContext const& ctx) } if (auto const data = tx[~sfData]; - data && !data->empty() && !validDataLength(tx[~sfData], maxDataPayloadLength)) + data && !data->empty() && !validDataLength(tx[~sfData], kMAX_DATA_PAYLOAD_LENGTH)) return temINVALID; for (auto const& field : {&sfLoanServiceFee, &sfLatePaymentFee, &sfClosePaymentFee}) { @@ -98,27 +98,27 @@ LoanSet::preflight(PreflightContext const& ctx) return temINVALID; if (!validNumericRange(tx[~sfLoanOriginationFee], p)) return temINVALID; - if (!validNumericRange(tx[~sfInterestRate], maxInterestRate)) + if (!validNumericRange(tx[~sfInterestRate], kMAX_INTEREST_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfOverpaymentFee], maxOverpaymentFee)) + if (!validNumericRange(tx[~sfOverpaymentFee], kMAX_OVERPAYMENT_FEE)) return temINVALID; - if (!validNumericRange(tx[~sfLateInterestRate], maxLateInterestRate)) + if (!validNumericRange(tx[~sfLateInterestRate], kMAX_LATE_INTEREST_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfCloseInterestRate], maxCloseInterestRate)) + if (!validNumericRange(tx[~sfCloseInterestRate], kMAX_CLOSE_INTEREST_RATE)) return temINVALID; - if (!validNumericRange(tx[~sfOverpaymentInterestRate], maxOverpaymentInterestRate)) + if (!validNumericRange(tx[~sfOverpaymentInterestRate], kMAX_OVERPAYMENT_INTEREST_RATE)) return temINVALID; if (auto const paymentTotal = tx[~sfPaymentTotal]; paymentTotal && *paymentTotal <= 0) return temINVALID; auto const paymentInterval = tx[~sfPaymentInterval]; - if (!validNumericMinimum(paymentInterval, LoanSet::minPaymentInterval)) + if (!validNumericMinimum(paymentInterval, LoanSet::kMIN_PAYMENT_INTERVAL)) return temINVALID; // Grace period is between min default value and payment interval if (auto const gracePeriod = tx[~sfGracePeriod]; !validNumericRange( gracePeriod, - paymentInterval.value_or(LoanSet::defaultPaymentInterval), - defaultGracePeriod)) + paymentInterval.value_or(LoanSet::kDEFAULT_PAYMENT_INTERVAL), + kDEFAULT_GRACE_PERIOD)) { return temINVALID; } @@ -131,7 +131,7 @@ LoanSet::preflight(PreflightContext const& ctx) return *ret; } - if (auto const brokerID = ctx.tx[~sfLoanBrokerID]; brokerID && *brokerID == beast::zero) + if (auto const brokerID = ctx.tx[~sfLoanBrokerID]; brokerID && *brokerID == beast::kZERO) return temINVALID; return tesSUCCESS; @@ -195,7 +195,7 @@ LoanSet::calculateBaseFee(ReadView const& view, STTx const& tx) std::vector> const& LoanSet::getValueFields() { - static std::vector> const valueFields{ + static std::vector> const kVALUE_FIELDS{ ~sfPrincipalRequested, ~sfLoanOriginationFee, ~sfLoanServiceFee, @@ -204,7 +204,7 @@ LoanSet::getValueFields() // Overpayment fee is really a rate. Don't check it here. }; - return valueFields; + return kVALUE_FIELDS; } static std::uint32_t @@ -226,14 +226,14 @@ LoanSet::preclaim(PreclaimContext const& ctx) // overflows, and we kill the transaction. using timeType = decltype(sfNextPaymentDueDate)::type::value_type; static_assert(std::is_same_v); - timeType constexpr maxTime = std::numeric_limits::max(); - static_assert(maxTime == 4'294'967'295); + timeType constexpr kMAX_TIME = std::numeric_limits::max(); + static_assert(kMAX_TIME == 4'294'967'295); - auto const timeAvailable = maxTime - getStartDate(ctx.view); + auto const timeAvailable = kMAX_TIME - getStartDate(ctx.view); - auto const interval = ctx.tx.at(~sfPaymentInterval).value_or(defaultPaymentInterval); - auto const total = ctx.tx.at(~sfPaymentTotal).value_or(defaultPaymentTotal); - auto const grace = ctx.tx.at(~sfGracePeriod).value_or(defaultGracePeriod); + auto const interval = ctx.tx.at(~sfPaymentInterval).value_or(kDEFAULT_PAYMENT_INTERVAL); + auto const total = ctx.tx.at(~sfPaymentTotal).value_or(kDEFAULT_PAYMENT_TOTAL); + auto const grace = ctx.tx.at(~sfGracePeriod).value_or(kDEFAULT_GRACE_PERIOD); // The grace period can't be larger than the interval. Check it first, // mostly so that unit tests can test that specific case. @@ -414,8 +414,8 @@ LoanSet::doApply() TenthBips32 const interestRate{tx[~sfInterestRate].value_or(0)}; - auto const paymentInterval = tx[~sfPaymentInterval].value_or(defaultPaymentInterval); - auto const paymentTotal = tx[~sfPaymentTotal].value_or(defaultPaymentTotal); + auto const paymentInterval = tx[~sfPaymentInterval].value_or(kDEFAULT_PAYMENT_INTERVAL); + auto const paymentTotal = tx[~sfPaymentTotal].value_or(kDEFAULT_PAYMENT_TOTAL); auto const properties = computeLoanProperties( vaultAsset, @@ -459,7 +459,7 @@ LoanSet::doApply() if (auto const ret = checkLoanGuards( vaultAsset, principalRequested, - interestRate != beast::zero, + interestRate != beast::kZERO, paymentTotal, properties, j_)) @@ -495,7 +495,7 @@ LoanSet::doApply() // Round the minimum required cover up to be conservative. This ensures // CoverAvailable never drops below the theoretical minimum, protecting // the broker's solvency. - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); if (brokerSle->at(sfCoverAvailable) < tenthBipsOfValue(newDebtTotal, coverRateMinimum)) { JLOG(j_.warn()) << "Insufficient first-loss capital to cover the loan."; @@ -536,7 +536,7 @@ LoanSet::doApply() // 2. Transfer originationFee, if any, from vault pseudo-account to // LoanBroker owner. - if (originationFee != beast::zero) + if (originationFee != beast::kZERO) { // Create the holding if it doesn't already exist (necessary for MPTs). // The owner may have deleted their MPT / line at some point. @@ -600,7 +600,7 @@ LoanSet::doApply() setLoanField(~sfLateInterestRate); setLoanField(~sfCloseInterestRate); setLoanField(~sfOverpaymentInterestRate); - setLoanField(~sfGracePeriod, defaultGracePeriod); + setLoanField(~sfGracePeriod, kDEFAULT_GRACE_PERIOD); // Set dynamic / computed fields to their initial values loan->at(sfPrincipalOutstanding) = principalRequested; loan->at(sfPeriodicPayment) = properties.periodicPayment; diff --git a/src/libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp b/src/libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp index 099b174778..06bd1301cb 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp @@ -44,7 +44,7 @@ NFTokenAcceptOffer::preflight(PreflightContext const& ctx) if (!bo || !so) return temMALFORMED; - if (*bf <= beast::zero) + if (*bf <= beast::kZERO) return temMALFORMED; } @@ -186,8 +186,8 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx) // own currency auto const needed = bo->at(sfAmount); - if (accountFunds( - ctx.view, (*bo)[sfOwner], needed, FreezeHandling::fhZERO_IF_FROZEN, ctx.j) < needed) + if (accountFunds(ctx.view, (*bo)[sfOwner], needed, FreezeHandling::ZeroIfFrozen, ctx.j) < + needed) return tecINSUFFICIENT_FUNDS; // Check that the account accepting the buy offer (he's selling the NFT) @@ -256,7 +256,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx) // cover what the buyer will pay, which doesn't make sense, causes // an unnecessary tec, and is also resolved with this amendment. if (accountFunds( - ctx.view, ctx.tx[sfAccount], needed, FreezeHandling::fhZERO_IF_FROZEN, ctx.j) < + ctx.view, ctx.tx[sfAccount], needed, FreezeHandling::ZeroIfFrozen, ctx.j) < needed) return tecINSUFFICIENT_FUNDS; } @@ -306,7 +306,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx) // give the NFToken issuer an undesired trust line. // Issuer doesn't need a trust line to accept their own currency. if (ctx.view.rules().enabled(fixEnforceNFTokenTrustline) && - (nft::getFlags(tokenID) & nft::flagCreateTrustLines) == 0 && + (nft::getFlags(tokenID) & nft::kFLAG_CREATE_TRUST_LINES) == 0 && nftMinter != amount.getIssuer() && !ctx.view.read(keylet::line(nftMinter, amount.get()))) return tecNO_LINE; @@ -333,7 +333,7 @@ TER NFTokenAcceptOffer::pay(AccountID const& from, AccountID const& to, STAmount const& amount) { // This should never happen, but it's easy and quick to check. - if (amount < beast::zero) + if (amount < beast::kZERO) return tecINTERNAL; // LCOV_EXCL_LINE auto const result = accountSend(view(), from, to, amount, j_); @@ -345,9 +345,9 @@ NFTokenAcceptOffer::pay(AccountID const& from, AccountID const& to, STAmount con // just confirm that the end state is OK. if (!isTesSuccess(result)) return result; - if (accountFunds(view(), from, amount, FreezeHandling::fhZERO_IF_FROZEN, j_).signum() < 0) + if (accountFunds(view(), from, amount, FreezeHandling::ZeroIfFrozen, j_).signum() < 0) return tecINSUFFICIENT_FUNDS; - if (accountFunds(view(), to, amount, FreezeHandling::fhZERO_IF_FROZEN, j_).signum() < 0) + if (accountFunds(view(), to, amount, FreezeHandling::ZeroIfFrozen, j_).signum() < 0) return tecINSUFFICIENT_FUNDS; return tesSUCCESS; } @@ -412,7 +412,7 @@ NFTokenAcceptOffer::acceptOffer(std::shared_ptr const& offer) auto const nftokenID = (*offer)[sfNFTokenID]; - if (auto amount = offer->getFieldAmount(sfAmount); amount != beast::zero) + if (auto amount = offer->getFieldAmount(sfAmount); amount != beast::kZERO) { // Calculate the issuer's cut from this sale, if any: if (auto const fee = nft::getTransferFee(nftokenID); fee != 0) @@ -420,7 +420,7 @@ NFTokenAcceptOffer::acceptOffer(std::shared_ptr const& offer) auto const cut = multiply(amount, nft::transferFeeAsRate(fee)); if (auto const issuer = nft::getIssuer(nftokenID); - cut != beast::zero && seller != issuer && buyer != issuer) + cut != beast::kZERO && seller != issuer && buyer != issuer) { if (auto const r = pay(buyer, issuer, cut); !isTesSuccess(r)) return r; @@ -526,7 +526,7 @@ NFTokenAcceptOffer::doApply() // being paid out than the seller authorized. That would be bad! // Send the broker the amount they requested. - if (auto const cut = ctx_.tx[~sfNFTokenBrokerFee]; cut && cut.value() != beast::zero) + if (auto const cut = ctx_.tx[~sfNFTokenBrokerFee]; cut && cut.value() != beast::kZERO) { if (auto const r = pay(buyer, account_, cut.value()); !isTesSuccess(r)) return r; @@ -535,7 +535,7 @@ NFTokenAcceptOffer::doApply() } // Calculate the issuer's cut, if any. - if (auto const fee = nft::getTransferFee(nftokenID); amount != beast::zero && fee != 0) + if (auto const fee = nft::getTransferFee(nftokenID); amount != beast::kZERO && fee != 0) { auto cut = multiply(amount, nft::transferFeeAsRate(fee)); @@ -549,7 +549,7 @@ NFTokenAcceptOffer::doApply() } // And send whatever remains to the seller. - if (amount > beast::zero) + if (amount > beast::kZERO) { if (auto const r = pay(buyer, seller, amount); !isTesSuccess(r)) return r; diff --git a/src/libxrpl/tx/transactors/nft/NFTokenBurn.cpp b/src/libxrpl/tx/transactors/nft/NFTokenBurn.cpp index a0d10ca07d..fb57b14c15 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenBurn.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenBurn.cpp @@ -40,7 +40,7 @@ NFTokenBurn::preclaim(PreclaimContext const& ctx) // do so if the token is marked as burnable. if (auto const account = ctx.tx[sfAccount]; owner != account) { - if ((nft::getFlags(ctx.tx[sfNFTokenID]) & nft::flagBurnable) == 0) + if ((nft::getFlags(ctx.tx[sfNFTokenID]) & nft::kFLAG_BURNABLE) == 0) return tecNO_PERMISSION; if (auto const issuer = nft::getIssuer(ctx.tx[sfNFTokenID]); issuer != account) @@ -72,7 +72,7 @@ NFTokenBurn::doApply() if (auto issuer = view().peek(keylet::account(nft::getIssuer(ctx_.tx[sfNFTokenID])))) { - (*issuer)[~sfBurnedNFTokens] = (*issuer)[~sfBurnedNFTokens].value_or(0) + 1; + (*issuer)[~sfBurnedNFTokens] = (*issuer)[~sfBurnedNFTokens].valueOr(0) + 1; view().update(issuer); } @@ -81,14 +81,14 @@ NFTokenBurn::doApply() // the number of buy offers, we prioritize the deletion of sell // offers in order to clean up sell offer directory std::size_t const deletedSellOffers = nft::removeTokenOffersWithLimit( - view(), keylet::nft_sells(ctx_.tx[sfNFTokenID]), maxDeletableTokenOfferEntries); + view(), keylet::nftSells(ctx_.tx[sfNFTokenID]), kMAX_DELETABLE_TOKEN_OFFER_ENTRIES); - if (maxDeletableTokenOfferEntries > deletedSellOffers) + if (kMAX_DELETABLE_TOKEN_OFFER_ENTRIES > deletedSellOffers) { nft::removeTokenOffersWithLimit( view(), - keylet::nft_buys(ctx_.tx[sfNFTokenID]), - maxDeletableTokenOfferEntries - deletedSellOffers); + keylet::nftBuys(ctx_.tx[sfNFTokenID]), + kMAX_DELETABLE_TOKEN_OFFER_ENTRIES - deletedSellOffers); } return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/nft/NFTokenCancelOffer.cpp b/src/libxrpl/tx/transactors/nft/NFTokenCancelOffer.cpp index 9d25a7335f..e76d7677aa 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenCancelOffer.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenCancelOffer.cpp @@ -24,7 +24,7 @@ NotTEC NFTokenCancelOffer::preflight(PreflightContext const& ctx) { if (auto const& ids = ctx.tx[sfNFTokenOffers]; - ids.empty() || (ids.size() > maxTokenOfferCancelCount)) + ids.empty() || (ids.size() > kMAX_TOKEN_OFFER_CANCEL_COUNT)) return temMALFORMED; // In order to prevent unnecessarily overlarge transactions, we diff --git a/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp b/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp index 6043d918c2..c7cb37ad94 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp @@ -86,7 +86,7 @@ NFTokenMint::preflight(PreflightContext const& ctx) { if (auto const f = ctx.tx[~sfTransferFee]) { - if (f > maxTransferFee) + if (f > kMAX_TRANSFER_FEE) return temBAD_NFTOKEN_TRANSFER_FEE; // If a non-zero TransferFee is set then the tfTransferable flag @@ -101,7 +101,7 @@ NFTokenMint::preflight(PreflightContext const& ctx) if (auto uri = ctx.tx[~sfURI]) { - if (uri->empty() || uri->length() > maxTokenURILength) + if (uri->empty() || uri->length() > kMAX_TOKEN_URI_LENGTH) return temMALFORMED; } @@ -256,7 +256,7 @@ NFTokenMint::doApply() : acctSeq - 1; } - std::uint32_t const mintedNftCnt = (*root)[~sfMintedNFTokens].value_or(0u); + std::uint32_t const mintedNftCnt = (*root)[~sfMintedNFTokens].valueOr(0u); (*root)[sfMintedNFTokens] = mintedNftCnt + 1u; if ((*root)[sfMintedNFTokens] == 0u) diff --git a/src/libxrpl/tx/transactors/nft/NFTokenModify.cpp b/src/libxrpl/tx/transactors/nft/NFTokenModify.cpp index 392d928f02..b56ee9b061 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenModify.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenModify.cpp @@ -26,7 +26,7 @@ NFTokenModify::preflight(PreflightContext const& ctx) if (auto uri = ctx.tx[~sfURI]) { - if (uri->empty() || uri->length() > maxTokenURILength) + if (uri->empty() || uri->length() > kMAX_TOKEN_URI_LENGTH) return temMALFORMED; } @@ -43,7 +43,7 @@ NFTokenModify::preclaim(PreclaimContext const& ctx) return tecNO_ENTRY; // Check if the NFT is mutable - if ((nft::getFlags(ctx.tx[sfNFTokenID]) & nft::flagMutable) == 0) + if ((nft::getFlags(ctx.tx[sfNFTokenID]) & nft::kFLAG_MUTABLE) == 0) return tecNO_PERMISSION; // Verify permissions for the issuer diff --git a/src/libxrpl/tx/transactors/oracle/OracleSet.cpp b/src/libxrpl/tx/transactors/oracle/OracleSet.cpp index 4304427646..7c2a817ed1 100644 --- a/src/libxrpl/tx/transactors/oracle/OracleSet.cpp +++ b/src/libxrpl/tx/transactors/oracle/OracleSet.cpp @@ -43,7 +43,7 @@ OracleSet::preflight(PreflightContext const& ctx) auto const& dataSeries = ctx.tx.getFieldArray(sfPriceDataSeries); if (dataSeries.empty()) return temARRAY_EMPTY; - if (dataSeries.size() > maxOracleDataSeries) + if (dataSeries.size() > kMAX_ORACLE_DATA_SERIES) return temARRAY_TOO_LARGE; auto isInvalidLength = [&](auto const& sField, std::size_t length) { @@ -51,8 +51,9 @@ OracleSet::preflight(PreflightContext const& ctx) (ctx.tx[sField].length() == 0 || ctx.tx[sField].length() > length); }; - if (isInvalidLength(sfProvider, maxOracleProvider) || isInvalidLength(sfURI, maxOracleURI) || - isInvalidLength(sfAssetClass, maxOracleSymbolClass)) + if (isInvalidLength(sfProvider, kMAX_ORACLE_PROVIDER) || + isInvalidLength(sfURI, kMAX_ORACLE_URI) || + isInvalidLength(sfAssetClass, kMAX_ORACLE_SYMBOL_CLASS)) return temMALFORMED; return tesSUCCESS; @@ -71,13 +72,13 @@ OracleSet::preclaim(PreclaimContext const& ctx) std::size_t const closeTime = duration_cast(ctx.view.header().closeTime.time_since_epoch()).count(); std::size_t const lastUpdateTime = ctx.tx[sfLastUpdateTime]; - if (lastUpdateTime < epoch_offset.count()) + if (lastUpdateTime < kEPOCH_OFFSET.count()) return tecINVALID_UPDATE_TIME; - std::size_t const lastUpdateTimeEpoch = lastUpdateTime - epoch_offset.count(); - if (closeTime < maxLastUpdateTimeDelta) + std::size_t const lastUpdateTimeEpoch = lastUpdateTime - kEPOCH_OFFSET.count(); + if (closeTime < kMAX_LAST_UPDATE_TIME_DELTA) return tecINTERNAL; // LCOV_EXCL_LINE - if (lastUpdateTimeEpoch < (closeTime - maxLastUpdateTimeDelta) || - lastUpdateTimeEpoch > (closeTime + maxLastUpdateTimeDelta)) + if (lastUpdateTimeEpoch < (closeTime - kMAX_LAST_UPDATE_TIME_DELTA) || + lastUpdateTimeEpoch > (closeTime + kMAX_LAST_UPDATE_TIME_DELTA)) return tecINVALID_UPDATE_TIME; auto const sle = @@ -95,7 +96,7 @@ OracleSet::preclaim(PreclaimContext const& ctx) auto const key = tokenPairKey(entry); if (pairs.contains(key) || pairsDel.contains(key)) return temMALFORMED; - if (entry[~sfScale] > maxPriceScale) + if (entry[~sfScale] > kMAX_PRICE_SCALE) return temMALFORMED; if (entry.isFieldPresent(sfAssetPrice)) { @@ -165,7 +166,7 @@ OracleSet::preclaim(PreclaimContext const& ctx) if (pairs.empty()) return tecARRAY_EMPTY; - if (pairs.size() > maxOracleDataSeries) + if (pairs.size() > kMAX_ORACLE_DATA_SERIES) return tecARRAY_TOO_LARGE; auto const reserve = @@ -255,7 +256,7 @@ OracleSet::doApply() } STArray updatedSeries; for (auto const& iter : pairs) - updatedSeries.push_back(iter.second); + updatedSeries.pushBack(iter.second); sle->setFieldArray(sfPriceDataSeries, updatedSeries); if (ctx_.tx.isFieldPresent(sfURI)) sle->setFieldVL(sfURI, ctx_.tx[sfURI]); @@ -303,7 +304,7 @@ OracleSet::doApply() pairs.emplace(key, std::move(priceData)); } for (auto const& iter : pairs) - series.push_back(iter.second); + series.pushBack(iter.second); } sle->setFieldArray(sfPriceDataSeries, series); diff --git a/src/libxrpl/tx/transactors/payment/DepositPreauth.cpp b/src/libxrpl/tx/transactors/payment/DepositPreauth.cpp index f770b443f7..e4a060ea31 100644 --- a/src/libxrpl/tx/transactors/payment/DepositPreauth.cpp +++ b/src/libxrpl/tx/transactors/payment/DepositPreauth.cpp @@ -84,7 +84,7 @@ DepositPreauth::preflight(PreflightContext const& ctx) if (auto err = credentials::checkArray( ctx.tx.getFieldArray( authArrPresent ? sfAuthorizeCredentials : sfUnauthorizeCredentials), - maxCredentialsArraySize, + kMAX_CREDENTIALS_ARRAY_SIZE, ctx.j); !isTesSuccess(err)) return err; @@ -226,7 +226,7 @@ DepositPreauth::doApply() auto cred = STObject::makeInnerObject(sfCredential); cred.setAccountID(sfIssuer, p.first); cred.setFieldVL(sfCredentialType, p.second); - sortedLE.push_back(std::move(cred)); + sortedLE.pushBack(std::move(cred)); } Keylet const preauthKey = keylet::depositPreauth(account_, sortedTX); diff --git a/src/libxrpl/tx/transactors/payment/Payment.cpp b/src/libxrpl/tx/transactors/payment/Payment.cpp index 8ea79e0840..d283874296 100644 --- a/src/libxrpl/tx/transactors/payment/Payment.cpp +++ b/src/libxrpl/tx/transactors/payment/Payment.cpp @@ -53,7 +53,7 @@ Payment::makeTxConsequences(PreflightContext const& ctx) // If there's no sfSendMax in XRP, and the sfAmount isn't // in XRP, then the transaction does not spend XRP. - return maxAmount.native() ? maxAmount.xrp() : beast::zero; + return maxAmount.native() ? maxAmount.xrp() : beast::kZERO; }; return TxConsequences{ctx.tx, calculateMaxXRPSpend(ctx.tx)}; @@ -78,7 +78,7 @@ getMaxSourceAmount( Issue{issue.currency, account}, dstAmount.mantissa(), dstAmount.exponent(), - dstAmount < beast::zero); + dstAmount < beast::kZERO); }); } @@ -100,11 +100,11 @@ Payment::getFlagsMask(PreflightContext const& ctx) STAmount const dstAmount(tx.getFieldAmount(sfAmount)); bool const isDstMPT = dstAmount.holds(); - bool const MPTokensV2 = ctx.rules.enabled(featureMPTokensV2); + bool const mpTokensV2 = ctx.rules.enabled(featureMPTokensV2); - constexpr std::uint32_t tfMPTPaymentMaskV1 = ~(tfUniversal | tfPartialPayment); + constexpr std::uint32_t kTF_MPT_PAYMENT_MASK_V1 = ~(tfUniversal | tfPartialPayment); std::uint32_t const paymentMask = - (isDstMPT && !MPTokensV2) ? tfMPTPaymentMaskV1 : tfPaymentMask; + (isDstMPT && !mpTokensV2) ? kTF_MPT_PAYMENT_MASK_V1 : tfPaymentMask; return paymentMask; } @@ -117,14 +117,14 @@ Payment::preflight(PreflightContext const& ctx) STAmount const dstAmount(tx.getFieldAmount(sfAmount)); bool const isDstMPT = dstAmount.holds(); - bool const MPTokensV2 = ctx.rules.enabled(featureMPTokensV2); + bool const mpTokensV2 = ctx.rules.enabled(featureMPTokensV2); if (!ctx.rules.enabled(featureMPTokensV1) && isDstMPT) return temDISABLED; std::uint32_t const txFlags = tx.getFlags(); - if (!MPTokensV2 && isDstMPT && ctx.tx.isFieldPresent(sfPaths)) + if (!mpTokensV2 && isDstMPT && ctx.tx.isFieldPresent(sfPaths)) return temMALFORMED; bool const partialPaymentAllowed = (txFlags & tfPartialPayment) != 0u; @@ -138,7 +138,7 @@ Payment::preflight(PreflightContext const& ctx) auto const account = tx.getAccountID(sfAccount); STAmount const maxSourceAmount = getMaxSourceAmount(account, dstAmount, tx[~sfSendMax]); - if (!MPTokensV2 && + if (!mpTokensV2 && ((isDstMPT && dstAmount.asset() != maxSourceAmount.asset()) || (!isDstMPT && maxSourceAmount.holds()))) { @@ -164,13 +164,13 @@ Payment::preflight(PreflightContext const& ctx) << "Payment destination account not specified."; return temDST_NEEDED; } - if (hasMax && maxSourceAmount <= beast::zero) + if (hasMax && maxSourceAmount <= beast::kZERO) { JLOG(j.trace()) << "Malformed transaction: bad max amount: " << maxSourceAmount.getFullText(); return temBAD_AMOUNT; } - if (dstAmount <= beast::zero) + if (dstAmount <= beast::kZERO) { JLOG(j.trace()) << "Malformed transaction: bad dst amount: " << dstAmount.getFullText(); return temBAD_AMOUNT; @@ -201,7 +201,7 @@ Payment::preflight(PreflightContext const& ctx) << "SendMax specified for XRP to XRP."; return temBAD_SEND_XRP_MAX; } - if ((xrpDirect || (!MPTokensV2 && isDstMPT)) && hasPaths) + if ((xrpDirect || (!mpTokensV2 && isDstMPT)) && hasPaths) { // XRP is sent without paths. JLOG(j.trace()) << "Malformed transaction: " @@ -215,14 +215,14 @@ Payment::preflight(PreflightContext const& ctx) << "Partial payment specified for XRP to XRP."; return temBAD_SEND_XRP_PARTIAL; } - if ((xrpDirect || (!MPTokensV2 && isDstMPT)) && limitQuality) + if ((xrpDirect || (!mpTokensV2 && isDstMPT)) && limitQuality) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " << "Limit quality specified for XRP to XRP or MPT to MPT."; return temBAD_SEND_XRP_LIMIT; } - if ((xrpDirect || (!MPTokensV2 && isDstMPT)) && !defaultPathsAllowed) + if ((xrpDirect || (!mpTokensV2 && isDstMPT)) && !defaultPathsAllowed) { // Consistent but redundant transaction. JLOG(j.trace()) << "Malformed transaction: " @@ -236,14 +236,14 @@ Payment::preflight(PreflightContext const& ctx) { JLOG(j.trace()) << "Malformed transaction: Partial payment not " "specified for " - << jss::DeliverMin.c_str() << "."; + << jss::DeliverMin.cStr() << "."; return temBAD_AMOUNT; } auto const dMin = *deliverMin; - if (!isLegalNet(dMin) || dMin <= beast::zero) + if (!isLegalNet(dMin) || dMin <= beast::kZERO) { - JLOG(j.trace()) << "Malformed transaction: Invalid " << jss::DeliverMin.c_str() + JLOG(j.trace()) << "Malformed transaction: Invalid " << jss::DeliverMin.cStr() << " amount. " << dMin.getFullText(); return temBAD_AMOUNT; } @@ -251,13 +251,13 @@ Payment::preflight(PreflightContext const& ctx) { JLOG(j.trace()) << "Malformed transaction: Dst issue differs " "from " - << jss::DeliverMin.c_str() << ". " << dMin.getFullText(); + << jss::DeliverMin.cStr() << ". " << dMin.getFullText(); return temBAD_AMOUNT; } if (dMin > dstAmount) { JLOG(j.trace()) << "Malformed transaction: Dst amount less than " - << jss::DeliverMin.c_str() << ". " << dMin.getFullText(); + << jss::DeliverMin.cStr() << ". " << dMin.getFullText(); return temBAD_AMOUNT; } } @@ -376,8 +376,8 @@ Payment::preclaim(PreclaimContext const& ctx) { STPathSet const& paths = ctx.tx.getFieldPathSet(sfPaths); - if (paths.size() > MaxPathSize || std::ranges::any_of(paths, [](STPath const& path) { - return path.size() > MaxPathLength; + if (paths.size() > kMAX_PATH_SIZE || std::ranges::any_of(paths, [](STPath const& path) { + return path.size() > kMAX_PATH_LENGTH; })) { return telBAD_PATH_COUNT; @@ -431,7 +431,7 @@ Payment::doApply() sleDst = std::make_shared(k); sleDst->setAccountID(sfAccount, dstAccountID); sleDst->setFieldU32(sfSequence, view().seq()); - sleDst->setFieldAmount(sfBalance, XRPAmount(beast::zero)); + sleDst->setFieldAmount(sfBalance, XRPAmount(beast::kZERO)); view().insert(sleDst); } @@ -443,10 +443,10 @@ Payment::doApply() view().update(sleDst); } - bool const MPTokensV2 = view().rules().enabled(featureMPTokensV2); + bool const mpTokensV2 = view().rules().enabled(featureMPTokensV2); // Direct MPT payment is handled by payment engine if MPTokensV2 is enabled - bool const ripple = (hasPaths || sendMax || !dstAmount.native()) && (!isDstMPT || MPTokensV2); + bool const ripple = (hasPaths || sendMax || !dstAmount.native()) && (!isDstMPT || mpTokensV2); if (ripple) { diff --git a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelClaim.cpp b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelClaim.cpp index 256d1e87ca..ec2d4dd70d 100644 --- a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelClaim.cpp +++ b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelClaim.cpp @@ -44,11 +44,11 @@ NotTEC PaymentChannelClaim::preflight(PreflightContext const& ctx) { auto const bal = ctx.tx[~sfBalance]; - if (bal && (!isXRP(*bal) || *bal <= beast::zero)) + if (bal && (!isXRP(*bal) || *bal <= beast::kZERO)) return temBAD_AMOUNT; auto const amt = ctx.tx[~sfAmount]; - if (amt && (!isXRP(*amt) || *amt <= beast::zero)) + if (amt && (!isXRP(*amt) || *amt <= beast::kZERO)) return temBAD_AMOUNT; if (bal && amt && *bal > *amt) @@ -167,7 +167,7 @@ PaymentChannelClaim::doApply() (*slep)[sfBalance] = ctx_.tx[sfBalance]; XRPAmount const reqDelta = reqBalance - chanBalance; XRPL_ASSERT( - reqDelta >= beast::zero, "xrpl::PaymentChannelClaim::doApply : minimum balance delta"); + reqDelta >= beast::kZERO, "xrpl::PaymentChannelClaim::doApply : minimum balance delta"); (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta; ctx_.view().update(sled); ctx_.view().update(slep); diff --git a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelCreate.cpp b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelCreate.cpp index 4ced2d10bc..c86590aa98 100644 --- a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelCreate.cpp +++ b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelCreate.cpp @@ -56,7 +56,7 @@ PaymentChannelCreate::makeTxConsequences(PreflightContext const& ctx) NotTEC PaymentChannelCreate::preflight(PreflightContext const& ctx) { - if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero)) + if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::kZERO)) return temBAD_AMOUNT; if (ctx.tx[sfAccount] == ctx.tx[sfDestination]) diff --git a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelFund.cpp b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelFund.cpp index 4e588eda1e..4d2590c382 100644 --- a/src/libxrpl/tx/transactors/payment_channel/PaymentChannelFund.cpp +++ b/src/libxrpl/tx/transactors/payment_channel/PaymentChannelFund.cpp @@ -31,7 +31,7 @@ PaymentChannelFund::makeTxConsequences(PreflightContext const& ctx) NotTEC PaymentChannelFund::preflight(PreflightContext const& ctx) { - if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::zero)) + if (!isXRP(ctx.tx[sfAmount]) || (ctx.tx[sfAmount] <= beast::kZERO)) return temBAD_AMOUNT; return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.cpp b/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.cpp index 87794b8dc2..befae454b7 100644 --- a/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.cpp +++ b/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.cpp @@ -20,7 +20,7 @@ NotTEC PermissionedDomainDelete::preflight(PreflightContext const& ctx) { auto const domain = ctx.tx.getFieldH256(sfDomainID); - if (domain == beast::zero) + if (domain == beast::kZERO) return temMALFORMED; return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.cpp b/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.cpp index e7853b529b..92f260db4e 100644 --- a/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.cpp +++ b/src/libxrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.cpp @@ -33,13 +33,13 @@ PermissionedDomainSet::preflight(PreflightContext const& ctx) { if (auto err = credentials::checkArray( ctx.tx.getFieldArray(sfAcceptedCredentials), - maxPermissionedDomainCredentialsArraySize, + kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE, ctx.j); !isTesSuccess(err)) return err; auto const domain = ctx.tx.at(~sfDomainID); - if (domain && *domain == beast::zero) + if (domain && *domain == beast::kZERO) return temMALFORMED; return tesSUCCESS; @@ -89,7 +89,7 @@ PermissionedDomainSet::doApply() auto cred = STObject::makeInnerObject(sfCredential); cred.setAccountID(sfIssuer, p.first); cred.setFieldVL(sfCredentialType, p.second); - sortedLE.push_back(std::move(cred)); + sortedLE.pushBack(std::move(cred)); } if (ctx_.tx.isFieldPresent(sfDomainID)) diff --git a/src/libxrpl/tx/transactors/system/Batch.cpp b/src/libxrpl/tx/transactors/system/Batch.cpp index 1218f0d59f..f9ae9dc912 100644 --- a/src/libxrpl/tx/transactors/system/Batch.cpp +++ b/src/libxrpl/tx/transactors/system/Batch.cpp @@ -62,7 +62,7 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) if (baseFee > maxAmount - view.fees().base) { JLOG(debugLog().error()) << "BatchTrace: Base fee overflow detected."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -75,10 +75,10 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) auto const& txns = tx.getFieldArray(sfRawTransactions); // LCOV_EXCL_START - if (txns.size() > maxBatchTxCount) + if (txns.size() > kMAX_BATCH_TX_COUNT) { JLOG(debugLog().error()) << "BatchTrace: Raw Transactions array exceeds max entries."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -90,7 +90,7 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) if (stx.getTxnType() == ttBATCH) { JLOG(debugLog().error()) << "BatchTrace: Inner Batch transaction found."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -100,7 +100,7 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) { JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in txnFees calculation."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP txnFees += fee; @@ -114,10 +114,10 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) auto const& signers = tx.getFieldArray(sfBatchSigners); // LCOV_EXCL_START - if (signers.size() > maxBatchTxCount) + if (signers.size() > kMAX_BATCH_TX_COUNT) { JLOG(debugLog().error()) << "BatchTrace: Batch Signers array exceeds max entries."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -138,7 +138,7 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) if (signerCount > 0 && view.fees().base > maxAmount / signerCount) { JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in signerCount calculation."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -148,12 +148,12 @@ Batch::calculateBaseFee(ReadView const& view, STTx const& tx) if (signerFees > maxAmount - txnFees) { JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in signerFees calculation."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } if (txnFees + signerFees > maxAmount - batchBase) { JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in total fee calculation."; - return XRPAmount{INITIAL_XRP}; + return XRPAmount{kINITIAL_XRP}; } // LCOV_EXCL_STOP @@ -221,7 +221,7 @@ Batch::preflight(PreflightContext const& ctx) return temARRAY_EMPTY; } - if (rawTxns.size() > maxBatchTxCount) + if (rawTxns.size() > kMAX_BATCH_TX_COUNT) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:" << "txns array exceeds 8 entries."; @@ -282,7 +282,7 @@ Batch::preflight(PreflightContext const& ctx) } if (std::ranges::any_of( - disabledTxTypes, [txType](auto const& disabled) { return txType == disabled; })) + kDISABLED_TX_TYPES, [txType](auto const& disabled) { return txType == disabled; })) { return temINVALID_INNER_BATCH; } @@ -311,7 +311,7 @@ Batch::preflight(PreflightContext const& ctx) } // Check that the Fee is native asset (XRP) and zero - if (auto const fee = stx.getFieldAmount(sfFee); !fee.native() || fee.xrp() != beast::zero) + if (auto const fee = stx.getFieldAmount(sfFee); !fee.native() || fee.xrp() != beast::kZERO) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: " << "inner txn must have a fee of 0. " @@ -321,7 +321,7 @@ Batch::preflight(PreflightContext const& ctx) auto const innerAccount = stx.getAccountID(sfAccount); if (auto const preflightResult = - xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j); + xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, TapBatch, ctx.j); !isTesSuccess(preflightResult.ter)) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: " @@ -413,7 +413,7 @@ Batch::preflightSigValidated(PreflightContext const& ctx) STArray const& signers = ctx.tx.getFieldArray(sfBatchSigners); // Check that the batch signers array is not too large. - if (signers.size() > maxBatchTxCount) + if (signers.size() > kMAX_BATCH_TX_COUNT) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: " << "signers array exceeds 8 entries."; diff --git a/src/libxrpl/tx/transactors/system/Change.cpp b/src/libxrpl/tx/transactors/system/Change.cpp index 60dbb06a17..5f51f935f3 100644 --- a/src/libxrpl/tx/transactors/system/Change.cpp +++ b/src/libxrpl/tx/transactors/system/Change.cpp @@ -42,7 +42,7 @@ Transactor::invokePreflight(PreflightContext const& ctx) return ret; auto account = ctx.tx.getAccountID(sfAccount); - if (account != beast::zero) + if (account != beast::kZERO) { JLOG(ctx.j.warn()) << "Change: Bad source id"; return temBAD_SRC_ACCOUNT; @@ -50,7 +50,7 @@ Transactor::invokePreflight(PreflightContext const& ctx) // No point in going any further if the transaction fee is malformed. auto const fee = ctx.tx.getFieldAmount(sfFee); - if (!fee.native() || fee != beast::zero) + if (!fee.native() || fee != beast::kZERO) { JLOG(ctx.j.warn()) << "Change: invalid fee"; return temBAD_FEE; @@ -154,7 +154,7 @@ Change::doApply() void Change::preCompute() { - XRPL_ASSERT(account_ == beast::zero, "xrpl::Change::preCompute : zero account"); + XRPL_ASSERT(account_ == beast::kZERO, "xrpl::Change::preCompute : zero account"); } TER @@ -202,7 +202,7 @@ Change::applyAmendment() else { // pass through - newMajorities.push_back(majority); + newMajorities.pushBack(majority); } } } @@ -213,7 +213,7 @@ Change::applyAmendment() if (gotMajority) { // This amendment now has a majority - newMajorities.push_back(STObject::makeInnerObject(sfMajority)); + newMajorities.pushBack(STObject::makeInnerObject(sfMajority)); auto& entry = newMajorities.back(); entry[sfAmendment] = amendment; entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count(); @@ -226,7 +226,7 @@ Change::applyAmendment() else if (!lostMajority) { // No flags, enable amendment - amendments.push_back(amendment); + amendments.pushBack(amendment); amendmentObject->setFieldV256(sfAmendments, amendments); ctx_.registry.get().getAmendmentTable().enable(amendment); diff --git a/src/libxrpl/tx/transactors/system/LedgerStateFix.cpp b/src/libxrpl/tx/transactors/system/LedgerStateFix.cpp index 07ec677288..2bc71f8c86 100644 --- a/src/libxrpl/tx/transactors/system/LedgerStateFix.cpp +++ b/src/libxrpl/tx/transactors/system/LedgerStateFix.cpp @@ -21,7 +21,7 @@ LedgerStateFix::preflight(PreflightContext const& ctx) { switch (static_cast(ctx.tx[sfLedgerFixType])) { - case FixType::nfTokenPageLink: + case FixType::NfTokenPageLink: if (!ctx.tx.isFieldPresent(sfOwner)) return temINVALID; break; @@ -44,7 +44,7 @@ LedgerStateFix::calculateBaseFee(ReadView const& view, STTx const& tx) TER LedgerStateFix::preclaim(PreclaimContext const& ctx) { - if (static_cast(ctx.tx[sfLedgerFixType]) == FixType::nfTokenPageLink) + if (static_cast(ctx.tx[sfLedgerFixType]) == FixType::NfTokenPageLink) { AccountID const owner{ctx.tx[sfOwner]}; if (!ctx.view.read(keylet::account(owner))) @@ -60,7 +60,7 @@ LedgerStateFix::preclaim(PreclaimContext const& ctx) TER LedgerStateFix::doApply() { - if (static_cast(ctx_.tx[sfLedgerFixType]) == FixType::nfTokenPageLink) + if (static_cast(ctx_.tx[sfLedgerFixType]) == FixType::NfTokenPageLink) { if (!nft::repairNFTokenDirectoryLinks(view(), ctx_.tx[sfOwner])) return tecFAILED_PROCESSING; diff --git a/src/libxrpl/tx/transactors/system/TicketCreate.cpp b/src/libxrpl/tx/transactors/system/TicketCreate.cpp index fd6b947c5e..75095772dd 100644 --- a/src/libxrpl/tx/transactors/system/TicketCreate.cpp +++ b/src/libxrpl/tx/transactors/system/TicketCreate.cpp @@ -32,7 +32,7 @@ NotTEC TicketCreate::preflight(PreflightContext const& ctx) { if (std::uint32_t const count = ctx.tx[sfTicketCount]; - count < minValidCount || count > maxValidCount) + count < kMIN_VALID_COUNT || count > kMAX_VALID_COUNT) return temINVALID_COUNT; return tesSUCCESS; @@ -58,7 +58,7 @@ TicketCreate::preclaim(PreclaimContext const& ctx) // o consumedTickets <= 1 // So in the worst case addedTickets == consumedTickets and the // computation yields curTicketCount. - if (curTicketCount + addedTickets - consumedTickets > maxTicketThreshold) + if (curTicketCount + addedTickets - consumedTickets > kMAX_TICKET_THRESHOLD) return tecDIR_FULL; return tesSUCCESS; @@ -100,7 +100,7 @@ TicketCreate::doApply() for (std::uint32_t i = 0; i < ticketCount; ++i) { std::uint32_t const curTicketSeq = firstTicketSeq + i; - Keylet const ticketKeylet = keylet::ticket(account_, curTicketSeq); + Keylet const ticketKeylet = keylet::kTICKET(account_, curTicketSeq); SLE::pointer const sleTicket = std::make_shared(ticketKeylet); sleTicket->setAccountID(sfAccount, account_); @@ -120,7 +120,7 @@ TicketCreate::doApply() } // Update the record of the number of Tickets this account owns. - std::uint32_t const oldTicketCount = (*(sleAccountRoot))[~sfTicketCount].value_or(0u); + std::uint32_t const oldTicketCount = (*(sleAccountRoot))[~sfTicketCount].valueOr(0u); sleAccountRoot->setFieldU32(sfTicketCount, oldTicketCount + ticketCount); diff --git a/src/libxrpl/tx/transactors/token/Clawback.cpp b/src/libxrpl/tx/transactors/token/Clawback.cpp index ff20bd82c3..8c99ce9b08 100644 --- a/src/libxrpl/tx/transactors/token/Clawback.cpp +++ b/src/libxrpl/tx/transactors/token/Clawback.cpp @@ -46,7 +46,7 @@ preflightHelper(PreflightContext const& ctx) // The issuer field is used for the token holder instead AccountID const& holder = clawAmount.getIssuer(); - if (issuer == holder || isXRP(clawAmount) || clawAmount <= beast::zero) + if (issuer == holder || isXRP(clawAmount) || clawAmount <= beast::kZERO) return temBAD_AMOUNT; return tesSUCCESS; @@ -69,7 +69,7 @@ preflightHelper(PreflightContext const& ctx) if (ctx.tx[sfAccount] == *mptHolder) return temMALFORMED; - if (clawAmount.mpt() > MPTAmount{maxMPTokenAmount} || clawAmount <= beast::zero) + if (clawAmount.mpt() > MPTAmount{kMAX_MP_TOKEN_AMOUNT} || clawAmount <= beast::kZERO) return temBAD_AMOUNT; return tesSUCCESS; @@ -121,11 +121,11 @@ preclaimHelper( STAmount const balance = (*sleRippleState)[sfBalance]; // If balance is positive, issuer must have higher address than holder - if (balance > beast::zero && issuer < holder) + if (balance > beast::kZERO && issuer < holder) return tecNO_PERMISSION; // If balance is negative, issuer must have lower address than holder - if (balance < beast::zero && issuer > holder) + if (balance < beast::kZERO && issuer > holder) return tecNO_PERMISSION; // At this point, we know that issuer and holder accounts @@ -142,8 +142,8 @@ preclaimHelper( holder, clawAmount.get().currency, issuer, - FreezeHandling::fhIGNORE_FREEZE, - ctx.j) <= beast::zero) + FreezeHandling::IgnoreFreeze, + ctx.j) <= beast::kZERO) return tecINSUFFICIENT_FUNDS; return tesSUCCESS; @@ -176,9 +176,9 @@ preclaimHelper( ctx.view, holder, clawAmount.get(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - ctx.j) <= beast::zero) + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, + ctx.j) <= beast::kZERO) return tecINSUFFICIENT_FUNDS; return tesSUCCESS; @@ -237,7 +237,7 @@ applyHelper(ApplyContext& ctx) holder, clawAmount.get().currency, clawAmount.getIssuer(), - FreezeHandling::fhIGNORE_FREEZE, + FreezeHandling::IgnoreFreeze, ctx.journal); return directSendNoFee( @@ -257,8 +257,8 @@ applyHelper(ApplyContext& ctx) ctx.view(), holder, clawAmount.get(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.journal); return directSendNoFee( diff --git a/src/libxrpl/tx/transactors/token/MPTokenIssuanceCreate.cpp b/src/libxrpl/tx/transactors/token/MPTokenIssuanceCreate.cpp index 42fc037431..64652a80b0 100644 --- a/src/libxrpl/tx/transactors/token/MPTokenIssuanceCreate.cpp +++ b/src/libxrpl/tx/transactors/token/MPTokenIssuanceCreate.cpp @@ -57,7 +57,7 @@ MPTokenIssuanceCreate::preflight(PreflightContext const& ctx) if (auto const fee = ctx.tx[~sfTransferFee]) { - if (fee > maxTransferFee) + if (fee > kMAX_TRANSFER_FEE) return temBAD_TRANSFER_FEE; // If a non-zero TransferFee is set then the tfTransferable flag @@ -68,7 +68,7 @@ MPTokenIssuanceCreate::preflight(PreflightContext const& ctx) if (auto const domain = ctx.tx[~sfDomainID]) { - if (*domain == beast::zero) + if (*domain == beast::kZERO) return temMALFORMED; // Domain present implies that MPTokenIssuance is not public @@ -78,7 +78,7 @@ MPTokenIssuanceCreate::preflight(PreflightContext const& ctx) if (auto const metadata = ctx.tx[~sfMPTokenMetadata]) { - if (metadata->empty() || metadata->length() > maxMPTokenMetadataLength) + if (metadata->empty() || metadata->length() > kMAX_MP_TOKEN_METADATA_LENGTH) return temMALFORMED; } @@ -88,7 +88,7 @@ MPTokenIssuanceCreate::preflight(PreflightContext const& ctx) if (maxAmt == 0) return temMALFORMED; - if (maxAmt > maxMPTokenAmount) + if (maxAmt > kMAX_MP_TOKEN_AMOUNT) return temMALFORMED; } return tesSUCCESS; diff --git a/src/libxrpl/tx/transactors/token/MPTokenIssuanceSet.cpp b/src/libxrpl/tx/transactors/token/MPTokenIssuanceSet.cpp index 540dd6ef0c..fb0ff06ac2 100644 --- a/src/libxrpl/tx/transactors/token/MPTokenIssuanceSet.cpp +++ b/src/libxrpl/tx/transactors/token/MPTokenIssuanceSet.cpp @@ -52,7 +52,7 @@ struct MPTMutabilityFlags std::uint32_t canMutateFlag; }; -static constexpr std::array mptMutabilityFlags = { +static constexpr std::array kMPT_MUTABILITY_FLAGS = { {{.setFlag = tmfMPTSetCanLock, .clearFlag = tmfMPTClearCanLock, .canMutateFlag = lsmfMPTCanMutateCanLock}, @@ -114,10 +114,10 @@ MPTokenIssuanceSet::preflight(PreflightContext const& ctx) if (isMutate && ((txFlags & tfUniversalMask) != 0u)) return temMALFORMED; - if (transferFee && *transferFee > maxTransferFee) + if (transferFee && *transferFee > kMAX_TRANSFER_FEE) return temBAD_TRANSFER_FEE; - if (metadata && metadata->length() > maxMPTokenMetadataLength) + if (metadata && metadata->length() > kMAX_MP_TOKEN_METADATA_LENGTH) return temMALFORMED; if (mutableFlags) @@ -126,7 +126,7 @@ MPTokenIssuanceSet::preflight(PreflightContext const& ctx) return temINVALID_FLAG; // Can not set and clear the same flag - if (std::ranges::any_of(mptMutabilityFlags, [mutableFlags](auto const& f) { + if (std::ranges::any_of(kMPT_MUTABILITY_FLAGS, [mutableFlags](auto const& f) { return (*mutableFlags & f.setFlag) && (*mutableFlags & f.clearFlag); })) return temINVALID_FLAG; @@ -218,7 +218,7 @@ MPTokenIssuanceSet::preclaim(PreclaimContext const& ctx) if (not sleMptIssuance->isFlag(lsfMPTRequireAuth)) return tecNO_PERMISSION; - if (*domain != beast::zero) + if (*domain != beast::kZERO) { auto const sleDomain = ctx.view.read(keylet::permissionedDomain(*domain)); if (!sleDomain) @@ -236,10 +236,11 @@ MPTokenIssuanceSet::preclaim(PreclaimContext const& ctx) if (auto const mutableFlags = ctx.tx[~sfMutableFlags]) { - if (std::ranges::any_of(mptMutabilityFlags, [mutableFlags, &isMutableFlag](auto const& f) { - return !isMutableFlag(f.canMutateFlag) && - ((*mutableFlags & (f.setFlag | f.clearFlag))); - })) + if (std::ranges::any_of( + kMPT_MUTABILITY_FLAGS, [mutableFlags, &isMutableFlag](auto const& f) { + return !isMutableFlag(f.canMutateFlag) && + ((*mutableFlags & (f.setFlag | f.clearFlag))); + })) return tecNO_PERMISSION; // Clearing lsfMPTRequireAuth is invalid when the issuance already has @@ -303,7 +304,7 @@ MPTokenIssuanceSet::doApply() if (auto const mutableFlags = ctx_.tx[~sfMutableFlags].value_or(0)) { - for (auto const& f : mptMutabilityFlags) + for (auto const& f : kMPT_MUTABILITY_FLAGS) { if ((mutableFlags & f.setFlag) != 0u) { @@ -361,7 +362,7 @@ MPTokenIssuanceSet::doApply() sle->getType() == ltMPTOKEN_ISSUANCE, "MPTokenIssuanceSet::doApply : modifying MPTokenIssuance"); - if (*domainID != beast::zero) + if (*domainID != beast::kZERO) { sle->setFieldH256(sfDomainID, *domainID); } diff --git a/src/libxrpl/tx/transactors/token/TrustSet.cpp b/src/libxrpl/tx/transactors/token/TrustSet.cpp index 1610b2e5b9..27252aef46 100644 --- a/src/libxrpl/tx/transactors/token/TrustSet.cpp +++ b/src/libxrpl/tx/transactors/token/TrustSet.cpp @@ -108,7 +108,7 @@ TrustSet::preflight(PreflightContext const& ctx) return temBAD_CURRENCY; } - if (saLimitAmount < beast::zero) + if (saLimitAmount < beast::kZERO) { JLOG(j.trace()) << "Malformed transaction: Negative credit limit."; return temBAD_LIMIT; @@ -258,7 +258,7 @@ TrustSet::preclaim(PreclaimContext const& ctx) else if (auto const ammSle = ctx.view.read({ltAMM, sleDst->getFieldH256(sfAMMID)})) { auto const lpTokens = ammSle->getFieldAmount(sfLPTokenBalance); - if (lpTokens == beast::zero) + if (lpTokens == beast::kZERO) { return tecAMM_EMPTY; } @@ -369,7 +369,8 @@ TrustSet::doApply() // could use the extra XRP for their own purposes. XRPAmount const reserveCreate( - (uOwnerCount < 2) ? XRPAmount(beast::zero) : view().fees().accountReserve(uOwnerCount + 1)); + (uOwnerCount < 2) ? XRPAmount(beast::kZERO) + : view().fees().accountReserve(uOwnerCount + 1)); std::uint32_t const uQualityIn(bQualityIn ? ctx_.tx.getFieldU32(sfQualityIn) : 0); std::uint32_t uQualityOut(bQualityOut ? ctx_.tx.getFieldU32(sfQualityOut) : 0); @@ -505,7 +506,7 @@ TrustSet::doApply() if (bSetNoRipple && !bClearNoRipple) { - if ((bHigh ? saHighBalance : saLowBalance) >= beast::zero) + if ((bHigh ? saHighBalance : saLowBalance) >= beast::kZERO) { uFlagsOut |= (bHigh ? lsfHighNoRipple : lsfLowNoRipple); } @@ -542,12 +543,12 @@ TrustSet::doApply() bool const bLowReserveSet = (uLowQualityIn != 0u) || (uLowQualityOut != 0u) || ((uFlagsOut & lsfLowNoRipple) == 0) != bLowDefRipple || - ((uFlagsOut & lsfLowFreeze) != 0u) || saLowLimit || saLowBalance > beast::zero; + ((uFlagsOut & lsfLowFreeze) != 0u) || saLowLimit || saLowBalance > beast::kZERO; bool const bLowReserveClear = !bLowReserveSet; bool const bHighReserveSet = (uHighQualityIn != 0u) || (uHighQualityOut != 0u) || ((uFlagsOut & lsfHighNoRipple) == 0) != bHighDefRipple || - ((uFlagsOut & lsfHighFreeze) != 0u) || saHighLimit || saHighBalance > beast::zero; + ((uFlagsOut & lsfHighFreeze) != 0u) || saHighLimit || saHighBalance > beast::kZERO; bool const bHighReserveClear = !bHighReserveSet; bool const bDefault = bLowReserveClear && bHighReserveClear; diff --git a/src/libxrpl/tx/transactors/vault/VaultClawback.cpp b/src/libxrpl/tx/transactors/vault/VaultClawback.cpp index da22b82578..8743227e5c 100644 --- a/src/libxrpl/tx/transactors/vault/VaultClawback.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultClawback.cpp @@ -36,7 +36,7 @@ namespace xrpl { NotTEC VaultClawback::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfVaultID] == beast::zero) + if (ctx.tx[sfVaultID] == beast::kZERO) { JLOG(ctx.j.debug()) << "VaultClawback: zero/empty vault ID."; return temMALFORMED; @@ -46,7 +46,7 @@ VaultClawback::preflight(PreflightContext const& ctx) if (amount) { // Note, zero amount is valid, it means "all". It is also the default. - if (*amount < beast::zero) + if (*amount < beast::kZERO) { return temBAD_AMOUNT; } @@ -134,14 +134,14 @@ VaultClawback::preclaim(PreclaimContext const& ctx) } // If amount is non-zero, the VaultOwner must burn all shares - if (amount != beast::zero) + if (amount != beast::kZERO) { Number const& sharesHeld = accountHolds( ctx.view, holder, share, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, ctx.j); // The VaultOwner must burn all shares @@ -247,15 +247,10 @@ VaultClawback::assetsToClawback( // clamping to assetsAvailable, allowing more assets to be recovered // than available when there was an outstanding loan. Retained for // ledger replay compatibility. - if (!ctx_.view().rules().enabled(fixSecurity3_1_3) && clawbackAmount == beast::zero) + if (!ctx_.view().rules().enabled(fixSecurity3_1_3) && clawbackAmount == beast::kZERO) { auto const sharesDestroyed = accountHolds( - view(), - holder, - share, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_); + view(), holder, share, FreezeHandling::IgnoreFreeze, AuthHandling::IgnoreAuth, j_); auto const maybeAssets = sharesToAssetsWithdraw(vault, sleShareIssuance, sharesDestroyed); if (!maybeAssets) return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE @@ -268,15 +263,10 @@ VaultClawback::assetsToClawback( try { - if (clawbackAmount == beast::zero) + if (clawbackAmount == beast::kZERO) { sharesDestroyed = accountHolds( - view(), - holder, - share, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_); + view(), holder, share, FreezeHandling::IgnoreFreeze, AuthHandling::IgnoreAuth, j_); auto const maybeAssets = sharesToAssetsWithdraw(vault, sleShareIssuance, sharesDestroyed); if (!maybeAssets) @@ -307,7 +297,7 @@ VaultClawback::assetsToClawback( // AssetsAvailable { auto const maybeShares = assetsToSharesWithdraw( - vault, sleShareIssuance, assetsRecovered, TruncateShares::yes); + vault, sleShareIssuance, assetsRecovered, TruncateShares::Yes); if (!maybeShares) return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE sharesDestroyed = *maybeShares; @@ -381,12 +371,7 @@ VaultClawback::doApply() if (account_ == vault->at(sfOwner) && amount.asset() == share) { sharesDestroyed = accountHolds( - view(), - holder, - share, - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_); + view(), holder, share, FreezeHandling::IgnoreFreeze, AuthHandling::IgnoreAuth, j_); } else // The Issuer is clawbacking vault assets { @@ -400,7 +385,7 @@ VaultClawback::doApply() sharesDestroyed = clawbackParts->second; } - if (sharesDestroyed == beast::zero) + if (sharesDestroyed == beast::kZERO) return tecPRECISION_LOSS; assetsTotal -= assetsRecovered; @@ -441,7 +426,7 @@ VaultClawback::doApply() // else quietly ignore, holder balance is not zero } - if (assetsRecovered > beast::zero) + if (assetsRecovered > beast::kZERO) { // Transfer assets from vault to issuer. if (auto const ter = accountSend( @@ -454,9 +439,9 @@ VaultClawback::doApply() view(), vaultAccount, assetsRecovered.asset(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_) < beast::zero) + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, + j_) < beast::kZERO) { // LCOV_EXCL_START JLOG(j_.error()) << "VaultClawback: negative balance of vault assets."; diff --git a/src/libxrpl/tx/transactors/vault/VaultCreate.cpp b/src/libxrpl/tx/transactors/vault/VaultCreate.cpp index cc28abfe65..0346503ae7 100644 --- a/src/libxrpl/tx/transactors/vault/VaultCreate.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultCreate.cpp @@ -52,19 +52,19 @@ VaultCreate::getFlagsMask(PreflightContext const& ctx) NotTEC VaultCreate::preflight(PreflightContext const& ctx) { - if (!validDataLength(ctx.tx[~sfData], maxDataPayloadLength)) + if (!validDataLength(ctx.tx[~sfData], kMAX_DATA_PAYLOAD_LENGTH)) return temMALFORMED; if (auto const withdrawalPolicy = ctx.tx[~sfWithdrawalPolicy]) { // Enforce valid withdrawal policy - if (*withdrawalPolicy != vaultStrategyFirstComeFirstServe) + if (*withdrawalPolicy != kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE) return temMALFORMED; } if (auto const domain = ctx.tx[~sfDomainID]) { - if (*domain == beast::zero) + if (*domain == beast::kZERO) { return temMALFORMED; } @@ -76,13 +76,13 @@ VaultCreate::preflight(PreflightContext const& ctx) if (auto const assetMax = ctx.tx[~sfAssetsMaximum]) { - if (*assetMax < beast::zero) + if (*assetMax < beast::kZERO) return temMALFORMED; } if (auto const metadata = ctx.tx[~sfMPTokenMetadata]) { - if (metadata->empty() || metadata->length() > maxMPTokenMetadataLength) + if (metadata->empty() || metadata->length() > kMAX_MP_TOKEN_METADATA_LENGTH) return temMALFORMED; } @@ -92,7 +92,7 @@ VaultCreate::preflight(PreflightContext const& ctx) if (vaultAsset.holds() || vaultAsset.native()) return temMALFORMED; - if (scale > vaultMaximumIOUScale) + if (scale > kVAULT_MAXIMUM_IOU_SCALE) return temMALFORMED; } @@ -130,7 +130,7 @@ VaultCreate::preclaim(PreclaimContext const& ctx) auto const sequence = ctx.tx.getSeqValue(); if (auto const accountId = pseudoAccountAddress(ctx.view, keylet::vault(account, sequence).key); - accountId == beast::zero) + accountId == beast::kZERO) return terADDRESS_COLLISION; return tesSUCCESS; @@ -171,7 +171,7 @@ VaultCreate::doApply() std::uint8_t const scale = (asset.holds() || asset.native()) ? 0 - : ctx_.tx[~sfScale].value_or(vaultDefaultIOUScale); + : ctx_.tx[~sfScale].value_or(kVAULT_DEFAULT_IOU_SCALE); auto txFlags = tx.getFlags(); std::uint32_t mptFlags = 0; @@ -223,7 +223,7 @@ VaultCreate::doApply() } else { - vault->at(sfWithdrawalPolicy) = vaultStrategyFirstComeFirstServe; + vault->at(sfWithdrawalPolicy) = kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE; } if (scale != 0u) vault->at(sfScale) = scale; diff --git a/src/libxrpl/tx/transactors/vault/VaultDelete.cpp b/src/libxrpl/tx/transactors/vault/VaultDelete.cpp index e4542d524f..58b0fdee82 100644 --- a/src/libxrpl/tx/transactors/vault/VaultDelete.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultDelete.cpp @@ -24,7 +24,7 @@ namespace xrpl { NotTEC VaultDelete::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfVaultID] == beast::zero) + if (ctx.tx[sfVaultID] == beast::kZERO) { JLOG(ctx.j.debug()) << "VaultDelete: zero/empty vault ID."; return temMALFORMED; diff --git a/src/libxrpl/tx/transactors/vault/VaultDeposit.cpp b/src/libxrpl/tx/transactors/vault/VaultDeposit.cpp index fbb8908ddb..501ba58ca5 100644 --- a/src/libxrpl/tx/transactors/vault/VaultDeposit.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultDeposit.cpp @@ -28,13 +28,13 @@ namespace xrpl { NotTEC VaultDeposit::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfVaultID] == beast::zero) + if (ctx.tx[sfVaultID] == beast::kZERO) { JLOG(ctx.j.debug()) << "VaultDeposit: zero/empty vault ID."; return temMALFORMED; } - if (ctx.tx[sfAmount] <= beast::zero) + if (ctx.tx[sfAmount] <= beast::kZERO) return temBAD_AMOUNT; return tesSUCCESS; @@ -125,10 +125,10 @@ VaultDeposit::preclaim(PreclaimContext const& ctx) ctx.view, account, vaultAsset, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahZERO_IF_UNAUTHORIZED, + FreezeHandling::ZeroIfFrozen, + AuthHandling::ZeroIfUnauthorized, ctx.j, - SpendableHandling::shFULL_BALANCE) < assets) + SpendableHandling::FullBalance) < assets) return tecINSUFFICIENT_FUNDS; return tesSUCCESS; @@ -204,7 +204,7 @@ VaultDeposit::doApply() return tecINTERNAL; // LCOV_EXCL_LINE sharesCreated = *maybeShares; } - if (sharesCreated == beast::zero) + if (sharesCreated == beast::kZERO) return tecPRECISION_LOSS; auto const maybeAssets = sharesToAssetsDeposit(vault, sleIssuance, sharesCreated); @@ -257,9 +257,9 @@ VaultDeposit::doApply() view(), account_, assetsDeposited.asset(), - FreezeHandling::fhIGNORE_FREEZE, - AuthHandling::ahIGNORE_AUTH, - j_) < beast::zero) + FreezeHandling::IgnoreFreeze, + AuthHandling::IgnoreAuth, + j_) < beast::kZERO) { // LCOV_EXCL_START JLOG(j_.error()) << "VaultDeposit: negative balance of account assets."; diff --git a/src/libxrpl/tx/transactors/vault/VaultSet.cpp b/src/libxrpl/tx/transactors/vault/VaultSet.cpp index a5b0b20699..92dbb198f3 100644 --- a/src/libxrpl/tx/transactors/vault/VaultSet.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultSet.cpp @@ -28,7 +28,7 @@ VaultSet::checkExtraFeatures(PreflightContext const& ctx) NotTEC VaultSet::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfVaultID] == beast::zero) + if (ctx.tx[sfVaultID] == beast::kZERO) { JLOG(ctx.j.debug()) << "VaultSet: zero/empty vault ID."; return temMALFORMED; @@ -36,7 +36,7 @@ VaultSet::preflight(PreflightContext const& ctx) if (auto const data = ctx.tx[~sfData]) { - if (data->empty() || data->length() > maxDataPayloadLength) + if (data->empty() || data->length() > kMAX_DATA_PAYLOAD_LENGTH) { JLOG(ctx.j.debug()) << "VaultSet: invalid data payload size."; return temMALFORMED; @@ -45,7 +45,7 @@ VaultSet::preflight(PreflightContext const& ctx) if (auto const assetMax = ctx.tx[~sfAssetsMaximum]) { - if (*assetMax < beast::zero) + if (*assetMax < beast::kZERO) { JLOG(ctx.j.debug()) << "VaultSet: invalid max assets."; return temMALFORMED; @@ -95,7 +95,7 @@ VaultSet::preclaim(PreclaimContext const& ctx) return tecNO_PERMISSION; } - if (*domain != beast::zero) + if (*domain != beast::kZERO) { auto const sleDomain = ctx.view.read(keylet::permissionedDomain(*domain)); if (!sleDomain) @@ -153,7 +153,7 @@ VaultSet::doApply() if (auto const domainId = tx[~sfDomainID]; domainId) { - if (*domainId != beast::zero) + if (*domainId != beast::kZERO) { // In VaultSet::preclaim we enforce that lsfVaultPrivate must have // been set in the vault. We currently do not support making such a diff --git a/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp b/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp index 3e608733b6..6932dc21f2 100644 --- a/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp @@ -29,18 +29,18 @@ namespace xrpl { NotTEC VaultWithdraw::preflight(PreflightContext const& ctx) { - if (ctx.tx[sfVaultID] == beast::zero) + if (ctx.tx[sfVaultID] == beast::kZERO) { JLOG(ctx.j.debug()) << "VaultWithdraw: zero/empty vault ID."; return temMALFORMED; } - if (ctx.tx[sfAmount] <= beast::zero) + if (ctx.tx[sfAmount] <= beast::kZERO) return temBAD_AMOUNT; if (auto const destination = ctx.tx[~sfDestination]) { - if (*destination == beast::zero) + if (*destination == beast::kZERO) { return temMALFORMED; } @@ -72,7 +72,7 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx) } // Enforce valid withdrawal policy - if (vault->at(sfWithdrawalPolicy) != vaultStrategyFirstComeFirstServe) + if (vault->at(sfWithdrawalPolicy) != kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE) { // LCOV_EXCL_START JLOG(ctx.j.error()) << "VaultWithdraw: invalid withdrawal policy."; @@ -187,7 +187,7 @@ VaultWithdraw::doApply() sharesRedeemed = *maybeShares; } - if (sharesRedeemed == beast::zero) + if (sharesRedeemed == beast::kZERO) return tecPRECISION_LOSS; auto const maybeAssets = sharesToAssetsWithdraw(vault, sleIssuance, sharesRedeemed); if (!maybeAssets) @@ -222,12 +222,8 @@ VaultWithdraw::doApply() } if (accountHolds( - view(), - account_, - share, - FreezeHandling::fhZERO_IF_FROZEN, - AuthHandling::ahIGNORE_AUTH, - j_) < sharesRedeemed) + view(), account_, share, FreezeHandling::ZeroIfFrozen, AuthHandling::IgnoreAuth, j_) < + sharesRedeemed) { JLOG(j_.debug()) << "VaultWithdraw: account doesn't hold enough shares"; return tecINSUFFICIENT_FUNDS; diff --git a/src/test/app/AMMCalc_test.cpp b/src/test/app/AMMCalc_test.cpp index 6c32c6118d..3c4a62bfd3 100644 --- a/src/test/app/AMMCalc_test.cpp +++ b/src/test/app/AMMCalc_test.cpp @@ -41,13 +41,13 @@ namespace xrpl::test { * find out AMM offer, which changes AMM's SP quality to * the Offer's quality. */ -class AMMCalc_test : public beast::unit_test::suite +class AMMCalc_test : public beast::unit_test::Suite { using token_iter = boost::sregex_token_iterator; using steps = std::vector>; using transfer_rates = std::map; using swapargs = std::tuple; - jtx::Account const gw{jtx::Account("gw")}; + jtx::Account const gw_{jtx::Account("gw")}; token_iter const end_; std::optional @@ -74,7 +74,7 @@ class AMMCalc_test : public beast::unit_test::suite { return XRPAmount{std::stoll(match[2])}; } - return amountFromString(gw[match[1]].asset(), match[2]); + return amountFromString(gw_[match[1]].asset(), match[2]); } return std::nullopt; } @@ -187,7 +187,8 @@ class AMMCalc_test : public beast::unit_test::suite static std::string toString(STAmount const& a) { - return (boost::format("%s/%s") % a.getText() % to_string(a.get().currency)).str(); + return (boost::format("%s/%s") % a.getText() % ::xrpl::to_string(a.get().currency)) + .str(); } static STAmount @@ -213,7 +214,7 @@ class AMMCalc_test : public beast::unit_test::suite int limitingStep = vp.size(); STAmount limitStepOut{}; auto transferRate = [&](STAmount const& amt) { - auto const currency = to_string(amt.get().currency); + auto const currency = ::xrpl::to_string(amt.get().currency); return rates.contains(currency) ? rates.at(currency) : QUALITY_ONE; }; // swap out reverse @@ -229,7 +230,7 @@ class AMMCalc_test : public beast::unit_test::suite } else if (sout <= amts.out) { - sin = Quality{amts}.ceil_out(amts, sout).in; + sin = Quality{amts}.ceilOut(amts, sout).in; } // limiting step else @@ -255,7 +256,7 @@ class AMMCalc_test : public beast::unit_test::suite // assume there is no limiting step in fwd else { - sout = Quality{amts}.ceil_in(amts, sin).out; + sout = Quality{amts}.ceilIn(amts, sin).out; } sin = sout; resultOut = sout; @@ -276,7 +277,7 @@ class AMMCalc_test : public beast::unit_test::suite int limitingStep = 0; STAmount limitStepIn{}; auto transferRate = [&](STAmount const& amt) { - auto const currency = to_string(amt.get().currency); + auto const currency = ::xrpl::to_string(amt.get().currency); return rates.contains(currency) ? rates.at(currency) : QUALITY_ONE; }; // Swap in forward @@ -292,7 +293,7 @@ class AMMCalc_test : public beast::unit_test::suite } else if (sin <= amts.in) { - sout = Quality{amts}.ceil_in(amts, sin).out; + sout = Quality{amts}.ceilIn(amts, sin).out; } // limiting step, requested in is greater than the offer // pay exactly amts.in, which gets amts.out @@ -318,7 +319,7 @@ class AMMCalc_test : public beast::unit_test::suite // assume there is no limiting step else { - sin = Quality{amts}.ceil_out(amts, sout).in; + sin = Quality{amts}.ceilOut(amts, sout).in; } resultIn = sin; } @@ -396,8 +397,9 @@ class AMMCalc_test : public beast::unit_test::suite if (auto const pool = getAmounts(++p); pool) { Account const amm("amm"); - auto const LPT = amm["LPT"]; - std::cout << to_string(ammLPTokens(pool->first.in, pool->first.out, LPT).iou()) + auto const lpt = amm["LPT"]; + std::cout << ::xrpl::to_string( + ammLPTokens(pool->first.in, pool->first.out, lpt).iou()) << std::endl; return true; } diff --git a/src/test/app/AMMClawbackMPT_test.cpp b/src/test/app/AMMClawbackMPT_test.cpp index 393c0b062c..6f0fff0282 100644 --- a/src/test/app/AMMClawbackMPT_test.cpp +++ b/src/test/app/AMMClawbackMPT_test.cpp @@ -27,7 +27,7 @@ #include namespace xrpl::test { -class AMMClawbackMPT_test : public beast::unit_test::suite +class AMMClawbackMPT_test : public beast::unit_test::Suite { void testInvalidRequest(FeatureBitset features) @@ -47,62 +47,62 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - auto const USD = gw["USD"]; - env.trust(USD(10000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(10000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM amm(env, gw, BTC(100), USD(100)); + AMM amm(env, gw, btc(100), usd(100)); // holder does not exist - env(amm::ammClawback(gw, Account("unknown"), USD, BTC, std::nullopt), - ter(terNO_ACCOUNT)); + env(amm::ammClawback(gw, Account("unknown"), usd, btc, std::nullopt), + Ter(terNO_ACCOUNT)); // can not clawback from self. - env(amm::ammClawback(gw, gw, USD, BTC, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(gw, gw, usd, btc, std::nullopt), Ter(temMALFORMED)); // provided Asset does not match issuer gw { env(amm::ammClawback( - gw, alice, Issue{gw["USD"].currency, alice.id()}, BTC, std::nullopt), - ter(temMALFORMED)); - env(amm::ammClawback(gw, alice, MPTIssue{makeMptID(1, alice)}, USD, std::nullopt), - ter(temMALFORMED)); + gw, alice, Issue{gw["USD"].currency, alice.id()}, btc, std::nullopt), + Ter(temMALFORMED)); + env(amm::ammClawback(gw, alice, MPTIssue{makeMptID(1, alice)}, usd, std::nullopt), + Ter(temMALFORMED)); } // Amount does not match asset { env(amm::ammClawback( - gw, alice, USD, BTC, STAmount{Issue{gw["USD"].currency, alice.id()}, 1}), - ter(temBAD_AMOUNT)); + gw, alice, usd, btc, STAmount{Issue{gw["USD"].currency, alice.id()}, 1}), + Ter(temBAD_AMOUNT)); env(amm::ammClawback( - gw, alice, BTC, USD, STAmount{MPTIssue{makeMptID(1, alice)}, 10}), - ter(temBAD_AMOUNT)); + gw, alice, btc, usd, STAmount{MPTIssue{makeMptID(1, alice)}, 10}), + Ter(temBAD_AMOUNT)); } // Amount is not greater than 0 { - env(amm::ammClawback(gw, alice, BTC, USD, BTC(-1)), ter(temBAD_AMOUNT)); - env(amm::ammClawback(gw, alice, BTC, USD, BTC(0)), ter(temBAD_AMOUNT)); + env(amm::ammClawback(gw, alice, btc, usd, btc(-1)), Ter(temBAD_AMOUNT)); + env(amm::ammClawback(gw, alice, btc, usd, btc(0)), Ter(temBAD_AMOUNT)); } // clawback from account not holding lptoken - env(amm::ammClawback(gw, bob, BTC, USD, BTC(1000)), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, bob, btc, usd, btc(1000)), Ter(tecAMM_BALANCE)); // can not perform regular claw from amm pool { - Issue const usd(USD.currency, amm.ammAccount()); - auto amount = amountFromString(usd, "10"); + Issue const ammUsd(usd.currency, amm.ammAccount()); + auto amount = amountFromString(ammUsd, "10"); auto const err = feature[featureSingleAssetVault] ? tecPSEUDO_ACCOUNT : tecAMM_ACCOUNT; - env(claw(gw, amount), ter(err)); + env(claw(gw, amount), Ter(err)); } // AMM does not exist @@ -111,7 +111,7 @@ class AMMClawbackMPT_test : public beast::unit_test::suite amm.withdrawAll(gw); BEAST_EXPECT(!amm.ammExists()); env.close(); - env(amm::ammClawback(gw, alice, USD, BTC, std::nullopt), ter(terNO_AMM)); + env(amm::ammClawback(gw, alice, usd, btc, std::nullopt), Ter(terNO_AMM)); } } @@ -126,21 +126,21 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000}); - auto const USD = gw["USD"]; - env.trust(USD(10000), alice); - env(pay(gw, alice, USD(10000))); + auto const usd = gw["USD"]; + env.trust(usd(10000), alice); + env(pay(gw, alice, usd(10000))); env.close(); - AMM amm(env, gw, BTC(100), USD(100)); + AMM amm(env, gw, btc(100), usd(100)); env.close(); amm.deposit(alice, 1'000); env.close(); // can not clawback when tfMPTCanClawback is not enabled - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), ter(tecNO_PERMISSION)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Ter(tecNO_PERMISSION)); } // can not claw with tfClawTwoAssets if the assets are not issued by the @@ -156,20 +156,20 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(10000), alice); - env(pay(gw, alice, USD(10000))); + auto const usd = gw["USD"]; + env.trust(usd(10000), alice); + env(pay(gw, alice, usd(10000))); env.close(); // todo: check tfMPTCanTransfer in xrpl.org - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw2, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM const amm(env, alice, BTC(100), USD(100)); + AMM const amm(env, alice, btc(100), usd(100)); env.close(); { @@ -177,9 +177,9 @@ class AMMClawbackMPT_test : public beast::unit_test::suite // tfClawTwoAssets, but the issuer only issues USD in the pool. // The issuer is not allowed to set tfClawTwoAssets flag if he // did not issue both assets in the pool. - env(amm::ammClawback(gw, alice, USD, BTC, std::nullopt), - txflags(tfClawTwoAssets), - ter(temINVALID_FLAG)); + env(amm::ammClawback(gw, alice, usd, btc, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(temINVALID_FLAG)); } } @@ -192,19 +192,19 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env.fund(XRP(10000), gw, alice); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM const amm(env, alice, BTC(100), XRP(100)); + AMM const amm(env, alice, btc(100), XRP(100)); env.close(); // If asfAllowTrustLineClawback is not set, the issuer can // still claw MPT because the MPT's tfMPTCanClawback is set. - env(amm::ammClawback(gw, alice, BTC, XRP, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, XRP, std::nullopt)); } } @@ -220,27 +220,27 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 10'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM const amm(env, alice, XRP(1'000), BTC(1'000)); + AMM const amm(env, alice, XRP(1'000), btc(1'000)); // disable featureAMMClawback env.disableFeature(featureAMMClawback); - env(amm::ammClawback(gw, alice, BTC, XRP, std::nullopt), ter(temDISABLED)); + env(amm::ammClawback(gw, alice, btc, XRP, std::nullopt), Ter(temDISABLED)); // enable featureAMMClawback and disable featureMPTokensV2 env.enableFeature(featureAMMClawback); env.disableFeature(featureMPTokensV2); - env(amm::ammClawback(gw, alice, BTC, XRP, BTC(100)), ter(temDISABLED)); + env(amm::ammClawback(gw, alice, btc, XRP, btc(100)), Ter(temDISABLED)); // enable featureMPTokensV2 env.enableFeature(featureMPTokensV2); - env(amm::ammClawback(gw, alice, BTC, XRP, BTC(200))); + env(amm::ammClawback(gw, alice, btc, XRP, btc(200))); } void @@ -262,59 +262,59 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw2, .holders = {alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM const amm(env, alice, BTC(1000000000), USD(2000)); + AMM const amm(env, alice, btc(1000000000), usd(2000)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'000000), USD(2000), IOUAmount{1414'213'562373095, -9})); + btc(1'000'000000), usd(2000), IOUAmount{1414'213'562373095, -9})); // can not set tfClawTwoAssets because the assets are not issued by // the same issuer. - env(amm::ammClawback(gw2, alice, BTC, USD, BTC(1000)), - txflags(tfClawTwoAssets), - ter(temINVALID_FLAG)); + env(amm::ammClawback(gw2, alice, btc, usd, btc(1000)), + Txflags(tfClawTwoAssets), + Ter(temINVALID_FLAG)); - auto aliceUSD = env.balance(alice, USD); - auto aliceBTC = env.balance(alice, BTC); + auto aliceUSD = env.balance(alice, usd); + auto aliceBTC = env.balance(alice, btc); // gw clawback 1000 USD from alice - env(amm::ammClawback(gw, alice, USD, BTC, USD(1000))); + env(amm::ammClawback(gw, alice, usd, btc, usd(1000))); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(500'000000), USD(1000), IOUAmount{707'106'7811865475, -10})); + amm.expectBalances(btc(500'000000), usd(1000), IOUAmount{707'106'7811865475, -10})); // USD is clawed back, - env.require(balance(alice, aliceUSD)); + env.require(Balance(alice, aliceUSD)); // a proportional amount of BTC is returned to alice - env.require(balance(alice, aliceBTC + BTC(500'000000))); - aliceBTC = env.balance(alice, BTC); + env.require(Balance(alice, aliceBTC + btc(500'000000))); + aliceBTC = env.balance(alice, btc); // gw2 clawback 250'000000 BTC from alice - env(amm::ammClawback(gw2, alice, BTC, USD, BTC(250'000000))); + env(amm::ammClawback(gw2, alice, btc, usd, btc(250'000000))); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(250'000000), USD(500), IOUAmount{353'553'3905932737, -10})); - env.require(balance(alice, aliceUSD + USD(500))); - env.require(balance(alice, aliceBTC)); - aliceUSD = env.balance(alice, USD); + amm.expectBalances(btc(250'000000), usd(500), IOUAmount{353'553'3905932737, -10})); + env.require(Balance(alice, aliceUSD + usd(500))); + env.require(Balance(alice, aliceBTC)); + aliceUSD = env.balance(alice, usd); // gw2 clawback 500'000000 BTC which exceeds the balance, // this will clawback all and the amm will be deleted. - env(amm::ammClawback(gw2, alice, BTC, USD, BTC(500'000000))); + env(amm::ammClawback(gw2, alice, btc, usd, btc(500'000000))); env.close(); BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceUSD + USD(500))); - env.require(balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(500))); + env.require(Balance(alice, aliceBTC)); } // AMMClawback from MPT/XRP pool @@ -329,87 +329,87 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(1000000000), XRP(2000)); + AMM amm(env, alice, btc(1000000000), XRP(2000)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'000000), XRP(2000), IOUAmount{1'414'213'562'373095, -6})); + btc(1'000'000000), XRP(2000), IOUAmount{1'414'213'562'373095, -6})); - amm.deposit(bob, BTC(2'000'000000), XRP(4000)); + amm.deposit(bob, btc(2'000'000000), XRP(4000)); BEAST_EXPECT(amm.expectBalances( - BTC(3'000'000000), XRP(6000), IOUAmount{4'242'640'687'119285, -6})); + btc(3'000'000000), XRP(6000), IOUAmount{4'242'640'687'119285, -6})); auto aliceXRP = env.balance(alice, XRP); - auto aliceBTC = env.balance(alice, BTC); + auto aliceBTC = env.balance(alice, btc); auto bobXRP = env.balance(bob, XRP); - auto bobBTC = env.balance(bob, BTC); + auto bobBTC = env.balance(bob, btc); // can not claw XRP - env(amm::ammClawback(gw, alice, XRP, BTC, XRP(1000)), ter(temMALFORMED)); + env(amm::ammClawback(gw, alice, XRP, btc, XRP(1000)), Ter(temMALFORMED)); // can not set tfClawTwoAssets - env(amm::ammClawback(gw, alice, BTC, XRP, BTC(1000)), - txflags(tfClawTwoAssets), - ter(temINVALID_FLAG)); + env(amm::ammClawback(gw, alice, btc, XRP, btc(1000)), + Txflags(tfClawTwoAssets), + Ter(temINVALID_FLAG)); // gw clawback 500 BTC from alice - env(amm::ammClawback(gw, alice, BTC, XRP, BTC(500))); + env(amm::ammClawback(gw, alice, btc, XRP, btc(500))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(2'999'999501), + btc(2'999'999501), STAmount{XRP, UINT64_C(5'999'999001)}, IOUAmount{4'242'639'980'012504, -6})); - env.require(balance(alice, aliceXRP + drops(999))); - env.require(balance(alice, aliceBTC)); - env.require(balance(bob, bobXRP)); - env.require(balance(bob, bobBTC)); + env.require(Balance(alice, aliceXRP + drops(999))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(bob, bobXRP)); + env.require(Balance(bob, bobBTC)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'414'212'855'266314, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{2'828'427'124'74619, -5})); aliceXRP = env.balance(alice, XRP); // gw clawback 1000'000000 BTC from bob - env(amm::ammClawback(gw, bob, BTC, XRP, BTC(1'000'000000))); + env(amm::ammClawback(gw, bob, btc, XRP, btc(1'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'999'999501), + btc(1'999'999501), STAmount{XRP, UINT64_C(3'999'999002)}, IOUAmount{2828426418'110813, -6})); - env.require(balance(alice, aliceXRP)); - env.require(balance(alice, aliceBTC)); - env.require(balance(bob, bobXRP + XRPAmount(1999999999))); - env.require(balance(bob, bobBTC)); + env.require(Balance(alice, aliceXRP)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(bob, bobXRP + XRPAmount(1999999999))); + env.require(Balance(bob, bobBTC)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'414'212'855'266314, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{1'414'213'562'844499, -6})); bobXRP = env.balance(bob, XRP); // gw clawback 1000'000000 BTC from alice, which exceeds her balance // will clawback all her balance - env(amm::ammClawback(gw, alice, BTC, XRP, BTC(1'000'000000))); + env(amm::ammClawback(gw, alice, btc, XRP, btc(1'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'000001), XRPAmount(2'000'000002), IOUAmount{1'414'213'562'844499, -6})); - env.require(balance(alice, aliceXRP + STAmount{XRP, UINT64_C(1'999'999000)})); - env.require(balance(alice, aliceBTC)); - env.require(balance(bob, bobXRP)); - env.require(balance(bob, bobBTC)); + btc(1'000'000001), XRPAmount(2'000'000002), IOUAmount{1'414'213'562'844499, -6})); + env.require(Balance(alice, aliceXRP + STAmount{XRP, UINT64_C(1'999'999000)})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(bob, bobXRP)); + env.require(Balance(bob, bobBTC)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{1'414'213'562'844499, -6})); aliceXRP = env.balance(alice, XRP); // gw clawback from bob, which exceeds his balance - env(amm::ammClawback(gw, bob, BTC, XRP, BTC(2'000'000000))); + env(amm::ammClawback(gw, bob, btc, XRP, btc(2'000'000000))); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceXRP)); - env.require(balance(alice, aliceBTC)); - env.require(balance(bob, bobXRP + XRPAmount(2000000002))); - env.require(balance(bob, bobBTC)); + env.require(Balance(alice, aliceXRP)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(bob, bobXRP + XRPAmount(2000000002))); + env.require(Balance(bob, bobBTC)); } // AMMClawback from MPT/MPT pool, different issuers @@ -426,80 +426,80 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, .issuer = gw2, .holders = {alice, bob}, .pay = 30'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(2'000'000000), ETH(3'000'000000)); + AMM amm(env, alice, btc(2'000'000000), eth(3'000'000000)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(2'000'000000), ETH(3'000'000000), IOUAmount{2'449'489'742'783178, -6})); + btc(2'000'000000), eth(3'000'000000), IOUAmount{2'449'489'742'783178, -6})); - amm.deposit(bob, BTC(4'000'000000), ETH(6'000'000000)); + amm.deposit(bob, btc(4'000'000000), eth(6'000'000000)); BEAST_EXPECT(amm.expectBalances( - BTC(6'000'000000), ETH(9'000'000000), IOUAmount{7'348'469'228'349534, -6})); + btc(6'000'000000), eth(9'000'000000), IOUAmount{7'348'469'228'349534, -6})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceETH = env.balance(alice, ETH); - auto bobBTC = env.balance(bob, BTC); - auto bobETH = env.balance(bob, ETH); + auto aliceBTC = env.balance(alice, btc); + auto aliceETH = env.balance(alice, eth); + auto bobBTC = env.balance(bob, btc); + auto bobETH = env.balance(bob, eth); // gw clawback BTC from alice - env(amm::ammClawback(gw, alice, BTC, ETH, BTC(1'000'000000))); + env(amm::ammClawback(gw, alice, btc, eth, btc(1'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(5'000'000000), ETH(7'500'000000), IOUAmount{6'123'724'356'957944, -6})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH + ETH(1'500'000000))); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + btc(5'000'000000), eth(7'500'000000), IOUAmount{6'123'724'356'957944, -6})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH + eth(1'500'000000))); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'224'744'871'391588, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{4'898'979'485'566356, -6})); - aliceETH = env.balance(alice, ETH); + aliceETH = env.balance(alice, eth); // gw2 clawback ETH from bob - env(amm::ammClawback(gw2, bob, ETH, BTC, ETH(3'000'000000))); + env(amm::ammClawback(gw2, bob, eth, btc, eth(3'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(3'000'000000), ETH(4'500'000000), IOUAmount{3'674'234'614'174766, -6})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC + BTC(2'000'000000))); - env.require(balance(bob, bobETH)); + btc(3'000'000000), eth(4'500'000000), IOUAmount{3'674'234'614'174766, -6})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC + btc(2'000'000000))); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'224'744'871'391588, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{2'449'489'742'783178, -6})); - bobBTC = env.balance(bob, BTC); + bobBTC = env.balance(bob, btc); // gw2 clawback ETH from alice, which exceeds her balance - env(amm::ammClawback(gw2, alice, ETH, BTC, ETH(4'000'000000))); + env(amm::ammClawback(gw2, alice, eth, btc, eth(4'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(2'000'000001), ETH(3'000'000001), IOUAmount{2'449'489'742'783178, -6})); - env.require(balance(alice, aliceBTC + BTC(999'999999))); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); - aliceBTC = env.balance(alice, BTC); + btc(2'000'000001), eth(3'000'000001), IOUAmount{2'449'489'742'783178, -6})); + env.require(Balance(alice, aliceBTC + btc(999'999999))); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); + aliceBTC = env.balance(alice, btc); // gw clawback BTC from bob, which exceeds his balance - env(amm::ammClawback(gw, bob, BTC, ETH, BTC(3'000'000000))); + env(amm::ammClawback(gw, bob, btc, eth, btc(3'000'000000))); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH + ETH(3'000'000001))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH + eth(3'000'000001))); } } @@ -523,53 +523,53 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(200000), bob); - env(pay(gw, bob, USD(60000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(200000), bob); + env(pay(gw, bob, usd(60000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw2, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(2000000000), USD(2000)); + AMM amm(env, alice, btc(2000000000), usd(2000)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(2'000'000000), USD(2000), IOUAmount(2000000))); + BEAST_EXPECT(amm.expectBalances(btc(2'000'000000), usd(2000), IOUAmount(2000000))); // gw clawback all BTC from alice - amm.deposit(bob, BTC(1'000'000000), USD(2000)); + amm.deposit(bob, btc(1'000'000000), usd(2000)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(3'000'000000), USD(3000), IOUAmount(3000000))); + BEAST_EXPECT(amm.expectBalances(btc(3'000'000000), usd(3000), IOUAmount(3000000))); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - auto bobBTC = env.balance(bob, BTC); - auto bobUSD = env.balance(bob, USD); + auto aliceBTC = env.balance(alice, btc); + auto aliceUSD = env.balance(alice, usd); + auto bobBTC = env.balance(bob, btc); + auto bobUSD = env.balance(bob, usd); // gw2 clawback all BTC from alice - env(amm::ammClawback(gw2, alice, BTC, USD, std::nullopt)); + env(amm::ammClawback(gw2, alice, btc, usd, std::nullopt)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(1'000'000000), USD(1000), IOUAmount(1000000))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(2000))); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobUSD)); - aliceUSD = env.balance(alice, USD); + BEAST_EXPECT(amm.expectBalances(btc(1'000'000000), usd(1000), IOUAmount(1000000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(2000))); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobUSD)); + aliceUSD = env.balance(alice, usd); // gw clawback all USD from bob - env(amm::ammClawback(gw, bob, USD, BTC, std::nullopt)); + env(amm::ammClawback(gw, bob, usd, btc, std::nullopt)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); - env.require(balance(bob, bobBTC + BTC(1'000'000000))); - env.require(balance(bob, bobUSD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(bob, bobBTC + btc(1'000'000000))); + env.require(Balance(bob, bobUSD)); } // AMMClawback all from MPT/XRP pool @@ -584,47 +584,47 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(5000), XRP(10'000)); + AMM amm(env, alice, btc(5000), XRP(10'000)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(5'000), XRP(10'000), IOUAmount{7'071'067'811865475, -9})); + amm.expectBalances(btc(5'000), XRP(10'000), IOUAmount{7'071'067'811865475, -9})); - amm.deposit(bob, BTC(10'000), XRP(20'000)); + amm.deposit(bob, btc(10'000), XRP(20'000)); BEAST_EXPECT( - amm.expectBalances(BTC(15'000), XRP(30'000), IOUAmount{21'213'203'43559642, -8})); + amm.expectBalances(btc(15'000), XRP(30'000), IOUAmount{21'213'203'43559642, -8})); auto aliceXRP = env.balance(alice, XRP); - auto aliceBTC = env.balance(alice, BTC); + auto aliceBTC = env.balance(alice, btc); auto bobXRP = env.balance(bob, XRP); - auto bobBTC = env.balance(bob, BTC); + auto bobBTC = env.balance(bob, btc); // gw clawback all BTC from alice - env(amm::ammClawback(gw, alice, BTC, XRP, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, XRP, std::nullopt)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(10'000), XRP(20'000), IOUAmount{14'142'135'62373094, -8})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceXRP + XRP(10'000))); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobXRP)); + amm.expectBalances(btc(10'000), XRP(20'000), IOUAmount{14'142'135'62373094, -8})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceXRP + XRP(10'000))); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobXRP)); aliceXRP = env.balance(alice, XRP); // gw clawback all BTC from bob - env(amm::ammClawback(gw, bob, BTC, XRP, std::nullopt)); + env(amm::ammClawback(gw, bob, btc, XRP, std::nullopt)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceXRP)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobXRP + XRP(20'000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceXRP)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobXRP + XRP(20'000))); } // AMMClawback all from MPT/MPT pool, different issuers @@ -641,54 +641,54 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, .issuer = gw2, .holders = {alice, bob}, .pay = 30'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(20'000), ETH(50'000)); + AMM amm(env, alice, btc(20'000), eth(50'000)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(20'000), ETH(50'000), IOUAmount{31'622'77660168379, -11})); + amm.expectBalances(btc(20'000), eth(50'000), IOUAmount{31'622'77660168379, -11})); - amm.deposit(bob, BTC(40'000), ETH(100'000)); + amm.deposit(bob, btc(40'000), eth(100'000)); BEAST_EXPECT( - amm.expectBalances(BTC(60'000), ETH(150'000), IOUAmount{94'868'32980505137, -11})); + amm.expectBalances(btc(60'000), eth(150'000), IOUAmount{94'868'32980505137, -11})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceETH = env.balance(alice, ETH); - auto bobBTC = env.balance(bob, BTC); - auto bobETH = env.balance(bob, ETH); + auto aliceBTC = env.balance(alice, btc); + auto aliceETH = env.balance(alice, eth); + auto bobBTC = env.balance(bob, btc); + auto bobETH = env.balance(bob, eth); // gw clawback all BTC from bob - env(amm::ammClawback(gw, bob, BTC, ETH, std::nullopt)); + env(amm::ammClawback(gw, bob, btc, eth, std::nullopt)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(20'000), ETH(50'000), IOUAmount{31'622'77660168379, -11})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH + ETH(100'000))); - bobETH = env.balance(bob, ETH); + amm.expectBalances(btc(20'000), eth(50'000), IOUAmount{31'622'77660168379, -11})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH + eth(100'000))); + bobETH = env.balance(bob, eth); // gw2 clawback all ETH from alice - env(amm::ammClawback(gw2, alice, ETH, BTC, std::nullopt)); + env(amm::ammClawback(gw2, alice, eth, btc, std::nullopt)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC + BTC(20'000))); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + env.require(Balance(alice, aliceBTC + btc(20'000))); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); } } @@ -710,88 +710,88 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(40000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(40000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(1'000'000000), USD(2000)); + AMM amm(env, alice, btc(1'000'000000), usd(2000)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'000000), USD(2000), IOUAmount{1414'213'562373095, -9})); + btc(1'000'000000), usd(2000), IOUAmount{1414'213'562373095, -9})); - amm.deposit(bob, BTC(500'000000), USD(1000)); + amm.deposit(bob, btc(500'000000), usd(1000)); BEAST_EXPECT(amm.expectBalances( - BTC(1'500'000000), - STAmount{USD, UINT64_C(2'999'999999999999), -12}, + btc(1'500'000000), + STAmount{usd, UINT64_C(2'999'999999999999), -12}, IOUAmount{2'121'320'343559642, -9})); - auto aliceUSD = env.balance(alice, USD); - auto aliceBTC = env.balance(alice, BTC); - auto bobUSD = env.balance(bob, USD); - auto bobBTC = env.balance(bob, BTC); + auto aliceUSD = env.balance(alice, usd); + auto aliceBTC = env.balance(alice, btc); + auto bobUSD = env.balance(bob, usd); + auto bobBTC = env.balance(bob, btc); // gw clawback 500 USD from alice. - env(amm::ammClawback(gw, alice, USD, BTC, USD(500))); + env(amm::ammClawback(gw, alice, usd, btc, usd(500))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1250'000001), USD(2500), IOUAmount{1'767'766'952966369, -9})); - env.require(balance(alice, aliceUSD)); - env.require(balance(alice, aliceBTC + BTC(249'999999))); - env.require(balance(bob, bobUSD)); - env.require(balance(bob, bobBTC)); - aliceBTC = env.balance(alice, BTC); + btc(1250'000001), usd(2500), IOUAmount{1'767'766'952966369, -9})); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC + btc(249'999999))); + env.require(Balance(bob, bobUSD)); + env.require(Balance(bob, bobBTC)); + aliceBTC = env.balance(alice, btc); // gw clawback 250'000000 BTC and 500 USD from bob // with tfClawTwoAssets - env(amm::ammClawback(gw, bob, BTC, USD, BTC(250'000000)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, bob, btc, usd, btc(250'000000)), Txflags(tfClawTwoAssets)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'000002), - STAmount{USD, UINT64_C(2000'0000004), -7}, + btc(1'000'000002), + STAmount{usd, UINT64_C(2000'0000004), -7}, IOUAmount{1'414'213'562655938, -9})); - env.require(balance(alice, aliceUSD)); - env.require(balance(alice, aliceBTC)); - env.require(balance(bob, bobUSD)); - env.require(balance(bob, bobBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(bob, bobUSD)); + env.require(Balance(bob, bobBTC)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'060'660'171779822, -9})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{353'553'390876116, -9})); // gw clawback USD from alice exceeding her balance - env(amm::ammClawback(gw, alice, USD, BTC, USD(5'000))); + env(amm::ammClawback(gw, alice, usd, btc, usd(5'000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(250'000001), - STAmount{USD, UINT64_C(500'0000004), -7}, + btc(250'000001), + STAmount{usd, UINT64_C(500'0000004), -7}, IOUAmount{353'553'390876116, -9})); - env.require(balance(alice, aliceUSD)); - env.require(balance(alice, aliceBTC + BTC(750'000001))); - env.require(balance(bob, bobUSD)); - env.require(balance(bob, bobBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC + btc(750'000001))); + env.require(Balance(bob, bobUSD)); + env.require(Balance(bob, bobBTC)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{353'553'390876116, -9})); - aliceBTC = env.balance(alice, BTC); + aliceBTC = env.balance(alice, btc); // gw clawback BTC from bob which exceeds his balance with // tfClawTwoAssets - env(amm::ammClawback(gw, bob, BTC, USD, BTC(300'000000)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, bob, btc, usd, btc(300'000000)), Txflags(tfClawTwoAssets)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceUSD)); - env.require(balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC)); // USD is also clawed back from bob because of tfClawTwoAssets, // bob's USD balance will not change - env.require(balance(bob, bobUSD)); - env.require(balance(bob, bobBTC)); + env.require(Balance(bob, bobUSD)); + env.require(Balance(bob, bobBTC)); } // AMMClawback from MPT/MPT issued by the same issuer @@ -806,81 +806,81 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 30'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(2'000'000000), ETH(3'000'000000)); + AMM amm(env, alice, btc(2'000'000000), eth(3'000'000000)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(2'000'000000), ETH(3'000'000000), IOUAmount{2'449'489'742'783178, -6})); + btc(2'000'000000), eth(3'000'000000), IOUAmount{2'449'489'742'783178, -6})); - amm.deposit(bob, BTC(4'000'000000), ETH(6'000'000000)); + amm.deposit(bob, btc(4'000'000000), eth(6'000'000000)); BEAST_EXPECT(amm.expectBalances( - BTC(6'000'000000), ETH(9'000'000000), IOUAmount{7'348'469'228'349534, -6})); + btc(6'000'000000), eth(9'000'000000), IOUAmount{7'348'469'228'349534, -6})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceETH = env.balance(alice, ETH); - auto bobBTC = env.balance(bob, BTC); - auto bobETH = env.balance(bob, ETH); + auto aliceBTC = env.balance(alice, btc); + auto aliceETH = env.balance(alice, eth); + auto bobBTC = env.balance(bob, btc); + auto bobETH = env.balance(bob, eth); // gw clawback BTC from alice - env(amm::ammClawback(gw, alice, BTC, ETH, BTC(1'000'000000))); + env(amm::ammClawback(gw, alice, btc, eth, btc(1'000'000000))); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(5'000'000000), ETH(7'500'000000), IOUAmount{6'123'724'356'957944, -6})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH + ETH(1'500'000000))); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + btc(5'000'000000), eth(7'500'000000), IOUAmount{6'123'724'356'957944, -6})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH + eth(1'500'000000))); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'224'744'871'391588, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{4'898'979'485'566356, -6})); - aliceETH = env.balance(alice, ETH); + aliceETH = env.balance(alice, eth); // gw clawback ETH and BTC from bob with tfClawTwoAssets - env(amm::ammClawback(gw, bob, ETH, BTC, ETH(3'000'000000)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, bob, eth, btc, eth(3'000'000000)), Txflags(tfClawTwoAssets)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(3'000'000000), ETH(4'500'000000), IOUAmount{3'674'234'614'174766, -6})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + btc(3'000'000000), eth(4'500'000000), IOUAmount{3'674'234'614'174766, -6})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1'224'744'871'391588, -6})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{2'449'489'742'783178, -6})); // gw clawback BTC from alice, which exceeds her balance with // tfClawTwoAssets - env(amm::ammClawback(gw, alice, BTC, ETH, BTC(3'000'000000)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, btc, eth, btc(3'000'000000)), Txflags(tfClawTwoAssets)); env.close(); BEAST_EXPECT(amm.expectBalances( - BTC(2'000'000001), ETH(3'000'000001), IOUAmount{2'449'489'742'783178, -6})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + btc(2'000'000001), eth(3'000'000001), IOUAmount{2'449'489'742'783178, -6})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{2'449'489'742'783178, -6})); // gw clawback ETH from bob, which is the same as his balance - env(amm::ammClawback(gw, bob, ETH, BTC, ETH(3'000'000001))); + env(amm::ammClawback(gw, bob, eth, btc, eth(3'000'000001))); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC + BTC(2'000'000001))); - env.require(balance(bob, bobETH)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC + btc(2'000'000001))); + env.require(Balance(bob, bobETH)); } } @@ -902,54 +902,54 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(200000), bob); - env(pay(gw, bob, USD(60000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(200000), bob); + env(pay(gw, bob, usd(60000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(2'000'000000), USD(8'000)); + AMM amm(env, alice, btc(2'000'000000), usd(8'000)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(2'000'000000), USD(8'000), IOUAmount(4'000'000))); + BEAST_EXPECT(amm.expectBalances(btc(2'000'000000), usd(8'000), IOUAmount(4'000'000))); - amm.deposit(bob, BTC(1'000'000000), USD(4'000)); + amm.deposit(bob, btc(1'000'000000), usd(4'000)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(3'000'000000), USD(12'000), IOUAmount(6'000'000))); + BEAST_EXPECT(amm.expectBalances(btc(3'000'000000), usd(12'000), IOUAmount(6'000'000))); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - auto bobBTC = env.balance(bob, BTC); - auto bobUSD = env.balance(bob, USD); + auto aliceBTC = env.balance(alice, btc); + auto aliceUSD = env.balance(alice, usd); + auto bobBTC = env.balance(bob, btc); + auto bobUSD = env.balance(bob, usd); // gw clawback all BTC and USD from alice - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Txflags(tfClawTwoAssets)); env.close(); - BEAST_EXPECT(amm.expectBalances(BTC(1'000'000000), USD(4'000), IOUAmount(2'000'000))); + BEAST_EXPECT(amm.expectBalances(btc(1'000'000000), usd(4'000), IOUAmount(2'000'000))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(2'000'000))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobUSD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobUSD)); // gw clawback all USD from bob - env(amm::ammClawback(gw, bob, USD, BTC, std::nullopt)); + env(amm::ammClawback(gw, bob, usd, btc, std::nullopt)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); - env.require(balance(bob, bobBTC + BTC(1'000'000000))); - env.require(balance(bob, bobUSD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(bob, bobBTC + btc(1'000'000000))); + env.require(Balance(bob, bobUSD)); } // AMMClawback all from MPT/MPT issued by the same issuer @@ -964,57 +964,57 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 30'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(20'000), ETH(10'000)); + AMM amm(env, alice, btc(20'000), eth(10'000)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(20'000), ETH(10'000), IOUAmount{14'142'13562373095, -11})); + amm.expectBalances(btc(20'000), eth(10'000), IOUAmount{14'142'13562373095, -11})); - amm.deposit(bob, BTC(40'000), ETH(20'000)); + amm.deposit(bob, btc(40'000), eth(20'000)); BEAST_EXPECT( - amm.expectBalances(BTC(60'000), ETH(30'000), IOUAmount{42'426'40687119285, -11})); + amm.expectBalances(btc(60'000), eth(30'000), IOUAmount{42'426'40687119285, -11})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceETH = env.balance(alice, ETH); - auto bobBTC = env.balance(bob, BTC); - auto bobETH = env.balance(bob, ETH); + auto aliceBTC = env.balance(alice, btc); + auto aliceETH = env.balance(alice, eth); + auto bobBTC = env.balance(bob, btc); + auto bobETH = env.balance(bob, eth); // gw clawback all ETH from bob - env(amm::ammClawback(gw, bob, ETH, BTC, std::nullopt)); + env(amm::ammClawback(gw, bob, eth, btc, std::nullopt)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(20'000), ETH(10'000), IOUAmount{14'142'13562373095, -11})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC + BTC(40'000))); - env.require(balance(bob, bobETH)); + amm.expectBalances(btc(20'000), eth(10'000), IOUAmount{14'142'13562373095, -11})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC + btc(40'000))); + env.require(Balance(bob, bobETH)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{14'142'13562373095, -11})); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(0))); - bobBTC = env.balance(bob, BTC); + bobBTC = env.balance(bob, btc); // gw clawback all ETH and BTC from alice with tfClawTwoAssets - env(amm::ammClawback(gw, alice, ETH, BTC, std::nullopt), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, eth, btc, std::nullopt), Txflags(tfClawTwoAssets)); env.close(); // amm is empty and deleted BEAST_EXPECT(!amm.ammExists()); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(bob, bobBTC)); - env.require(balance(bob, bobETH)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(bob, bobBTC)); + env.require(Balance(bob, bobETH)); } } @@ -1037,83 +1037,83 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), gw2); - env(pay(gw, gw2, USD(5000))); - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(5000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), gw2); + env(pay(gw, gw2, usd(5000))); + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(5000))); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw2, .holders = {alice, gw}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, gw, USD(1000), BTC(2000)); + AMM amm(env, gw, usd(1000), btc(2000)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(1000), BTC(2000), IOUAmount{1414'213562373095, -12})); + amm.expectBalances(usd(1000), btc(2000), IOUAmount{1414'213562373095, -12})); - amm.deposit(gw2, USD(2000), BTC(4000)); + amm.deposit(gw2, usd(2000), btc(4000)); BEAST_EXPECT( - amm.expectBalances(USD(3000), BTC(6000), IOUAmount{4242'640687119285, -12})); + amm.expectBalances(usd(3000), btc(6000), IOUAmount{4242'640687119285, -12})); - amm.deposit(alice, USD(3000), BTC(6000)); + amm.deposit(alice, usd(3000), btc(6000)); BEAST_EXPECT( - amm.expectBalances(USD(6000), BTC(12000), IOUAmount{8485'281374238570, -12})); + amm.expectBalances(usd(6000), btc(12000), IOUAmount{8485'281374238570, -12})); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{1414'213562373095, -12})); BEAST_EXPECT(amm.expectLPTokens(gw2, IOUAmount{2828'427124746190, -12})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242'640687119285, -12})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - auto gwBTC = env.balance(gw, BTC); - auto gw2USD = env.balance(gw2, USD); + auto aliceBTC = env.balance(alice, btc); + auto aliceUSD = env.balance(alice, usd); + auto gwBTC = env.balance(gw, btc); + auto gw2USD = env.balance(gw2, usd); // gw claws back 1000 USD from gw2. - env(amm::ammClawback(gw, gw2, USD, BTC, USD(1000))); + env(amm::ammClawback(gw, gw2, usd, btc, usd(1000))); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(5000), BTC(10000), IOUAmount{7071'067811865474, -12})); + amm.expectBalances(usd(5000), btc(10000), IOUAmount{7071'067811865474, -12})); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{1414'213562373095, -12})); BEAST_EXPECT(amm.expectLPTokens(gw2, IOUAmount{1414'213562373094, -12})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242'640687119285, -12})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); - env.require(balance(gw, gwBTC)); - env.require(balance(gw2, gw2USD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(gw, gwBTC)); + env.require(Balance(gw2, gw2USD)); // gw2 claws back 1000 BTC from gw. - env(amm::ammClawback(gw2, gw, BTC, USD, BTC(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, gw, btc, usd, btc(1000)), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(4500), BTC(9001), IOUAmount{6363'961030678927, -12})); + amm.expectBalances(usd(4500), btc(9001), IOUAmount{6363'961030678927, -12})); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{707'1067811865480, -13})); BEAST_EXPECT(amm.expectLPTokens(gw2, IOUAmount{1414'213562373094, -12})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242'640687119285, -12})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); - env.require(balance(gw, gwBTC)); - env.require(balance(gw2, gw2USD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); + env.require(Balance(gw, gwBTC)); + env.require(Balance(gw2, gw2USD)); // gw2 claws back 4000 BTC from alice - env(amm::ammClawback(gw2, alice, BTC, USD, BTC(4000))); + env(amm::ammClawback(gw2, alice, btc, usd, btc(4000))); env.close(); BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2500'222197533607), -12}, - BTC(5001), + STAmount{usd, UINT64_C(2500'222197533607), -12}, + btc(5001), IOUAmount{3535'84814069829, -11})); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{707'1067811865480, -13})); BEAST_EXPECT(amm.expectLPTokens(gw2, IOUAmount{1414'213562373094, -12})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1414'527797138648, -12})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + STAmount{USD, UINT64_C(1999'777802466393), -12})); - env.require(balance(gw, gwBTC)); - env.require(balance(gw2, gw2USD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + STAmount{usd, UINT64_C(1999'777802466393), -12})); + env.require(Balance(gw, gwBTC)); + env.require(Balance(gw2, gw2USD)); } // AMMClawback from MPT/MPT issued by each other @@ -1129,67 +1129,67 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {gw2, alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, .issuer = gw2, .holders = {gw, alice}, .pay = 30'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, gw, BTC(10'000), ETH(50'000)); + AMM amm(env, gw, btc(10'000), eth(50'000)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(10'000), ETH(50'000), IOUAmount{22'360'67977499789, -11})); + amm.expectBalances(btc(10'000), eth(50'000), IOUAmount{22'360'67977499789, -11})); - amm.deposit(gw2, BTC(20'000), ETH(100'000)); + amm.deposit(gw2, btc(20'000), eth(100'000)); BEAST_EXPECT( - amm.expectBalances(BTC(30'000), ETH(150'000), IOUAmount{67'082'03932499367, -11})); + amm.expectBalances(btc(30'000), eth(150'000), IOUAmount{67'082'03932499367, -11})); - amm.deposit(alice, BTC(40'000), ETH(200'000)); + amm.deposit(alice, btc(40'000), eth(200'000)); BEAST_EXPECT( - amm.expectBalances(BTC(70'000), ETH(350'000), IOUAmount{156'524'7584249852, -10})); + amm.expectBalances(btc(70'000), eth(350'000), IOUAmount{156'524'7584249852, -10})); - auto aliceBTC = env.balance(alice, BTC); - auto aliceETH = env.balance(alice, ETH); - auto gw2BTC = env.balance(gw2, BTC); - auto gwETH = env.balance(gw, ETH); + auto aliceBTC = env.balance(alice, btc); + auto aliceETH = env.balance(alice, eth); + auto gw2BTC = env.balance(gw2, btc); + auto gwETH = env.balance(gw, eth); // gw claws back 1000 BTC from gw2. - env(amm::ammClawback(gw, gw2, BTC, ETH, BTC(1000))); + env(amm::ammClawback(gw, gw2, btc, eth, btc(1000))); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(69'001), ETH(345'001), IOUAmount{154'288'6904474855, -10})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(gw, gwETH)); - env.require(balance(gw2, gw2BTC)); + amm.expectBalances(btc(69'001), eth(345'001), IOUAmount{154'288'6904474855, -10})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(gw, gwETH)); + env.require(Balance(gw2, gw2BTC)); // gw2 claws back all ETH from gw - env(amm::ammClawback(gw2, gw, ETH, BTC, std::nullopt)); + env(amm::ammClawback(gw2, gw, eth, btc, std::nullopt)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(59'001), ETH(295'001), IOUAmount{131'928'0106724876, -10})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH)); - env.require(balance(gw, gwETH)); - env.require(balance(gw2, gw2BTC)); + amm.expectBalances(btc(59'001), eth(295'001), IOUAmount{131'928'0106724876, -10})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH)); + env.require(Balance(gw, gwETH)); + env.require(Balance(gw2, gw2BTC)); // gw claws back all BTC from alice - env(amm::ammClawback(gw, alice, BTC, ETH, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, eth, std::nullopt)); env.close(); BEAST_EXPECT( - amm.expectBalances(BTC(19'001), ETH(95'001), IOUAmount{42'485'29157249607, -11})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceETH + ETH(200'000))); - env.require(balance(gw, gwETH)); - env.require(balance(gw2, gw2BTC)); + amm.expectBalances(btc(19'001), eth(95'001), IOUAmount{42'485'29157249607, -11})); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceETH + eth(200'000))); + env.require(Balance(gw, gwETH)); + env.require(Balance(gw2, gw2BTC)); } } @@ -1208,65 +1208,65 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(1'000'000), alice); - env(pay(gw, alice, USD(500'000))); + auto const usd = gw["USD"]; + env.trust(usd(1'000'000), alice); + env(pay(gw, alice, usd(500'000))); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice}, .pay = 30'000, - .flags = tfMPTCanClawback | tfMPTCanLock | MPTDEXFlags}); - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000)); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'000), BTC(10'000), IOUAmount(10'000))); + .flags = tfMPTCanClawback | tfMPTCanLock | kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice, usd(10'000), btc(10'000)); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'000), btc(10'000), IOUAmount(10'000))); env.close(); - auto aliceBTC = env.balance(alice, MPT(BTC)); - auto aliceUSD = env.balance(alice, USD); + auto aliceBTC = env.balance(alice, MPT(btc)); + auto aliceUSD = env.balance(alice, usd); // globally locked and claw back 1000 BTC. // this should be successful - BTC.set({.flags = tfMPTLock}); - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(1'000))); - BEAST_EXPECT(ammAlice.expectBalances(USD(9'000), BTC(9'000), IOUAmount(9'000))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(1'000))); - aliceUSD = env.balance(alice, USD); + btc.set({.flags = tfMPTLock}); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(1'000))); + BEAST_EXPECT(ammAlice.expectBalances(usd(9'000), btc(9'000), IOUAmount(9'000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(1'000))); + aliceUSD = env.balance(alice, usd); // unlock and claw back 2000 BTC - BTC.set({.flags = tfMPTUnlock}); - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(2'000))); + btc.set({.flags = tfMPTUnlock}); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(2'000))); BEAST_EXPECT(ammAlice.expectBalances( - STAmount(USD, UINT64_C(7'000'000000000001), -12), BTC(7'001), IOUAmount(7'000))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(2'000))); - aliceUSD = env.balance(alice, USD); + STAmount(usd, UINT64_C(7'000'000000000001), -12), btc(7'001), IOUAmount(7'000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(2'000))); + aliceUSD = env.balance(alice, usd); // globally freeze trustline and claw back 1000 USD. // this should be successful env(trust(gw, alice["USD"](0), tfSetFreeze)); env.close(); - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(1'000))); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(1'000))); BEAST_EXPECT(ammAlice.expectBalances( - STAmount(USD, UINT64_C(6000'000000000002), -12), - BTC(6'001), + STAmount(usd, UINT64_C(6000'000000000002), -12), + btc(6'001), IOUAmount(6'000'000000000001, -12))); - env.require(balance(alice, aliceBTC + BTC(1'000))); - env.require(balance(alice, aliceUSD)); - aliceBTC = env.balance(alice, MPT(BTC)); + env.require(Balance(alice, aliceBTC + btc(1'000))); + env.require(Balance(alice, aliceUSD)); + aliceBTC = env.balance(alice, MPT(btc)); // globally unfreeze trustline and claw back 2000 USD // and 2000 BTC with tfClawTwoAssets env(fset(gw, asfGlobalFreeze)); env.close(); - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(2'000)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(2'000)), Txflags(tfClawTwoAssets)); BEAST_EXPECT(ammAlice.expectBalances( - STAmount(USD, UINT64_C(4'000'000000000002), -12), - BTC(4'001), + STAmount(usd, UINT64_C(4'000'000000000002), -12), + btc(4'001), IOUAmount(4'000'000000000001, -12))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); } // test AMMClawback when MPT individually locked or IOU individually @@ -1279,59 +1279,59 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(1'000'000), alice); - env(pay(gw, alice, USD(500'000))); + auto const usd = gw["USD"]; + env.trust(usd(1'000'000), alice); + env(pay(gw, alice, usd(500'000))); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice}, .pay = 30'000, - .flags = tfMPTCanClawback | tfMPTCanLock | MPTDEXFlags}); - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000)); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'000), BTC(10'000), IOUAmount(10'000))); + .flags = tfMPTCanClawback | tfMPTCanLock | kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice, usd(10'000), btc(10'000)); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'000), btc(10'000), IOUAmount(10'000))); env.close(); - auto aliceBTC = env.balance(alice, MPT(BTC)); - auto aliceUSD = env.balance(alice, USD); + auto aliceBTC = env.balance(alice, MPT(btc)); + auto aliceUSD = env.balance(alice, usd); // individually locked and claw back 2000 BTC from alice - BTC.set({.holder = alice, .flags = tfMPTLock}); - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(2'000))); - BEAST_EXPECT(ammAlice.expectBalances(USD(8'000), BTC(8'000), IOUAmount(8'000))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(2'000))); - aliceUSD = env.balance(alice, USD); + btc.set({.holder = alice, .flags = tfMPTLock}); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(2'000))); + BEAST_EXPECT(ammAlice.expectBalances(usd(8'000), btc(8'000), IOUAmount(8'000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(2'000))); + aliceUSD = env.balance(alice, usd); // individually freeze trustline and claw back 1000 USD from alice env(trust(gw, alice["USD"](0), tfSetFreeze)); env.close(); - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(1'000))); - BEAST_EXPECT(ammAlice.expectBalances(USD(7'000), BTC(7'000), IOUAmount(7'000))); - env.require(balance(alice, aliceBTC + BTC(1'000))); - env.require(balance(alice, aliceUSD)); - aliceBTC = env.balance(alice, MPT(BTC)); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(1'000))); + BEAST_EXPECT(ammAlice.expectBalances(usd(7'000), btc(7'000), IOUAmount(7'000))); + env.require(Balance(alice, aliceBTC + btc(1'000))); + env.require(Balance(alice, aliceUSD)); + aliceBTC = env.balance(alice, MPT(btc)); // unlock MPT and claw back 3000 BTC from alice - BTC.set({.holder = alice, .flags = tfMPTUnlock}); - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(3'000))); + btc.set({.holder = alice, .flags = tfMPTUnlock}); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(3'000))); BEAST_EXPECT(ammAlice.expectBalances( - STAmount{USD, UINT64_C(4000'000000000001), -12}, BTC(4'001), IOUAmount(4'000))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(3'000))); - aliceUSD = env.balance(alice, USD); + STAmount{usd, UINT64_C(4000'000000000001), -12}, btc(4'001), IOUAmount(4'000))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(3'000))); + aliceUSD = env.balance(alice, usd); // unlock trustline and claw back 1000 USD from alice env(trust(gw, alice["USD"](0), tfClearFreeze)); env.close(); - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(1'000))); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(1'000))); BEAST_EXPECT(ammAlice.expectBalances( - STAmount(USD, UINT64_C(3'000'000000000002), -12), - BTC(3'001), + STAmount(usd, UINT64_C(3'000'000000000002), -12), + btc(3'001), IOUAmount(3000'000000000001, -12))); - env.require(balance(alice, aliceBTC + BTC(1'000))); - env.require(balance(alice, aliceUSD)); + env.require(Balance(alice, aliceBTC + btc(1'000))); + env.require(Balance(alice, aliceUSD)); } } @@ -1349,31 +1349,31 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env.fund(XRP(1000000000), gw, alice); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); // gw creates AMM pool of BTC/XRP. - AMM amm(env, gw, XRP(100), BTC(400), ter(tesSUCCESS)); + AMM amm(env, gw, XRP(100), btc(400), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(XRP(100), BTC(400), IOUAmount(200000))); - amm.deposit(alice, BTC(400)); + BEAST_EXPECT(amm.expectBalances(XRP(100), btc(400), IOUAmount(200000))); + amm.deposit(alice, btc(400)); env.close(); - BEAST_EXPECT(amm.expectBalances(XRP(100), BTC(800), IOUAmount{282842'712474619, -9})); + BEAST_EXPECT(amm.expectBalances(XRP(100), btc(800), IOUAmount{282842'712474619, -9})); - auto aliceBTC = env.balance(alice, MPT(BTC)); + auto aliceBTC = env.balance(alice, MPT(btc)); auto aliceXRP = env.balance(alice, XRP); // gw clawback 100 BTC from alice - env(amm::ammClawback(gw, alice, MPT(BTC), XRP, BTC(100))); + env(amm::ammClawback(gw, alice, MPT(btc), XRP, btc(100))); BEAST_EXPECT(amm.expectBalances( - XRPAmount(87500001), BTC(701), IOUAmount{247'487'3734152917, -10})); + XRPAmount(87500001), btc(701), IOUAmount{247'487'3734152917, -10})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceXRP + XRPAmount(12'499999))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceXRP + XRPAmount(12'499999))); } // MPT/IOU @@ -1387,50 +1387,50 @@ class AMMClawbackMPT_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 1000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(1000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(1000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); // gw creates AMM pool of BTC/USD. - AMM amm(env, gw, USD(100), BTC(400), ter(tesSUCCESS)); + AMM amm(env, gw, usd(100), btc(400), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(100), BTC(400), IOUAmount(200))); - amm.deposit(alice, BTC(400)); + BEAST_EXPECT(amm.expectBalances(usd(100), btc(400), IOUAmount(200))); + amm.deposit(alice, btc(400)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(100), BTC(800), IOUAmount{282'842712474619, -12})); + BEAST_EXPECT(amm.expectBalances(usd(100), btc(800), IOUAmount{282'842712474619, -12})); - auto aliceBTC = env.balance(alice, MPT(BTC)); - auto aliceUSD = env.balance(alice, USD); + auto aliceBTC = env.balance(alice, MPT(btc)); + auto aliceUSD = env.balance(alice, usd); // gw clawback 100 BTC from alice - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(100))); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(100))); BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(87'50000000000003), -14}, - BTC(701), + STAmount{usd, UINT64_C(87'50000000000003), -14}, + btc(701), IOUAmount{247'4873734152917, -13})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(12.5))); - aliceUSD = env.balance(alice, USD); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(12.5))); + aliceUSD = env.balance(alice, usd); // gw clawback 30 USD from alice with tfClawTwoAssets, which exceeds // her balance - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(30)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(30)), Txflags(tfClawTwoAssets)); BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(70'71067811865476), -14}, BTC(567), IOUAmount(200))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); + STAmount{usd, UINT64_C(70'71067811865476), -14}, btc(567), IOUAmount(200))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount(200))); } @@ -1443,45 +1443,45 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env.fund(XRP(1000000000), gw, alice); env.close(); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); // gw creates AMM pool of BTC/USD. - AMM amm(env, gw, USD(100), BTC(400), ter(tesSUCCESS)); + AMM amm(env, gw, usd(100), btc(400), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(100), BTC(400), IOUAmount(200))); - amm.deposit(alice, BTC(400)); + BEAST_EXPECT(amm.expectBalances(usd(100), btc(400), IOUAmount(200))); + amm.deposit(alice, btc(400)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(100), BTC(800), IOUAmount{282'842712474619, -12})); + BEAST_EXPECT(amm.expectBalances(usd(100), btc(800), IOUAmount{282'842712474619, -12})); - auto aliceBTC = env.balance(alice, MPT(BTC)); - auto aliceUSD = env.balance(alice, USD); + auto aliceBTC = env.balance(alice, MPT(btc)); + auto aliceUSD = env.balance(alice, usd); // gw clawback 100 BTC from alice - env(amm::ammClawback(gw, alice, MPT(BTC), USD, BTC(100))); - BEAST_EXPECT(amm.expectBalances(USD(88), BTC(701), IOUAmount{247'4873734152917, -13})); + env(amm::ammClawback(gw, alice, MPT(btc), usd, btc(100))); + BEAST_EXPECT(amm.expectBalances(usd(88), btc(701), IOUAmount{247'4873734152917, -13})); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD + USD(12))); - aliceUSD = env.balance(alice, USD); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD + usd(12))); + aliceUSD = env.balance(alice, usd); // gw clawback 30 USD from alice with tfClawTwoAssets, which exceeds // her balance - env(amm::ammClawback(gw, alice, USD, MPT(BTC), USD(30)), txflags(tfClawTwoAssets)); - BEAST_EXPECT(amm.expectBalances(USD(72), BTC(567), IOUAmount(200))); - env.require(balance(alice, aliceBTC)); - env.require(balance(alice, aliceUSD)); + env(amm::ammClawback(gw, alice, usd, MPT(btc), usd(30)), Txflags(tfClawTwoAssets)); + BEAST_EXPECT(amm.expectBalances(usd(72), btc(567), IOUAmount(200))); + env.require(Balance(alice, aliceBTC)); + env.require(Balance(alice, aliceUSD)); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount(200))); } @@ -1505,21 +1505,21 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(40000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(40000))); env.close(); - MPT const EUR = MPTTester( + MPT const eur = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, USD(2), EUR(1)); + AMM amm(env, alice, usd(2), eur(1)); amm.deposit(alice, IOUAmount{1'576123487565916, -15}); amm.deposit(bob, IOUAmount{1'000}); amm.withdraw(alice, IOUAmount{1'576123487565916, -15}); @@ -1544,26 +1544,26 @@ class AMMClawbackMPT_test : public beast::unit_test::suite if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt)); BEAST_EXPECT(!amm.ammExists()); } else if ( features[fixAMMv1_3] && (features[featureSingleAssetVault] || features[featureLendingProtocol])) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt)); // Without the Rounding feature and with new Number a dust pool // amount remains BEAST_EXPECT(amm.ammExists()); } else if (!features[featureSingleAssetVault] && !features[featureLendingProtocol]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), ter(tecINTERNAL)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Ter(tecINTERNAL)); BEAST_EXPECT(amm.ammExists()); } else { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Ter(tecAMM_BALANCE)); BEAST_EXPECT(amm.ammExists()); } } @@ -1575,21 +1575,21 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env.fund(XRP(100000), gw, alice, bob); env.close(); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - MPT const EUR = MPTTester( + MPT const eur = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM amm(env, alice, USD(2), EUR(1)); + AMM amm(env, alice, usd(2), eur(1)); amm.deposit(alice, IOUAmount{1'576123487565916, -15}); amm.deposit(bob, IOUAmount{1'000}); amm.withdraw(alice, IOUAmount{1'576123487565916, -15}); @@ -1614,7 +1614,7 @@ class AMMClawbackMPT_test : public beast::unit_test::suite if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt)); BEAST_EXPECT(!amm.ammExists()); } else if ( @@ -1623,17 +1623,17 @@ class AMMClawbackMPT_test : public beast::unit_test::suite { // Without the Rounding feature and with new Number a dust pool // amount remains - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt)); BEAST_EXPECT(amm.ammExists()); } else if (!features[featureSingleAssetVault] && !features[featureLendingProtocol]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), ter(tecINTERNAL)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Ter(tecINTERNAL)); BEAST_EXPECT(amm.ammExists()); } else if (features[featureMPTokensV2]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Ter(tecAMM_BALANCE)); BEAST_EXPECT(amm.ammExists()); } } @@ -1656,27 +1656,27 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(1000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(1000))); env.close(); - MPT const BTC = + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000}); - AMM const amm(env, alice, USD(200), BTC(100)); + AMM const amm(env, alice, usd(200), btc(100)); // Asset BTC is not clawable without tfMPTCanClawback. - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), ter(tecNO_PERMISSION)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Ter(tecNO_PERMISSION)); // Although USD is clawable with asfAllowTrustLineClawback. // When tfClawTwoAssets is set, we will claw Asser2 as well. // But Asset2 is not clawable. tfMPTCanClawback was not set for BTC. - env(amm::ammClawback(gw, alice, USD, BTC, std::nullopt), - txflags(tfClawTwoAssets), - ter(tecNO_PERMISSION)); + env(amm::ammClawback(gw, alice, usd, btc, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(tecNO_PERMISSION)); // Can only claw the other asset - env(amm::ammClawback(gw, alice, USD, BTC, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, btc, std::nullopt)); } // IOU/MPT, IOU not clawable @@ -1687,32 +1687,32 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env.fund(XRP(100000), gw, alice); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(1000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(1000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); // Asset USD is not clawable without asfAllowTrustLineClawback. - AMM const amm(env, alice, USD(200), BTC(100)); - env(amm::ammClawback(gw, alice, USD, BTC, std::nullopt), ter(tecNO_PERMISSION)); + AMM const amm(env, alice, usd(200), btc(100)); + env(amm::ammClawback(gw, alice, usd, btc, std::nullopt), Ter(tecNO_PERMISSION)); // Although BTC is clawable with tfMPTCanClawback. // When tfClawTwoAssets is set, we will claw Asset2 as well. // But Asset2 is not clawable. asfAllowTrustLineClawback was not set // by the issuer. - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), - txflags(tfClawTwoAssets), - ter(tecNO_PERMISSION)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(tecNO_PERMISSION)); // Can only claw the other asset - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt)); } // IOU/MPT both clawable @@ -1727,23 +1727,23 @@ class AMMClawbackMPT_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(1000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(1000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw2, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); - AMM const amm(env, alice, USD(200), BTC(100)); + AMM const amm(env, alice, usd(200), btc(100)); // the account trying to claw MPT is not its issuer // will return temMALFORMED in preflight. - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Ter(temMALFORMED)); } // only issuer can claw. IOU/MPT mix @@ -1753,25 +1753,25 @@ class AMMClawbackMPT_test : public beast::unit_test::suite Account const gw("gateway"), alice("alice"), bob("bob"); env.fund(XRP(30'000), alice, bob, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = bob, .holders = {alice}, .limit = 1'000'000}); - env(pay(gw, alice, USD(50000))); - env(pay(bob, alice, BTC(50000))); + env(pay(gw, alice, usd(50000))); + env(pay(bob, alice, btc(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10100)); + auto ammAlice = AMM(env, alice, usd(10000), btc(10100)); // BTC's issuer is bob, alice can not clawback - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Ter(temMALFORMED)); }; testHelper2TokensMix(test); } @@ -1783,29 +1783,29 @@ class AMMClawbackMPT_test : public beast::unit_test::suite Account const gw("gateway"), alice("alice"), bob("bob"); env.fund(XRP(30'000), alice, bob, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = bob, .holders = {alice}, .limit = 1'000'000}); - env(pay(gw, alice, USD(50000))); - env(pay(bob, alice, BTC(50000))); + env(pay(gw, alice, usd(50000))); + env(pay(bob, alice, btc(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10100)); + auto ammAlice = AMM(env, alice, usd(10000), btc(10100)); // BTC's issuer is bob. But with tfClawTwoAssets, we will claw // both. It will fail because the other asset USD's issuer is // gw. - env(amm::ammClawback(bob, alice, BTC, USD, std::nullopt), - txflags(tfClawTwoAssets), - ter(temINVALID_FLAG)); + env(amm::ammClawback(bob, alice, btc, usd, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(temINVALID_FLAG)); }; testHelper2TokensMix(test); } @@ -1814,7 +1814,7 @@ class AMMClawbackMPT_test : public beast::unit_test::suite void run() override { - FeatureBitset const all{jtx::testable_amendments() | fixAMMClawbackRounding}; + FeatureBitset const all{jtx::testableAmendments() | fixAMMClawbackRounding}; testInvalidRequest(all); testFeatureDisabled(all); diff --git a/src/test/app/AMMClawback_test.cpp b/src/test/app/AMMClawback_test.cpp index bf08b57bf3..9683e8ac17 100644 --- a/src/test/app/AMMClawback_test.cpp +++ b/src/test/app/AMMClawback_test.cpp @@ -25,7 +25,7 @@ #include namespace xrpl::test { -class AMMClawback_test : public beast::unit_test::suite +class AMMClawback_test : public beast::unit_test::Suite { void testInvalidRequest(FeatureBitset features) @@ -44,17 +44,17 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); - auto const USD = gw["USD"]; - env.trust(USD(10000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(10000), alice); + env(pay(gw, alice, usd(100))); - AMM const amm(env, alice, XRP(100), USD(100)); + AMM const amm(env, alice, XRP(100), usd(100)); env.close(); - env(amm::ammClawback(gw, Account("unknown"), USD, XRP, std::nullopt), - ter(terNO_ACCOUNT)); + env(amm::ammClawback(gw, Account("unknown"), usd, XRP, std::nullopt), + Ter(terNO_ACCOUNT)); } // Test if asset pair provided does not exist. This should @@ -69,24 +69,24 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(10000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(10000), alice); + env(pay(gw, alice, usd(100))); env.close(); // Withdraw all the tokens from the AMMAccount. // The AMMAccount will be auto deleted. - AMM amm(env, gw, XRP(100), USD(100)); + AMM amm(env, gw, XRP(100), usd(100)); amm.withdrawAll(gw); BEAST_EXPECT(!amm.ammExists()); env.close(); // The AMM account does not exist at all now. // It should return terNO_AMM error. - env(amm::ammClawback(gw, alice, USD, gw["EUR"], std::nullopt), ter(terNO_AMM)); + env(amm::ammClawback(gw, alice, usd, gw["EUR"], std::nullopt), Ter(terNO_AMM)); } // Test if the issuer field and holder field is the same. This should @@ -101,21 +101,21 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // Issuer can not clawback from himself. - env(amm::ammClawback(gw, gw, USD, XRP, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(gw, gw, usd, XRP, std::nullopt), Ter(temMALFORMED)); // Holder can not clawback from himself. - env(amm::ammClawback(alice, alice, USD, XRP, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(alice, alice, usd, XRP, std::nullopt), Ter(temMALFORMED)); } // Test if the Asset field matches the Account field. @@ -129,21 +129,21 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // The Asset's issuer field is alice, while the Account field is gw. // This should return temMALFORMED because they do not match. env(amm::ammClawback( gw, alice, Issue{gw["USD"].currency, alice.id()}, XRP, std::nullopt), - ter(temMALFORMED)); + Ter(temMALFORMED)); } // Test if the Amount field matches the Asset field. @@ -157,22 +157,22 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // The Asset's issuer subfield is gw account and Amount's issuer // subfield is alice account. Return temBAD_AMOUNT because // they do not match. env(amm::ammClawback( - gw, alice, USD, XRP, STAmount{Issue{gw["USD"].currency, alice.id()}, 1}), - ter(temBAD_AMOUNT)); + gw, alice, usd, XRP, STAmount{Issue{gw["USD"].currency, alice.id()}, 1}), + Ter(temBAD_AMOUNT)); } // Test if the Amount is invalid, which is less than zero. @@ -186,25 +186,25 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // Return temBAD_AMOUNT if the Amount value is less than 0. env(amm::ammClawback( - gw, alice, USD, XRP, STAmount{Issue{gw["USD"].currency, gw.id()}, -1}), - ter(temBAD_AMOUNT)); + gw, alice, usd, XRP, STAmount{Issue{gw["USD"].currency, gw.id()}, -1}), + Ter(temBAD_AMOUNT)); // Return temBAD_AMOUNT if the Amount value is 0. env(amm::ammClawback( - gw, alice, USD, XRP, STAmount{Issue{gw["USD"].currency, gw.id()}, 0}), - ter(temBAD_AMOUNT)); + gw, alice, usd, XRP, STAmount{Issue{gw["USD"].currency, gw.id()}, 0}), + Ter(temBAD_AMOUNT)); } // Test if the issuer did not set asfAllowTrustLineClawback, AMMClawback @@ -217,19 +217,19 @@ class AMMClawback_test : public beast::unit_test::suite env.close(); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - env.require(balance(alice, USD(100))); - env.require(balance(gw, alice["USD"](-100))); + env.require(Balance(alice, usd(100))); + env.require(Balance(gw, alice["USD"](-100))); // gw creates AMM pool of XRP/USD. - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // If asfAllowTrustLineClawback is not set, the issuer is not // allowed to send the AMMClawback transaction. - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), ter(tecNO_PERMISSION)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), Ter(tecNO_PERMISSION)); } // Test invalid flag. @@ -243,20 +243,20 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // Return temINVALID_FLAG when providing invalid flag. - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), - txflags(tfTwoAssetIfEmpty), - ter(temINVALID_FLAG)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), + Txflags(tfTwoAssetIfEmpty), + Ter(temINVALID_FLAG)); } // Test if tfClawTwoAssets is set when the two assets in the AMM pool @@ -271,24 +271,24 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 100 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(1000), alice); - env(pay(gw, alice, USD(100))); + auto const usd = gw["USD"]; + env.trust(usd(1000), alice); + env(pay(gw, alice, usd(100))); env.close(); // gw creates AMM pool of XRP/USD. - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); + AMM const amm(env, gw, XRP(100), usd(100), Ter(tesSUCCESS)); // Return temINVALID_FLAG because the issuer set tfClawTwoAssets, // but the issuer only issues USD in the pool. The issuer is not // allowed to set tfClawTwoAssets flag if he did not issue both // assets in the pool. - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), - txflags(tfClawTwoAssets), - ter(temINVALID_FLAG)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(temINVALID_FLAG)); } // Test clawing back XRP is being prohibited. @@ -302,20 +302,20 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); // Alice creates AMM pool of XRP/USD. - AMM const amm(env, alice, XRP(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, XRP(1000), usd(2000), Ter(tesSUCCESS)); env.close(); // Clawback XRP is prohibited. - env(amm::ammClawback(gw, alice, XRP, USD, std::nullopt), ter(temMALFORMED)); + env(amm::ammClawback(gw, alice, XRP, usd, std::nullopt), Ter(temMALFORMED)); } } @@ -335,18 +335,18 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); // When featureAMMClawback is not enabled, AMMClawback is disabled. // Because when featureAMMClawback is disabled, we can not create // amm account, call amm::ammClawback directly for testing purpose. - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), ter(temDISABLED)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), Ter(temDISABLED)); } } @@ -369,68 +369,68 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); - env.require(balance(gw, alice["USD"](-3000))); - env.require(balance(alice, USD(3000))); + env.require(Balance(gw, alice["USD"](-3000))); + env.require(Balance(alice, usd(3000))); // gw2 issues 3000 EUR to Alice. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(3000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(3000))); env.close(); - env.require(balance(gw2, alice["EUR"](-3000))); - env.require(balance(alice, EUR(3000))); + env.require(Balance(gw2, alice["EUR"](-3000))); + env.require(Balance(alice, eur(3000))); // Alice creates AMM pool of EUR/USD. - AMM const amm(env, alice, EUR(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, eur(1000), usd(2000), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(2000), EUR(1000), IOUAmount{1414213562373095, -12})); + amm.expectBalances(usd(2000), eur(1000), IOUAmount{1414213562373095, -12})); // gw clawback 1000 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice's initial balance for USD is 3000 USD. Alice deposited 2000 // USD into the pool, then she has 1000 USD. And 1000 USD was clawed // back from the AMM pool, so she still has 1000 USD. - env.require(balance(gw, alice["USD"](-1000))); - env.require(balance(alice, USD(1000))); + env.require(Balance(gw, alice["USD"](-1000))); + env.require(Balance(alice, usd(1000))); // Alice's initial balance for EUR is 3000 EUR. Alice deposited 1000 // EUR into the pool, 500 EUR was withdrawn proportionally. So she // has 2500 EUR now. - env.require(balance(gw2, alice["EUR"](-2500))); - env.require(balance(alice, EUR(2500))); + env.require(Balance(gw2, alice["EUR"](-2500))); + env.require(Balance(alice, eur(2500))); // 1000 USD and 500 EUR was withdrawn from the AMM pool, so the // current balance is 1000 USD and 500 EUR. - BEAST_EXPECT(amm.expectBalances(USD(1000), EUR(500), IOUAmount{7071067811865475, -13})); + BEAST_EXPECT(amm.expectBalances(usd(1000), eur(500), IOUAmount{7071067811865475, -13})); // Alice has half of its initial lptokens Left. BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{7071067811865475, -13})); // gw clawback another 1000 USD from the AMM pool. The AMM pool will // be empty and get deleted. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice should still has 1000 USD because gw clawed back from the // AMM pool. - env.require(balance(gw, alice["USD"](-1000))); - env.require(balance(alice, USD(1000))); + env.require(Balance(gw, alice["USD"](-1000))); + env.require(Balance(alice, usd(1000))); // Alice should has 3000 EUR now because another 500 EUR was // withdrawn. - env.require(balance(gw2, alice["EUR"](-3000))); - env.require(balance(alice, EUR(3000))); + env.require(Balance(gw2, alice["EUR"](-3000))); + env.require(Balance(alice, eur(3000))); // amm is automatically deleted. BEAST_EXPECT(!amm.ammExists()); @@ -448,33 +448,33 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); - env.require(balance(gw, alice["USD"](-3000))); - env.require(balance(alice, USD(3000))); + env.require(Balance(gw, alice["USD"](-3000))); + env.require(Balance(alice, usd(3000))); // Alice creates AMM pool of XRP/USD. - AMM const amm(env, alice, XRP(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, XRP(1000), usd(2000), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(2000), XRP(1000), IOUAmount{1414213562373095, -9})); + BEAST_EXPECT(amm.expectBalances(usd(2000), XRP(1000), IOUAmount{1414213562373095, -9})); auto aliceXrpBalance = env.balance(alice, XRP); // gw clawback 1000 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, XRP, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice's initial balance for USD is 3000 USD. Alice deposited 2000 // USD into the pool, then she has 1000 USD. And 1000 USD was clawed // back from the AMM pool, so she still has 1000 USD. - env.require(balance(gw, alice["USD"](-1000))); - env.require(balance(alice, USD(1000))); + env.require(Balance(gw, alice["USD"](-1000))); + env.require(Balance(alice, usd(1000))); // Alice will get 500 XRP back. BEAST_EXPECT(expectLedgerEntryRoot(env, alice, aliceXrpBalance + XRP(500))); @@ -482,20 +482,20 @@ class AMMClawback_test : public beast::unit_test::suite // 1000 USD and 500 XRP was withdrawn from the AMM pool, so the // current balance is 1000 USD and 500 XRP. - BEAST_EXPECT(amm.expectBalances(USD(1000), XRP(500), IOUAmount{7071067811865475, -10})); + BEAST_EXPECT(amm.expectBalances(usd(1000), XRP(500), IOUAmount{7071067811865475, -10})); // Alice has half of its initial lptokens Left. BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{7071067811865475, -10})); // gw clawback another 1000 USD from the AMM pool. The AMM pool will // be empty and get deleted. - env(amm::ammClawback(gw, alice, USD, XRP, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice should still has 1000 USD because gw clawed back from the // AMM pool. - env.require(balance(gw, alice["USD"](-1000))); - env.require(balance(alice, USD(1000))); + env.require(Balance(gw, alice["USD"](-1000))); + env.require(Balance(alice, usd(1000))); // Alice will get another 500 XRP back. BEAST_EXPECT(expectLedgerEntryRoot(env, alice, aliceXrpBalance + XRP(500))); @@ -528,62 +528,62 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 6000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(6000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(6000))); env.close(); - env.require(balance(alice, USD(6000))); + env.require(Balance(alice, usd(6000))); // gw2 issues 6000 EUR to Alice. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(6000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(6000))); env.close(); - env.require(balance(alice, EUR(6000))); + env.require(Balance(alice, eur(6000))); // Alice creates AMM pool of EUR/USD - AMM const amm(env, alice, EUR(5000), USD(4000), ter(tesSUCCESS)); + AMM const amm(env, alice, eur(5000), usd(4000), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(4000), EUR(5000), IOUAmount{4472135954999580, -12})); + amm.expectBalances(usd(4000), eur(5000), IOUAmount{4472135954999580, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(4000), EUR(5000), IOUAmount{4472135954999579, -12})); + amm.expectBalances(usd(4000), eur(5000), IOUAmount{4472135954999579, -12})); } // gw clawback 1000 USD from the AMM pool - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice's initial balance for USD is 6000 USD. Alice deposited 4000 // USD into the pool, then she has 2000 USD. And 1000 USD was clawed // back from the AMM pool, so she still has 2000 USD. - env.require(balance(alice, USD(2000))); + env.require(Balance(alice, usd(2000))); // Alice's initial balance for EUR is 6000 EUR. Alice deposited 5000 // EUR into the pool, 1250 EUR was withdrawn proportionally. So she // has 2500 EUR now. - env.require(balance(alice, EUR(2250))); + env.require(Balance(alice, eur(2250))); // 1000 USD and 1250 EUR was withdrawn from the AMM pool, so the // current balance is 3000 USD and 3750 EUR. if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(3000), EUR(3750), IOUAmount{3354101966249685, -12})); + amm.expectBalances(usd(3000), eur(3750), IOUAmount{3354101966249685, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(3000), EUR(3750), IOUAmount{3354101966249684, -12})); + amm.expectBalances(usd(3000), eur(3750), IOUAmount{3354101966249684, -12})); } // Alice has 3/4 of its initial lptokens Left. @@ -597,87 +597,87 @@ class AMMClawback_test : public beast::unit_test::suite } // gw clawback another 500 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, EUR, USD(500)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(500)), Ter(tesSUCCESS)); env.close(); // Alice should still has 2000 USD because gw clawed back from the // AMM pool. - env.require(balance(alice, USD(2000))); + env.require(Balance(alice, usd(2000))); if (!features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2500000000000001), -12}, - STAmount{EUR, UINT64_C(3125000000000001), -12}, + STAmount{usd, UINT64_C(2500000000000001), -12}, + STAmount{eur, UINT64_C(3125000000000001), -12}, IOUAmount{2795084971874738, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(2500), EUR(3125), IOUAmount{2795084971874737, -12})); + amm.expectBalances(usd(2500), eur(3125), IOUAmount{2795084971874737, -12})); } if (!features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(alice, EUR) == STAmount(EUR, UINT64_C(2874999999999999), -12)); + env.balance(alice, eur) == STAmount(eur, UINT64_C(2874999999999999), -12)); } else { - BEAST_EXPECT(env.balance(alice, EUR) == EUR(2875)); + BEAST_EXPECT(env.balance(alice, eur) == eur(2875)); } // gw clawback small amount, 1 USD. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1)), Ter(tesSUCCESS)); env.close(); // Another 1 USD / 1.25 EUR was withdrawn. - env.require(balance(alice, USD(2000))); + env.require(Balance(alice, usd(2000))); if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2499000000000002), -12}, - STAmount{EUR, UINT64_C(3123750000000002), -12}, + STAmount{usd, UINT64_C(2499000000000002), -12}, + STAmount{eur, UINT64_C(3123750000000002), -12}, IOUAmount{2793966937885989, -12})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(2499), EUR(3123.75), IOUAmount{2793966937885987, -12})); + amm.expectBalances(usd(2499), eur(3123.75), IOUAmount{2793966937885987, -12})); } else if (features[fixAMMClawbackRounding] && features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2499000000000001), -12}, - STAmount{EUR, UINT64_C(3123750000000001), -12}, + STAmount{usd, UINT64_C(2499000000000001), -12}, + STAmount{eur, UINT64_C(3123750000000001), -12}, IOUAmount{2793966937885988, -12})); } if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - env.balance(alice, EUR) == STAmount(EUR, UINT64_C(2876'249999999998), -12)); + env.balance(alice, eur) == STAmount(eur, UINT64_C(2876'249999999998), -12)); } else if (!features[fixAMMClawbackRounding]) { - BEAST_EXPECT(env.balance(alice, EUR) == EUR(2876.25)); + BEAST_EXPECT(env.balance(alice, eur) == eur(2876.25)); } else if (features[fixAMMClawbackRounding] && features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(alice, EUR) == STAmount(EUR, UINT64_C(2876'249999999999), -12)); + env.balance(alice, eur) == STAmount(eur, UINT64_C(2876'249999999999), -12)); } // gw clawback 4000 USD, exceeding the current balance. We // will clawback all. - env(amm::ammClawback(gw, alice, USD, EUR, USD(4000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(4000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(2000))); + env.require(Balance(alice, usd(2000))); // All alice's EUR in the pool goes back to alice. - BEAST_EXPECT(env.balance(alice, EUR) == STAmount(EUR, UINT64_C(6000000000000000), -12)); + BEAST_EXPECT(env.balance(alice, eur) == STAmount(eur, UINT64_C(6000000000000000), -12)); // amm is automatically deleted. BEAST_EXPECT(!amm.ammExists()); @@ -700,73 +700,73 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw2 sets asfAllowTrustLineClawback. env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw2, asfAllowTrustLineClawback)); + env.require(Flags(gw2, asfAllowTrustLineClawback)); // gw issues 6000 USD to Alice and 5000 USD to Bob. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(6000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(5000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(6000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(5000))); env.close(); // gw2 issues 5000 EUR to Alice and 4000 EUR to Bob. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(5000))); - env.trust(EUR(100000), bob); - env(pay(gw2, bob, EUR(4000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(5000))); + env.trust(eur(100000), bob); + env(pay(gw2, bob, eur(4000))); env.close(); // gw creates AMM pool of XRP/USD, alice and bob deposit XRP/USD. - AMM amm(env, gw, XRP(2000), USD(1000), ter(tesSUCCESS)); - BEAST_EXPECT(amm.expectBalances(USD(1000), XRP(2000), IOUAmount{1414213562373095, -9})); - amm.deposit(alice, USD(1000), XRP(2000)); - BEAST_EXPECT(amm.expectBalances(USD(2000), XRP(4000), IOUAmount{2828427124746190, -9})); - amm.deposit(bob, USD(1000), XRP(2000)); - BEAST_EXPECT(amm.expectBalances(USD(3000), XRP(6000), IOUAmount{4242640687119285, -9})); + AMM amm(env, gw, XRP(2000), usd(1000), Ter(tesSUCCESS)); + BEAST_EXPECT(amm.expectBalances(usd(1000), XRP(2000), IOUAmount{1414213562373095, -9})); + amm.deposit(alice, usd(1000), XRP(2000)); + BEAST_EXPECT(amm.expectBalances(usd(2000), XRP(4000), IOUAmount{2828427124746190, -9})); + amm.deposit(bob, usd(1000), XRP(2000)); + BEAST_EXPECT(amm.expectBalances(usd(3000), XRP(6000), IOUAmount{4242640687119285, -9})); env.close(); // gw2 creates AMM pool of XRP/EUR, alice and bob deposit XRP/EUR. - AMM amm2(env, gw2, XRP(3000), EUR(1000), ter(tesSUCCESS)); + AMM amm2(env, gw2, XRP(3000), eur(1000), Ter(tesSUCCESS)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm2.expectBalances(EUR(1000), XRP(3000), IOUAmount{1732050807568878, -9})); + amm2.expectBalances(eur(1000), XRP(3000), IOUAmount{1732050807568878, -9})); } else { BEAST_EXPECT( - amm2.expectBalances(EUR(1000), XRP(3000), IOUAmount{1732050807568877, -9})); + amm2.expectBalances(eur(1000), XRP(3000), IOUAmount{1732050807568877, -9})); } - amm2.deposit(alice, EUR(1000), XRP(3000)); + amm2.deposit(alice, eur(1000), XRP(3000)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm2.expectBalances(EUR(2000), XRP(6000), IOUAmount{3464101615137756, -9})); + amm2.expectBalances(eur(2000), XRP(6000), IOUAmount{3464101615137756, -9})); } else { BEAST_EXPECT( - amm2.expectBalances(EUR(2000), XRP(6000), IOUAmount{3464101615137754, -9})); + amm2.expectBalances(eur(2000), XRP(6000), IOUAmount{3464101615137754, -9})); } - amm2.deposit(bob, EUR(1000), XRP(3000)); + amm2.deposit(bob, eur(1000), XRP(3000)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm2.expectBalances(EUR(3000), XRP(9000), IOUAmount{5196152422706634, -9})); + amm2.expectBalances(eur(3000), XRP(9000), IOUAmount{5196152422706634, -9})); } else { BEAST_EXPECT( - amm2.expectBalances(EUR(3000), XRP(9000), IOUAmount{5196152422706631, -9})); + amm2.expectBalances(eur(3000), XRP(9000), IOUAmount{5196152422706631, -9})); } env.close(); @@ -774,16 +774,16 @@ class AMMClawback_test : public beast::unit_test::suite auto bobXrpBalance = env.balance(bob, XRP); // gw clawback 500 USD from alice in amm - env(amm::ammClawback(gw, alice, USD, XRP, USD(500)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(500)), Ter(tesSUCCESS)); env.close(); // Alice's initial balance for USD is 6000 USD. Alice deposited 1000 // USD into the pool, then she has 5000 USD. And 500 USD was clawed // back from the AMM pool, so she still has 5000 USD. - env.require(balance(alice, USD(5000))); + env.require(Balance(alice, usd(5000))); // Bob's balance is not changed. - env.require(balance(bob, USD(4000))); + env.require(Balance(bob, usd(4000))); // Alice gets 1000 XRP back. if (features[fixAMMClawbackRounding] && features[fixAMMv1_3]) @@ -800,17 +800,17 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(2500), XRP(5000), IOUAmount{3535533905932738, -9})); + amm.expectBalances(usd(2500), XRP(5000), IOUAmount{3535533905932738, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(2500), XRP(5000), IOUAmount{3535533905932737, -9})); + amm.expectBalances(usd(2500), XRP(5000), IOUAmount{3535533905932737, -9})); } else if (features[fixAMMClawbackRounding] && features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - USD(2500), XRPAmount(5000000001), IOUAmount{3'535'533'905932738, -9})); + usd(2500), XRPAmount(5000000001), IOUAmount{3'535'533'905932738, -9})); } if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) @@ -829,11 +829,11 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount{1414213562373095, -9})); // gw clawback 10 USD from bob in amm. - env(amm::ammClawback(gw, bob, USD, XRP, USD(10)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, XRP, usd(10)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(5000))); - env.require(balance(bob, USD(4000))); + env.require(Balance(alice, usd(5000))); + env.require(Balance(bob, usd(4000))); // Bob gets 20 XRP back. BEAST_EXPECT(expectLedgerEntryRoot(env, bob, bobXrpBalance + XRP(20))); @@ -842,19 +842,19 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2490000000000001), -12}, + STAmount{usd, UINT64_C(2490000000000001), -12}, XRP(4980), IOUAmount{3521391770309008, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(2'490), XRP(4980), IOUAmount{3521391770309006, -9})); + amm.expectBalances(usd(2'490), XRP(4980), IOUAmount{3521391770309006, -9})); } else if (features[fixAMMClawbackRounding] && features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(2490000000000001), -12}, + STAmount{usd, UINT64_C(2490000000000001), -12}, XRPAmount(4980000001), IOUAmount{3521391'770309008, -9})); } @@ -886,11 +886,11 @@ class AMMClawback_test : public beast::unit_test::suite } // gw2 clawback 200 EUR from amm2. - env(amm::ammClawback(gw2, alice, EUR, XRP, EUR(200)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, alice, eur, XRP, eur(200)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, EUR(4000))); - env.require(balance(bob, EUR(3000))); + env.require(Balance(alice, eur(4000))); + env.require(Balance(bob, eur(3000))); if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { @@ -910,17 +910,17 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(2800), XRP(8400), IOUAmount{4849742261192859, -9})); + amm2.expectBalances(eur(2800), XRP(8400), IOUAmount{4849742261192859, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(2800), XRP(8400), IOUAmount{4849742261192856, -9})); + amm2.expectBalances(eur(2800), XRP(8400), IOUAmount{4849742261192856, -9})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm2.expectBalances( - EUR(2800), XRPAmount(8400000001), IOUAmount{4849742261192856, -9})); + eur(2800), XRPAmount(8400000001), IOUAmount{4849742261192856, -9})); } if (!features[fixAMMv1_3]) @@ -943,11 +943,11 @@ class AMMClawback_test : public beast::unit_test::suite // gw claw back 1000 USD from alice in amm, which exceeds alice's // balance. This will clawback all the remaining LP tokens of alice // (corresponding 500 USD / 1000 XRP). - env(amm::ammClawback(gw, alice, USD, XRP, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(5000))); - env.require(balance(bob, USD(4000))); + env.require(Balance(alice, usd(5000))); + env.require(Balance(bob, usd(4000))); // Alice gets 1000 XRP back. if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) @@ -982,19 +982,19 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(1990000000000001), -12}, + STAmount{usd, UINT64_C(1990000000000001), -12}, XRP(3980), IOUAmount{2814284989122460, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - USD(1'990), XRPAmount{3'980'000'001}, IOUAmount{2814284989122459, -9})); + usd(1'990), XRPAmount{3'980'000'001}, IOUAmount{2814284989122459, -9})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(1990000000000001), -12}, + STAmount{usd, UINT64_C(1990000000000001), -12}, XRPAmount{3'980'000'001}, IOUAmount{2814284989122460, -9})); } @@ -1002,11 +1002,11 @@ class AMMClawback_test : public beast::unit_test::suite // gw clawback 1000 USD from bob in amm, which also exceeds bob's // balance in amm. All bob's lptoken in amm will be consumed, which // corresponds to 990 USD / 1980 XRP - env(amm::ammClawback(gw, bob, USD, XRP, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, XRP, usd(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(5000))); - env.require(balance(bob, USD(4000))); + env.require(Balance(alice, usd(5000))); + env.require(Balance(bob, usd(4000))); BEAST_EXPECT(expectLedgerEntryRoot(env, alice, aliceXrpBalance)); @@ -1020,11 +1020,11 @@ class AMMClawback_test : public beast::unit_test::suite // gw2 claw back 1000 EUR from alice in amm2, which exceeds alice's // balance. All alice's lptokens will be consumed, which corresponds // to 800EUR / 2400 XRP. - env(amm::ammClawback(gw2, alice, EUR, XRP, EUR(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, alice, eur, XRP, eur(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, EUR(4000))); - env.require(balance(bob, EUR(3000))); + env.require(Balance(alice, eur(4000))); + env.require(Balance(bob, eur(3000))); // Alice gets another 2400 XRP back, bob's XRP balance remains the // same. @@ -1039,27 +1039,27 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(2000), XRP(6000), IOUAmount{3464101615137756, -9})); + amm2.expectBalances(eur(2000), XRP(6000), IOUAmount{3464101615137756, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(2000), XRP(6000), IOUAmount{3464101615137754, -9})); + amm2.expectBalances(eur(2000), XRP(6000), IOUAmount{3464101615137754, -9})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm2.expectBalances( - EUR(2000), XRPAmount(6000000001), IOUAmount{3464101615137754, -9})); + eur(2000), XRPAmount(6000000001), IOUAmount{3464101615137754, -9})); } // gw2 claw back 2000 EUR from bob in amm2, which exceeds bob's // balance. All bob's lptokens will be consumed, which corresponds // to 1000EUR / 3000 XRP. - env(amm::ammClawback(gw2, bob, EUR, XRP, EUR(2000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, bob, eur, XRP, eur(2000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, EUR(4000))); - env.require(balance(bob, EUR(3000))); + env.require(Balance(alice, eur(4000))); + env.require(Balance(bob, eur(3000))); // Bob gets another 3000 XRP back. Alice's XRP balance remains the // same. @@ -1075,17 +1075,17 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(1000), XRP(3000), IOUAmount{1732050807568878, -9})); + amm2.expectBalances(eur(1000), XRP(3000), IOUAmount{1732050807568878, -9})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm2.expectBalances(EUR(1000), XRP(3000), IOUAmount{1732050807568877, -9})); + amm2.expectBalances(eur(1000), XRP(3000), IOUAmount{1732050807568877, -9})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm2.expectBalances( - EUR(1000), XRPAmount(3000000001), IOUAmount{1732050807568877, -9})); + eur(1000), XRPAmount(3000000001), IOUAmount{1732050807568877, -9})); } } } @@ -1111,70 +1111,70 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw2 sets asfAllowTrustLineClawback. env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw2, asfAllowTrustLineClawback)); + env.require(Flags(gw2, asfAllowTrustLineClawback)); // gw issues 6000 USD to Alice, 5000 USD to Bob, and 4000 USD // to Carol. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(6000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(5000))); - env.trust(USD(100000), carol); - env(pay(gw, carol, USD(4000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(6000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(5000))); + env.trust(usd(100000), carol); + env(pay(gw, carol, usd(4000))); env.close(); // gw2 issues 6000 EUR to Alice and 5000 EUR to Bob and 4000 // EUR to Carol. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(6000))); - env.trust(EUR(100000), bob); - env(pay(gw2, bob, EUR(5000))); - env.trust(EUR(100000), carol); - env(pay(gw2, carol, EUR(4000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(6000))); + env.trust(eur(100000), bob); + env(pay(gw2, bob, eur(5000))); + env.trust(eur(100000), carol); + env(pay(gw2, carol, eur(4000))); env.close(); // Alice creates AMM pool of EUR/USD - AMM amm(env, alice, EUR(5000), USD(4000), ter(tesSUCCESS)); + AMM amm(env, alice, eur(5000), usd(4000), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(4000), EUR(5000), IOUAmount{4472135954999580, -12})); + amm.expectBalances(usd(4000), eur(5000), IOUAmount{4472135954999580, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(4000), EUR(5000), IOUAmount{4472135954999579, -12})); + amm.expectBalances(usd(4000), eur(5000), IOUAmount{4472135954999579, -12})); } - amm.deposit(bob, USD(2000), EUR(2500)); + amm.deposit(bob, usd(2000), eur(2500)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(6000), EUR(7500), IOUAmount{6708203932499370, -12})); + amm.expectBalances(usd(6000), eur(7500), IOUAmount{6708203932499370, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(6000), EUR(7500), IOUAmount{6708203932499368, -12})); + amm.expectBalances(usd(6000), eur(7500), IOUAmount{6708203932499368, -12})); } - amm.deposit(carol, USD(1000), EUR(1250)); + amm.deposit(carol, usd(1000), eur(1250)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(7000), EUR(8750), IOUAmount{7826237921249265, -12})); + amm.expectBalances(usd(7000), eur(8750), IOUAmount{7826237921249265, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(7000), EUR(8750), IOUAmount{7826237921249262, -12})); + amm.expectBalances(usd(7000), eur(8750), IOUAmount{7826237921249262, -12})); } if (!features[fixAMMv1_3]) @@ -1202,29 +1202,29 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount{1118033988749894, -12})); } - env.require(balance(alice, USD(2000))); - env.require(balance(alice, EUR(1000))); - env.require(balance(bob, USD(3000))); - env.require(balance(bob, EUR(2500))); - env.require(balance(carol, USD(3000))); - env.require(balance(carol, EUR(2750))); + env.require(Balance(alice, usd(2000))); + env.require(Balance(alice, eur(1000))); + env.require(Balance(bob, usd(3000))); + env.require(Balance(bob, eur(2500))); + env.require(Balance(carol, usd(3000))); + env.require(Balance(carol, eur(2750))); // gw clawback all the bob's USD in amm. (2000 USD / 2500 EUR) - env(amm::ammClawback(gw, bob, USD, EUR, std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, eur, std::nullopt), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(4999999999999999), -12}, - STAmount{EUR, UINT64_C(6249999999999999), -12}, + STAmount{usd, UINT64_C(4999999999999999), -12}, + STAmount{eur, UINT64_C(6249999999999999), -12}, IOUAmount{5590169943749475, -12})); } else { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(5000000000000001), -12}, - STAmount{EUR, UINT64_C(6250000000000001), -12}, + STAmount{usd, UINT64_C(5000000000000001), -12}, + STAmount{eur, UINT64_C(6250000000000001), -12}, IOUAmount{5590169943749473, -12})); } @@ -1247,38 +1247,38 @@ class AMMClawback_test : public beast::unit_test::suite } // Bob will get 2500 EUR back. - env.require(balance(alice, USD(2000))); - env.require(balance(alice, EUR(1000))); - BEAST_EXPECT(env.balance(bob, USD) == STAmount(USD, UINT64_C(3000000000000000), -12)); + env.require(Balance(alice, usd(2000))); + env.require(Balance(alice, eur(1000))); + BEAST_EXPECT(env.balance(bob, usd) == STAmount(usd, UINT64_C(3000000000000000), -12)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(bob, EUR) == STAmount(EUR, UINT64_C(5000000000000001), -12)); + env.balance(bob, eur) == STAmount(eur, UINT64_C(5000000000000001), -12)); } else { BEAST_EXPECT( - env.balance(bob, EUR) == STAmount(EUR, UINT64_C(4999999999999999), -12)); + env.balance(bob, eur) == STAmount(eur, UINT64_C(4999999999999999), -12)); } - env.require(balance(carol, USD(3000))); - env.require(balance(carol, EUR(2750))); + env.require(Balance(carol, usd(3000))); + env.require(Balance(carol, eur(2750))); // gw2 clawback all carol's EUR in amm. (1000 USD / 1250 EUR) - env(amm::ammClawback(gw2, carol, EUR, USD, std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, carol, eur, usd, std::nullopt), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(3999999999999999), -12}, - STAmount{EUR, UINT64_C(4999999999999999), -12}, + STAmount{usd, UINT64_C(3999999999999999), -12}, + STAmount{eur, UINT64_C(4999999999999999), -12}, IOUAmount{4472135954999580, -12})); } else { BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(4000000000000001), -12}, - STAmount{EUR, UINT64_C(5000000000000002), -12}, + STAmount{usd, UINT64_C(4000000000000001), -12}, + STAmount{eur, UINT64_C(5000000000000002), -12}, IOUAmount{4472135954999579, -12})); } @@ -1294,11 +1294,11 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(0))); // gw2 clawback all alice's EUR in amm. (4000 USD / 5000 EUR) - env(amm::ammClawback(gw2, alice, EUR, USD, std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, alice, eur, usd, std::nullopt), Ter(tesSUCCESS)); env.close(); - env.require(balance(carol, EUR(2750))); - env.require(balance(carol, USD(4000))); + env.require(Balance(carol, eur(2750))); + env.require(Balance(carol, usd(4000))); BEAST_EXPECT(!amm.ammExists()); } @@ -1315,49 +1315,49 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 600000 USD to Alice and 500000 USD to Bob. - auto const USD = gw["USD"]; - env.trust(USD(1000000), alice); - env(pay(gw, alice, USD(600000))); - env.trust(USD(1000000), bob); - env(pay(gw, bob, USD(500000))); + auto const usd = gw["USD"]; + env.trust(usd(1000000), alice); + env(pay(gw, alice, usd(600000))); + env.trust(usd(1000000), bob); + env(pay(gw, bob, usd(500000))); env.close(); // gw creates AMM pool of XRP/USD, alice and bob deposit XRP/USD. - AMM amm(env, gw, XRP(2000), USD(10000), ter(tesSUCCESS)); + AMM amm(env, gw, XRP(2000), usd(10000), Ter(tesSUCCESS)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(10000), XRP(2000), IOUAmount{4472135954999580, -9})); + amm.expectBalances(usd(10000), XRP(2000), IOUAmount{4472135954999580, -9})); } else { BEAST_EXPECT( - amm.expectBalances(USD(10000), XRP(2000), IOUAmount{4472135954999579, -9})); + amm.expectBalances(usd(10000), XRP(2000), IOUAmount{4472135954999579, -9})); } - amm.deposit(alice, USD(1000), XRP(200)); + amm.deposit(alice, usd(1000), XRP(200)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(11000), XRP(2200), IOUAmount{4919349550499538, -9})); + amm.expectBalances(usd(11000), XRP(2200), IOUAmount{4919349550499538, -9})); } else { BEAST_EXPECT( - amm.expectBalances(USD(11000), XRP(2200), IOUAmount{4919349550499536, -9})); + amm.expectBalances(usd(11000), XRP(2200), IOUAmount{4919349550499536, -9})); } - amm.deposit(bob, USD(2000), XRP(400)); + amm.deposit(bob, usd(2000), XRP(400)); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(13000), XRP(2600), IOUAmount{5813776741499453, -9})); + amm.expectBalances(usd(13000), XRP(2600), IOUAmount{5813776741499453, -9})); } else { BEAST_EXPECT( - amm.expectBalances(USD(13000), XRP(2600), IOUAmount{5813776741499451, -9})); + amm.expectBalances(usd(13000), XRP(2600), IOUAmount{5813776741499451, -9})); } env.close(); @@ -1365,17 +1365,17 @@ class AMMClawback_test : public beast::unit_test::suite auto bobXrpBalance = env.balance(bob, XRP); // gw clawback all alice's USD in amm. (1000 USD / 200 XRP) - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(12000), XRP(2400), IOUAmount{5366563145999495, -9})); + amm.expectBalances(usd(12000), XRP(2400), IOUAmount{5366563145999495, -9})); } else { BEAST_EXPECT(amm.expectBalances( - USD(12000), XRPAmount(2400000001), IOUAmount{5366563145999494, -9})); + usd(12000), XRPAmount(2400000001), IOUAmount{5366563145999494, -9})); } if (!features[fixAMMv1_3]) { @@ -1389,17 +1389,17 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); // gw clawback all bob's USD in amm. (2000 USD / 400 XRP) - env(amm::ammClawback(gw, bob, USD, XRP, std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, XRP, std::nullopt), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT( - amm.expectBalances(USD(10000), XRP(2000), IOUAmount{4472135954999580, -9})); + amm.expectBalances(usd(10000), XRP(2000), IOUAmount{4472135954999580, -9})); } else { BEAST_EXPECT(amm.expectBalances( - USD(10000), XRPAmount(2000000001), IOUAmount{4472135954999579, -9})); + usd(10000), XRPAmount(2000000001), IOUAmount{4472135954999579, -9})); } BEAST_EXPECT(expectLedgerEntryRoot(env, bob, bobXrpBalance + XRP(400))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); @@ -1428,117 +1428,117 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(10000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(9000))); - env.trust(USD(100000), carol); - env(pay(gw, carol, USD(8000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(10000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(9000))); + env.trust(usd(100000), carol); + env(pay(gw, carol, usd(8000))); env.close(); - auto const EUR = gw["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw, alice, EUR(10000))); - env.trust(EUR(100000), bob); - env(pay(gw, bob, EUR(9000))); - env.trust(EUR(100000), carol); - env(pay(gw, carol, EUR(8000))); + auto const eur = gw["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw, alice, eur(10000))); + env.trust(eur(100000), bob); + env(pay(gw, bob, eur(9000))); + env.trust(eur(100000), carol); + env(pay(gw, carol, eur(8000))); env.close(); - AMM amm(env, alice, EUR(2000), USD(8000), ter(tesSUCCESS)); + AMM amm(env, alice, eur(2000), usd(8000), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(8000), EUR(2000), IOUAmount(4000))); - amm.deposit(bob, USD(4000), EUR(1000)); - BEAST_EXPECT(amm.expectBalances(USD(12000), EUR(3000), IOUAmount(6000))); + BEAST_EXPECT(amm.expectBalances(usd(8000), eur(2000), IOUAmount(4000))); + amm.deposit(bob, usd(4000), eur(1000)); + BEAST_EXPECT(amm.expectBalances(usd(12000), eur(3000), IOUAmount(6000))); if (!features[fixAMMv1_3]) { - amm.deposit(carol, USD(2000), EUR(500)); + amm.deposit(carol, usd(2000), eur(500)); } else { - amm.deposit(carol, USD(2000.25), EUR(500)); + amm.deposit(carol, usd(2000.25), eur(500)); } - BEAST_EXPECT(amm.expectBalances(USD(14000), EUR(3500), IOUAmount(7000))); + BEAST_EXPECT(amm.expectBalances(usd(14000), eur(3500), IOUAmount(7000))); // gw clawback 1000 USD from carol. - env(amm::ammClawback(gw, carol, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, carol, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(13000), EUR(3250), IOUAmount(6500))); + BEAST_EXPECT(amm.expectBalances(usd(13000), eur(3250), IOUAmount(6500))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(4000))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(2000))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } // 250 EUR goes back to carol. - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); // gw clawback 1000 USD from bob with tfClawTwoAssets flag. // then the corresponding EUR will also be clawed back // by gw. - env(amm::ammClawback(gw, bob, USD, EUR, USD(1000)), - txflags(tfClawTwoAssets), - ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, eur, usd(1000)), + Txflags(tfClawTwoAssets), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(12000), EUR(3000), IOUAmount(6000))); + BEAST_EXPECT(amm.expectBalances(usd(12000), eur(3000), IOUAmount(6000))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(4000))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(1500))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); // 250 EUR did not go back to bob because tfClawTwoAssets is set. - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); // gw clawback all USD from alice and set tfClawTwoAssets. - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), - txflags(tfClawTwoAssets), - ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(4000), EUR(1000), IOUAmount(2000))); + BEAST_EXPECT(amm.expectBalances(usd(4000), eur(1000), IOUAmount(2000))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(1500))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); } void @@ -1562,12 +1562,12 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw2 sets asfAllowTrustLineClawback. env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw2, asfAllowTrustLineClawback)); + env.require(Flags(gw2, asfAllowTrustLineClawback)); env.trust(gw["USD"](100000), alice); env(pay(gw, alice, gw["USD"](8000))); @@ -1580,7 +1580,7 @@ class AMMClawback_test : public beast::unit_test::suite env(pay(gw2, bob, gw2["USD"](5000))); env.close(); - AMM amm(env, alice, gw["USD"](1000), gw2["USD"](1500), ter(tesSUCCESS)); + AMM amm(env, alice, gw["USD"](1000), gw2["USD"](1500), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(amm.expectBalances( @@ -1596,7 +1596,7 @@ class AMMClawback_test : public beast::unit_test::suite gw2["USD"], gw["USD"], STAmount{Issue{gw2["USD"].currency, gw2.id()}, 500}), - ter(temMALFORMED)); + Ter(temMALFORMED)); // gw2 clawback 500 gw2[USD] from alice. env(amm::ammClawback( @@ -1605,7 +1605,7 @@ class AMMClawback_test : public beast::unit_test::suite gw2["USD"], gw["USD"], STAmount{Issue{gw2["USD"].currency, gw2.id()}, 500}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(amm.expectBalances( STAmount{gw["USD"], UINT64_C(2666666666666667), -12}, @@ -1621,7 +1621,7 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(bob, gw2["USD"]) == gw2["USD"](2000)); // gw clawback all gw["USD"] from bob. - env(amm::ammClawback(gw, bob, gw["USD"], gw2["USD"], std::nullopt), ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, gw["USD"], gw2["USD"], std::nullopt), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(amm.expectBalances( STAmount{gw["USD"], UINT64_C(6666666666666670), -13}, @@ -1656,52 +1656,52 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw2 sets asfAllowTrustLineClawback. env(fset(gw2, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw2, asfAllowTrustLineClawback)); + env.require(Flags(gw2, asfAllowTrustLineClawback)); - auto const USD = gw["USD"]; - env.trust(USD(100000), gw2); - env(pay(gw, gw2, USD(5000))); - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(5000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), gw2); + env(pay(gw, gw2, usd(5000))); + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(5000))); - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), gw); - env(pay(gw2, gw, EUR(6000))); - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(6000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), gw); + env(pay(gw2, gw, eur(6000))); + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(6000))); env.close(); - AMM amm(env, gw, USD(1000), EUR(2000), ter(tesSUCCESS)); + AMM amm(env, gw, usd(1000), eur(2000), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(1000), EUR(2000), IOUAmount{1414213562373095, -12})); + BEAST_EXPECT(amm.expectBalances(usd(1000), eur(2000), IOUAmount{1414213562373095, -12})); - amm.deposit(gw2, USD(2000), EUR(4000)); - BEAST_EXPECT(amm.expectBalances(USD(3000), EUR(6000), IOUAmount{4242640687119285, -12})); + amm.deposit(gw2, usd(2000), eur(4000)); + BEAST_EXPECT(amm.expectBalances(usd(3000), eur(6000), IOUAmount{4242640687119285, -12})); - amm.deposit(alice, USD(3000), EUR(6000)); - BEAST_EXPECT(amm.expectBalances(USD(6000), EUR(12000), IOUAmount{8485281374238570, -12})); + amm.deposit(alice, usd(3000), eur(6000)); + BEAST_EXPECT(amm.expectBalances(usd(6000), eur(12000), IOUAmount{8485281374238570, -12})); BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{1414213562373095, -12})); BEAST_EXPECT(amm.expectLPTokens(gw2, IOUAmount{2828427124746190, -12})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242640687119285, -12})); // gw claws back 1000 USD from gw2. - env(amm::ammClawback(gw, gw2, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, gw2, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3] || !features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(5000), EUR(10000), IOUAmount{7071067811865475, -12})); + amm.expectBalances(usd(5000), eur(10000), IOUAmount{7071067811865475, -12})); } else { BEAST_EXPECT( - amm.expectBalances(USD(5000), EUR(10000), IOUAmount{7071067811865474, -12})); + amm.expectBalances(usd(5000), eur(10000), IOUAmount{7071067811865474, -12})); } BEAST_EXPECT(amm.expectLPTokens(gw, IOUAmount{1414213562373095, -12})); @@ -1715,31 +1715,31 @@ class AMMClawback_test : public beast::unit_test::suite } BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242640687119285, -12})); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); - BEAST_EXPECT(env.balance(gw, EUR) == EUR(4000)); - BEAST_EXPECT(env.balance(gw2, USD) == USD(3000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); + BEAST_EXPECT(env.balance(gw, eur) == eur(4000)); + BEAST_EXPECT(env.balance(gw2, usd) == usd(3000)); // gw2 claws back 1000 EUR from gw. - env(amm::ammClawback(gw2, gw, EUR, USD, EUR(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, gw, eur, usd, eur(1000)), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - USD(4500), - STAmount(EUR, UINT64_C(9000000000000001), -12), + usd(4500), + STAmount(eur, UINT64_C(9000000000000001), -12), IOUAmount{6363961030678928, -12})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(4500), EUR(9000), IOUAmount{6363961030678928, -12})); + amm.expectBalances(usd(4500), eur(9000), IOUAmount{6363961030678928, -12})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - USD(4500), - STAmount(EUR, UINT64_C(9000000000000001), -12), + usd(4500), + STAmount(eur, UINT64_C(9000000000000001), -12), IOUAmount{6363961030678927, -12})); } @@ -1767,31 +1767,31 @@ class AMMClawback_test : public beast::unit_test::suite BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{4242640687119285, -12})); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); - BEAST_EXPECT(env.balance(gw, EUR) == EUR(4000)); - BEAST_EXPECT(env.balance(gw2, USD) == USD(3000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); + BEAST_EXPECT(env.balance(gw, eur) == eur(4000)); + BEAST_EXPECT(env.balance(gw2, usd) == usd(3000)); // gw2 claws back 4000 EUR from alice. - env(amm::ammClawback(gw2, alice, EUR, USD, EUR(4000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw2, alice, eur, usd, eur(4000)), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - USD(2500), - STAmount(EUR, UINT64_C(5000000000000001), -12), + usd(2500), + STAmount(eur, UINT64_C(5000000000000001), -12), IOUAmount{3535533905932738, -12})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT( - amm.expectBalances(USD(2500), EUR(5000), IOUAmount{3535533905932738, -12})); + amm.expectBalances(usd(2500), eur(5000), IOUAmount{3535533905932738, -12})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - USD(2500), - STAmount(EUR, UINT64_C(5000000000000001), -12), + usd(2500), + STAmount(eur, UINT64_C(5000000000000001), -12), IOUAmount{3535533905932737, -12})); } @@ -1818,10 +1818,10 @@ class AMMClawback_test : public beast::unit_test::suite } BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{1414213562373095, -12})); - BEAST_EXPECT(env.balance(alice, USD) == USD(4000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); - BEAST_EXPECT(env.balance(gw, EUR) == EUR(4000)); - BEAST_EXPECT(env.balance(gw2, USD) == USD(3000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(4000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); + BEAST_EXPECT(env.balance(gw, eur) == eur(4000)); + BEAST_EXPECT(env.balance(gw2, usd) == usd(3000)); } void @@ -1841,18 +1841,18 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(5000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(5000))); - AMM const amm(env, gw, USD(1000), XRP(2000), ter(tesSUCCESS)); + AMM const amm(env, gw, usd(1000), XRP(2000), Ter(tesSUCCESS)); env.close(); // Alice did not deposit in the amm pool. So AMMClawback from Alice // will fail. - env(amm::ammClawback(gw, alice, USD, XRP, USD(1000)), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1000)), Ter(tecAMM_BALANCE)); } void @@ -1873,53 +1873,53 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); - env.require(balance(alice, USD(3000))); + env.require(Balance(alice, usd(3000))); // gw2 issues 3000 EUR to Alice. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(3000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(3000))); env.close(); - env.require(balance(alice, EUR(3000))); + env.require(Balance(alice, eur(3000))); // Alice creates AMM pool of EUR/USD. - AMM const amm(env, alice, EUR(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, eur(1000), usd(2000), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(2000), EUR(1000), IOUAmount{1414213562373095, -12})); + amm.expectBalances(usd(2000), eur(1000), IOUAmount{1414213562373095, -12})); // freeze trustline env(trust(gw, alice["USD"](0), tfSetFreeze)); env.close(); // gw clawback 1000 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(1000))); - env.require(balance(alice, EUR(2500))); - BEAST_EXPECT(amm.expectBalances(USD(1000), EUR(500), IOUAmount{7071067811865475, -13})); + env.require(Balance(alice, usd(1000))); + env.require(Balance(alice, eur(2500))); + BEAST_EXPECT(amm.expectBalances(usd(1000), eur(500), IOUAmount{7071067811865475, -13})); // Alice has half of its initial lptokens Left. BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{7071067811865475, -13})); // gw clawback another 1000 USD from the AMM pool. The AMM pool will // be empty and get deleted. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); // Alice should still has 1000 USD because gw clawed back from the // AMM pool. - env.require(balance(alice, USD(1000))); - env.require(balance(alice, EUR(3000))); + env.require(Balance(alice, usd(1000))); + env.require(Balance(alice, eur(3000))); // amm is automatically deleted. BEAST_EXPECT(!amm.ammExists()); @@ -1937,28 +1937,28 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); - env.require(balance(alice, USD(3000))); + env.require(Balance(alice, usd(3000))); // gw2 issues 3000 EUR to Alice. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(3000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(3000))); env.close(); - env.require(balance(alice, EUR(3000))); + env.require(Balance(alice, eur(3000))); // Alice creates AMM pool of EUR/USD. - AMM const amm(env, alice, EUR(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, eur(1000), usd(2000), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(2000), EUR(1000), IOUAmount{1414213562373095, -12})); + amm.expectBalances(usd(2000), eur(1000), IOUAmount{1414213562373095, -12})); // freeze trustlines env(trust(gw, alice["USD"](0), tfSetFreeze)); @@ -1966,12 +1966,12 @@ class AMMClawback_test : public beast::unit_test::suite env.close(); // gw clawback 1000 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(1000))); - env.require(balance(alice, EUR(2500))); - BEAST_EXPECT(amm.expectBalances(USD(1000), EUR(500), IOUAmount{7071067811865475, -13})); + env.require(Balance(alice, usd(1000))); + env.require(Balance(alice, eur(2500))); + BEAST_EXPECT(amm.expectBalances(usd(1000), eur(500), IOUAmount{7071067811865475, -13})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{7071067811865475, -13})); } @@ -1987,40 +1987,40 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 3000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(3000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(3000))); env.close(); - env.require(balance(alice, USD(3000))); + env.require(Balance(alice, usd(3000))); // gw2 issues 3000 EUR to Alice. - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(3000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(3000))); env.close(); - env.require(balance(alice, EUR(3000))); + env.require(Balance(alice, eur(3000))); // Alice creates AMM pool of EUR/USD. - AMM const amm(env, alice, EUR(1000), USD(2000), ter(tesSUCCESS)); + AMM const amm(env, alice, eur(1000), usd(2000), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT( - amm.expectBalances(USD(2000), EUR(1000), IOUAmount{1414213562373095, -12})); + amm.expectBalances(usd(2000), eur(1000), IOUAmount{1414213562373095, -12})); // global freeze env(fset(gw, asfGlobalFreeze)); env.close(); // gw clawback 1000 USD from the AMM pool. - env(amm::ammClawback(gw, alice, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(alice, USD(1000))); - env.require(balance(alice, EUR(2500))); - BEAST_EXPECT(amm.expectBalances(USD(1000), EUR(500), IOUAmount{7071067811865475, -13})); + env.require(Balance(alice, usd(1000))); + env.require(Balance(alice, eur(2500))); + BEAST_EXPECT(amm.expectBalances(usd(1000), eur(500), IOUAmount{7071067811865475, -13})); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{7071067811865475, -13})); } @@ -2038,122 +2038,122 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(10000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(9000))); - env.trust(USD(100000), carol); - env(pay(gw, carol, USD(8000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(10000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(9000))); + env.trust(usd(100000), carol); + env(pay(gw, carol, usd(8000))); env.close(); - auto const EUR = gw["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw, alice, EUR(10000))); - env.trust(EUR(100000), bob); - env(pay(gw, bob, EUR(9000))); - env.trust(EUR(100000), carol); - env(pay(gw, carol, EUR(8000))); + auto const eur = gw["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw, alice, eur(10000))); + env.trust(eur(100000), bob); + env(pay(gw, bob, eur(9000))); + env.trust(eur(100000), carol); + env(pay(gw, carol, eur(8000))); env.close(); - AMM amm(env, alice, EUR(2000), USD(8000), ter(tesSUCCESS)); + AMM amm(env, alice, eur(2000), usd(8000), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(8000), EUR(2000), IOUAmount(4000))); - amm.deposit(bob, USD(4000), EUR(1000)); - BEAST_EXPECT(amm.expectBalances(USD(12000), EUR(3000), IOUAmount(6000))); + BEAST_EXPECT(amm.expectBalances(usd(8000), eur(2000), IOUAmount(4000))); + amm.deposit(bob, usd(4000), eur(1000)); + BEAST_EXPECT(amm.expectBalances(usd(12000), eur(3000), IOUAmount(6000))); if (!features[fixAMMv1_3]) { - amm.deposit(carol, USD(2000), EUR(500)); + amm.deposit(carol, usd(2000), eur(500)); } else { - amm.deposit(carol, USD(2000.25), EUR(500)); + amm.deposit(carol, usd(2000.25), eur(500)); } - BEAST_EXPECT(amm.expectBalances(USD(14000), EUR(3500), IOUAmount(7000))); + BEAST_EXPECT(amm.expectBalances(usd(14000), eur(3500), IOUAmount(7000))); // global freeze env(fset(gw, asfGlobalFreeze)); env.close(); // gw clawback 1000 USD from carol. - env(amm::ammClawback(gw, carol, USD, EUR, USD(1000)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, carol, usd, eur, usd(1000)), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(13000), EUR(3250), IOUAmount(6500))); + BEAST_EXPECT(amm.expectBalances(usd(13000), eur(3250), IOUAmount(6500))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(4000))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(2000))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } // 250 EUR goes back to carol. - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); // gw clawback 1000 USD from bob with tfClawTwoAssets flag. // then the corresponding EUR will also be clawed back // by gw. - env(amm::ammClawback(gw, bob, USD, EUR, USD(1000)), - txflags(tfClawTwoAssets), - ter(tesSUCCESS)); + env(amm::ammClawback(gw, bob, usd, eur, usd(1000)), + Txflags(tfClawTwoAssets), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(12000), EUR(3000), IOUAmount(6000))); + BEAST_EXPECT(amm.expectBalances(usd(12000), eur(3000), IOUAmount(6000))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(4000))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(1500))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); // 250 EUR did not go back to bob because tfClawTwoAssets is set. - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); // gw clawback all USD from alice and set tfClawTwoAssets. - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), - txflags(tfClawTwoAssets), - ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(4000), EUR(1000), IOUAmount(2000))); + BEAST_EXPECT(amm.expectBalances(usd(4000), eur(1000), IOUAmount(2000))); BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); BEAST_EXPECT(amm.expectLPTokens(bob, IOUAmount(1500))); BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount(500))); - BEAST_EXPECT(env.balance(alice, USD) == USD(2000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(8000)); - BEAST_EXPECT(env.balance(bob, USD) == USD(5000)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(8000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(2000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(8000)); + BEAST_EXPECT(env.balance(bob, usd) == usd(5000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(8000)); if (!features[fixAMMv1_3]) { - BEAST_EXPECT(env.balance(carol, USD) == USD(6000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(6000)); } else { BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(5999'999999999999), -12)); + env.balance(carol, usd) == STAmount(usd, UINT64_C(5999'999999999999), -12)); } - BEAST_EXPECT(env.balance(carol, EUR) == EUR(7750)); + BEAST_EXPECT(env.balance(carol, eur) == eur(7750)); } } @@ -2175,40 +2175,40 @@ class AMMClawback_test : public beast::unit_test::suite // gw sets asfAllowTrustLineClawback. env(fset(gw, asfAllowTrustLineClawback)); env.close(); - env.require(flags(gw, asfAllowTrustLineClawback)); + env.require(Flags(gw, asfAllowTrustLineClawback)); // gw issues 1000 USD to Alice. - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(1000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(1000))); env.close(); - env.require(balance(alice, USD(1000))); + env.require(Balance(alice, usd(1000))); // gw creates AMM pool of XRP/USD. - AMM amm(env, gw, XRP(100), USD(400), ter(tesSUCCESS)); + AMM amm(env, gw, XRP(100), usd(400), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(400), XRP(100), IOUAmount(200000))); + BEAST_EXPECT(amm.expectBalances(usd(400), XRP(100), IOUAmount(200000))); - amm.deposit(alice, USD(400)); + amm.deposit(alice, usd(400)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(800), XRP(100), IOUAmount{2828427124746190, -10})); + BEAST_EXPECT(amm.expectBalances(usd(800), XRP(100), IOUAmount{2828427124746190, -10})); auto aliceXrpBalance = env.balance(alice, XRP); - env(amm::ammClawback(gw, alice, USD, XRP, USD(400)), ter(tesSUCCESS)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(400)), Ter(tesSUCCESS)); env.close(); if (!features[fixAMMv1_3]) { BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(5656854249492380), -13), XRP(70.710678), IOUAmount(200000))); + STAmount(usd, UINT64_C(5656854249492380), -13), XRP(70.710678), IOUAmount(200000))); } else { BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(565'685424949238), -12), XRP(70.710679), IOUAmount(200000))); + STAmount(usd, UINT64_C(565'685424949238), -12), XRP(70.710679), IOUAmount(200000))); } BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount(0))); if (!features[fixAMMv1_3]) @@ -2237,14 +2237,14 @@ class AMMClawback_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(40000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(40000))); env.close(); - return USD; + return usd; }; auto getLPTokenBalances = [&](auto& env, @@ -2262,9 +2262,9 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); - AMM amm(env, alice, XRP(2), USD(1)); + AMM amm(env, alice, XRP(2), usd(1)); amm.deposit(alice, IOUAmount{1'876123487565916, -15}); amm.deposit(bob, IOUAmount{1'000'000}); amm.withdraw(alice, IOUAmount{1'876123487565916, -15}); @@ -2278,15 +2278,15 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMClawbackRounding] || !features[fixAMMv1_3]) { - env(amm::ammClawback(gw, alice, USD, XRP, USD(1)), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1)), Ter(tecAMM_BALANCE)); BEAST_EXPECT(amm.ammExists()); } else { auto const lpBalance = IOUAmount{989, -12}; - env(amm::ammClawback(gw, alice, USD, XRP, USD(1))); + env(amm::ammClawback(gw, alice, usd, XRP, usd(1))); BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(7000000000000000), -28), XRPAmount(1), lpBalance)); + STAmount(usd, UINT64_C(7000000000000000), -28), XRPAmount(1), lpBalance)); BEAST_EXPECT(amm.expectLPTokens(alice, lpBalance)); } } @@ -2295,9 +2295,9 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); - AMM amm(env, alice, XRP(2), USD(1)); + AMM amm(env, alice, XRP(2), usd(1)); amm.deposit(alice, IOUAmount{1'876123487565916, -15}); amm.deposit(bob, IOUAmount{1'000'000}); amm.withdrawAll(bob); @@ -2308,19 +2308,19 @@ class AMMClawback_test : public beast::unit_test::suite auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice); BEAST_EXPECT(res && res.value()); - env(amm::ammClawback(gw, alice, USD, XRP, USD(0.5))); + env(amm::ammClawback(gw, alice, usd, XRP, usd(0.5))); if (!features[fixAMMv1_3] && !features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(5013266196406), -13), + STAmount(usd, UINT64_C(5013266196406), -13), XRPAmount(1002653), IOUAmount{708'9829046744236, -13})); } else if (!features[fixAMMClawbackRounding]) { BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(5013266196407), -13), + STAmount(usd, UINT64_C(5013266196407), -13), XRPAmount(1002654), IOUAmount{708'9829046744941, -13})); } @@ -2328,7 +2328,7 @@ class AMMClawback_test : public beast::unit_test::suite { auto const lpBalance = IOUAmount{708'9829046743238, -13}; BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(5013266196406999), -16), XRPAmount(1002655), lpBalance)); + STAmount(usd, UINT64_C(5013266196406999), -16), XRPAmount(1002655), lpBalance)); BEAST_EXPECT(amm.expectLPTokens(alice, lpBalance)); } } @@ -2337,9 +2337,9 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); - AMM amm(env, alice, XRP(2), USD(1)); + AMM amm(env, alice, XRP(2), usd(1)); amm.deposit(alice, IOUAmount{1'876123487565916, -15}); amm.deposit(bob, IOUAmount{1'000'000}); amm.withdraw(alice, IOUAmount{1'876123487565916, -15}); @@ -2353,19 +2353,19 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMClawbackRounding] && !features[fixAMMv1_3]) { - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt), Ter(tecAMM_BALANCE)); } else if (!features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt)); BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(2410000000000000), -28), + STAmount(usd, UINT64_C(2410000000000000), -28), XRPAmount(1), IOUAmount{34, -11})); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, XRP, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, XRP, std::nullopt)); BEAST_EXPECT(!amm.ammExists()); } } @@ -2374,19 +2374,19 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); Account const gw2{"gateway2"}; env.fund(XRP(100000), gw2); env.close(); - auto const EUR = gw2["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw2, alice, EUR(50000))); - env.trust(EUR(100000), bob); - env(pay(gw2, bob, EUR(50000))); + auto const eur = gw2["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw2, alice, eur(50000))); + env.trust(eur(100000), bob); + env(pay(gw2, bob, eur(50000))); env.close(); - AMM amm(env, alice, USD(2), EUR(1)); + AMM amm(env, alice, usd(2), eur(1)); amm.deposit(alice, IOUAmount{1'576123487565916, -15}); amm.deposit(bob, IOUAmount{1'000}); amm.withdraw(alice, IOUAmount{1'576123487565916, -15}); @@ -2400,12 +2400,12 @@ class AMMClawback_test : public beast::unit_test::suite if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt)); BEAST_EXPECT(!amm.ammExists()); } else { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), ter(tecINTERNAL)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Ter(tecINTERNAL)); BEAST_EXPECT(amm.ammExists()); } } @@ -2414,16 +2414,16 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); - auto const EUR = gw["EUR"]; - env.trust(EUR(100000), alice); - env(pay(gw, alice, EUR(50000))); - env.trust(EUR(100000), bob); - env(pay(gw, bob, EUR(50000))); + auto const eur = gw["EUR"]; + env.trust(eur(100000), alice); + env(pay(gw, alice, eur(50000))); + env.trust(eur(100000), bob); + env(pay(gw, bob, eur(50000))); env.close(); - AMM amm(env, alice, USD(1), EUR(2)); + AMM amm(env, alice, usd(1), eur(2)); amm.deposit(alice, IOUAmount{1'076123487565916, -15}); amm.deposit(bob, IOUAmount{1'000}); amm.withdraw(alice, IOUAmount{1'076123487565916, -15}); @@ -2437,14 +2437,14 @@ class AMMClawback_test : public beast::unit_test::suite if (features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), Txflags(tfClawTwoAssets)); BEAST_EXPECT(!amm.ammExists()); } else { - env(amm::ammClawback(gw, alice, USD, EUR, std::nullopt), - txflags(tfClawTwoAssets), - ter(tecINTERNAL)); + env(amm::ammClawback(gw, alice, usd, eur, std::nullopt), + Txflags(tfClawTwoAssets), + Ter(tecINTERNAL)); BEAST_EXPECT(amm.ammExists()); } } @@ -2453,16 +2453,16 @@ class AMMClawback_test : public beast::unit_test::suite { Env env(*this, features, std::make_unique(&logs)); Account const gw{"gateway"}, alice{"alice"}, bob{"bob"}; - auto const USD = setupAccounts(env, gw, alice, bob); + auto const usd = setupAccounts(env, gw, alice, bob); - auto const EUR = gw["EUR"]; - env.trust(EUR(1000000000), alice); - env(pay(gw, alice, EUR(500000000))); - env.trust(EUR(1000000000), bob); - env(pay(gw, bob, EUR(500000000))); + auto const eur = gw["EUR"]; + env.trust(eur(1000000000), alice); + env(pay(gw, alice, eur(500000000))); + env.trust(eur(1000000000), bob); + env(pay(gw, bob, eur(500000000))); env.close(); - AMM amm(env, alice, USD(1), EUR(2000000)); + AMM amm(env, alice, usd(1), eur(2000000)); amm.deposit(alice, IOUAmount{1'076123487565916, -12}); amm.deposit(bob, IOUAmount{10000}); amm.withdraw(alice, IOUAmount{1'076123487565916, -12}); @@ -2477,25 +2477,25 @@ class AMMClawback_test : public beast::unit_test::suite if (!features[fixAMMClawbackRounding] && !features[fixAMMv1_3]) { - env(amm::ammClawback(gw, alice, USD, EUR, USD(1))); + env(amm::ammClawback(gw, alice, usd, eur, usd(1))); BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(4), -15), - STAmount(EUR, UINT64_C(8), -9), + STAmount(usd, UINT64_C(4), -15), + STAmount(eur, UINT64_C(8), -9), IOUAmount{6, -12})); } else if (!features[fixAMMClawbackRounding]) { // sqrt(amount * amount2) >= LPTokens and exceeds the allowed // tolerance - env(amm::ammClawback(gw, alice, USD, EUR, USD(1)), ter(tecINVARIANT_FAILED)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1)), Ter(tecINVARIANT_FAILED)); BEAST_EXPECT(amm.ammExists()); } else if (features[fixAMMv1_3] && features[fixAMMClawbackRounding]) { - env(amm::ammClawback(gw, alice, USD, EUR, USD(1)), txflags(tfClawTwoAssets)); + env(amm::ammClawback(gw, alice, usd, eur, usd(1)), Txflags(tfClawTwoAssets)); auto const lpBalance = IOUAmount{5, -12}; BEAST_EXPECT(amm.expectBalances( - STAmount(USD, UINT64_C(4), -15), STAmount(EUR, UINT64_C(8), -9), lpBalance)); + STAmount(usd, UINT64_C(4), -15), STAmount(eur, UINT64_C(8), -9), lpBalance)); BEAST_EXPECT(amm.expectLPTokens(alice, lpBalance)); } } @@ -2507,7 +2507,7 @@ class AMMClawback_test : public beast::unit_test::suite // For now, just disable SAV entirely, which locks in the small Number // mantissas FeatureBitset const all = - jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol; + jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol; testInvalidRequest(all); testInvalidRequest(all - featureMPTokensV2); diff --git a/src/test/app/AMMExtendedMPT_test.cpp b/src/test/app/AMMExtendedMPT_test.cpp index 44ced2edc2..6de39b73ec 100644 --- a/src/test/app/AMMExtendedMPT_test.cpp +++ b/src/test/app/AMMExtendedMPT_test.cpp @@ -78,48 +78,48 @@ private: using namespace jtx; Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 200'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 2'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // Must be two offers at the same quality // "taker gets" must be XRP // (Different amounts so I can distinguish the offers) - env(offer(carol, BTC(49'000'000'000'000), XRP(49))); - env(offer(carol, BTC(51'000'000'000'000), XRP(51))); + env(offer(carol_, btc(49'000'000'000'000), XRP(49))); + env(offer(carol_, btc(51'000'000'000'000), XRP(51))); // Offers for the poor quality path // Must be two offers at the same quality - env(offer(carol, XRP(50), ETH(50'000'000'000'000))); - env(offer(carol, XRP(50), ETH(50'000'000'000'000))); + env(offer(carol_, XRP(50), eth(50'000'000'000'000))); + env(offer(carol_, XRP(50), eth(50'000'000'000'000))); // Good quality path - AMM const ammCarol(env, carol, BTC(1'000'000'000'000'000), ETH(100'100'000'000'000'000)); + AMM const ammCarol(env, carol_, btc(1'000'000'000'000'000), eth(100'100'000'000'000'000)); - PathSet const paths(Path(XRP, MPT(ETH)), Path(MPT(ETH))); + PathSet const paths(TestPath(XRP, MPT(eth)), TestPath(MPT(eth))); - env(pay(alice, bob, ETH(100'000'000'000'000)), - json(paths.json()), - sendmax(BTC(1'000'000'000'000'000)), - txflags(tfPartialPayment)); + env(pay(alice_, bob_, eth(100'000'000'000'000)), + Json(paths.json()), + Sendmax(btc(1'000'000'000'000'000)), + Txflags(tfPartialPayment)); BEAST_EXPECT(ammCarol.expectBalances( - BTC(1'001'000'000'374'816), ETH(100'000'000'000'000'000), ammCarol.tokens())); + btc(1'001'000'000'374'816), eth(100'000'000'000'000'000), ammCarol.tokens())); - env.require(balance(bob, ETH(200'100'000'000'000'000))); - BEAST_EXPECT(isOffer(env, carol, BTC(49'000'000'000'000), XRP(49))); + env.require(Balance(bob_, eth(200'100'000'000'000'000))); + BEAST_EXPECT(isOffer(env, carol_, btc(49'000'000'000'000), XRP(49))); } void @@ -135,29 +135,29 @@ private: // that are discovered along the way. testAMM( [&](AMM& ammAlice, Env& env) { - auto const& BTC = MPT(ammAlice[1]); + auto const& btc = MPT(ammAlice[1]); auto const baseFee = env.current()->fees().base; - auto carolBTC = env.balance(carol, BTC); - auto carolXRP = env.balance(carol, XRP); + auto carolBTC = env.balance(carol_, btc); + auto carolXRP = env.balance(carol_, XRP); // Order that can't be filled - env(offer(carol, BTC(100), XRP(100)), txflags(tfFillOrKill), ter(tecKILLED)); + env(offer(carol_, btc(100), XRP(100)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), BTC(10'000), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), btc(10'000), ammAlice.tokens())); // fee = AMM - env.require(balance(carol, carolXRP - baseFee)); - env.require(balance(carol, carolBTC)); + env.require(Balance(carol_, carolXRP - baseFee)); + env.require(Balance(carol_, carolBTC)); - BEAST_EXPECT(expectOffers(env, carol, 0)); - carolXRP = env.balance(carol, XRP); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + carolXRP = env.balance(carol_, XRP); // Order that can be filled - env(offer(carol, XRP(100), BTC(100)), txflags(tfFillOrKill), ter(tesSUCCESS)); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'100), ammAlice.tokens())); - env.require(balance(carol, carolXRP + XRP(100) - baseFee)); - env.require(balance(carol, carolBTC - BTC(100))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + env(offer(carol_, XRP(100), btc(100)), Txflags(tfFillOrKill), Ter(tesSUCCESS)); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'100), ammAlice.tokens())); + env.require(Balance(carol_, carolXRP + XRP(100) - baseFee)); + env.require(Balance(carol_, carolBTC - btc(100))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, - {{XRP(10'100), AMMMPT(10'000)}}, + {{XRP(10'100), gAmmmpt(10'000)}}, 0, std::nullopt, {features}); @@ -166,23 +166,23 @@ private: // and add nothing on the books. testAMM( [&](AMM& ammAlice, Env& env) { - auto const& BTC = MPT(ammAlice[1]); + auto const& btc = MPT(ammAlice[1]); auto const baseFee = env.current()->fees().base; - auto carolBTC = env.balance(carol, BTC); - auto carolXRP = env.balance(carol, XRP); - env(offer(carol, XRP(200), BTC(200)), - txflags(tfImmediateOrCancel), - ter(tesSUCCESS)); + auto carolBTC = env.balance(carol_, btc); + auto carolXRP = env.balance(carol_, XRP); + env(offer(carol_, XRP(200), btc(200)), + Txflags(tfImmediateOrCancel), + Ter(tesSUCCESS)); // AMM generates a synthetic offer of 100BTC/100XRP // to match the CLOB offer quality. - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'100), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'100), ammAlice.tokens())); // +AMM - offer * fee - env.require(balance(carol, carolXRP + XRP(100) - baseFee)); - env.require(balance(carol, carolBTC - BTC(100))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + env.require(Balance(carol_, carolXRP + XRP(100) - baseFee)); + env.require(Balance(carol_, carolBTC - btc(100))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, - {{XRP(10'100), AMMMPT(10'000)}}, + {{XRP(10'100), gAmmmpt(10'000)}}, 0, std::nullopt, {features}); @@ -192,13 +192,13 @@ private: [&](AMM& ammAlice, Env& env) { // Carol creates a passive offer that could cross AMM. // Carol's offer should stay in the ledger. - auto const& BTC = MPT(ammAlice[1]); - env(offer(carol, XRP(100), BTC(100), tfPassive)); + auto const& btc = MPT(ammAlice[1]); + env(offer(carol_, XRP(100), btc(100), tfPassive)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), BTC(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 1, {{{XRP(100), BTC(100)}}})); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), btc(10'000), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{{XRP(100), btc(100)}}})); }, - {{XRP(10'100), AMMMPT(10'000)}}, + {{XRP(10'100), gAmmmpt(10'000)}}, 0, std::nullopt, {features}); @@ -206,19 +206,19 @@ private: // tfPassive -- cross only offers of better quality. testAMM( [&](AMM& ammAlice, Env& env) { - auto const& BTC = MPT(ammAlice[1]); - env(offer(alice, BTC(110), XRP(100))); + auto const& btc = MPT(ammAlice[1]); + env(offer(alice_, btc(110), XRP(100))); env.close(); // Carol creates a passive offer. That offer should cross // AMM and leave Alice's offer untouched. - env(offer(carol, XRP(100), BTC(100), tfPassive)); + env(offer(carol_, XRP(100), btc(100), tfPassive)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'900), BTC(9083), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, alice, 1)); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'900), btc(9083), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 1)); }, - {{XRP(11'000), AMMMPT(9'000)}}, + {{XRP(11'000), gAmmmpt(9'000)}}, 0, std::nullopt, {features}); @@ -233,30 +233,30 @@ private: Env env{*this, features}; - fund(env, gw, {bob, alice}, XRP(300'000)); + fund(env, gw_, {bob_, alice_}, XRP(300'000)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 100'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XRP(150'000), BTC(50'000'000)); + AMM const ammAlice(env, alice_, XRP(150'000), btc(50'000'000)); // Existing offer pays better than this wants. // Partially consume existing offer. // Pay 1'000'000 BTC, get 3061224490 Drops. auto const xrpTransferred = XRPAmount{3'061'224'490}; - env(offer(bob, BTC(1'000'000), XRP(4'000))); + env(offer(bob_, btc(1'000'000), XRP(4'000))); BEAST_EXPECT(ammAlice.expectBalances( - XRP(150'000) + xrpTransferred, BTC(49'000'000), IOUAmount{273'861'278752583, -5})); + XRP(150'000) + xrpTransferred, btc(49'000'000), IOUAmount{273'861'278752583, -5})); - env.require(balance(bob, BTC(101'000'000))); + env.require(Balance(bob_, btc(101'000'000))); BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(300'000) - xrpTransferred - 2 * txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + expectLedgerEntryRoot(env, bob_, XRP(300'000) - xrpTransferred - 2 * txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } void @@ -268,20 +268,20 @@ private: Env env{*this, features}; - env.fund(XRP(200'000), gw, alice, bob); + env.fund(XRP(200'000), gw_, alice_, bob_); env.close(); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(500'000'000))); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(500'000'000))); - AMM const ammAlice(env, alice, XRP(150'000), BTC(51'000'000)); - env(offer(bob, BTC(1'000'000), XRP(3'000))); + AMM const ammAlice(env, alice_, XRP(150'000), btc(51'000'000)); + env(offer(bob_, btc(1'000'000), XRP(3'000))); - BEAST_EXPECT(ammAlice.expectBalances(XRP(153'000), BTC(50'000'000), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(153'000), btc(50'000'000), ammAlice.tokens())); - env.require(balance(bob, BTC(1'000'000))); - env.require(balance(bob, XRP(200'000) - XRP(3'000) - env.current()->fees().base * 2)); + env.require(Balance(bob_, btc(1'000'000))); + env.require(Balance(bob_, XRP(200'000) - XRP(3'000) - env.current()->fees().base * 2)); } void @@ -293,25 +293,25 @@ private: Env env{*this, features}; - fund(env, gw, {alice, bob}, XRP(10'000)); - env.require(owners(bob, 0)); + fund(env, gw_, {alice_, bob_}, XRP(10'000)); + env.require(Owners(bob_, 0)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); - env(pay(gw, bob, BTC(1'000'000'000))); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, bob_, btc(1'000'000'000))); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice_, 1), Owners(bob_, 1)); - env(pay(gw, alice, BTC(100'000'000))); - AMM const ammBob(env, bob, BTC(200'000'000), XRP(1'500)); + env(pay(gw_, alice_, btc(100'000'000))); + AMM const ammBob(env, bob_, btc(200'000'000), XRP(1'500)); - env(pay(alice, alice, XRP(500)), sendmax(BTC(100'000'000))); + env(pay(alice_, alice_, XRP(500)), Sendmax(btc(100'000'000))); - BEAST_EXPECT(ammBob.expectBalances(BTC(300'000'000), XRP(1'000), ammBob.tokens())); - env.require(balance(alice, BTC(0))); + BEAST_EXPECT(ammBob.expectBalances(btc(300'000'000), XRP(1'000), ammBob.tokens())); + env.require(Balance(alice_, btc(0))); - auto jrr = ledgerEntryRoot(env, alice); - env.require(balance(alice, XRP(10'000) + XRP(500) - env.current()->fees().base * 2)); + auto jrr = ledgerEntryRoot(env, alice_); + env.require(Balance(alice_, XRP(10'000) + XRP(500) - env.current()->fees().base * 2)); } void @@ -322,37 +322,37 @@ private: using namespace jtx; Env env{*this, features}; - env.fund(XRP(30'000), gw, bob); - env.fund(XRP(40'000), alice); + env.fund(XRP(30'000), gw_, bob_); + env.fund(XRP(40'000), alice_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 30'000'000'000, - .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(10'000'000'000))); + .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(10'000'000'000))); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000'000'000)); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000'000'000)); env.close(); // Alice converts BTC to XRP which should fail // due to PartialPayment. - env(pay(alice, alice, XRP(100)), sendmax(BTC(100'000'000)), ter(tecPATH_PARTIAL)); + env(pay(alice_, alice_, XRP(100)), Sendmax(btc(100'000'000)), Ter(tecPATH_PARTIAL)); // Alice converts BTC to XRP, should succeed because // we permit partial payment - env(pay(alice, alice, XRP(100)), sendmax(BTC(100'000'000)), txflags(tfPartialPayment)); + env(pay(alice_, alice_, XRP(100)), Sendmax(btc(100'000'000)), Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{9'900'990'100}, BTC(10'100'000'000), ammAlice.tokens())); + XRPAmount{9'900'990'100}, btc(10'100'000'000), ammAlice.tokens())); // initial 40,000'000'000 - 10,000'000'000AMM - 100'000'000pay - env.require(balance(alice, BTC(29'900'000'000))); + env.require(Balance(alice_, btc(29'900'000'000))); // initial 40,000 - 10,0000AMM + 99.009900pay - fee*3 BEAST_EXPECT(expectLedgerEntryRoot( env, - alice, - XRP(40'000) - XRP(10'000) + XRPAmount{99'009'900} - ammCrtFee(env) - txfee(env, 3))); + alice_, + XRP(40'000) - XRP(10'000) + XRPAmount{99'009'900} - ammCrtFee(env) - txFee(env, 3))); } void @@ -363,20 +363,20 @@ private: using namespace jtx; Env env{*this, features}; - env.fund(XRP(30'000), gw); - env.fund(XRP(40'000), alice); - env.fund(XRP(1'000), bob); + env.fund(XRP(30'000), gw_); + env.fund(XRP(40'000), alice_); + env.fund(XRP(1'000), bob_); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(10'100'000'000))); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(10'100'000'000))); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000'000)); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000'000)); env.close(); - env(pay(alice, bob, BTC(100'000'000)), sendmax(XRP(100))); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), BTC(10'000'000'000), ammAlice.tokens())); - env.require(balance(bob, BTC(100'000'000))); + env(pay(alice_, bob_, btc(100'000'000)), Sendmax(XRP(100))); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), btc(10'000'000'000), ammAlice.tokens())); + env.require(Balance(bob_, btc(100'000'000))); } void @@ -387,20 +387,20 @@ private: using namespace jtx; Env env{*this, features}; - env.fund(XRP(30'000), gw); - env.fund(XRP(40'100), alice); - env.fund(XRP(1'000), bob); + env.fund(XRP(30'000), gw_); + env.fund(XRP(40'100), alice_); + env.fund(XRP(1'000), bob_); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(40'000'000'000))); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(40'000'000'000))); - AMM const ammAlice(env, alice, XRP(10'100), BTC(10'000'000'000)); + AMM const ammAlice(env, alice_, XRP(10'100), btc(10'000'000'000)); env.close(); - env(pay(alice, bob, XRP(100)), sendmax(BTC(100'000'000))); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'100'000'000), ammAlice.tokens())); - BEAST_EXPECT(expectLedgerEntryRoot(env, bob, XRP(1'000) + XRP(100) - txfee(env, 1))); + env(pay(alice_, bob_, XRP(100)), Sendmax(btc(100'000'000))); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'100'000'000), ammAlice.tokens())); + BEAST_EXPECT(expectLedgerEntryRoot(env, bob_, XRP(1'000) + XRP(100) - txFee(env, 1))); } void @@ -413,40 +413,40 @@ private: auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); auto const dan = Account{"dan"}; - env.fund(XRP(60'000), alice, bob, carol, gw, dan); + env.fund(XRP(60'000), alice_, bob_, carol_, gw_, dan); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob, carol, dan}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan}, .limit = 10'000'000'000'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol, dan}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan}, .limit = 10'000'000'000'000'000}); - env(pay(gw, alice, BTC(500'000'000'000'000))); - env(pay(gw, carol, BTC(6'000'000'000'000'000))); - env(pay(gw, dan, ETH(400'000'000'000'000))); + env(pay(gw_, alice_, btc(500'000'000'000'000))); + env(pay(gw_, carol_, btc(6'000'000'000'000'000))); + env(pay(gw_, dan, eth(400'000'000'000'000))); env.close(); env.close(); - AMM const ammCarol(env, carol, BTC(5'000'000'000'000'000), XRP(50'000)); + AMM const ammCarol(env, carol_, btc(5'000'000'000'000'000), XRP(50'000)); - env(offer(dan, XRP(500), ETH(50'000'000'000'000))); + env(offer(dan, XRP(500), eth(50'000'000'000'000))); env.close(); - Json::Value jtp{Json::arrayValue}; + json::Value jtp{json::ArrayValue}; jtp[0u][0u][jss::currency] = "XRP"; - env(pay(alice, bob, ETH(30'000'000'000'000)), - json(jss::Paths, jtp), - sendmax(BTC(333'000'000'000'000))); + env(pay(alice_, bob_, eth(30'000'000'000'000)), + Json(jss::Paths, jtp), + Sendmax(btc(333'000'000'000'000))); env.close(); BEAST_EXPECT(ammCarol.expectBalances( - XRP(49'700), BTC(5'030'181'086'519'115), ammCarol.tokens())); - BEAST_EXPECT(expectOffers(env, dan, 1, {{Amounts{XRP(200), ETH(20'000'000'000'000)}}})); - env.require(balance(bob, ETH(30'000'000'000'000))); + XRP(49'700), btc(5'030'181'086'519'115), ammCarol.tokens())); + BEAST_EXPECT(expectOffers(env, dan, 1, {{Amounts{XRP(200), eth(20'000'000'000'000)}}})); + env.require(Balance(bob_, eth(30'000'000'000'000))); }; testHelper2TokensMix(test); } @@ -462,33 +462,34 @@ private: // Provide micro amounts to compensate for fees to make results round // nice. - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(2) + env.current()->fees().base * 3; - env.fund(starting_xrp, gw, alice); - env.fund(XRP(2'000), bob); + env.fund(startingXrp, gw_, alice_); + env.fund(XRP(2'000), bob_); env.close(); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); // Created only to increase one reserve count for alice - MPTTester const ETH({.env = env, .issuer = gw, .holders = {alice}, .flags = MPTDEXFlags}); + MPTTester const eth( + {.env = env, .issuer = gw_, .holders = {alice_}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(1'200'000'000'000'000))); + env(pay(gw_, bob_, btc(1'200'000'000'000'000))); - AMM const ammBob(env, bob, XRP(1'000), BTC(1'200'000'000'000'000)); + AMM const ammBob(env, bob_, XRP(1'000), btc(1'200'000'000'000'000)); // Alice has 400 - (2 reserve of 50 = 300 reserve) = 100 available. // Ask for more than available to prove reserve works. - env(offer(alice, BTC(200'000'000'000'000), XRP(200))); + env(offer(alice_, btc(200'000'000'000'000), XRP(200))); // The pool gets only 100XRP for ~109.09e12BTC, even though // it can exchange more. BEAST_EXPECT( - ammBob.expectBalances(XRP(1'100), BTC(1'090'909'090'909'091), ammBob.tokens())); + ammBob.expectBalances(XRP(1'100), btc(1'090'909'090'909'091), ammBob.tokens())); - env.require(balance(alice, BTC(109'090'909'090'909))); - env.require(balance(alice, XRP(300))); + env.require(Balance(alice_, btc(109'090'909'090'909))); + env.require(Balance(alice_, XRP(300))); } void @@ -500,26 +501,26 @@ private: Env env{*this, features}; - fund(env, gw, {alice, bob}, XRP(200'000)); + fund(env, gw_, {alice_, bob_}, XRP(200'000)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .transferFee = 500, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(1'000'000'000'000))); - env(pay(gw, alice, BTC(200'000'000'000'000))); + env(pay(gw_, bob_, btc(1'000'000'000'000))); + env(pay(gw_, alice_, btc(200'000'000'000'000))); - AMM const ammAlice(env, alice, BTC(150'000'000'000'000), XRP(150'100)); - env(offer(bob, XRP(100), BTC(100'000'000'000))); + AMM const ammAlice(env, alice_, btc(150'000'000'000'000), XRP(150'100)); + env(offer(bob_, XRP(100), btc(100'000'000'000))); BEAST_EXPECT( - ammAlice.expectBalances(BTC(150'100'000'000'000), XRP(150'000), ammAlice.tokens())); + ammAlice.expectBalances(btc(150'100'000'000'000), XRP(150'000), ammAlice.tokens())); // Bob pays 0.005 transfer fee. - env.require(balance(bob, BTC(899'500'000'000))); + env.require(Balance(bob_, btc(899'500'000'000))); } void @@ -530,25 +531,26 @@ private: using namespace jtx; Env env{*this, features}; - env.fund(XRP(30'000), gw, bob, carol); - env.fund(XRP(39'900), alice); + env.fund(XRP(30'000), gw_, bob_, carol_); + env.fund(XRP(39'900), alice_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000, - .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(10'100))); + .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(10'100))); - AMM const ammAlice(env, alice, XRP(9'900), BTC(10'100)); + AMM const ammAlice(env, alice_, XRP(9'900), btc(10'100)); - env(offer(carol, BTC(100), XRP(100)), json(jss::Flags, tfSell)); + env(offer(carol_, btc(100), XRP(100)), Json(jss::Flags, tfSell)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(9'999), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); - env.require(balance(carol, BTC(30'101))); - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRP(30'000) - XRP(100) - 2 * txfee(env, 1))); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(9'999), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + env.require(Balance(carol_, btc(30'101))); + BEAST_EXPECT( + expectLedgerEntryRoot(env, carol_, XRP(30'000) - XRP(100) - 2 * txFee(env, 1))); } void @@ -560,27 +562,27 @@ private: Env env{*this, features}; - auto const starting_xrp = XRP(100) + reserve(env, 1) + env.current()->fees().base * 2; + auto const startingXrp = XRP(100) + reserve(env, 1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice); - env.fund(XRP(2'000), bob); + env.fund(startingXrp, gw_, alice_); + env.fund(XRP(2'000), bob_); env.close(); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); - env(pay(gw, bob, BTC(2'200'000'000))); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, bob_, btc(2'200'000'000))); - AMM const ammBob(env, bob, XRP(1'000), BTC(2'200'000'000)); + AMM const ammBob(env, bob_, XRP(1'000), btc(2'200'000'000)); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. // Taker pays 100'000'000 BTC for 100 XRP. // Selling XRP. // Will sell all 100 XRP and get more BTC than asked for. - env(offer(alice, BTC(100'000'000), XRP(200)), json(jss::Flags, tfSell)); - BEAST_EXPECT(ammBob.expectBalances(XRP(1'100), BTC(2'000'000'000), ammBob.tokens())); - env.require(balance(alice, BTC(200'000'000))); - BEAST_EXPECT(expectLedgerEntryRoot(env, alice, XRP(250))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + env(offer(alice_, btc(100'000'000), XRP(200)), Json(jss::Flags, tfSell)); + BEAST_EXPECT(ammBob.expectBalances(XRP(1'100), btc(2'000'000'000), ammBob.tokens())); + env.require(Balance(alice_, btc(200'000'000))); + BEAST_EXPECT(expectLedgerEntryRoot(env, alice_, XRP(250))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } void @@ -592,43 +594,43 @@ private: Env env{*this, features}; - auto const starting_xrp = XRP(100.1) + reserve(env, 1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + auto const startingXrp = XRP(100.1) + reserve(env, 1) + env.current()->fees().base * 2; + env.fund(startingXrp, gw_, alice_, bob_); - MPTTester const XTS( + MPTTester const xts( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const XXX( + .flags = kMPT_DEX_FLAGS}); + MPTTester const xxx( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XTS(1'000'000'000'000'000), XXX(1'000'000'000'000'000)); + AMM const ammAlice(env, alice_, xts(1'000'000'000'000'000), xxx(1'000'000'000'000'000)); - Json::Value payment; + json::Value payment; payment[jss::secret] = toBase58(generateSeed("bob")); - payment[jss::id] = env.seq(bob); + payment[jss::id] = env.seq(bob_); payment[jss::build_path] = true; - payment[jss::tx_json] = pay(bob, bob, XXX(10'000'000'000'000)); + payment[jss::tx_json] = pay(bob_, bob_, xxx(10'000'000'000'000)); payment[jss::tx_json][jss::Sequence] = - env.current()->read(keylet::account(bob.id()))->getFieldU32(sfSequence); + env.current()->read(keylet::account(bob_.id()))->getFieldU32(sfSequence); payment[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); payment[jss::tx_json][jss::SendMax] = - XTS(15'000'000'000'000).value().getJson(JsonOptions::none); + xts(15'000'000'000'000).value().getJson(JsonOptions::KNone); payment[jss::tx_json][jss::Flags] = tfPartialPayment; auto const jrr = env.rpc("json", "submit", to_string(payment)); BEAST_EXPECT(jrr[jss::result][jss::status] == "success"); BEAST_EXPECT(jrr[jss::result][jss::engine_result] == "tesSUCCESS"); BEAST_EXPECT(ammAlice.expectBalances( - XTS(1'010'101'010'101'011), XXX(990'000'000'000'000), ammAlice.tokens())); - env.require(balance(bob, XTS(989'898'989'898'989))); - env.require(balance(bob, XXX(1'010'000'000'000'000))); + xts(1'010'101'010'101'011), xxx(990'000'000'000'000), ammAlice.tokens())); + env.require(Balance(bob_, xts(989'898'989'898'989))); + env.require(Balance(bob_, xxx(1'010'000'000'000'000))); } void @@ -640,20 +642,20 @@ private: { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // The scenario: // o BTC/XRP AMM is created. @@ -661,38 +663,38 @@ private: // o carol has ETH but wants BTC. // Note that carol's offer must come last. If carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000'000)); - AMM const ammBob(env, bob, ETH(10'000'000'000), XRP(10'100)); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000'000)); + AMM const ammBob(env, bob_, eth(10'000'000'000), XRP(10'100)); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, BTC(100'000'000), ETH(100'000'000))); + env(offer(carol_, btc(100'000'000), eth(100'000'000))); env.close(); BEAST_EXPECT( - ammAlice.expectBalances(XRP(10'100), BTC(10'000'000'000), ammAlice.tokens())); - BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), ETH(10'100'000'000), ammBob.tokens())); - env.require(balance(carol, BTC(15'100'000'000))); - env.require(balance(carol, ETH(14'900'000'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + ammAlice.expectBalances(XRP(10'100), btc(10'000'000'000), ammAlice.tokens())); + BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), eth(10'100'000'000), ammBob.tokens())); + env.require(Balance(carol_, btc(15'100'000'000))); + env.require(Balance(carol_, eth(14'900'000'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // The scenario: // o BTC/XRP AMM is created. @@ -701,39 +703,39 @@ private: // Note that carol's offer must come last. If carol's offer is // placed before AMM and bob's offer are created, then autobridging // will not occur. - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000'000)); - env(offer(bob, ETH(100'000'000), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000'000)); + env(offer(bob_, eth(100'000'000), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, BTC(100'000'000), ETH(100'000'000))); + env(offer(carol_, btc(100'000'000), eth(100'000'000))); env.close(); BEAST_EXPECT( - ammAlice.expectBalances(XRP(10'100), BTC(10'000'000'000), ammAlice.tokens())); - env.require(balance(carol, BTC(15'100'000'000))); - env.require(balance(carol, ETH(14'900'000'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + ammAlice.expectBalances(XRP(10'100), btc(10'000'000'000), ammAlice.tokens())); + env.require(Balance(carol_, btc(15'100'000'000))); + env.require(Balance(carol_, eth(14'900'000'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 15'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // The scenario: // o BTC/XRP offer is created. @@ -742,20 +744,20 @@ private: // Note that carol's offer must come last. If carol's offer is // placed before AMM and alice's offer are created, then // autobridging will not occur. - env(offer(alice, XRP(100), BTC(100'000'000))); + env(offer(alice_, XRP(100), btc(100'000'000))); env.close(); - AMM const ammBob(env, bob, ETH(10'000'000'000), XRP(10'100)); + AMM const ammBob(env, bob_, eth(10'000'000'000), XRP(10'100)); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, BTC(100'000'000), ETH(100'000'000))); + env(offer(carol_, btc(100'000'000), eth(100'000'000))); env.close(); - BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), ETH(10'100'000'000), ammBob.tokens())); - env.require(balance(carol, BTC(15'100'000'000))); - env.require(balance(carol, ETH(14'900'000'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), eth(10'100'000'000), ammBob.tokens())); + env.require(Balance(carol_, btc(15'100'000'000))); + env.require(Balance(carol_, eth(14'900'000'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } } @@ -770,62 +772,62 @@ private: { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 20'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammBob(env, bob, XRP(20'000), BTC(200'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammBob(env, bob_, XRP(20'000), btc(200'000'000)); // alice submits a tfSell | tfFillOrKill offer that does not cross. - env(offer(alice, BTC(2'100'000), XRP(210), tfSell | tfFillOrKill), ter(tecKILLED)); + env(offer(alice_, btc(2'100'000), XRP(210), tfSell | tfFillOrKill), Ter(tecKILLED)); - BEAST_EXPECT(ammBob.expectBalances(XRP(20'000), BTC(200'000'000), ammBob.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(ammBob.expectBalances(XRP(20'000), btc(200'000'000), ammBob.tokens())); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammBob(env, bob, XRP(20'000), BTC(200'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammBob(env, bob_, XRP(20'000), btc(200'000'000'000'000)); // alice submits a tfSell | tfFillOrKill offer that crosses. // Even though tfSell is present it doesn't matter this time. - env(offer(alice, BTC(2'000'000'000'000), XRP(220), tfSell | tfFillOrKill)); + env(offer(alice_, btc(2'000'000'000'000), XRP(220), tfSell | tfFillOrKill)); env.close(); BEAST_EXPECT( - ammBob.expectBalances(XRP(20'220), BTC(197'823'936'696'341), ammBob.tokens())); - env.require(balance(alice, BTC(1'002'176'063'303'659))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + ammBob.expectBalances(XRP(20'220), btc(197'823'936'696'341), ammBob.tokens())); + env.require(Balance(alice_, btc(1'002'176'063'303'659))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { // alice submits a tfSell | tfFillOrKill offer that crosses and // returns more than was asked for (because of the tfSell flag). Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammBob(env, bob, XRP(20'000), BTC(200'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammBob(env, bob_, XRP(20'000), btc(200'000'000'000'000)); - env(offer(alice, BTC(10'000'000'000'000), XRP(1'500), tfSell | tfFillOrKill)); + env(offer(alice_, btc(10'000'000'000'000), XRP(1'500), tfSell | tfFillOrKill)); env.close(); BEAST_EXPECT( - ammBob.expectBalances(XRP(21'500), BTC(186'046'511'627'907), ammBob.tokens())); - env.require(balance(alice, BTC(1'013'953'488'372'093))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + ammBob.expectBalances(XRP(21'500), btc(186'046'511'627'907), ammBob.tokens())); + env.require(Balance(alice_, btc(1'013'953'488'372'093))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { // alice submits a tfSell | tfFillOrKill offer that doesn't cross. @@ -834,20 +836,20 @@ private: // all of the offer is consumed because AMM generated offer, // which matches alice's offer quality is ~ 10XRP/0.01996e3BTC. Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 10'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammBob(env, bob, XRP(5000), BTC(10'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammBob(env, bob_, XRP(5000), btc(10'000'000)); - env(offer(alice, BTC(1'000'000), XRP(501), tfSell | tfFillOrKill), ter(tecKILLED)); + env(offer(alice_, btc(1'000'000), XRP(501), tfSell | tfFillOrKill), Ter(tecKILLED)); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } } @@ -861,75 +863,75 @@ private: // AMM XRP/BTC. Alice places BTC/XRP offer. { Env env(*this, features); - env.fund(XRP(30'000), gw, bob, carol); - env.fund(XRP(40'000), alice); + env.fund(XRP(30'000), gw_, bob_, carol_); + env.fund(XRP(40'000), alice_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 30'000'000, - .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(10'100'000))); + .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(10'100'000))); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000)); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000)); env.close(); - env(offer(carol, BTC(100'000), XRP(100))); + env(offer(carol_, btc(100'000), XRP(100))); env.close(); // AMM doesn't pay the transfer fee - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), BTC(10'000'000), ammAlice.tokens())); - env.require(balance(carol, BTC(30'100'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), btc(10'000'000), ammAlice.tokens())); + env.require(Balance(carol_, btc(30'100'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } { Env env(*this, features); - env.fund(XRP(30'000), gw, bob, carol); - env.fund(XRP(40'100), alice); + env.fund(XRP(30'000), gw_, bob_, carol_); + env.fund(XRP(40'100), alice_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 30'000'000, - .flags = MPTDEXFlags}); - env(pay(gw, alice, BTC(10'000'000))); + .flags = kMPT_DEX_FLAGS}); + env(pay(gw_, alice_, btc(10'000'000))); - AMM const ammAlice(env, alice, XRP(10'100), BTC(10'000'000)); + AMM const ammAlice(env, alice_, XRP(10'100), btc(10'000'000)); env.close(); - env(offer(carol, XRP(100), BTC(100'000))); + env(offer(carol_, XRP(100), btc(100'000))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'100'000), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'100'000), ammAlice.tokens())); // Carol pays 25% transfer fee - env.require(balance(carol, BTC(29'875'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + env.require(Balance(carol_, btc(29'875'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } { // Bridged crossing. Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 15'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 15'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // The scenario: // o BTC/XRP AMM is created. @@ -937,44 +939,44 @@ private: // o carol has ETH but wants BTC. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000)); - env(offer(bob, ETH(100'000), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000)); + env(offer(bob_, eth(100'000), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Bob's offer. - env(offer(carol, BTC(100'000), ETH(100'000))); + env(offer(carol_, btc(100'000), eth(100'000))); env.close(); // AMM doesn't pay the transfer fee - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), BTC(10'000'000), ammAlice.tokens())); - env.require(balance(carol, BTC(15'100'000))); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), btc(10'000'000), ammAlice.tokens())); + env.require(Balance(carol_, btc(15'100'000))); // Carol pays 25% transfer fee. - env.require(balance(carol, ETH(14'875'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + env.require(Balance(carol_, eth(14'875'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { // Bridged crossing. The transfer fee is paid on the step not // involving AMM as src/dst. Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 15'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 15'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // The scenario: // o BTC/XRP AMM is created. @@ -982,25 +984,25 @@ private: // o carol has ETH but wants BTC. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'050'000)); - env(offer(bob, ETH(100'000), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'050'000)); + env(offer(bob_, eth(100'000), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // partially consumes Bob's offer. - env(offer(carol, BTC(50'000), ETH(50'000))); + env(offer(carol_, btc(50'000), eth(50'000))); env.close(); // This test verifies that the amount removed from an offer // accounts for the transfer fee that is removed from the // account but not from the remaining offer. // AMM doesn't pay the transfer fee - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'050), BTC(10'000'000), ammAlice.tokens())); - env.require(balance(carol, BTC(15'050'000))); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'050), btc(10'000'000), ammAlice.tokens())); + env.require(Balance(carol_, btc(15'050'000))); // Carol pays 25% transfer fee. - env.require(balance(carol, ETH(14'937'500))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 1, {{Amounts{ETH(50'000), XRP(50)}}})); + env.require(Balance(carol_, eth(14'937'500))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{Amounts{eth(50'000), XRP(50)}}})); } } @@ -1016,19 +1018,20 @@ private: auto const f = env.current()->fees().base; - env.fund(XRP(30'000) + f, alice, bob); + env.fund(XRP(30'000) + f, alice_, bob_); env.close(); - MPTTester const BTC({.env = env, .issuer = bob, .holders = {alice}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = bob_, .holders = {alice_}, .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, XRP(10'000), BTC(10'100)); + AMM const ammBob(env, bob_, XRP(10'000), btc(10'100)); - env(offer(alice, BTC(100), XRP(100))); + env(offer(alice_, btc(100), XRP(100))); env.close(); - BEAST_EXPECT(ammBob.expectBalances(XRP(10'100), BTC(10'000), ammBob.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 0)); - env.require(balance(alice, BTC(100))); + BEAST_EXPECT(ammBob.expectBalances(XRP(10'100), btc(10'000), ammBob.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 0)); + env.require(Balance(alice_, btc(100))); } void @@ -1054,36 +1057,36 @@ private: env.fund(reserve(env, 4) + (fee * 5), ann, bob, cam); env.close(); - MPTTester const A_BUX( - {.env = env, .issuer = ann, .holders = {bob, cam, carol}, .flags = MPTDEXFlags}); + MPTTester const aBux( + {.env = env, .issuer = ann, .holders = {bob, cam, carol}, .flags = kMPT_DEX_FLAGS}); - MPTTester const B_BUX( - {.env = env, .issuer = bob, .holders = {ann, cam, carol}, .flags = MPTDEXFlags}); + MPTTester const bBux( + {.env = env, .issuer = bob, .holders = {ann, cam, carol}, .flags = kMPT_DEX_FLAGS}); - env(pay(ann, cam, A_BUX(350'000'000'000'000))); - env(pay(bob, cam, B_BUX(350'000'000'000'000))); - env(pay(bob, carol, B_BUX(4'000'000'000'000'000))); - env(pay(ann, carol, A_BUX(4'000'000'000'000'000))); + env(pay(ann, cam, aBux(350'000'000'000'000))); + env(pay(bob, cam, bBux(350'000'000'000'000))); + env(pay(bob, carol, bBux(4'000'000'000'000'000))); + env(pay(ann, carol, aBux(4'000'000'000'000'000))); - AMM const ammCarol(env, carol, A_BUX(3'000'000'000'000'000), B_BUX(3'300'000'000'000'000)); + AMM const ammCarol(env, carol, aBux(3'000'000'000'000'000), bBux(3'300'000'000'000'000)); // cam puts an offer on the books that her upcoming offer could cross. // But this offer should be deleted, not crossed, by her upcoming // offer. - env(offer(cam, A_BUX(290'000'000'000'000), B_BUX(300'000'000'000'000), tfPassive)); + env(offer(cam, aBux(290'000'000'000'000), bBux(300'000'000'000'000), tfPassive)); env.close(); - env.require(balance(cam, A_BUX(350'000'000'000'000))); - env.require(balance(cam, B_BUX(350'000'000'000'000))); + env.require(Balance(cam, aBux(350'000'000'000'000))); + env.require(Balance(cam, bBux(350'000'000'000'000))); env.require(offers(cam, 1)); // This offer caused the assert. - env(offer(cam, B_BUX(300'000'000'000'000), A_BUX(300'000'000'000'000))); + env(offer(cam, bBux(300'000'000'000'000), aBux(300'000'000'000'000))); // AMM is consumed up to the first cam Offer quality BEAST_EXPECT(ammCarol.expectBalances( - A_BUX(3'093'541'659'651'604), B_BUX(3'200'215'509'984'418), ammCarol.tokens())); + aBux(3'093'541'659'651'604), bBux(3'200'215'509'984'418), ammCarol.tokens())); BEAST_EXPECT(expectOffers( - env, cam, 1, {{Amounts{B_BUX(200'215'509'984'418), A_BUX(200'215'509'984'419)}}})); + env, cam, 1, {{Amounts{bBux(200'215'509'984'418), aBux(200'215'509'984'419)}}})); } void @@ -1094,36 +1097,36 @@ private: using namespace jtx; Env env{*this, features}; - env.fund(XRP(400'000), gw, alice, bob); + env.fund(XRP(400'000), gw_, alice_, bob_); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, - .flags = tfMPTRequireAuth | MPTDEXFlags}); + .issuer = gw_, + .holders = {alice_, bob_}, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS}); // Authorize bob and alice - BTC.authorize({.holder = alice}); - BTC.authorize({.holder = bob}); + btc.authorize({.holder = alice_}); + btc.authorize({.holder = bob_}); - env(pay(gw, alice, BTC(1'000))); + env(pay(gw_, alice_, btc(1'000))); env.close(); // Alice is able to create AMM since the GW has authorized her - AMM const ammAlice(env, alice, BTC(1'000), XRP(1'050)); + AMM const ammAlice(env, alice_, btc(1'000), XRP(1'050)); - env(pay(gw, bob, BTC(50))); + env(pay(gw_, bob_, btc(50))); env.close(); - env.require(balance(bob, BTC(50))); + env.require(Balance(bob_, btc(50))); // Bob's offer should cross Alice's AMM - env(offer(bob, XRP(50), BTC(50))); + env(offer(bob_, XRP(50), btc(50))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'050), XRP(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); - env.require(balance(bob, BTC(0))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'050), XRP(1'000), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, bob_, 0)); + env.require(Balance(bob_, btc(0))); } void @@ -1135,55 +1138,55 @@ private: Env env{*this, features}; - env.fund(XRP(400'000), gw, alice, bob); + env.fund(XRP(400'000), gw_, alice_, bob_); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, - .flags = tfMPTRequireAuth | MPTDEXFlags}); + .issuer = gw_, + .holders = {alice_, bob_}, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS}); // Alice doesn't have the funds { - AMM const ammAlice(env, alice, BTC(1'000), XRP(1'000), ter(tecNO_AUTH)); + AMM const ammAlice(env, alice_, btc(1'000), XRP(1'000), Ter(tecNO_AUTH)); } - BTC.authorize({.holder = bob}); - env(pay(gw, bob, BTC(50))); + btc.authorize({.holder = bob_}); + env(pay(gw_, bob_, btc(50))); env.close(); - env.require(balance(bob, BTC(50))); + env.require(Balance(bob_, btc(50))); // Alice should not be able to create AMM without authorization. { - AMM const ammAlice(env, alice, BTC(1'000), XRP(1'000), ter(tecNO_AUTH)); + AMM const ammAlice(env, alice_, btc(1'000), XRP(1'000), Ter(tecNO_AUTH)); } // Finally, authorize alice. Now alice's AMM create should succeed. - BTC.authorize({.holder = alice}); - env(pay(gw, alice, BTC(1'000))); + btc.authorize({.holder = alice_}); + env(pay(gw_, alice_, btc(1'000))); env.close(); - AMM const ammAlice(env, alice, BTC(1'000), XRP(1'050)); + AMM const ammAlice(env, alice_, btc(1'000), XRP(1'050)); // Authorize AMM. // BTC.authorize({.account = ammAlice.ammAccount()}); // env.close(); // Now bob creates his offer again, which crosses with alice's AMM. - env(offer(bob, XRP(50), BTC(50))); + env(offer(bob_, XRP(50), btc(50))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'050), XRP(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); - env.require(balance(bob, BTC(0))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'050), XRP(1'000), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, bob_, 0)); + env.require(Balance(bob_, btc(0))); } void testOffers() { using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testRmFundedOffer(all); testFillModes(all); testOfferCrossWithXRP(all); @@ -1208,81 +1211,81 @@ private: } void - path_find_consume_all() + pathFindConsumeAll() { testcase("path find consume all"); using namespace jtx; Env env = pathTestEnv(); - env.fund(XRP(100'000'260), alice); - env.fund(XRP(30'000), gw, bob, carol); + env.fund(XRP(100'000'260), alice_); + env.fund(XRP(30'000), gw_, bob_, carol_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 100'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammCarol(env, carol, XRP(100), ETH(100'000'000'000'000)); + AMM const ammCarol(env, carol_, XRP(100), eth(100'000'000'000'000)); STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = - find_paths(env, alice, bob, bob["AUD"](-1), std::optional(XRP(100'000'000))); + std::tie(st, sa, da) = findPaths( + env, alice_, bob_, bob_["AUD"](-1), std::optional(XRP(100'000'000))); BEAST_EXPECT(st.empty()); std::tie(st, sa, da) = - find_paths(env, alice, bob, ETH(-1), std::optional(XRP(100'000'000))); + findPaths(env, alice_, bob_, eth(-1), std::optional(XRP(100'000'000))); // Alice sends all requested 100,000,000XRP BEAST_EXPECT(sa == XRP(100'000'000)); // Bob gets ~99.99e12ETH. This is the amount Bob // can get out of AMM for 100,000,000XRP. - BEAST_EXPECT(equal(da, ETH(99'999'900'000'100))); + BEAST_EXPECT(equal(da, eth(99'999'900'000'100))); } // carol holds ETH, sells ETH for XRP // bob will hold ETH // alice pays bob ETH using XRP void - via_offers_via_gateway() + viaOffersViaGateway() { testcase("via gateway"); using namespace jtx; Env env = pathTestEnv(); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 10'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 10'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, carol, ETH(51))); + env(pay(gw_, carol_, eth(51))); env.close(); - AMM const ammCarol(env, carol, XRP(40), ETH(51)); - env(pay(alice, bob, ETH(10)), sendmax(XRP(100)), paths(XRP)); + AMM const ammCarol(env, carol_, XRP(40), eth(51)); + env(pay(alice_, bob_, eth(10)), Sendmax(XRP(100)), Paths(XRP)); env.close(); // AMM offer is 51.282052XRP/11ETH, 11ETH/1.1 = 10ETH to bob - BEAST_EXPECT(ammCarol.expectBalances(XRP(51), ETH(40), ammCarol.tokens())); - env.require(balance(bob, ETH(10))); + BEAST_EXPECT(ammCarol.expectBalances(XRP(51), eth(40), ammCarol.tokens())); + env.require(Balance(bob_, eth(10))); - auto const result = find_paths(env, alice, bob, BTC(25)); + auto const result = findPaths(env, alice_, bob_, btc(25)); BEAST_EXPECT(std::get<0>(result).empty()); } void - receive_max() + receiveMax() { testcase("Receive max"); using namespace jtx; @@ -1290,44 +1293,44 @@ private: { // XRP -> MPT receive max Env env = pathTestEnv(); - env.fund(XRP(30'000), alice, bob, charlie, gw); + env.fund(XRP(30'000), alice_, bob_, charlie, gw_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, charlie}, + .issuer = gw_, + .holders = {alice_, bob_, charlie}, .pay = 11'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammCharlie(env, charlie, XRP(10), ETH(11'000'000'000'000)); - auto [st, sa, da] = find_paths(env, alice, bob, ETH(-1), XRP(1).value()); + AMM const ammCharlie(env, charlie, XRP(10), eth(11'000'000'000'000)); + auto [st, sa, da] = findPaths(env, alice_, bob_, eth(-1), XRP(1).value()); BEAST_EXPECT(sa == XRP(1)); - BEAST_EXPECT(equal(da, ETH(1'000'000'000'000))); + BEAST_EXPECT(equal(da, eth(1'000'000'000'000))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { auto const& pathElem = st[0][0]; BEAST_EXPECT( - pathElem.isOffer() && pathElem.getIssuerID() == gw.id() && - pathElem.getMPTID() == ETH.issuanceID()); + pathElem.isOffer() && pathElem.getIssuerID() == gw_.id() && + pathElem.getMPTID() == eth.issuanceID()); } } { // MPT -> XRP receive max Env env = pathTestEnv(); - env.fund(XRP(30'000), alice, bob, charlie, gw); + env.fund(XRP(30'000), alice_, bob_, charlie, gw_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, charlie}, + .issuer = gw_, + .holders = {alice_, bob_, charlie}, .pay = 11'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammCharlie(env, charlie, XRP(11), ETH(10'000'000'000'000)); + AMM const ammCharlie(env, charlie, XRP(11), eth(10'000'000'000'000)); env.close(); auto [st, sa, da] = - find_paths(env, alice, bob, drops(-1), ETH(1'000'000'000'000).value()); - BEAST_EXPECT(sa == ETH(1'000'000'000'000)); + findPaths(env, alice_, bob_, drops(-1), eth(1'000'000'000'000).value()); + BEAST_EXPECT(sa == eth(1'000'000'000'000)); BEAST_EXPECT(equal(da, XRP(1))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { @@ -1340,172 +1343,165 @@ private: } void - path_find_01() + pathFind01() { testcase("Path Find: XRP -> XRP and XRP -> MPT"); using namespace jtx; Env env = pathTestEnv(); - Account A1{"A1"}; - Account A2{"A2"}; - Account A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account G3{"G3"}; - Account M1{"M1"}; + Account a1{"A1"}; + Account a2{"A2"}; + Account a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account g3{"G3"}; + Account m1{"M1"}; - env.fund(XRP(100'000), A1); - env.fund(XRP(10'000), A2); - env.fund(XRP(1'000), A3, G1, G2, G3); - env.fund(XRP(20'000), M1); + env.fund(XRP(100'000), a1); + env.fund(XRP(10'000), a2); + env.fund(XRP(1'000), a3, g1, g2, g3); + env.fund(XRP(20'000), m1); env.close(); - MPTTester const XYZ_G1( - {.env = env, .issuer = G1, .holders = {A1, M1, A2}, .flags = MPTDEXFlags}); + MPTTester const xyzG1( + {.env = env, .issuer = g1, .holders = {a1, m1, a2}, .flags = kMPT_DEX_FLAGS}); - MPTTester const XYZ_G2( - {.env = env, .issuer = G2, .holders = {A2, M1, A1}, .flags = MPTDEXFlags}); + MPTTester const xyzG2( + {.env = env, .issuer = g2, .holders = {a2, m1, a1}, .flags = kMPT_DEX_FLAGS}); - MPTTester const ABC_G3( - {.env = env, .issuer = G3, .holders = {A1, A2, M1, A3}, .flags = MPTDEXFlags}); + MPTTester const abcG3( + {.env = env, .issuer = g3, .holders = {a1, a2, m1, a3}, .flags = kMPT_DEX_FLAGS}); - MPTTester const ABC_A2( - {.env = env, .issuer = A2, .holders = {G3, A1}, .flags = MPTDEXFlags}); + MPTTester const abcA2( + {.env = env, .issuer = a2, .holders = {g3, a1}, .flags = kMPT_DEX_FLAGS}); - env(pay(G1, A1, XYZ_G1(3'500'000'000))); - env(pay(G3, A1, ABC_G3(1'200'000'000))); - env(pay(G1, M1, XYZ_G1(25'000'000'000))); - env(pay(G2, M1, XYZ_G2(25'000'000'000))); - env(pay(G3, M1, ABC_G3(25'000'000'000))); - env(pay(A2, G3, ABC_A2(101'000'000))); + env(pay(g1, a1, xyzG1(3'500'000'000))); + env(pay(g3, a1, abcG3(1'200'000'000))); + env(pay(g1, m1, xyzG1(25'000'000'000))); + env(pay(g2, m1, xyzG2(25'000'000'000))); + env(pay(g3, m1, abcG3(25'000'000'000))); + env(pay(a2, g3, abcA2(101'000'000))); env.close(); - AMM const ammM1_XYZ_G1_XYZ_G2(env, M1, XYZ_G1(1'000'000'000), XYZ_G2(1'000'000'000)); - AMM const ammM1_XRP_ABC_G3(env, M1, XRP(10'000), ABC_G3(1'000'000'000)); - AMM const ammG3_ABC_G3_ABC_A2(env, G3, ABC_G3(100'000'000), ABC_A2(101'000'000)); + AMM const ammM1XyzG1XyzG2(env, m1, xyzG1(1'000'000'000), xyzG2(1'000'000'000)); + AMM const ammM1XrpAbcG3(env, m1, XRP(10'000), abcG3(1'000'000'000)); + AMM const ammG3AbcG3AbcA2(env, g3, abcG3(100'000'000), abcA2(101'000'000)); env.close(); STPathSet st; STAmount sa, da; { - auto const& send_amt = XRP(10); - std::tie(st, sa, da) = find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = XRP(10); + std::tie(st, sa, da) = findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { // no path should exist for this since dest account // does not exist. - auto const& send_amt = XRP(200); + auto const& sendAmt = XRP(200); std::tie(st, sa, da) = - find_paths(env, A1, Account{"A0"}, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, Account{"A0"}, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { - auto const& send_amt = ABC_G3(10'000'000); - std::tie(st, sa, da) = find_paths(env, A2, G3, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = abcG3(10'000'000); + std::tie(st, sa, da) = findPaths(env, a2, g3, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRPAmount{101'010'102})); - BEAST_EXPECT(same(st, stpath(IPE(MPT(ABC_G3))))); + BEAST_EXPECT(same(st, stpath(ipe(MPT(abcG3))))); } { - auto const& send_amt = ABC_A2(1'000'000); - std::tie(st, sa, da) = find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = abcA2(1'000'000); + std::tie(st, sa, da) = findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRPAmount{10'010'011})); - BEAST_EXPECT(same(st, stpath(IPE(MPT(ABC_G3)), IPE(MPT(ABC_A2))))); + BEAST_EXPECT(same(st, stpath(ipe(MPT(abcG3)), ipe(MPT(abcA2))))); } } void - path_find_02() + pathFind02() { testcase("Path Find: non-XRP -> XRP"); using namespace jtx; Env env = pathTestEnv(); - Account A1{"A1"}; - Account A2{"A2"}; - Account const G3{"G3"}; - Account M1{"M1"}; + Account a1{"A1"}; + Account a2{"A2"}; + Account const g3{"G3"}; + Account m1{"M1"}; - env.fund(XRP(1'000), A1, A2, G3); - env.fund(XRP(11'000), M1); + env.fund(XRP(1'000), a1, a2, g3); + env.fund(XRP(11'000), m1); env.close(); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = G3, - .holders = {A1, A2, M1}, + .issuer = g3, + .holders = {a1, a2, m1}, .pay = 1'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammM1(env, M1, ETH(1'000'000'000), XRP(10'010)); + AMM const ammM1(env, m1, eth(1'000'000'000), XRP(10'010)); STPathSet st; STAmount sa, da; - auto const& send_amt = XRP(10); + auto const& sendAmt = XRP(10); std::tie(st, sa, da) = - find_paths_by_element(env, A1, A2, send_amt, std::nullopt, IPE(MPT(ETH))); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, ETH(1'000'000))); - BEAST_EXPECT(same(st, stpath(IPE(xrpIssue())))); + findPathsByElement(env, a1, a2, sendAmt, std::nullopt, ipe(MPT(eth))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, eth(1'000'000))); + BEAST_EXPECT(same(st, stpath(ipe(xrpIssue())))); } void - path_find_06() + pathFind06() { testcase("Path Find: non-XRP -> non-XRP, same issuanceID"); using namespace jtx; { Env env = pathTestEnv(); - Account A1{"A1"}; - Account A2{"A2"}; - Account const A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account M1{"M1"}; + Account a1{"A1"}; + Account a2{"A2"}; + Account const a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account m1{"M1"}; - env.fund(XRP(11'000), M1); - env.fund(XRP(1'000), A1, A2, A3, G1, G2); + env.fund(XRP(11'000), m1); + env.fund(XRP(1'000), a1, a2, a3, g1, g2); env.close(); - MPTTester const HKD_G1( + MPTTester const hkdG1( {.env = env, - .issuer = G1, - .holders = {A1, M1}, + .issuer = g1, + .holders = {a1, m1}, .pay = 5'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const HKD_G2( + MPTTester const hkdG2( {.env = env, - .issuer = G2, - .holders = {A2, M1}, + .issuer = g2, + .holders = {a2, m1}, .pay = 5'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammM1(env, M1, HKD_G1(1'000'000'000), HKD_G2(1'010'000'000)); + AMM const ammM1(env, m1, hkdG1(1'000'000'000), hkdG2(1'010'000'000)); - auto const& send_amt = HKD_G2(10'000'000); + auto const& sendAmt = hkdG2(10'000'000); STPathSet st; STAmount sa, da; - std::tie(st, sa, da) = jtx::find_paths( - env, - G1, - A2, - send_amt, - std::nullopt, - HKD_G1.issuanceID(), - std::nullopt, - std::nullopt); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, HKD_G1(10'000'000))); - BEAST_EXPECT(same(st, stpath(IPE(MPT(HKD_G2))))); + std::tie(st, sa, da) = jtx::findPaths( + env, g1, a2, sendAmt, std::nullopt, hkdG1.issuanceID(), std::nullopt, std::nullopt); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, hkdG1(10'000'000))); + BEAST_EXPECT(same(st, stpath(ipe(MPT(hkdG2))))); } } @@ -1517,22 +1513,28 @@ private: using namespace jtx; Env env(*this, features); - env.memoize(bob); + env.memoize(bob_); - env.fund(XRP(10'000), alice, gw); - fund(env, gw, {carol}, XRP(10'000), {}, Fund::Acct); - auto const AMMXRPPool = env.current()->fees().increment * 2; - env.fund(reserve(env, 5) + ammCrtFee(env) + AMMXRPPool, bob); + env.fund(XRP(10'000), alice_, gw_); + fund(env, gw_, {carol_}, XRP(10'000), {}, Fund::Acct); + auto const ammxrpPool = env.current()->fees().increment * 2; + env.fund(reserve(env, 5) + ammCrtFee(env) + ammxrpPool, bob_); env.close(); - MPTTester const ETH( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester const eth( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, alice, ETH(50'000))); - env(pay(gw, bob, BTC(150'000))); + env(pay(gw_, alice_, eth(50'000))); + env(pay(gw_, bob_, btc(150'000))); // Bob has _just_ slightly less than 50 xrp available // If his owner count changes, he will have more liquidity. @@ -1541,16 +1543,16 @@ private: // recursive calls to the ETH/XRP offer. The second call will return // tecPATH_DRY, but the entire path should not be marked as dry. // This is the second error case to test (when flowV1 is used). - env(offer(bob, ETH(50'000), XRP(50))); - AMM const ammBob(env, bob, AMMXRPPool, BTC(150'000)); + env(offer(bob_, eth(50'000), XRP(50))); + AMM const ammBob(env, bob_, ammxrpPool, btc(150'000)); - env(pay(alice, carol, BTC(1'000'000'000)), - path(~XRP, ~MPT(BTC)), - sendmax(ETH(500'000)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, btc(1'000'000'000)), + Path(~XRP, ~MPT(btc)), + Sendmax(eth(500'000)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - auto const carolBTC = env.balance(carol, MPT(BTC)); - BEAST_EXPECT(carolBTC > BTC(0) && carolBTC < BTC(50'000)); + auto const carolBTC = env.balance(carol_, MPT(btc)); + BEAST_EXPECT(carolBTC > btc(0) && carolBTC < btc(50'000)); } void @@ -1564,36 +1566,36 @@ private: { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 100'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 100'000'000}); - env(pay(gw, alice, BTC(500000))); - env(pay(gw, bob, BTC(500000))); - env(pay(gw, carol, BTC(500000))); - env(pay(gw, alice, ETH(500000))); - env(pay(gw, bob, ETH(500000))); - env(pay(gw, carol, ETH(500000))); + env(pay(gw_, alice_, btc(500000))); + env(pay(gw_, bob_, btc(500000))); + env(pay(gw_, carol_, btc(500000))); + env(pay(gw_, alice_, eth(500000))); + env(pay(gw_, bob_, eth(500000))); + env(pay(gw_, carol_, eth(500000))); env.close(); - AMM const ammBob(env, bob, BTC(100'000), ETH(150'000)); + AMM const ammBob(env, bob_, btc(100'000), eth(150'000)); - env(pay(alice, carol, ETH(50'000)), path(~ETH), sendmax(BTC(50'000))); + env(pay(alice_, carol_, eth(50'000)), Path(~eth), Sendmax(btc(50'000))); - env.require(balance(alice, BTC(450'000))); - env.require(balance(bob, BTC(400'000))); - env.require(balance(bob, ETH(350'000))); - env.require(balance(carol, ETH(550'000))); - BEAST_EXPECT(ammBob.expectBalances(BTC(150'000), ETH(100'000), ammBob.tokens())); + env.require(Balance(alice_, btc(450'000))); + env.require(Balance(bob_, btc(400'000))); + env.require(Balance(bob_, eth(350'000))); + env.require(Balance(carol_, eth(550'000))); + BEAST_EXPECT(ammBob.expectBalances(btc(150'000), eth(100'000), ammBob.tokens())); }; testHelper2TokensMix(test); } @@ -1601,136 +1603,136 @@ private: { // simple MPT/XRP XRP/MPT offer Env env(*this, features); - env.fund(XRP(10'000), gw, alice, bob, carol); + env.fund(XRP(10'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 150'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBobBTC_XRP(env, bob, BTC(100'000), XRP(150)); - AMM const ammBobXRP_ETH(env, bob, XRP(100), ETH(150'000)); + AMM const ammBobBtcXrp(env, bob_, btc(100'000), XRP(150)); + AMM const ammBobXrpEth(env, bob_, XRP(100), eth(150'000)); - env(pay(alice, carol, ETH(50'000)), path(~XRP, ~MPT(ETH)), sendmax(BTC(50'000))); + env(pay(alice_, carol_, eth(50'000)), Path(~XRP, ~MPT(eth)), Sendmax(btc(50'000))); - env.require(balance(alice, BTC(50'000))); - env.require(balance(bob, BTC(0))); - env.require(balance(bob, ETH(0))); - env.require(balance(carol, ETH(200'000))); + env.require(Balance(alice_, btc(50'000))); + env.require(Balance(bob_, btc(0))); + env.require(Balance(bob_, eth(0))); + env.require(Balance(carol_, eth(200'000))); BEAST_EXPECT( - ammBobBTC_XRP.expectBalances(BTC(150'000), XRP(100), ammBobBTC_XRP.tokens())); + ammBobBtcXrp.expectBalances(btc(150'000), XRP(100), ammBobBtcXrp.tokens())); BEAST_EXPECT( - ammBobXRP_ETH.expectBalances(XRP(150), ETH(100'000), ammBobXRP_ETH.tokens())); + ammBobXrpEth.expectBalances(XRP(150), eth(100'000), ammBobXrpEth.tokens())); } { // simple XRP -> MPT through offer and sendmax Env env(*this, features); XRPAmount const baseFee{env.current()->fees().base}; - env.fund(XRP(10'000), gw, alice, bob, carol); + env.fund(XRP(10'000), gw_, alice_, bob_, carol_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 150'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, XRP(100), ETH(150'000)); + AMM const ammBob(env, bob_, XRP(100), eth(150'000)); - env(pay(alice, carol, ETH(50'000)), path(~MPT(ETH)), sendmax(XRP(50))); - BEAST_EXPECT(expectLedgerEntryRoot(env, alice, XRP(10'000) - XRP(50) - 2 * baseFee)); - BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(10'000) - XRP(100) - ammCrtFee(env) - baseFee)); - env.require(balance(bob, ETH(0))); - env.require(balance(carol, ETH(200'000))); - BEAST_EXPECT(ammBob.expectBalances(XRP(150), ETH(100'000), ammBob.tokens())); + env(pay(alice_, carol_, eth(50'000)), Path(~MPT(eth)), Sendmax(XRP(50))); + BEAST_EXPECT(expectLedgerEntryRoot(env, alice_, XRP(10'000) - XRP(50) - 2 * baseFee)); + BEAST_EXPECT(expectLedgerEntryRoot( + env, bob_, XRP(10'000) - XRP(100) - ammCrtFee(env) - baseFee)); + env.require(Balance(bob_, eth(0))); + env.require(Balance(carol_, eth(200'000))); + BEAST_EXPECT(ammBob.expectBalances(XRP(150), eth(100'000), ammBob.tokens())); } { // simple MPT -> XRP through offer and sendmax Env env(*this, features); XRPAmount const baseFee{env.current()->fees().base}; - env.fund(XRP(10'000), gw, alice, bob, carol); + env.fund(XRP(10'000), gw_, alice_, bob_, carol_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, ETH(100'000), XRP(150)); + AMM const ammBob(env, bob_, eth(100'000), XRP(150)); - env(pay(alice, carol, XRP(50)), path(~XRP), sendmax(ETH(50'000))); + env(pay(alice_, carol_, XRP(50)), Path(~XRP), Sendmax(eth(50'000))); - env.require(balance(alice, ETH(50'000))); - BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(10'000) - XRP(150) - ammCrtFee(env) - baseFee)); - env.require(balance(bob, ETH(0))); - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRP(10'000 + 50) - baseFee)); - BEAST_EXPECT(ammBob.expectBalances(ETH(150'000), XRP(100), ammBob.tokens())); + env.require(Balance(alice_, eth(50'000))); + BEAST_EXPECT(expectLedgerEntryRoot( + env, bob_, XRP(10'000) - XRP(150) - ammCrtFee(env) - baseFee)); + env.require(Balance(bob_, eth(0))); + BEAST_EXPECT(expectLedgerEntryRoot(env, carol_, XRP(10'000 + 50) - baseFee)); + BEAST_EXPECT(ammBob.expectBalances(eth(150'000), XRP(100), ammBob.tokens())); } // test unfunded offers are removed when payment succeeds { auto test = [&](auto&& issue1, auto&& issue2, auto&& issue3) { Env env(*this, features); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - auto const BTC = issue1( + auto const btc = issue1( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1000'000000}); - auto const ETH = issue2( + auto const eth = issue2( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1000'000000}); - auto const GBP = issue3( + auto const gbp = issue3( {.env = env, .token = "GBP", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1000'000000}); - env(pay(gw, alice, BTC(60'000))); - env(pay(gw, bob, ETH(200'000))); - env(pay(gw, bob, GBP(150'000))); - env(offer(bob, BTC(50'000), ETH(50'000))); - env(offer(bob, BTC(40'000), GBP(50'000))); + env(pay(gw_, alice_, btc(60'000))); + env(pay(gw_, bob_, eth(200'000))); + env(pay(gw_, bob_, gbp(150'000))); + env(offer(bob_, btc(50'000), eth(50'000))); + env(offer(bob_, btc(40'000), gbp(50'000))); env.close(); - AMM const ammBob(env, bob, GBP(100'000), ETH(150'000)); + AMM const ammBob(env, bob_, gbp(100'000), eth(150'000)); // unfund offer - env(pay(bob, gw, GBP(50'000))); - BEAST_EXPECT(isOffer(env, bob, BTC(50'000), ETH(50'000))); - BEAST_EXPECT(isOffer(env, bob, BTC(40'000), GBP(50'000))); - env(pay(alice, carol, ETH(50'000)), - path(~ETH), - path(~GBP, ~ETH), - sendmax(BTC(60'000))); - env.require(balance(alice, BTC(10'000))); - env.require(balance(bob, BTC(50'000))); - env.require(balance(bob, ETH(0))); - env.require(balance(bob, GBP(0))); - env.require(balance(carol, ETH(50'000))); + env(pay(bob_, gw_, gbp(50'000))); + BEAST_EXPECT(isOffer(env, bob_, btc(50'000), eth(50'000))); + BEAST_EXPECT(isOffer(env, bob_, btc(40'000), gbp(50'000))); + env(pay(alice_, carol_, eth(50'000)), + Path(~eth), + Path(~gbp, ~eth), + Sendmax(btc(60'000))); + env.require(Balance(alice_, btc(10'000))); + env.require(Balance(bob_, btc(50'000))); + env.require(Balance(bob_, eth(0))); + env.require(Balance(bob_, gbp(0))); + env.require(Balance(carol_, eth(50'000))); // used in the payment - BEAST_EXPECT(!isOffer(env, bob, BTC(50'000), ETH(50'000))); + BEAST_EXPECT(!isOffer(env, bob_, btc(50'000), eth(50'000))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(40'000), GBP(50'000))); + BEAST_EXPECT(!isOffer(env, bob_, btc(40'000), gbp(50'000))); // unchanged - BEAST_EXPECT(ammBob.expectBalances(GBP(100'000), ETH(150'000), ammBob.tokens())); + BEAST_EXPECT(ammBob.expectBalances(gbp(100'000), eth(150'000), ammBob.tokens())); }; testHelper3TokensMix(test); } @@ -1747,74 +1749,83 @@ private: // that removes unfunded offers when the payment succeeds. Env env(*this, features); - env.fund(XRP(10'000), bob, carol, gw); + env.fund(XRP(10'000), bob_, carol_, gw_); env.close(); // Sets rippling on, this is different from // the original test - fund(env, gw, {alice}, XRP(10'000), {}, Fund::Acct); + fund(env, gw_, {alice_}, XRP(10'000), {}, Fund::Acct); - MPTTester BTC( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester btc( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - MPTTester ETH( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester eth( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - MPTTester GBP( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester gbp( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, alice, BTC(60'000'000))); - env(pay(gw, bob, BTC(100'000'000))); - env(pay(gw, bob, ETH(100'000'000))); - env(pay(gw, bob, GBP(50'000'000))); - env(pay(gw, carol, GBP(1'000'000))); + env(pay(gw_, alice_, btc(60'000'000))); + env(pay(gw_, bob_, btc(100'000'000))); + env(pay(gw_, bob_, eth(100'000'000))); + env(pay(gw_, bob_, gbp(50'000'000))); + env(pay(gw_, carol_, gbp(1'000'000))); env.close(); // This is multiplath, which generates limited # of offers - AMM const ammBobBTC_ETH(env, bob, BTC(50'000'000), ETH(50'000'000)); - env(offer(bob, BTC(60'000'000), GBP(50'000'000))); - env(offer(carol, BTC(1'000'000'000), GBP(1'000'000))); - env(offer(bob, GBP(50'000'000), ETH(50'000'000))); + AMM const ammBobBtcEth(env, bob_, btc(50'000'000), eth(50'000'000)); + env(offer(bob_, btc(60'000'000), gbp(50'000'000))); + env(offer(carol_, btc(1'000'000'000), gbp(1'000'000))); + env(offer(bob_, gbp(50'000'000), eth(50'000'000))); // unfund offer - env(pay(bob, gw, GBP(50'000'000))); - BEAST_EXPECT(ammBobBTC_ETH.expectBalances( - BTC(50'000'000), ETH(50'000'000), ammBobBTC_ETH.tokens())); - BEAST_EXPECT(isOffer(env, bob, BTC(60'000'000), GBP(50'000'000))); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000'000'000), GBP(1'000'000))); - BEAST_EXPECT(isOffer(env, bob, GBP(50'000'000), ETH(50'000'000))); + env(pay(bob_, gw_, gbp(50'000'000))); + BEAST_EXPECT(ammBobBtcEth.expectBalances( + btc(50'000'000), eth(50'000'000), ammBobBtcEth.tokens())); + BEAST_EXPECT(isOffer(env, bob_, btc(60'000'000), gbp(50'000'000))); + BEAST_EXPECT(isOffer(env, carol_, btc(1'000'000'000), gbp(1'000'000))); + BEAST_EXPECT(isOffer(env, bob_, gbp(50'000'000), eth(50'000'000))); auto flowJournal = env.app().getLogs().journal("Flow"); auto const flowResult = [&] { - STAmount const deliver(ETH(51'000'000)); - STAmount smax(BTC(61'000'000)); - PaymentSandbox sb(env.current().get(), tapNONE); + STAmount const deliver(eth(51'000'000)); + STAmount smax(btc(61'000'000)); + PaymentSandbox sb(env.current().get(), TapNone); STPathSet paths; - auto IPE = [](MPTTester const& iss) { + auto ipe = [](MPTTester const& iss) { return STPathElement( - STPathElement::typeMPT | STPathElement::typeIssuer, + STPathElement::TypeMpt | STPathElement::TypeIssuer, xrpAccount(), PathAsset{iss.issuanceID()}, iss.issuer()); }; { // BTC -> ETH - STPath const p1({IPE(ETH)}); - paths.push_back(p1); + STPath const p1({ipe(eth)}); + paths.pushBack(p1); // BTC -> GBP -> ETH - STPath const p2({IPE(GBP), IPE(ETH)}); - paths.push_back(p2); + STPath const p2({ipe(gbp), ipe(eth)}); + paths.pushBack(p2); } return flow( sb, deliver, - alice, - carol, + alice_, + carol_, paths, false, false, true, - OfferCrossing::no, + OfferCrossing::No, std::nullopt, smax, std::nullopt, @@ -1825,7 +1836,7 @@ private: env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { if (flowResult.removableOffers.empty()) return false; - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); for (auto const& o : flowResult.removableOffers) { if (auto ok = sb.peek(keylet::offer(o))) @@ -1838,11 +1849,11 @@ private: }); // used in payment, but since payment failed should be untouched - BEAST_EXPECT(ammBobBTC_ETH.expectBalances( - BTC(50'000'000), ETH(50'000'000), ammBobBTC_ETH.tokens())); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000'000'000), GBP(1'000'000))); + BEAST_EXPECT(ammBobBtcEth.expectBalances( + btc(50'000'000), eth(50'000'000), ammBobBtcEth.tokens())); + BEAST_EXPECT(isOffer(env, carol_, btc(1'000'000'000), gbp(1'000'000))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(60'000'000), GBP(50'000'000))); + BEAST_EXPECT(!isOffer(env, bob_, btc(60'000'000), gbp(50'000'000))); } { // Do not produce more in the forward pass than the reverse pass @@ -1855,36 +1866,36 @@ private: auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 10'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 10'000'000}); - env(pay(gw, alice, ETH(1'000'000))); - env(pay(gw, bob, BTC(1'000'000))); - env(pay(gw, bob, ETH(1'000'000))); + env(pay(gw_, alice_, eth(1'000'000))); + env(pay(gw_, bob_, btc(1'000'000))); + env(pay(gw_, bob_, eth(1'000'000))); env.close(); - AMM const ammBob(env, bob, ETH(8'000), XRPAmount{21}); - env(offer(bob, drops(1), BTC(1'000'000)), txflags(tfPassive)); + AMM const ammBob(env, bob_, eth(8'000), XRPAmount{21}); + env(offer(bob_, drops(1), btc(1'000'000)), Txflags(tfPassive)); - env(pay(alice, carol, BTC(1'000)), - path(~XRP, ~BTC), - sendmax(ETH(400)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, btc(1'000)), + Path(~XRP, ~btc), + Sendmax(eth(400)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - env.require(balance(carol, BTC(1'000))); - BEAST_EXPECT(ammBob.expectBalances(ETH(8400), XRPAmount{20}, ammBob.tokens())); + env.require(Balance(carol_, btc(1'000))); + BEAST_EXPECT(ammBob.expectBalances(eth(8400), XRPAmount{20}, ammBob.tokens())); }; testHelper2TokensMix(test); } @@ -1899,280 +1910,280 @@ private: { // payment via AMM Env env(*this, features); - env.fund(XRP(1'000), gw, alice, bob, carol); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm(env, bob, GBP(1'000'000'000'000'000), BTC(1'000'000'000'000'000)); + AMM const amm(env, bob_, gbp(1'000'000'000'000'000), btc(1'000'000'000'000'000)); - env(pay(alice, carol, BTC(100'000'000'000'000)), - path(~MPT(BTC)), - sendmax(GBP(150'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, btc(100'000'000'000'000)), + Path(~MPT(btc)), + Sendmax(gbp(150'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); // alice buys 107.1428e12BTC with 120e12GBP and pays 25% tr fee on // 120e12GBP 1,000e12 - 120e12*1.25 = 850e12GBP - env.require(balance(alice, GBP(850'000'000'000'000))); + env.require(Balance(alice_, gbp(850'000'000'000'000))); BEAST_EXPECT(amm.expectBalances( - GBP(1'120'000'000'000'000), BTC(892'857'142'857'143), amm.tokens())); + gbp(1'120'000'000'000'000), btc(892'857'142'857'143), amm.tokens())); // 25% of 85.7142e12BTC is paid in tr fee // 85.7142e12*1.25 = 107.1428e12BTC - env.require(balance(carol, BTC(1'085'714'285'714'285))); + env.require(Balance(carol_, btc(1'085'714'285'714'285))); } { // Payment via offer and AMM Env env(*this, features); Account const ed("ed"); - env.fund(XRP(1'000), gw, alice, bob, carol, ed); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_, ed); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(ed, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)), - txflags(tfPassive)); + env(offer(ed, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)), + Txflags(tfPassive)); env.close(); - AMM const amm(env, bob, ETH(1'000'000'000'000'000), BTC(1'000'000'000'000'000)); + AMM const amm(env, bob_, eth(1'000'000'000'000'000), btc(1'000'000'000'000'000)); - env(pay(alice, carol, BTC(100'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(150'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, btc(100'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(150'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); // alice buys 120e12ETH with 120e12GBP via the offer // and pays 25% tr fee on 120e12GBP // 1,000e12 - 120e12*1.25 = 850e12GBP - env.require(balance(alice, GBP(850'000'000'000'000))); + env.require(Balance(alice_, gbp(850'000'000'000'000))); // consumed offer is 120e12GBP/120e12ETH // ed doesn't pay tr fee - env.require(balance(ed, ETH(880'000'000'000'000))); - env.require(balance(ed, GBP(1'120'000'000'000'000))); + env.require(Balance(ed, eth(880'000'000'000'000))); + env.require(Balance(ed, gbp(1'120'000'000'000'000))); BEAST_EXPECT(expectOffers( - env, ed, 1, {Amounts{GBP(880'000'000'000'000), ETH(880'000'000'000'000)}})); + env, ed, 1, {Amounts{gbp(880'000'000'000'000), eth(880'000'000'000'000)}})); // 25% on 96e12ETH is paid in tr fee 96e12*1.25 = 120e12ETH // 96e12ETH is swapped in for 87.5912e12BTC BEAST_EXPECT(amm.expectBalances( - ETH(1'096'000'000'000'000), BTC(912'408'759'124'088), amm.tokens())); + eth(1'096'000'000'000'000), btc(912'408'759'124'088), amm.tokens())); // 25% on 70.0729e12BTC is paid in tr fee 70.0729e12*1.25 // = 87.5912e12BTC - env.require(balance(carol, BTC(1'070'072'992'700'729))); + env.require(Balance(carol_, btc(1'070'072'992'700'729))); } { // Payment via AMM, AMM Env env(*this, features); Account const ed("ed"); - env.fund(XRP(1'000), gw, alice, bob, carol, ed); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_, ed); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm1(env, bob, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)); - AMM const amm2(env, ed, ETH(1'000'000'000'000'000), BTC(1'000'000'000'000'000)); + AMM const amm1(env, bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)); + AMM const amm2(env, ed, eth(1'000'000'000'000'000), btc(1'000'000'000'000'000)); - env(pay(alice, carol, BTC(100'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(150'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, btc(100'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(150'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - env.require(balance(alice, GBP(850'000'000'000'000))); + env.require(Balance(alice_, gbp(850'000'000'000'000))); // alice buys 107.1428e12ETH with 120e12GBP and pays 25% tr fee on // 120e12GBP 1,000e12 - 120e12*1.25 = 850e12GBP 120e12GBP is swapped // in for 107.1428e12ETH BEAST_EXPECT(amm1.expectBalances( - GBP(1'120'000'000'000'000), ETH(892'857'142'857'143), amm1.tokens())); + gbp(1'120'000'000'000'000), eth(892'857'142'857'143), amm1.tokens())); // 25% on 85.7142e12ETH is paid in tr fee 85.7142e12*1.25 = // 107.1428e12ETH 85.7142e12ETH is swapped in for 78.9473e12BTC BEAST_EXPECT(amm2.expectBalances( - ETH(1'085'714'285'714'285), BTC(921'052'631'578'948), amm2.tokens())); + eth(1'085'714'285'714'285), btc(921'052'631'578'948), amm2.tokens())); // 25% on 63.1578e12BTC is paid in tr fee 63.1578e12*1.25 // = 78.9473e12BTC - env.require(balance(carol, BTC(1'063'157'894'736'841))); + env.require(Balance(carol_, btc(1'063'157'894'736'841))); } { // AMM offer crossing Env env(*this, features); - env.fund(XRP(1'000), gw, alice, bob); + env.fund(XRP(1'000), gw_, alice_, bob_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .transferFee = 25'000, .pay = 1'100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .transferFee = 25'000, .pay = 1'100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm(env, bob, BTC(1'000'000), ETH(1'100'000)); - env(offer(alice, ETH(100'000), BTC(100'000))); + AMM const amm(env, bob_, btc(1'000'000), eth(1'100'000)); + env(offer(alice_, eth(100'000), btc(100'000))); env.close(); // 100e3BTC is swapped in for 100e3ETH - BEAST_EXPECT(amm.expectBalances(BTC(1'100'000), ETH(1'000'000), amm.tokens())); + BEAST_EXPECT(amm.expectBalances(btc(1'100'000), eth(1'000'000), amm.tokens())); // alice pays 25% tr fee on 100e3BTC 1100e3-100e3*1.25 = 975e3BTC - env.require(balance(alice, BTC(975'000))); - env.require(balance(alice, ETH(1'200'000))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + env.require(Balance(alice_, btc(975'000))); + env.require(Balance(alice_, eth(1'200'000))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { // Payment via AMM with limit quality Env env(*this, features); - env.fund(XRP(1'000), gw, alice, bob, carol); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm(env, bob, GBP(1'000'000'000'000'000), BTC(1'000'000'000'000'000)); + AMM const amm(env, bob_, gbp(1'000'000'000'000'000), btc(1'000'000'000'000'000)); // requested quality limit is 100e12BTC/178.58e12GBP = 0.55997 // trade quality is 100e12BTC/178.5714 = 0.55999e12 - env(pay(alice, carol, BTC(100'000'000'000'000)), - path(~MPT(BTC)), - sendmax(GBP(178'580'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, btc(100'000'000'000'000)), + Path(~MPT(btc)), + Sendmax(gbp(178'580'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // alice buys 125e12BTC with 142.8571e12GBP and pays 25% tr fee // on 142.8571e12GBP // 1,000e12 - 142.8571e12*1.25 = 821.4285e12GBP - env.require(balance(alice, GBP(821'428'571'428'571))); + env.require(Balance(alice_, gbp(821'428'571'428'571))); // 142.8571e12GBP is swapped in for 125e12BTC BEAST_EXPECT(amm.expectBalances( - GBP(1'142'857'142'857'143), BTC(875'000'000'000'000), amm.tokens())); + gbp(1'142'857'142'857'143), btc(875'000'000'000'000), amm.tokens())); // 25% on 100e12BTC is paid in tr fee // 100e12*1.25 = 125e12BTC - env.require(balance(carol, BTC(1'100'000'000'000'000))); + env.require(Balance(carol_, btc(1'100'000'000'000'000))); } { // Payment via AMM with limit quality, deliver less // than requested Env env(*this, features); - env.fund(XRP(1'000), gw, alice, bob, carol); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'200'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'200'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm(env, bob, GBP(1'000'000'000'000'000), BTC(1'200'000'000'000'000)); + AMM const amm(env, bob_, gbp(1'000'000'000'000'000), btc(1'200'000'000'000'000)); // requested quality limit is 90e12BTC/120e12GBP = 0.75 // trade quality is 22.5e12BTC/30e12GBP = 0.75 - env(pay(alice, carol, BTC(90'000'000'000'000)), - path(~MPT(BTC)), - sendmax(GBP(120'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, btc(90'000'000'000'000)), + Path(~MPT(btc)), + Sendmax(gbp(120'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // alice buys 28.125e12BTC with 24e12GBP and pays 25% tr fee // on 24e12GBP // 1,200e12 - 24e12*1.25 =~ 1,170e12GBP - env.require(balance(alice, GBP(1'170'000'000'000'000))); + env.require(Balance(alice_, gbp(1'170'000'000'000'000))); // 24e12GBP is swapped in for 28.125e12BTC BEAST_EXPECT(amm.expectBalances( - GBP(1'024'000'000'000'000), BTC(1'171'875'000'000'000), amm.tokens())); + gbp(1'024'000'000'000'000), btc(1'171'875'000'000'000), amm.tokens())); // 25% on 22.5e12BTC is paid in tr fee // 22.5*1.25 = 28.125e12BTC - env.require(balance(carol, BTC(1'222'500'000'000'000))); + env.require(Balance(carol_, btc(1'222'500'000'000'000))); } { // Payment via offer and AMM with limit quality, deliver less @@ -2180,65 +2191,65 @@ private: Env env(*this, features); Account const ed("ed"); - env.fund(XRP(1'000), gw, alice, bob, carol, ed); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_, ed); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(ed, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)), - txflags(tfPassive)); + env(offer(ed, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)), + Txflags(tfPassive)); env.close(); - AMM const amm(env, bob, ETH(1'000'000'000'000'000), BTC(1'400'000'000'000'000)); + AMM const amm(env, bob_, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000)); // requested quality limit is 95e12BTC/140e12GBP = 0.6785 // trade quality is 59.7321e12BTC/88.0262e12GBP = 0.6785 - env(pay(alice, carol, BTC(95'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(140'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, btc(95'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(140'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // alice buys 70.4210e12ETH with 70.4210e12GBP via the offer // and pays 25% tr fee on 70.4210e12GBP // 1,400e12 - 70.4210e12*1.25 = 1400e12 - 88.0262e12 = // 1311.9736e12GBP - env.require(balance(alice, GBP(1'311'973'684'210'525))); + env.require(Balance(alice_, gbp(1'311'973'684'210'525))); // ed doesn't pay tr fee, the balances reflect consumed offer // 70.4210e12GBP/70.4210e12ETH - env.require(balance(ed, ETH(1'329'578'947'368'420))); - env.require(balance(ed, GBP(1'470'421'052'631'580))); + env.require(Balance(ed, eth(1'329'578'947'368'420))); + env.require(Balance(ed, gbp(1'470'421'052'631'580))); BEAST_EXPECT(expectOffers( - env, ed, 1, {Amounts{GBP(929'578'947'368'420), ETH(929'578'947'368'420)}})); + env, ed, 1, {Amounts{gbp(929'578'947'368'420), eth(929'578'947'368'420)}})); // 25% on 56.3368e12ETH is paid in tr fee 56.3368e12*1.25 // = 70.4210e12ETH 56.3368e12ETH is swapped in for 74.6651e12BTC BEAST_EXPECT(amm.expectBalances( - ETH(1'056'336'842'105'264), BTC(1'325'334'821'428'571), amm.tokens())); + eth(1'056'336'842'105'264), btc(1'325'334'821'428'571), amm.tokens())); // 25% on 59.7321e12BTC is paid in tr fee 59.7321e12*1.25 // = 74.6651e12BTC - env.require(balance(carol, BTC(1'459'732'142'857'143))); + env.require(Balance(carol_, btc(1'459'732'142'857'143))); } { // Payment via AMM and offer with limit quality, deliver less @@ -2246,66 +2257,66 @@ private: Env env(*this, features); Account const ed("ed"); - env.fund(XRP(1'000), gw, alice, bob, carol, ed); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_, ed); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm(env, bob, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)); + AMM const amm(env, bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)); - env(offer(ed, ETH(1'000'000'000'000'000), BTC(1'400'000'000'000'000)), - txflags(tfPassive)); + env(offer(ed, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000)), + Txflags(tfPassive)); env.close(); // requested quality limit is 95e12BTC/140e12GBP = 0.6785 // trade quality is 47.7857e12BTC/70.4210e12GBP = 0.6785 - env(pay(alice, carol, BTC(95'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(140'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, btc(95'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(140'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // alice buys 53.3322e12ETH with 56.3368e12GBP via the amm // and pays 25% tr fee on 56.3368e12GBP // 1,400e12 - 56.3368e12*1.25 = 1400e12 - 70.4210e12 = // 1329.5789e12GBP - env.require(balance(alice, GBP(1'329'578'947'368'420))); + env.require(Balance(alice_, gbp(1'329'578'947'368'420))); //// 25% on 56.3368e12ETH is paid in tr fee 56.3368e12*1.25 ///= 70.4210e12ETH // 56.3368e12GBP is swapped in for 53.3322e12ETH BEAST_EXPECT(amm.expectBalances( - GBP(1'056'336'842'105'264), ETH(946'667'729'591'836), amm.tokens())); + gbp(1'056'336'842'105'264), eth(946'667'729'591'836), amm.tokens())); // 25% on 42.6658e12ETH is paid in tr fee 42.6658e12*1.25 // = 53.3322e12ETH 42.6658e12ETH/59.7321e12BTC - env.require(balance(ed, BTC(1'340'267'857'142'857))); - env.require(balance(ed, ETH(1'442'665'816'326'531))); + env.require(Balance(ed, btc(1'340'267'857'142'857))); + env.require(Balance(ed, eth(1'442'665'816'326'531))); BEAST_EXPECT(expectOffers( - env, ed, 1, {Amounts{ETH(957'334'183'673'469), BTC(1'340'267'857'142'857)}})); + env, ed, 1, {Amounts{eth(957'334'183'673'469), btc(1'340'267'857'142'857)}})); // 25% on 47.7857e12BTC is paid in tr fee 47.7857e12*1.25 // = 59.7321e12BTC - env.require(balance(carol, BTC(1'447'785714285714))); + env.require(Balance(carol_, btc(1'447'785714285714))); } { // Payment via AMM, AMM with limit quality, deliver less @@ -2313,113 +2324,113 @@ private: Env env(*this, features); Account const ed("ed"); - env.fund(XRP(1'000), gw, alice, bob, carol, ed); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_, ed); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm1(env, bob, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)); - AMM const amm2(env, ed, ETH(1'000'000'000'000'000), BTC(1'400'000'000'000'000)); + AMM const amm1(env, bob_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)); + AMM const amm2(env, ed, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000)); // requested quality limit is 90e12BTC/145e12GBP = 0.6206 // trade quality is 66.7432e12BTC/107.5308e12GBP = 0.6206 - env(pay(alice, carol, BTC(90'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(145'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, btc(90'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(145'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // alice buys 53.3322e12ETH with 107.5308e12GBP // 25% on 86.0246e12GBP is paid in tr fee // 1,400e12 - 86.0246e12*1.25 = 1400e12 - 107.5308e12 = // 1229.4691e12GBP - env.require(balance(alice, GBP(1'292'469'135'802'465))); + env.require(Balance(alice_, gbp(1'292'469'135'802'465))); // 86.0246e12GBP is swapped in for 79.2106e12ETH BEAST_EXPECT(amm1.expectBalances( - GBP(1'086'024'691'358'028), ETH(920'789'377'955'618), amm1.tokens())); + gbp(1'086'024'691'358'028), eth(920'789'377'955'618), amm1.tokens())); // 25% on 63.3684e12ETH is paid in tr fee 63.3684e12*1.25 // = 79.2106e12ETH 63.3684e12ETH is swapped in for 83.4291e12BTC BEAST_EXPECT(amm2.expectBalances( - ETH(1'063'368'497'635'505), BTC(1'316'570'881'226'053), amm2.tokens())); + eth(1'063'368'497'635'505), btc(1'316'570'881'226'053), amm2.tokens())); // 25% on 66.7432e12BTC is paid in tr fee 66.7432e12*1.25 // = 83.4291e12BTC - env.require(balance(carol, BTC(1'466'743'295'019'157))); + env.require(Balance(carol_, btc(1'466'743'295'019'157))); } { // Payment by the issuer via AMM, AMM with limit quality, // deliver less than requested Env env(*this, features); - env.fund(XRP(1'000), gw, alice, bob, carol); + env.fund(XRP(1'000), gw_, alice_, bob_, carol_); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const GBP( + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 1'400'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const amm1(env, alice, GBP(1'000'000'000'000'000), ETH(1'000'000'000'000'000)); - AMM const amm2(env, bob, ETH(1'000'000'000'000'000), BTC(1'400'000'000'000'000)); + AMM const amm1(env, alice_, gbp(1'000'000'000'000'000), eth(1'000'000'000'000'000)); + AMM const amm2(env, bob_, eth(1'000'000'000'000'000), btc(1'400'000'000'000'000)); // requested quality limit is 90e12BTC/120e12GBP = 0.75 // trade quality is 81.1111e12BTC/108.1481e12GBP = 0.75 - env(pay(gw, carol, BTC(90'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(GBP(120'000'000'000'000)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(gw_, carol_, btc(90'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(gbp(120'000'000'000'000)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); // 108.1481e12GBP is swapped in for 97.5935e12ETH BEAST_EXPECT(amm1.expectBalances( - GBP(1'108'148'148'148'150), ETH(902'406'417'112'298), amm1.tokens())); + gbp(1'108'148'148'148'150), eth(902'406'417'112'298), amm1.tokens())); // 25% on 78.0748e12ETH is paid in tr fee 78.0748e12*1.25 // = 97.5935e12ETH 78.0748e12ETH is swapped in for 101.3888e12BTC BEAST_EXPECT(amm2.expectBalances( - ETH(1'078'074'866'310'161), BTC(1'298'611'111'111'111), amm2.tokens())); + eth(1'078'074'866'310'161), btc(1'298'611'111'111'111), amm2.tokens())); // 25% on 81.1111e12BTC is paid in tr fee 81.1111e12*1.25 = // 101.3888e12BTC - env.require(balance(carol, BTC(1'481'111'111'111'111))); + env.require(Balance(carol_, btc(1'481'111'111'111'111))); } } @@ -2435,26 +2446,26 @@ private: { Env env(*this); - env.fund(XRP(10'000), gw, alice, bob, carol); + env.fund(XRP(10'000), gw_, alice_, bob_, carol_); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 2'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, XRP(1'000), ETH(1'050'000)); - env(offer(bob, XRP(100), ETH(50'000))); + AMM const ammBob(env, bob_, XRP(1'000), eth(1'050'000)); + env(offer(bob_, XRP(100), eth(50'000))); - env(pay(alice, carol, ETH(100'000)), - path(~MPT(ETH)), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, eth(100'000)), + Path(~MPT(eth)), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); - BEAST_EXPECT(ammBob.expectBalances(XRP(1'050), ETH(1'000'000), ammBob.tokens())); - env.require(balance(carol, ETH(2'050'000))); - BEAST_EXPECT(expectOffers(env, bob, 1, {{{XRP(100), ETH(50'000)}}})); + BEAST_EXPECT(ammBob.expectBalances(XRP(1'050), eth(1'000'000), ammBob.tokens())); + env.require(Balance(carol_, eth(2'050'000))); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{{XRP(100), eth(50'000)}}})); } } @@ -2469,34 +2480,34 @@ private: { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, gw); + env.fund(XRP(30'000), alice_, bob_, gw_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - env(pay(gw, alice, BTC(200'000))); - env(pay(gw, bob, BTC(200'000))); - env(pay(gw, alice, ETH(200'000))); - env(pay(gw, bob, ETH(200'000))); + env(pay(gw_, alice_, btc(200'000))); + env(pay(gw_, bob_, btc(200'000))); + env(pay(gw_, alice_, eth(200'000))); + env(pay(gw_, bob_, eth(200'000))); env.close(); - AMM const ammAliceXRP_BTC(env, alice, XRP(100), BTC(101'000)); - AMM const ammAliceXRP_ETH(env, alice, XRP(100), ETH(101'000)); - env(pay(alice, bob, ETH(1'000)), - path(~BTC, ~XRP, ~ETH), - sendmax(XRP(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + AMM const ammAliceXrpBtc(env, alice_, XRP(100), btc(101'000)); + AMM const ammAliceXrpEth(env, alice_, XRP(100), eth(101'000)); + env(pay(alice_, bob_, eth(1'000)), + Path(~btc, ~XRP, ~eth), + Sendmax(XRP(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper2TokensMix(test); } @@ -2505,35 +2516,35 @@ private: { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, gw); + env.fund(XRP(30'000), alice_, bob_, gw_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - env(pay(gw, alice, BTC(200'000))); - env(pay(gw, bob, BTC(200'000))); - env(pay(gw, alice, ETH(200'000))); - env(pay(gw, bob, ETH(200'000))); + env(pay(gw_, alice_, btc(200'000))); + env(pay(gw_, bob_, btc(200'000))); + env(pay(gw_, alice_, eth(200'000))); + env(pay(gw_, bob_, eth(200'000))); env.close(); - AMM const ammAliceXRP_BTC(env, alice, XRP(100), BTC(100'000)); - AMM const ammAliceXRP_ETH(env, alice, XRP(100), ETH(100'000)); + AMM const ammAliceXrpBtc(env, alice_, XRP(100), btc(100'000)); + AMM const ammAliceXrpEth(env, alice_, XRP(100), eth(100'000)); // ETH -> //XRP -> //BTC ->XRP - env(pay(alice, bob, XRP(1)), - path(~XRP, ~BTC, ~XRP), - sendmax(ETH(1'000)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, bob_, XRP(1)), + Path(~XRP, ~btc, ~XRP), + Sendmax(eth(1'000)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper2TokensMix(test); } @@ -2543,44 +2554,44 @@ private: { auto test = [&](auto&& issue1, auto&& issue2, auto&& issue3) { Env env(*this); - env.fund(XRP(10'000), gw, alice, bob); + env.fund(XRP(10'000), gw_, alice_, bob_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - auto const JPY = issue2( + auto const jpy = issue2( {.env = env, .token = "JPY", - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .limit = 2000'000}); - env(pay(gw, alice, BTC(200'000))); - env(pay(gw, bob, BTC(200'000))); - env(pay(gw, alice, ETH(200'000))); - env(pay(gw, bob, ETH(200'000))); - env(pay(gw, alice, JPY(200'000))); - env(pay(gw, bob, JPY(200'000))); + env(pay(gw_, alice_, btc(200'000))); + env(pay(gw_, bob_, btc(200'000))); + env(pay(gw_, alice_, eth(200'000))); + env(pay(gw_, bob_, eth(200'000))); + env(pay(gw_, alice_, jpy(200'000))); + env(pay(gw_, bob_, jpy(200'000))); env.close(); - AMM const ammAliceXRP_BTC(env, alice, XRP(100), BTC(100'000)); - AMM const ammAliceXRP_ETH(env, alice, XRP(100), ETH(100'000)); - AMM const ammAliceXRP_JPY(env, alice, XRP(100), JPY(100'000)); + AMM const ammAliceXrpBtc(env, alice_, XRP(100), btc(100'000)); + AMM const ammAliceXrpEth(env, alice_, XRP(100), eth(100'000)); + AMM const ammAliceXrpJpy(env, alice_, XRP(100), jpy(100'000)); - env(pay(alice, bob, JPY(1'000)), - path(~XRP, ~ETH, ~XRP, ~JPY), - sendmax(BTC(1'000)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, bob_, jpy(1'000)), + Path(~XRP, ~eth, ~XRP, ~jpy), + Sendmax(btc(1'000)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper3TokensMix(test); } @@ -2597,39 +2608,39 @@ private: auto const dan = Account("dan"); auto const ed = Account("ed"); - env.fund(XRP(100'000'000), gw, alice, bob, carol, dan, ed); + env.fund(XRP(100'000'000), gw_, alice_, bob_, carol_, dan, ed); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {bob, dan, ed}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {bob_, dan, ed}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, ed, BTC(11'000'000'000'000))); - env(pay(gw, bob, BTC(1'000'000'000'000))); - env(pay(gw, dan, BTC(1'000'000'000'000))); + env(pay(gw_, ed, btc(11'000'000'000'000))); + env(pay(gw_, bob_, btc(1'000'000'000'000))); + env(pay(gw_, dan, btc(1'000'000'000'000))); - n_offers(env, 2'000, bob, XRP(1), BTC(1'000'000'000'000)); - n_offers(env, 1, dan, XRP(1), BTC(1'000'000'000'000)); - AMM const ammEd(env, ed, XRP(9), BTC(11'000'000'000'000)); + nOffers(env, 2'000, bob_, XRP(1), btc(1'000'000'000'000)); + nOffers(env, 1, dan, XRP(1), btc(1'000'000'000'000)); + AMM const ammEd(env, ed, XRP(9), btc(11'000'000'000'000)); // Alice offers to buy 1000 XRP for 1000e12 BTC. She takes Bob's // first offer, removes 999 more as unfunded, then hits the step // limit. - env(offer(alice, BTC(1'000'000'000'000'000), XRP(1'000))); - env.require(balance(alice, BTC(2'050'125'257'867))); - env.require(owners(alice, 2)); - env.require(balance(bob, BTC(0))); - env.require(owners(bob, 1'001)); - env.require(balance(dan, BTC(1'000'000'000'000))); - env.require(owners(dan, 2)); + env(offer(alice_, btc(1'000'000'000'000'000), XRP(1'000))); + env.require(Balance(alice_, btc(2'050'125'257'867))); + env.require(Owners(alice_, 2)); + env.require(Balance(bob_, btc(0))); + env.require(Owners(bob_, 1'001)); + env.require(Balance(dan, btc(1'000'000'000'000))); + env.require(Owners(dan, 2)); // Carol offers to buy 1000 XRP for 1000e12 BTC. She removes Bob's // next 1000 offers as unfunded and hits the step limit. - env(offer(carol, BTC(1'000'000'000'000'000), XRP(1'000))); - env.require(balance(carol, MPT(BTC)(none))); - env.require(owners(carol, 1)); - env.require(balance(bob, BTC(0))); - env.require(owners(bob, 1)); - env.require(balance(dan, BTC(1'000'000'000'000))); - env.require(owners(dan, 2)); + env(offer(carol_, btc(1'000'000'000'000'000), XRP(1'000))); + env.require(Balance(carol_, MPT(btc)(kNONE))); + env.require(Owners(carol_, 1)); + env.require(Balance(bob_, btc(0))); + env.require(Owners(bob_, 1)); + env.require(Balance(dan, btc(1'000'000'000'000))); + env.require(Owners(dan, 2)); } // MPT/IOU, similar to the case above @@ -2638,35 +2649,35 @@ private: auto const dan = Account("dan"); auto const ed = Account("ed"); - env.fund(XRP(100'000), gw, alice, bob, carol, dan, ed); + env.fund(XRP(100'000), gw_, alice_, bob_, carol_, dan, ed); env.close(); - MPTTester const USD( + MPTTester const usd( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .pay = 10000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); env.trust(BTC(11'000'000'000'000), ed); - env(pay(gw, ed, BTC(11'000'000'000'000))); - env.trust(BTC(1'000'000'000'000), bob); - env(pay(gw, bob, BTC(1'000'000'000'000))); + env(pay(gw_, ed, BTC(11'000'000'000'000))); + env.trust(BTC(1'000'000'000'000), bob_); + env(pay(gw_, bob_, BTC(1'000'000'000'000))); env.trust(BTC(1'000'000'000'000), dan); - env(pay(gw, dan, BTC(1'000'000'000'000))); + env(pay(gw_, dan, BTC(1'000'000'000'000))); env.close(); - n_offers(env, 2'000, bob, USD(1000000), BTC(1'000'000'000'000)); - n_offers(env, 1, dan, USD(1000000), BTC(1'000'000'000'000)); - AMM const ammEd(env, ed, USD(9000000), BTC(11'000'000'000'000)); - env(offer(alice, BTC(1'000'000'000'000'000), USD(1'000000000))); + nOffers(env, 2'000, bob_, usd(1000000), BTC(1'000'000'000'000)); + nOffers(env, 1, dan, usd(1000000), BTC(1'000'000'000'000)); + AMM const ammEd(env, ed, usd(9000000), BTC(11'000'000'000'000)); + env(offer(alice_, BTC(1'000'000'000'000'000), usd(1'000000000))); - env.require(balance(alice, STAmount{BTC, UINT64_C(2050125257867'587), -3})); - env.require(owners(alice, 3)); - env.require(balance(bob, BTC(0))); - env.require(owners(bob, 1'002)); - env.require(balance(dan, BTC(1000000000000))); - env.require(owners(dan, 3)); + env.require(Balance(alice_, STAmount{BTC, UINT64_C(2050125257867'587), -3})); + env.require(Owners(alice_, 3)); + env.require(Balance(bob_, BTC(0))); + env.require(Owners(bob_, 1'002)); + env.require(Balance(dan, BTC(1000000000000))); + env.require(Owners(dan, 3)); } // IOU/MPT, similar to the case above @@ -2675,40 +2686,40 @@ private: auto const dan = Account("dan"); auto const ed = Account("ed"); - env.fund(XRP(100'000), gw, alice, bob, carol, dan, ed); + env.fund(XRP(100'000), gw_, alice_, bob_, carol_, dan, ed); env.close(); - env.trust(USD(10000'000'000), alice); - env(pay(gw, alice, USD(10000'000'000))); - env.trust(USD(10000'000'000), bob); - env(pay(gw, bob, USD(10000'000'000))); - env.trust(USD(10000'000'000), carol); - env(pay(gw, carol, USD(10000'000'000))); + env.trust(USD(10000'000'000), alice_); + env(pay(gw_, alice_, USD(10000'000'000))); + env.trust(USD(10000'000'000), bob_); + env(pay(gw_, bob_, USD(10000'000'000))); + env.trust(USD(10000'000'000), carol_); + env(pay(gw_, carol_, USD(10000'000'000))); env.trust(USD(10000'000'000), dan); - env(pay(gw, dan, USD(10000'000'000))); + env(pay(gw_, dan, USD(10000'000'000))); env.trust(USD(10000'000'000), ed); - env(pay(gw, ed, USD(10000'000'000))); + env(pay(gw_, ed, USD(10000'000'000))); env.close(); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {bob, dan, ed}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {bob_, dan, ed}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, ed, BTC(11'000'000'000'000))); - env(pay(gw, bob, BTC(1'000'000'000'000))); - env(pay(gw, dan, BTC(1'000'000'000'000))); + env(pay(gw_, ed, btc(11'000'000'000'000))); + env(pay(gw_, bob_, btc(1'000'000'000'000))); + env(pay(gw_, dan, btc(1'000'000'000'000))); env.close(); - n_offers(env, 2'000, bob, USD(1000000), BTC(1'000'000'000'000)); - n_offers(env, 1, dan, USD(1000000), BTC(1'000'000'000'000)); - AMM const ammEd(env, ed, USD(9000000), BTC(11'000'000'000'000)); - env(offer(alice, BTC(1'000'000'000'000'000), USD(1'000000000))); + nOffers(env, 2'000, bob_, USD(1000000), btc(1'000'000'000'000)); + nOffers(env, 1, dan, USD(1000000), btc(1'000'000'000'000)); + AMM const ammEd(env, ed, USD(9000000), btc(11'000'000'000'000)); + env(offer(alice_, btc(1'000'000'000'000'000), USD(1'000000000))); - env.require(balance(alice, BTC(2050125628933))); - env.require(owners(alice, 3)); - env.require(balance(bob, BTC(0))); - env.require(owners(bob, 1'002)); - env.require(balance(dan, BTC(1000000000000))); - env.require(owners(dan, 3)); + env.require(Balance(alice_, btc(2050125628933))); + env.require(Owners(alice_, 3)); + env.require(Balance(bob_, btc(0))); + env.require(Owners(bob_, 1'002)); + env.require(Balance(dan, btc(1000000000000))); + env.require(Owners(dan, 3)); } // MPT/MPT, similar to the case above @@ -2717,39 +2728,39 @@ private: auto const dan = Account("dan"); auto const ed = Account("ed"); - env.fund(XRP(100'000), gw, alice, bob, carol, dan, ed); + env.fund(XRP(100'000), gw_, alice_, bob_, carol_, dan, ed); env.close(); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {bob, dan, ed}, .flags = MPTDEXFlags}); - MPTTester const USD( + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {bob_, dan, ed}, .flags = kMPT_DEX_FLAGS}); + MPTTester const usd( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .pay = 10000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, ed, BTC(11'000'000'000'000))); - env(pay(gw, bob, BTC(1'000'000'000'000))); - env(pay(gw, dan, BTC(1'000'000'000'000))); + env(pay(gw_, ed, btc(11'000'000'000'000))); + env(pay(gw_, bob_, btc(1'000'000'000'000))); + env(pay(gw_, dan, btc(1'000'000'000'000))); env.close(); - n_offers(env, 2'000, bob, USD(1000000), BTC(1'000'000'000'000)); - n_offers(env, 1, dan, USD(1000000), BTC(1'000'000'000'000)); - AMM const ammEd(env, ed, USD(9000000), BTC(11'000'000'000'000)); - env(offer(alice, BTC(1'000'000'000'000'000), USD(1'000000000))); + nOffers(env, 2'000, bob_, usd(1000000), btc(1'000'000'000'000)); + nOffers(env, 1, dan, usd(1000000), btc(1'000'000'000'000)); + AMM const ammEd(env, ed, usd(9000000), btc(11'000'000'000'000)); + env(offer(alice_, btc(1'000'000'000'000'000), usd(1'000000000))); - env.require(balance(alice, BTC(2050125257867))); - env.require(owners(alice, 3)); - env.require(balance(bob, BTC(0))); - env.require(owners(bob, 1'002)); - env.require(balance(dan, BTC(1000000000000))); - env.require(owners(dan, 3)); + env.require(Balance(alice_, btc(2050125257867))); + env.require(Owners(alice_, 3)); + env.require(Balance(bob_, btc(0))); + env.require(Owners(bob_, 1'002)); + env.require(Balance(dan, btc(1000000000000))); + env.require(Owners(dan, 3)); } } void - test_convert_all_of_an_asset(FeatureBitset features) + testConvertAllOfAnAsset(FeatureBitset features) { testcase("Convert all of an asset using DeliverMin"); @@ -2757,157 +2768,160 @@ private: { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - env(pay(alice, bob, BTC(10'000)), deliver_min(BTC(10'000)), ter(temBAD_AMOUNT)); - env(pay(alice, bob, BTC(10'000)), - deliver_min(BTC(-5'000)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(alice, bob, BTC(10'000)), - deliver_min(XRP(5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(alice, bob, BTC(10'000)), - deliver_min(BTC(5'000)), - txflags(tfPartialPayment), - ter(tecPATH_DRY)); - env(pay(alice, bob, BTC(10'000)), - deliver_min(BTC(15'000)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(gw, carol, BTC(50'000))); - AMM const ammCarol(env, carol, XRP(10), BTC(15'000)); - env(pay(alice, bob, BTC(10'000)), - paths(XRP), - deliver_min(BTC(7'000)), - txflags(tfPartialPayment), - sendmax(XRP(5)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, bob_, btc(10'000)), DeliverMin(btc(10'000)), Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, btc(10'000)), + DeliverMin(btc(-5'000)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, btc(10'000)), + DeliverMin(XRP(5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, btc(10'000)), + DeliverMin(btc(5'000)), + Txflags(tfPartialPayment), + Ter(tecPATH_DRY)); + env(pay(alice_, bob_, btc(10'000)), + DeliverMin(btc(15'000)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(gw_, carol_, btc(50'000))); + AMM const ammCarol(env, carol_, XRP(10), btc(15'000)); + env(pay(alice_, bob_, btc(10'000)), + Paths(XRP), + DeliverMin(btc(7'000)), + Txflags(tfPartialPayment), + Sendmax(XRP(5)), + Ter(tecPATH_PARTIAL)); env.require( - balance(alice, drops(10'000'000'000 - (3 * env.current()->fees().base.drops())))); - env.require(balance(bob, drops(10'000'000'000 - env.current()->fees().base.drops()))); + Balance(alice_, drops(10'000'000'000 - (3 * env.current()->fees().base.drops())))); + env.require(Balance(bob_, drops(10'000'000'000 - env.current()->fees().base.drops()))); } { Env env(*this, features); - fund(env, gw, {alice, bob}, XRP(10'000)); + fund(env, gw_, {alice_, bob_}, XRP(10'000)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, bob_}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(1'100'000))); - AMM const ammBob(env, bob, XRP(1'000), BTC(1'100'000)); - env(pay(alice, alice, BTC(10'000'000)), - paths(XRP), - deliver_min(BTC(100'000)), - txflags(tfPartialPayment), - sendmax(XRP(100))); - env.require(balance(alice, BTC(100'000))); + env(pay(gw_, bob_, btc(1'100'000))); + AMM const ammBob(env, bob_, XRP(1'000), btc(1'100'000)); + env(pay(alice_, alice_, btc(10'000'000)), + Paths(XRP), + DeliverMin(btc(100'000)), + Txflags(tfPartialPayment), + Sendmax(XRP(100))); + env.require(Balance(alice_, btc(100'000))); } // IOU/MPT mix, similar to the above case { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 3000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); - env(pay(gw, bob, BTC(1'200))); + env(pay(gw_, alice_, usd(10'000))); + env(pay(gw_, bob_, usd(10'000))); + env(pay(gw_, bob_, btc(1'200))); env.close(); - AMM const ammBob(env, bob, USD(1'000), BTC(1'100)); - env(pay(alice, alice, BTC(10'000)), - paths(USD), - deliver_min(BTC(100)), - txflags(tfPartialPayment), - sendmax(USD(100))); - env.require(balance(alice, BTC(100))); + AMM const ammBob(env, bob_, usd(1'000), btc(1'100)); + env(pay(alice_, alice_, btc(10'000)), + Paths(usd), + DeliverMin(btc(100)), + Txflags(tfPartialPayment), + Sendmax(usd(100))); + env.require(Balance(alice_, btc(100))); }; testHelper2TokensMix(test); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {bob, carol}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {bob_, carol_}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(1'200'000))); - AMM const ammBob(env, bob, XRP(5'500), BTC(1'200'000)); - env(pay(alice, carol, BTC(10'000'000)), - paths(XRP), - deliver_min(BTC(200'000)), - txflags(tfPartialPayment), - sendmax(XRP(1'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, BTC(10'000'000)), - paths(XRP), - deliver_min(BTC(200'000)), - txflags(tfPartialPayment), - sendmax(XRP(1'100))); - BEAST_EXPECT(ammBob.expectBalances(XRP(6'600), BTC(1'000'000), ammBob.tokens())); - env.require(balance(carol, BTC(200'000))); + env(pay(gw_, bob_, btc(1'200'000))); + AMM const ammBob(env, bob_, XRP(5'500), btc(1'200'000)); + env(pay(alice_, carol_, btc(10'000'000)), + Paths(XRP), + DeliverMin(btc(200'000)), + Txflags(tfPartialPayment), + Sendmax(XRP(1'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, btc(10'000'000)), + Paths(XRP), + DeliverMin(btc(200'000)), + Txflags(tfPartialPayment), + Sendmax(XRP(1'100))); + BEAST_EXPECT(ammBob.expectBalances(XRP(6'600), btc(1'000'000), ammBob.tokens())); + env.require(Balance(carol_, btc(200'000))); } // IOU/MPT mix, similar to the above case { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 3000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, USD(100'000))); - env(pay(gw, bob, USD(100'000))); - env(pay(gw, carol, USD(100'000))); + env(pay(gw_, alice_, usd(100'000))); + env(pay(gw_, bob_, usd(100'000))); + env(pay(gw_, carol_, usd(100'000))); - env(pay(gw, bob, BTC(1'200))); + env(pay(gw_, bob_, btc(1'200))); env.close(); - AMM const ammBob(env, bob, USD(5'500), BTC(1'200)); - env(pay(alice, carol, BTC(10'000)), - paths(USD), - deliver_min(BTC(200)), - txflags(tfPartialPayment), - sendmax(USD(1'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, BTC(10'000)), - paths(USD), - deliver_min(BTC(200)), - txflags(tfPartialPayment), - sendmax(USD(1'100))); - BEAST_EXPECT(ammBob.expectBalances(USD(6'600), BTC(1'000), ammBob.tokens())); - env.require(balance(carol, BTC(200))); + AMM const ammBob(env, bob_, usd(5'500), btc(1'200)); + env(pay(alice_, carol_, btc(10'000)), + Paths(usd), + DeliverMin(btc(200)), + Txflags(tfPartialPayment), + Sendmax(usd(1'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, btc(10'000)), + Paths(usd), + DeliverMin(btc(200)), + Txflags(tfPartialPayment), + Sendmax(usd(1'100))); + BEAST_EXPECT(ammBob.expectBalances(usd(6'600), btc(1'000), ammBob.tokens())); + env.require(Balance(carol_, btc(200))); }; testHelper2TokensMix(test); } @@ -2915,26 +2929,29 @@ private: { auto const dan = Account("dan"); Env env(*this, features); - fund(env, gw, {alice, bob, carol, dan}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_, dan}, XRP(10'000)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {bob, carol, dan}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {bob_, carol_, dan}, + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(100'000'000))); - env(pay(gw, dan, BTC(1'100'000'000))); - env(offer(bob, XRP(100), BTC(100'000'000))); - env(offer(bob, XRP(1'000), BTC(100'000'000))); - AMM const ammDan(env, dan, XRP(1'000), BTC(1'100'000'000)); + env(pay(gw_, bob_, btc(100'000'000))); + env(pay(gw_, dan, btc(1'100'000'000))); + env(offer(bob_, XRP(100), btc(100'000'000))); + env(offer(bob_, XRP(1'000), btc(100'000'000))); + AMM const ammDan(env, dan, XRP(1'000), btc(1'100'000'000)); - env(pay(alice, carol, BTC(10'000'000'000)), - paths(XRP), - deliver_min(BTC(200'000'000)), - txflags(tfPartialPayment), - sendmax(XRPAmount(200'000'001))); - env.require(balance(bob, BTC(0))); - env.require(balance(carol, BTC(200'000'000))); + env(pay(alice_, carol_, btc(10'000'000'000)), + Paths(XRP), + DeliverMin(btc(200'000'000)), + Txflags(tfPartialPayment), + Sendmax(XRPAmount(200'000'001))); + env.require(Balance(bob_, btc(0))); + env.require(Balance(carol_, btc(200'000'000))); BEAST_EXPECT( - ammDan.expectBalances(XRPAmount{1'100'000'001}, BTC(1000'000000), ammDan.tokens())); + ammDan.expectBalances(XRPAmount{1'100'000'001}, btc(1000'000000), ammDan.tokens())); } } @@ -2947,29 +2964,29 @@ private: Account const becky{"becky"}; Env env(*this, features); - fund(env, gw, {alice, becky}, XRP(5'000)); + fund(env, gw_, {alice_, becky}, XRP(5'000)); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, becky}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, becky}, .flags = kMPT_DEX_FLAGS}); - env(pay(gw, alice, BTC(500'000))); + env(pay(gw_, alice_, btc(500'000))); env.close(); - AMM const ammAlice(env, alice, XRP(100), BTC(140'000)); + AMM const ammAlice(env, alice_, XRP(100), btc(140'000)); // becky pays herself BTC (10'000) by consuming part of alice's offer. // Make sure the payment works if PaymentAuth is not involved. - env(pay(becky, becky, BTC(10'000)), path(~MPT(BTC)), sendmax(XRP(10))); + env(pay(becky, becky, btc(10'000)), Path(~MPT(btc)), Sendmax(XRP(10))); env.close(); BEAST_EXPECT( - ammAlice.expectBalances(XRPAmount(107'692'308), BTC(130'000), ammAlice.tokens())); + ammAlice.expectBalances(XRPAmount(107'692'308), btc(130'000), ammAlice.tokens())); // becky decides to require authorization for deposits. env(fset(becky, asfDepositAuth)); env.close(); // becky pays herself again. - env(pay(becky, becky, BTC(10'000)), path(~MPT(BTC)), sendmax(XRP(10)), ter(tesSUCCESS)); + env(pay(becky, becky, btc(10'000)), Path(~MPT(btc)), Sendmax(XRP(10)), Ter(tesSUCCESS)); env.close(); } @@ -2985,42 +3002,45 @@ private: Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester BTC( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester btc( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, alice, BTC(150'000))); - env(pay(gw, carol, BTC(150'000))); - AMM const ammCarol(env, carol, BTC(100'000), XRPAmount(101)); + env(pay(gw_, alice_, btc(150'000))); + env(pay(gw_, carol_, btc(150'000))); + AMM const ammCarol(env, carol_, btc(100'000), XRPAmount(101)); - env(pay(alice, bob, BTC(50'000))); + env(pay(alice_, bob_, btc(50'000))); env.close(); // bob sets the lsfDepositAuth flag. - env(fset(bob, asfDepositAuth), require(flags(bob, asfDepositAuth))); + env(fset(bob_, asfDepositAuth), Require(Flags(bob_, asfDepositAuth))); env.close(); // None of the following payments should succeed. - auto failedMptPayments = [this, &env, &BTC]() { - env.require(flags(bob, asfDepositAuth)); + auto failedMptPayments = [this, &env, &btc]() { + env.require(Flags(bob_, asfDepositAuth)); // Capture bob's balances before hand to confirm they don't // change. - PrettyAmount const bobXrpBalance{env.balance(bob, XRP)}; - PrettyAmount const bobBTCBalance{env.balance(bob, MPT(BTC))}; + PrettyAmount const bobXrpBalance{env.balance(bob_, XRP)}; + PrettyAmount const bobBTCBalance{env.balance(bob_, MPT(btc))}; - env(pay(alice, bob, BTC(50'000)), ter(tecNO_PERMISSION)); + env(pay(alice_, bob_, btc(50'000)), Ter(tecNO_PERMISSION)); env.close(); // Note that even though alice is paying bob in XRP, the payment // is still not allowed since the payment passes through an // offer. - env(pay(alice, bob, drops(1)), sendmax(BTC(1'000)), ter(tecNO_PERMISSION)); + env(pay(alice_, bob_, drops(1)), Sendmax(btc(1'000)), Ter(tecNO_PERMISSION)); env.close(); - BEAST_EXPECT(bobXrpBalance == env.balance(bob, XRP)); - BEAST_EXPECT(bobBTCBalance == env.balance(bob, MPT(BTC))); + BEAST_EXPECT(bobXrpBalance == env.balance(bob_, XRP)); + BEAST_EXPECT(bobBTCBalance == env.balance(bob_, MPT(btc))); }; // Test when bob has an XRP balance > base reserve. @@ -3028,41 +3048,41 @@ private: // Set bob's XRP balance == base reserve. Also demonstrate that // bob can make payments while his lsfDepositAuth flag is set. - env(pay(bob, alice, BTC(25'000))); + env(pay(bob_, alice_, btc(25'000))); env.close(); { - STAmount const bobPaysXRP{env.balance(bob, XRP) - reserve(env, 1)}; + STAmount const bobPaysXRP{env.balance(bob_, XRP) - reserve(env, 1)}; XRPAmount const bobPaysFee{reserve(env, 1) - reserve(env, 0)}; - env(pay(bob, alice, bobPaysXRP), fee(bobPaysFee)); + env(pay(bob_, alice_, bobPaysXRP), Fee(bobPaysFee)); env.close(); } // Test when bob's XRP balance == base reserve. - BEAST_EXPECT(env.balance(bob, XRP) == reserve(env, 0)); - BEAST_EXPECT(env.balance(bob, MPT(BTC)) == BTC(25'000)); + BEAST_EXPECT(env.balance(bob_, XRP) == reserve(env, 0)); + BEAST_EXPECT(env.balance(bob_, MPT(btc)) == btc(25'000)); failedMptPayments(); // Test when bob has an XRP balance == 0. - env(noop(bob), fee(reserve(env, 0))); + env(noop(bob_), Fee(reserve(env, 0))); env.close(); - BEAST_EXPECT(env.balance(bob, XRP) == XRP(0)); + BEAST_EXPECT(env.balance(bob_, XRP) == XRP(0)); failedMptPayments(); // Give bob enough XRP for the fee to clear the lsfDepositAuth flag. - env(pay(alice, bob, drops(env.current()->fees().base))); + env(pay(alice_, bob_, drops(env.current()->fees().base))); // bob clears the lsfDepositAuth and the next payment succeeds. - env(fclear(bob, asfDepositAuth)); + env(fclear(bob_, asfDepositAuth)); env.close(); - env(pay(alice, bob, BTC(50'000))); + env(pay(alice_, bob_, btc(50'000))); env.close(); - env(pay(alice, bob, drops(1)), sendmax(BTC(1'000))); + env(pay(alice_, bob_, drops(1)), Sendmax(btc(1'000))); env.close(); - BEAST_EXPECT(ammCarol.expectBalances(BTC(101'000), XRPAmount(100), ammCarol.tokens())); + BEAST_EXPECT(ammCarol.expectBalances(btc(101'000), XRPAmount(100), ammCarol.tokens())); } void @@ -3073,66 +3093,66 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; + Account const g1{"G1"}; Account const alice{"alice"}; Account const bob{"bob"}; - env.fund(XRP(1'000), G1, alice, bob); + env.fund(XRP(1'000), g1, alice, bob); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = G1, + .issuer = g1, .holders = {alice, bob}, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - env(pay(G1, bob, BTC(10))); - env(pay(G1, alice, BTC(205))); + env(pay(g1, bob, btc(10))); + env(pay(g1, alice, btc(205))); env.close(); - AMM const ammAlice(env, alice, XRP(500), BTC(105)); + AMM const ammAlice(env, alice, XRP(500), btc(105)); - env.require(balance(bob, BTC(10))); - env.require(balance(alice, BTC(100))); + env.require(Balance(bob, btc(10))); + env.require(Balance(alice, btc(100))); // Account with MPT unlocked (proving operations normally work) // can make Payment - env(pay(alice, bob, BTC(1))); + env(pay(alice, bob, btc(1))); // can receive Payment - env(pay(bob, alice, BTC(1))); + env(pay(bob, alice, btc(1))); env.close(); // Lock MPT for bob - BTC.set({.holder = bob, .flags = tfMPTLock}); + btc.set({.holder = bob, .flags = tfMPTLock}); { // different from IOU. The offer is created but not crossed. - env(offer(bob, BTC(5), XRP(25))); + env(offer(bob, btc(5), XRP(25))); env.close(); - BEAST_EXPECT(expectOffers(env, bob, 1, {{{BTC(5), XRP(25)}}})); - BEAST_EXPECT(ammAlice.expectBalances(XRP(500), BTC(105), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, bob, 1, {{{btc(5), XRP(25)}}})); + BEAST_EXPECT(ammAlice.expectBalances(XRP(500), btc(105), ammAlice.tokens())); } { // can not sell assets - env(offer(bob, XRP(1), BTC(5)), ter(tecUNFUNDED_OFFER)); + env(offer(bob, XRP(1), btc(5)), Ter(tecUNFUNDED_OFFER)); // different from IOU // can not receive Payment when locked - env(pay(alice, bob, BTC(1)), ter(tecPATH_DRY)); + env(pay(alice, bob, btc(1)), Ter(tecPATH_DRY)); // can not make Payment when locked - env(pay(bob, alice, BTC(1)), ter(tecPATH_DRY)); + env(pay(bob, alice, btc(1)), Ter(tecPATH_DRY)); - env.require(balance(bob, BTC(10))); + env.require(Balance(bob, btc(10))); } { // Unlock - BTC.set({.holder = bob, .flags = tfMPTUnlock}); - env(offer(bob, XRP(1), BTC(5))); - env(pay(bob, alice, BTC(1))); - env(pay(alice, bob, BTC(1))); + btc.set({.holder = bob, .flags = tfMPTUnlock}); + env(offer(bob, XRP(1), btc(5))); + env(pay(bob, alice, btc(1))); + env(pay(alice, bob, btc(1))); env.close(); } } @@ -3145,49 +3165,49 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account A1{"A1"}; - Account A2{"A2"}; - Account A3{"A3"}; - Account A4{"A4"}; + Account const g1{"G1"}; + Account a1{"A1"}; + Account a2{"A2"}; + Account a3{"A3"}; + Account a4{"A4"}; - env.fund(XRP(12'000), G1); - env.fund(XRP(1'000), A1); - env.fund(XRP(20'000), A2, A3, A4); + env.fund(XRP(12'000), g1); + env.fund(XRP(1'000), a1); + env.fund(XRP(20'000), a2, a3, a4); - MPTTester const ETH( + MPTTester const eth( {.env = env, - .issuer = G1, - .holders = {A1, A2, A3, A4}, - .flags = tfMPTCanLock | MPTDEXFlags}); + .issuer = g1, + .holders = {a1, a2, a3, a4}, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = G1, - .holders = {A1, A2, A3, A4}, - .flags = tfMPTCanLock | MPTDEXFlags}); + .issuer = g1, + .holders = {a1, a2, a3, a4}, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - env(pay(G1, A1, ETH(1'000))); - env(pay(G1, A2, ETH(100))); - env(pay(G1, A3, BTC(100))); - env(pay(G1, A4, BTC(100))); + env(pay(g1, a1, eth(1'000))); + env(pay(g1, a2, eth(100))); + env(pay(g1, a3, btc(100))); + env(pay(g1, a4, btc(100))); env.close(); - AMM const ammG1(env, G1, XRP(10'000), ETH(100)); - env(offer(A1, XRP(10'000), ETH(100)), txflags(tfPassive)); - env(offer(A2, ETH(100), XRP(10'000)), txflags(tfPassive)); + AMM const ammG1(env, g1, XRP(10'000), eth(100)); + env(offer(a1, XRP(10'000), eth(100)), Txflags(tfPassive)); + env(offer(a2, eth(100), XRP(10'000)), Txflags(tfPassive)); env.close(); { // Account without Global Lock (proving operations normally // work) // visible offers where taker_pays is unlocked issuer - auto offers = getAccountOffers(env, A2)[jss::offers]; + auto offers = getAccountOffers(env, a2)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; // visible offers where taker_gets is unlocked issuer - offers = getAccountOffers(env, A1)[jss::offers]; + offers = getAccountOffers(env, a1)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; } @@ -3195,39 +3215,39 @@ private: { // Offers/Payments // assets can be bought on the market - AMM ammA3(env, A3, BTC(1), XRP(1)); + AMM ammA3(env, a3, btc(1), XRP(1)); // assets can be sold on the market // AMM is bidirectional - env(pay(G1, A2, ETH(1))); - env(pay(A2, G1, ETH(1))); - env(pay(A2, A1, ETH(1))); - env(pay(A1, A2, ETH(1))); + env(pay(g1, a2, eth(1))); + env(pay(a2, g1, eth(1))); + env(pay(a2, a1, eth(1))); + env(pay(a1, a2, eth(1))); ammA3.withdrawAll(std::nullopt); } { // Account with Global Lock // set Global Lock first - BTC.set({.flags = tfMPTLock}); + btc.set({.flags = tfMPTLock}); // assets can't be bought on the market - AMM const ammA3(env, A3, BTC(1), XRP(1), ter(tecFROZEN)); + AMM const ammA3(env, a3, btc(1), XRP(1), Ter(tecFROZEN)); // direct issues can be sent - env(pay(G1, A2, BTC(1))); - env(pay(A2, G1, BTC(1))); + env(pay(g1, a2, btc(1))); + env(pay(a2, g1, btc(1))); // locked - env(pay(A2, A1, BTC(1)), ter(tecPATH_DRY)); - env(pay(A1, A2, BTC(1)), ter(tecPATH_DRY)); + env(pay(a2, a1, btc(1)), Ter(tecPATH_DRY)); + env(pay(a1, a2, btc(1)), Ter(tecPATH_DRY)); } { - auto offers = getAccountOffers(env, A2)[jss::offers]; + auto offers = getAccountOffers(env, a2)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; - offers = getAccountOffers(env, A1)[jss::offers]; + offers = getAccountOffers(env, a1)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; } @@ -3241,63 +3261,63 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account A2{"A2"}; - Account A3{"A3"}; - Account A4{"A4"}; + Account const g1{"G1"}; + Account a2{"A2"}; + Account a3{"A3"}; + Account a4{"A4"}; - env.fund(XRP(2'000), G1, A3, A4); - env.fund(XRP(2'000), A2); + env.fund(XRP(2'000), g1, a3, a4); + env.fund(XRP(2'000), a2); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = G1, - .holders = {A2, A3, A4}, - .flags = tfMPTCanLock | MPTDEXFlags}); + .issuer = g1, + .holders = {a2, a3, a4}, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - env(pay(G1, A3, BTC(2'000))); - env(pay(G1, A4, BTC(2'001))); + env(pay(g1, a3, btc(2'000))); + env(pay(g1, a4, btc(2'001))); env.close(); - AMM const ammA3(env, A3, XRP(1'000), BTC(1'001)); + AMM const ammA3(env, a3, XRP(1'000), btc(1'001)); // removal after successful payment // test: make a payment with partially consuming offer - env(pay(A2, G1, BTC(1)), paths(MPT(BTC)), sendmax(XRP(1))); + env(pay(a2, g1, btc(1)), Paths(MPT(btc)), Sendmax(XRP(1))); env.close(); - BEAST_EXPECT(ammA3.expectBalances(XRP(1'001), BTC(1'000), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'001), btc(1'000), ammA3.tokens())); // test: someone else creates an offer providing liquidity - env(offer(A4, XRP(999), BTC(999))); + env(offer(a4, XRP(999), btc(999))); env.close(); // The offer consumes AMM offer - BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), BTC(1'001), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), btc(1'001), ammA3.tokens())); // test: AMM is Locked - BTC.set({.holder = ammA3.ammAccount(), .flags = tfMPTLock}); + btc.set({.holder = ammA3.ammAccount(), .flags = tfMPTLock}); auto const info = ammA3.ammRpcInfo(); BEAST_EXPECT(info[jss::amm][jss::asset2_frozen].asBool()); env.close(); // test: Can make a payment via the new offer - env(pay(A2, G1, BTC(1)), paths(MPT(BTC)), sendmax(XRP(1))); + env(pay(a2, g1, btc(1)), Paths(MPT(btc)), Sendmax(XRP(1))); env.close(); // AMM is not consumed - BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), BTC(1'001), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), btc(1'001), ammA3.tokens())); // removal buy successful OfferCreate // test: lock the new offer - BTC.set({.holder = A4, .flags = tfMPTUnlock}); + btc.set({.holder = a4, .flags = tfMPTUnlock}); env.close(); // test: can no longer create a crossing offer - env(offer(A2, BTC(999), XRP(999))); + env(offer(a2, btc(999), XRP(999))); env.close(); // test: offer was removed by offer_create - auto offers = getAccountOffers(env, A4)[jss::offers]; + auto offers = getAccountOffers(env, a4)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 0u))) return; } @@ -3309,52 +3329,52 @@ private: using namespace jtx; Env env{*this, features}; - Account const bogie{"bogie", KeyType::secp256k1}; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const zelda{"zelda", KeyType::secp256k1}; - fund(env, gw, {alice, becky, zelda}, XRP(20'000)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const zelda{"zelda", KeyType::Secp256k1}; + fund(env, gw_, {alice, becky, zelda}, XRP(20'000)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, + .issuer = gw_, .holders = {alice, becky, zelda}, .pay = 20'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // alice uses a regular key with the master disabled. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // Attach signers to alice. - env(signers(alice, 2, {{becky, 1}, {bogie, 1}}), sig(alie)); + env(signers(alice, 2, {{becky, 1}, {bogie, 1}}), Sig(alie)); env.close(); - int constexpr signerListOwners{2}; - env.require(owners(alice, signerListOwners + 0)); + int constexpr kSIGNER_LIST_OWNERS{2}; + env.require(Owners(alice, kSIGNER_LIST_OWNERS + 0)); - msig const ms{becky, bogie}; + Msig const ms{becky, bogie}; // Multisign all AMM transactions AMM ammAlice( env, alice, XRP(10'000), - BTC(10'000), + btc(10'000), false, 0, ammCrtFee(env).drops(), std::nullopt, std::nullopt, ms, - ter(tesSUCCESS)); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'000), ammAlice.tokens())); + Ter(tesSUCCESS)); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'000), ammAlice.tokens())); ammAlice.deposit(alice, 1'000'000); - BEAST_EXPECT(ammAlice.expectBalances(XRP(11'000), BTC(11'000), IOUAmount{11'000'000, 0})); + BEAST_EXPECT(ammAlice.expectBalances(XRP(11'000), btc(11'000), IOUAmount{11'000'000, 0})); ammAlice.withdraw(alice, 1'000'000); - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'000), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'000), ammAlice.tokens())); ammAlice.vote({}, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); @@ -3362,7 +3382,7 @@ private: env(ammAlice.bid({.account = alice, .bidMin = 100}), ms).close(); BEAST_EXPECT(ammAlice.expectAuctionSlot(100, 0, IOUAmount{4'000})); // 4000 tokens burnt - BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), BTC(10'000), IOUAmount{9'996'000, 0})); + BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), btc(10'000), IOUAmount{9'996'000, 0})); } void @@ -3376,36 +3396,36 @@ private: { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const ETH = issue1( + auto const eth = issue1( {.env = env, .token = "ETH", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, ETH(50000))); - env(pay(gw, bob, ETH(50000))); - env(pay(gw, carol, ETH(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, eth(50000))); + env(pay(gw_, bob_, eth(50000))); + env(pay(gw_, carol_, eth(50000))); env.close(); - AMM const bobXRP_BTC(env, bob, XRP(1'000), BTC(1'000)); - AMM const bobBTC_ETH(env, bob, BTC(1'000), ETH(1'000)); + AMM const bobXrpBtc(env, bob_, XRP(1'000), btc(1'000)); + AMM const bobBtcEth(env, bob_, btc(1'000), eth(1'000)); // payment path: XRP -> XRP/BTC -> BTC/ETH -> ETH/BTC - env(pay(alice, carol, BTC(100)), - path(~BTC, ~ETH, ~BTC), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, btc(100)), + Path(~btc, ~eth, ~btc), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper2TokensMix(test); } @@ -3419,85 +3439,85 @@ private: { Env env(*this, features); - fund(env, gw, {alice, bob}, XRP(10'000)); + fund(env, gw_, {alice_, bob_}, XRP(10'000)); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = bob, - .holders = {alice, gw}, + .issuer = bob_, + .holders = {alice_, gw_}, .pay = 100'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - MPTTester ETH( + MPTTester eth( {.env = env, - .issuer = bob, - .holders = {alice, gw}, + .issuer = bob_, + .holders = {alice_, gw_}, .pay = 100'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammXRP_BTC(env, bob, XRP(100), BTC(100'000)); - env(offer(gw, XRP(100), BTC(100'000)), txflags(tfPassive)); + AMM const ammXrpBtc(env, bob_, XRP(100), btc(100'000)); + env(offer(gw_, XRP(100), btc(100'000)), Txflags(tfPassive)); - AMM const ammBTC_ETH(env, bob, BTC(100'000), ETH(100'000)); - env(offer(gw, BTC(100'000), ETH(100'000)), txflags(tfPassive)); + AMM const ammBtcEth(env, bob_, btc(100'000), eth(100'000)); + env(offer(gw_, btc(100'000), eth(100'000)), Txflags(tfPassive)); - Path const p = [&] { - Path result; - result.push_back(allPathElements(gw, MPT(BTC))); - result.push_back(cpe(ETH.issuanceID())); + TestPath const p = [&] { + TestPath result; + result.pushBack(allPathElements(gw_, MPT(btc))); + result.pushBack(cpe(eth.issuanceID())); return result; }(); PathSet const paths(p); - env(pay(alice, alice, ETH(1'000)), - json(paths.json()), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(temBAD_PATH)); + env(pay(alice_, alice_, eth(1'000)), + Json(paths.json()), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(temBAD_PATH)); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, XRP(100), BTC(100)); + AMM const ammBob(env, bob_, XRP(100), btc(100)); // payment path: XRP -> XRP/BTC -> BTC/XRP - env(pay(alice, carol, XRP(100)), - path(~MPT(BTC), ~XRP), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_PATHS)); + env(pay(alice_, carol_, XRP(100)), + Path(~MPT(btc), ~XRP), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_PATHS)); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 100'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM const ammBob(env, bob, XRP(100), BTC(100)); + AMM const ammBob(env, bob_, XRP(100), btc(100)); // payment path: XRP -> XRP/BTC -> BTC/XRP - env(pay(alice, carol, XRP(100)), - path(~MPT(BTC), ~XRP), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_MAX)); + env(pay(alice_, carol_, XRP(100)), + Path(~MPT(btc), ~XRP), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_MAX)); } } @@ -3510,54 +3530,57 @@ private: { Env env(*this, features); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .flags = MPTDEXFlags}); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, + .flags = kMPT_DEX_FLAGS}); - env(pay(gw, bob, BTC(100'000'000))); - env(pay(gw, alice, BTC(100'000'000))); + env(pay(gw_, bob_, btc(100'000'000))); + env(pay(gw_, alice_, btc(100'000'000))); env.close(); - AMM const ammBob(env, bob, XRP(100), BTC(100'000'000)); + AMM const ammBob(env, bob_, XRP(100), btc(100'000'000)); // payment path: BTC -> BTC/XRP -> XRP/BTC - env(pay(alice, carol, BTC(100'000'000)), - sendmax(BTC(100'000'000)), - path(~XRP, ~MPT(BTC)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, btc(100'000'000)), + Sendmax(btc(100'000'000)), + Path(~XRP, ~MPT(btc)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { auto test = [&](auto&& issue1, auto&& issue2, auto&& issue3) { Env env(*this, features); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - auto const BTC = issue1( - {.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}}); - auto const ETH = issue2( - {.env = env, .token = "ETH", .issuer = gw, .holders = {alice, bob, carol}}); - auto const CNY = issue3( - {.env = env, .token = "CNY", .issuer = gw, .holders = {alice, bob, carol}}); + auto const btc = issue1( + {.env = env, .token = "BTC", .issuer = gw_, .holders = {alice_, bob_, carol_}}); + auto const eth = issue2( + {.env = env, .token = "ETH", .issuer = gw_, .holders = {alice_, bob_, carol_}}); + auto const cny = issue3( + {.env = env, .token = "CNY", .issuer = gw_, .holders = {alice_, bob_, carol_}}); - env(pay(gw, bob, BTC(200))); - env(pay(gw, bob, ETH(200))); - env(pay(gw, bob, CNY(100))); + env(pay(gw_, bob_, btc(200))); + env(pay(gw_, bob_, eth(200))); + env(pay(gw_, bob_, cny(100))); env.close(); - AMM const ammBobXRP_BTC(env, bob, XRP(100), BTC(100)); - AMM const ammBobBTC_ETH(env, bob, BTC(100), ETH(100)); - AMM const ammBobETH_CNY(env, bob, ETH(100), CNY(100)); + AMM const ammBobXrpBtc(env, bob_, XRP(100), btc(100)); + AMM const ammBobBtcEth(env, bob_, btc(100), eth(100)); + AMM const ammBobEthCny(env, bob_, eth(100), cny(100)); // payment path: XRP->XRP/BTC->BTC/ETH->BTC/CNY - env(pay(alice, carol, CNY(100)), - sendmax(XRP(100)), - path(~BTC, ~ETH, ~BTC, ~CNY), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, cny(100)), + Sendmax(XRP(100)), + Path(~btc, ~eth, ~btc, ~cny), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper3TokensMix(test); } @@ -3566,19 +3589,19 @@ private: void testPaths() { - path_find_consume_all(); - via_offers_via_gateway(); - receive_max(); - path_find_01(); - path_find_02(); - path_find_06(); + pathFindConsumeAll(); + viaOffersViaGateway(); + receiveMax(); + pathFind01(); + pathFind02(); + pathFind06(); } void testFlow() { using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testFalseDry(all); testBookStep(all); @@ -3591,7 +3614,7 @@ private: testCrossingLimits() { using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testStepLimit(all); } @@ -3599,14 +3622,14 @@ private: testDeliverMin() { using namespace jtx; - FeatureBitset const all{testable_amendments()}; - test_convert_all_of_an_asset(all); + FeatureBitset const all{testableAmendments()}; + testConvertAllOfAnAsset(all); } void testDepositAuth() { - auto const supported{jtx::testable_amendments()}; + auto const supported{jtx::testableAmendments()}; testPayment(supported); testPayMPT(); } @@ -3615,7 +3638,7 @@ private: testLock() { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testIndividualLock(sa); testGlobalLock(sa); testOffersWhenLocked(sa); @@ -3625,7 +3648,7 @@ private: testMultisign() { using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); testTxMultisign(all); } @@ -3634,7 +3657,7 @@ private: testPayStrand() { using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); testToStrand(all); testRIPD1373(all); diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 9eb7eb1620..8132c012ad 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -68,7 +68,7 @@ namespace xrpl::test { struct AMMExtended_test : public jtx::AMMTest { // Use small Number mantissas for the life of this test. - NumberMantissaScaleGuard const sg_{xrpl::MantissaRange::mantissa_scale::small}; + NumberMantissaScaleGuard const sg{xrpl::MantissaRange::MantissaScale::Small}; private: void @@ -89,28 +89,28 @@ private: Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, XRP(10'000), {USD(200'000), BTC(2'000)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {USD(200'000), BTC(2'000)}); // Must be two offers at the same quality // "taker gets" must be XRP // (Different amounts so I can distinguish the offers) - env(offer(carol, BTC(49), XRP(49))); - env(offer(carol, BTC(51), XRP(51))); + env(offer(carol_, BTC(49), XRP(49))); + env(offer(carol_, BTC(51), XRP(51))); // Offers for the poor quality path // Must be two offers at the same quality - env(offer(carol, XRP(50), USD(50))); - env(offer(carol, XRP(50), USD(50))); + env(offer(carol_, XRP(50), USD(50))); + env(offer(carol_, XRP(50), USD(50))); // Good quality path - AMM const ammCarol(env, carol, BTC(1'000), USD(100'100)); + AMM const ammCarol(env, carol_, BTC(1'000), USD(100'100)); - PathSet const paths(Path(XRP, USD), Path(USD)); + PathSet const paths(TestPath(XRP, USD), TestPath(USD)); - env(pay(alice, bob, USD(100)), - json(paths.json()), - sendmax(BTC(1'000)), - txflags(tfPartialPayment)); + env(pay(alice_, bob_, USD(100)), + Json(paths.json()), + Sendmax(BTC(1'000)), + Txflags(tfPartialPayment)); if (!features[fixAMMv1_1]) { @@ -123,8 +123,8 @@ private: STAmount{BTC, UINT64_C(1'001'000000374815), -12}, USD(100'000), ammCarol.tokens())); } - env.require(balance(bob, USD(200'100))); - BEAST_EXPECT(isOffer(env, carol, BTC(49), XRP(49))); + env.require(Balance(bob_, USD(200'100))); + BEAST_EXPECT(isOffer(env, carol_, BTC(49), XRP(49))); } void @@ -140,29 +140,29 @@ private: Account const dan("dan"); Account const gw1("gw1"); Account const gw2("gw2"); - auto const USD1 = gw1["USD"]; - auto const USD2 = gw2["USD"]; + auto const usD1 = gw1["USD"]; + auto const usD2 = gw2["USD"]; - env.fund(XRP(20'000), alice, noripple(bob), carol, dan, gw1, gw2); + env.fund(XRP(20'000), alice_, noripple(bob_), carol_, dan, gw1, gw2); env.close(); - env.trust(USD1(20'000), alice, carol, dan); - env(trust(bob, USD1(1'000), tfSetNoRipple)); - env.trust(USD2(1'000), alice, carol, dan); - env(trust(bob, USD2(1'000), tfSetNoRipple)); + env.trust(usD1(20'000), alice_, carol_, dan); + env(trust(bob_, usD1(1'000), tfSetNoRipple)); + env.trust(usD2(1'000), alice_, carol_, dan); + env(trust(bob_, usD2(1'000), tfSetNoRipple)); env.close(); - env(pay(gw1, dan, USD1(10'000))); - env(pay(gw1, bob, USD1(50))); - env(pay(gw2, bob, USD2(50))); + env(pay(gw1, dan, usD1(10'000))); + env(pay(gw1, bob_, usD1(50))); + env(pay(gw2, bob_, usD2(50))); env.close(); - AMM const ammDan(env, dan, XRP(10'000), USD1(10'000)); + AMM const ammDan(env, dan, XRP(10'000), usD1(10'000)); - env(pay(alice, carol, USD2(50)), - path(~USD1, bob), - sendmax(XRP(50)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, usD2(50)), + Path(~usD1, bob_), + Sendmax(XRP(50)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); } { @@ -172,33 +172,33 @@ private: Account const dan("dan"); Account const gw1("gw1"); Account const gw2("gw2"); - auto const USD1 = gw1["USD"]; - auto const USD2 = gw2["USD"]; + auto const usD1 = gw1["USD"]; + auto const usD2 = gw2["USD"]; - env.fund(XRP(20'000), alice, bob, carol, gw1, gw2); + env.fund(XRP(20'000), alice_, bob_, carol_, gw1, gw2); env.fund(XRP(20'000), dan); env.close(); - env.trust(USD1(20'000), alice, bob, carol, dan); - env.trust(USD2(1'000), alice, bob, carol, dan); + env.trust(usD1(20'000), alice_, bob_, carol_, dan); + env.trust(usD2(1'000), alice_, bob_, carol_, dan); env.close(); - env(pay(gw1, dan, USD1(10'050))); - env(pay(gw1, bob, USD1(50))); - env(pay(gw2, bob, USD2(50))); + env(pay(gw1, dan, usD1(10'050))); + env(pay(gw1, bob_, usD1(50))); + env(pay(gw2, bob_, usD2(50))); env.close(); - AMM const ammDan(env, dan, XRP(10'000), USD1(10'050)); + AMM const ammDan(env, dan, XRP(10'000), usD1(10'050)); - env(pay(alice, carol, USD2(50)), - path(~USD1, bob), - sendmax(XRP(50)), - txflags(tfNoRippleDirect)); - BEAST_EXPECT(ammDan.expectBalances(XRP(10'050), USD1(10'000), ammDan.tokens())); + env(pay(alice_, carol_, usD2(50)), + Path(~usD1, bob_), + Sendmax(XRP(50)), + Txflags(tfNoRippleDirect)); + BEAST_EXPECT(ammDan.expectBalances(XRP(10'050), usD1(10'000), ammDan.tokens())); - BEAST_EXPECT(expectLedgerEntryRoot(env, alice, XRP(20'000) - XRP(50) - txfee(env, 1))); - BEAST_EXPECT(expectHolding(env, bob, USD1(100))); - BEAST_EXPECT(expectHolding(env, bob, USD2(0))); - BEAST_EXPECT(expectHolding(env, carol, USD2(50))); + BEAST_EXPECT(expectLedgerEntryRoot(env, alice_, XRP(20'000) - XRP(50) - txFee(env, 1))); + BEAST_EXPECT(expectHolding(env, bob_, usD1(100))); + BEAST_EXPECT(expectHolding(env, bob_, usD2(0))); + BEAST_EXPECT(expectHolding(env, carol_, usD2(50))); } } @@ -217,21 +217,21 @@ private: [&](AMM& ammAlice, Env& env) { // Order that can't be filled TER const killedCode{TER{tecKILLED}}; - env(offer(carol, USD(100), XRP(100)), txflags(tfFillOrKill), ter(killedCode)); + env(offer(carol_, USD(100), XRP(100)), Txflags(tfFillOrKill), Ter(killedCode)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // fee = AMM - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRP(30'000) - (txfee(env, 1)))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + BEAST_EXPECT(expectLedgerEntryRoot(env, carol_, XRP(30'000) - (txFee(env, 1)))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); // Order that can be filled - env(offer(carol, XRP(100), USD(100)), txflags(tfFillOrKill), ter(tesSUCCESS)); + env(offer(carol_, XRP(100), USD(100)), Txflags(tfFillOrKill), Ter(tesSUCCESS)); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'100), ammAlice.tokens())); BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRP(30'000) + XRP(100) - txfee(env, 2))); - BEAST_EXPECT(expectHolding(env, carol, USD(29'900))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + expectLedgerEntryRoot(env, carol_, XRP(30'000) + XRP(100) - txFee(env, 2))); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'900))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, {{XRP(10'100), USD(10'000)}}, 0, @@ -242,19 +242,19 @@ private: // and add nothing on the books. testAMM( [&](AMM& ammAlice, Env& env) { - env(offer(carol, XRP(200), USD(200)), - txflags(tfImmediateOrCancel), - ter(tesSUCCESS)); + env(offer(carol_, XRP(200), USD(200)), + Txflags(tfImmediateOrCancel), + Ter(tesSUCCESS)); // AMM generates a synthetic offer of 100USD/100XRP // to match the CLOB offer quality. BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'100), ammAlice.tokens())); // +AMM - offer * fee BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRP(30'000) + XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, carol_, XRP(30'000) + XRP(100) - txFee(env, 1))); // AMM - BEAST_EXPECT(expectHolding(env, carol, USD(29'900))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'900))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, {{XRP(10'100), USD(10'000)}}, 0, @@ -266,11 +266,11 @@ private: [&](AMM& ammAlice, Env& env) { // Carol creates a passive offer that could cross AMM. // Carol's offer should stay in the ledger. - env(offer(carol, XRP(100), USD(100), tfPassive)); + env(offer(carol_, XRP(100), USD(100), tfPassive)); env.close(); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), STAmount{USD, 10'000}, ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 1, {{{XRP(100), STAmount{USD, 100}}}})); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{{XRP(100), STAmount{USD, 100}}}})); }, {{XRP(10'100), USD(10'000)}}, 0, @@ -280,19 +280,19 @@ private: // tfPassive -- cross only offers of better quality. testAMM( [&](AMM& ammAlice, Env& env) { - env(offer(alice, USD(110), XRP(100))); + env(offer(alice_, USD(110), XRP(100))); env.close(); // Carol creates a passive offer. That offer should cross // AMM and leave Alice's offer untouched. - env(offer(carol, XRP(100), USD(100), tfPassive)); + env(offer(carol_, XRP(100), USD(100), tfPassive)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'900), STAmount{USD, UINT64_C(9'082'56880733945), -11}, ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, alice, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 1)); }, {{XRP(11'000), USD(9'000)}}, 0, @@ -309,23 +309,23 @@ private: Env env{*this, features}; - fund(env, gw, {bob, alice}, XRP(300'000), {USD(100)}, Fund::All); + fund(env, gw_, {bob_, alice_}, XRP(300'000), {USD(100)}, Fund::All); - AMM const ammAlice(env, alice, XRP(150'000), USD(50)); + AMM const ammAlice(env, alice_, XRP(150'000), USD(50)); // Existing offer pays better than this wants. // Partially consume existing offer. // Pay 1 USD, get 3061224490 Drops. auto const xrpTransferred = XRPAmount{3'061'224'490}; - env(offer(bob, USD(1), XRP(4'000))); + env(offer(bob_, USD(1), XRP(4'000))); BEAST_EXPECT(ammAlice.expectBalances( XRP(150'000) + xrpTransferred, USD(49), IOUAmount{273'861'278752583, -8})); - BEAST_EXPECT(expectHolding(env, bob, STAmount{USD, 101})); + BEAST_EXPECT(expectHolding(env, bob_, STAmount{USD, 101})); BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(300'000) - xrpTransferred - txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + expectLedgerEntryRoot(env, bob_, XRP(300'000) - xrpTransferred - txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } void @@ -337,21 +337,21 @@ private: Env env{*this, features}; - env.fund(XRP(200'000), gw, alice, bob); + env.fund(XRP(200'000), gw_, alice_, bob_); env.close(); - env(trust(alice, USD(1'000))); + env(trust(alice_, USD(1'000))); - env(pay(gw, alice, alice["USD"](500))); + env(pay(gw_, alice_, alice_["USD"](500))); - AMM const ammAlice(env, alice, XRP(150'000), USD(51)); - env(offer(bob, USD(1), XRP(3'000))); + AMM const ammAlice(env, alice_, XRP(150'000), USD(51)); + env(offer(bob_, USD(1), XRP(3'000))); BEAST_EXPECT(ammAlice.expectBalances(XRP(153'000), USD(50), ammAlice.tokens())); - auto jrr = ledgerEntryState(env, bob, gw, "USD"); + auto jrr = ledgerEntryState(env, bob_, gw_, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-1"); - jrr = ledgerEntryRoot(env, bob); + jrr = ledgerEntryRoot(env, bob_); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string((XRP(200'000) - XRP(3'000) - env.current()->fees().base * 1).xrp())); @@ -366,24 +366,24 @@ private: Env env{*this, features}; - fund(env, gw, {alice, bob}, XRP(10'000)); - env.require(owners(bob, 0)); + fund(env, gw_, {alice_, bob_}, XRP(10'000)); + env.require(Owners(bob_, 0)); - env(trust(alice, USD(100))); - env(trust(bob, USD(1'000))); - env(pay(gw, bob, USD(1'000))); + env(trust(alice_, USD(100))); + env(trust(bob_, USD(1'000))); + env(pay(gw_, bob_, USD(1'000))); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice_, 1), Owners(bob_, 1)); - env(pay(gw, alice, alice["USD"](100))); - AMM const ammBob(env, bob, USD(200), XRP(1'500)); + env(pay(gw_, alice_, alice_["USD"](100))); + AMM const ammBob(env, bob_, USD(200), XRP(1'500)); - env(pay(alice, alice, XRP(500)), sendmax(USD(100))); + env(pay(alice_, alice_, XRP(500)), Sendmax(USD(100))); BEAST_EXPECT(ammBob.expectBalances(USD(300), XRP(1'000), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, alice, USD(0))); + BEAST_EXPECT(expectHolding(env, alice_, USD(0))); - auto jrr = ledgerEntryRoot(env, alice); + auto jrr = ledgerEntryRoot(env, alice_); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string((XRP(10'000) + XRP(500) - env.current()->fees().base * 2).xrp())); @@ -400,22 +400,22 @@ private: [&](AMM& ammAlice, Env& env) { // Alice converts USD to XRP which should fail // due to PartialPayment. - env(pay(alice, alice, XRP(100)), sendmax(USD(100)), ter(tecPATH_PARTIAL)); + env(pay(alice_, alice_, XRP(100)), Sendmax(USD(100)), Ter(tecPATH_PARTIAL)); // Alice converts USD to XRP, should succeed because // we permit partial payment - env(pay(alice, alice, XRP(100)), sendmax(USD(100)), txflags(tfPartialPayment)); + env(pay(alice_, alice_, XRP(100)), Sendmax(USD(100)), Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{9'900'990'100}, USD(10'100), ammAlice.tokens())); // initial 30,000 - 10,000AMM - 100pay - BEAST_EXPECT(expectHolding(env, alice, USD(19'900))); + BEAST_EXPECT(expectHolding(env, alice_, USD(19'900))); // initial 30,000 - 10,0000AMM + 99.009900pay - fee*3 BEAST_EXPECT(expectLedgerEntryRoot( env, - alice, + alice_, XRP(30'000) - XRP(10'000) + XRPAmount{99'009'900} - ammCrtFee(env) - - txfee(env, 2))); + txFee(env, 2))); }, {{XRP(10'000), USD(10'000)}}, 0, @@ -432,13 +432,13 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); - env(trust(bob, USD(100))); + env(trust(bob_, USD(100))); env.close(); - env(pay(alice, bob, USD(100)), sendmax(XRP(100))); + env(pay(alice_, bob_, USD(100)), Sendmax(XRP(100))); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, bob, USD(100))); + BEAST_EXPECT(expectHolding(env, bob_, USD(100))); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -455,14 +455,14 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); - env(trust(bob, USD(100))); + env(trust(bob_, USD(100))); env.close(); - env(pay(alice, bob, XRP(100)), sendmax(USD(100))); + env(pay(alice_, bob_, XRP(100)), Sendmax(USD(100))); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'100), ammAlice.tokens())); BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(1'000) + XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(1'000) + XRP(100) - txFee(env, 1))); }, {{XRP(10'100), USD(10'000)}}, 0, @@ -482,38 +482,38 @@ private: auto const gw1 = Account{"gateway_1"}; auto const gw2 = Account{"gateway_2"}; auto const dan = Account{"dan"}; - auto const USD1 = gw1["USD"]; - auto const EUR1 = gw2["EUR"]; + auto const usD1 = gw1["USD"]; + auto const euR1 = gw2["EUR"]; - fund(env, gw1, {gw2, alice, bob, carol, dan}, XRP(60'000)); - env(trust(alice, USD1(1'000))); + fund(env, gw1, {gw2, alice_, bob_, carol_, dan}, XRP(60'000)); + env(trust(alice_, usD1(1'000))); env.close(); - env(trust(bob, EUR1(1'000))); + env(trust(bob_, euR1(1'000))); env.close(); - env(trust(carol, USD1(10'000))); + env(trust(carol_, usD1(10'000))); env.close(); - env(trust(dan, EUR1(1'000))); + env(trust(dan, euR1(1'000))); env.close(); - env(pay(gw1, alice, alice["USD"](500))); + env(pay(gw1, alice_, alice_["USD"](500))); env.close(); - env(pay(gw1, carol, carol["USD"](6'000))); + env(pay(gw1, carol_, carol_["USD"](6'000))); env(pay(gw2, dan, dan["EUR"](400))); env.close(); - AMM const ammCarol(env, carol, USD1(5'000), XRP(50'000)); + AMM const ammCarol(env, carol_, usD1(5'000), XRP(50'000)); - env(offer(dan, XRP(500), EUR1(50))); + env(offer(dan, XRP(500), euR1(50))); env.close(); - Json::Value jtp{Json::arrayValue}; + json::Value jtp{json::ArrayValue}; jtp[0u][0u][jss::currency] = "XRP"; - env(pay(alice, bob, EUR1(30)), json(jss::Paths, jtp), sendmax(USD1(333))); + env(pay(alice_, bob_, euR1(30)), Json(jss::Paths, jtp), Sendmax(usD1(333))); env.close(); BEAST_EXPECT(ammCarol.expectBalances( - XRP(49'700), STAmount{USD1, UINT64_C(5'030'181086519115), -12}, ammCarol.tokens())); + XRP(49'700), STAmount{usD1, UINT64_C(5'030'181086519115), -12}, ammCarol.tokens())); BEAST_EXPECT(expectOffers(env, dan, 1, {{Amounts{XRP(200), EUR(20)}}})); - BEAST_EXPECT(expectHolding(env, bob, STAmount{EUR1, 30})); + BEAST_EXPECT(expectHolding(env, bob_, STAmount{euR1, 30})); } void @@ -528,46 +528,46 @@ private: auto const gw1 = Account{"gateway_1"}; auto const gw2 = Account{"gateway_2"}; auto const gw3 = Account{"gateway_3"}; - auto const alice = Account{"alice"}; - auto const bob = Account{"bob"}; - auto const USD1 = gw1["USD"]; - auto const USD2 = gw2["USD"]; - auto const USD3 = gw3["USD"]; + auto const localAlice = Account{"alice"}; + auto const localBob = Account{"bob"}; + auto const usD1 = gw1["USD"]; + auto const usD2 = gw2["USD"]; + auto const usD3 = gw3["USD"]; // Provide micro amounts to compensate for fees to make results round // nice. // reserve: Alice has 3 entries in the ledger, via trust lines // fees: - // 1 for each trust limit == 3 (alice < mtgox/amazon/bitstamp) + + // 1 for each trust limit == 3 (alice_ < mtgox/amazon/bitstamp) + // 1 for payment == 4 - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(3) + env.current()->fees().base * 4; - env.fund(starting_xrp, gw1, gw2, gw3, alice); - env.fund(XRP(2'000), bob); + env.fund(startingXrp, gw1, gw2, gw3, localAlice); + env.fund(XRP(2'000), localBob); env.close(); - env(trust(alice, USD1(1'000))); - env(trust(alice, USD2(1'000))); - env(trust(alice, USD3(1'000))); - env(trust(bob, USD1(1'200))); - env(trust(bob, USD2(1'100))); + env(trust(localAlice, usD1(1'000))); + env(trust(localAlice, usD2(1'000))); + env(trust(localAlice, usD3(1'000))); + env(trust(localBob, usD1(1'200))); + env(trust(localBob, usD2(1'100))); - env(pay(gw1, bob, bob["USD"](1'200))); + env(pay(gw1, localBob, localBob["USD"](1'200))); - AMM const ammBob(env, bob, XRP(1'000), USD1(1'200)); + AMM const ammBob(env, localBob, XRP(1'000), usD1(1'200)); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. - env(offer(alice, USD1(200), XRP(200))); + env(offer(localAlice, usD1(200), XRP(200))); // The pool gets only 100XRP for ~109.09USD, even though // it can exchange more. BEAST_EXPECT(ammBob.expectBalances( - XRP(1'100), STAmount{USD1, UINT64_C(1'090'909090909091), -12}, ammBob.tokens())); + XRP(1'100), STAmount{usD1, UINT64_C(1'090'909090909091), -12}, ammBob.tokens())); - auto jrr = ledgerEntryState(env, alice, gw1, "USD"); + auto jrr = ledgerEntryState(env, localAlice, gw1, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "109.090909090909"); - jrr = ledgerEntryRoot(env, alice); + jrr = ledgerEntryRoot(env, localAlice); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName] == XRP(350).value().getText()); } @@ -580,22 +580,22 @@ private: Env env{*this, features}; - fund(env, gw, {alice, bob}, XRP(200'000)); + fund(env, gw_, {alice_, bob_}, XRP(200'000)); - env(rate(gw, 1.005)); + env(rate(gw_, 1.005)); - env(trust(alice, USD(1'000))); - env(trust(bob, USD(1'000))); + env(trust(alice_, USD(1'000))); + env(trust(bob_, USD(1'000))); - env(pay(gw, bob, USD(1))); - env(pay(gw, alice, USD(200))); + env(pay(gw_, bob_, USD(1))); + env(pay(gw_, alice_, USD(200))); - AMM const ammAlice(env, alice, USD(150), XRP(150'100)); - env(offer(bob, XRP(100), USD(0.1))); + AMM const ammAlice(env, alice_, USD(150), XRP(150'100)); + env(offer(bob_, XRP(100), USD(0.1))); BEAST_EXPECT(ammAlice.expectBalances(USD(150.1), XRP(150'000), ammAlice.tokens())); - auto const jrr = ledgerEntryState(env, bob, gw, "USD"); + auto const jrr = ledgerEntryState(env, bob_, gw_, "USD"); // Bob pays 0.005 transfer fee. Note 10**-10 round-off. BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-0.8995000001"); } @@ -609,13 +609,13 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { - env(offer(carol, USD(100), XRP(100)), json(jss::Flags, tfSell)); + env(offer(carol_, USD(100), XRP(100)), Json(jss::Flags, tfSell)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(9'999), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectHolding(env, carol, USD(30'101))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'101))); BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, carol_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, {{XRP(9'900), USD(10'100)}}, 0, @@ -632,28 +632,28 @@ private: Env env{*this, features}; - auto const starting_xrp = XRP(100) + reserve(env, 1) + env.current()->fees().base * 2; + auto const startingXrp = XRP(100) + reserve(env, 1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice); - env.fund(XRP(2'000), bob); + env.fund(startingXrp, gw_, alice_); + env.fund(XRP(2'000), bob_); env.close(); - env(trust(alice, USD(150))); - env(trust(bob, USD(4'000))); + env(trust(alice_, USD(150))); + env(trust(bob_, USD(4'000))); - env(pay(gw, bob, bob["USD"](2'200))); + env(pay(gw_, bob_, bob_["USD"](2'200))); - AMM const ammBob(env, bob, XRP(1'000), USD(2'200)); + AMM const ammBob(env, bob_, XRP(1'000), USD(2'200)); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. // Taker pays 100 USD for 100 XRP. // Selling XRP. // Will sell all 100 XRP and get more USD than asked for. - env(offer(alice, USD(100), XRP(200)), json(jss::Flags, tfSell)); + env(offer(alice_, USD(100), XRP(200)), Json(jss::Flags, tfSell)); BEAST_EXPECT(ammBob.expectBalances(XRP(1'100), USD(2'000), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, alice, USD(200))); - BEAST_EXPECT(expectLedgerEntryRoot(env, alice, XRP(250))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectHolding(env, alice_, USD(200))); + BEAST_EXPECT(expectLedgerEntryRoot(env, alice_, XRP(250))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } void @@ -665,23 +665,23 @@ private: Env env{*this, features}; - auto const XTS = gw["XTS"]; - auto const XXX = gw["XXX"]; + auto const xts = gw_["XTS"]; + auto const xxx = gw_["XXX"]; - auto const starting_xrp = XRP(100.1) + reserve(env, 1) + env.current()->fees().base * 2; - fund(env, gw, {alice, bob}, starting_xrp, {XTS(100), XXX(100)}, Fund::All); + auto const startingXrp = XRP(100.1) + reserve(env, 1) + env.current()->fees().base * 2; + fund(env, gw_, {alice_, bob_}, startingXrp, {xts(100), xxx(100)}, Fund::All); - AMM const ammAlice(env, alice, XTS(100), XXX(100)); + AMM const ammAlice(env, alice_, xts(100), xxx(100)); - Json::Value payment; + json::Value payment; payment[jss::secret] = toBase58(generateSeed("bob")); - payment[jss::id] = env.seq(bob); + payment[jss::id] = env.seq(bob_); payment[jss::build_path] = true; - payment[jss::tx_json] = pay(bob, bob, bob["XXX"](1)); + payment[jss::tx_json] = pay(bob_, bob_, bob_["XXX"](1)); payment[jss::tx_json][jss::Sequence] = - env.current()->read(keylet::account(bob.id()))->getFieldU32(sfSequence); + env.current()->read(keylet::account(bob_.id()))->getFieldU32(sfSequence); payment[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); - payment[jss::tx_json][jss::SendMax] = bob["XTS"](1.5).value().getJson(JsonOptions::none); + payment[jss::tx_json][jss::SendMax] = bob_["XTS"](1.5).value().getJson(JsonOptions::KNone); payment[jss::tx_json][jss::Flags] = tfPartialPayment; auto const jrr = env.rpc("json", "submit", to_string(payment)); BEAST_EXPECT(jrr[jss::result][jss::status] == "success"); @@ -689,16 +689,16 @@ private: if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( - STAmount(XTS, UINT64_C(101'010101010101), -12), XXX(99), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, bob, STAmount{XTS, UINT64_C(98'989898989899), -12})); + STAmount(xts, UINT64_C(101'010101010101), -12), xxx(99), ammAlice.tokens())); + BEAST_EXPECT(expectHolding(env, bob_, STAmount{xts, UINT64_C(98'989898989899), -12})); } else { BEAST_EXPECT(ammAlice.expectBalances( - STAmount(XTS, UINT64_C(101'0101010101011), -13), XXX(99), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, bob, STAmount{XTS, UINT64_C(98'9898989898989), -13})); + STAmount(xts, UINT64_C(101'0101010101011), -13), xxx(99), ammAlice.tokens())); + BEAST_EXPECT(expectHolding(env, bob_, STAmount{xts, UINT64_C(98'9898989898989), -13})); } - BEAST_EXPECT(expectHolding(env, bob, XXX(101))); + BEAST_EXPECT(expectHolding(env, bob_, xxx(101))); } void @@ -711,83 +711,83 @@ private: { Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(15'000), EUR(15'000)}, Fund::All); + fund(env, gw_, {alice_, bob_, carol_}, {USD(15'000), EUR(15'000)}, Fund::All); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP AMM is created. - // o carol has EUR but wants USD. - // Note that carol's offer must come last. If carol's offer is + // o carol_ has EUR but wants USD. + // Note that carol_'s offer must come last. If carol_'s offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - AMM const ammBob(env, bob, EUR(10'000), XRP(10'100)); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + AMM const ammBob(env, bob_, EUR(10'000), XRP(10'100)); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), EUR(10'100), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(15'100))); - BEAST_EXPECT(expectHolding(env, carol, EUR(14'900))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(15'100))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(14'900))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } { Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(15'000), EUR(15'000)}, Fund::All); + fund(env, gw_, {alice_, bob_, carol_}, {USD(15'000), EUR(15'000)}, Fund::All); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP offer is created. - // o carol has EUR but wants USD. - // Note that carol's offer must come last. If carol's offer is - // placed before AMM and bob's offer are created, then autobridging + // o carol_ has EUR but wants USD. + // Note that carol_'s offer must come last. If carol_'s offer is + // placed before AMM and bob_'s offer are created, then autobridging // will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - env(offer(bob, EUR(100), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + env(offer(bob_, EUR(100), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(15'100))); - BEAST_EXPECT(expectHolding(env, carol, EUR(14'900))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(15'100))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(14'900))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(15'000), EUR(15'000)}, Fund::All); + fund(env, gw_, {alice_, bob_, carol_}, {USD(15'000), EUR(15'000)}, Fund::All); // The scenario: // o USD/XRP offer is created. // o EUR/XRP AMM is created. - // o carol has EUR but wants USD. - // Note that carol's offer must come last. If carol's offer is - // placed before AMM and alice's offer are created, then + // o carol_ has EUR but wants USD. + // Note that carol_'s offer must come last. If carol_'s offer is + // placed before AMM and alice_'s offer are created, then // autobridging will not occur. - env(offer(alice, XRP(100), USD(100))); + env(offer(alice_, XRP(100), USD(100))); env.close(); - AMM const ammBob(env, bob, EUR(10'000), XRP(10'100)); + AMM const ammBob(env, bob_, EUR(10'000), XRP(10'100)); // Carol makes an offer that consumes AMM liquidity and // fully consumes Carol's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); BEAST_EXPECT(ammBob.expectBalances(XRP(10'000), EUR(10'100), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(15'100))); - BEAST_EXPECT(expectHolding(env, carol, EUR(14'900))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(15'100))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(14'900))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } } @@ -805,58 +805,58 @@ private: { Env env{*this, features}; - fund(env, gw, {alice, bob}, {USD(20'000)}, Fund::All); - AMM const ammBob(env, bob, XRP(20'000), USD(200)); - // alice submits a tfSell | tfFillOrKill offer that does not cross. - env(offer(alice, USD(2.1), XRP(210), tfSell | tfFillOrKill), ter(killedCode)); + fund(env, gw_, {alice_, bob_}, {USD(20'000)}, Fund::All); + AMM const ammBob(env, bob_, XRP(20'000), USD(200)); + // alice_ submits a tfSell | tfFillOrKill offer that does not cross. + env(offer(alice_, USD(2.1), XRP(210), tfSell | tfFillOrKill), Ter(killedCode)); BEAST_EXPECT(ammBob.expectBalances(XRP(20'000), USD(200), ammBob.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { Env env{*this, features}; - fund(env, gw, {alice, bob}, {USD(1'000)}, Fund::All); - AMM const ammBob(env, bob, XRP(20'000), USD(200)); - // alice submits a tfSell | tfFillOrKill offer that crosses. + fund(env, gw_, {alice_, bob_}, {USD(1'000)}, Fund::All); + AMM const ammBob(env, bob_, XRP(20'000), USD(200)); + // alice_ submits a tfSell | tfFillOrKill offer that crosses. // Even though tfSell is present it doesn't matter this time. - env(offer(alice, USD(2), XRP(220), tfSell | tfFillOrKill)); + env(offer(alice_, USD(2), XRP(220), tfSell | tfFillOrKill)); env.close(); BEAST_EXPECT(ammBob.expectBalances( XRP(20'220), STAmount{USD, UINT64_C(197'8239366963403), -13}, ammBob.tokens())); BEAST_EXPECT( - expectHolding(env, alice, STAmount{USD, UINT64_C(1'002'17606330366), -11})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + expectHolding(env, alice_, STAmount{USD, UINT64_C(1'002'17606330366), -11})); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { - // alice submits a tfSell | tfFillOrKill offer that crosses and + // alice_ submits a tfSell | tfFillOrKill offer that crosses and // returns more than was asked for (because of the tfSell flag). Env env{*this, features}; - fund(env, gw, {alice, bob}, {USD(1'000)}, Fund::All); - AMM const ammBob(env, bob, XRP(20'000), USD(200)); + fund(env, gw_, {alice_, bob_}, {USD(1'000)}, Fund::All); + AMM const ammBob(env, bob_, XRP(20'000), USD(200)); - env(offer(alice, USD(10), XRP(1'500), tfSell | tfFillOrKill)); + env(offer(alice_, USD(10), XRP(1'500), tfSell | tfFillOrKill)); env.close(); BEAST_EXPECT(ammBob.expectBalances( XRP(21'500), STAmount{USD, UINT64_C(186'046511627907), -12}, ammBob.tokens())); BEAST_EXPECT( - expectHolding(env, alice, STAmount{USD, UINT64_C(1'013'953488372093), -12})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + expectHolding(env, alice_, STAmount{USD, UINT64_C(1'013'953488372093), -12})); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { - // alice submits a tfSell | tfFillOrKill offer that doesn't cross. + // alice_ submits a tfSell | tfFillOrKill offer that doesn't cross. // This would have succeeded with a regular tfSell, but the // fillOrKill prevents the transaction from crossing since not // all of the offer is consumed because AMM generated offer, - // which matches alice's offer quality is ~ 10XRP/0.01996USD. + // which matches alice_'s offer quality is ~ 10XRP/0.01996USD. Env env{*this, features}; - fund(env, gw, {alice, bob}, {USD(10'000)}, Fund::All); - AMM const ammBob(env, bob, XRP(5000), USD(10)); + fund(env, gw_, {alice_, bob_}, {USD(10'000)}, Fund::All); + AMM const ammBob(env, bob_, XRP(5000), USD(10)); - env(offer(alice, USD(1), XRP(501), tfSell | tfFillOrKill), ter(tecKILLED)); + env(offer(alice_, USD(1), XRP(501), tfSell | tfFillOrKill), Ter(tecKILLED)); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } } @@ -870,16 +870,16 @@ private: // AMM XRP/USD. Alice places USD/XRP offer. testAMM( [&](AMM& ammAlice, Env& env) { - env(rate(gw, 1.25)); + env(rate(gw_, 1.25)); env.close(); - env(offer(carol, USD(100), XRP(100))); + env(offer(carol_, USD(100), XRP(100))); env.close(); // AMM doesn't pay the transfer fee BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -890,16 +890,16 @@ private: // in return for USD. testAMM( [&](AMM& ammAlice, Env& env) { - env(rate(gw, 1.25)); + env(rate(gw_, 1.25)); env.close(); - env(offer(carol, XRP(100), USD(100))); + env(offer(carol_, XRP(100), USD(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'100), ammAlice.tokens())); // Carol pays 25% transfer fee - BEAST_EXPECT(expectHolding(env, carol, USD(29'875))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'875))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); }, {{XRP(10'100), USD(10'000)}}, 0, @@ -909,53 +909,53 @@ private: { // Bridged crossing. Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(15'000), EUR(15'000)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_, carol_}, {USD(15'000), EUR(15'000)}, Fund::All); + env(rate(gw_, 1.25)); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP Offer is created. - // o carol has EUR but wants USD. + // o carol_ has EUR but wants USD. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - env(offer(bob, EUR(100), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + env(offer(bob_, EUR(100), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Bob's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); // AMM doesn't pay the transfer fee BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(15'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(15'100))); // Carol pays 25% transfer fee. - BEAST_EXPECT(expectHolding(env, carol, EUR(14'875))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, EUR(14'875))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { // Bridged crossing. The transfer fee is paid on the step not // involving AMM as src/dst. Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(15'000), EUR(15'000)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_, carol_}, {USD(15'000), EUR(15'000)}, Fund::All); + env(rate(gw_, 1.25)); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP Offer is created. - // o carol has EUR but wants USD. + // o carol_ has EUR but wants USD. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'050)); - env(offer(bob, EUR(100), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'050)); + env(offer(bob_, EUR(100), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // partially consumes Bob's offer. - env(offer(carol, USD(50), EUR(50))); + env(offer(carol_, USD(50), EUR(50))); env.close(); // This test verifies that the amount removed from an offer // accounts for the transfer fee that is removed from the @@ -963,11 +963,11 @@ private: // AMM doesn't pay the transfer fee BEAST_EXPECT(ammAlice.expectBalances(XRP(10'050), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(15'050))); + BEAST_EXPECT(expectHolding(env, carol_, USD(15'050))); // Carol pays 25% transfer fee. - BEAST_EXPECT(expectHolding(env, carol, EUR(14'937.5))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 1, {{Amounts{EUR(50), XRP(50)}}})); + BEAST_EXPECT(expectHolding(env, carol_, EUR(14'937.5))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{Amounts{EUR(50), XRP(50)}}})); } { @@ -975,42 +975,42 @@ private: // Bridged crossing. The transfer fee is paid on the step not // involving AMM as src/dst. Env env{*this, features}; - fund(env, gw, {alice, carol, bob}, XRP(30'000)); - env(rate(gw, 1.25)); - env(trust(alice, USD(15'000))); - env(trust(bob, EUR(15'000))); - env(trust(carol, EUR(15'000)), qualityInPercent(80)); - env(trust(bob, USD(15'000))); - env(trust(carol, USD(15'000))); + fund(env, gw_, {alice_, carol_, bob_}, XRP(30'000)); + env(rate(gw_, 1.25)); + env(trust(alice_, USD(15'000))); + env(trust(bob_, EUR(15'000))); + env(trust(carol_, EUR(15'000)), QualityInPercent(80)); + env(trust(bob_, USD(15'000))); + env(trust(carol_, USD(15'000))); env.close(); - env(pay(gw, alice, USD(11'000))); - env(pay(gw, carol, EUR(1'000)), sendmax(EUR(10'000))); + env(pay(gw_, alice_, USD(11'000))); + env(pay(gw_, carol_, EUR(1'000)), Sendmax(EUR(10'000))); env.close(); // 1000 / 0.8 - BEAST_EXPECT(expectHolding(env, carol, EUR(1'250))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(1'250))); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP Offer is created. - // o carol has EUR but wants USD. + // o carol_ has EUR but wants USD. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - env(offer(bob, EUR(100), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + env(offer(bob_, EUR(100), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Bob's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); // AMM doesn't pay the transfer fee BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(100))); // Carol pays 25% transfer fee: 1250 - 100(offer) - 25(transfer fee) - BEAST_EXPECT(expectHolding(env, carol, EUR(1'125))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, EUR(1'125))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } { @@ -1018,41 +1018,41 @@ private: // Bridged crossing. The transfer fee is paid on the step not // involving AMM as src/dst. Env env{*this, features}; - fund(env, gw, {alice, carol, bob}, XRP(30'000)); - env(rate(gw, 1.25)); - env(trust(alice, USD(15'000))); - env(trust(bob, EUR(15'000))); - env(trust(carol, EUR(15'000)), qualityOutPercent(120)); - env(trust(bob, USD(15'000))); - env(trust(carol, USD(15'000))); + fund(env, gw_, {alice_, carol_, bob_}, XRP(30'000)); + env(rate(gw_, 1.25)); + env(trust(alice_, USD(15'000))); + env(trust(bob_, EUR(15'000))); + env(trust(carol_, EUR(15'000)), QualityOutPercent(120)); + env(trust(bob_, USD(15'000))); + env(trust(carol_, USD(15'000))); env.close(); - env(pay(gw, alice, USD(11'000))); - env(pay(gw, carol, EUR(1'000)), sendmax(EUR(10'000))); + env(pay(gw_, alice_, USD(11'000))); + env(pay(gw_, carol_, EUR(1'000)), Sendmax(EUR(10'000))); env.close(); - BEAST_EXPECT(expectHolding(env, carol, EUR(1'000))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(1'000))); // The scenario: // o USD/XRP AMM is created. // o EUR/XRP Offer is created. - // o carol has EUR but wants USD. + // o carol_ has EUR but wants USD. // Note that Carol's offer must come last. If Carol's offer is // placed before AMM is created, then autobridging will not occur. - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - env(offer(bob, EUR(100), XRP(100))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + env(offer(bob_, EUR(100), XRP(100))); env.close(); // Carol makes an offer that consumes AMM liquidity and // fully consumes Bob's offer. - env(offer(carol, USD(100), EUR(100))); + env(offer(carol_, USD(100), EUR(100))); env.close(); // AMM pay doesn't transfer fee BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(100))); // Carol pays 25% transfer fee: 1000 - 100(offer) - 25(transfer fee) - BEAST_EXPECT(expectHolding(env, carol, EUR(875))); - BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, EUR(875))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } } @@ -1066,19 +1066,19 @@ private: Env env{*this, features}; - auto const USD_bob = bob["USD"]; + auto const usdBob = bob_["USD"]; auto const f = env.current()->fees().base; - env.fund(XRP(30'000) + f, alice, bob); + env.fund(XRP(30'000) + f, alice_, bob_); env.close(); - AMM const ammBob(env, bob, XRP(10'000), USD_bob(10'100)); + AMM const ammBob(env, bob_, XRP(10'000), usdBob(10'100)); - env(offer(alice, USD_bob(100), XRP(100))); + env(offer(alice_, usdBob(100), XRP(100))); env.close(); - BEAST_EXPECT(ammBob.expectBalances(XRP(10'100), USD_bob(10'000), ammBob.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(expectHolding(env, alice, USD_bob(100))); + BEAST_EXPECT(ammBob.expectBalances(XRP(10'100), usdBob(10'000), ammBob.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 0)); + BEAST_EXPECT(expectHolding(env, alice_, usdBob(100))); } void @@ -1098,52 +1098,52 @@ private: { // A trust line's QualityOut should not affect offer crossing. auto const ann = Account("ann"); - auto const A_BUX = ann["BUX"]; - auto const bob = Account("bob"); + auto const aBux = ann["BUX"]; + auto const localBob = Account("bob"); auto const cam = Account("cam"); auto const dan = Account("dan"); - auto const D_BUX = dan["BUX"]; + auto const dBux = dan["BUX"]; // Verify trust line QualityOut affects payments. - env.fund(reserve(env, 4) + (fee * 4), ann, bob, cam, dan); + env.fund(reserve(env, 4) + (fee * 4), ann, localBob, cam, dan); env.close(); - env(trust(bob, A_BUX(400))); - env(trust(bob, D_BUX(200)), qualityOutPercent(120)); - env(trust(cam, D_BUX(100))); + env(trust(localBob, aBux(400))); + env(trust(localBob, dBux(200)), QualityOutPercent(120)); + env(trust(cam, dBux(100))); env.close(); - env(pay(dan, bob, D_BUX(100))); + env(pay(dan, localBob, dBux(100))); env.close(); - BEAST_EXPECT(expectHolding(env, bob, D_BUX(100))); + BEAST_EXPECT(expectHolding(env, localBob, dBux(100))); - env(pay(ann, cam, D_BUX(60)), path(bob, dan), sendmax(A_BUX(200))); + env(pay(ann, cam, dBux(60)), Path(localBob, dan), Sendmax(aBux(200))); env.close(); - BEAST_EXPECT(expectHolding(env, ann, A_BUX(none))); - BEAST_EXPECT(expectHolding(env, ann, D_BUX(none))); - BEAST_EXPECT(expectHolding(env, bob, A_BUX(72))); - BEAST_EXPECT(expectHolding(env, bob, D_BUX(40))); - BEAST_EXPECT(expectHolding(env, cam, A_BUX(none))); - BEAST_EXPECT(expectHolding(env, cam, D_BUX(60))); - BEAST_EXPECT(expectHolding(env, dan, A_BUX(none))); - BEAST_EXPECT(expectHolding(env, dan, D_BUX(none))); + BEAST_EXPECT(expectHolding(env, ann, aBux(kNONE))); + BEAST_EXPECT(expectHolding(env, ann, dBux(kNONE))); + BEAST_EXPECT(expectHolding(env, localBob, aBux(72))); + BEAST_EXPECT(expectHolding(env, localBob, dBux(40))); + BEAST_EXPECT(expectHolding(env, cam, aBux(kNONE))); + BEAST_EXPECT(expectHolding(env, cam, dBux(60))); + BEAST_EXPECT(expectHolding(env, dan, aBux(kNONE))); + BEAST_EXPECT(expectHolding(env, dan, dBux(kNONE))); - AMM const ammBob(env, bob, A_BUX(30), D_BUX(30)); + AMM const ammBob(env, localBob, aBux(30), dBux(30)); - env(trust(ann, D_BUX(100))); + env(trust(ann, dBux(100))); env.close(); // This payment caused the assert. - env(pay(ann, ann, D_BUX(30)), path(A_BUX, D_BUX), sendmax(A_BUX(30)), ter(temBAD_PATH)); + env(pay(ann, ann, dBux(30)), Path(aBux, dBux), Sendmax(aBux(30)), Ter(temBAD_PATH)); env.close(); - BEAST_EXPECT(ammBob.expectBalances(A_BUX(30), D_BUX(30), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, ann, A_BUX(none))); - BEAST_EXPECT(expectHolding(env, ann, D_BUX(0))); - BEAST_EXPECT(expectHolding(env, cam, A_BUX(none))); - BEAST_EXPECT(expectHolding(env, cam, D_BUX(60))); - BEAST_EXPECT(expectHolding(env, dan, A_BUX(0))); - BEAST_EXPECT(expectHolding(env, dan, D_BUX(none))); + BEAST_EXPECT(ammBob.expectBalances(aBux(30), dBux(30), ammBob.tokens())); + BEAST_EXPECT(expectHolding(env, ann, aBux(kNONE))); + BEAST_EXPECT(expectHolding(env, ann, dBux(0))); + BEAST_EXPECT(expectHolding(env, cam, aBux(kNONE))); + BEAST_EXPECT(expectHolding(env, cam, dBux(60))); + BEAST_EXPECT(expectHolding(env, dan, aBux(0))); + BEAST_EXPECT(expectHolding(env, dan, dBux(kNONE))); } } @@ -1161,72 +1161,72 @@ private: Env env{*this, features}; auto const ann = Account("ann"); - auto const bob = Account("bob"); + auto const localBob = Account("bob"); auto const cam = Account("cam"); auto const carol = Account("carol"); - auto const A_BUX = ann["BUX"]; - auto const B_BUX = bob["BUX"]; + auto const aBux = ann["BUX"]; + auto const bBux = localBob["BUX"]; auto const fee = env.current()->fees().base; env.fund(XRP(1'000), carol); - env.fund(reserve(env, 4) + (fee * 5), ann, bob, cam); + env.fund(reserve(env, 4) + (fee * 5), ann, localBob, cam); env.close(); - env(trust(ann, B_BUX(40))); - env(trust(cam, A_BUX(40))); - env(trust(bob, A_BUX(30))); - env(trust(cam, B_BUX(40))); - env(trust(carol, B_BUX(400))); - env(trust(carol, A_BUX(400))); + env(trust(ann, bBux(40))); + env(trust(cam, aBux(40))); + env(trust(localBob, aBux(30))); + env(trust(cam, bBux(40))); + env(trust(carol, bBux(400))); + env(trust(carol, aBux(400))); env.close(); - env(pay(ann, cam, A_BUX(35))); - env(pay(bob, cam, B_BUX(35))); - env(pay(bob, carol, B_BUX(400))); - env(pay(ann, carol, A_BUX(400))); + env(pay(ann, cam, aBux(35))); + env(pay(localBob, cam, bBux(35))); + env(pay(localBob, carol, bBux(400))); + env(pay(ann, carol, aBux(400))); - AMM const ammCarol(env, carol, A_BUX(300), B_BUX(330)); + AMM const ammCarol(env, carol, aBux(300), bBux(330)); // cam puts an offer on the books that her upcoming offer could cross. // But this offer should be deleted, not crossed, by her upcoming // offer. - env(offer(cam, A_BUX(29), B_BUX(30), tfPassive)); + env(offer(cam, aBux(29), bBux(30), tfPassive)); env.close(); - env.require(balance(cam, A_BUX(35))); - env.require(balance(cam, B_BUX(35))); + env.require(Balance(cam, aBux(35))); + env.require(Balance(cam, bBux(35))); env.require(offers(cam, 1)); // This offer caused the assert. - env(offer(cam, B_BUX(30), A_BUX(30))); + env(offer(cam, bBux(30), aBux(30))); // AMM is consumed up to the first cam Offer quality if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammCarol.expectBalances( - STAmount{A_BUX, UINT64_C(309'3541659651605), -13}, - STAmount{B_BUX, UINT64_C(320'0215509984417), -13}, + STAmount{aBux, UINT64_C(309'3541659651605), -13}, + STAmount{bBux, UINT64_C(320'0215509984417), -13}, ammCarol.tokens())); BEAST_EXPECT(expectOffers( env, cam, 1, {{Amounts{ - STAmount{B_BUX, UINT64_C(20'0215509984417), -13}, - STAmount{A_BUX, UINT64_C(20'0215509984417), -13}}}})); + STAmount{bBux, UINT64_C(20'0215509984417), -13}, + STAmount{aBux, UINT64_C(20'0215509984417), -13}}}})); } else { BEAST_EXPECT(ammCarol.expectBalances( - STAmount{A_BUX, UINT64_C(309'3541659651604), -13}, - STAmount{B_BUX, UINT64_C(320'0215509984419), -13}, + STAmount{aBux, UINT64_C(309'3541659651604), -13}, + STAmount{bBux, UINT64_C(320'0215509984419), -13}, ammCarol.tokens())); BEAST_EXPECT(expectOffers( env, cam, 1, {{Amounts{ - STAmount{B_BUX, UINT64_C(20'0215509984419), -13}, - STAmount{A_BUX, UINT64_C(20'0215509984419), -13}}}})); + STAmount{bBux, UINT64_C(20'0215509984419), -13}, + STAmount{aBux, UINT64_C(20'0215509984419), -13}}}})); } } @@ -1239,43 +1239,43 @@ private: Env env{*this, features}; - auto const aliceUSD = alice["USD"]; - auto const bobUSD = bob["USD"]; + auto const aliceUSD = alice_["USD"]; + auto const bobUSD = bob_["USD"]; - env.fund(XRP(400'000), gw, alice, bob); + env.fund(XRP(400'000), gw_, alice_, bob_); env.close(); // GW requires authorization for holders of its IOUs - env(fset(gw, asfRequireAuth)); + env(fset(gw_, asfRequireAuth)); env.close(); - // Properly set trust and have gw authorize bob and alice - env(trust(gw, bobUSD(100)), txflags(tfSetfAuth)); - env(trust(bob, USD(100))); - env(trust(gw, aliceUSD(100)), txflags(tfSetfAuth)); - env(trust(alice, USD(2'000))); - env(pay(gw, alice, USD(1'000))); + // Properly set trust and have gw_ authorize bob_ and alice_ + env(trust(gw_, bobUSD(100)), Txflags(tfSetfAuth)); + env(trust(bob_, USD(100))); + env(trust(gw_, aliceUSD(100)), Txflags(tfSetfAuth)); + env(trust(alice_, USD(2'000))); + env(pay(gw_, alice_, USD(1'000))); env.close(); // Alice is able to create AMM since the GW has authorized her - AMM const ammAlice(env, alice, USD(1'000), XRP(1'050)); + AMM const ammAlice(env, alice_, USD(1'000), XRP(1'050)); // Set up authorized trust line for AMM. - env(trust(gw, STAmount{Issue{USD.currency, ammAlice.ammAccount()}, 10}), - txflags(tfSetfAuth)); + env(trust(gw_, STAmount{Issue{USD.currency, ammAlice.ammAccount()}, 10}), + Txflags(tfSetfAuth)); env.close(); - env(pay(gw, bob, USD(50))); + env(pay(gw_, bob_, USD(50))); env.close(); - BEAST_EXPECT(expectHolding(env, bob, USD(50))); + BEAST_EXPECT(expectHolding(env, bob_, USD(50))); // Bob's offer should cross Alice's AMM - env(offer(bob, XRP(50), USD(50))); + env(offer(bob_, XRP(50), USD(50))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(USD(1'050), XRP(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); } void @@ -1287,61 +1287,61 @@ private: Env env{*this, features}; - env.fund(XRP(400'000), gw, alice, bob); + env.fund(XRP(400'000), gw_, alice_, bob_); env.close(); // Alice doesn't have the funds { - AMM const ammAlice(env, alice, USD(1'000), XRP(1'000), ter(tecUNFUNDED_AMM)); + AMM const ammAlice(env, alice_, USD(1'000), XRP(1'000), Ter(tecUNFUNDED_AMM)); } - env(fset(gw, asfRequireAuth)); + env(fset(gw_, asfRequireAuth)); env.close(); - env(trust(gw, bob["USD"](50)), txflags(tfSetfAuth)); + env(trust(gw_, bob_["USD"](50)), Txflags(tfSetfAuth)); env.close(); - env(trust(bob, USD(50))); + env(trust(bob_, USD(50))); env.close(); - env(pay(gw, bob, USD(50))); + env(pay(gw_, bob_, USD(50))); env.close(); - BEAST_EXPECT(expectHolding(env, bob, USD(50))); + BEAST_EXPECT(expectHolding(env, bob_, USD(50))); // Alice should not be able to create AMM without authorization. { - AMM const ammAlice(env, alice, USD(1'000), XRP(1'000), ter(tecNO_LINE)); + AMM const ammAlice(env, alice_, USD(1'000), XRP(1'000), Ter(tecNO_LINE)); } // Set up a trust line for Alice, but don't authorize it. Alice - // should still not be able to create AMM for USD/gw. - env(trust(gw, alice["USD"](2'000))); + // should still not be able to create AMM for USD/gw_. + env(trust(gw_, alice_["USD"](2'000))); env.close(); { - AMM const ammAlice(env, alice, USD(1'000), XRP(1'000), ter(tecNO_AUTH)); + AMM const ammAlice(env, alice_, USD(1'000), XRP(1'000), Ter(tecNO_AUTH)); } // Finally, set up an authorized trust line for Alice. Now Alice's // AMM create should succeed. - env(trust(gw, alice["USD"](100)), txflags(tfSetfAuth)); - env(trust(alice, USD(2'000))); - env(pay(gw, alice, USD(1'000))); + env(trust(gw_, alice_["USD"](100)), Txflags(tfSetfAuth)); + env(trust(alice_, USD(2'000))); + env(pay(gw_, alice_, USD(1'000))); env.close(); - AMM const ammAlice(env, alice, USD(1'000), XRP(1'050)); + AMM const ammAlice(env, alice_, USD(1'000), XRP(1'050)); // Set up authorized trust line for AMM. - env(trust(gw, STAmount{Issue{USD.currency, ammAlice.ammAccount()}, 10}), - txflags(tfSetfAuth)); + env(trust(gw_, STAmount{Issue{USD.currency, ammAlice.ammAccount()}, 10}), + Txflags(tfSetfAuth)); env.close(); - // Now bob creates his offer again, which crosses with alice's AMM. - env(offer(bob, XRP(50), USD(50))); + // Now bob_ creates his offer again, which crosses with alice_'s AMM. + env(offer(bob_, XRP(50), USD(50))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(USD(1'050), XRP(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 0)); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); } void @@ -1351,7 +1351,7 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas FeatureBitset const all{ - testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; + testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; testRmFundedOffer(all); testRmFundedOffer(all - fixAMMv1_1 - fixAMMv1_3); @@ -1382,62 +1382,62 @@ private: } void - path_find_consume_all() + pathFindConsumeAll() { testcase("path find consume all"); using namespace jtx; Env env = pathTestEnv(); - env.fund(XRP(100'000'250), alice); - fund(env, gw, {carol, bob}, {USD(100)}, Fund::All); - fund(env, gw, {alice}, {USD(100)}, Fund::TokenOnly); - AMM const ammCarol(env, carol, XRP(100), USD(100)); + env.fund(XRP(100'000'250), alice_); + fund(env, gw_, {carol_, bob_}, {USD(100)}, Fund::All); + fund(env, gw_, {alice_}, {USD(100)}, Fund::TokenOnly); + AMM const ammCarol(env, carol_, XRP(100), USD(100)); STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = - find_paths(env, alice, bob, bob["AUD"](-1), std::optional(XRP(100'000'000))); + std::tie(st, sa, da) = findPaths( + env, alice_, bob_, bob_["AUD"](-1), std::optional(XRP(100'000'000))); BEAST_EXPECT(st.empty()); - std::tie(st, sa, da) = - find_paths(env, alice, bob, bob["USD"](-1), std::optional(XRP(100'000'000))); + std::tie(st, sa, da) = findPaths( + env, alice_, bob_, bob_["USD"](-1), std::optional(XRP(100'000'000))); // Alice sends all requested 100,000,000XRP BEAST_EXPECT(sa == XRP(100'000'000)); // Bob gets ~99.99USD. This is the amount Bob // can get out of AMM for 100,000,000XRP. - BEAST_EXPECT(equal(da, STAmount{bob["USD"], UINT64_C(99'9999000001), -10})); + BEAST_EXPECT(equal(da, STAmount{bob_["USD"], UINT64_C(99'9999000001), -10})); } - // carol holds gateway AUD, sells gateway AUD for XRP - // bob will hold gateway AUD - // alice pays bob gateway AUD using XRP + // carol_ holds gateway AUD, sells gateway AUD for XRP + // bob_ will hold gateway AUD + // alice_ pays bob_ gateway AUD using XRP void - via_offers_via_gateway() + viaOffersViaGateway() { testcase("via gateway"); using namespace jtx; Env env = pathTestEnv(); - auto const AUD = gw["AUD"]; - env.fund(XRP(10'000), alice, bob, carol, gw); + auto const aud = gw_["AUD"]; + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - env(rate(gw, 1.1)); - env.trust(AUD(2'000), bob, carol); - env(pay(gw, carol, AUD(51))); + env(rate(gw_, 1.1)); + env.trust(aud(2'000), bob_, carol_); + env(pay(gw_, carol_, aud(51))); env.close(); - AMM const ammCarol(env, carol, XRP(40), AUD(51)); - env(pay(alice, bob, AUD(10)), sendmax(XRP(100)), paths(XRP)); + AMM const ammCarol(env, carol_, XRP(40), aud(51)); + env(pay(alice_, bob_, aud(10)), Sendmax(XRP(100)), Paths(XRP)); env.close(); - // AMM offer is 51.282052XRP/11AUD, 11AUD/1.1 = 10AUD to bob - BEAST_EXPECT(ammCarol.expectBalances(XRP(51), AUD(40), ammCarol.tokens())); - BEAST_EXPECT(expectHolding(env, bob, AUD(10))); + // AMM offer is 51.282052XRP/11AUD, 11AUD/1.1 = 10AUD to bob_ + BEAST_EXPECT(ammCarol.expectBalances(XRP(51), aud(40), ammCarol.tokens())); + BEAST_EXPECT(expectHolding(env, bob_, aud(10))); - auto const result = find_paths(env, alice, bob, Account(bob)["USD"](25)); + auto const result = findPaths(env, alice_, bob_, Account(bob_)["USD"](25)); BEAST_EXPECT(std::get<0>(result).empty()); } void - receive_max() + receiveMax() { testcase("Receive max"); using namespace jtx; @@ -1445,26 +1445,26 @@ private: { // XRP -> IOU receive max Env env = pathTestEnv(); - fund(env, gw, {alice, bob, charlie}, {USD(11)}, Fund::All); + fund(env, gw_, {alice_, bob_, charlie}, {USD(11)}, Fund::All); AMM const ammCharlie(env, charlie, XRP(10), USD(11)); - auto [st, sa, da] = find_paths(env, alice, bob, USD(-1), XRP(1).value()); + auto [st, sa, da] = findPaths(env, alice_, bob_, USD(-1), XRP(1).value()); BEAST_EXPECT(sa == XRP(1)); BEAST_EXPECT(equal(da, USD(1))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { auto const& pathElem = st[0][0]; BEAST_EXPECT( - pathElem.isOffer() && pathElem.getIssuerID() == gw.id() && + pathElem.isOffer() && pathElem.getIssuerID() == gw_.id() && pathElem.getCurrency() == USD.currency); } } { // IOU -> XRP receive max Env env = pathTestEnv(); - fund(env, gw, {alice, bob, charlie}, {USD(11)}, Fund::All); + fund(env, gw_, {alice_, bob_, charlie}, {USD(11)}, Fund::All); AMM const ammCharlie(env, charlie, XRP(11), USD(10)); env.close(); - auto [st, sa, da] = find_paths(env, alice, bob, drops(-1), USD(1).value()); + auto [st, sa, da] = findPaths(env, alice_, bob_, drops(-1), USD(1).value()); BEAST_EXPECT(sa == USD(1)); BEAST_EXPECT(equal(da, XRP(1))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) @@ -1478,169 +1478,169 @@ private: } void - path_find_01() + pathFind01() { testcase("Path Find: XRP -> XRP and XRP -> IOU"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const G3{"G3"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const g3{"G3"}; + Account const m1{"M1"}; - env.fund(XRP(100'000), A1); - env.fund(XRP(10'000), A2); - env.fund(XRP(1'000), A3, G1, G2, G3); - env.fund(XRP(20'000), M1); + env.fund(XRP(100'000), a1); + env.fund(XRP(10'000), a2); + env.fund(XRP(1'000), a3, g1, g2, g3); + env.fund(XRP(20'000), m1); env.close(); - env.trust(G1["XYZ"](5'000), A1); - env.trust(G3["ABC"](5'000), A1); - env.trust(G2["XYZ"](5'000), A2); - env.trust(G3["ABC"](5'000), A2); - env.trust(A2["ABC"](1'000), A3); - env.trust(G1["XYZ"](100'000), M1); - env.trust(G2["XYZ"](100'000), M1); - env.trust(G3["ABC"](100'000), M1); + env.trust(g1["XYZ"](5'000), a1); + env.trust(g3["ABC"](5'000), a1); + env.trust(g2["XYZ"](5'000), a2); + env.trust(g3["ABC"](5'000), a2); + env.trust(a2["ABC"](1'000), a3); + env.trust(g1["XYZ"](100'000), m1); + env.trust(g2["XYZ"](100'000), m1); + env.trust(g3["ABC"](100'000), m1); env.close(); - env(pay(G1, A1, G1["XYZ"](3'500))); - env(pay(G3, A1, G3["ABC"](1'200))); - env(pay(G1, M1, G1["XYZ"](25'000))); - env(pay(G2, M1, G2["XYZ"](25'000))); - env(pay(G3, M1, G3["ABC"](25'000))); + env(pay(g1, a1, g1["XYZ"](3'500))); + env(pay(g3, a1, g3["ABC"](1'200))); + env(pay(g1, m1, g1["XYZ"](25'000))); + env(pay(g2, m1, g2["XYZ"](25'000))); + env(pay(g3, m1, g3["ABC"](25'000))); env.close(); - AMM const ammM1_G1_G2(env, M1, G1["XYZ"](1'000), G2["XYZ"](1'000)); - AMM const ammM1_XRP_G3(env, M1, XRP(10'000), G3["ABC"](1'000)); + AMM const ammM1G1G2(env, m1, g1["XYZ"](1'000), g2["XYZ"](1'000)); + AMM const ammM1XrpG3(env, m1, XRP(10'000), g3["ABC"](1'000)); STPathSet st; STAmount sa, da; { - auto const& send_amt = XRP(10); - std::tie(st, sa, da) = find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = XRP(10); + std::tie(st, sa, da) = findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { // no path should exist for this since dest account // does not exist. - auto const& send_amt = XRP(200); + auto const& sendAmt = XRP(200); std::tie(st, sa, da) = - find_paths(env, A1, Account{"A0"}, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, Account{"A0"}, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { - auto const& send_amt = G3["ABC"](10); - std::tie(st, sa, da) = find_paths(env, A2, G3, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = g3["ABC"](10); + std::tie(st, sa, da) = findPaths(env, a2, g3, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRPAmount{101'010'102})); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"])))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"])))); } { - auto const& send_amt = A2["ABC"](1); - std::tie(st, sa, da) = find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = a2["ABC"](1); + std::tie(st, sa, da) = findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRPAmount{10'010'011})); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"]), g3))); } { - auto const& send_amt = A3["ABC"](1); - std::tie(st, sa, da) = find_paths(env, A1, A3, send_amt, std::nullopt, xrpCurrency()); - BEAST_EXPECT(equal(da, send_amt)); + auto const& sendAmt = a3["ABC"](1); + std::tie(st, sa, da) = findPaths(env, a1, a3, sendAmt, std::nullopt, xrpCurrency()); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRPAmount{10'010'011})); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3, A2))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"]), g3, a2))); } } void - path_find_02() + pathFind02() { testcase("Path Find: non-XRP -> XRP"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const G3{"G3"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const g3{"G3"}; + Account const m1{"M1"}; - env.fund(XRP(1'000), A1, A2, G3); - env.fund(XRP(11'000), M1); + env.fund(XRP(1'000), a1, a2, g3); + env.fund(XRP(11'000), m1); env.close(); - env.trust(G3["ABC"](1'000), A1, A2); - env.trust(G3["ABC"](100'000), M1); + env.trust(g3["ABC"](1'000), a1, a2); + env.trust(g3["ABC"](100'000), m1); env.close(); - env(pay(G3, A1, G3["ABC"](1'000))); - env(pay(G3, A2, G3["ABC"](1'000))); - env(pay(G3, M1, G3["ABC"](1'200))); + env(pay(g3, a1, g3["ABC"](1'000))); + env(pay(g3, a2, g3["ABC"](1'000))); + env(pay(g3, m1, g3["ABC"](1'200))); env.close(); - AMM const ammM1(env, M1, G3["ABC"](1'000), XRP(10'010)); + AMM const ammM1(env, m1, g3["ABC"](1'000), XRP(10'010)); STPathSet st; STAmount sa, da; - auto const& send_amt = XRP(10); - std::tie(st, sa, da) = find_paths(env, A1, A2, send_amt, std::nullopt, A2["ABC"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["ABC"](1))); - BEAST_EXPECT(same(st, stpath(G3, IPE(xrpIssue())))); + auto const& sendAmt = XRP(10); + std::tie(st, sa, da) = findPaths(env, a1, a2, sendAmt, std::nullopt, a2["ABC"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["ABC"](1))); + BEAST_EXPECT(same(st, stpath(g3, ipe(xrpIssue())))); } void - path_find_05() + pathFind05() { testcase("Path Find: non-XRP -> non-XRP, same currency"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const G3{"G3"}; - Account const G4{"G4"}; - Account const M1{"M1"}; - Account const M2{"M2"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const g3{"G3"}; + Account const g4{"G4"}; + Account const m1{"M1"}; + Account const m2{"M2"}; - env.fund(XRP(1'000), A1, A2, A3, G1, G2, G3, G4); - env.fund(XRP(10'000), A4); - env.fund(XRP(21'000), M1, M2); + env.fund(XRP(1'000), a1, a2, a3, g1, g2, g3, g4); + env.fund(XRP(10'000), a4); + env.fund(XRP(21'000), m1, m2); env.close(); - env.trust(G1["HKD"](2'000), A1); - env.trust(G2["HKD"](2'000), A2); - env.trust(G1["HKD"](2'000), A3); - env.trust(G1["HKD"](100'000), M1); - env.trust(G2["HKD"](100'000), M1); - env.trust(G1["HKD"](100'000), M2); - env.trust(G2["HKD"](100'000), M2); + env.trust(g1["HKD"](2'000), a1); + env.trust(g2["HKD"](2'000), a2); + env.trust(g1["HKD"](2'000), a3); + env.trust(g1["HKD"](100'000), m1); + env.trust(g2["HKD"](100'000), m1); + env.trust(g1["HKD"](100'000), m2); + env.trust(g2["HKD"](100'000), m2); env.close(); - env(pay(G1, A1, G1["HKD"](1'000))); - env(pay(G2, A2, G2["HKD"](1'000))); - env(pay(G1, A3, G1["HKD"](1'000))); - env(pay(G1, M1, G1["HKD"](1'200))); - env(pay(G2, M1, G2["HKD"](5'000))); - env(pay(G1, M2, G1["HKD"](1'200))); - env(pay(G2, M2, G2["HKD"](5'000))); + env(pay(g1, a1, g1["HKD"](1'000))); + env(pay(g2, a2, g2["HKD"](1'000))); + env(pay(g1, a3, g1["HKD"](1'000))); + env(pay(g1, m1, g1["HKD"](1'200))); + env(pay(g2, m1, g2["HKD"](5'000))); + env(pay(g1, m2, g1["HKD"](1'200))); + env(pay(g2, m2, g2["HKD"](5'000))); env.close(); - AMM const ammM1(env, M1, G1["HKD"](1'010), G2["HKD"](1'000)); - AMM const ammM2XRP_G2(env, M2, XRP(10'000), G2["HKD"](1'010)); - AMM const ammM2G1_XRP(env, M2, G1["HKD"](1'010), XRP(10'000)); + AMM const ammM1(env, m1, g1["HKD"](1'010), g2["HKD"](1'000)); + AMM const ammM2XrpG2(env, m2, XRP(10'000), g2["HKD"](1'010)); + AMM const ammM2G1Xrp(env, m2, g1["HKD"](1'010), XRP(10'000)); STPathSet st; STAmount sa, da; @@ -1648,127 +1648,127 @@ private: { // A) Borrow or repay -- // Source -> Destination (repay source issuer) - auto const& send_amt = G1["HKD"](10); + auto const& sendAmt = g1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency); + findPaths(env, a1, g1, sendAmt, std::nullopt, g1["HKD"].currency); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // A2) Borrow or repay -- // Source -> Destination (repay destination issuer) - auto const& send_amt = A1["HKD"](10); + auto const& sendAmt = a1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency); + findPaths(env, a1, g1, sendAmt, std::nullopt, g1["HKD"].currency); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // B) Common gateway -- // Source -> AC -> Destination - auto const& send_amt = A3["HKD"](10); + auto const& sendAmt = a3["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, A3, send_amt, std::nullopt, G1["HKD"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(G1))); + findPaths(env, a1, a3, sendAmt, std::nullopt, g1["HKD"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(g1))); } { // C) Gateway to gateway -- // Source -> OB -> Destination - auto const& send_amt = G2["HKD"](10); + auto const& sendAmt = g2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, G1, G2, send_amt, std::nullopt, G1["HKD"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1["HKD"](10))); + findPaths(env, g1, g2, sendAmt, std::nullopt, g1["HKD"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(IPE(G2["HKD"])), - stpath(M1), - stpath(M2), - stpath(IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(ipe(g2["HKD"])), + stpath(m1), + stpath(m2), + stpath(ipe(xrpIssue()), ipe(g2["HKD"])))); } { // D) User to unlinked gateway via order book -- // Source -> AC -> OB -> Destination - auto const& send_amt = G2["HKD"](10); + auto const& sendAmt = g2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G2, send_amt, std::nullopt, G1["HKD"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + findPaths(env, a1, g2, sendAmt, std::nullopt, g1["HKD"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1), - stpath(G1, M2), - stpath(G1, IPE(G2["HKD"])), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(g1, m1), + stpath(g1, m2), + stpath(g1, ipe(g2["HKD"])), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"])))); } { // I4) XRP bridge" -- // Source -> AC -> OB to XRP -> OB from XRP -> AC -> // Destination - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, G1["HKD"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + findPaths(env, a1, a2, sendAmt, std::nullopt, g1["HKD"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1, G2), - stpath(G1, M2, G2), - stpath(G1, IPE(G2["HKD"]), G2), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"]), G2))); + stpath(g1, m1, g2), + stpath(g1, m2, g2), + stpath(g1, ipe(g2["HKD"]), g2), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"]), g2))); } } void - path_find_06() + pathFind06() { testcase("Path Find: non-XRP -> non-XRP, same currency"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const m1{"M1"}; - env.fund(XRP(11'000), M1); - env.fund(XRP(1'000), A1, A2, A3, G1, G2); + env.fund(XRP(11'000), m1); + env.fund(XRP(1'000), a1, a2, a3, g1, g2); env.close(); - env.trust(G1["HKD"](2'000), A1); - env.trust(G2["HKD"](2'000), A2); - env.trust(A2["HKD"](2'000), A3); - env.trust(G1["HKD"](100'000), M1); - env.trust(G2["HKD"](100'000), M1); + env.trust(g1["HKD"](2'000), a1); + env.trust(g2["HKD"](2'000), a2); + env.trust(a2["HKD"](2'000), a3); + env.trust(g1["HKD"](100'000), m1); + env.trust(g2["HKD"](100'000), m1); env.close(); - env(pay(G1, A1, G1["HKD"](1'000))); - env(pay(G2, A2, G2["HKD"](1'000))); - env(pay(G1, M1, G1["HKD"](5'000))); - env(pay(G2, M1, G2["HKD"](5'000))); + env(pay(g1, a1, g1["HKD"](1'000))); + env(pay(g2, a2, g2["HKD"](1'000))); + env(pay(g1, m1, g1["HKD"](5'000))); + env(pay(g2, m1, g2["HKD"](5'000))); env.close(); - AMM const ammM1(env, M1, G1["HKD"](1'010), G2["HKD"](1'000)); + AMM const ammM1(env, m1, g1["HKD"](1'010), g2["HKD"](1'000)); // E) Gateway to user // Source -> OB -> AC -> Destination - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); STPathSet st; STAmount sa, da; - std::tie(st, sa, da) = find_paths(env, G1, A2, send_amt, std::nullopt, G1["HKD"].currency); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(M1, G2), stpath(IPE(G2["HKD"]), G2))); + std::tie(st, sa, da) = findPaths(env, g1, a2, sendAmt, std::nullopt, g1["HKD"].currency); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(m1, g2), stpath(ipe(g2["HKD"]), g2))); } void @@ -1780,18 +1780,18 @@ private: Env env(*this, features); - env.fund(XRP(10'000), alice, gw); - // This removes no ripple for carol, + env.fund(XRP(10'000), alice_, gw_); + // This removes no ripple for carol_, // different from the original test - fund(env, gw, {carol}, XRP(10'000), {}, Fund::Acct); + fund(env, gw_, {carol_}, XRP(10'000), {}, Fund::Acct); auto const ammXrpPool = env.current()->fees().increment * 2; - env.fund(reserve(env, 5) + ammCrtFee(env) + ammXrpPool, bob); + env.fund(reserve(env, 5) + ammCrtFee(env) + ammXrpPool, bob_); env.close(); - env.trust(USD(1'000), alice, bob, carol); - env.trust(EUR(1'000), alice, bob, carol); + env.trust(USD(1'000), alice_, bob_, carol_); + env.trust(EUR(1'000), alice_, bob_, carol_); - env(pay(gw, alice, EUR(50))); - env(pay(gw, bob, USD(150))); + env(pay(gw_, alice_, EUR(50))); + env(pay(gw_, bob_, USD(150))); // Bob has _just_ slightly less than 50 xrp available // If his owner count changes, he will have more liquidity. @@ -1800,15 +1800,15 @@ private: // recursive calls to the EUR/XRP offer. The second call will return // tecPATH_DRY, but the entire path should not be marked as dry. // This is the second error case to test (when flowV1 is used). - env(offer(bob, EUR(50), XRP(50))); - AMM const ammBob(env, bob, ammXrpPool, USD(150)); + env(offer(bob_, EUR(50), XRP(50))); + AMM const ammBob(env, bob_, ammXrpPool, USD(150)); - env(pay(alice, carol, USD(1'000'000)), - path(~XRP, ~USD), - sendmax(EUR(500)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, USD(1'000'000)), + Path(~XRP, ~USD), + Sendmax(EUR(500)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - auto const carolUSD = env.balance(carol, USD).value(); + auto const carolUSD = env.balance(carol_, USD).value(); BEAST_EXPECT(carolUSD > USD(0) && carolUSD < USD(50)); } @@ -1823,183 +1823,183 @@ private: // simple IOU/IOU offer Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000), {BTC(100), USD(150)}, Fund::All); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {BTC(100), USD(150)}, Fund::All); - AMM const ammBob(env, bob, BTC(100), USD(150)); + AMM const ammBob(env, bob_, BTC(100), USD(150)); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(BTC(50))); + env(pay(alice_, carol_, USD(50)), Path(~USD), Sendmax(BTC(50))); - BEAST_EXPECT(expectHolding(env, alice, BTC(50))); - BEAST_EXPECT(expectHolding(env, bob, BTC(0))); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); - BEAST_EXPECT(expectHolding(env, carol, USD(200))); + BEAST_EXPECT(expectHolding(env, alice_, BTC(50))); + BEAST_EXPECT(expectHolding(env, bob_, BTC(0))); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); + BEAST_EXPECT(expectHolding(env, carol_, USD(200))); BEAST_EXPECT(ammBob.expectBalances(BTC(150), USD(100), ammBob.tokens())); } { // simple IOU/XRP XRP/IOU offer Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(10'000), {BTC(100), USD(150)}, Fund::All); + fund(env, gw_, {alice_, carol_, bob_}, XRP(10'000), {BTC(100), USD(150)}, Fund::All); - AMM const ammBobBTC_XRP(env, bob, BTC(100), XRP(150)); - AMM const ammBobXRP_USD(env, bob, XRP(100), USD(150)); + AMM const ammBobBtcXrp(env, bob_, BTC(100), XRP(150)); + AMM const ammBobXrpUsd(env, bob_, XRP(100), USD(150)); - env(pay(alice, carol, USD(50)), path(~XRP, ~USD), sendmax(BTC(50))); + env(pay(alice_, carol_, USD(50)), Path(~XRP, ~USD), Sendmax(BTC(50))); - BEAST_EXPECT(expectHolding(env, alice, BTC(50))); - BEAST_EXPECT(expectHolding(env, bob, BTC(0))); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); - BEAST_EXPECT(expectHolding(env, carol, USD(200))); - BEAST_EXPECT(ammBobBTC_XRP.expectBalances(BTC(150), XRP(100), ammBobBTC_XRP.tokens())); - BEAST_EXPECT(ammBobXRP_USD.expectBalances(XRP(150), USD(100), ammBobXRP_USD.tokens())); + BEAST_EXPECT(expectHolding(env, alice_, BTC(50))); + BEAST_EXPECT(expectHolding(env, bob_, BTC(0))); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); + BEAST_EXPECT(expectHolding(env, carol_, USD(200))); + BEAST_EXPECT(ammBobBtcXrp.expectBalances(BTC(150), XRP(100), ammBobBtcXrp.tokens())); + BEAST_EXPECT(ammBobXrpUsd.expectBalances(XRP(150), USD(100), ammBobXrpUsd.tokens())); } { // simple XRP -> USD through offer and sendmax Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(150)}, Fund::All); + fund(env, gw_, {alice_, carol_, bob_}, XRP(10'000), {USD(150)}, Fund::All); - AMM const ammBob(env, bob, XRP(100), USD(150)); + AMM const ammBob(env, bob_, XRP(100), USD(150)); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(XRP(50))); + env(pay(alice_, carol_, USD(50)), Path(~USD), Sendmax(XRP(50))); - BEAST_EXPECT(expectLedgerEntryRoot(env, alice, xrpMinusFee(env, 10'000 - 50))); - BEAST_EXPECT(expectLedgerEntryRoot(env, bob, XRP(10'000) - XRP(100) - ammCrtFee(env))); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); - BEAST_EXPECT(expectHolding(env, carol, USD(200))); + BEAST_EXPECT(expectLedgerEntryRoot(env, alice_, xrpMinusFee(env, 10'000 - 50))); + BEAST_EXPECT(expectLedgerEntryRoot(env, bob_, XRP(10'000) - XRP(100) - ammCrtFee(env))); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); + BEAST_EXPECT(expectHolding(env, carol_, USD(200))); BEAST_EXPECT(ammBob.expectBalances(XRP(150), USD(100), ammBob.tokens())); } { // simple USD -> XRP through offer and sendmax Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(100)}, Fund::All); + fund(env, gw_, {alice_, carol_, bob_}, XRP(10'000), {USD(100)}, Fund::All); - AMM const ammBob(env, bob, USD(100), XRP(150)); + AMM const ammBob(env, bob_, USD(100), XRP(150)); - env(pay(alice, carol, XRP(50)), path(~XRP), sendmax(USD(50))); + env(pay(alice_, carol_, XRP(50)), Path(~XRP), Sendmax(USD(50))); - BEAST_EXPECT(expectHolding(env, alice, USD(50))); - BEAST_EXPECT(expectLedgerEntryRoot(env, bob, XRP(10'000) - XRP(150) - ammCrtFee(env))); - BEAST_EXPECT(expectHolding(env, bob, USD(0))); - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRP(10'000 + 50))); + BEAST_EXPECT(expectHolding(env, alice_, USD(50))); + BEAST_EXPECT(expectLedgerEntryRoot(env, bob_, XRP(10'000) - XRP(150) - ammCrtFee(env))); + BEAST_EXPECT(expectHolding(env, bob_, USD(0))); + BEAST_EXPECT(expectLedgerEntryRoot(env, carol_, XRP(10'000 + 50))); BEAST_EXPECT(ammBob.expectBalances(USD(150), XRP(100), ammBob.tokens())); } { // test unfunded offers are removed when payment succeeds Env env(*this, features); - env.fund(XRP(10'000), alice, carol, gw); - env.fund(XRP(10'000), bob); + env.fund(XRP(10'000), alice_, carol_, gw_); + env.fund(XRP(10'000), bob_); env.close(); - env.trust(USD(1'000), alice, bob, carol); - env.trust(BTC(1'000), alice, bob, carol); - env.trust(EUR(1'000), alice, bob, carol); + env.trust(USD(1'000), alice_, bob_, carol_); + env.trust(BTC(1'000), alice_, bob_, carol_); + env.trust(EUR(1'000), alice_, bob_, carol_); env.close(); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, USD(200))); - env(pay(gw, bob, EUR(150))); + env(pay(gw_, alice_, BTC(60))); + env(pay(gw_, bob_, USD(200))); + env(pay(gw_, bob_, EUR(150))); env.close(); - env(offer(bob, BTC(50), USD(50))); - env(offer(bob, BTC(40), EUR(50))); + env(offer(bob_, BTC(50), USD(50))); + env(offer(bob_, BTC(40), EUR(50))); env.close(); - AMM const ammBob(env, bob, EUR(100), USD(150)); + AMM const ammBob(env, bob_, EUR(100), USD(150)); // unfund offer - env(pay(bob, gw, EUR(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(40), EUR(50))); + env(pay(bob_, gw_, EUR(50))); + BEAST_EXPECT(isOffer(env, bob_, BTC(50), USD(50))); + BEAST_EXPECT(isOffer(env, bob_, BTC(40), EUR(50))); - env(pay(alice, carol, USD(50)), path(~USD), path(~EUR, ~USD), sendmax(BTC(60))); + env(pay(alice_, carol_, USD(50)), Path(~USD), Path(~EUR, ~USD), Sendmax(BTC(60))); - env.require(balance(alice, BTC(10))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(bob, EUR(0))); - env.require(balance(carol, USD(50))); + env.require(Balance(alice_, BTC(10))); + env.require(Balance(bob_, BTC(50))); + env.require(Balance(bob_, USD(0))); + env.require(Balance(bob_, EUR(0))); + env.require(Balance(carol_, USD(50))); // used in the payment - BEAST_EXPECT(!isOffer(env, bob, BTC(50), USD(50))); + BEAST_EXPECT(!isOffer(env, bob_, BTC(50), USD(50))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(40), EUR(50))); + BEAST_EXPECT(!isOffer(env, bob_, BTC(40), EUR(50))); // unchanged BEAST_EXPECT(ammBob.expectBalances(EUR(100), USD(150), ammBob.tokens())); } { // test unfunded offers are removed when the payment fails. - // bob makes two offers: a funded 50 USD for 50 BTC and an - // unfunded 50 EUR for 60 BTC. alice pays carol 61 USD with 61 - // BTC. alice only has 60 BTC, so the payment will fail. The - // payment uses two paths: one through bob's funded offer and + // bob_ makes two offers: a funded 50 USD for 50 BTC and an + // unfunded 50 EUR for 60 BTC. alice_ pays carol_ 61 USD with 61 + // BTC. alice_ only has 60 BTC, so the payment will fail. The + // payment uses two paths: one through bob_'s funded offer and // one through his unfunded offer. When the payment fails `flow` // should return the unfunded offer. This test is intentionally // similar to the one that removes unfunded offers when the // payment succeeds. Env env(*this, features); - env.fund(XRP(10'000), bob, carol, gw); + env.fund(XRP(10'000), bob_, carol_, gw_); env.close(); // Sets rippling on, this is different from // the original test - fund(env, gw, {alice}, XRP(10'000), {}, Fund::Acct); - env.trust(USD(1'000), alice, bob, carol); - env.trust(BTC(1'000), alice, bob, carol); - env.trust(EUR(1'000), alice, bob, carol); + fund(env, gw_, {alice_}, XRP(10'000), {}, Fund::Acct); + env.trust(USD(1'000), alice_, bob_, carol_); + env.trust(BTC(1'000), alice_, bob_, carol_); + env.trust(EUR(1'000), alice_, bob_, carol_); env.close(); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, BTC(100))); - env(pay(gw, bob, USD(100))); - env(pay(gw, bob, EUR(50))); - env(pay(gw, carol, EUR(1))); + env(pay(gw_, alice_, BTC(60))); + env(pay(gw_, bob_, BTC(100))); + env(pay(gw_, bob_, USD(100))); + env(pay(gw_, bob_, EUR(50))); + env(pay(gw_, carol_, EUR(1))); env.close(); // This is multiplath, which generates limited # of offers - AMM const ammBobBTC_USD(env, bob, BTC(50), USD(50)); - env(offer(bob, BTC(60), EUR(50))); - env(offer(carol, BTC(1'000), EUR(1))); - env(offer(bob, EUR(50), USD(50))); + AMM const ammBobBtcUsd(env, bob_, BTC(50), USD(50)); + env(offer(bob_, BTC(60), EUR(50))); + env(offer(carol_, BTC(1'000), EUR(1))); + env(offer(bob_, EUR(50), USD(50))); // unfund offer - env(pay(bob, gw, EUR(50))); - BEAST_EXPECT(ammBobBTC_USD.expectBalances(BTC(50), USD(50), ammBobBTC_USD.tokens())); - BEAST_EXPECT(isOffer(env, bob, BTC(60), EUR(50))); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000), EUR(1))); - BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50))); + env(pay(bob_, gw_, EUR(50))); + BEAST_EXPECT(ammBobBtcUsd.expectBalances(BTC(50), USD(50), ammBobBtcUsd.tokens())); + BEAST_EXPECT(isOffer(env, bob_, BTC(60), EUR(50))); + BEAST_EXPECT(isOffer(env, carol_, BTC(1'000), EUR(1))); + BEAST_EXPECT(isOffer(env, bob_, EUR(50), USD(50))); auto flowJournal = env.app().getJournal("Flow"); auto const flowResult = [&] { STAmount const deliver(USD(51)); STAmount smax(BTC(61)); - PaymentSandbox sb(env.current().get(), tapNONE); + PaymentSandbox sb(env.current().get(), TapNone); STPathSet paths; - auto IPE = [](Issue const& iss) { + auto ipe = [](Issue const& iss) { return STPathElement( - STPathElement::typeCurrency | STPathElement::typeIssuer, + STPathElement::TypeCurrency | STPathElement::TypeIssuer, xrpAccount(), iss.currency, iss.account); }; { // BTC -> USD - STPath const p1({IPE(USD)}); - paths.push_back(p1); + STPath const p1({ipe(USD)}); + paths.pushBack(p1); // BTC -> EUR -> USD - STPath const p2({IPE(EUR), IPE(USD)}); - paths.push_back(p2); + STPath const p2({ipe(EUR), ipe(USD)}); + paths.pushBack(p2); } return flow( sb, deliver, - alice, - carol, + alice_, + carol_, paths, false, false, true, - OfferCrossing::no, + OfferCrossing::No, std::nullopt, smax, std::nullopt, @@ -2010,7 +2010,7 @@ private: env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { if (flowResult.removableOffers.empty()) return false; - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); for (auto const& o : flowResult.removableOffers) { if (auto ok = sb.peek(keylet::offer(o))) @@ -2021,10 +2021,10 @@ private: }); // used in payment, but since payment failed should be untouched - BEAST_EXPECT(ammBobBTC_USD.expectBalances(BTC(50), USD(50), ammBobBTC_USD.tokens())); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000), EUR(1))); + BEAST_EXPECT(ammBobBtcUsd.expectBalances(BTC(50), USD(50), ammBobBtcUsd.tokens())); + BEAST_EXPECT(isOffer(env, carol_, BTC(1'000), EUR(1))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(60), EUR(50))); + BEAST_EXPECT(!isOffer(env, bob_, BTC(60), EUR(50))); } { // Do not produce more in the forward pass than the reverse pass @@ -2036,28 +2036,28 @@ private: // 1 EUR, as expected. Env env(*this, features); - env.fund(XRP(10'000), bob, carol, gw); + env.fund(XRP(10'000), bob_, carol_, gw_); env.close(); - fund(env, gw, {alice}, XRP(10'000), {}, Fund::Acct); - env.trust(USD(1'000), alice, bob, carol); - env.trust(EUR(1'000), alice, bob, carol); + fund(env, gw_, {alice_}, XRP(10'000), {}, Fund::Acct); + env.trust(USD(1'000), alice_, bob_, carol_); + env.trust(EUR(1'000), alice_, bob_, carol_); env.close(); - env(pay(gw, alice, USD(1'000))); - env(pay(gw, bob, EUR(1'000))); - env(pay(gw, bob, USD(1'000))); + env(pay(gw_, alice_, USD(1'000))); + env(pay(gw_, bob_, EUR(1'000))); + env(pay(gw_, bob_, USD(1'000))); env.close(); - // env(offer(bob, USD(1), drops(2)), txflags(tfPassive)); - AMM const ammBob(env, bob, USD(8), XRPAmount{21}); - env(offer(bob, drops(1), EUR(1'000)), txflags(tfPassive)); + // env(offer(bob_, USD(1), drops(2)), txflags(tfPassive)); + AMM const ammBob(env, bob_, USD(8), XRPAmount{21}); + env(offer(bob_, drops(1), EUR(1'000)), Txflags(tfPassive)); - env(pay(alice, carol, EUR(1)), - path(~XRP, ~EUR), - sendmax(USD(0.4)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, EUR(1)), + Path(~XRP, ~EUR), + Sendmax(USD(0.4)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - BEAST_EXPECT(expectHolding(env, carol, EUR(1))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(1))); BEAST_EXPECT(ammBob.expectBalances(USD(8.4), XRPAmount{20}, ammBob.tokens())); } } @@ -2072,21 +2072,21 @@ private: // payment via AMM Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(1'000), {USD(1'000), GBP(1'000)}); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(1'000), {USD(1'000), GBP(1'000)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm(env, bob, GBP(1'000), USD(1'000)); + AMM const amm(env, bob_, GBP(1'000), USD(1'000)); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(GBP(150)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(GBP(150)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - // alice buys 107.1428USD with 120GBP and pays 25% tr fee on 120GBP + // alice_ buys 107.1428USD with 120GBP and pays 25% tr fee on 120GBP // 1,000 - 120*1.25 = 850GBP - BEAST_EXPECT(expectHolding(env, alice, GBP(850))); + BEAST_EXPECT(expectHolding(env, alice_, GBP(850))); if (!features[fixAMMv1_1]) { // 120GBP is swapped in for 107.1428USD @@ -2101,7 +2101,7 @@ private: // 25% of 85.7142USD is paid in tr fee // 85.7142*1.25 = 107.1428USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'085'714285714286), -12))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'085'714285714286), -12))); } { @@ -2110,25 +2110,29 @@ private: Account const ed("ed"); fund( - env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(1'000), EUR(1'000), GBP(1'000)}); - env(rate(gw, 1.25)); + env, + gw_, + {alice_, bob_, carol_, ed}, + XRP(1'000), + {USD(1'000), EUR(1'000), GBP(1'000)}); + env(rate(gw_, 1.25)); env.close(); - env(offer(ed, GBP(1'000), EUR(1'000)), txflags(tfPassive)); + env(offer(ed, GBP(1'000), EUR(1'000)), Txflags(tfPassive)); env.close(); - AMM const amm(env, bob, EUR(1'000), USD(1'000)); + AMM const amm(env, bob_, EUR(1'000), USD(1'000)); - env(pay(alice, carol, USD(100)), - path(~EUR, ~USD), - sendmax(GBP(150)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, USD(100)), + Path(~EUR, ~USD), + Sendmax(GBP(150)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - // alice buys 120EUR with 120GBP via the offer + // alice_ buys 120EUR with 120GBP via the offer // and pays 25% tr fee on 120GBP // 1,000 - 120*1.25 = 850GBP - BEAST_EXPECT(expectHolding(env, alice, GBP(850))); + BEAST_EXPECT(expectHolding(env, alice_, GBP(850))); // consumed offer is 120GBP/120EUR // ed doesn't pay tr fee BEAST_EXPECT(expectHolding(env, ed, EUR(880), GBP(1'120))); @@ -2139,7 +2143,7 @@ private: EUR(1'096), STAmount{USD, UINT64_C(912'4087591240876), -13}, amm.tokens())); // 25% on 70.0729USD is paid in tr fee 70.0729*1.25 = 87.5912USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'070'07299270073), -11))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'070'07299270073), -11))); } { // Payment via AMM, AMM @@ -2147,23 +2151,27 @@ private: Account const ed("ed"); fund( - env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(1'000), EUR(1'000), GBP(1'000)}); - env(rate(gw, 1.25)); + env, + gw_, + {alice_, bob_, carol_, ed}, + XRP(1'000), + {USD(1'000), EUR(1'000), GBP(1'000)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm1(env, bob, GBP(1'000), EUR(1'000)); + AMM const amm1(env, bob_, GBP(1'000), EUR(1'000)); AMM const amm2(env, ed, EUR(1'000), USD(1'000)); - env(pay(alice, carol, USD(100)), - path(~EUR, ~USD), - sendmax(GBP(150)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice_, carol_, USD(100)), + Path(~EUR, ~USD), + Sendmax(GBP(150)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - BEAST_EXPECT(expectHolding(env, alice, GBP(850))); + BEAST_EXPECT(expectHolding(env, alice_, GBP(850))); if (!features[fixAMMv1_1]) { - // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on + // alice_ buys 107.1428EUR with 120GBP and pays 25% tr fee on // 120GBP 1,000 - 120*1.25 = 850GBP 120GBP is swapped in for // 107.1428EUR BEAST_EXPECT(amm1.expectBalances( @@ -2177,7 +2185,7 @@ private: } else { - // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on + // alice_ buys 107.1428EUR with 120GBP and pays 25% tr fee on // 120GBP 1,000 - 120*1.25 = 850GBP 120GBP is swapped in for // 107.1428EUR BEAST_EXPECT(amm1.expectBalances( @@ -2191,92 +2199,92 @@ private: } // 25% on 63.1578USD is paid in tr fee 63.1578*1.25 = 78.9473USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'063'157894736842), -12))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'063'157894736842), -12))); } { // AMM offer crossing Env env(*this, features); - fund(env, gw, {alice, bob}, XRP(1'000), {USD(1'100), EUR(1'100)}); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_}, XRP(1'000), {USD(1'100), EUR(1'100)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm(env, bob, USD(1'000), EUR(1'100)); - env(offer(alice, EUR(100), USD(100))); + AMM const amm(env, bob_, USD(1'000), EUR(1'100)); + env(offer(alice_, EUR(100), USD(100))); env.close(); // 100USD is swapped in for 100EUR BEAST_EXPECT(amm.expectBalances(USD(1'100), EUR(1'000), amm.tokens())); - // alice pays 25% tr fee on 100USD 1100-100*1.25 = 975USD - BEAST_EXPECT(expectHolding(env, alice, USD(975), EUR(1'200))); - BEAST_EXPECT(expectOffers(env, alice, 0)); + // alice_ pays 25% tr fee on 100USD 1100-100*1.25 = 975USD + BEAST_EXPECT(expectHolding(env, alice_, USD(975), EUR(1'200))); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } { // Payment via AMM with limit quality Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(1'000), {USD(1'000), GBP(1'000)}); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(1'000), {USD(1'000), GBP(1'000)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm(env, bob, GBP(1'000), USD(1'000)); + AMM const amm(env, bob_, GBP(1'000), USD(1'000)); // requested quality limit is 100USD/178.58GBP = 0.55997 // trade quality is 100USD/178.5714 = 0.55999 - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(GBP(178.58)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(GBP(178.58)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 125USD with 142.8571GBP and pays 25% tr fee + // alice_ buys 125USD with 142.8571GBP and pays 25% tr fee // on 142.8571GBP // 1,000 - 142.8571*1.25 = 821.4285GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount(GBP, UINT64_C(821'4285714285712), -13))); + expectHolding(env, alice_, STAmount(GBP, UINT64_C(821'4285714285712), -13))); // 142.8571GBP is swapped in for 125USD BEAST_EXPECT(amm.expectBalances( STAmount{GBP, UINT64_C(1'142'857142857143), -12}, USD(875), amm.tokens())); // 25% on 100USD is paid in tr fee // 100*1.25 = 125USD - BEAST_EXPECT(expectHolding(env, carol, USD(1'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(1'100))); } { // Payment via AMM with limit quality, deliver less // than requested Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(1'000), {USD(1'200), GBP(1'200)}); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_, bob_, carol_}, XRP(1'000), {USD(1'200), GBP(1'200)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm(env, bob, GBP(1'000), USD(1'200)); + AMM const amm(env, bob_, GBP(1'000), USD(1'200)); // requested quality limit is 90USD/120GBP = 0.75 // trade quality is 22.5USD/30GBP = 0.75 - env(pay(alice, carol, USD(90)), - path(~USD), - sendmax(GBP(120)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(90)), + Path(~USD), + Sendmax(GBP(120)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); if (!features[fixAMMv1_1]) { - // alice buys 28.125USD with 24GBP and pays 25% tr fee + // alice_ buys 28.125USD with 24GBP and pays 25% tr fee // on 24GBP // 1,200 - 24*1.25 = 1,170GBP - BEAST_EXPECT(expectHolding(env, alice, GBP(1'170))); + BEAST_EXPECT(expectHolding(env, alice_, GBP(1'170))); // 24GBP is swapped in for 28.125USD BEAST_EXPECT(amm.expectBalances(GBP(1'024), USD(1'171.875), amm.tokens())); } else { - // alice buys 28.125USD with 24GBP and pays 25% tr fee + // alice_ buys 28.125USD with 24GBP and pays 25% tr fee // on 24GBP // 1,200 - 24*1.25 =~ 1,170GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'169'999999999999), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'169'999999999999), -12})); // 24GBP is swapped in for 28.125USD BEAST_EXPECT(amm.expectBalances( STAmount{GBP, UINT64_C(1'024'000000000001), -12}, @@ -2285,7 +2293,7 @@ private: } // 25% on 22.5USD is paid in tr fee // 22.5*1.25 = 28.125USD - BEAST_EXPECT(expectHolding(env, carol, USD(1'222.5))); + BEAST_EXPECT(expectHolding(env, carol_, USD(1'222.5))); } { // Payment via offer and AMM with limit quality, deliver less @@ -2294,30 +2302,34 @@ private: Account const ed("ed"); fund( - env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(1'400), EUR(1'400), GBP(1'400)}); - env(rate(gw, 1.25)); + env, + gw_, + {alice_, bob_, carol_, ed}, + XRP(1'000), + {USD(1'400), EUR(1'400), GBP(1'400)}); + env(rate(gw_, 1.25)); env.close(); - env(offer(ed, GBP(1'000), EUR(1'000)), txflags(tfPassive)); + env(offer(ed, GBP(1'000), EUR(1'000)), Txflags(tfPassive)); env.close(); - AMM const amm(env, bob, EUR(1'000), USD(1'400)); + AMM const amm(env, bob_, EUR(1'000), USD(1'400)); // requested quality limit is 95USD/140GBP = 0.6785 // trade quality is 59.7321USD/88.0262GBP = 0.6785 - env(pay(alice, carol, USD(95)), - path(~EUR, ~USD), - sendmax(GBP(140)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(95)), + Path(~EUR, ~USD), + Sendmax(GBP(140)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); if (!features[fixAMMv1_1]) { - // alice buys 70.4210EUR with 70.4210GBP via the offer + // alice_ buys 70.4210EUR with 70.4210GBP via the offer // and pays 25% tr fee on 70.4210GBP // 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'311'973684210527), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'311'973684210527), -12})); // ed doesn't pay tr fee, the balances reflect consumed offer // 70.4210GBP/70.4210EUR BEAST_EXPECT(expectHolding( @@ -2341,11 +2353,11 @@ private: } else { - // alice buys 70.4210EUR with 70.4210GBP via the offer + // alice_ buys 70.4210EUR with 70.4210GBP via the offer // and pays 25% tr fee on 70.4210GBP // 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'311'973684210525), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'311'973684210525), -12})); // ed doesn't pay tr fee, the balances reflect consumed offer // 70.4210GBP/70.4210EUR BEAST_EXPECT(expectHolding( @@ -2369,7 +2381,7 @@ private: } // 25% on 59.7321USD is paid in tr fee 59.7321*1.25 = 74.6651USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'459'732142857143), -12))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'459'732142857143), -12))); } { // Payment via AMM and offer with limit quality, deliver less @@ -2378,30 +2390,34 @@ private: Account const ed("ed"); fund( - env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(1'400), EUR(1'400), GBP(1'400)}); - env(rate(gw, 1.25)); + env, + gw_, + {alice_, bob_, carol_, ed}, + XRP(1'000), + {USD(1'400), EUR(1'400), GBP(1'400)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm(env, bob, GBP(1'000), EUR(1'000)); + AMM const amm(env, bob_, GBP(1'000), EUR(1'000)); - env(offer(ed, EUR(1'000), USD(1'400)), txflags(tfPassive)); + env(offer(ed, EUR(1'000), USD(1'400)), Txflags(tfPassive)); env.close(); // requested quality limit is 95USD/140GBP = 0.6785 // trade quality is 47.7857USD/70.4210GBP = 0.6785 - env(pay(alice, carol, USD(95)), - path(~EUR, ~USD), - sendmax(GBP(140)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(95)), + Path(~EUR, ~USD), + Sendmax(GBP(140)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); if (!features[fixAMMv1_1]) { - // alice buys 53.3322EUR with 56.3368GBP via the amm + // alice_ buys 53.3322EUR with 56.3368GBP via the amm // and pays 25% tr fee on 56.3368GBP // 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'329'578947368421), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'329'578947368421), -12})); //// 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 ///= 70.4210EUR // 56.3368GBP is swapped in for 53.3322EUR @@ -2412,11 +2428,11 @@ private: } else { - // alice buys 53.3322EUR with 56.3368GBP via the amm + // alice_ buys 53.3322EUR with 56.3368GBP via the amm // and pays 25% tr fee on 56.3368GBP // 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'329'57894736842), -11})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'329'57894736842), -11})); //// 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 ///= 70.4210EUR // 56.3368GBP is swapped in for 53.3322EUR @@ -2441,7 +2457,7 @@ private: STAmount{USD, UINT64_C(1'340'267857142857), -12}}})); // 25% on 47.7857USD is paid in tr fee 47.7857*1.25 = 59.7321USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'447'785714285714), -12))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'447'785714285714), -12))); } { // Payment via AMM, AMM with limit quality, deliver less @@ -2450,28 +2466,32 @@ private: Account const ed("ed"); fund( - env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(1'400), EUR(1'400), GBP(1'400)}); - env(rate(gw, 1.25)); + env, + gw_, + {alice_, bob_, carol_, ed}, + XRP(1'000), + {USD(1'400), EUR(1'400), GBP(1'400)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm1(env, bob, GBP(1'000), EUR(1'000)); + AMM const amm1(env, bob_, GBP(1'000), EUR(1'000)); AMM const amm2(env, ed, EUR(1'000), USD(1'400)); // requested quality limit is 90USD/145GBP = 0.6206 // trade quality is 66.7432USD/107.5308GBP = 0.6206 - env(pay(alice, carol, USD(90)), - path(~EUR, ~USD), - sendmax(GBP(145)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(90)), + Path(~EUR, ~USD), + Sendmax(GBP(145)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); if (!features[fixAMMv1_1]) { - // alice buys 53.3322EUR with 107.5308GBP + // alice_ buys 53.3322EUR with 107.5308GBP // 25% on 86.0246GBP is paid in tr fee // 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'292'469135802469), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'292'469135802469), -12})); // 86.0246GBP is swapped in for 79.2106EUR BEAST_EXPECT(amm1.expectBalances( STAmount{GBP, UINT64_C(1'086'024691358025), -12}, @@ -2486,11 +2506,11 @@ private: } else { - // alice buys 53.3322EUR with 107.5308GBP + // alice_ buys 53.3322EUR with 107.5308GBP // 25% on 86.0246GBP is paid in tr fee // 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP BEAST_EXPECT( - expectHolding(env, alice, STAmount{GBP, UINT64_C(1'292'469135802466), -12})); + expectHolding(env, alice_, STAmount{GBP, UINT64_C(1'292'469135802466), -12})); // 86.0246GBP is swapped in for 79.2106EUR BEAST_EXPECT(amm1.expectBalances( STAmount{GBP, UINT64_C(1'086'024691358027), -12}, @@ -2505,26 +2525,27 @@ private: } // 25% on 66.7432USD is paid in tr fee 66.7432*1.25 = 83.4291USD BEAST_EXPECT( - expectHolding(env, carol, STAmount(USD, UINT64_C(1'466'743295019157), -12))); + expectHolding(env, carol_, STAmount(USD, UINT64_C(1'466'743295019157), -12))); } { // Payment by the issuer via AMM, AMM with limit quality, // deliver less than requested Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(1'000), {USD(1'400), EUR(1'400), GBP(1'400)}); - env(rate(gw, 1.25)); + fund( + env, gw_, {alice_, bob_, carol_}, XRP(1'000), {USD(1'400), EUR(1'400), GBP(1'400)}); + env(rate(gw_, 1.25)); env.close(); - AMM const amm1(env, alice, GBP(1'000), EUR(1'000)); - AMM const amm2(env, bob, EUR(1'000), USD(1'400)); + AMM const amm1(env, alice_, GBP(1'000), EUR(1'000)); + AMM const amm2(env, bob_, EUR(1'000), USD(1'400)); // requested quality limit is 90USD/120GBP = 0.75 // trade quality is 81.1111USD/108.1481GBP = 0.75 - env(pay(gw, carol, USD(90)), - path(~EUR, ~USD), - sendmax(GBP(120)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(gw_, carol_, USD(90)), + Path(~EUR, ~USD), + Sendmax(GBP(120)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); if (!features[fixAMMv1_1]) @@ -2557,7 +2578,7 @@ private: } // 25% on 81.1111USD is paid in tr fee 81.1111*1.25 = 101.3888USD BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(1'481'111111111111), -12})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(1'481'111111111111), -12})); } } @@ -2574,19 +2595,19 @@ private: { Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(10'000), {USD(2'000)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {USD(2'000)}); - AMM const ammBob(env, bob, XRP(1'000), USD(1'050)); - env(offer(bob, XRP(100), USD(50))); + AMM const ammBob(env, bob_, XRP(1'000), USD(1'050)); + env(offer(bob_, XRP(100), USD(50))); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); BEAST_EXPECT(ammBob.expectBalances(XRP(1'050), USD(1'000), ammBob.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(2'050))); - BEAST_EXPECT(expectOffers(env, bob, 1, {{{XRP(100), USD(50)}}})); + BEAST_EXPECT(expectHolding(env, carol_, USD(2'050))); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{{XRP(100), USD(50)}}})); } } @@ -2598,56 +2619,56 @@ private: using namespace jtx; { // Payment path starting with XRP - Env env(*this, testable_amendments()); - // Note, if alice doesn't have default ripple, then pay + Env env(*this, testableAmendments()); + // Note, if alice_ doesn't have default ripple, then pay // fails with tecPATH_DRY. - fund(env, gw, {alice, bob}, XRP(10'000), {USD(200), EUR(200)}, Fund::All); + fund(env, gw_, {alice_, bob_}, XRP(10'000), {USD(200), EUR(200)}, Fund::All); - AMM const ammAliceXRP_USD(env, alice, XRP(100), USD(101)); - AMM const ammAliceXRP_EUR(env, alice, XRP(100), EUR(101)); + AMM const ammAliceXrpUsd(env, alice_, XRP(100), USD(101)); + AMM const ammAliceXrpEur(env, alice_, XRP(100), EUR(101)); env.close(); TER const expectedTer = TER{temBAD_PATH_LOOP}; - env(pay(alice, bob, EUR(1)), - path(~USD, ~XRP, ~EUR), - sendmax(XRP(1)), - txflags(tfNoRippleDirect), - ter(expectedTer)); + env(pay(alice_, bob_, EUR(1)), + Path(~USD, ~XRP, ~EUR), + Sendmax(XRP(1)), + Txflags(tfNoRippleDirect), + Ter(expectedTer)); } { // Payment path ending with XRP Env env(*this); - // Note, if alice doesn't have default ripple, then pay fails + // Note, if alice_ doesn't have default ripple, then pay fails // with tecPATH_DRY. - fund(env, gw, {alice, bob}, XRP(10'000), {USD(200), EUR(200)}, Fund::All); + fund(env, gw_, {alice_, bob_}, XRP(10'000), {USD(200), EUR(200)}, Fund::All); - AMM const ammAliceXRP_USD(env, alice, XRP(100), USD(100)); - AMM const ammAliceXRP_EUR(env, alice, XRP(100), EUR(100)); + AMM const ammAliceXrpUsd(env, alice_, XRP(100), USD(100)); + AMM const ammAliceXrpEur(env, alice_, XRP(100), EUR(100)); // EUR -> //XRP -> //USD ->XRP - env(pay(alice, bob, XRP(1)), - path(~XRP, ~USD, ~XRP), - sendmax(EUR(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, bob_, XRP(1)), + Path(~XRP, ~USD, ~XRP), + Sendmax(EUR(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { // Payment where loop is formed in the middle of the path, not // on an endpoint - auto const JPY = gw["JPY"]; + auto const jpy = gw_["JPY"]; Env env(*this); - // Note, if alice doesn't have default ripple, then pay fails + // Note, if alice_ doesn't have default ripple, then pay fails // with tecPATH_DRY. - fund(env, gw, {alice, bob}, XRP(10'000), {USD(200), EUR(200), JPY(200)}, Fund::All); + fund(env, gw_, {alice_, bob_}, XRP(10'000), {USD(200), EUR(200), jpy(200)}, Fund::All); - AMM const ammAliceXRP_USD(env, alice, XRP(100), USD(100)); - AMM const ammAliceXRP_EUR(env, alice, XRP(100), EUR(100)); - AMM const ammAliceXRP_JPY(env, alice, XRP(100), JPY(100)); + AMM const ammAliceXrpUsd(env, alice_, XRP(100), USD(100)); + AMM const ammAliceXrpEur(env, alice_, XRP(100), EUR(100)); + AMM const ammAliceXrpJpy(env, alice_, XRP(100), jpy(100)); - env(pay(alice, bob, JPY(1)), - path(~XRP, ~EUR, ~XRP, ~JPY), - sendmax(USD(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, bob_, jpy(1)), + Path(~XRP, ~EUR, ~XRP, ~jpy), + Sendmax(USD(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } } @@ -2661,47 +2682,47 @@ private: auto const dan = Account("dan"); auto const ed = Account("ed"); - fund(env, gw, {ed}, XRP(100'000'000), {USD(11)}); - env.fund(XRP(100'000'000), alice, bob, carol, dan); + fund(env, gw_, {ed}, XRP(100'000'000), {USD(11)}); + env.fund(XRP(100'000'000), alice_, bob_, carol_, dan); env.close(); - env.trust(USD(1), bob); - env(pay(gw, bob, USD(1))); + env.trust(USD(1), bob_); + env(pay(gw_, bob_, USD(1))); env.trust(USD(1), dan); - env(pay(gw, dan, USD(1))); - n_offers(env, 2'000, bob, XRP(1), USD(1)); - n_offers(env, 1, dan, XRP(1), USD(1)); + env(pay(gw_, dan, USD(1))); + nOffers(env, 2'000, bob_, XRP(1), USD(1)); + nOffers(env, 1, dan, XRP(1), USD(1)); AMM const ammEd(env, ed, XRP(9), USD(11)); // Alice offers to buy 1000 XRP for 1000 USD. She takes Bob's first // offer, removes 999 more as unfunded, then hits the step limit. - env(offer(alice, USD(1'000), XRP(1'000))); + env(offer(alice_, USD(1'000), XRP(1'000))); if (!features[fixAMMv1_1]) { - env.require(balance(alice, STAmount{USD, UINT64_C(2'050126257867561), -15})); + env.require(Balance(alice_, STAmount{USD, UINT64_C(2'050126257867561), -15})); } else { - env.require(balance(alice, STAmount{USD, UINT64_C(2'050125257867587), -15})); + env.require(Balance(alice_, STAmount{USD, UINT64_C(2'050125257867587), -15})); } - env.require(owners(alice, 2)); - env.require(balance(bob, USD(0))); - env.require(owners(bob, 1'001)); - env.require(balance(dan, USD(1))); - env.require(owners(dan, 2)); + env.require(Owners(alice_, 2)); + env.require(Balance(bob_, USD(0))); + env.require(Owners(bob_, 1'001)); + env.require(Balance(dan, USD(1))); + env.require(Owners(dan, 2)); // Carol offers to buy 1000 XRP for 1000 USD. She removes Bob's next // 1000 offers as unfunded and hits the step limit. - env(offer(carol, USD(1'000), XRP(1'000))); - env.require(balance(carol, USD(none))); - env.require(owners(carol, 1)); - env.require(balance(bob, USD(0))); - env.require(owners(bob, 1)); - env.require(balance(dan, USD(1))); - env.require(owners(dan, 2)); + env(offer(carol_, USD(1'000), XRP(1'000))); + env.require(Balance(carol_, USD(kNONE))); + env.require(Owners(carol_, 1)); + env.require(Balance(bob_, USD(0))); + env.require(Owners(bob_, 1)); + env.require(Balance(dan, USD(1))); + env.require(Owners(dan, 2)); } void - test_convert_all_of_an_asset(FeatureBitset features) + testConvertAllOfAnAsset(FeatureBitset features) { testcase("Convert all of an asset using DeliverMin"); @@ -2709,103 +2730,104 @@ private: { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); - env.trust(USD(100), alice, bob, carol); - env(pay(alice, bob, USD(10)), deliver_min(USD(10)), ter(temBAD_AMOUNT)); - env(pay(alice, bob, USD(10)), - deliver_min(USD(-5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(alice, bob, USD(10)), - deliver_min(XRP(5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(alice, bob, USD(10)), - deliver_min(Account(carol)["USD"](5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(alice, bob, USD(10)), - deliver_min(USD(15)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(gw, carol, USD(50))); - AMM const ammCarol(env, carol, XRP(10), USD(15)); - env(pay(alice, bob, USD(10)), - paths(XRP), - deliver_min(USD(7)), - txflags(tfPartialPayment), - sendmax(XRP(5)), - ter(tecPATH_PARTIAL)); - env.require(balance(alice, drops(10'000'000'000 - env.current()->fees().base.drops()))); - env.require(balance(bob, XRP(10'000))); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); + env.trust(USD(100), alice_, bob_, carol_); + env(pay(alice_, bob_, USD(10)), DeliverMin(USD(10)), Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, USD(10)), + DeliverMin(USD(-5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, USD(10)), + DeliverMin(XRP(5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, USD(10)), + DeliverMin(Account(carol_)["USD"](5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(alice_, bob_, USD(10)), + DeliverMin(USD(15)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(gw_, carol_, USD(50))); + AMM const ammCarol(env, carol_, XRP(10), USD(15)); + env(pay(alice_, bob_, USD(10)), + Paths(XRP), + DeliverMin(USD(7)), + Txflags(tfPartialPayment), + Sendmax(XRP(5)), + Ter(tecPATH_PARTIAL)); + env.require( + Balance(alice_, drops(10'000'000'000 - env.current()->fees().base.drops()))); + env.require(Balance(bob_, XRP(10'000))); } { Env env(*this, features); - fund(env, gw, {alice, bob}, XRP(10'000)); - env.trust(USD(1'100), alice, bob); - env(pay(gw, bob, USD(1'100))); - AMM const ammBob(env, bob, XRP(1'000), USD(1'100)); - env(pay(alice, alice, USD(10'000)), - paths(XRP), - deliver_min(USD(100)), - txflags(tfPartialPayment), - sendmax(XRP(100))); - env.require(balance(alice, USD(100))); + fund(env, gw_, {alice_, bob_}, XRP(10'000)); + env.trust(USD(1'100), alice_, bob_); + env(pay(gw_, bob_, USD(1'100))); + AMM const ammBob(env, bob_, XRP(1'000), USD(1'100)); + env(pay(alice_, alice_, USD(10'000)), + Paths(XRP), + DeliverMin(USD(100)), + Txflags(tfPartialPayment), + Sendmax(XRP(100))); + env.require(Balance(alice_, USD(100))); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); - env.trust(USD(1'200), bob, carol); - env(pay(gw, bob, USD(1'200))); - AMM const ammBob(env, bob, XRP(5'500), USD(1'200)); - env(pay(alice, carol, USD(10'000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(1'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, USD(10'000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(1'100))); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); + env.trust(USD(1'200), bob_, carol_); + env(pay(gw_, bob_, USD(1'200))); + AMM const ammBob(env, bob_, XRP(5'500), USD(1'200)); + env(pay(alice_, carol_, USD(10'000)), + Paths(XRP), + DeliverMin(USD(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(1'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(10'000)), + Paths(XRP), + DeliverMin(USD(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(1'100))); BEAST_EXPECT(ammBob.expectBalances(XRP(6'600), USD(1'000), ammBob.tokens())); - env.require(balance(carol, USD(200))); + env.require(Balance(carol_, USD(200))); } { auto const dan = Account("dan"); Env env(*this, features); - fund(env, gw, {alice, bob, carol, dan}, XRP(10'000)); + fund(env, gw_, {alice_, bob_, carol_, dan}, XRP(10'000)); env.close(); - env.trust(USD(1'100), bob, carol, dan); - env(pay(gw, bob, USD(100))); - env(pay(gw, dan, USD(1'100))); - env(offer(bob, XRP(100), USD(100))); - env(offer(bob, XRP(1'000), USD(100))); + env.trust(USD(1'100), bob_, carol_, dan); + env(pay(gw_, bob_, USD(100))); + env(pay(gw_, dan, USD(1'100))); + env(offer(bob_, XRP(100), USD(100))); + env(offer(bob_, XRP(1'000), USD(100))); AMM const ammDan(env, dan, XRP(1'000), USD(1'100)); if (!features[fixAMMv1_1]) { - env(pay(alice, carol, USD(10'000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(200))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(200))); + env(pay(alice_, carol_, USD(10'000)), + Paths(XRP), + DeliverMin(USD(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(200))); + env.require(Balance(bob_, USD(0))); + env.require(Balance(carol_, USD(200))); BEAST_EXPECT(ammDan.expectBalances(XRP(1'100), USD(1'000), ammDan.tokens())); } else { - env(pay(alice, carol, USD(10'000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRPAmount(200'000'001))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, STAmount{USD, UINT64_C(200'00000090909), -11})); + env(pay(alice_, carol_, USD(10'000)), + Paths(XRP), + DeliverMin(USD(200)), + Txflags(tfPartialPayment), + Sendmax(XRPAmount(200'000'001))); + env.require(Balance(bob_, USD(0))); + env.require(Balance(carol_, STAmount{USD, UINT64_C(200'00000090909), -11})); BEAST_EXPECT(ammDan.expectBalances( XRPAmount{1'100'000'001}, STAmount{USD, UINT64_C(999'99999909091), -11}, @@ -2826,21 +2848,21 @@ private: // account with the DepositAuth flag set could not make a payment // to itself. That bug was fixed in the DepositPreauth amendment. Env env(*this, features); - fund(env, gw, {alice, becky}, XRP(5'000)); + fund(env, gw_, {alice_, becky}, XRP(5'000)); env.close(); - env.trust(USD(1'000), alice); + env.trust(USD(1'000), alice_); env.trust(USD(1'000), becky); env.close(); - env(pay(gw, alice, USD(500))); + env(pay(gw_, alice_, USD(500))); env.close(); - AMM const ammAlice(env, alice, XRP(100), USD(140)); + AMM const ammAlice(env, alice_, XRP(100), USD(140)); - // becky pays herself USD (10) by consuming part of alice's offer. + // becky pays herself USD (10) by consuming part of alice_'s offer. // Make sure the payment works if PaymentAuth is not involved. - env(pay(becky, becky, USD(10)), path(~USD), sendmax(XRP(10))); + env(pay(becky, becky, USD(10)), Path(~USD), Sendmax(XRP(10))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRPAmount(107'692'308), USD(130), ammAlice.tokens())); @@ -2849,7 +2871,7 @@ private: env.close(); // becky pays herself again. - env(pay(becky, becky, USD(10)), path(~USD), sendmax(XRP(10)), ter(tesSUCCESS)); + env(pay(becky, becky, USD(10)), Path(~USD), Sendmax(XRP(10)), Ter(tesSUCCESS)); env.close(); } @@ -2865,82 +2887,82 @@ private: Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(10'000)); - env.trust(USD(1'000), alice, bob, carol); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000)); + env.trust(USD(1'000), alice_, bob_, carol_); env.close(); - env(pay(gw, alice, USD(150))); - env(pay(gw, carol, USD(150))); - AMM const ammCarol(env, carol, USD(100), XRPAmount(101)); + env(pay(gw_, alice_, USD(150))); + env(pay(gw_, carol_, USD(150))); + AMM const ammCarol(env, carol_, USD(100), XRPAmount(101)); - // Make sure bob's trust line is all set up so he can receive USD. - env(pay(alice, bob, USD(50))); + // Make sure bob_'s trust line is all set up so he can receive USD. + env(pay(alice_, bob_, USD(50))); env.close(); - // bob sets the lsfDepositAuth flag. - env(fset(bob, asfDepositAuth), require(flags(bob, asfDepositAuth))); + // bob_ sets the lsfDepositAuth flag. + env(fset(bob_, asfDepositAuth), Require(Flags(bob_, asfDepositAuth))); env.close(); // None of the following payments should succeed. auto failedIouPayments = [this, &env]() { - env.require(flags(bob, asfDepositAuth)); + env.require(Flags(bob_, asfDepositAuth)); - // Capture bob's balances before hand to confirm they don't + // Capture bob_'s balances before hand to confirm they don't // change. - PrettyAmount const bobXrpBalance{env.balance(bob, XRP)}; - PrettyAmount const bobUsdBalance{env.balance(bob, USD)}; + PrettyAmount const bobXrpBalance{env.balance(bob_, XRP)}; + PrettyAmount const bobUsdBalance{env.balance(bob_, USD)}; - env(pay(alice, bob, USD(50)), ter(tecNO_PERMISSION)); + env(pay(alice_, bob_, USD(50)), Ter(tecNO_PERMISSION)); env.close(); - // Note that even though alice is paying bob in XRP, the payment + // Note that even though alice_ is paying bob_ in XRP, the payment // is still not allowed since the payment passes through an // offer. - env(pay(alice, bob, drops(1)), sendmax(USD(1)), ter(tecNO_PERMISSION)); + env(pay(alice_, bob_, drops(1)), Sendmax(USD(1)), Ter(tecNO_PERMISSION)); env.close(); - BEAST_EXPECT(bobXrpBalance == env.balance(bob, XRP)); - BEAST_EXPECT(bobUsdBalance == env.balance(bob, USD)); + BEAST_EXPECT(bobXrpBalance == env.balance(bob_, XRP)); + BEAST_EXPECT(bobUsdBalance == env.balance(bob_, USD)); }; - // Test when bob has an XRP balance > base reserve. + // Test when bob_ has an XRP balance > base reserve. failedIouPayments(); - // Set bob's XRP balance == base reserve. Also demonstrate that - // bob can make payments while his lsfDepositAuth flag is set. - env(pay(bob, alice, USD(25))); + // Set bob_'s XRP balance == base reserve. Also demonstrate that + // bob_ can make payments while his lsfDepositAuth flag is set. + env(pay(bob_, alice_, USD(25))); env.close(); { - STAmount const bobPaysXRP{env.balance(bob, XRP) - reserve(env, 1)}; + STAmount const bobPaysXRP{env.balance(bob_, XRP) - reserve(env, 1)}; XRPAmount const bobPaysFee{reserve(env, 1) - reserve(env, 0)}; - env(pay(bob, alice, bobPaysXRP), fee(bobPaysFee)); + env(pay(bob_, alice_, bobPaysXRP), Fee(bobPaysFee)); env.close(); } - // Test when bob's XRP balance == base reserve. - BEAST_EXPECT(env.balance(bob, XRP) == reserve(env, 0)); - BEAST_EXPECT(env.balance(bob, USD) == USD(25)); + // Test when bob_'s XRP balance == base reserve. + BEAST_EXPECT(env.balance(bob_, XRP) == reserve(env, 0)); + BEAST_EXPECT(env.balance(bob_, USD) == USD(25)); failedIouPayments(); - // Test when bob has an XRP balance == 0. - env(noop(bob), fee(reserve(env, 0))); + // Test when bob_ has an XRP balance == 0. + env(noop(bob_), Fee(reserve(env, 0))); env.close(); - BEAST_EXPECT(env.balance(bob, XRP) == XRP(0)); + BEAST_EXPECT(env.balance(bob_, XRP) == XRP(0)); failedIouPayments(); - // Give bob enough XRP for the fee to clear the lsfDepositAuth flag. - env(pay(alice, bob, drops(env.current()->fees().base))); + // Give bob_ enough XRP for the fee to clear the lsfDepositAuth flag. + env(pay(alice_, bob_, drops(env.current()->fees().base))); - // bob clears the lsfDepositAuth and the next payment succeeds. - env(fclear(bob, asfDepositAuth)); + // bob_ clears the lsfDepositAuth and the next payment succeeds. + env(fclear(bob_, asfDepositAuth)); env.close(); - env(pay(alice, bob, USD(50))); + env(pay(alice_, bob_, USD(50))); env.close(); - env(pay(alice, bob, drops(1)), sendmax(USD(1))); + env(pay(alice_, bob_, drops(1)), Sendmax(USD(1))); env.close(); BEAST_EXPECT(ammCarol.expectBalances(USD(101), XRPAmount(100), ammCarol.tokens())); } @@ -2953,37 +2975,37 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; + Account const g1{"G1"}; Account const alice{"alice"}; Account const bob{"bob"}; - env.fund(XRP(1'000), G1, alice, bob); + env.fund(XRP(1'000), g1, alice, bob); env.close(); - env.trust(G1["USD"](100), bob); - env.trust(G1["USD"](205), alice); + env.trust(g1["USD"](100), bob); + env.trust(g1["USD"](205), alice); env.close(); - env(pay(G1, bob, G1["USD"](10))); - env(pay(G1, alice, G1["USD"](205))); + env(pay(g1, bob, g1["USD"](10))); + env(pay(g1, alice, g1["USD"](205))); env.close(); - AMM const ammAlice(env, alice, XRP(500), G1["USD"](105)); + AMM const ammAlice(env, alice, XRP(500), g1["USD"](105)); { auto lines = getAccountLines(env, bob); if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u))) return; - BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human()); + BEAST_EXPECT(lines[jss::lines][0u][jss::account] == g1.human()); BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "100"); BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "10"); } { - auto lines = getAccountLines(env, alice, G1["USD"]); + auto lines = getAccountLines(env, alice, g1["USD"]); if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u))) return; - BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human()); + BEAST_EXPECT(lines[jss::lines][0u][jss::account] == g1.human()); BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "205"); // 105 transferred to AMM BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "100"); @@ -2991,41 +3013,41 @@ private: // Account with line unfrozen (proving operations normally work) // test: can make Payment on that line - env(pay(alice, bob, G1["USD"](1))); + env(pay(alice, bob, g1["USD"](1))); // test: can receive Payment on that line - env(pay(bob, alice, G1["USD"](1))); + env(pay(bob, alice, g1["USD"](1))); env.close(); // Is created via a TrustSet with SetFreeze flag // test: sets LowFreeze | HighFreeze flags - env(trust(G1, bob["USD"](0), tfSetFreeze)); + env(trust(g1, bob["USD"](0), tfSetFreeze)); env.close(); { // Account with line frozen by issuer // test: can buy more assets on that line - env(offer(bob, G1["USD"](5), XRP(25))); + env(offer(bob, g1["USD"](5), XRP(25))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(XRP(525), G1["USD"](100), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectBalances(XRP(525), g1["USD"](100), ammAlice.tokens())); } { // test: can not sell assets from that line - env(offer(bob, XRP(1), G1["USD"](5)), ter(tecUNFUNDED_OFFER)); + env(offer(bob, XRP(1), g1["USD"](5)), Ter(tecUNFUNDED_OFFER)); // test: can receive Payment on that line - env(pay(alice, bob, G1["USD"](1))); + env(pay(alice, bob, g1["USD"](1))); // test: can not make Payment from that line - env(pay(bob, alice, G1["USD"](1)), ter(tecPATH_DRY)); + env(pay(bob, alice, g1["USD"](1)), Ter(tecPATH_DRY)); } { // check G1 account lines // test: shows freeze - auto lines = getAccountLines(env, G1); - Json::Value bobLine; + auto lines = getAccountLines(env, g1); + json::Value bobLine; for (auto const& it : lines[jss::lines]) { if (it[jss::account] == bob.human()) @@ -3043,10 +3065,10 @@ private: { // test: shows freeze peer auto lines = getAccountLines(env, bob); - Json::Value g1Line; + json::Value g1Line; for (auto const& it : lines[jss::lines]) { - if (it[jss::account] == G1.human()) + if (it[jss::account] == g1.human()) { g1Line = it; break; @@ -3061,13 +3083,13 @@ private: { // Is cleared via a TrustSet with ClearFreeze flag // test: sets LowFreeze | HighFreeze flags - env(trust(G1, bob["USD"](0), tfClearFreeze)); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, bob["USD"](0), tfClearFreeze)); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 2u))) return; auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; BEAST_EXPECT( - ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none)); + ff[sfLowLimit.fieldName] == g1["USD"](0).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze)); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze)); env.close(); @@ -3082,32 +3104,32 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; - env.fund(XRP(12'000), G1); - env.fund(XRP(1'000), A1); - env.fund(XRP(20'000), A2, A3, A4); + env.fund(XRP(12'000), g1); + env.fund(XRP(1'000), a1); + env.fund(XRP(20'000), a2, a3, a4); env.close(); - env.trust(G1["USD"](1'200), A1); - env.trust(G1["USD"](200), A2); - env.trust(G1["BTC"](100), A3); - env.trust(G1["BTC"](100), A4); + env.trust(g1["USD"](1'200), a1); + env.trust(g1["USD"](200), a2); + env.trust(g1["BTC"](100), a3); + env.trust(g1["BTC"](100), a4); env.close(); - env(pay(G1, A1, G1["USD"](1'000))); - env(pay(G1, A2, G1["USD"](100))); - env(pay(G1, A3, G1["BTC"](100))); - env(pay(G1, A4, G1["BTC"](100))); + env(pay(g1, a1, g1["USD"](1'000))); + env(pay(g1, a2, g1["USD"](100))); + env(pay(g1, a3, g1["BTC"](100))); + env(pay(g1, a4, g1["BTC"](100))); env.close(); - AMM const ammG1(env, G1, XRP(10'000), G1["USD"](100)); - env(offer(A1, XRP(10'000), G1["USD"](100)), txflags(tfPassive)); - env(offer(A2, G1["USD"](100), XRP(10'000)), txflags(tfPassive)); + AMM const ammG1(env, g1, XRP(10'000), g1["USD"](100)); + env(offer(a1, XRP(10'000), g1["USD"](100)), Txflags(tfPassive)); + env(offer(a2, g1["USD"](100), XRP(10'000)), Txflags(tfPassive)); env.close(); { @@ -3115,7 +3137,7 @@ private: // work) // test: visible offers where taker_pays is unfrozen issuer auto offers = env.rpc( - "book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers]; + "book_offers", std::string("USD/") + g1.human(), "XRP")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; std::set accounts; @@ -3123,11 +3145,11 @@ private: { accounts.insert(offer[jss::Account].asString()); } - BEAST_EXPECT(accounts.find(A2.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(a2.human()) != std::end(accounts)); // test: visible offers where taker_gets is unfrozen issuer offers = env.rpc( - "book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers]; + "book_offers", "XRP", std::string("USD/") + g1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; accounts.clear(); @@ -3135,29 +3157,29 @@ private: { accounts.insert(offer[jss::Account].asString()); } - BEAST_EXPECT(accounts.find(A1.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(a1.human()) != std::end(accounts)); } { // Offers/Payments // test: assets can be bought on the market // env(offer(A3, G1["BTC"](1), XRP(1))); - AMM ammA3(env, A3, G1["BTC"](1), XRP(1)); + AMM ammA3(env, a3, g1["BTC"](1), XRP(1)); // test: assets can be sold on the market // AMM is bidirectional // test: direct issues can be sent - env(pay(G1, A2, G1["USD"](1))); + env(pay(g1, a2, g1["USD"](1))); // test: direct redemptions can be sent - env(pay(A2, G1, G1["USD"](1))); + env(pay(a2, g1, g1["USD"](1))); // test: via rippling can be sent - env(pay(A2, A1, G1["USD"](1))); + env(pay(a2, a1, g1["USD"](1))); // test: via rippling can be sent back - env(pay(A1, A2, G1["USD"](1))); + env(pay(a1, a2, g1["USD"](1))); ammA3.withdrawAll(std::nullopt); } @@ -3165,13 +3187,13 @@ private: // Account with GlobalFreeze // set GlobalFreeze first // test: SetFlag GlobalFreeze will toggle back to freeze - env.require(nflags(G1, asfGlobalFreeze)); - env(fset(G1, asfGlobalFreeze)); - env.require(flags(G1, asfGlobalFreeze)); - env.require(nflags(G1, asfNoFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); + env(fset(g1, asfGlobalFreeze)); + env.require(Flags(g1, asfGlobalFreeze)); + env.require(Nflags(g1, asfNoFreeze)); // test: assets can't be bought on the market - AMM const ammA3(env, A3, G1["BTC"](1), XRP(1), ter(tecFROZEN)); + AMM const ammA3(env, a3, g1["BTC"](1), XRP(1), Ter(tecFROZEN)); // test: assets can't be sold on the market // AMM is bidirectional @@ -3181,12 +3203,12 @@ private: // test: book_offers shows offers // (should these actually be filtered?) auto offers = env.rpc( - "book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers]; + "book_offers", "XRP", std::string("USD/") + g1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; offers = env.rpc( - "book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers]; + "book_offers", std::string("USD/") + g1.human(), "XRP")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; } @@ -3194,13 +3216,13 @@ private: { // Payments // test: direct issues can be sent - env(pay(G1, A2, G1["USD"](1))); + env(pay(g1, a2, g1["USD"](1))); // test: direct redemptions can be sent - env(pay(A2, G1, G1["USD"](1))); + env(pay(a2, g1, g1["USD"](1))); // test: via rippling cant be sent - env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY)); + env(pay(a2, a1, g1["USD"](1)), Ter(tecPATH_DRY)); } } @@ -3212,63 +3234,63 @@ private: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; + Account const g1{"G1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; - env.fund(XRP(2'000), G1, A3, A4); - env.fund(XRP(2'000), A2); + env.fund(XRP(2'000), g1, a3, a4); + env.fund(XRP(2'000), a2); env.close(); - env.trust(G1["USD"](1'000), A2); - env.trust(G1["USD"](2'000), A3); - env.trust(G1["USD"](2'001), A4); + env.trust(g1["USD"](1'000), a2); + env.trust(g1["USD"](2'000), a3); + env.trust(g1["USD"](2'001), a4); env.close(); - env(pay(G1, A3, G1["USD"](2'000))); - env(pay(G1, A4, G1["USD"](2'001))); + env(pay(g1, a3, g1["USD"](2'000))); + env(pay(g1, a4, g1["USD"](2'001))); env.close(); - AMM const ammA3(env, A3, XRP(1'000), G1["USD"](1'001)); + AMM const ammA3(env, a3, XRP(1'000), g1["USD"](1'001)); // removal after successful payment // test: make a payment with partially consuming offer - env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1))); + env(pay(a2, g1, g1["USD"](1)), Paths(g1["USD"]), Sendmax(XRP(1))); env.close(); - BEAST_EXPECT(ammA3.expectBalances(XRP(1'001), G1["USD"](1'000), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'001), g1["USD"](1'000), ammA3.tokens())); // test: someone else creates an offer providing liquidity - env(offer(A4, XRP(999), G1["USD"](999))); + env(offer(a4, XRP(999), g1["USD"](999))); env.close(); // The offer consumes AMM offer - BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), G1["USD"](1'001), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), g1["USD"](1'001), ammA3.tokens())); // test: AMM line is frozen - auto const a3am = STAmount{Issue{to_currency("USD"), ammA3.ammAccount()}, 0}; - env(trust(G1, a3am, tfSetFreeze)); + auto const a3am = STAmount{Issue{toCurrency("USD"), ammA3.ammAccount()}, 0}; + env(trust(g1, a3am, tfSetFreeze)); auto const info = ammA3.ammRpcInfo(); BEAST_EXPECT(info[jss::amm][jss::asset2_frozen].asBool()); env.close(); // test: Can make a payment via the new offer - env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1))); + env(pay(a2, g1, g1["USD"](1)), Paths(g1["USD"]), Sendmax(XRP(1))); env.close(); // AMM is not consumed - BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), G1["USD"](1'001), ammA3.tokens())); + BEAST_EXPECT(ammA3.expectBalances(XRP(1'000), g1["USD"](1'001), ammA3.tokens())); // removal buy successful OfferCreate // test: freeze the new offer - env(trust(G1, A4["USD"](0), tfSetFreeze)); + env(trust(g1, a4["USD"](0), tfSetFreeze)); env.close(); // test: can no longer create a crossing offer - env(offer(A2, G1["USD"](999), XRP(999))); + env(offer(a2, g1["USD"](999), XRP(999))); env.close(); // test: offer was removed by offer_create - auto offers = getAccountOffers(env, A4)[jss::offers]; + auto offers = getAccountOffers(env, a4)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 0u))) return; } @@ -3280,23 +3302,23 @@ private: using namespace jtx; Env env{*this, features}; - Account const bogie{"bogie", KeyType::secp256k1}; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const zelda{"zelda", KeyType::secp256k1}; - fund(env, gw, {alice, becky, zelda}, XRP(20'000), {USD(20'000)}); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const zelda{"zelda", KeyType::Secp256k1}; + fund(env, gw_, {alice, becky, zelda}, XRP(20'000), {USD(20'000)}); - // alice uses a regular key with the master disabled. - Account const alie{"alie", KeyType::secp256k1}; + // alice_ uses a regular key with the master disabled. + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); - // Attach signers to alice. - env(signers(alice, 2, {{becky, 1}, {bogie, 1}}), sig(alie)); + // Attach signers to alice_. + env(signers(alice, 2, {{becky, 1}, {bogie, 1}}), Sig(alie)); env.close(); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); - msig const ms{becky, bogie}; + Msig const ms{becky, bogie}; // Multisign all AMM transactions AMM ammAlice( @@ -3310,7 +3332,7 @@ private: std::nullopt, std::nullopt, ms, - ter(tesSUCCESS)); + Ter(tesSUCCESS)); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'000), ammAlice.tokens())); ammAlice.deposit(alice, 1'000'000); @@ -3339,17 +3361,17 @@ private: Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000), {USD(2'000), EUR(1'000)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {USD(2'000), EUR(1'000)}); - AMM const bobXRP_USD(env, bob, XRP(1'000), USD(1'000)); - AMM const bobUSD_EUR(env, bob, USD(1'000), EUR(1'000)); + AMM const bobXrpUsd(env, bob_, XRP(1'000), USD(1'000)); + AMM const bobUsdEur(env, bob_, USD(1'000), EUR(1'000)); // payment path: XRP -> XRP/USD -> USD/EUR -> EUR/USD - env(pay(alice, carol, USD(100)), - path(~USD, ~EUR, ~USD), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, USD(100)), + Path(~USD, ~EUR, ~USD), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } void @@ -3360,63 +3382,63 @@ private: { Env env(*this, features); - auto const BobUSD = bob["USD"]; - auto const BobEUR = bob["EUR"]; - fund(env, gw, {alice, bob}, XRP(10'000)); - env.trust(USD(1'000), alice, bob); - env.trust(EUR(1'000), alice, bob); + auto const bobUsd = bob_["USD"]; + auto const bobEur = bob_["EUR"]; + fund(env, gw_, {alice_, bob_}, XRP(10'000)); + env.trust(USD(1'000), alice_, bob_); + env.trust(EUR(1'000), alice_, bob_); env.close(); - fund(env, bob, {alice, gw}, {BobUSD(100), BobEUR(100)}, Fund::TokenOnly); + fund(env, bob_, {alice_, gw_}, {bobUsd(100), bobEur(100)}, Fund::TokenOnly); - AMM const ammBobXRP_USD(env, bob, XRP(100), BobUSD(100)); - env(offer(gw, XRP(100), USD(100)), txflags(tfPassive)); + AMM const ammBobXrpUsd(env, bob_, XRP(100), bobUsd(100)); + env(offer(gw_, XRP(100), USD(100)), Txflags(tfPassive)); - AMM const ammBobUSD_EUR(env, bob, BobUSD(100), BobEUR(100)); - env(offer(gw, USD(100), EUR(100)), txflags(tfPassive)); + AMM const ammBobUsdEur(env, bob_, bobUsd(100), bobEur(100)); + env(offer(gw_, USD(100), EUR(100)), Txflags(tfPassive)); - Path const p = [&] { - Path result; - result.push_back(allPathElements(gw, BobUSD)); - result.push_back(cpe(EUR.currency)); + TestPath const p = [&] { + TestPath result; + result.pushBack(allPathElements(gw_, bobUsd)); + result.pushBack(cpe(EUR.currency)); return result; }(); PathSet const paths(p); - env(pay(alice, alice, EUR(1)), - json(paths.json()), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(temBAD_PATH)); + env(pay(alice_, alice_, EUR(1)), + Json(paths.json()), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(temBAD_PATH)); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000), {USD(100)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {USD(100)}); - AMM const ammBob(env, bob, XRP(100), USD(100)); + AMM const ammBob(env, bob_, XRP(100), USD(100)); // payment path: XRP -> XRP/USD -> USD/XRP - env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_PATHS)); + env(pay(alice_, carol_, XRP(100)), + Path(~USD, ~XRP), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_PATHS)); } { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(10'000), {USD(100)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(10'000), {USD(100)}); - AMM const ammBob(env, bob, XRP(100), USD(100)); + AMM const ammBob(env, bob_, XRP(100), USD(100)); // payment path: XRP -> XRP/USD -> USD/XRP - env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_MAX)); + env(pay(alice_, carol_, XRP(100)), + Path(~USD, ~XRP), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_MAX)); } } @@ -3426,65 +3448,65 @@ private: testcase("test loop"); using namespace jtx; - auto const CNY = gw["CNY"]; + auto const cny = gw_["CNY"]; { Env env(*this, features); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - env.trust(USD(10'000), alice, bob, carol); + env.trust(USD(10'000), alice_, bob_, carol_); env.close(); - env(pay(gw, bob, USD(100))); - env(pay(gw, alice, USD(100))); + env(pay(gw_, bob_, USD(100))); + env(pay(gw_, alice_, USD(100))); env.close(); - AMM const ammBob(env, bob, XRP(100), USD(100)); + AMM const ammBob(env, bob_, XRP(100), USD(100)); // payment path: USD -> USD/XRP -> XRP/USD - env(pay(alice, carol, USD(100)), - sendmax(USD(100)), - path(~XRP, ~USD), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, USD(100)), + Sendmax(USD(100)), + Path(~XRP, ~USD), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { Env env(*this, features); - env.fund(XRP(10'000), alice, bob, carol, gw); + env.fund(XRP(10'000), alice_, bob_, carol_, gw_); env.close(); - env.trust(USD(10'000), alice, bob, carol); - env.trust(EUR(10'000), alice, bob, carol); - env.trust(CNY(10'000), alice, bob, carol); + env.trust(USD(10'000), alice_, bob_, carol_); + env.trust(EUR(10'000), alice_, bob_, carol_); + env.trust(cny(10'000), alice_, bob_, carol_); - env(pay(gw, bob, USD(200))); - env(pay(gw, bob, EUR(200))); - env(pay(gw, bob, CNY(100))); + env(pay(gw_, bob_, USD(200))); + env(pay(gw_, bob_, EUR(200))); + env(pay(gw_, bob_, cny(100))); - AMM const ammBobXRP_USD(env, bob, XRP(100), USD(100)); - AMM const ammBobUSD_EUR(env, bob, USD(100), EUR(100)); - AMM const ammBobEUR_CNY(env, bob, EUR(100), CNY(100)); + AMM const ammBobXrpUsd(env, bob_, XRP(100), USD(100)); + AMM const ammBobUsdEur(env, bob_, USD(100), EUR(100)); + AMM const ammBobEurCny(env, bob_, EUR(100), cny(100)); // payment path: XRP->XRP/USD->USD/EUR->USD/CNY - env(pay(alice, carol, CNY(100)), - sendmax(XRP(100)), - path(~USD, ~EUR, ~USD, ~CNY), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice_, carol_, cny(100)), + Sendmax(XRP(100)), + Path(~USD, ~EUR, ~USD, ~cny), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } } void testPaths() { - path_find_consume_all(); - via_offers_via_gateway(); - receive_max(); - path_find_01(); - path_find_02(); - path_find_05(); - path_find_06(); + pathFindConsumeAll(); + viaOffersViaGateway(); + receiveMax(); + pathFind01(); + pathFind02(); + pathFind05(); + pathFind06(); } void @@ -3494,7 +3516,7 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas in the transaction engine FeatureBitset const all{ - testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; + testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; testFalseDry(all); testBookStep(all); @@ -3511,7 +3533,7 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas in the transaction engine FeatureBitset const all{ - testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; + testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; testStepLimit(all); testStepLimit(all - fixAMMv1_1 - fixAMMv1_3); } @@ -3523,9 +3545,9 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas in the transaction engine FeatureBitset const all{ - testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; - test_convert_all_of_an_asset(all); - test_convert_all_of_an_asset(all - fixAMMv1_1 - fixAMMv1_3); + testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; + testConvertAllOfAnAsset(all); + testConvertAllOfAnAsset(all - fixAMMv1_1 - fixAMMv1_3); } void @@ -3534,7 +3556,7 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas in the transaction engine FeatureBitset const all{ - jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; + jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; testPayment(all); testPayIOU(); } @@ -3546,7 +3568,7 @@ private: // For now, just disable SAV entirely, which locks in the small Number // mantissas in the transaction engine FeatureBitset const sa{ - testable_amendments() - featureSingleAssetVault - featureLendingProtocol}; + testableAmendments() - featureSingleAssetVault - featureLendingProtocol}; testRippleState(sa); testGlobalFreeze(sa); testOffersWhenFrozen(sa); @@ -3555,13 +3577,13 @@ private: void testMultisign() { - testTxMultisign(jtx::testable_amendments()); + testTxMultisign(jtx::testableAmendments()); } void testPayStrand() { - auto const all = jtx::testable_amendments(); + auto const all = jtx::testableAmendments(); testToStrand(all); testRIPD1373(all); diff --git a/src/test/app/AMMMPT_test.cpp b/src/test/app/AMMMPT_test.cpp index f453d6cf75..4318a19503 100644 --- a/src/test/app/AMMMPT_test.cpp +++ b/src/test/app/AMMMPT_test.cpp @@ -75,7 +75,7 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'000), IOUAmount{10'000'000})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // IOU to MPT testAMM( @@ -83,7 +83,7 @@ private: BEAST_EXPECT(ammAlice.expectBalances( USD(20'000), MPT(ammAlice[1])(20'000), IOUAmount{20'000})); }, - {{USD(20'000), AMMMPT(20'000)}}); + {{USD(20'000), gAmmmpt(20'000)}}); // MPT to MPT testAMM( @@ -91,62 +91,62 @@ private: BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(20'000), MPT(ammAlice[1])(20'000), IOUAmount{20'000})); }, - {{AMMMPT(20'000), AMMMPT(20'000)}}); + {{gAmmmpt(20'000), gAmmmpt(20'000)}}); // IOU to MPT + transfer fee { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); + env(rate(gw_, 1.25)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .transferFee = 1'500, .pay = 30'000}); // no transfer fee on create - AMM const ammAlice(env, alice, USD(20'000), BTC(20'000)); - BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(20'000), IOUAmount{20'000, 0})); - BEAST_EXPECT(expectHolding(env, alice, USD(0))); + AMM const ammAlice(env, alice_, USD(20'000), btc(20'000)); + BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), btc(20'000), IOUAmount{20'000, 0})); + BEAST_EXPECT(expectHolding(env, alice_, USD(0))); // alice initially had 30'000 - BEAST_EXPECT(expectMPT(env, alice, BTC(10'000))); + BEAST_EXPECT(expectMPT(env, alice_, btc(10'000))); } // Require authorization is set, account is authorized { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(fset(gw, asfRequireAuth)); - env(trust(alice, gw["USD"](30'000), 0)); - env(trust(gw, alice["USD"](0), tfSetfAuth)); - env(pay(gw, alice, USD(10'000))); + env(fset(gw_, asfRequireAuth)); + env(trust(alice_, gw_["USD"](30'000), 0)); + env(trust(gw_, alice_["USD"](0), tfSetfAuth)); + env(pay(gw_, alice_, USD(10'000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000)); + AMM const ammAlice(env, alice_, USD(10'000), btc(10'000)); } // Cleared global freeze { Env env{*this}; - env.fund(XRP(30'000), gw, alice); - MPTTester USD( + env.fund(XRP(30'000), gw_, alice_); + MPTTester usd( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - USD.set({.flags = tfMPTLock}); - AMM const ammAliceFail(env, alice, XRP(10'000), USD(10'000), ter(tecFROZEN)); - USD.set({.flags = tfMPTUnlock}); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000)); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + usd.set({.flags = tfMPTLock}); + AMM const ammAliceFail(env, alice_, XRP(10'000), usd(10'000), Ter(tecFROZEN)); + usd.set({.flags = tfMPTUnlock}); + AMM const ammAlice(env, alice_, XRP(10'000), usd(10'000)); } } @@ -160,89 +160,89 @@ private: // Can't have both tokens the same MPT { Env env{*this}; - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .transferFee = 1'500, .pay = 40'000}); - AMM const ammAlice(env, alice, BTC(20'000), BTC(10'000), ter(temBAD_AMM_TOKENS)); + AMM const ammAlice(env, alice_, btc(20'000), btc(10'000), Ter(temBAD_AMM_TOKENS)); } // MPTCanTrade is not set and AMM creator is not the issuer of MPT { Env env{*this}; - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 40'000, .flags = tfMPTCanLock}); - AMM const ammAlice(env, alice, BTC(20'000), XRP(10'000), ter(tecNO_PERMISSION)); + AMM const ammAlice(env, alice_, btc(20'000), XRP(10'000), Ter(tecNO_PERMISSION)); } // MPTokenIssuance doesn't exist { Env env{*this}; - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); AMM const ammAlice( - env, alice, MPT(gw, 1'000)(20'000), XRP(10'000), ter(tecOBJECT_NOT_FOUND)); + env, alice_, MPT(gw_, 1'000)(20'000), XRP(10'000), Ter(tecOBJECT_NOT_FOUND)); } // MPToken doesn't exist and amm creator is not the issuer { Env env{*this}; - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - MPT const BTC = MPTTester({ + MPT const btc = MPTTester({ .env = env, - .issuer = gw, + .issuer = gw_, }); - AMM const ammAlice(env, alice, BTC(20'000), XRP(10'000), ter(tecNO_AUTH)); + AMM const ammAlice(env, alice_, btc(20'000), XRP(10'000), Ter(tecNO_AUTH)); } // Can't have zero or negative amounts { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); + env(rate(gw_, 1.25)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .transferFee = 1'500, .pay = 30'000}); - AMM const ammAlice(env, alice, XRP(0), BTC(10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice(env, alice_, XRP(0), btc(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice.ammExists()); - AMM const ammAlice1(env, alice, XRP(10'000), BTC(0), ter(temBAD_AMOUNT)); + AMM const ammAlice1(env, alice_, XRP(10'000), btc(0), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice1.ammExists()); - AMM const ammAlice2(env, alice, USD(0), BTC(10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice2(env, alice_, USD(0), btc(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice2.ammExists()); - AMM const ammAlice3(env, alice, USD(10'000), BTC(0), ter(temBAD_AMOUNT)); + AMM const ammAlice3(env, alice_, USD(10'000), btc(0), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice3.ammExists()); - AMM const ammAlice4(env, alice, XRP(-10'0000), BTC(10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice4(env, alice_, XRP(-10'0000), btc(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice4.ammExists()); - AMM const ammAlice5(env, alice, XRP(10'000), BTC(-10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice5(env, alice_, XRP(10'000), btc(-10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice5.ammExists()); - AMM const ammAlice6(env, alice, USD(-10'000), BTC(10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice6(env, alice_, USD(-10'000), btc(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice6.ammExists()); - AMM const ammAlice7(env, alice, USD(10'000), BTC(-10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice7(env, alice_, USD(10'000), btc(-10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice7.ammExists()); } // Bad MPT { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(10'000), MPT(badMPT())(100), ter(temBAD_MPT)); + AMM const ammAlice(env, alice_, XRP(10'000), MPT(badMPT())(100), Ter(temBAD_MPT)); BEAST_EXPECT(!ammAlice.ammExists()); } @@ -250,39 +250,39 @@ private: // Insufficient MPT balance { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .transferFee = 1'500, .pay = 30'000}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(40'000), ter(tecUNFUNDED_AMM)); + AMM const ammAlice(env, alice_, XRP(10'000), btc(40'000), Ter(tecUNFUNDED_AMM)); BEAST_EXPECT(!ammAlice.ammExists()); } // Invalid trading fee { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .transferFee = 1'500, .pay = 30'000}); AMM const ammAlice( env, - alice, + alice_, USD(10'000), - BTC(10'000), + btc(10'000), false, 65'001, 10, std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_FEE)); + Ter(temBAD_FEE)); BEAST_EXPECT(!ammAlice.ammExists()); } @@ -290,106 +290,106 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // Account bob1("bob1"); - env.fund(XRP(30'000), bob); + env.fund(XRP(30'000), bob_); env.close(); - AMM const ammBob(env, bob, XRP(1'000), MPT(ammAlice[1])(1'000), ter(tecDUPLICATE)); + AMM const ammBob(env, bob_, XRP(1'000), MPT(ammAlice[1])(1'000), Ter(tecDUPLICATE)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // AMM already exists IOU/MPT testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(30'000), bob); + env.fund(XRP(30'000), bob_); env.close(); - env.trust(USD(10000), bob); - env(pay(gw, bob, USD(100))); + env.trust(USD(10000), bob_); + env(pay(gw_, bob_, USD(100))); - AMM const ammBob(env, bob, USD(1'000), MPT(ammAlice[1])(1'000), ter(tecDUPLICATE)); + AMM const ammBob(env, bob_, USD(1'000), MPT(ammAlice[1])(1'000), Ter(tecDUPLICATE)); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // AMM already exists MPT/MPT testAMM( [&](AMM& ammAlice, Env& env) { AMM const ammCarol( env, - carol, + carol_, MPT(ammAlice[0])(1'000), MPT(ammAlice[1])(2'000), - ter(tecDUPLICATE)); + Ter(tecDUPLICATE)); }, - {{AMMMPT(20'000), AMMMPT(10'000)}}); + {{gAmmmpt(20'000), gAmmmpt(10'000)}}); // MPTRequireAuth flag is set and AMM creator is not authorized { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(fset(gw, asfRequireAuth)); - env(trust(alice, gw["USD"](30'000), 0)); - env(trust(gw, alice["USD"](0), tfSetfAuth)); + env(fset(gw_, asfRequireAuth)); + env(trust(alice_, gw_["USD"](30'000), 0)); + env(trust(gw_, alice_["USD"](0), tfSetfAuth)); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw_, alice_, USD(10'000))); env.close(); - MPT const BTC = MPTTester( - {.env = env, .issuer = gw, .holders = {alice}, .flags = tfMPTRequireAuth}); - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000), ter(tecNO_AUTH)); + MPT const btc = MPTTester( + {.env = env, .issuer = gw_, .holders = {alice_}, .flags = tfMPTRequireAuth}); + AMM const ammAlice(env, alice_, USD(10'000), btc(10'000), Ter(tecNO_AUTH)); BEAST_EXPECT(!ammAlice.ammExists()); } // MPTLocked flag is set { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); - MPTTester BTC( + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - BTC.set({.flags = tfMPTLock}); - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000), ter(tecFROZEN)); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + btc.set({.flags = tfMPTLock}); + AMM const ammAlice(env, alice_, USD(10'000), btc(10'000), Ter(tecFROZEN)); BEAST_EXPECT(!ammAlice.ammExists()); } // MPT individually locked { Env env{*this}; - fund(env, gw, {alice, bob}, {USD(20'000)}, Fund::All); - MPTTester BTC( + fund(env, gw_, {alice_, bob_}, {USD(20'000)}, Fund::All); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - BTC.set({.holder = alice, .flags = tfMPTLock}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + btc.set({.holder = alice_, .flags = tfMPTLock}); // alice's token is locked - AMM const ammAlice(env, alice, USD(10'000), BTC(10'000), ter(tecFROZEN)); + AMM const ammAlice(env, alice_, USD(10'000), btc(10'000), Ter(tecFROZEN)); BEAST_EXPECT(!ammAlice.ammExists()); // bob can create - AMM const ammBob(env, bob, USD(10'000), BTC(10'000)); + AMM const ammBob(env, bob_, USD(10'000), btc(10'000)); BEAST_EXPECT(ammBob.ammExists()); } // OutstandingAmount > MaximumAmount { Env env{*this}; - env.fund(XRP(1'000), gw, alice); + env.fund(XRP(1'000), gw_, alice_); - MPTTester const BTC({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 100}); + MPTTester const btc({.env = env, .issuer = gw_, .holders = {alice_}, .maxAmt = 100}); // OutstandingAmount is 0, issuer issues 10 over MaximumAmount - AMM const amm(env, gw, XRP(100), BTC(110), ter(tecUNFUNDED_AMM)); + AMM const amm(env, gw_, XRP(100), btc(110), Ter(tecUNFUNDED_AMM)); - env(pay(gw, alice, BTC(100))); + env(pay(gw_, alice_, btc(100))); // OutstandingAmount is 100, issuer issues 100 over MaximumAmount - AMM const amm1(env, gw, XRP(100), BTC(100), ter(tecUNFUNDED_AMM)); + AMM const amm1(env, gw_, XRP(100), btc(100), Ter(tecUNFUNDED_AMM)); // This is fine - alice transfers 100 to AMM. OutstandingAmount // is 100. - AMM const ammAlice(env, alice, XRP(100), BTC(100)); + AMM const ammAlice(env, alice_, XRP(100), btc(100)); } } @@ -403,40 +403,42 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // LPTokenOut can not be zero - ammAlice.deposit(alice, 0, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(alice_, 0, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // LPTokenOut can not be negative ammAlice.deposit( - alice, IOUAmount{-1}, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, IOUAmount{-1}, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // LPTokenOut can not be MPT { - Json::Value jv = Json::objectValue; - jv[jss::Account] = alice.human(); + json::Value jv = json::ObjectValue; + jv[jss::Account] = alice_.human(); jv[jss::TransactionType] = jss::AMMDeposit; - jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::none); - jv[jss::Asset2] = STIssue(sfAsset, MPT(ammAlice[1])).getJson(JsonOptions::none); - jv[jss::LPTokenOut] = MPT(ammAlice[1])(100).value().getJson(JsonOptions::none); + jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::KNone); + jv[jss::Asset2] = + STIssue(sfAsset, MPT(ammAlice[1])).getJson(JsonOptions::KNone); + jv[jss::LPTokenOut] = MPT(ammAlice[1])(100).value().getJson(JsonOptions::KNone); jv[jss::Flags] = tfLPToken; - env(jv, ter(telENV_RPC_FAILED)); + env(jv, Ter(telENV_RPC_FAILED)); } // Provided LPTokenOut does not match AMM pool's LPToken // asset { - Json::Value jv = Json::objectValue; - jv[jss::Account] = alice.human(); + json::Value jv = json::ObjectValue; + jv[jss::Account] = alice_.human(); jv[jss::TransactionType] = jss::AMMDeposit; - jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::none); - jv[jss::Asset2] = STIssue(sfAsset, MPT(ammAlice[1])).getJson(JsonOptions::none); - jv[jss::LPTokenOut] = USD(100).value().getJson(JsonOptions::none); + jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::KNone); + jv[jss::Asset2] = + STIssue(sfAsset, MPT(ammAlice[1])).getJson(JsonOptions::KNone); + jv[jss::LPTokenOut] = USD(100).value().getJson(JsonOptions::KNone); jv[jss::Flags] = tfLPToken; - env(jv, ter(temBAD_AMM_TOKENS)); + env(jv, Ter(temBAD_AMM_TOKENS)); } // Invalid trading fee ammAlice.deposit( - carol, + carol_, std::nullopt, XRP(200), MPT(ammAlice[1])(200), @@ -445,14 +447,14 @@ private: std::nullopt, std::nullopt, 10'000, - ter(temBAD_FEE)); + Ter(temBAD_FEE)); // Invalid tokens { auto const mpt1 = MPTIssue{MPTID(0xabc)}; auto const mpt2 = MPTIssue{MPTID(0xdef)}; ammAlice.deposit( - alice, + alice_, 1'000, std::nullopt, std::nullopt, @@ -461,78 +463,78 @@ private: {{mpt1, mpt2}}, std::nullopt, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); } // invalid MPT ammAlice.deposit( - alice, badMPT(), std::nullopt, std::nullopt, std::nullopt, ter(temBAD_MPT)); + alice_, badMPT(), std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_MPT)); ammAlice.deposit( - alice, XRP(100), badMPT(), std::nullopt, std::nullopt, ter(temBAD_MPT)); + alice_, XRP(100), badMPT(), std::nullopt, std::nullopt, Ter(temBAD_MPT)); // MPTokenIssuance object doesn't exist ammAlice.deposit( - alice, + alice_, XRP(100), - MPT(gw, 1'000)(100), + MPT(gw_, 1'000)(100), std::nullopt, tfTwoAsset, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // MPToken object doesn't exist - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); ammAlice.deposit( - bob, + bob_, XRP(100), MPT(ammAlice[1])(200), std::nullopt, tfTwoAsset, - ter(tecNO_AUTH)); + Ter(tecNO_AUTH)); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, - .flags = tfMPTCanLock | MPTDEXFlags, + .issuer = gw_, + .holders = {alice_, carol_}, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .authHolder = true}); // Depositing mismatched token, invalid Asset1In.issue ammAlice.deposit( - alice, - BTC(100), + alice_, + btc(100), std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // Depositing mismatched token, invalid Asset2In.issue ammAlice.deposit( - alice, XRP(100), BTC(100), std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, XRP(100), btc(100), std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Assets can not be the same ammAlice.deposit( - alice, + alice_, MPT(ammAlice[1])(100), MPT(ammAlice[1])(200), std::nullopt, tfTwoAsset, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // Invalid amount value ammAlice.deposit( - alice, + alice_, MPT(ammAlice[1])(0), std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); ammAlice.deposit( - alice, + alice_, MPT(ammAlice[1])(-1'000), std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); // Invalid Account { @@ -546,28 +548,28 @@ private: std::nullopt, std::nullopt, std::nullopt, - seq(1), + Seq(1), std::nullopt, - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); } // Invalid AMM ammAlice.deposit( - alice, + alice_, 1'000, std::nullopt, std::nullopt, std::nullopt, std::nullopt, - {{MPT(BTC), MPT(ammAlice[1])}}, + {{MPT(btc), MPT(ammAlice[1])}}, std::nullopt, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); // Single deposit: 100000 tokens worth of MPT // Amount to deposit exceeds Max ammAlice.deposit( - carol, + carol_, 100'000, MPT(ammAlice[1])(200), std::nullopt, @@ -576,12 +578,12 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Single deposit: 100000 tokens worth of XRP // Amount to deposit exceeds Max ammAlice.deposit( - carol, + carol_, 100'000, XRP(200), std::nullopt, @@ -590,54 +592,54 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Deposit amount is invalid ammAlice.deposit( - alice, + alice_, MPT(ammAlice[1])(0), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); // Calculated amount is 0 ammAlice.deposit( - alice, + alice_, MPT(ammAlice[1])(0), std::nullopt, STAmount{ammAlice.lptIssue(), 2'000, -6}, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Tiny deposit ammAlice.deposit( - carol, + carol_, IOUAmount{1, -10}, std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Deposit non-empty AMM ammAlice.deposit( - carol, + carol_, XRP(100), MPT(ammAlice[1])(100), std::nullopt, tfTwoAssetIfEmpty, - ter(tecAMM_NOT_EMPTY)); + Ter(tecAMM_NOT_EMPTY)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Tiny deposit testAMM( [&](AMM& ammAlice, Env& env) { - auto const enabledV1_3 = env.current()->rules().enabled(fixAMMv1_3); - auto const err = !enabledV1_3 ? ter(temBAD_AMOUNT) : ter(tesSUCCESS); + auto const enabledV13 = env.current()->rules().enabled(fixAMMv1_3); + auto const err = !enabledV13 ? Ter(temBAD_AMOUNT) : Ter(tesSUCCESS); // Pre-amendment XRP deposit side is rounded to 0 // and deposit fails. - ammAlice.deposit(carol, IOUAmount{1, -1}, std::nullopt, std::nullopt, err); + ammAlice.deposit(carol_, IOUAmount{1, -1}, std::nullopt, std::nullopt, err); }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 0, std::nullopt, {features, features - fixAMMv1_3}); @@ -645,212 +647,215 @@ private: // Invalid AMM testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); - ammAlice.deposit(alice, 10'000, std::nullopt, std::nullopt, ter(terNO_AMM)); + ammAlice.withdrawAll(alice_); + ammAlice.deposit(alice_, 10'000, std::nullopt, std::nullopt, Ter(terNO_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit MPT with eprice // the calculated amount to deposit is negative. testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}, tfLimitLPToken, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // although we should use lptoken unit for eprice, // we don't check the currency any more, we just use // the value ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{USD, 1, -1}, tfLimitLPToken, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Globally locked MPT { Env env{*this}; - fund(env, gw, {alice, carol}, {USD(20'000)}, Fund::All); - MPTTester BTC( + fund(env, gw_, {alice_, carol_}, {USD(20'000)}, Fund::All); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, USD(10'000), BTC(10'000)); - BTC.set({.flags = tfMPTLock}); + AMM ammAlice(env, alice_, USD(10'000), btc(10'000)); + btc.set({.flags = tfMPTLock}); ammAlice.deposit( - carol, BTC(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, btc(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); - ammAlice.deposit(carol, USD(100), BTC(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit( + carol_, USD(100), btc(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); } // Individually lock MPT or freeze IOU (AMM) with IOU/MPT AMM { Env env{*this, features}; - fund(env, gw, {alice, carol}, {USD(20'000)}, Fund::All); - MPTTester BTC( + fund(env, gw_, {alice_, carol_}, {USD(20'000)}, Fund::All); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, USD(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, USD(10'000), btc(10'000)); // Carol's mpt is locked - BTC.set({.holder = carol, .flags = tfMPTLock}); + btc.set({.holder = carol_, .flags = tfMPTLock}); // Carol can not deposit locked mpt ammAlice.deposit( - carol, BTC(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, btc(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); if (!features[featureAMMClawback]) { ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecLOCKED)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecLOCKED)); } else { // Carol can not deposit non-forzen token either ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); } // Alice can deposit because she's not individually locked - ammAlice.deposit(alice, BTC(100), std::nullopt, std::nullopt, std::nullopt); - ammAlice.deposit(alice, 1'000, std::nullopt, std::nullopt); - ammAlice.deposit(alice, USD(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(alice_, btc(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(alice_, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(alice_, USD(100), std::nullopt, std::nullopt, std::nullopt); // Unlock - BTC.set({.holder = carol, .flags = tfMPTUnlock}); + btc.set({.holder = carol_, .flags = tfMPTUnlock}); // Carol can deposit after unlock - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt); // Individually frozen AMM env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); + gw_, STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); env.close(); // Can deposit non-frozen token - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); // Cannot deposit frozen token - ammAlice.deposit(carol, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); // unfreeze IOU env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfClearFreeze)); + gw_, + STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, + tfClearFreeze)); env.close(); // Can deposit - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt); // Individually lock AMM - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); // Can deposit non-frozen token - ammAlice.deposit(carol, USD(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, USD(100), std::nullopt, std::nullopt, std::nullopt); // Can not deposit locked token - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, BTC(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, btc(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unlock AMM MPT - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); // can deposit - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt); - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); } // Individually lock MPT (AMM) account with MPT/MPT AMM { Env env{*this}; - env.fund(XRP(10'000), gw, alice, carol); + env.fund(XRP(10'000), gw_, alice_, carol_); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester USD( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester usd( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 40'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, USD(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, usd(10'000), btc(10'000)); // Carol's BTC is locked - BTC.set({.holder = carol, .flags = tfMPTLock}); + btc.set({.holder = carol_, .flags = tfMPTLock}); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, usd(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, BTC(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, btc(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unlock carol's BTC - BTC.set({.holder = carol, .flags = tfMPTUnlock}); + btc.set({.holder = carol_, .flags = tfMPTUnlock}); // Can deposit - ammAlice.deposit(carol, USD(100), std::nullopt, std::nullopt, std::nullopt); - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, usd(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); // Individually lock MPT BTC (AMM) account - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); // Can deposit non-locked token USD - ammAlice.deposit(carol, USD(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, usd(100), std::nullopt, std::nullopt, std::nullopt); // Can not deposit locked token BTC - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, BTC(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, btc(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unlock AMM MPT BTC - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); // Can deposit BTC - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt); - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); // Individually Lock MPT USD (AMM) account - USD.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); + usd.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); // Can deposit non-locked token BTC - ammAlice.deposit(carol, BTC(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, btc(100), std::nullopt, std::nullopt, std::nullopt); // Can not deposit locked token USD - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, usd(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unlock AMM MPT USD - USD.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); + usd.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); // Can deposit USD - ammAlice.deposit(carol, 1'000, std::nullopt, std::nullopt); - ammAlice.deposit(carol, USD(100), std::nullopt, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, 1'000, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, usd(100), std::nullopt, std::nullopt, std::nullopt); } // Deposit unauthorized token @@ -860,15 +865,15 @@ private: env.fund(XRP(30'000), alice, carol, gw); env.close(); - MPTTester BTC(env, gw, {.holders = {alice, carol}, .fund = false}); - BTC.create( + MPTTester btc(env, gw, {.holders = {alice, carol}, .fund = false}); + btc.create( {.maxAmt = 1'000'000, .authorize = {{alice}}, .pay = {{{alice}, 10'000}}, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - AMM amm(env, alice, XRP(10'000), BTC(10'000)); + AMM amm(env, alice, XRP(10'000), btc(10'000)); env.close(); if (!features[featureAMMClawback]) @@ -878,7 +883,7 @@ private: else { amm.deposit( - carol, XRP(10), std::nullopt, std::nullopt, std::nullopt, ter(tecNO_AUTH)); + carol, XRP(10), std::nullopt, std::nullopt, std::nullopt, Ter(tecNO_AUTH)); } } @@ -889,75 +894,75 @@ private: env.fund(XRP(30'000), alice, carol, gw); env.close(); - MPTTester const BTC( + MPTTester const btc( {.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000, .flags = tfMPTCanTrade}); - AMM amm(env, gw, XRP(10'000), BTC(10'000)); + AMM amm(env, gw, XRP(10'000), btc(10'000)); - amm.deposit({.account = alice, .asset1In = BTC(10), .err = ter(tecNO_PERMISSION)}); + amm.deposit({.account = alice, .asset1In = btc(10), .err = Ter(tecNO_PERMISSION)}); } // Insufficient XRP balance testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); - ammAlice.deposit(bob, XRP(10)); + ammAlice.deposit(bob_, XRP(10)); ammAlice.deposit( - bob, + bob_, XRP(1'000), std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Insufficient MPT balance testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(450'000), std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Insufficient IOU balance testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {USD(1'000)}, Fund::Acct); + fund(env, gw_, {bob_}, {USD(1'000)}, Fund::Acct); ammAlice.deposit( - bob, + bob_, USD(1'001), std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); }, - {{USD(1000), AMMMPT(1000)}}); + {{USD(1000), gAmmmpt(1000)}}); // Insufficient MPT balance by tokens { Env env{*this}; - env.fund(XRP(30'000), alice, bob, gw); + env.fund(XRP(30'000), alice_, bob_, gw_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .transferFee = 1'500, .pay = 1000}); - AMM ammAlice(env, alice, XRP(20'000), BTC(1000)); + AMM ammAlice(env, alice_, XRP(20'000), btc(1000)); ammAlice.deposit( - bob, + bob_, 10'000'000, std::nullopt, std::nullopt, @@ -966,52 +971,52 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); } // Insufficient reserve, XRP/MPT { Env env(*this); - auto const starting_xrp = reserve(env, 4) + env.current()->fees().base * 4; - env.fund(XRP(10'000), gw); - env.fund(XRP(10'000), alice); - env.fund(starting_xrp, carol); + auto const startingXrp = reserve(env, 4) + env.current()->fees().base * 4; + env.fund(XRP(10'000), gw_); + env.fund(XRP(10'000), alice_); + env.fund(startingXrp, carol_); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 1'500, .pay = 40'000}); - env(offer(carol, XRP(100), BTC(101))); - AMM ammAlice(env, alice, XRP(1000), BTC(1000)); + env(offer(carol_, XRP(100), btc(101))); + AMM ammAlice(env, alice_, XRP(1000), btc(1000)); ammAlice.deposit( - carol, + carol_, XRP(100), std::nullopt, std::nullopt, std::nullopt, - ter(tecINSUF_RESERVE_LINE)); + Ter(tecINSUF_RESERVE_LINE)); - env(offer(carol, XRP(100), BTC(102))); + env(offer(carol_, XRP(100), btc(102))); ammAlice.deposit( - carol, - BTC(100), + carol_, + btc(100), std::nullopt, std::nullopt, std::nullopt, - ter(tecINSUF_RESERVE_LINE)); + Ter(tecINSUF_RESERVE_LINE)); } // Invalid min testAMM( [&](AMM& ammAlice, Env& env) { // min tokens can't be <= zero - ammAlice.deposit(carol, 0, XRP(100), tfSingleAsset, ter(temBAD_AMM_TOKENS)); - ammAlice.deposit(carol, -1, XRP(100), tfSingleAsset, ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(carol_, 0, XRP(100), tfSingleAsset, Ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(carol_, -1, XRP(100), tfSingleAsset, Ter(temBAD_AMM_TOKENS)); ammAlice.deposit( - carol, + carol_, 0, XRP(100), MPT(ammAlice[1])(100), @@ -1020,11 +1025,11 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // min amounts can't be <= zero ammAlice.deposit( - carol, + carol_, 1'000, XRP(0), MPT(ammAlice[1])(100), @@ -1033,9 +1038,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), MPT(ammAlice[1])(-1), @@ -1044,9 +1049,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), badMPT(), @@ -1055,16 +1060,16 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_MPT)); + Ter(temBAD_MPT)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Min deposit testAMM( [&](AMM& ammAlice, Env& env) { // Equal deposit by tokens ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), MPT(ammAlice[1])(1'001), @@ -1073,9 +1078,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'001), MPT(ammAlice[1])(1'000), @@ -1084,10 +1089,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Equal deposit by asset ammAlice.deposit( - carol, + carol_, 100'001, XRP(100), MPT(ammAlice[1])(100), @@ -1096,10 +1101,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Single deposit by asset ammAlice.deposit( - carol, + carol_, 488'090, XRP(1'000), std::nullopt, @@ -1108,30 +1113,30 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); }, - {{XRP(1000), AMMMPT(1000)}}); + {{XRP(1000), gAmmmpt(1000)}}); // OutstandingAmount > MaximumAmount { Env env{*this}; - env.fund(XRP(1'000), gw, alice); + env.fund(XRP(1'000), gw_, alice_); - MPTTester const BTC({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 100}); + MPTTester const btc({.env = env, .issuer = gw_, .holders = {alice_}, .maxAmt = 100}); - AMM amm(env, gw, XRP(100), BTC(90)); + AMM amm(env, gw_, XRP(100), btc(90)); // OutstandingAmount is 90, issuer issues 1 over MaximumAmount amm.deposit( - DepositArg{.account = gw, .asset1In = BTC(11), .err = ter(tecUNFUNDED_AMM)}); + DepositArg{.account = gw_, .asset1In = btc(11), .err = Ter(tecUNFUNDED_AMM)}); - env(pay(gw, alice, BTC(10))); + env(pay(gw_, alice_, btc(10))); // OutstandingAmount is 100, issuer issues 10 over MaximumAmount amm.deposit( - DepositArg{.account = gw, .asset1In = BTC(10), .err = ter(tecUNFUNDED_AMM)}); + DepositArg{.account = gw_, .asset1In = btc(10), .err = Ter(tecUNFUNDED_AMM)}); // This is fine - alice transfers 10 to AMM. OutstandingAmount // is 100. - amm.deposit(DepositArg{.account = alice, .asset1In = BTC(10)}); + amm.deposit(DepositArg{.account = alice_, .asset1In = btc(10)}); } } @@ -1146,25 +1151,25 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); // carol deposited 1000 XRP and pays the transaction fee - env.require(balance(carol, carolXRP - XRP(1000) - drops(baseFee))); + env.require(Balance(carol_, carolXRP - XRP(1000) - drops(baseFee))); // carol deposited 1000 MPT - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(1000))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(1000))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // single deposit MPT with eprice testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}, @@ -1174,47 +1179,47 @@ private: // we don't check the currency any more, we just use // the value ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{USD, 1, -1}, tfLimitLPToken); }, - {{USD(10'000'000), AMMMPT(10'000)}}); + {{USD(10'000'000), gAmmmpt(10'000)}}); // Equal deposit: 1000000 tokens. IOU/MPT combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); - ammAlice.deposit(carol, 1'000); - BEAST_EXPECT(ammAlice.expectBalances(BTC(11'000), USD(11'000), IOUAmount(11'000))); + ammAlice.deposit(carol_, 1'000); + BEAST_EXPECT(ammAlice.expectBalances(btc(11'000), usd(11'000), IOUAmount(11'000))); - env.require(balance(carol, carolBTC - BTC(1000))); - env.require(balance(carol, carolUSD - USD(1000))); + env.require(Balance(carol_, carolBTC - btc(1000))); + env.require(Balance(carol_, carolUSD - usd(1000))); }; testHelper2TokensMix(test); } @@ -1223,51 +1228,51 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, MPT(ammAlice[1])(100), XRP(100)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(100), XRP(100)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'100), IOUAmount{10'100'000, 0})); - env.require(balance(carol, carolXRP - XRP(100) - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(100))); + env.require(Balance(carol_, carolXRP - XRP(100) - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(100))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Deposit MPT/IOU combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); - ammAlice.deposit(carol, BTC(100), USD(100)); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); + ammAlice.deposit(carol_, btc(100), usd(100)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(10'100), USD(10'100), IOUAmount(10'100))); + BEAST_EXPECT(ammAlice.expectBalances(btc(10'100), usd(10'100), IOUAmount(10'100))); - env.require(balance(carol, carolBTC - BTC(100))); - env.require(balance(carol, carolUSD - USD(100))); + env.require(Balance(carol_, carolBTC - btc(100))); + env.require(Balance(carol_, carolUSD - usd(100))); }; testHelper2TokensMix(test); } @@ -1277,50 +1282,50 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, MPT(ammAlice[1])(200), XRP(100)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(200), XRP(100)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'100), IOUAmount{10'100'000, 0})); - env.require(balance(carol, carolXRP - XRP(100) - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(100))); + env.require(Balance(carol_, carolXRP - XRP(100) - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(100))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal limit deposit. MPT/IOU combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); - ammAlice.deposit(carol, BTC(200), USD(100)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(10'100), USD(10'100), IOUAmount(10'100))); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); + ammAlice.deposit(carol_, btc(200), usd(100)); + BEAST_EXPECT(ammAlice.expectBalances(btc(10'100), usd(10'100), IOUAmount(10'100))); - env.require(balance(carol, carolBTC - BTC(100))); - env.require(balance(carol, carolUSD - USD(100))); + env.require(Balance(carol_, carolBTC - btc(100))); + env.require(Balance(carol_, carolUSD - usd(100))); }; testHelper2TokensMix(test); } @@ -1329,156 +1334,156 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, MPT(ammAlice[1])(1000)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(11'000), IOUAmount{10'488'088'48170151, -8})); - env.require(balance(carol, carolXRP - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(1000))); + env.require(Balance(carol_, carolXRP - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(1000))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit: 1000 XRP into MPT/XRP testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, XRP(1000)); + ammAlice.deposit(carol_, XRP(1000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(10'000), IOUAmount{10'488'088'48170151, -8})); - env.require(balance(carol, carolXRP - XRP(1000) - drops(baseFee))); - env.require(balance(carol, carolMPT)); + env.require(Balance(carol_, carolXRP - XRP(1000) - drops(baseFee))); + env.require(Balance(carol_, carolMPT)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit: 1000 MPT0 into MPT/MPT testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT0 = env.balance(carol, MPT(ammAlice[0])); - auto carolMPT1 = env.balance(carol, MPT(ammAlice[1])); + auto carolMPT0 = env.balance(carol_, MPT(ammAlice[0])); + auto carolMPT1 = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, MPT(ammAlice[0])(1000)); + ammAlice.deposit(carol_, MPT(ammAlice[0])(1000)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(11'000), MPT(ammAlice[1])(10'000), IOUAmount{10'488'08848170151, -11})); - env.require(balance(carol, carolMPT0 - MPT(ammAlice[0])(1000))); - env.require(balance(carol, carolMPT1)); + env.require(Balance(carol_, carolMPT0 - MPT(ammAlice[0])(1000))); + env.require(Balance(carol_, carolMPT1)); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); // Single deposit: 1000 MPT into MPT/IOU testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[0])); - auto carolUSD = env.balance(carol, USD); + auto carolMPT = env.balance(carol_, MPT(ammAlice[0])); + auto carolUSD = env.balance(carol_, USD); - ammAlice.deposit(carol, MPT(ammAlice[0])(1000)); + ammAlice.deposit(carol_, MPT(ammAlice[0])(1000)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(11'000), USD(10'000), IOUAmount{10'488'08848170151, -11})); - env.require(balance(carol, carolMPT - MPT(ammAlice[0])(1000))); - env.require(balance(carol, carolUSD)); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[0])(1000))); + env.require(Balance(carol_, carolUSD)); }, - {{AMMMPT(10'000), USD(10'000)}}); + {{gAmmmpt(10'000), USD(10'000)}}); // Single deposit: 1000 IOU into MPT/IOU testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[0])); - auto carolUSD = env.balance(carol, USD); + auto carolMPT = env.balance(carol_, MPT(ammAlice[0])); + auto carolUSD = env.balance(carol_, USD); - ammAlice.deposit(carol, USD(1000)); + ammAlice.deposit(carol_, USD(1000)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000), STAmount{USD, UINT64_C(10999'99999999999), -11}, IOUAmount{10'488'08848170151, -11})); - env.require(balance(carol, carolMPT)); + env.require(Balance(carol_, carolMPT)); env.require( - balance(carol, carolUSD - STAmount{USD, UINT64_C(999'99999999999), -11})); + Balance(carol_, carolUSD - STAmount{USD, UINT64_C(999'99999999999), -11})); }, - {{AMMMPT(10'000), USD(10'000)}}); + {{gAmmmpt(10'000), USD(10'000)}}); // Single deposit: 100000 tokens worth of MPT into XRP/MPT testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, 100'000, MPT(ammAlice[1])(205)); + ammAlice.deposit(carol_, 100'000, MPT(ammAlice[1])(205)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'201), IOUAmount{10'100'000, 0})); - env.require(balance(carol, carolXRP - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(201))); + env.require(Balance(carol_, carolXRP - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(201))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit: 100000 tokens worth of XRP into XRP/MPT testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); - ammAlice.deposit(carol, 100'000, XRP(205)); + ammAlice.deposit(carol_, 100'000, XRP(205)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'201), MPT(ammAlice[1])(10'000), IOUAmount{10'100'000, 0})); - env.require(balance(carol, carolXRP - XRP(201) - drops(baseFee))); - env.require(balance(carol, carolMPT)); + env.require(Balance(carol_, carolXRP - XRP(201) - drops(baseFee))); + env.require(Balance(carol_, carolMPT)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit: 100 tokens worth of MPT/IOU into pool of MPT/IOU // combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); - ammAlice.deposit(carol, 100, USD(205)); + ammAlice.deposit(carol_, 100, usd(205)); auto deltaUSD = [&]() { - if constexpr (std::is_same_v>) - return USD(202); - return USD(201); + if constexpr (std::is_same_v>) + return usd(202); + return usd(201); }(); BEAST_EXPECT(ammAlice.expectBalances( - BTC(10'000), USD(10'000) + deltaUSD, IOUAmount{10'100, 0})); + btc(10'000), usd(10'000) + deltaUSD, IOUAmount{10'100, 0})); - env.require(balance(carol, carolBTC)); - env.require(balance(carol, carolUSD - deltaUSD)); + env.require(Balance(carol_, carolBTC)); + env.require(Balance(carol_, carolUSD - deltaUSD)); }; testHelper2TokensMix(test); } @@ -1489,7 +1494,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}); @@ -1497,18 +1502,18 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10100), IOUAmount{10'049'875'62112089, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit with EP not exceeding specified: // 100 MPT with EP not to exceed 0.002004 (AssetIn/TokensOut) testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 2004, -6}); @@ -1516,21 +1521,21 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'081), IOUAmount{10'039'920'31840891, -8})); - env.require(balance(carol, carolXRP - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(81))); + env.require(Balance(carol_, carolXRP - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(81))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit with EP not exceeding specified: // 0 MPT with EP not to exceed 0.002004 (AssetIn/TokensOut) testAMM( [&](AMM& ammAlice, Env& env) { XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(0), std::nullopt, STAmount{ammAlice.lptIssue(), 2004, -6}); @@ -1538,10 +1543,10 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'081), IOUAmount{10'039'920'31840891, -8})); - env.require(balance(carol, carolXRP - drops(baseFee))); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(81))); + env.require(Balance(carol_, carolXRP - drops(baseFee))); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(81))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit with EP not exceeding specified: // 100 MPT with EP not to exceed 0.1 (AssetIn/TokensOut) @@ -1549,7 +1554,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}); @@ -1559,21 +1564,21 @@ private: MPT(ammAlice[1])(10100), IOUAmount{10'049'875'62112089, -8})); }, - {{USD(10'000'000'000), AMMMPT(10'000)}}); + {{USD(10'000'000'000), gAmmmpt(10'000)}}); // Single deposit with EP not exceeding specified: // 100 IOU with EP not to exceed 0.1 (AssetIn/TokensOut) // for IOU/MPT testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, USD(100), std::nullopt, STAmount{USD, 1, -1}); + ammAlice.deposit(carol_, USD(100), std::nullopt, STAmount{USD, 1, -1}); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[1])(10'000'000'000), USD(10100), IOUAmount{10'049'875'62112089, -8})); }, - {{USD(10'000), AMMMPT(10'000'000'000)}}); + {{USD(10'000), gAmmmpt(10'000'000'000)}}); // Single deposit with EP not exceeding specified: // 100 IOU with EP not to exceed 0.1 (AssetIn/TokensOut) @@ -1581,7 +1586,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, MPT(ammAlice[0])(100), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}); @@ -1591,198 +1596,198 @@ private: MPT(ammAlice[0])(10100), IOUAmount{10'049'875'62112089, -8})); }, - {{AMMMPT(10'000), AMMMPT(10'000'000'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000'000'000)}}); // MPT/MPT with transfer fee { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); + env.fund(XRP(30'000), gw_, alice_, carol_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 25'000, .pay = 400'000}); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 25'000, .pay = 400'000}); - AMM ammAlice(env, alice, USD(200'000), BTC(5)); - BEAST_EXPECT(ammAlice.expectBalances(USD(200'000), BTC(5), IOUAmount{1000, 0})); + AMM ammAlice(env, alice_, usd(200'000), btc(5)); + BEAST_EXPECT(ammAlice.expectBalances(usd(200'000), btc(5), IOUAmount{1000, 0})); - ammAlice.deposit(carol, 100, std::nullopt, std::nullopt); - BEAST_EXPECT(ammAlice.expectBalances(USD(220'000), BTC(6), IOUAmount{1100, 0})); + ammAlice.deposit(carol_, 100, std::nullopt, std::nullopt); + BEAST_EXPECT(ammAlice.expectBalances(usd(220'000), btc(6), IOUAmount{1100, 0})); } // IOU/MPT with transfer fee { Env env(*this); - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); env.close(); - env(rate(gw, 1.25)); + env(rate(gw_, 1.25)); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 400'000}); - auto const USD = gw["USD"]; - env.trust(USD(1000000), alice); - env(pay(gw, alice, USD(1000000))); - env.trust(USD(1000000), bob); - env(pay(gw, bob, USD(1000000))); - env.trust(USD(1000000), carol); - env(pay(gw, carol, USD(1000000))); + auto const usd = gw_["USD"]; + env.trust(usd(1000000), alice_); + env(pay(gw_, alice_, usd(1000000))); + env.trust(usd(1000000), bob_); + env(pay(gw_, bob_, usd(1000000))); + env.trust(usd(1000000), carol_); + env(pay(gw_, carol_, usd(1000000))); env.close(); // IOU/MPT - AMM ammAlice(env, alice, USD(200'000), BTC(5)); - BEAST_EXPECT(ammAlice.expectBalances(USD(200'000), BTC(5), IOUAmount{1000, 0})); - ammAlice.deposit(carol, 100, std::nullopt, std::nullopt); - BEAST_EXPECT(ammAlice.expectBalances(USD(220'000), BTC(6), IOUAmount{1100, 0})); + AMM ammAlice(env, alice_, usd(200'000), btc(5)); + BEAST_EXPECT(ammAlice.expectBalances(usd(200'000), btc(5), IOUAmount{1000, 0})); + ammAlice.deposit(carol_, 100, std::nullopt, std::nullopt); + BEAST_EXPECT(ammAlice.expectBalances(usd(220'000), btc(6), IOUAmount{1100, 0})); - MPT const ETH = MPTTester( + MPT const eth = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 400'000}); // MPT/IOU - AMM ammBob(env, bob, ETH(20'000), USD(0.5)); - BEAST_EXPECT(ammBob.expectBalances(ETH(20'000), USD(0.5), IOUAmount{100, 0})); - ammBob.deposit(carol, 10); - BEAST_EXPECT(ammBob.expectBalances(ETH(22'000), USD(0.55), IOUAmount{110, 0})); + AMM ammBob(env, bob_, eth(20'000), usd(0.5)); + BEAST_EXPECT(ammBob.expectBalances(eth(20'000), usd(0.5), IOUAmount{100, 0})); + ammBob.deposit(carol_, 10); + BEAST_EXPECT(ammBob.expectBalances(eth(22'000), usd(0.55), IOUAmount{110, 0})); } // Tiny deposits for IOU/MPT testAMM( [&](AMM& ammAlice, Env& env) { // tiny amount causes MPT to deposit rounded to 0 - ammAlice.deposit(carol, IOUAmount{1, -3}, std::nullopt, std::nullopt); + ammAlice.deposit(carol_, IOUAmount{1, -3}, std::nullopt, std::nullopt); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(10'000'001), -3}, MPT(ammAlice[1])(10'001), IOUAmount{10'000'001, -3})); - ammAlice.deposit(carol, IOUAmount{1}); + ammAlice.deposit(carol_, IOUAmount{1}); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(10'001'001), -3}, MPT(ammAlice[1])(10'003), IOUAmount{10'001'001, -3})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, STAmount{USD, 1, -10}); + ammAlice.deposit(carol_, STAmount{USD, 1, -10}); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(10'000'00000000008), -11}, MPT(ammAlice[1])(10'000), IOUAmount{1'000'000'000000004, -11})); - ammAlice.deposit(carol, MPT(ammAlice[1])(1)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1)); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(10'000'00000000008), -11}, MPT(ammAlice[1])(10'001), IOUAmount{10'000'49998750066, -11})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Tiny deposits for XRP/MPT testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, XRPAmount{1}); + ammAlice.deposit(carol_, XRPAmount{1}); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'001}, MPT(ammAlice[1])(10'000), IOUAmount{1'000'000'000049999, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'001), IOUAmount{10'000'499'98750062, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Tiny deposits for MPT/MPT testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000), MPT(ammAlice[1])(10'001), IOUAmount{1'000'049'998750062, -11})); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); // MPT Issuer create/deposit { Env env(*this); - env.fund(XRP(30'000), gw); + env.fund(XRP(30'000), gw_); env.close(); - MPT const BTC = MPTTester({.env = env, .issuer = gw, .holders = {}}); + MPT const btc = MPTTester({.env = env, .issuer = gw_, .holders = {}}); - AMM ammGw(env, gw, XRP(10'000), BTC(10'000'000'000)); + AMM ammGw(env, gw_, XRP(10'000), btc(10'000'000'000)); BEAST_EXPECT( - ammGw.expectBalances(XRP(10'000), BTC(10'000'000'000), IOUAmount{10'000'000'000})); + ammGw.expectBalances(XRP(10'000), btc(10'000'000'000), IOUAmount{10'000'000'000})); - ammGw.deposit(gw, 1'000'000); + ammGw.deposit(gw_, 1'000'000); BEAST_EXPECT( - ammGw.expectBalances(XRP(10'001), BTC(10'001000000), IOUAmount{10'001000000})); + ammGw.expectBalances(XRP(10'001), btc(10'001000000), IOUAmount{10'001000000})); - ammGw.deposit(gw, BTC(1'000000000)); + ammGw.deposit(gw_, btc(1'000000000)); BEAST_EXPECT(ammGw.expectBalances( - XRP(10'001), BTC(11'001000000), IOUAmount{1048'908'961731188, -5})); + XRP(10'001), btc(11'001000000), IOUAmount{1048'908'961731188, -5})); } // Issuer deposit in MPT/MPT pool testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(gw, 1'000'000); + ammAlice.deposit(gw_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(1'010'000), MPT(ammAlice[1])(1'010'000), IOUAmount{1'010'000})); - ammAlice.deposit(gw, MPT(ammAlice[0])(1000)); + ammAlice.deposit(gw_, MPT(ammAlice[0])(1000)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(1'010'999), MPT(ammAlice[1])(1'010'000), IOUAmount{1'010'499'376546071, -9})); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); // Issuer deposit in MPT/XRP pool testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(gw, 1'000'000); + ammAlice.deposit(gw_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000})); - ammAlice.deposit(gw, MPT(ammAlice[1])(1'000)); + ammAlice.deposit(gw_, MPT(ammAlice[1])(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(12'000), IOUAmount{11'489'125'29307605, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit by tokens MPT/XRP testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), MPT(ammAlice[1])(1'000), @@ -1793,49 +1798,49 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit by tokens MPT/IOU combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); ammAlice.deposit( - carol, + carol_, 1'000, - USD(1'000), - BTC(1'000), + usd(1'000), + btc(1'000), std::nullopt, tfLPToken, std::nullopt, std::nullopt); - BEAST_EXPECT(ammAlice.expectBalances(USD(11'000), BTC(11'000), IOUAmount{11'000})); + BEAST_EXPECT(ammAlice.expectBalances(usd(11'000), btc(11'000), IOUAmount{11'000})); - env.require(balance(carol, carolBTC - BTC(1000))); - env.require(balance(carol, carolUSD - USD(1000))); + env.require(Balance(carol_, carolBTC - btc(1000))); + env.require(Balance(carol_, carolUSD - usd(1000))); }; testHelper2TokensMix(test); } @@ -1844,7 +1849,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), MPT(ammAlice[1])(1'000), @@ -1855,49 +1860,49 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit by asset IOU/MPT combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); ammAlice.deposit( - carol, + carol_, 1'000, - USD(1'000), - BTC(1'000), + usd(1'000), + btc(1'000), std::nullopt, tfTwoAsset, std::nullopt, std::nullopt); BEAST_EXPECT( - ammAlice.expectBalances(USD(11'000), BTC(11'000), IOUAmount{11'000, 0})); + ammAlice.expectBalances(usd(11'000), btc(11'000), IOUAmount{11'000, 0})); - env.require(balance(carol, carolBTC - BTC(1000))); - env.require(balance(carol, carolUSD - USD(1000))); + env.require(Balance(carol_, carolBTC - btc(1000))); + env.require(Balance(carol_, carolUSD - usd(1000))); }; testHelper2TokensMix(test); } @@ -1906,7 +1911,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 488'088, XRP(1'000), std::nullopt, @@ -1917,13 +1922,13 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(10'000), IOUAmount{10'488'088'48170151, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit MPT by asset MPT/XRP testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 488'088, MPT(ammAlice[1])(1'000), std::nullopt, @@ -1934,13 +1939,13 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(11'000), IOUAmount{10'488'088'48170151, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit IOU by asset MPT/IOU testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 488, USD(1'000), std::nullopt, @@ -1953,13 +1958,13 @@ private: MPT(ammAlice[1])(10'000), IOUAmount{10'488'08848170151, -11})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit MPT by asset MPT/IOU testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 488, MPT(ammAlice[1])(1'000), std::nullopt, @@ -1970,13 +1975,13 @@ private: BEAST_EXPECT(ammAlice.expectBalances( USD(10'000), MPT(ammAlice[1])(11'000), IOUAmount{10'488'088'48170151, -11})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit MPT by asset MPT/MPT testAMM( [&](AMM& ammAlice, Env& env) { ammAlice.deposit( - carol, + carol_, 488, MPT(ammAlice[1])(1'000), std::nullopt, @@ -1989,7 +1994,7 @@ private: MPT(ammAlice[1])(11'000), IOUAmount{10'488'088'48170151, -11})); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); } void @@ -1998,100 +2003,100 @@ private: testcase("Invalid AMMWithdraw"); using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .asset1Out = XRP(100), - .err = ter(tecAMM_BALANCE), + .err = Ter(tecAMM_BALANCE), }; ammAlice.withdraw(args); }, - {{XRP(99), AMMMPT(99)}}); + {{XRP(99), gAmmmpt(99)}}); testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .asset1Out = MPT(ammAlice[1])(100), - .err = ter(tecAMM_BALANCE), + .err = Ter(tecAMM_BALANCE), }; ammAlice.withdraw(args); }, - {{XRP(99), AMMMPT(99)}}); + {{XRP(99), gAmmmpt(99)}}); { Env env{*this}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); env.close(); // alice is authorized to hold gw MPT, bob is not authorized - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); WithdrawArg const args{ - .account = bob, - .asset1Out = BTC(100), - .err = ter(tecNO_AUTH), + .account = bob_, + .asset1Out = btc(100), + .err = Ter(tecNO_AUTH), }; ammAlice.withdraw(args); } testAMM( [&](AMM& ammAlice, Env& env) { - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 2'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); // Invalid tokens - ammAlice.withdraw(alice, 0, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, 0, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); ammAlice.withdraw( - alice, IOUAmount{-1}, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, IOUAmount{-1}, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Mismatched token, invalid Asset1Out issue ammAlice.withdraw( - alice, BTC(100), std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, btc(100), std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); ammAlice.withdraw( - alice, MPT(badMPT())(100), std::nullopt, std::nullopt, ter(temBAD_MPT)); + alice_, MPT(badMPT())(100), std::nullopt, std::nullopt, Ter(temBAD_MPT)); // Mismatched token, invalid Asset2Out issue - ammAlice.withdraw(alice, XRP(100), BTC(100), std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, XRP(100), btc(100), std::nullopt, Ter(temBAD_AMM_TOKENS)); // Mismatched token, Asset1Out.issue == Asset2Out.issue ammAlice.withdraw( - alice, + alice_, MPT(ammAlice[1])(100), MPT(ammAlice[1])(100), std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // Invalid amount value ammAlice.withdraw( - alice, MPT(ammAlice[1])(0), std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); + alice_, MPT(ammAlice[1])(0), std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); ammAlice.withdraw( - alice, MPT(ammAlice[1])(-100), std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); + alice_, MPT(ammAlice[1])(-100), std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); ammAlice.withdraw( - alice, MPT(ammAlice[1])(10), std::nullopt, IOUAmount{-1}, ter(temBAD_AMOUNT)); + alice_, MPT(ammAlice[1])(10), std::nullopt, IOUAmount{-1}, Ter(temBAD_AMOUNT)); // Invalid amount/token value, withdraw all tokens from one side // of the pool. ammAlice.withdraw( - alice, + alice_, MPT(ammAlice[1])(10'000), std::nullopt, std::nullopt, - ter(tecAMM_BALANCE)); + Ter(tecAMM_BALANCE)); ammAlice.withdraw( - alice, XRP(10'000), std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); + alice_, XRP(10'000), std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); ammAlice.withdraw( - alice, + alice_, std::nullopt, MPT(ammAlice[1])(0), std::nullopt, @@ -2099,15 +2104,15 @@ private: tfOneAssetWithdrawAll, std::nullopt, std::nullopt, - ter(tecAMM_BALANCE)); + Ter(tecAMM_BALANCE)); // Bad MPT ammAlice.withdraw( - alice, XRP(100), MPT(badMPT())(100), std::nullopt, ter(temBAD_MPT)); + alice_, XRP(100), MPT(badMPT())(100), std::nullopt, Ter(temBAD_MPT)); // Specified MPToken doesn't match the pool assets ammAlice.withdraw( - alice, XRP(100), MPT(noMPT())(100), std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, XRP(100), MPT(noMPT())(100), std::nullopt, Ter(temBAD_AMM_TOKENS)); // Invalid Account Account bad("bad"); @@ -2120,12 +2125,12 @@ private: std::nullopt, std::nullopt, std::nullopt, - seq(1), - ter(terNO_ACCOUNT)); + Seq(1), + Ter(terNO_ACCOUNT)); // Invalid AMM ammAlice.withdraw( - alice, + alice_, 1'000, std::nullopt, std::nullopt, @@ -2133,12 +2138,12 @@ private: std::nullopt, {{MPT(ammAlice[1]), GBP}}, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); // Carol is not a Liquidity Provider - ammAlice.withdraw(carol, 10'000, std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); + ammAlice.withdraw(carol_, 10'000, std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { @@ -2149,16 +2154,16 @@ private: // while leaving a tiny amount in USD pool. // Post-fixAMMv1_3: // Most of the pool is withdrawn with remaining tiny amounts - auto err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS) : ter(tecAMM_BALANCE); + auto err = env.enabled(fixAMMv1_3) ? Ter(tesSUCCESS) : Ter(tecAMM_BALANCE); ammAlice.withdraw( - alice, IOUAmount{9'999'999'9999, -4}, std::nullopt, std::nullopt, err); + alice_, IOUAmount{9'999'999'9999, -4}, std::nullopt, std::nullopt, err); if (env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(1), STAmount{USD, 1, -7}, IOUAmount{1, -4})); } }, - {{AMMMPT(10'000'000'000), USD(10'000)}}, + {{gAmmmpt(10'000'000'000), USD(10'000)}}, 0, std::nullopt, {all, all - fixAMMv1_3}); @@ -2169,16 +2174,16 @@ private: // Pre-fixAMMv1_3: results in full withdraw of MPT pool only, // returning tecAMM_BALANCE. Post-fixAMMv1_3: most of the pool // is withdrawn with remaining tiny amounts - auto err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS) : ter(tecAMM_BALANCE); + auto err = env.enabled(fixAMMv1_3) ? Ter(tesSUCCESS) : Ter(tecAMM_BALANCE); ammAlice.withdraw( - alice, IOUAmount{9'999'999'999999999, -9}, std::nullopt, std::nullopt, err); + alice_, IOUAmount{9'999'999'999999999, -9}, std::nullopt, std::nullopt, err); if (env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(1), STAmount{USD, 1, -11}, IOUAmount{1, -8})); } }, - {{AMMMPT(10'000'000'000), USD(10'000)}}, + {{gAmmmpt(10'000'000'000), USD(10'000)}}, 0, std::nullopt, {all, all - fixAMMv1_3}); @@ -2186,204 +2191,206 @@ private: // Invalid AMM testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); - ammAlice.withdraw(alice, 10'000, std::nullopt, std::nullopt, ter(terNO_AMM)); + ammAlice.withdrawAll(alice_); + ammAlice.withdraw(alice_, 10'000, std::nullopt, std::nullopt, Ter(terNO_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // MPTokenIssuance object doesn't exist { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - MPT const BTC = - MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 30'000}); + MPT const btc = + MPTTester({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); ammAlice.withdraw( WithdrawArg{ - .account = alice, - .asset1Out = MPT(gw, 1'000)(10), - .assets = {{XRP, MPT(gw, 1'000)}}, - .err = ter(terNO_AMM)}); + .account = alice_, + .asset1Out = MPT(gw_, 1'000)(10), + .assets = {{XRP, MPT(gw_, 1'000)}}, + .err = Ter(terNO_AMM)}); } // MPTRequireAuth flag is set and the account is not authorized { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - auto BTCM = MPTTester( + auto btcm = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - MPT const BTC = BTCM; + MPT const btc = btcm; - AMM amm(env, alice, XRP(10'000), BTC(10'000)); + AMM amm(env, alice_, XRP(10'000), btc(10'000)); - BTCM.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); + btcm.authorize({.account = gw_, .holder = alice_, .flags = tfMPTUnauthorize}); amm.withdraw( WithdrawArg{ - .account = alice, - .asset1Out = BTC(100), - .assets = {{XRP, BTC}}, - .err = ter(tecNO_AUTH)}); + .account = alice_, + .asset1Out = btc(100), + .assets = {{XRP, btc}}, + .err = Ter(tecNO_AUTH)}); } // MPTCanTransfer is not set and the account is not the issuer of MPT { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - auto BTCM = MPTTester( + auto btcm = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, .flags = tfMPTCanTrade, .authHolder = true}); - MPT const BTC = BTCM; + MPT const btc = btcm; - AMM amm(env, gw, XRP(10'000), BTC(10'000)); + AMM amm(env, gw_, XRP(10'000), btc(10'000)); amm.withdraw( WithdrawArg{ - .account = alice, - .asset1Out = BTC(100), - .assets = {{XRP, BTC}}, - .err = ter(tecNO_PERMISSION)}); + .account = alice_, + .asset1Out = btc(100), + .assets = {{XRP, btc}}, + .err = Ter(tecNO_PERMISSION)}); } // Globally locked MPT // MPTLocked flag is set and the account is not the issuer of MPT { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .authHolder = true}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); - BTC.set({.flags = tfMPTLock}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); + btc.set({.flags = tfMPTLock}); ammAlice.withdraw( - alice, MPT(ammAlice[1])(100), std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + alice_, MPT(ammAlice[1])(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); // can single withdraw the other asset - ammAlice.withdraw({.account = alice, .asset1Out = XRP(100)}); + ammAlice.withdraw({.account = alice_, .asset1Out = XRP(100)}); } // Individually frozen (AMM) account with MPT/MPT AMM { Env env{*this}; - env.fund(XRP(10'000), gw, alice); + env.fund(XRP(10'000), gw_, alice_); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester const USD( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester const usd( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 40'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, USD(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, usd(10'000), btc(10'000)); // Alice's BTC is locked - BTC.set({.holder = alice, .flags = tfMPTLock}); - ammAlice.withdraw(alice, 1000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + btc.set({.holder = alice_, .flags = tfMPTLock}); + ammAlice.withdraw(alice_, 1000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); // can withdraw the other asset - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, usd(100), std::nullopt, std::nullopt); // Unlock and then alice can withdraw - BTC.set({.holder = alice, .flags = tfMPTUnlock}); - ammAlice.withdraw(alice, 1000, std::nullopt, std::nullopt); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt); - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); + btc.set({.holder = alice_, .flags = tfMPTUnlock}); + ammAlice.withdraw(alice_, 1000, std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, usd(100), std::nullopt, std::nullopt); } // Individually lock MPT or freeze IOU (AMM) { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000)}, Fund::All); - MPTTester BTC( + fund(env, gw_, {alice_}, {USD(20'000)}, Fund::All); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, USD(10'000), BTC(10'000)); + AMM ammAlice(env, alice_, USD(10'000), btc(10'000)); // Alice's BTC is locked - BTC.set({.holder = alice, .flags = tfMPTLock}); + btc.set({.holder = alice_, .flags = tfMPTLock}); - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); // can still single withdraw the unlocked other asset - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt); // Unlock alice's BTC - BTC.set({.holder = alice, .flags = tfMPTUnlock}); + btc.set({.holder = alice_, .flags = tfMPTUnlock}); // Now alice can withdraw - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt); // Individually lock MPT BTC (AMM) account - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); // Can withdraw non-frozen token USD - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt); // Can not withdraw locked token BTC - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unlock AMM MPT - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTUnlock}); // Can withdraw - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt); - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt); // Individually frozen AMM env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); + gw_, STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); env.close(); // Can withdraw non-locked token BTC - ammAlice.withdraw(alice, BTC(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, btc(100), std::nullopt, std::nullopt); // Can not withdraw frozen token USD - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); // Unfreeze env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfClearFreeze)); + gw_, + STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, + tfClearFreeze)); env.close(); // Can withdraw - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt); - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt); } // Carol withdraws more than she owns @@ -2391,28 +2398,28 @@ private: [&](AMM& ammAlice, Env&) { // Single deposit of 100000 worth of tokens // which is 10% of the pool. Carol is LP now. - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); ammAlice.withdraw( - carol, 2'000'000, std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, 2'000'000, std::nullopt, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Withdraw with EPrice limit. Fails to withdraw, calculated tokens // to withdraw are 0. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); auto const err = - env.enabled(fixAMMv1_3) ? ter(tecAMM_INVALID_TOKENS) : ter(tecAMM_FAILED); + env.enabled(fixAMMv1_3) ? Ter(tecAMM_INVALID_TOKENS) : Ter(tecAMM_FAILED); ammAlice.withdraw( - carol, MPT(ammAlice[1])(100), std::nullopt, IOUAmount{500, 0}, err); + carol_, MPT(ammAlice[1])(100), std::nullopt, IOUAmount{500, 0}, err); }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 0, std::nullopt, {all, all - fixAMMv1_3}); @@ -2421,106 +2428,106 @@ private: // to withdraw are greater than the LP shares. testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); ammAlice.withdraw( - carol, + carol_, MPT(ammAlice[1])(100), std::nullopt, IOUAmount{600, 0}, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Withdraw with EPrice limit. Fails to withdraw, amount1 // to withdraw is less than 1700 MPT. testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); ammAlice.withdraw( - carol, + carol_, MPT(ammAlice[1])(1'700), std::nullopt, IOUAmount{520, 0}, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Deposit/Withdraw the same amount with the trading fee testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); ammAlice.withdraw( - carol, + carol_, MPT(ammAlice[1])(1'000), std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 1'000); testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, XRP(1'000)); + ammAlice.deposit(carol_, XRP(1'000)); ammAlice.withdraw( - carol, XRP(1'000), std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, XRP(1'000), std::nullopt, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 1'000); // Deposit/Withdraw the same amount fails due to the tokens adjustment testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, STAmount{USD, 1, -6}); + ammAlice.deposit(carol_, STAmount{USD, 1, -6}); ammAlice.withdraw( - carol, + carol_, STAmount{USD, 1, -6}, std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // Withdraw close to one side of the pool. Account's LP tokens // are rounded to all LP tokens. testAMM( [&](AMM& ammAlice, Env&) { ammAlice.withdraw( - alice, + alice_, STAmount{MPT(ammAlice[1]), UINT64_C(9'999'999999999999), -12}, std::nullopt, std::nullopt, - ter(tecAMM_BALANCE)); + Ter(tecAMM_BALANCE)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Tiny withdraw testAMM( [&](AMM& ammAlice, Env&) { // XRP amount to withdraw is 0 ammAlice.withdraw( - alice, IOUAmount{1, -5}, std::nullopt, std::nullopt, ter(tecAMM_FAILED)); + alice_, IOUAmount{1, -5}, std::nullopt, std::nullopt, Ter(tecAMM_FAILED)); // Calculated tokens to withdraw are 0 ammAlice.withdraw( - alice, + alice_, std::nullopt, STAmount{USD, 1, -11}, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); - ammAlice.deposit(carol, STAmount{USD, 1, -10}); + Ter(tecAMM_INVALID_TOKENS)); + ammAlice.deposit(carol_, STAmount{USD, 1, -10}); ammAlice.withdraw( - carol, + carol_, std::nullopt, STAmount{USD, 1, -9}, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); ammAlice.withdraw( - carol, + carol_, std::nullopt, MPT(ammAlice[0])(1), std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); } void @@ -2536,66 +2543,66 @@ private: [&](AMM& ammAlice, Env& env) { // XRP/MPT XRPAmount const baseFee{env.current()->fees().base}; - auto carolXRP = env.balance(carol, XRP); - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); + auto carolXRP = env.balance(carol_, XRP); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); // Single deposit of 1'000'000 worth of tokens, // which is 10% of the pool. Carol is LP now. - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{11'000'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); - env.require(balance(carol, carolMPT - MPT(ammAlice[1])(1'000))); - env.require(balance(carol, carolXRP - XRP(1'000) - drops(baseFee))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); + env.require(Balance(carol_, carolMPT - MPT(ammAlice[1])(1'000))); + env.require(Balance(carol_, carolXRP - XRP(1'000) - drops(baseFee))); // Carol withdraws all tokens - ammAlice.withdraw(carol, 1'000'000); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); - env.require(balance(carol, carolMPT)); - env.require(balance(carol, carolXRP - drops(2 * baseFee))); + ammAlice.withdraw(carol_, 1'000'000); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); + env.require(Balance(carol_, carolMPT)); + env.require(Balance(carol_, carolXRP - drops(2 * baseFee))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal withdrawal by tokens 1000000, 10% // of the current pool, XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { // XRP/MPT - ammAlice.withdraw(alice, 1'000'000); + ammAlice.withdraw(alice_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( XRP(9'000), MPT(ammAlice[1])(9'000), IOUAmount{9'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal withdrawal by tokens, 10% of the current pool, IOU/MPT // combination { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, alice, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - ammAlice.withdraw(alice, 1'000); - BEAST_EXPECT(ammAlice.expectBalances(BTC(9'000), USD(9'000), IOUAmount(9'000))); - env.require(balance(alice, aliceBTC + BTC(1000))); - env.require(balance(alice, aliceUSD + USD(1000))); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto aliceBTC = env.balance(alice_, btc); + auto aliceUSD = env.balance(alice_, usd); + ammAlice.withdraw(alice_, 1'000); + BEAST_EXPECT(ammAlice.expectBalances(btc(9'000), usd(9'000), IOUAmount(9'000))); + env.require(Balance(alice_, aliceBTC + btc(1000))); + env.require(Balance(alice_, aliceUSD + usd(1000))); }; testHelper2TokensMix(test); } @@ -2608,51 +2615,51 @@ private: testAMM( [&](AMM& ammAlice, Env&) { // XRP/MPT - ammAlice.withdraw(alice, XRP(200), MPT(ammAlice[1])(100)); + ammAlice.withdraw(alice_, XRP(200), MPT(ammAlice[1])(100)); BEAST_EXPECT(ammAlice.expectBalances( XRP(9'900), MPT(ammAlice[1])(9'900), IOUAmount{9'900'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal withdrawal with a limit. XRP100/MPT200 truncated to // XRP100/MPT100 testAMM( [&](AMM& ammAlice, Env&) { // XRP/MPT - ammAlice.withdraw(alice, XRP(100), MPT(ammAlice[1])(200)); + ammAlice.withdraw(alice_, XRP(100), MPT(ammAlice[1])(200)); BEAST_EXPECT(ammAlice.expectBalances( XRP(9'900), MPT(ammAlice[1])(9'900), IOUAmount{9'900'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal withdrawal with a limit. IOU/MPT combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, alice, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - ammAlice.withdraw(alice, BTC(200), USD(100)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(9'900), USD(9'900), IOUAmount(9'900))); - env.require(balance(alice, aliceBTC + BTC(100))); - env.require(balance(alice, aliceUSD + USD(100))); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto aliceBTC = env.balance(alice_, btc); + auto aliceUSD = env.balance(alice_, usd); + ammAlice.withdraw(alice_, btc(200), usd(100)); + BEAST_EXPECT(ammAlice.expectBalances(btc(9'900), usd(9'900), IOUAmount(9'900))); + env.require(Balance(alice_, aliceBTC + btc(100))); + env.require(Balance(alice_, aliceUSD + usd(100))); }; testHelper2TokensMix(test); } @@ -2661,96 +2668,96 @@ private: testAMM( [&](AMM& ammAlice, Env&) { // single withdraw XRP from XRP/MPT - ammAlice.withdraw(alice, XRP(1'000)); + ammAlice.withdraw(alice_, XRP(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9000'000001), MPT(ammAlice[1])(10'000), IOUAmount{9'486'832'98050514, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // single withdraw MPT from XRP/MPT - ammAlice.withdraw(alice, MPT(ammAlice[1])(1'000)); + ammAlice.withdraw(alice_, MPT(ammAlice[1])(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10000), MPT(ammAlice[1])(9001), IOUAmount{9'486'832'98050514, -8})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // single withdraw IOU from IOU/MPT - ammAlice.withdraw(alice, USD(1'000)); + ammAlice.withdraw(alice_, USD(1'000)); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(9000'000000000004), -12}, MPT(ammAlice[1])(10'000), IOUAmount{9486'83298050514, -11})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // single withdraw MPT from IOU/MPT - ammAlice.withdraw(alice, MPT(ammAlice[1])(1'000)); + ammAlice.withdraw(alice_, MPT(ammAlice[1])(1'000)); BEAST_EXPECT(ammAlice.expectBalances( USD(10'000), MPT(ammAlice[1])(9001), IOUAmount{9486'83298050514, -11})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // single withdraw MPT from MPT/MPT - ammAlice.withdraw(alice, MPT(ammAlice[0])(1'000)); + ammAlice.withdraw(alice_, MPT(ammAlice[0])(1'000)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(9001), MPT(ammAlice[1])(10'000), IOUAmount{9486'83298050514, -11})); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); // Single withdrawal MPT by tokens 10000. XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, 10'000, MPT(ammAlice[1])(0)); + ammAlice.withdraw(alice_, 10'000, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(9981), IOUAmount{9'990'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single withdrawal XRP by tokens 10000. XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, 10'000, XRP(0)); + ammAlice.withdraw(alice_, 10'000, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9980010000), MPT(ammAlice[1])(10'000), IOUAmount{9'990'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single withdrawal by tokens 10000. MPT/IOU combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, gw); + env.fund(XRP(30'000), alice_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, alice, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto aliceBTC = env.balance(alice, BTC); - auto aliceUSD = env.balance(alice, USD); - ammAlice.withdraw(alice, 1000, BTC(0)); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'000), BTC(8100), IOUAmount{9000, 0})); - env.require(balance(alice, aliceBTC + BTC(1900))); - env.require(balance(alice, aliceUSD)); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto aliceBTC = env.balance(alice_, btc); + auto aliceUSD = env.balance(alice_, usd); + ammAlice.withdraw(alice_, 1000, btc(0)); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'000), btc(8100), IOUAmount{9000, 0})); + env.require(Balance(alice_, aliceBTC + btc(1900))); + env.require(Balance(alice_, aliceUSD)); }; testHelper2TokensMix(test); } @@ -2758,198 +2765,198 @@ private: // Withdraw all tokens. testAMM( [&](AMM& ammAlice, Env& env) { - env(trust(carol, STAmount{ammAlice.lptIssue(), 10'000})); + env(trust(carol_, STAmount{ammAlice.lptIssue(), 10'000})); // Can SetTrust only for AMM LP tokens - env(trust(carol, STAmount{Issue{EUR.currency, ammAlice.ammAccount()}, 10'000}), - ter(tecNO_PERMISSION)); + env(trust(carol_, STAmount{Issue{EUR.currency, ammAlice.ammAccount()}, 10'000}), + Ter(tecNO_PERMISSION)); env.close(); - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); BEAST_EXPECT(!ammAlice.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(ammAlice.ammAccount()))); // Can create AMM for the XRP/MPT pair - AMM const ammCarol(env, carol, XRP(10'000), MPT(ammAlice[1])(10'000)); + AMM const ammCarol(env, carol_, XRP(10'000), MPT(ammAlice[1])(10'000)); BEAST_EXPECT(ammCarol.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'000), IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in MPT from XRP/MPT testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'001), IOUAmount{10'000'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in XRP from XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, XRP(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9'090'909'091), MPT(ammAlice[1])(11000), IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in MPT from USD/MPT testAMM( [&](AMM& ammAlice, Env& env) { // USD/MPT - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( USD(10'000), MPT(ammAlice[1])(10'001), IOUAmount{10'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit 1000USD, withdraw all tokens in USD from USD/MPT testAMM( [&](AMM& ammAlice, Env& env) { // USD/MPT - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT(ammAlice.expectBalances( USD(10'000), MPT(ammAlice[1])(10'000), IOUAmount{10'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in MPT from MPT/MPT testAMM( [&](AMM& ammAlice, Env& env) { // MPT/MPT - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000), MPT(ammAlice[1])(10'001), IOUAmount{10'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10001), IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit 1000MPT, withdraw all tokens in USD testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(9'090'9090909091), -10}, MPT(ammAlice[1])(11000), IOUAmount{10'000, 0})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit 1000USD, withdraw all tokens in MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(10'999'99999999999), -11}, MPT(ammAlice[1])(9091), IOUAmount{10'000, 0})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Single deposit/withdraw by the same account testAMM( [&](AMM& ammAlice, Env&) { - auto lpTokens = ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdraw(carol, lpTokens, USD(0)); - lpTokens = ammAlice.deposit(carol, STAmount(USD, 1, -6)); - ammAlice.withdraw(carol, lpTokens, USD(0)); - lpTokens = ammAlice.deposit(carol, MPT(ammAlice[0])(1)); - ammAlice.withdraw(carol, lpTokens, MPT(ammAlice[0])(0)); + auto lpTokens = ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdraw(carol_, lpTokens, USD(0)); + lpTokens = ammAlice.deposit(carol_, STAmount(USD, 1, -6)); + ammAlice.withdraw(carol_, lpTokens, USD(0)); + lpTokens = ammAlice.deposit(carol_, MPT(ammAlice[0])(1)); + ammAlice.withdraw(carol_, lpTokens, MPT(ammAlice[0])(0)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000'000'001), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { - auto const& BTC = MPT(ammAlice[1]); - auto lpTokens = ammAlice.deposit(carol, BTC(1'000)); - ammAlice.withdraw(carol, lpTokens, BTC(0)); - lpTokens = ammAlice.deposit(carol, BTC(1)); - ammAlice.withdraw(carol, lpTokens, BTC(0)); - lpTokens = ammAlice.deposit(carol, BTC(1)); - ammAlice.withdraw(carol, lpTokens, BTC(0)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(10'003), XRP(10'000), ammAlice.tokens())); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + auto const& btc = MPT(ammAlice[1]); + auto lpTokens = ammAlice.deposit(carol_, btc(1'000)); + ammAlice.withdraw(carol_, lpTokens, btc(0)); + lpTokens = ammAlice.deposit(carol_, btc(1)); + ammAlice.withdraw(carol_, lpTokens, btc(0)); + lpTokens = ammAlice.deposit(carol_, btc(1)); + ammAlice.withdraw(carol_, lpTokens, btc(0)); + BEAST_EXPECT(ammAlice.expectBalances(btc(10'003), XRP(10'000), ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Single deposit by different accounts and then withdraw // in reverse. testAMM( [&](AMM& ammAlice, Env&) { - auto const carolTokens = ammAlice.deposit(carol, MPT(ammAlice[1])(1'000)); - auto const aliceTokens = ammAlice.deposit(alice, MPT(ammAlice[1])(1'000)); - ammAlice.withdraw(alice, aliceTokens, MPT(ammAlice[1])(0)); - ammAlice.withdraw(carol, carolTokens, MPT(ammAlice[1])(0)); + auto const carolTokens = ammAlice.deposit(carol_, MPT(ammAlice[1])(1'000)); + auto const aliceTokens = ammAlice.deposit(alice_, MPT(ammAlice[1])(1'000)); + ammAlice.withdraw(alice_, aliceTokens, MPT(ammAlice[1])(0)); + ammAlice.withdraw(carol_, carolTokens, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'001), ammAlice.tokens())); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, ammAlice.tokens())); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit 10%, withdraw all tokens. XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'000), IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit 10%, withdraw all tokens. IOU/MPT combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, carol, gw); + env.fund(XRP(30'000), alice_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - auto carolBTC = env.balance(carol, BTC); - auto carolUSD = env.balance(carol, USD); - ammAlice.deposit(carol, 1'000); - ammAlice.withdrawAll(carol); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + auto carolBTC = env.balance(carol_, btc); + auto carolUSD = env.balance(carol_, usd); + ammAlice.deposit(carol_, 1'000); + ammAlice.withdrawAll(carol_); BEAST_EXPECT( - ammAlice.expectBalances(USD(10'000), BTC(10'000), IOUAmount{10'000, 0})); - env.require(balance(carol, carolBTC)); - env.require(balance(carol, carolUSD)); + ammAlice.expectBalances(usd(10'000), btc(10'000), IOUAmount{10'000, 0})); + env.require(Balance(carol_, carolBTC)); + env.require(Balance(carol_, carolUSD)); }; testHelper2TokensMix(test); } @@ -2957,54 +2964,54 @@ private: // Equal deposit 10%, withdraw all tokens in MPT from XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), STAmount{MPT(ammAlice[1]), UINT64_C(9'090'909090909092), -12}, IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit 10%, withdraw all tokens in XRP from XRP/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol, XRP(0)); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9'090'909'091), MPT(ammAlice[1])(11'000), IOUAmount{10'000'000, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Equal deposit 10%, withdraw all tokens in USD from USD/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, 1'000); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(9'090'909090909092), -12}, MPT(ammAlice[1])(11'000), IOUAmount{10'000})); }, - {{USD(10'000), AMMMPT(10'000)}}); + {{USD(10'000), gAmmmpt(10'000)}}); // Equal deposit 10%, withdraw all tokens in MPT from MPT/MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.deposit(carol_, 1'000); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(11'000), MPT(ammAlice[1])(9'091), IOUAmount{10'000})); }, - {{AMMMPT(10'000), AMMMPT(10'000)}}); + {{gAmmmpt(10'000), gAmmmpt(10'000)}}); - auto const all = testable_amendments(); + auto const all = testableAmendments(); // Withdraw with EPrice limit. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000'000'000); + ammAlice.deposit(carol_, 1'000'000'000'000); ammAlice.withdraw( - carol, MPT(ammAlice[1])(100'000000), std::nullopt, IOUAmount{520, 0}); + carol_, MPT(ammAlice[1])(100'000000), std::nullopt, IOUAmount{520, 0}); if (!env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { BEAST_EXPECT( @@ -3012,7 +3019,7 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781065), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } else if (env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { @@ -3021,7 +3028,7 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781065), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } else if (env.enabled(fixAMMv1_3)) { @@ -3030,12 +3037,12 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781066), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } - ammAlice.withdrawAll(carol); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + ammAlice.withdrawAll(carol_); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, - {{XRP(10'000'000'000), AMMMPT(10'000'000'000)}}, + {{XRP(10'000'000'000), gAmmmpt(10'000'000'000)}}, 0, std::nullopt, {all, all - fixAMMv1_3, all - fixAMMv1_1 - fixAMMv1_3}); @@ -3043,8 +3050,8 @@ private: // Withdraw with EPrice limit. AssetOut is 0. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000'000'000); - ammAlice.withdraw(carol, MPT(ammAlice[1])(0), std::nullopt, IOUAmount{520, 0}); + ammAlice.deposit(carol_, 1'000'000'000'000); + ammAlice.withdraw(carol_, MPT(ammAlice[1])(0), std::nullopt, IOUAmount{520, 0}); if (!env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { BEAST_EXPECT( @@ -3052,7 +3059,7 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781065), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } else if (env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { @@ -3061,7 +3068,7 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781065), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } else if (env.enabled(fixAMMv1_3)) { @@ -3070,12 +3077,12 @@ private: XRP(11'000'000000), MPT(ammAlice[1])(9372781066), IOUAmount{10'153'846'15384616, -2}) && - ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -2})); + ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -2})); } - ammAlice.withdrawAll(carol); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + ammAlice.withdrawAll(carol_); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, - {{XRP(10'000'000'000), AMMMPT(10'000'000'000)}}, + {{XRP(10'000'000'000), gAmmmpt(10'000'000'000)}}, 0, std::nullopt, {all, all - fixAMMv1_3, all - fixAMMv1_1 - fixAMMv1_3}); @@ -3084,47 +3091,47 @@ private: { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000, .transferFee = 25'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000, .transferFee = 25'000}); - env(pay(gw, alice, BTC(10000))); - env(pay(gw, bob, BTC(10000))); - env(pay(gw, carol, BTC(10000))); - env(pay(gw, alice, USD(10000))); - env(pay(gw, bob, USD(10000))); - env(pay(gw, carol, USD(10000))); + env(pay(gw_, alice_, btc(10000))); + env(pay(gw_, bob_, btc(10000))); + env(pay(gw_, carol_, btc(10000))); + env(pay(gw_, alice_, usd(10000))); + env(pay(gw_, bob_, usd(10000))); + env(pay(gw_, carol_, usd(10000))); env.close(); // no transfer fee on create - AMM ammAlice(env, alice, BTC(2'000), USD(5)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(2'000), USD(5), IOUAmount{100, 0})); - env.require(balance(alice, BTC(8000))); - env.require(balance(alice, USD(9995))); + AMM ammAlice(env, alice_, btc(2'000), usd(5)); + BEAST_EXPECT(ammAlice.expectBalances(btc(2'000), usd(5), IOUAmount{100, 0})); + env.require(Balance(alice_, btc(8000))); + env.require(Balance(alice_, usd(9995))); // no transfer fee on deposit - ammAlice.deposit(carol, 100); - BEAST_EXPECT(ammAlice.expectBalances(BTC(4000), USD(10), IOUAmount{200, 0})); - env.require(balance(carol, BTC(8000))); - env.require(balance(carol, USD(9995))); + ammAlice.deposit(carol_, 100); + BEAST_EXPECT(ammAlice.expectBalances(btc(4000), usd(10), IOUAmount{200, 0})); + env.require(Balance(carol_, btc(8000))); + env.require(Balance(carol_, usd(9995))); // no transfer fee on withdraw - ammAlice.withdraw(carol, 100); - BEAST_EXPECT(ammAlice.expectBalances(BTC(2'000), USD(5), IOUAmount{100, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0, 0})); - env.require(balance(carol, BTC(10000))); - env.require(balance(carol, USD(10000))); + ammAlice.withdraw(carol_, 100); + BEAST_EXPECT(ammAlice.expectBalances(btc(2'000), usd(5), IOUAmount{100, 0})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0, 0})); + env.require(Balance(carol_, btc(10000))); + env.require(Balance(carol_, usd(10000))); }; testHelper2TokensMix(test); } @@ -3133,106 +3140,106 @@ private: testAMM( [&](AMM& ammAlice, Env&) { // By tokens - ammAlice.withdraw(alice, IOUAmount{1, -3}); + ammAlice.withdraw(alice_, IOUAmount{1, -3}); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(9'999'999'999), STAmount{USD, UINT64_C(9'999'999999), -6}, IOUAmount{9'999'999'999, -3})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // Single withdraw MPT from MPT/IOU - ammAlice.withdraw(alice, std::nullopt, MPT(ammAlice[0])(1)); + ammAlice.withdraw(alice_, std::nullopt, MPT(ammAlice[0])(1)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10000'000000), USD(10'000), IOUAmount{9'999'999'9995, -4})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // Single withdraw IOU from MPT/IOU - ammAlice.withdraw(alice, std::nullopt, STAmount{USD, 1, -10}); + ammAlice.withdraw(alice_, std::nullopt, STAmount{USD, 1, -10}); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000'000'000), STAmount{USD, UINT64_C(9'999'9999999999), -10}, IOUAmount{9'999'999'99999995, -8})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { // Single withdraw XRP from MPT/XRP - ammAlice.withdraw(alice, std::nullopt, XRPAmount(1)); + ammAlice.withdraw(alice_, std::nullopt, XRPAmount(1)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[1])(10'000), XRP(10'000), IOUAmount{9999999'9995, -4})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Withdraw close to entire pool // Equal by tokens testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'999'999, -3}); + ammAlice.withdraw(alice_, IOUAmount{9'999'999'999, -3}); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(1), STAmount{USD, 1, -6}, IOUAmount{1, -3})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // USD by tokens testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'999}, USD(0)); + ammAlice.withdraw(alice_, IOUAmount{9'999'999}, USD(0)); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000'000'000), STAmount{USD, 1, -10}, IOUAmount{1})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // MPT by tokens testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'900}, MPT(ammAlice[0])(0)); + ammAlice.withdraw(alice_, IOUAmount{9'999'900}, MPT(ammAlice[0])(0)); BEAST_EXPECT( ammAlice.expectBalances(MPT(ammAlice[0])(1), USD(10'000), IOUAmount{100})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // XRP by tokens testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'900}, XRP(0)); + ammAlice.withdraw(alice_, IOUAmount{9'999'900}, XRP(0)); BEAST_EXPECT( ammAlice.expectBalances(MPT(ammAlice[1])(10000), XRPAmount(1), IOUAmount{100})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // USD testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, STAmount{USD, UINT64_C(9'999'99999999999), -11}); + ammAlice.withdraw(alice_, STAmount{USD, UINT64_C(9'999'99999999999), -11}); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000'000'000), STAmount{USD, 1, -11}, IOUAmount{316227765, -9})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // XRP testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, XRPAmount{9'999'999'999}); + ammAlice.withdraw(alice_, XRPAmount{9'999'999'999}); BEAST_EXPECT( ammAlice.expectBalances(MPT(ammAlice[1])(10000), XRPAmount(1), IOUAmount{100})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // MPT testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, MPT(ammAlice[0])(9'999'999'999)); + ammAlice.withdraw(alice_, MPT(ammAlice[0])(9'999'999'999)); BEAST_EXPECT( ammAlice.expectBalances(MPT(ammAlice[0])(1), USD(10'000), IOUAmount{100})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, MPT(ammAlice[1])(9'999)); + ammAlice.withdraw(alice_, MPT(ammAlice[1])(9'999)); BEAST_EXPECT( ammAlice.expectBalances(MPT(ammAlice[1])(1), XRP(10'000), IOUAmount{100000})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); } void @@ -3246,52 +3253,52 @@ private: // Invalid Account Account bad("bad"); env.memoize(bad); - ammAlice.vote(bad, 1'000, std::nullopt, seq(1), std::nullopt, ter(terNO_ACCOUNT)); + ammAlice.vote(bad, 1'000, std::nullopt, Seq(1), std::nullopt, Ter(terNO_ACCOUNT)); // Invalid AMM ammAlice.vote( - alice, + alice_, 1'000, std::nullopt, std::nullopt, {{MPT(ammAlice[1]), GBP}}, - ter(terNO_AMM)); + Ter(terNO_AMM)); // Account is not LP ammAlice.vote( - carol, + carol_, 1'000, std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Invalid asset pair ammAlice.vote( - alice, + alice_, 1'000, std::nullopt, std::nullopt, {{MPT(ammAlice[1]), MPT(ammAlice[1])}}, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Invalid AMM testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); ammAlice.vote( - alice, 1'000, std::nullopt, std::nullopt, std::nullopt, ter(terNO_AMM)); + alice_, 1'000, std::nullopt, std::nullopt, std::nullopt, Ter(terNO_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // MPTokenInstance object doesn't exist { Env env(*this); - env.fund(XRP(1'000), alice); - env(AMM::voteJv({.account = alice, .tfee = 1'000, .assets = {{XRP, MPT(alice, 0)}}}), - ter(terNO_AMM)); + env.fund(XRP(1'000), alice_); + env(AMM::voteJv({.account = alice_, .tfee = 1'000, .assets = {{XRP, MPT(alice_, 0)}}}), + Ter(terNO_AMM)); } } @@ -3310,7 +3317,7 @@ private: // Discounted fee is 1/10 of trading fee. BEAST_EXPECT(ammAlice.expectAuctionSlot(100, 0, IOUAmount{0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); auto vote = [&](AMM& ammAlice, Env& env, @@ -3328,8 +3335,8 @@ private: // Eight votes fill all voting slots, set fee 0.175%. // New vote, same account, sets fee 0.225% Env env{*this}; - env.fund(XRP(30'000), gw, alice); - std::vector holders = {alice}; + env.fund(XRP(30'000), gw_, alice_); + std::vector holders = {alice_}; for (int i = 0; i <= 7; ++i) { Account const a(std::to_string(i)); @@ -3338,8 +3345,8 @@ private: } env.close(); // create MPT and pay 30'000 to all the accounts - MPTTester const BTC({.env = env, .issuer = gw, .holders = holders, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + MPTTester const btc({.env = env, .issuer = gw_, .holders = holders, .pay = 30'000}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); for (int i = 0; i < 7; ++i) vote(ammAlice, env, i); BEAST_EXPECT(ammAlice.expectTradingFee(175)); @@ -3352,8 +3359,8 @@ private: // Eight votes fill all voting slots, set fee 0.175%. // New vote, new account, higher vote weight, set higher fee 0.244% Env env{*this}; - env.fund(XRP(30'000), gw, alice); - std::vector holders = {alice}; + env.fund(XRP(30'000), gw_, alice_); + std::vector holders = {alice_}; for (int i = 0; i < 8; ++i) { Account const a(std::to_string(i)); @@ -3361,8 +3368,8 @@ private: env.fund(XRP(30'000), a); } env.close(); - MPTTester const BTC({.env = env, .issuer = gw, .holders = holders, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + MPTTester const btc({.env = env, .issuer = gw_, .holders = holders, .pay = 30'000}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); for (int i = 0; i < 7; ++i) vote(ammAlice, env, i); BEAST_EXPECT(ammAlice.expectTradingFee(175)); @@ -3374,8 +3381,8 @@ private: // Eight votes fill all voting slots, set fee 0.219%. // New vote, new account, higher vote weight, set smaller fee 0.206% Env env{*this}; - env.fund(XRP(30'000), gw, alice); - std::vector holders = {alice}; + env.fund(XRP(30'000), gw_, alice_); + std::vector holders = {alice_}; for (int i = 0; i < 8; ++i) { Account const a(std::to_string(i)); @@ -3383,8 +3390,8 @@ private: env.fund(XRP(30'000), a); } env.close(); - MPTTester const BTC({.env = env, .issuer = gw, .holders = holders, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + MPTTester const btc({.env = env, .issuer = gw_, .holders = holders, .pay = 30'000}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); for (int i = 7; i > 0; --i) vote(ammAlice, env, i); BEAST_EXPECT(ammAlice.expectTradingFee(219)); @@ -3397,8 +3404,8 @@ private: // tokens. An account sets a new fee and the previous slots are // deleted. Env env{*this}; - env.fund(XRP(30'000), gw, alice, carol); - std::vector holders = {alice, carol}; + env.fund(XRP(30'000), gw_, alice_, carol_); + std::vector holders = {alice_, carol_}; for (int i = 0; i < 7; ++i) { Account const a(std::to_string(i)); @@ -3406,16 +3413,16 @@ private: env.fund(XRP(30'000), a); } env.close(); - MPTTester const BTC({.env = env, .issuer = gw, .holders = holders, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + MPTTester const btc({.env = env, .issuer = gw_, .holders = holders, .pay = 30'000}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); std::vector accounts; for (int i = 0; i < 7; ++i) vote(ammAlice, env, i, 10'000'000, &accounts); BEAST_EXPECT(ammAlice.expectTradingFee(175)); for (int i = 0; i < 7; ++i) ammAlice.withdrawAll(accounts[i]); - ammAlice.deposit(carol, 10'000'000); - ammAlice.vote(carol, 1'000); + ammAlice.deposit(carol_, 10'000'000); + ammAlice.vote(carol_, 1'000); // The initial LP set the fee to 1000. Carol gets 50% voting // power, and the new fee is 500. BEAST_EXPECT(ammAlice.expectTradingFee(500)); @@ -3425,8 +3432,8 @@ private: // some tokens. The new vote doesn't get the voting power but the // slots are refreshed and the fee is updated. Env env{*this}; - env.fund(XRP(30'000), gw, alice, carol); - std::vector holders = {alice, carol}; + env.fund(XRP(30'000), gw_, alice_, carol_); + std::vector holders = {alice_, carol_}; for (int i = 0; i < 7; ++i) { Account const a(std::to_string(i)); @@ -3434,20 +3441,20 @@ private: env.fund(XRP(30'000), a); } env.close(); - MPTTester const BTC({.env = env, .issuer = gw, .holders = holders, .pay = 30'000}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + MPTTester const btc({.env = env, .issuer = gw_, .holders = holders, .pay = 30'000}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); std::vector accounts; for (int i = 0; i < 7; ++i) vote(ammAlice, env, i, 10'000'000, &accounts); BEAST_EXPECT(ammAlice.expectTradingFee(175)); for (int i = 0; i < 7; ++i) ammAlice.withdraw(accounts[i], 9'000'000); - ammAlice.deposit(carol, 1'000); + ammAlice.deposit(carol_, 1'000); // The vote is not added to the slots - ammAlice.vote(carol, 1'000); + ammAlice.vote(carol_, 1'000); auto const info = ammAlice.ammRpcInfo()[jss::amm][jss::vote_slots]; for (auto i = 0; i < info.size(); ++i) - BEAST_EXPECT(info[i][jss::account] != carol.human()); + BEAST_EXPECT(info[i][jss::account] != carol_.human()); // But the slots are refreshed and the fee is changed BEAST_EXPECT(ammAlice.expectTradingFee(82)); } @@ -3463,10 +3470,14 @@ private: // burn all the LPTokens through a AMMBid transaction { Env env(*this); - env.fund(XRP(2'000), gw, alice); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice}, .pay = 2'000, .flags = MPTDEXFlags}); - AMM amm(env, gw, XRP(1'000), BTC(1'000), false, 1'000); + env.fund(XRP(2'000), gw_, alice_); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {alice_}, + .pay = 2'000, + .flags = kMPT_DEX_FLAGS}); + AMM amm(env, gw_, XRP(1'000), btc(1'000), false, 1'000); // auction slot is owned by the creator of the AMM i.e. gw BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0})); @@ -3475,19 +3486,23 @@ private: // this transaction fails because AMMBid transaction can not burn // all the outstanding LPTokens env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = 1'000'000, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); } // burn all the LPTokens through a AMMBid transaction { Env env(*this); - env.fund(XRP(2'000), gw, alice); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice}, .pay = 2'000, .flags = MPTDEXFlags}); - AMM amm(env, gw, XRP(1'000), BTC(1'000), false, 1'000); + env.fund(XRP(2'000), gw_, alice_); + MPTTester const btc( + {.env = env, + .issuer = gw_, + .holders = {alice_}, + .pay = 2'000, + .flags = kMPT_DEX_FLAGS}); + AMM amm(env, gw_, XRP(1'000), btc(1'000), false, 1'000); // auction slot is owned by the creator of the AMM i.e. gw BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0})); @@ -3496,41 +3511,41 @@ private: // this transaction succeeds because the bid price is less than // the total outstanding LPToken balance env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = STAmount{amm.lptIssue(), UINT64_C(999'999)}, }), - ter(tesSUCCESS)) + Ter(tesSUCCESS)) .close(); // gw must own the auction slot BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{999'999})); // 999'999 tokens are burned, only 1 LPToken is owned by gw - BEAST_EXPECT(amm.expectBalances(XRP(1'000), BTC(1'000), IOUAmount{1})); + BEAST_EXPECT(amm.expectBalances(XRP(1'000), btc(1'000), IOUAmount{1})); // gw owns only 1 LPToken in its balance - BEAST_EXPECT(Number{amm.getLPTokensBalance(gw)} == 1); + BEAST_EXPECT(Number{amm.getLPTokensBalance(gw_)} == 1); // gw attempts to burn the last of its LPTokens in an AMMBid // transaction. This transaction fails because it would burn all // the remaining LPTokens env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = 1, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); } testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Invlaid Min/Max combination env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 200, .bidMax = 100, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Invalid Account Account bad("bad"); @@ -3539,8 +3554,8 @@ private: .account = bad, .bidMax = 100, }), - seq(1), - ter(terNO_ACCOUNT)); + Seq(1), + Ter(terNO_ACCOUNT)); // Account is not LP Account const dan("dan"); @@ -3549,102 +3564,102 @@ private: .account = dan, .bidMin = 100, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ .account = dan, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Auth account is invalid. env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 100, - .authAccounts = {bob}, + .authAccounts = {bob_}, }), - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); // Invalid Assets env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMax = 100, .assets = {{MPT(ammAlice[1]), GBP}}, }), - ter(terNO_AMM)); + Ter(terNO_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Invalid AMM testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMax = 100, }), - ter(terNO_AMM)); + Ter(terNO_AMM)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Bid price exceeds LP owned tokens { Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(1'000), {USD(30'000)}, Fund::All); - MPTTester const BTC( + fund(env, gw_, {alice_, bob_, carol_}, XRP(1'000), {USD(30'000)}, Fund::All); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol, bob}, + .issuer = gw_, + .holders = {alice_, carol_, bob_}, .pay = 30'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - AMM ammAlice(env, alice, BTC(10'000'000'000), USD(10'000)); - ammAlice.deposit(carol, 1'000'000); - ammAlice.deposit(bob, 10); + AMM ammAlice(env, alice_, btc(10'000'000'000), USD(10'000)); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.deposit(bob_, 10); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 1'000'001, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMax = 1'000'001, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 1'000, })); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{1'000})); // Slot purchase price is more than 1000 but bob only has 10 tokens env(ammAlice.bid({ - .account = bob, + .account = bob_, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); } // Bid all tokens, still own the slot { Env env(*this); - env.fund(XRP(1'000), gw, alice, bob); - MPTTester const BTC( + env.fund(XRP(1'000), gw_, alice_, bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 1'000, - .flags = MPTDEXFlags}); - AMM amm(env, gw, XRP(10), BTC(1'000)); + .flags = kMPT_DEX_FLAGS}); + AMM amm(env, gw_, XRP(10), btc(1'000)); auto const lpIssue = amm.lptIssue(); - env.trust(STAmount{lpIssue, 100}, alice); - env.trust(STAmount{lpIssue, 50}, bob); - env(pay(gw, alice, STAmount{lpIssue, 100})); - env(pay(gw, bob, STAmount{lpIssue, 50})); - env(amm.bid({.account = alice, .bidMin = 100})); + env.trust(STAmount{lpIssue, 100}, alice_); + env.trust(STAmount{lpIssue, 50}, bob_); + env(pay(gw_, alice_, STAmount{lpIssue, 100})); + env(pay(gw_, bob_, STAmount{lpIssue, 50})); + env(amm.bid({.account = alice_, .bidMin = 100})); // Alice doesn't have any more tokens, but // she still owns the slot. env(amm.bid({ - .account = bob, + .account = bob_, .bidMax = 50, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); } } @@ -3660,119 +3675,120 @@ private: // Bid 110 tokens. Pay bidMin. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - env(ammAlice.bid({.account = carol, .bidMin = 110})); + ammAlice.deposit(carol_, 1'000'000); + env(ammAlice.bid({.account = carol_, .bidMin = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); // 110 tokens are burned. BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{10'999'890, 0})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Bid with min/max when the pay price is less than min. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Bid exactly 110. Pay 110 because the pay price is < 110. - env(ammAlice.bid({.account = carol, .bidMin = 110, .bidMax = 110})); + env(ammAlice.bid({.account = carol_, .bidMin = 110, .bidMax = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{10'999'890})); // Bid exactly 180-200. Pay 180 because the pay price is < 180. - env(ammAlice.bid({.account = alice, .bidMin = 180, .bidMax = 200})); + env(ammAlice.bid({.account = alice_, .bidMin = 180, .bidMax = 200})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{180})); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), MPT(ammAlice[1])(11'000), IOUAmount{10'999'814'5, -1})); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Start bid at bidMin 110. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol, bob); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_, bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol, bob}, + .issuer = gw_, + .holders = {alice_, carol_, bob_}, .pay = 30'000, - .flags = MPTDEXFlags}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + .flags = kMPT_DEX_FLAGS}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Bid, pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})); + env(ammAlice.bid({.account = carol_, .bidMin = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - ammAlice.deposit(bob, 1'000'000); + ammAlice.deposit(bob_, 1'000'000); // Bid, pay the computed price. - env(ammAlice.bid({.account = bob})); + env(ammAlice.bid({.account = bob_})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount(1155, -1))); // Bid bidMax fails because the computed price is higher. env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMax = 120, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Bid MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMax = 600})); + env(ammAlice.bid({.account = carol_, .bidMax = 600})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{121'275, -3})); // Bid Min/MaxSlotPrice fails because the computed price is not // in range env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 10, .bidMax = 100, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Bid Min/MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMin = 100, .bidMax = 600})); + env(ammAlice.bid({.account = carol_, .bidMin = 100, .bidMax = 600})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{127'33875, -5})); } // Slot states. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol, bob); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_, bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol, bob}, + .issuer = gw_, + .holders = {alice_, carol_, bob_}, .pay = 30'000, - .flags = MPTDEXFlags}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'000)); + .flags = kMPT_DEX_FLAGS}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'000)); - ammAlice.deposit(carol, 1'000'000); - ammAlice.deposit(bob, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.deposit(bob_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount(12'000'000001), BTC(12'001), IOUAmount{12'000'000, 0})); + XRPAmount(12'000'000001), btc(12'001), IOUAmount{12'000'000, 0})); // Initial state. Pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + env(ammAlice.bid({.account = carol_, .bidMin = 110})).close(); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); // 1st Interval after close, price for 0th interval. - env(ammAlice.bid({.account = bob})); - env.close(seconds(AUCTION_SLOT_INTERVAL_DURATION + 1)); + env(ammAlice.bid({.account = bob_})); + env.close(seconds(kAUCTION_SLOT_INTERVAL_DURATION + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 1, IOUAmount{1'155, -1})); // 10th Interval after close, price for 1st interval. - env(ammAlice.bid({.account = carol})); - env.close(seconds((10 * AUCTION_SLOT_INTERVAL_DURATION) + 1)); + env(ammAlice.bid({.account = carol_})); + env.close(seconds((10 * kAUCTION_SLOT_INTERVAL_DURATION) + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 10, IOUAmount{121'275, -3})); // 20th Interval (expired) after close, price for 10th interval. - env(ammAlice.bid({.account = bob})); - env.close(seconds((AUCTION_SLOT_TIME_INTERVALS * AUCTION_SLOT_INTERVAL_DURATION) + 1)); + env(ammAlice.bid({.account = bob_})); + env.close( + seconds((kAUCTION_SLOT_TIME_INTERVALS * kAUCTION_SLOT_INTERVAL_DURATION) + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, std::nullopt, IOUAmount{127'33875, -5})); // 0 Interval. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + env(ammAlice.bid({.account = carol_, .bidMin = 110})).close(); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, std::nullopt, IOUAmount{110})); // ~321.09 tokens burnt on bidding fees. BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount(12'000'000001), BTC(12'001), IOUAmount{11'999'678'91000001, -8})); + XRPAmount(12'000'000001), btc(12'001), IOUAmount{11'999'678'91000001, -8})); } // Pool's fee 1%. Bid bidMin. @@ -3783,48 +3799,49 @@ private: Env env(*this); Account const dan("dan"); Account const ed("ed"); - env.fund(XRP(2'000), gw, alice, bob, carol, dan, ed); - MPTTester const BTC( + env.fund(XRP(2'000), gw_, alice_, bob_, carol_, dan, ed); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .pay = 30'000'000'000}); - fund(env, gw, {alice, carol}, {USD(30'000)}, Fund::TokenOnly); - fund(env, gw, {bob, dan, ed}, {USD(20'000)}, Fund::TokenOnly); + fund(env, gw_, {alice_, carol_}, {USD(30'000)}, Fund::TokenOnly); + fund(env, gw_, {bob_, dan, ed}, {USD(20'000)}, Fund::TokenOnly); - AMM ammAlice(env, alice, BTC(10'000'000'000), USD(10'000), CreateArg{.tfee = 1'000}); - ammAlice.deposit(bob, 1'000'000); + AMM ammAlice(env, alice_, btc(10'000'000'000), USD(10'000), CreateArg{.tfee = 1'000}); + ammAlice.deposit(bob_, 1'000'000); ammAlice.deposit(ed, 1'000'000); - ammAlice.deposit(carol, 500'000); + ammAlice.deposit(carol_, 500'000); ammAlice.deposit(dan, 500'000); auto ammTokens = ammAlice.getLPTokensBalance(); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 120, - .authAccounts = {bob, ed}, + .authAccounts = {bob_, ed}, })); auto const slotPrice = IOUAmount{5'200}; ammTokens -= slotPrice; BEAST_EXPECT(ammAlice.expectAuctionSlot(100, 0, slotPrice)); - BEAST_EXPECT(ammAlice.expectBalances(BTC(13'000'000'003), USD(13'000), ammTokens)); + BEAST_EXPECT(ammAlice.expectBalances(btc(13'000'000'003), USD(13'000), ammTokens)); // Discounted trade for (int i = 0; i < 10; ++i) { - auto tokens = ammAlice.deposit(carol, USD(100)); - ammAlice.withdraw(carol, tokens, USD(0)); - tokens = ammAlice.deposit(bob, USD(100)); - ammAlice.withdraw(bob, tokens, USD(0)); + auto tokens = ammAlice.deposit(carol_, USD(100)); + ammAlice.withdraw(carol_, tokens, USD(0)); + tokens = ammAlice.deposit(bob_, USD(100)); + ammAlice.withdraw(bob_, tokens, USD(0)); tokens = ammAlice.deposit(ed, USD(100)); ammAlice.withdraw(ed, tokens, USD(0)); } // carol, bob, and ed pay ~0.99USD in fees. BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(29'499'00572620545), -11)); - BEAST_EXPECT(env.balance(bob, USD) == STAmount(USD, UINT64_C(18'999'00572616195), -11)); + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'499'00572620545), -11)); + BEAST_EXPECT( + env.balance(bob_, USD) == STAmount(USD, UINT64_C(18'999'00572616195), -11)); BEAST_EXPECT(env.balance(ed, USD) == STAmount(USD, UINT64_C(18'999'00572611841), -11)); // USD pool is slightly higher because of the fees. BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'000'000'003), STAmount(USD, UINT64_C(13'002'98282151419), -11), ammTokens)); + btc(13'000'000'003), STAmount(USD, UINT64_C(13'002'98282151419), -11), ammTokens)); ammTokens = ammAlice.getLPTokensBalance(); // Trade with the fee @@ -3840,67 +3857,67 @@ private: BEAST_EXPECT(env.balance(dan, USD) == STAmount(USD, UINT64_C(19'490'05672274398), -11)); // USD pool gains more in dan's fees. BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'000'000'003), STAmount{USD, UINT64_C(13'012'92609877021), -11}, ammTokens)); + btc(13'000'000'003), STAmount{USD, UINT64_C(13'012'92609877021), -11}, ammTokens)); // Discounted fee payment - ammAlice.deposit(carol, USD(100)); + ammAlice.deposit(carol_, USD(100)); ammTokens = ammAlice.getLPTokensBalance(); BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(13'000'000'003), STAmount{USD, UINT64_C(13'112'92609877019), -11}, ammTokens)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(BTC(110'000'000))); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(btc(110'000'000))); env.close(); // carol pays 100000 drops in fees // 99900668MPT swapped in for 100USD BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'100'000'671), STAmount{USD, UINT64_C(13'012'92609877019), -11}, ammTokens)); + btc(13'100'000'671), STAmount{USD, UINT64_C(13'012'92609877019), -11}, ammTokens)); // Payment with the trading fee - env(pay(alice, carol, BTC(100'000'000)), path(~MPT(ammAlice[0])), sendmax(USD(110))); + env(pay(alice_, carol_, btc(100'000'000)), Path(~MPT(ammAlice[0])), Sendmax(USD(110))); env.close(); // alice pays ~1.011USD in fees, which is ~10 times more // than carol's fee // 100.099431529USD swapped in for 100MPT BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'000'000'671), STAmount{USD, UINT64_C(13'114'03663044931), -11}, ammTokens)); + btc(13'000'000'671), STAmount{USD, UINT64_C(13'114'03663044931), -11}, ammTokens)); // Auction slot expired, no discounted fee - env.close(seconds(TOTAL_TIME_SLOT_SECS + 1)); + env.close(seconds(kTOTAL_TIME_SLOT_SECS + 1)); // clock is parent's based env.close(); BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(29'399'00572620547), -11)); + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'399'00572620547), -11)); ammTokens = ammAlice.getLPTokensBalance(); for (int i = 0; i < 10; ++i) { - auto const tokens = ammAlice.deposit(carol, USD(100)); - ammAlice.withdraw(carol, tokens, USD(0)); + auto const tokens = ammAlice.deposit(carol_, USD(100)); + ammAlice.withdraw(carol_, tokens, USD(0)); } // carol pays ~9.94USD in fees, which is ~10 times more in // trading fees vs discounted fee. BEAST_EXPECT( - env.balance(carol, USD) == STAmount(USD, UINT64_C(29'389'06197177122), -11)); + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'389'06197177122), -11)); BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'000'000'671), STAmount{USD, UINT64_C(13'123'98038488356), -11}, ammTokens)); + btc(13'000'000'671), STAmount{USD, UINT64_C(13'123'98038488356), -11}, ammTokens)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(BTC(110'000'000))); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(btc(110'000'000))); env.close(); // carol pays ~1.008MPT in trading fee, which is // ~10 times more than the discounted fee. // 99.815876MPT is swapped in for 100USD BEAST_EXPECT(ammAlice.expectBalances( - BTC(13'100'824'793), STAmount{USD, UINT64_C(13'023'98038488356), -11}, ammTokens)); + btc(13'100'824'793), STAmount{USD, UINT64_C(13'023'98038488356), -11}, ammTokens)); } // Bid tiny amount testAMM( [&](AMM& ammAlice, Env& env) { // Bid a tiny amount - auto const tiny = Number{STAmount::cMinValue, STAmount::cMinOffset}; - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{tiny}})); + auto const tiny = Number{STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET}; + env(ammAlice.bid({.account = alice_, .bidMin = IOUAmount{tiny}})); // Auction slot purchase price is equal to the tiny amount // since the minSlotPrice is 0 with no trading fee. BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny})); @@ -3909,8 +3926,8 @@ private: MPT(ammAlice[0])(10'000'000'000), USD(10'000), ammAlice.tokens())); // Bid the tiny amount env(ammAlice.bid({ - .account = alice, - .bidMin = IOUAmount{STAmount::cMinValue, STAmount::cMinOffset}, + .account = alice_, + .bidMin = IOUAmount{STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET}, })); // Pay slightly higher price BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny * Number{105, -2}})); @@ -3919,63 +3936,63 @@ private: BEAST_EXPECT(ammAlice.expectBalances( MPT(ammAlice[0])(10'000'000'000), USD(10'000), ammAlice.tokens())); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // Reset auth account testAMM( [&](AMM& ammAlice, Env& env) { env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMin = IOUAmount{100}, - .authAccounts = {carol}, + .authAccounts = {carol_}, })); - BEAST_EXPECT(ammAlice.expectAuctionSlot({carol})); - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{100}})); + BEAST_EXPECT(ammAlice.expectAuctionSlot({carol_})); + env(ammAlice.bid({.account = alice_, .bidMin = IOUAmount{100}})); BEAST_EXPECT(ammAlice.expectAuctionSlot({})); Account bob("bob"); Account dan("dan"); fund(env, {bob, dan}, XRP(1'000)); env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMin = IOUAmount{100}, .authAccounts = {bob, dan}, })); BEAST_EXPECT(ammAlice.expectAuctionSlot({bob, dan})); }, - {{AMMMPT(10'000'000'000), USD(10'000)}}); + {{gAmmmpt(10'000'000'000), USD(10'000)}}); // Bid all tokens, still own the slot and trade at a discount { Env env(*this); - env.fund(XRP(2'000), gw, alice, bob); - MPTTester const BTC( + env.fund(XRP(2'000), gw_, alice_, bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 2'000'000'000, - .flags = MPTDEXFlags}); - fund(env, gw, {alice, bob}, {USD(2'000)}, Fund::TokenOnly); - AMM amm(env, gw, BTC(1'000'000'000), USD(1'010), false, 1'000); + .flags = kMPT_DEX_FLAGS}); + fund(env, gw_, {alice_, bob_}, {USD(2'000)}, Fund::TokenOnly); + AMM amm(env, gw_, btc(1'000'000'000), USD(1'010), false, 1'000); auto const lpIssue = amm.lptIssue(); - env.trust(STAmount{lpIssue, 500}, alice); - env.trust(STAmount{lpIssue, 50}, bob); - env(pay(gw, alice, STAmount{lpIssue, 500})); - env(pay(gw, bob, STAmount{lpIssue, 50})); + env.trust(STAmount{lpIssue, 500}, alice_); + env.trust(STAmount{lpIssue, 50}, bob_); + env(pay(gw_, alice_, STAmount{lpIssue, 500})); + env(pay(gw_, bob_, STAmount{lpIssue, 50})); // Alice doesn't have anymore lp tokens - env(amm.bid({.account = alice, .bidMin = 500})); + env(amm.bid({.account = alice_, .bidMin = 500})); BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{500})); - BEAST_EXPECT(expectHolding(env, alice, STAmount{lpIssue, 0})); + BEAST_EXPECT(expectHolding(env, alice_, STAmount{lpIssue, 0})); // But trades with the discounted fee since she still owns the slot. // Alice pays ~10011 MPT in fees - env(pay(alice, bob, USD(10)), path(~USD), sendmax(BTC(11'000'000))); + env(pay(alice_, bob_, USD(10)), Path(~USD), Sendmax(btc(11'000'000))); BEAST_EXPECT(amm.expectBalances( - BTC(1'010'010'011), USD(1'000), IOUAmount{1'004'487'562112089, -9})); + btc(1'010'010'011), USD(1'000), IOUAmount{1'004'487'562112089, -9})); // Bob pays the full fee ~0.1USD - env(pay(bob, alice, BTC(10'000'000)), path(~MPT(BTC)), sendmax(USD(11))); + env(pay(bob_, alice_, btc(10'000'000)), Path(~MPT(btc)), Sendmax(USD(11))); BEAST_EXPECT(amm.expectBalances( - BTC(1'000'010'011), + btc(1'000'010'011), STAmount{USD, UINT64_C(1'010'10090898081), -11}, IOUAmount{1'004'487'562112089, -9})); } @@ -3983,33 +4000,33 @@ private: // preflight tests { Env env(*this, features); - env.fund(XRP(2'000), gw, alice, bob); - MPTTester const BTC( + env.fund(XRP(2'000), gw_, alice_, bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob}, + .issuer = gw_, + .holders = {alice_, bob_}, .pay = 2'000, - .flags = MPTDEXFlags}); - AMM amm(env, gw, XRP(1'000), BTC(1'010), false, 1'000); - Json::Value const tx = amm.bid({.account = alice, .bidMin = 500}); + .flags = kMPT_DEX_FLAGS}); + AMM amm(env, gw_, XRP(1'000), btc(1'010), false, 1'000); + json::Value const tx = amm.bid({.account = alice_, .bidMin = 500}); { - auto jtx = env.jt(tx, seq(1), fee(10)); + auto jtx = env.jt(tx, Seq(1), Fee(10)); env.app().config().features.erase(featureMPTokensV2); PreflightContext const pfctx( - env.app(), *jtx.stx, env.current()->rules(), tapNONE, env.journal); + env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal); auto pf = AMMBid::checkExtraFeatures(pfctx); BEAST_EXPECT(pf == false); env.app().config().features.insert(featureMPTokensV2); } { - auto jtx = env.jt(tx, seq(1), fee(10)); + auto jtx = env.jt(tx, Seq(1), Fee(10)); jtx.jv["Asset2"]["currency"] = "XRP"; jtx.jv["Asset2"].removeMember("mpt_issuance_id"); jtx.stx = env.ust(jtx); PreflightContext const pfctx( - env.app(), *jtx.stx, env.current()->rules(), tapNONE, env.journal); + env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal); auto pf = AMMBid::preflight(pfctx); BEAST_EXPECT(pf == temBAD_AMM_TOKENS); } @@ -4023,15 +4040,15 @@ private: using namespace jtx; Env env(*this); - env.fund(XRP(2'000), gw, alice); - MPT const BTC = MPTTester( - {.env = env, .issuer = gw, .holders = {alice}, .transferFee = 1'500, .pay = 40'000}); + env.fund(XRP(2'000), gw_, alice_); + MPT const btc = MPTTester( + {.env = env, .issuer = gw_, .holders = {alice_}, .transferFee = 1'500, .pay = 40'000}); // alice creates AMM - AMM const amm(env, alice, XRP(1'000), BTC(1'000)); + AMM const amm(env, alice_, XRP(1'000), btc(1'000)); // gw owns MPTIssuance, not allowed to set asfAllowTrustLineClawback - env(fset(gw, asfAllowTrustLineClawback), ter(tecOWNERS)); + env(fset(gw_, asfAllowTrustLineClawback), Ter(tecOWNERS)); } void @@ -4041,27 +4058,27 @@ private: using namespace jtx; Env env(*this, features); - env.fund(XRP(1'000), gw); - env(fset(gw, asfAllowTrustLineClawback)); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}, Fund::Acct); + env.fund(XRP(1'000), gw_); + env(fset(gw_, asfAllowTrustLineClawback)); + fund(env, gw_, {alice_}, XRP(1'000), {USD(1'000)}, Fund::Acct); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); // to clawback from AMM account, must use AMMClawback instead of // Clawback auto const err = features[featureSingleAssetVault] ? tecPSEUDO_ACCOUNT : tecAMM_ACCOUNT; - AMM const amm(env, gw, XRP(100), BTC(100)); + AMM const amm(env, gw_, XRP(100), btc(100)); auto amount = amountFromString(amm.lptIssue(), "10"); - env(claw(gw, amount), ter(err)); + env(claw(gw_, amount), Ter(err)); - AMM const amm1(env, alice, USD(100), BTC(200)); + AMM const amm1(env, alice_, USD(100), btc(200)); auto amount1 = amountFromString(amm1.lptIssue(), "10"); - env(claw(gw, amount1), ter(err)); + env(claw(gw_, amount1), Ter(err)); } void @@ -4075,259 +4092,259 @@ private: // Can't pay into AMM account. // Can't pay out since there is no keys - for (auto const& acct : {gw, alice}) + for (auto const& acct : {gw_, alice_}) { { Env env(*this); - fund(env, gw, {alice, carol}, XRP(1'000)); - MPTTester const BTC( + fund(env, gw_, {alice_, carol_}, XRP(1'000)); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 100, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // XRP balance is below reserve - AMM const ammAlice(env, acct, XRP(10), BTC(10)); + AMM const ammAlice(env, acct, XRP(10), btc(10)); // Pay below reserve - env(pay(carol, ammAlice.ammAccount(), XRP(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(10)), Ter(tecNO_PERMISSION)); // Pay above reserve - env(pay(carol, ammAlice.ammAccount(), XRP(300)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(300)), Ter(tecNO_PERMISSION)); // Pay MPT - env(pay(carol, ammAlice.ammAccount(), BTC(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), btc(10)), Ter(tecNO_PERMISSION)); } { Env env(*this); - fund(env, gw, {alice, carol}, XRP(10'000'000)); - MPTTester const BTC( + fund(env, gw_, {alice_, carol_}, XRP(10'000'000)); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 20'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); // XRP balance is above reserve - AMM const ammAlice(env, acct, XRP(1'000'000), BTC(10'000)); + AMM const ammAlice(env, acct, XRP(1'000'000), btc(10'000)); // Pay below reserve - env(pay(carol, ammAlice.ammAccount(), XRP(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(10)), Ter(tecNO_PERMISSION)); // Pay above reserve - env(pay(carol, ammAlice.ammAccount(), XRP(1'000'000)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(1'000'000)), Ter(tecNO_PERMISSION)); // Pay MPT - env(pay(carol, ammAlice.ammAccount(), BTC(1'000)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), btc(1'000)), Ter(tecNO_PERMISSION)); } } // Can't pay into AMM with escrow. testAMM( [&](AMM& ammAlice, Env& env) { - env(escrow::create(carol, ammAlice.ammAccount(), MPT(ammAlice[1])(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(1'500), - ter(tecNO_PERMISSION)); + env(escrow::create(carol_, ammAlice.ammAccount(), MPT(ammAlice[1])(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(1'500), + Ter(tecNO_PERMISSION)); - env(escrow::create(carol, ammAlice.ammAccount(), XRP(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(1'500), - ter(tecNO_PERMISSION)); + env(escrow::create(carol_, ammAlice.ammAccount(), XRP(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(1'500), + Ter(tecNO_PERMISSION)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Can't pay into AMM with paychan. testAMM( [&](AMM& ammAlice, Env& env) { - auto const pk = carol.pk(); + auto const pk = carol_.pk(); auto const settleDelay = 10s; NetClock::time_point const cancelAfter = env.current()->header().parentCloseTime + 20s; env(create( - carol, + carol_, ammAlice.ammAccount(), MPT(ammAlice[1])(1'000), settleDelay, pk, cancelAfter), - ter(telENV_RPC_FAILED)); + Ter(telENV_RPC_FAILED)); - env(create(carol, ammAlice.ammAccount(), XRP(1'000), settleDelay, pk, cancelAfter), - ter(tecNO_PERMISSION)); + env(create(carol_, ammAlice.ammAccount(), XRP(1'000), settleDelay, pk, cancelAfter), + Ter(tecNO_PERMISSION)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Can't pay into AMM with checks. testAMM( [&](AMM& ammAlice, Env& env) { env(check::create(env.master.id(), ammAlice.ammAccount(), XRP(100)), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env(check::create(env.master.id(), ammAlice.ammAccount(), MPT(ammAlice[1])(100)), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Pay amounts close to one side of the pool testAMM( [&](AMM& ammAlice, Env& env) { - auto const& BTC = MPT(ammAlice[1]); + auto const& btc = MPT(ammAlice[1]); // Can't consume whole pool - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(BTC(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, BTC(100'000'000)), - path(~BTC), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(btc(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, btc(100'000'000)), + Path(~btc), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); // Overflow - env(pay(alice, carol, STAmount{USD, UINT64_C(99'999999999), -9}), - path(~USD), - sendmax(BTC(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, STAmount{USD, UINT64_C(999'99999999), -8}), - path(~USD), - sendmax(BTC(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, BTC(99'999'999)), - path(~BTC), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{USD, UINT64_C(99'999999999), -9}), + Path(~USD), + Sendmax(btc(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{USD, UINT64_C(999'99999999), -8}), + Path(~USD), + Sendmax(btc(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, btc(99'999'999)), + Path(~btc), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); // Sender doesn't have enough funds - env(pay(alice, carol, USD(99.99)), - path(~USD), - sendmax(BTC(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, BTC(99'990'000)), - path(~BTC), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(99.99)), + Path(~USD), + Sendmax(btc(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, btc(99'990'000)), + Path(~btc), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); }, - {{USD(100), AMMMPT(100'000'000)}}); + {{USD(100), gAmmmpt(100'000'000)}}); // Globally locked MPT. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); - BTC.set({.flags = tfMPTLock}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); + btc.set({.flags = tfMPTLock}); - env(pay(alice, carol, BTC(1)), - path(~static_cast(BTC)), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(XRP(10)), - ter(tecPATH_DRY)); - env(pay(alice, carol, XRP(1)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(BTC(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, btc(1)), + Path(~static_cast(btc)), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(XRP(10)), + Ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(btc(10)), + Ter(tecPATH_DRY)); } // Individually locked MPT destination account. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); - BTC.set({.holder = carol, .flags = tfMPTLock}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); + btc.set({.holder = carol_, .flags = tfMPTLock}); - env(pay(alice, carol, BTC(1)), - path(~static_cast(BTC)), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(XRP(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, btc(1)), + Path(~static_cast(btc)), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(XRP(10)), + Ter(tecPATH_DRY)); } // Individually locked MPT source account { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); - BTC.set({.holder = alice, .flags = tfMPTLock}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); + btc.set({.holder = alice_, .flags = tfMPTLock}); - env(pay(alice, carol, XRP(1)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(BTC(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(btc(10)), + Ter(tecPATH_DRY)); } // lock on both sides { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester ETH( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester eth( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, ETH(10'000), BTC(10'000)); - BTC.set({.holder = carol, .flags = tfMPTLock}); - BTC.set({.holder = alice, .flags = tfMPTLock}); - ETH.set({.holder = carol, .flags = tfMPTLock}); - ETH.set({.holder = alice, .flags = tfMPTLock}); + AMM const ammAlice(env, alice_, eth(10'000), btc(10'000)); + btc.set({.holder = carol_, .flags = tfMPTLock}); + btc.set({.holder = alice_, .flags = tfMPTLock}); + eth.set({.holder = carol_, .flags = tfMPTLock}); + eth.set({.holder = alice_, .flags = tfMPTLock}); - env(pay(alice, carol, ETH(1)), - path(~MPT(ETH)), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(BTC(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, eth(1)), + Path(~MPT(eth)), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(btc(10)), + Ter(tecPATH_DRY)); - env(pay(alice, carol, BTC(1)), - path(~MPT(BTC)), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(ETH(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, btc(1)), + Path(~MPT(btc)), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(eth(10)), + Ter(tecPATH_DRY)); } // Individually locked AMM MPT { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); - BTC.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); + btc.set({.holder = ammAlice.ammAccount(), .flags = tfMPTLock}); - env(pay(alice, carol, XRP(1)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(BTC(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(btc(10)), + Ter(tecPATH_DRY)); } } @@ -4341,64 +4358,64 @@ private: // Force one path with tfNoRippleDirect. testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); - env.fund(XRP(30'000), bob); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); + env.fund(XRP(30'000), bob_); env.close(); - env(pay(bob, carol, MPT(ammAlice[1])(100)), - path(~MPT(ammAlice[1])), - sendmax(XRP(100)), - txflags(tfNoRippleDirect)); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), + Path(~MPT(ammAlice[1])), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'000), ammAlice.tokens())); // Initial balance + 100 - env.require(balance(carol, carolMPT + MPT(ammAlice[1])(100))); + env.require(Balance(carol_, carolMPT + MPT(ammAlice[1])(100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, - {{XRP(10'000), AMMMPT(10'100)}}); + {{XRP(10'000), gAmmmpt(10'100)}}); // Payment 100IOU/MPT for 100IOU/MPT. Test IOU/MPT mix. // Force one path with tfNoRippleDirect. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10100)); - auto carolBTC = env.balance(carol, BTC); - auto bobUSD = env.balance(bob, USD); - env(pay(bob, carol, BTC(100)), - path(~BTC), - sendmax(USD(100)), - txflags(tfNoRippleDirect | tfPartialPayment)); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10100)); + auto carolBTC = env.balance(carol_, btc); + auto bobUSD = env.balance(bob_, usd); + env(pay(bob_, carol_, btc(100)), + Path(~btc), + Sendmax(usd(100)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'100), BTC(10'000), ammAlice.tokens())); - env.require(balance(carol, carolBTC + BTC(100))); - env.require(balance(bob, bobUSD - USD(100))); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'100), btc(10'000), ammAlice.tokens())); + env.require(Balance(carol_, carolBTC + btc(100))); + env.require(Balance(bob_, bobUSD - usd(100))); }; testHelper2TokensMix(test); } @@ -4406,58 +4423,58 @@ private: // Payment 100MPT for 100XRP, use default path. testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); - env.fund(XRP(30'000), bob); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); + env.fund(XRP(30'000), bob_); env.close(); - env(pay(bob, carol, MPT(ammAlice[1])(100)), sendmax(XRP(100))); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), Sendmax(XRP(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'000), ammAlice.tokens())); // Initial balance + 100 - env.require(balance(carol, carolMPT + MPT(ammAlice[1])(100))); + env.require(Balance(carol_, carolMPT + MPT(ammAlice[1])(100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, - {{XRP(10'000), AMMMPT(10'100)}}); + {{XRP(10'000), gAmmmpt(10'100)}}); // Payment 100IOU/MPT for 100IOU/MPT using default path. // Test IOU/MPT mix. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10100)); - auto carolBTC = env.balance(carol, BTC); - auto bobUSD = env.balance(bob, USD); - env(pay(bob, carol, BTC(100)), sendmax(USD(100))); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10100)); + auto carolBTC = env.balance(carol_, btc); + auto bobUSD = env.balance(bob_, usd); + env(pay(bob_, carol_, btc(100)), Sendmax(usd(100))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'100), BTC(10'000), ammAlice.tokens())); - env.require(balance(carol, carolBTC + BTC(100))); - env.require(balance(bob, bobUSD - USD(100))); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'100), btc(10'000), ammAlice.tokens())); + env.require(Balance(carol_, carolBTC + btc(100))); + env.require(Balance(bob_, bobUSD - usd(100))); }; testHelper2TokensMix(test); } @@ -4466,59 +4483,59 @@ private: // both default path and path, activeStrands has one path. testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); - env.fund(XRP(30'000), bob); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); + env.fund(XRP(30'000), bob_); env.close(); - env(pay(bob, carol, MPT(ammAlice[1])(100)), - path(~MPT(ammAlice[1])), - sendmax(XRP(100))); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), + Path(~MPT(ammAlice[1])), + Sendmax(XRP(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'000), ammAlice.tokens())); // Initial balance + 100 - env.require(balance(carol, carolMPT + MPT(ammAlice[1])(100))); + env.require(Balance(carol_, carolMPT + MPT(ammAlice[1])(100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, - {{XRP(10'000), AMMMPT(10'100)}}); + {{XRP(10'000), gAmmmpt(10'100)}}); // Test MPT/IOU combination for the case above. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10100)); - auto carolBTC = env.balance(carol, BTC); - auto bobUSD = env.balance(bob, USD); - env(pay(bob, carol, BTC(100)), path(~BTC), sendmax(USD(100))); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10100)); + auto carolBTC = env.balance(carol_, btc); + auto bobUSD = env.balance(bob_, usd); + env(pay(bob_, carol_, btc(100)), Path(~btc), Sendmax(usd(100))); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'100), BTC(10'000), ammAlice.tokens())); - env.require(balance(carol, carolBTC + BTC(100))); - env.require(balance(bob, bobUSD - USD(100))); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'100), btc(10'000), ammAlice.tokens())); + env.require(Balance(carol_, carolBTC + btc(100))); + env.require(Balance(bob_, bobUSD - usd(100))); }; testHelper2TokensMix(test); } @@ -4526,81 +4543,81 @@ private: // Payment with limitQuality set. testAMM( [&](AMM& ammAlice, Env& env) { - auto carolMPT = env.balance(carol, MPT(ammAlice[1])); - env.fund(jtx::XRP(30'000), bob); + auto carolMPT = env.balance(carol_, MPT(ammAlice[1])); + env.fund(jtx::XRP(30'000), bob_); env.close(); // Pays 10MPT for 10XRP. A larger payment of ~99.11MPT/100XRP // would have been sent has it not been for limitQuality. - env(pay(bob, carol, MPT(ammAlice[1])(100)), - path(~MPT(ammAlice[1])), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), + Path(~MPT(ammAlice[1])), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'010), MPT(ammAlice[1])(10'000), ammAlice.tokens())); // Initial balance + 10(limited by limitQuality) - env.require(balance(carol, carolMPT + MPT(ammAlice[1])(10))); + env.require(Balance(carol_, carolMPT + MPT(ammAlice[1])(10))); // Initial balance 30,000 - 10(limited by limitQuality) - 10(tx // fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(10) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(10) - txFee(env, 1))); // Fails because of limitQuality. Would have sent // ~98.91MPT/110XRP has it not been for limitQuality. - env(pay(bob, carol, MPT(ammAlice[1])(100)), - path(~MPT(ammAlice[1])), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), - ter(tecPATH_DRY)); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), + Path(~MPT(ammAlice[1])), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), + Ter(tecPATH_DRY)); env.close(); }, - {{XRP(10'000), AMMMPT(10'010)}}); + {{XRP(10'000), gAmmmpt(10'010)}}); // Payment with limitQuality set. MPT/IOU combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10010)); - auto carolBTC = env.balance(carol, BTC); - auto bobUSD = env.balance(bob, USD); - env(pay(bob, carol, BTC(100)), - path(~BTC), - sendmax(USD(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10010)); + auto carolBTC = env.balance(carol_, btc); + auto bobUSD = env.balance(bob_, usd); + env(pay(bob_, carol_, btc(100)), + Path(~btc), + Sendmax(usd(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(USD(10'010), BTC(10'000), ammAlice.tokens())); - env.require(balance(carol, carolBTC + BTC(10))); - env.require(balance(bob, bobUSD - USD(10))); + BEAST_EXPECT(ammAlice.expectBalances(usd(10'010), btc(10'000), ammAlice.tokens())); + env.require(Balance(carol_, carolBTC + btc(10))); + env.require(Balance(bob_, bobUSD - usd(10))); - env(pay(bob, carol, BTC(100)), - path(~BTC), - sendmax(USD(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), - ter(tecPATH_DRY)); + env(pay(bob_, carol_, btc(100)), + Path(~btc), + Sendmax(usd(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), + Ter(tecPATH_DRY)); env.close(); }; testHelper2TokensMix(test); @@ -4609,76 +4626,76 @@ private: // Payment with limitQuality and transfer fee set. { Env env(*this); - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); env.close(); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 10'000, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - auto ammAlice = AMM(env, alice, XRP(10'000), BTC(10'010'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + auto ammAlice = AMM(env, alice_, XRP(10'000), btc(10'010'000'000'000'000)); env.close(); - auto carolMPT = env.balance(carol, MPT(BTC)); + auto carolMPT = env.balance(carol_, MPT(btc)); // Pays 10'000'000'000'000MPT for 10XRP. A larger payment of // ~99'110'000'000'000MPT/100XRP would have been sent has it not // been for limitQuality and the transfer fee. - env(pay(bob, carol, BTC(100'000'000'000'000)), - path(~MPT(BTC)), - sendmax(XRP(110)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(bob_, carol_, btc(100'000'000'000'000)), + Path(~MPT(btc)), + Sendmax(XRP(110)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'010), BTC(10'000'000'000'000'000), ammAlice.tokens())); + XRP(10'010), btc(10'000'000'000'000'000), ammAlice.tokens())); // 10'000'000'000'000MPT - 10% transfer fee - env.require(balance(carol, carolMPT + BTC(9'090'909'090'909))); - BEAST_EXPECT(expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(10) - txfee(env, 1))); + env.require(Balance(carol_, carolMPT + btc(9'090'909'090'909))); + BEAST_EXPECT(expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(10) - txFee(env, 1))); } // Payment with limitQuality and transfer fee set. MPT/IOU combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1({ + auto const usd = issue1({ .env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000 //.transferFee = 10'000 }); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 300'000'000'000'000'000, .transferFee = 10'000}); - env(pay(gw, alice, BTC(30'000'000'000'000'000))); - env(pay(gw, bob, BTC(30'000'000'000'000'000))); - env(pay(gw, carol, BTC(30'000'000'000'000'000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(30'000'000'000'000'000))); + env(pay(gw_, bob_, btc(30'000'000'000'000'000))); + env(pay(gw_, carol_, btc(30'000'000'000'000'000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10'000), BTC(10'010'000'000'000'000)); - auto carolBTC = env.balance(carol, BTC); - auto bobUSD = env.balance(bob, USD); - env(pay(bob, carol, BTC(100'000'000'000'000)), - path(~BTC), - sendmax(USD(110)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + auto ammAlice = AMM(env, alice_, usd(10'000), btc(10'010'000'000'000'000)); + auto carolBTC = env.balance(carol_, btc); + auto bobUSD = env.balance(bob_, usd); + env(pay(bob_, carol_, btc(100'000'000'000'000)), + Path(~btc), + Sendmax(usd(110)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( - USD(10'010), BTC(10'000'000'000'000'000), ammAlice.tokens())); - env.require(balance(carol, carolBTC + BTC(9'090'909'090'909))); - env.require(balance(bob, bobUSD - USD(10))); + usd(10'010), btc(10'000'000'000'000'000), ammAlice.tokens())); + env.require(Balance(carol_, carolBTC + btc(9'090'909'090'909))); + env.require(Balance(bob_, bobUSD - usd(10))); }; testHelper2TokensMix(test); } @@ -4686,49 +4703,49 @@ private: // Fail when partial payment is not set. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); - env(pay(bob, carol, MPT(ammAlice[1])(100)), - path(~MPT(ammAlice[1])), - sendmax(XRP(100)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(bob_, carol_, MPT(ammAlice[1])(100)), + Path(~MPT(ammAlice[1])), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); // Fail when partial payment is not set. MPT/IOU combination. { auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); - env.fund(XRP(30'000), alice, bob, carol, gw); + env.fund(XRP(30'000), alice_, bob_, carol_, gw_); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .limit = 1'000'000}); - env(pay(gw, alice, BTC(50000))); - env(pay(gw, bob, BTC(50000))); - env(pay(gw, carol, BTC(50000))); - env(pay(gw, alice, USD(50000))); - env(pay(gw, bob, USD(50000))); - env(pay(gw, carol, USD(50000))); + env(pay(gw_, alice_, btc(50000))); + env(pay(gw_, bob_, btc(50000))); + env(pay(gw_, carol_, btc(50000))); + env(pay(gw_, alice_, usd(50000))); + env(pay(gw_, bob_, usd(50000))); + env(pay(gw_, carol_, usd(50000))); env.close(); - auto ammAlice = AMM(env, alice, USD(10000), BTC(10000)); - env(pay(bob, carol, BTC(100)), - path(~BTC), - sendmax(USD(100)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + auto ammAlice = AMM(env, alice_, usd(10000), btc(10000)); + env(pay(bob_, carol_, btc(100)), + Path(~btc), + Sendmax(usd(100)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); }; testHelper2TokensMix(test); } @@ -4739,48 +4756,48 @@ private: // is taken from the offer. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 3'000'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 3'000'000'000'000'000'000, - .flags = MPTDEXFlags}); - env.fund(XRP(1'000), bob); + .flags = kMPT_DEX_FLAGS}); + env.fund(XRP(1'000), bob_); env.close(); - auto ammETH_XRP = AMM(env, alice, XRP(10'000), ETH(1'000'000'000'000'000'000)); - auto ammBTC_ETH = - AMM(env, alice, ETH(1'000'000'000'000'000'000), BTC(1'000'000'000'000'000'000)); - env(offer(alice, XRP(101), BTC(10'000'000'000'000'000)), txflags(tfPassive)); + auto ammEthXrp = AMM(env, alice_, XRP(10'000), eth(1'000'000'000'000'000'000)); + auto ammBtcEth = + AMM(env, alice_, eth(1'000'000'000'000'000'000), btc(1'000'000'000'000'000'000)); + env(offer(alice_, XRP(101), btc(10'000'000'000'000'000)), Txflags(tfPassive)); env.close(); - env(pay(bob, carol, BTC(10'000'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(XRP(102)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, btc(10'000'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(XRP(102)), + Txflags(tfPartialPayment)); env.close(); - BEAST_EXPECT(ammETH_XRP.expectBalances( - XRPAmount(10'030'082'730), ETH(9'970'00749812546872), ammETH_XRP.tokens())); + BEAST_EXPECT(ammEthXrp.expectBalances( + XRPAmount(10'030'082'730), eth(9'970'00749812546872), ammEthXrp.tokens())); - BEAST_EXPECT(ammBTC_ETH.expectBalances( - BTC(9'970'09727766213961), ETH(10'029'99250187453128), ammBTC_ETH.tokens())); + BEAST_EXPECT(ammBtcEth.expectBalances( + btc(9'970'09727766213961), eth(10'029'99250187453128), ammBtcEth.tokens())); - Amounts const expectedAmounts = Amounts{XRPAmount(30'201'749), BTC(29'90272233786039)}; + Amounts const expectedAmounts = Amounts{XRPAmount(30'201'749), btc(29'90272233786039)}; - BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{expectedAmounts}})); // Initial (30,000 + 100)e14 - env.require(balance(carol, BTC(3'010'000'000'000'000'000))); + env.require(Balance(carol_, btc(3'010'000'000'000'000'000))); // Initial 1,000 - 30082730(AMM pool) - 70798251(offer) - 10(tx fee) BEAST_EXPECT(expectLedgerEntryRoot( env, - bob, - XRP(1'000) - XRPAmount{30'082'730} - XRPAmount{70'798'251} - txfee(env, 1))); + bob_, + XRP(1'000) - XRPAmount{30'082'730} - XRPAmount{70'798'251} - txFee(env, 1))); } // Default path (with AMM) has a better quality than a @@ -4789,82 +4806,82 @@ private: // path ~49XRP/49e14BTC. The rest is taken from the offer. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 3'000'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 1'000'000'000'000'000'000, - .flags = MPTDEXFlags}); - auto ammAlice = AMM(env, alice, XRP(10'000), BTC(1'000'000'000'000'000'000)); - env.fund(XRP(1'000), bob); + .flags = kMPT_DEX_FLAGS}); + auto ammAlice = AMM(env, alice_, XRP(10'000), btc(1'000'000'000'000'000'000)); + env.fund(XRP(1'000), bob_); env.close(); - env(offer(alice, XRP(101), ETH(10'000'000'000'000'000)), txflags(tfPassive)); + env(offer(alice_, XRP(101), eth(10'000'000'000'000'000)), Txflags(tfPassive)); env.close(); - env(offer(alice, ETH(10'000'000'000'000'000), BTC(10'000'000'000'000'000)), - txflags(tfPassive)); + env(offer(alice_, eth(10'000'000'000'000'000), btc(10'000'000'000'000'000)), + Txflags(tfPassive)); env.close(); - env(pay(bob, carol, BTC(10'000'000'000'000'000)), - path(~MPT(ETH), ~MPT(BTC)), - sendmax(XRP(102)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, btc(10'000'000'000'000'000)), + Path(~MPT(eth), ~MPT(btc)), + Sendmax(XRP(102)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount(10'050'238'637), BTC(9'950'01249687578120), ammAlice.tokens())); + XRPAmount(10'050'238'637), btc(9'950'01249687578120), ammAlice.tokens())); BEAST_EXPECT(expectOffers( env, - alice, + alice_, 2, - {{Amounts{XRPAmount(50'487'378), ETH(49'98750312421880)}, - Amounts{ETH(49'98750312421880), BTC(49'98750312421880)}}})); + {{Amounts{XRPAmount(50'487'378), eth(49'98750312421880)}, + Amounts{eth(49'98750312421880), btc(49'98750312421880)}}})); // Initial (30,000 + 100)e14 - env.require(balance(carol, BTC(30'100'00000000000000))); + env.require(Balance(carol_, btc(30'100'00000000000000))); // Initial 1,000 - 50238637(AMM pool) - 50512622(offer) - 10(tx // fee) BEAST_EXPECT(expectLedgerEntryRoot( env, - bob, - XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - txfee(env, 1))); + bob_, + XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - txFee(env, 1))); } // Default path with AMM and Order Book offer. AMM is consumed first, // remaining amount is consumed by the offer. { Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(30'000)); - MPTTester const BTC( + fund(env, gw_, {alice_, bob_, carol_}, XRP(30'000)); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'100'000'000'000'000)); - env(offer(bob, XRP(100), MPT(ammAlice[1])(100'000'000'000'000)), txflags(tfPassive)); + .flags = kMPT_DEX_FLAGS}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'100'000'000'000'000)); + env(offer(bob_, XRP(100), MPT(ammAlice[1])(100'000'000'000'000)), Txflags(tfPassive)); env.close(); - env(pay(alice, carol, MPT(ammAlice[1])(200'000'000'000'000)), - sendmax(XRP(200)), - txflags(tfPartialPayment)); + env(pay(alice_, carol_, MPT(ammAlice[1])(200'000'000'000'000)), + Sendmax(XRP(200)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), MPT(ammAlice[1])(10'000'000000000001), ammAlice.tokens())); - env.require(balance(carol, MPT(ammAlice[1])(30'199'999999999999))); + env.require(Balance(carol_, MPT(ammAlice[1])(30'199'999999999999))); // Initial 30,000 - 10000(AMM pool LP) - 100(AMMoffer) - // - 100(offer) - 10(tx fee) - 10(tx fee of MPTTester init as // holder) - one reserve BEAST_EXPECT(expectLedgerEntryRoot( env, - alice, + alice_, XRP(30'000) - XRP(10'000) - XRP(100) - XRP(100) - ammCrtFee(env) - - 2 * txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + 2 * txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } // Default path with AMM and Order Book offer. @@ -4872,165 +4889,165 @@ private: // Remaining amount is consumed by AMM. { Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(20'000)); - MPTTester const BTC( + fund(env, gw_, {alice_, bob_, carol_}, XRP(20'000)); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 2'000, - .flags = MPTDEXFlags}); - env(offer(bob, XRP(50), BTC(150)), txflags(tfPassive)); + .flags = kMPT_DEX_FLAGS}); + env(offer(bob_, XRP(50), btc(150)), Txflags(tfPassive)); env.close(); - AMM const ammAlice(env, alice, XRP(1'000), BTC(1'050)); - env(pay(alice, carol, BTC(200)), sendmax(XRP(200)), txflags(tfPartialPayment)); - BEAST_EXPECT(ammAlice.expectBalances(XRP(1'050), BTC(1'000), ammAlice.tokens())); - env.require(balance(carol, BTC(2'200))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + AMM const ammAlice(env, alice_, XRP(1'000), btc(1'050)); + env(pay(alice_, carol_, btc(200)), Sendmax(XRP(200)), Txflags(tfPartialPayment)); + BEAST_EXPECT(ammAlice.expectBalances(XRP(1'050), btc(1'000), ammAlice.tokens())); + env.require(Balance(carol_, btc(2'200))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } // Offer crossing XRP/MPT { Env env(*this); - fund(env, gw, {alice, bob, carol}, XRP(30'000)); - MPTTester const BTC( + fund(env, gw_, {alice_, bob_, carol_}, XRP(30'000)); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000, - .flags = MPTDEXFlags}); - AMM ammAlice(env, alice, XRP(10'000), BTC(10'100)); - env(offer(bob, MPT(ammAlice[1])(100), XRP(100))); + .flags = kMPT_DEX_FLAGS}); + AMM ammAlice(env, alice_, XRP(10'000), btc(10'100)); + env(offer(bob_, MPT(ammAlice[1])(100), XRP(100))); env.close(); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), MPT(ammAlice[1])(10'000), ammAlice.tokens())); // Initial 30,000 + 100 - env.require(balance(bob, MPT(ammAlice[1])(30'100))); + env.require(Balance(bob_, MPT(ammAlice[1])(30'100))); // Initial 30,000 - 100(offer) - 10(tx fee) - 1(tx fee for MPTTester // holder) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - 2 * txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - 2 * txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } // Offer crossing MPT/MPT and transfer rate // Single path AMM offer { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 25'000, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 25'000, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammAlice(env, alice, BTC(1'000'000'000'000'000), ETH(1'100'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, btc(1'000'000'000'000'000), eth(1'100'000'000'000'000)); // This offer succeeds to cross pre- and post-amendment // because the strand's out amount is small enough to match // limitQuality value and limitOut() function in StrandFlow // doesn't require an adjustment to out value. - env(offer(carol, ETH(100'000'000'000'000), BTC(100'000'000'000'000))); + env(offer(carol_, eth(100'000'000'000'000), btc(100'000'000'000'000))); env.close(); // No transfer fee BEAST_EXPECT(ammAlice.expectBalances( - BTC(1'100'000'000'000'000), ETH(1'000'000'000'000'000), ammAlice.tokens())); + btc(1'100'000'000'000'000), eth(1'000'000'000'000'000), ammAlice.tokens())); // Initial 30,000'000'000'000'000 - 100'000'000'000'000(offer)-25 % // transfer fee - env.require(balance(carol, BTC(29'875'000'000'000'000))); + env.require(Balance(carol_, btc(29'875'000'000'000'000))); // Initial 30,000'000'000'000'000 + 100'000'000'000'000(offer) - env.require(balance(carol, ETH(30'100'000'000'000'000))); - BEAST_EXPECT(expectOffers(env, carol, 0)); + env.require(Balance(carol_, eth(30'100'000'000'000'000))); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Single-path AMM offer { Env env(*this); - env.fund(XRP(30'000), gw, alice, bob, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 100, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const amm(env, alice, XRP(1'000), BTC(500'000'000'000'000)); - env(offer(carol, XRP(100), BTC(55'000'000'000'000))); + .flags = kMPT_DEX_FLAGS}); + AMM const amm(env, alice_, XRP(1'000), btc(500'000'000'000'000)); + env(offer(carol_, XRP(100), btc(55'000'000'000'000))); env.close(); BEAST_EXPECT( - amm.expectBalances(XRPAmount(909'090'909), BTC(550'000000055001), amm.tokens())); + amm.expectBalances(XRPAmount(909'090'909), btc(550'000000055001), amm.tokens())); // Offer ~91XRP/49.99e12BTC BEAST_EXPECT(expectOffers( - env, carol, 1, {{Amounts{XRPAmount{9'090'909}, BTC(4'999999950000)}}})); + env, carol_, 1, {{Amounts{XRPAmount{9'090'909}, btc(4'999999950000)}}})); // Carol pays 0.1% fee on 50'000000055000BTC = 50'000000055BTC - env.require(balance(carol, BTC(29'949'949'999'944'943))); + env.require(Balance(carol_, btc(29'949'949'999'944'943))); } { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .transferFee = 100, .pay = 3'000'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const amm(env, alice, XRP(1'000), BTC(50'000'000'000'000'000)); - env(offer(carol, XRP(10), BTC(5'500'000'000'000'000))); + .flags = kMPT_DEX_FLAGS}); + AMM const amm(env, alice_, XRP(1'000), btc(50'000'000'000'000'000)); + env(offer(carol_, XRP(10), btc(5'500'000'000'000'000))); env.close(); - BEAST_EXPECT(amm.expectBalances(XRP(990), BTC(505'05050505050506), amm.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(amm.expectBalances(XRP(990), btc(505'05050505050506), amm.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Multi-path AMM offer { Env env(*this); Account const ed("ed"); - env.fund(XRP(30'000), gw, alice, bob, carol, ed); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, bob_, carol_, ed); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 20'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = 25'000, .pay = 20'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); AMM const ammAlice( - env, alice, BTC(10'000'000'000'000'000), ETH(11'000'000'000'000'000)); + env, alice_, btc(10'000'000'000'000'000), eth(11'000'000'000'000'000)); - env(offer(bob, BTC(100'000'000'000'000), XRP(10)), txflags(tfPassive)); - env(offer(ed, XRP(10), ETH(100'000'000'000'000)), txflags(tfPassive)); + env(offer(bob_, btc(100'000'000'000'000), XRP(10)), Txflags(tfPassive)); + env(offer(ed, XRP(10), eth(100'000'000'000'000)), Txflags(tfPassive)); env.close(); - env(offer(carol, ETH(1'000'000'000'000'000), BTC(1'000'000'000'000'000))); + env(offer(carol_, eth(1'000'000'000'000'000), btc(1'000'000'000'000'000))); env.close(); BEAST_EXPECT(ammAlice.expectBalances( - BTC(1'060'6848287928033), ETH(1'037'0658372213574), ammAlice.tokens())); + btc(1'060'6848287928033), eth(1'037'0658372213574), ammAlice.tokens())); // Consumed offer ~72.93e13ETH/72.93e13BTC BEAST_EXPECT(expectOffers( - env, carol, 1, {Amounts{ETH(27'0658372213574), BTC(27'0658372213575)}})); - BEAST_EXPECT(expectOffers(env, bob, 0)); + env, carol_, 1, {Amounts{eth(27'0658372213574), btc(27'0658372213575)}})); + BEAST_EXPECT(expectOffers(env, bob_, 0)); BEAST_EXPECT(expectOffers(env, ed, 0)); - env.require(balance(carol, BTC(19'116'439'640'089'955))); - env.require(balance(carol, ETH(20'729'341'627'786'426))); - env.require(balance(bob, BTC(20'100'000'000'000'000))); - env.require(balance(ed, ETH(19'875'000'000'000'000))); + env.require(Balance(carol_, btc(19'116'439'640'089'955))); + env.require(Balance(carol_, eth(20'729'341'627'786'426))); + env.require(Balance(bob_, btc(20'100'000'000'000'000))); + env.require(Balance(ed, eth(19'875'000'000'000'000))); } // Payment and transfer fee @@ -5042,32 +5059,32 @@ private: // 100EUR/1.25 = 80EUR paid to carol { Env env(*this); - env.fund(XRP(30'000), gw, alice, bob, carol); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 30'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .transferFee = 25'000, .pay = 30'000, - .flags = MPTDEXFlags}); - AMM const ammAlice(env, alice, BTC(1'000), ETH(1'100)); - env(rate(gw, 1.25)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, btc(1'000), eth(1'100)); + env(rate(gw_, 1.25)); env.close(); - env(pay(bob, carol, ETH(100)), - path(~MPT(ETH)), - sendmax(BTC(125)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, eth(100)), + Path(~MPT(eth)), + Sendmax(btc(125)), + Txflags(tfPartialPayment)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'100), ETH(1'000), ammAlice.tokens())); - env.require(balance(bob, BTC(29'875))); - env.require(balance(carol, ETH(30'080))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'100), eth(1'000), ammAlice.tokens())); + env.require(Balance(bob_, btc(29'875))); + env.require(Balance(carol_, eth(30'080))); } // Payment and transfer fee, multiple steps @@ -5085,139 +5102,139 @@ private: Env env(*this); Account const dan("dan"); Account const ed("ed"); - env.fund(XRP(30'000), gw, alice, bob, carol, dan, ed); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, bob_, carol_, dan, ed); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .transferFee = 25'000, .pay = 30'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .transferFee = 25'000, .pay = 30'000, - .flags = MPTDEXFlags}); - MPTTester const CAN( + .flags = kMPT_DEX_FLAGS}); + MPTTester const can( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .transferFee = 25'000, .pay = 2'000'000, - .flags = MPTDEXFlags}); - MPTTester const GBP( + .flags = kMPT_DEX_FLAGS}); + MPTTester const gbp( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, dan, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, dan, ed}, .transferFee = 25'000, .pay = 3'000'000, - .flags = MPTDEXFlags}); - AMM const ammAlice(env, alice, GBP(1'000'000), ETH(10'125)); - env(pay(gw, bob, CAN(1'953'125))); + .flags = kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, gbp(1'000'000), eth(10'125)); + env(pay(gw_, bob_, can(1'953'125))); env.close(); - env(offer(dan, CAN(2'000'000), GBP(20'000))); - env(offer(ed, ETH(200), BTC(200))); + env(offer(dan, can(2'000'000), gbp(20'000))); + env(offer(ed, eth(200), btc(200))); env.close(); - env(pay(bob, carol, BTC(100)), - path(~MPT(GBP), ~MPT(ETH), ~MPT(BTC)), - sendmax(CAN(1'953'125)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, btc(100)), + Path(~MPT(gbp), ~MPT(eth), ~MPT(btc)), + Sendmax(can(1'953'125)), + Txflags(tfPartialPayment)); env.close(); - env.require(balance(bob, CAN(2'000'000))); - env.require(balance(dan, CAN(3'562'500))); - env.require(balance(dan, GBP(2'984'375))); + env.require(Balance(bob_, can(2'000'000))); + env.require(Balance(dan, can(3'562'500))); + env.require(Balance(dan, gbp(2'984'375))); - BEAST_EXPECT(ammAlice.expectBalances(GBP(1'012'500), ETH(10'000), ammAlice.tokens())); - env.require(balance(ed, ETH(30'100))); - env.require(balance(ed, BTC(29'900))); - env.require(balance(carol, BTC(30'080))); + BEAST_EXPECT(ammAlice.expectBalances(gbp(1'012'500), eth(10'000), ammAlice.tokens())); + env.require(Balance(ed, eth(30'100))); + env.require(Balance(ed, btc(29'900))); + env.require(Balance(carol_, btc(30'080))); } // Pay amounts close to one side of the pool testAMM( [&](AMM& ammAlice, Env& env) { - auto const& BTC = MPT(ammAlice[1]); - env(pay(alice, carol, BTC(9999)), - path(~BTC), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, BTC(10'000)), - path(~BTC), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, XRP(100)), - path(~XRP), - sendmax(BTC(100)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, STAmount{xrpIssue(), 99'999'900}), - path(~XRP), - sendmax(BTC(100)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); + auto const& btc = MPT(ammAlice[1]); + env(pay(alice_, carol_, btc(9999)), + Path(~btc), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, btc(10'000)), + Path(~btc), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, XRP(100)), + Path(~XRP), + Sendmax(btc(100)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, STAmount{xrpIssue(), 99'999'900}), + Path(~XRP), + Sendmax(btc(100)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); }, - {{XRP(100), AMMMPT(10'000)}}); + {{XRP(100), gAmmmpt(10'000)}}); // Multiple paths/steps { Env env(*this); - env.fund(XRP(100'000), gw, alice); - env.fund(XRP(1'000), bob, carol); - MPTTester const BTC( + env.fund(XRP(100'000), gw_, alice_); + env.fund(XRP(1'000), bob_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 500'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 500'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const USD( + .flags = kMPT_DEX_FLAGS}); + MPTTester const usd( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 500'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const EUR( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eur( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 500'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const xrp_eur(env, alice, XRP(10'100), EUR(100'000'000'000'000'000)); - AMM const eur_btc( - env, alice, EUR(100'000'000'000'000'000), BTC(102'000'000'000'000'000)); - AMM const btc_usd( - env, alice, BTC(101'000'000'000'000'000), USD(100'000'000'000'000'000)); - AMM const xrp_usd(env, alice, XRP(10'150), USD(102'000'000'000'000'000)); - AMM const xrp_eth(env, alice, XRP(10'000), ETH(101'000'000'000'000'000)); - AMM const eth_eur( - env, alice, ETH(109'000'000'000'000'000), EUR(110'000'000'000'000'000)); - AMM const eur_usd( - env, alice, EUR(101'000'000'000'000'000), USD(100'000'000'000'000'000)); - env(pay(bob, carol, USD(1'000'000'000'000'000)), - path(~MPT(EUR), ~MPT(BTC), ~MPT(USD)), - path(~MPT(USD)), - path(~MPT(ETH), ~MPT(EUR), ~MPT(USD)), - sendmax(XRP(200))); + .flags = kMPT_DEX_FLAGS}); + AMM const xrpEur(env, alice_, XRP(10'100), eur(100'000'000'000'000'000)); + AMM const eurBtc( + env, alice_, eur(100'000'000'000'000'000), btc(102'000'000'000'000'000)); + AMM const btcUsd( + env, alice_, btc(101'000'000'000'000'000), usd(100'000'000'000'000'000)); + AMM const xrpUsd(env, alice_, XRP(10'150), usd(102'000'000'000'000'000)); + AMM const xrpEth(env, alice_, XRP(10'000), eth(101'000'000'000'000'000)); + AMM const ethEur( + env, alice_, eth(109'000'000'000'000'000), eur(110'000'000'000'000'000)); + AMM const eurUsd( + env, alice_, eur(101'000'000'000'000'000), usd(100'000'000'000'000'000)); + env(pay(bob_, carol_, usd(1'000'000'000'000'000)), + Path(~MPT(eur), ~MPT(btc), ~MPT(usd)), + Path(~MPT(usd)), + Path(~MPT(eth), ~MPT(eur), ~MPT(usd)), + Sendmax(XRP(200))); - BEAST_EXPECT(xrp_eth.expectBalances( - XRPAmount(10'026'208'900), ETH(10'073'6577924447994), xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - ETH(10'926'3422075552006), EUR(10'973'5423207873690), eth_eur.tokens())); - BEAST_EXPECT(eur_usd.expectBalances( - EUR(10'126'4576792126310), USD(9'973'9315171207179), eur_usd.tokens())); + BEAST_EXPECT(xrpEth.expectBalances( + XRPAmount(10'026'208'900), eth(10'073'6577924447994), xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + eth(10'926'3422075552006), eur(10'973'5423207873690), ethEur.tokens())); + BEAST_EXPECT(eurUsd.expectBalances( + eur(10'126'4576792126310), usd(9'973'9315171207179), eurUsd.tokens())); // XRP-USD path // This path provides ~73.9e12USD/74.1XRP - BEAST_EXPECT(xrp_usd.expectBalances( - XRPAmount(10'224'106'246), USD(10'126'0684828792821), xrp_usd.tokens())); + BEAST_EXPECT(xrpUsd.expectBalances( + XRPAmount(10'224'106'246), usd(10'126'0684828792821), xrpUsd.tokens())); // XRP-EUR-BTC-USD // This path doesn't provide any liquidity due to how @@ -5226,205 +5243,205 @@ private: // XRP-EUR-BTC-USD 11.6e12USD/11.64XRP, // XRP-USD 60.7e12USD/60.8XRP, // XRP-ETH-EUR-USD 27.6e12USD/27.6XRP - BEAST_EXPECT(xrp_eur.expectBalances( - XRP(10'100), EUR(100'000'000'000'000'000), xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances( - EUR(100'000'000'000'000'000), BTC(102'000'000'000'000'000), eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances( - BTC(101'000'000'000'000'000), USD(100'000'000'000'000'000), btc_usd.tokens())); - env.require(balance(carol, USD(501'000'000'000'000'000))); + BEAST_EXPECT( + xrpEur.expectBalances(XRP(10'100), eur(100'000'000'000'000'000), xrpEur.tokens())); + BEAST_EXPECT(eurBtc.expectBalances( + eur(100'000'000'000'000'000), btc(102'000'000'000'000'000), eurBtc.tokens())); + BEAST_EXPECT(btcUsd.expectBalances( + btc(101'000'000'000'000'000), usd(100'000'000'000'000'000), btcUsd.tokens())); + env.require(Balance(carol_, usd(501'000'000'000'000'000))); } // Dependent AMM { Env env(*this); - env.fund(XRP(40'000), gw, alice); - env.fund(XRP(1'000), bob, carol); - MPTTester const BTC( + env.fund(XRP(40'000), gw_, alice_); + env.fund(XRP(1'000), bob_, carol_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 50'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 50'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const USD( + .flags = kMPT_DEX_FLAGS}); + MPTTester const usd( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 50'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const EUR( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eur( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 50'000'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const xrp_eur(env, alice, XRP(10'100), EUR(10'000'000'000'000'000)); - AMM const eur_btc(env, alice, EUR(10'000'000'000'000'000), BTC(10'200'000'000'000'000)); - AMM const btc_usd(env, alice, BTC(10'100'000'000'000'000), USD(10'000'000'000'000'000)); - AMM const xrp_eth(env, alice, XRP(10'000), ETH(10'100'000'000'000'000)); - AMM const eth_eur(env, alice, ETH(10'900'000'000'000'000), EUR(11'000'000'000'000'000)); - env(pay(bob, carol, USD(100'000'000'000'000)), - path(~MPT(EUR), ~MPT(BTC), ~MPT(USD)), - path(~MPT(ETH), ~MPT(EUR), ~MPT(BTC), ~MPT(USD)), - sendmax(XRP(200))); + .flags = kMPT_DEX_FLAGS}); + AMM const xrpEur(env, alice_, XRP(10'100), eur(10'000'000'000'000'000)); + AMM const eurBtc(env, alice_, eur(10'000'000'000'000'000), btc(10'200'000'000'000'000)); + AMM const btcUsd(env, alice_, btc(10'100'000'000'000'000), usd(10'000'000'000'000'000)); + AMM const xrpEth(env, alice_, XRP(10'000), eth(10'100'000'000'000'000)); + AMM const ethEur(env, alice_, eth(10'900'000'000'000'000), eur(11'000'000'000'000'000)); + env(pay(bob_, carol_, usd(100'000'000'000'000)), + Path(~MPT(eur), ~MPT(btc), ~MPT(usd)), + Path(~MPT(eth), ~MPT(eur), ~MPT(btc), ~MPT(usd)), + Sendmax(XRP(200))); - BEAST_EXPECT(xrp_eur.expectBalances( - XRPAmount(10'118'738'472), EUR(9'981'544436337981), xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances( - EUR(10'101'160967851758), BTC(10'097'914269680647), eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances( - BTC(10'202'085730319353), USD(9'900'000'000'000'000), btc_usd.tokens())); - BEAST_EXPECT(xrp_eth.expectBalances( - XRPAmount(10'082'446'397), ETH(10'017'410727780081), xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - ETH(10'982'589272219919), EUR(10'917'294595810261), eth_eur.tokens())); - env.require(balance(carol, USD(50'100'000'000'000'000))); + BEAST_EXPECT(xrpEur.expectBalances( + XRPAmount(10'118'738'472), eur(9'981'544436337981), xrpEur.tokens())); + BEAST_EXPECT(eurBtc.expectBalances( + eur(10'101'160967851758), btc(10'097'914269680647), eurBtc.tokens())); + BEAST_EXPECT(btcUsd.expectBalances( + btc(10'202'085730319353), usd(9'900'000'000'000'000), btcUsd.tokens())); + BEAST_EXPECT(xrpEth.expectBalances( + XRPAmount(10'082'446'397), eth(10'017'410727780081), xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + eth(10'982'589272219919), eur(10'917'294595810261), ethEur.tokens())); + env.require(Balance(carol_, usd(50'100'000'000'000'000))); } // AMM offers limit // Consuming 30 CLOB offers, results in hitting 30 AMM offers limit. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - env.fund(XRP(1'000), bob); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + env.fund(XRP(1'000), bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 400'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000'000'000'000'000)); for (int i = 0; i < 30; ++i) - env(offer(alice, ETH(1'000'000'000'000 + (10'000'000'000 * i)), XRP(1))); + env(offer(alice_, eth(1'000'000'000'000 + (10'000'000'000 * i)), XRP(1))); // This is worse quality offer than 30 offers above. // It will not be consumed because of AMM offers limit. - env(offer(alice, ETH(140'000'000'000'000), XRP(100))); - env(pay(bob, carol, BTC(100'000'000'000'000)), - path(~XRP, ~MPT(BTC)), - sendmax(ETH(400'000'000'000'000)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(offer(alice_, eth(140'000'000'000'000), XRP(100))); + env(pay(bob_, carol_, btc(100'000'000'000'000)), + Path(~XRP, ~MPT(btc)), + Sendmax(eth(400'000'000'000'000)), + Txflags(tfPartialPayment | tfNoRippleDirect)); BEAST_EXPECT( - ammAlice.expectBalances(XRP(10'030), BTC(9'970'089730807592), ammAlice.tokens())); + ammAlice.expectBalances(XRP(10'030), btc(9'970'089730807592), ammAlice.tokens())); - env.require(balance(carol, BTC(30'029'910269192408))); - BEAST_EXPECT(expectOffers(env, alice, 1, {{{ETH(140'000'000'000'000), XRP(100)}}})); + env.require(Balance(carol_, btc(30'029'910269192408))); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{{eth(140'000'000'000'000), XRP(100)}}})); } // This payment is fulfilled { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - env.fund(XRP(1'000), bob); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + env.fund(XRP(1'000), bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); - MPTTester const ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 400'000'000'000'000, - .flags = MPTDEXFlags}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000'000'000'000'000)); + .flags = kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000'000'000'000'000)); for (int i = 0; i < 29; ++i) - env(offer(alice, ETH(1'000'000'000'000 + (10'000'000'000 * i)), XRP(1))); + env(offer(alice_, eth(1'000'000'000'000 + (10'000'000'000 * i)), XRP(1))); // This is worse quality offer than 30 offers above. // It will not be consumed because of AMM offers limit. - env(offer(alice, ETH(140'000'000'000'000), XRP(100))); - env(pay(bob, carol, BTC(100'000'000'000'000)), - path(~XRP, ~MPT(BTC)), - sendmax(ETH(400'000'000'000'000)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(offer(alice_, eth(140'000'000'000'000), XRP(100))); + env(pay(bob_, carol_, btc(100'000'000'000'000)), + Path(~XRP, ~MPT(btc)), + Sendmax(eth(400'000'000'000'000)), + Txflags(tfPartialPayment | tfNoRippleDirect)); BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{10'101'010'102}, BTC(9'900'000'000'000'000), ammAlice.tokens())); + XRPAmount{10'101'010'102}, btc(9'900'000'000'000'000), ammAlice.tokens())); - env.require(balance(carol, BTC(30'100'000'000'000'000))); + env.require(Balance(carol_, btc(30'100'000'000'000'000))); BEAST_EXPECT( - expectOffers(env, alice, 1, {{{ETH(39'185857200000), XRPAmount{27'989'898}}}})); + expectOffers(env, alice_, 1, {{{eth(39'185857200000), XRPAmount{27'989'898}}}})); } // Offer crossing with AMM and another offer. // AMM has a better quality and is consumed first. { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - env.fund(XRP(1'000), bob); - MPTTester const BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + env.fund(XRP(1'000), bob_); + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000'000'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(bob, XRP(100), BTC(100'001'000'000'000))); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'100'000'000'000'000)); - env(offer(carol, BTC(100'000'000'000'000), XRP(100))); + env(offer(bob_, XRP(100), btc(100'001'000'000'000))); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'100'000'000'000'000)); + env(offer(carol_, btc(100'000'000'000'000), XRP(100))); BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{10'049'825'372}, BTC(10'049'925870493027), ammAlice.tokens())); + XRPAmount{10'049'825'372}, btc(10'049'925870493027), ammAlice.tokens())); BEAST_EXPECT( - expectOffers(env, bob, 1, {{{XRPAmount{50'074'628}, BTC(50'075129506973)}}})); + expectOffers(env, bob_, 1, {{{XRPAmount{50'074'628}, btc(50'075129506973)}}})); - env.require(balance(carol, BTC(30'100'000'000'000'000))); + env.require(Balance(carol_, btc(30'100'000'000'000'000))); } // Individually locked MPT destination account { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); - BTC.set({.holder = carol, .flags = tfMPTLock}); + btc.set({.holder = carol_, .flags = tfMPTLock}); - env(pay(alice, carol, XRP(1)), - path(~XRP), - sendmax(BTC(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(tesSUCCESS)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Sendmax(btc(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(tesSUCCESS)); } // Individually locked MPT source account { Env env(*this); - env.fund(XRP(30'000), gw, alice, carol); - MPTTester BTC( + env.fund(XRP(30'000), gw_, alice_, carol_); + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - AMM const ammAlice(env, alice, XRP(10'000), BTC(10'000)); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + AMM const ammAlice(env, alice_, XRP(10'000), btc(10'000)); - BTC.set({.holder = alice, .flags = tfMPTLock}); + btc.set({.holder = alice_, .flags = tfMPTLock}); - env(pay(alice, carol, BTC(1)), - path(~MPT(BTC)), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(tesSUCCESS)); + env(pay(alice_, carol_, btc(1)), + Path(~MPT(btc)), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(tesSUCCESS)); } } @@ -5445,68 +5462,69 @@ private: STAmount{token1, 5'000'000}, 0); // Carol places an order to buy LPTokens - env(offer(carol, STAmount{token1, 5'000'000}, priceXRP)); + env(offer(carol_, STAmount{token1, 5'000'000}, priceXRP)); // Alice places an order to sell LPTokens - env(offer(alice, priceXRP, STAmount{token1, 5'000'000})); + env(offer(alice_, priceXRP, STAmount{token1, 5'000'000})); // Pool's LPTokens balance doesn't change BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), MPT(ammAlice[1])(10'000), IOUAmount{10'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, IOUAmount{5'000'000})); // Carol votes - ammAlice.vote(carol, 1'000); + ammAlice.vote(carol_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(500)); - ammAlice.vote(carol, 0); + ammAlice.vote(carol_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); // Carol bids auto const baseFee = env.current()->fees().base; - auto const carolXRP = env.balance(carol); - env(ammAlice.bid({.account = carol, .bidMin = 100})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{4'999'900})); + auto const carolXRP = env.balance(carol_); + env(ammAlice.bid({.account = carol_, .bidMin = 100})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{4'999'900})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{100})); - BEAST_EXPECT(env.balance(carol) == (carolXRP - baseFee)); + BEAST_EXPECT(env.balance(carol_) == (carolXRP - baseFee)); priceXRP = ammAssetOut( STAmount{XRPAmount{10'000'000'000}}, STAmount{token1, 9'999'900}, STAmount{token1, 4'999'900}, 0); // Carol withdraws - ammAlice.withdrawAll(carol, XRP(0)); - BEAST_EXPECT(env.balance(carol) == (carolXRP - baseFee * 2 + priceXRP)); + ammAlice.withdrawAll(carol_, XRP(0)); + BEAST_EXPECT(env.balance(carol_) == (carolXRP - baseFee * 2 + priceXRP)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'000} - priceXRP, MPT(ammAlice[1])(10'000), IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, - {{XRP(10000), AMMMPT(10000)}}); + {{XRP(10000), gAmmmpt(10000)}}); // Offer crossing with two AMM LPTokens. // token1 comes from MPT/XRP pool. // token2 comes from XRP/IOU pool. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - fund(env, gw, {alice, carol}, {EUR(10'000)}, Fund::TokenOnly); - AMM ammAlice1(env, alice, XRP(10'000), EUR(10'000)); - ammAlice1.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); + fund(env, gw_, {alice_, carol_}, {EUR(10'000)}, Fund::TokenOnly); + AMM ammAlice1(env, alice_, XRP(10'000), EUR(10'000)); + ammAlice1.deposit(carol_, 1'000'000); auto const token1 = ammAlice.lptIssue(); auto const token2 = ammAlice1.lptIssue(); - env(offer(alice, STAmount{token1, 100}, STAmount{token2, 100}), txflags(tfPassive)); + env(offer(alice_, STAmount{token1, 100}, STAmount{token2, 100}), + Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1)); - env(offer(carol, STAmount{token2, 100}, STAmount{token1, 100})); + BEAST_EXPECT(expectOffers(env, alice_, 1)); + env(offer(carol_, STAmount{token2, 100}, STAmount{token1, 100})); env.close(); BEAST_EXPECT( - expectHolding(env, alice, STAmount{token1, 10'000'100}) && - expectHolding(env, alice, STAmount{token2, 9'999'900})); + expectHolding(env, alice_, STAmount{token1, 10'000'100}) && + expectHolding(env, alice_, STAmount{token2, 9'999'900})); BEAST_EXPECT( - expectHolding(env, carol, STAmount{token2, 1'000'100}) && - expectHolding(env, carol, STAmount{token1, 999'900})); - BEAST_EXPECT(expectOffers(env, alice, 0) && expectOffers(env, carol, 0)); + expectHolding(env, carol_, STAmount{token2, 1'000'100}) && + expectHolding(env, carol_, STAmount{token1, 999'900})); + BEAST_EXPECT(expectOffers(env, alice_, 0) && expectOffers(env, carol_, 0)); }, - {{XRP(10000), AMMMPT(10000)}}); + {{XRP(10000), gAmmmpt(10000)}}); // LPs pay LPTokens directly. Must trust set because the trust line // is checked for the limit, which is 0 in the AMM auto-created @@ -5514,32 +5532,32 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { auto const token1 = ammAlice.lptIssue(); - env.trust(STAmount{token1, 2'000'000}, carol); + env.trust(STAmount{token1, 2'000'000}, carol_); env.close(); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT( - ammAlice.expectLPTokens(alice, IOUAmount{10'000'000, 0}) && - ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); + ammAlice.expectLPTokens(alice_, IOUAmount{10'000'000, 0}) && + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); // Pool balance doesn't change, only tokens moved from // one line to another. - env(pay(alice, carol, STAmount{token1, 100})); + env(pay(alice_, carol_, STAmount{token1, 100})); env.close(); BEAST_EXPECT( // Alice initial token1 10,000,000 - 100 - ammAlice.expectLPTokens(alice, IOUAmount{9'999'900, 0}) && + ammAlice.expectLPTokens(alice_, IOUAmount{9'999'900, 0}) && // Carol initial token1 1,000,000 + 100 - ammAlice.expectLPTokens(carol, IOUAmount{1'000'100, 0})); + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'100, 0})); - env.trust(STAmount{token1, 20'000'000}, alice); + env.trust(STAmount{token1, 20'000'000}, alice_); env.close(); - env(pay(carol, alice, STAmount{token1, 100})); + env(pay(carol_, alice_, STAmount{token1, 100})); env.close(); // Back to the original balance BEAST_EXPECT( - ammAlice.expectLPTokens(alice, IOUAmount{10'000'000, 0}) && - ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); + ammAlice.expectLPTokens(alice_, IOUAmount{10'000'000, 0}) && + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); }, - {{XRP(10000), AMMMPT(10000)}}); + {{XRP(10000), gAmmmpt(10000)}}); } void @@ -5547,27 +5565,27 @@ private: { testcase("Amendment"); using namespace jtx; - FeatureBitset const feature{testable_amendments() - featureMPTokensV2}; + FeatureBitset const feature{testableAmendments() - featureMPTokensV2}; Env env{*this, feature}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 10'000, .flags = tfMPTCanClawback | tfMPTCanTransfer}); - AMM amm(env, alice, XRP(1'000), BTC(1'000), ter(temDISABLED)); + AMM amm(env, alice_, XRP(1'000), btc(1'000), Ter(temDISABLED)); - env(amm.bid({.bidMax = 1000}), ter(temMALFORMED)); - env(amm.bid({}), ter(temDISABLED)); - amm.vote(VoteArg{.tfee = 100, .err = ter(temDISABLED)}); - amm.withdraw(WithdrawArg{.tokens = 100, .err = ter(temMALFORMED)}); - amm.withdraw(WithdrawArg{.err = ter(temDISABLED)}); - amm.deposit(DepositArg{.asset1In = USD(100), .err = ter(temDISABLED)}); - amm.ammDelete(alice, ter(temDISABLED)); + env(amm.bid({.bidMax = 1000}), Ter(temMALFORMED)); + env(amm.bid({}), Ter(temDISABLED)); + amm.vote(VoteArg{.tfee = 100, .err = Ter(temDISABLED)}); + amm.withdraw(WithdrawArg{.tokens = 100, .err = Ter(temMALFORMED)}); + amm.withdraw(WithdrawArg{.err = Ter(temDISABLED)}); + amm.deposit(DepositArg{.asset1In = USD(100), .err = Ter(temDISABLED)}); + amm.ammDelete(alice_, Ter(temDISABLED)); } void @@ -5576,27 +5594,27 @@ private: testcase("AMMAndCLOB, offer quality change"); using namespace jtx; auto const gw = Account("gw"); - auto const LP1 = Account("LP1"); - auto const LP2 = Account("LP2"); + auto const lP1 = Account("LP1"); + auto const lP2 = Account("LP2"); auto prep = [&](auto const& offerCb, auto const& expectCb) { Env env(*this, features); env.fund(XRP(30'000'000'000), gw); - env.fund(XRP(10'000), LP1); - env.fund(XRP(10'000), LP2); - MPTTester const TST( - {.env = env, .issuer = gw, .holders = {LP1, LP2}, .flags = MPTDEXFlags}); + env.fund(XRP(10'000), lP1); + env.fund(XRP(10'000), lP2); + MPTTester const tst( + {.env = env, .issuer = gw, .holders = {lP1, lP2}, .flags = kMPT_DEX_FLAGS}); - env(offer(gw, XRP(11'500'000'000), TST(1'000'000'000'000'000))); + env(offer(gw, XRP(11'500'000'000), tst(1'000'000'000'000'000))); - env(offer(LP1, TST(25'000'000), XRPAmount(287'500'000))); + env(offer(lP1, tst(25'000'000), XRPAmount(287'500'000))); // Either AMM or CLOB offer - offerCb(env, TST); + offerCb(env, tst); - env(offer(LP2, TST(25'000'000), XRPAmount(287'500'000))); + env(offer(lP2, tst(25'000'000), XRPAmount(287'500'000))); - expectCb(env, TST); + expectCb(env, tst); }; // If we replace AMM with an equivalent CLOB offer, which AMM generates @@ -5606,21 +5624,21 @@ private: std::string lp2TakerPays; // Execute with AMM first prep( - [&](Env& env, MPTTester TST) { AMM const amm(env, LP1, TST(25'000'000), XRP(250)); }, - [&](Env& env, MPTTester TST) { - lp2TSTBalance = env.balance(LP2, MPT(TST)); - auto const offer = getAccountOffers(env, LP2)["offers"][0u]; + [&](Env& env, MPTTester tst) { AMM const amm(env, lP1, tst(25'000'000), XRP(250)); }, + [&](Env& env, MPTTester tst) { + lp2TSTBalance = env.balance(lP2, MPT(tst)); + auto const offer = getAccountOffers(env, lP2)["offers"][0u]; lp2TakerGets = offer["taker_gets"].asString(); lp2TakerPays = offer["taker_pays"]["value"].asString(); }); // Execute with CLOB offer prep( - [&](Env& env, MPTTester TST) { - env(offer(LP1, XRPAmount{18'095'131}, TST(1'687'379)), txflags(tfPassive)); + [&](Env& env, MPTTester tst) { + env(offer(lP1, XRPAmount{18'095'131}, tst(1'687'379)), Txflags(tfPassive)); }, - [&](Env& env, MPTTester TST) { - BEAST_EXPECT(lp2TSTBalance == env.balance(LP2, MPT(TST))); - auto const offer = getAccountOffers(env, LP2)["offers"][0u]; + [&](Env& env, MPTTester tst) { + BEAST_EXPECT(lp2TSTBalance == env.balance(lP2, MPT(tst))); + auto const offer = getAccountOffers(env, lP2)["offers"][0u]; BEAST_EXPECT(lp2TakerGets == offer["taker_gets"].asString()); BEAST_EXPECT(lp2TakerPays == offer["taker_pays"]["value"].asString()); }); @@ -5636,36 +5654,36 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // No fee - ammAlice.deposit(carol, MPT(ammAlice[1])(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000})); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); - env.require(balance(carol, MPT(ammAlice[1])(30'000))); + ammAlice.deposit(carol_, MPT(ammAlice[1])(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000})); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); + env.require(Balance(carol_, MPT(ammAlice[1])(30'000))); // Set fee to 1% - ammAlice.vote(alice, 1'000); + ammAlice.vote(alice_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); // Carol gets fewer LPToken ~994, because of the single deposit // fee - ammAlice.deposit(carol, MPT(ammAlice[1])(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{994'981155689671, -12})); - env.require(balance(carol, MPT(ammAlice[1])(27'000))); + ammAlice.deposit(carol_, MPT(ammAlice[1])(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{994'981155689671, -12})); + env.require(Balance(carol_, MPT(ammAlice[1])(27'000))); // Set fee to 0 - ammAlice.vote(alice, 0); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.vote(alice_, 0); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); // Carol gets back less than the original deposit if (!features[fixAMMv1_3]) { - env.require(balance(carol, MPT(ammAlice[1])(29'995))); + env.require(Balance(carol_, MPT(ammAlice[1])(29'995))); } else { - env.require(balance(carol, MPT(ammAlice[1])(29'994))); + env.require(Balance(carol_, MPT(ammAlice[1])(29'994))); } }, - {{USD(1000), AMMMPT(1000)}}, + {{USD(1000), gAmmmpt(1000)}}, 0, std::nullopt, {features}); @@ -5675,17 +5693,17 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); - auto const balance = env.balance(carol, MPT(ammAlice[1])); + auto const balance = env.balance(carol_, MPT(ammAlice[1])); auto const tokensFee = ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(1000), std::nullopt, STAmount{ammAlice.lptIssue(), 1, -1}); - auto const deposit = balance - env.balance(carol, MPT(ammAlice[1])); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); - ammAlice.vote(alice, 0); + auto const deposit = balance - env.balance(carol_, MPT(ammAlice[1])); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.deposit(carol, deposit); + auto const tokensNoFee = ammAlice.deposit(carol_, deposit); BEAST_EXPECT(tokensFee == IOUAmount(485636'0611129, -7)); if (!features[fixAMMv1_3]) { @@ -5696,7 +5714,7 @@ private: BEAST_EXPECT(tokensNoFee == IOUAmount(487612'21584827, -8)); } }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 1'000, std::nullopt, {features}); @@ -5706,17 +5724,17 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); - auto const balance = env.balance(carol, MPT(ammAlice[1])); + auto const balance = env.balance(carol_, MPT(ammAlice[1])); auto const tokensFee = ammAlice.deposit( - carol, + carol_, MPT(ammAlice[1])(200), std::nullopt, STAmount{ammAlice.lptIssue(), 2020, -6}); - auto const deposit = balance - env.balance(carol, MPT(ammAlice[1])); - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); - ammAlice.vote(alice, 0); + auto const deposit = balance - env.balance(carol_, MPT(ammAlice[1])); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.deposit(carol, deposit); + auto const tokensNoFee = ammAlice.deposit(carol_, deposit); if (!features[fixAMMv1_3]) { BEAST_EXPECT(tokensFee == IOUAmount(98'019'80198019, -8)); @@ -5728,7 +5746,7 @@ private: BEAST_EXPECT(tokensNoFee == IOUAmount(98000'10293049, -8)); } }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 1'000, std::nullopt, {features}); @@ -5737,24 +5755,24 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // No fee - ammAlice.deposit(carol, MPT(ammAlice[1])(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000})); - env.require(balance(carol, MPT(ammAlice[1])(27'000))); + ammAlice.deposit(carol_, MPT(ammAlice[1])(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000})); + env.require(Balance(carol_, MPT(ammAlice[1])(27'000))); // Set fee to 1% - ammAlice.vote(alice, 1'000); + ammAlice.vote(alice_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); // Single withdrawal. Carol gets ~5USD less than deposited. - ammAlice.withdrawAll(carol, MPT(ammAlice[1])(0)); + ammAlice.withdrawAll(carol_, MPT(ammAlice[1])(0)); if (!features[fixAMMv1_3]) { - env.require(balance(carol, MPT(ammAlice[1])(29'995))); + env.require(Balance(carol_, MPT(ammAlice[1])(29'995))); } else { - env.require(balance(carol, MPT(ammAlice[1])(29'994))); + env.require(Balance(carol_, MPT(ammAlice[1])(29'994))); } }, - {{USD(1000), AMMMPT(1000)}}, + {{USD(1000), gAmmmpt(1000)}}, 0, std::nullopt, {features}); @@ -5762,31 +5780,31 @@ private: // Withdraw with EPrice limit, 1% fee. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); auto const tokensFee = ammAlice.withdraw( - carol, MPT(ammAlice[1])(100), std::nullopt, IOUAmount{520, 0}); - env.require(balance(carol, MPT(ammAlice[1])(30443))); + carol_, MPT(ammAlice[1])(100), std::nullopt, IOUAmount{520, 0}); + env.require(Balance(carol_, MPT(ammAlice[1])(30443))); // Set to original pool size auto const deposit = - env.balance(carol, MPT(ammAlice[1])) - MPT(ammAlice[1])(29'000); - ammAlice.deposit(carol, deposit); + env.balance(carol_, MPT(ammAlice[1])) - MPT(ammAlice[1])(29'000); + ammAlice.deposit(carol_, deposit); // fee 0% - ammAlice.vote(alice, 0); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.withdraw(carol, deposit); + auto const tokensNoFee = ammAlice.withdraw(carol_, deposit); if (!features[fixAMMv1_3]) { - env.require(balance(carol, MPT(ammAlice[1])(30443))); + env.require(Balance(carol_, MPT(ammAlice[1])(30443))); } else { - env.require(balance(carol, MPT(ammAlice[1])(30442))); + env.require(Balance(carol_, MPT(ammAlice[1])(30442))); } BEAST_EXPECT(tokensNoFee == IOUAmount(746'327'46496649, -8)); BEAST_EXPECT(tokensFee == IOUAmount(750'588'23529411, -8)); }, - {{XRP(10'000), AMMMPT(10'000)}}, + {{XRP(10'000), gAmmmpt(10'000)}}, 1'000, std::nullopt, {features}); @@ -5794,83 +5812,86 @@ private: // Payment, 1% fee { Env env{*this, features}; - env.fund(XRP(30'000), gw, alice, bob, carol); + env.fund(XRP(30'000), gw_, alice_, bob_, carol_); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol}, + .issuer = gw_, + .holders = {alice_, bob_, carol_}, .pay = 30'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - auto const USD = gw["USD"]; - env.trust(USD(30'000), alice); - env(pay(gw, alice, USD(30'000))); - env.trust(USD(30'000), bob); - env(pay(gw, bob, USD(1'000))); - env.trust(USD(30'000), carol); - env(pay(gw, carol, USD(30'000))); + auto const usd = gw_["USD"]; + env.trust(usd(30'000), alice_); + env(pay(gw_, alice_, usd(30'000))); + env.trust(usd(30'000), bob_); + env(pay(gw_, bob_, usd(1'000))); + env.trust(usd(30'000), carol_); + env(pay(gw_, carol_, usd(30'000))); env.close(); - AMM amm(env, alice, BTC(1000), USD(1010)); + AMM amm(env, alice_, btc(1000), usd(1010)); - env.require(balance(alice, BTC(29'000))); - env.require(balance(alice, USD(28'990))); - env.require(balance(carol, BTC(30'000))); + env.require(Balance(alice_, btc(29'000))); + env.require(Balance(alice_, usd(28'990))); + env.require(Balance(carol_, btc(30'000))); // Carol pays to Alice with no fee - env(pay(carol, alice, USD(10)), - path(~USD), - sendmax(BTC(10)), - txflags(tfNoRippleDirect)); + env(pay(carol_, alice_, usd(10)), + Path(~usd), + Sendmax(btc(10)), + Txflags(tfNoRippleDirect)); env.close(); // Alice has 10USD more and Carol has 10BTC less - env.require(balance(alice, BTC(29'000))); - env.require(balance(alice, USD(29'000))); - env.require(balance(carol, BTC(29'990))); + env.require(Balance(alice_, btc(29'000))); + env.require(Balance(alice_, usd(29'000))); + env.require(Balance(carol_, btc(29'990))); // Set fee to 1% - amm.vote(alice, 1'000); + amm.vote(alice_, 1'000); BEAST_EXPECT(amm.expectTradingFee(1'000)); // Bob pays to Carol with 1% fee - env(pay(bob, carol, BTC(10)), path(~BTC), sendmax(USD(15)), txflags(tfNoRippleDirect)); + env(pay(bob_, carol_, btc(10)), + Path(~btc), + Sendmax(usd(15)), + Txflags(tfNoRippleDirect)); env.close(); // Bob sends 10.1~USD to pay 10BTC - env.require(balance(bob, STAmount{USD, UINT64_C(989'8989898989899), -13})); + env.require(Balance(bob_, STAmount{usd, UINT64_C(989'8989898989899), -13})); // Carol got 10BTC - env.require(balance(carol, BTC(30'000))); + env.require(Balance(carol_, btc(30'000))); BEAST_EXPECT(amm.expectBalances( - BTC(1'000), STAmount{USD, UINT64_C(1'010'10101010101), -11}, amm.tokens())); + btc(1'000), STAmount{usd, UINT64_C(1'010'10101010101), -11}, amm.tokens())); } // Offer crossing, 0.05% fee MPT/XRP testAMM( [&](AMM& ammAlice, Env& env) { - auto const BTC = MPT(ammAlice[1]); - auto const carolXRP = env.balance(carol); + auto const btc = MPT(ammAlice[1]); + auto const carolXRP = env.balance(carol_); auto const baseFee = env.current()->fees().base; - env(offer(carol, BTC(10), XRP(10))); + env(offer(carol_, btc(10), XRP(10))); env.close(); - env.require(balance(carol, BTC(30'010))); - env.require(balance(carol, carolXRP - baseFee - XRP(10))); + env.require(Balance(carol_, btc(30'010))); + env.require(Balance(carol_, carolXRP - baseFee - XRP(10))); // Change pool composition back - env(offer(carol, XRP(10), BTC(10))); + env(offer(carol_, XRP(10), btc(10))); env.close(); - env.require(balance(carol, BTC(30'000))); - env.require(balance(carol, carolXRP - baseFee * 2)); + env.require(Balance(carol_, btc(30'000))); + env.require(Balance(carol_, carolXRP - baseFee * 2)); // set fee to 0.05% - ammAlice.vote(alice, 50); + ammAlice.vote(alice_, 50); BEAST_EXPECT(ammAlice.expectTradingFee(50)); - env(offer(carol, BTC(10), XRP(10))); + env(offer(carol_, btc(10), XRP(10))); env.close(); - env.require(balance(carol, BTC(30'009))); - env.require(balance(carol, carolXRP - baseFee * 3 - XRPAmount(8'995'507))); - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{BTC(1), XRP(1)}}})); + env.require(Balance(carol_, btc(30'009))); + env.require(Balance(carol_, carolXRP - baseFee * 3 - XRPAmount(8'995'507))); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{btc(1), XRP(1)}}})); }, - {{XRP(1000), AMMMPT(1010)}}, + {{XRP(1000), gAmmmpt(1010)}}, 0, std::nullopt, {features}); @@ -5878,32 +5899,32 @@ private: // Offer crossing, 0.5% fee MPT/IOU testAMM( [&](AMM& ammAlice, Env& env) { - auto const BTC = MPT(ammAlice[1]); - env(offer(carol, BTC(10'000'000), USD(10))); + auto const btc = MPT(ammAlice[1]); + env(offer(carol_, btc(10'000'000), USD(10))); env.close(); - env.require(balance(carol, BTC(1'020'001'000))); - env.require(balance(carol, USD(29'990))); + env.require(Balance(carol_, btc(1'020'001'000))); + env.require(Balance(carol_, USD(29'990))); // Change pool composition back - env(offer(carol, USD(10), BTC(10'000'000))); + env(offer(carol_, USD(10), btc(10'000'000))); env.close(); - env.require(balance(carol, BTC(1'010'001'000))); - env.require(balance(carol, USD(30'000))); + env.require(Balance(carol_, btc(1'010'001'000))); + env.require(Balance(carol_, USD(30'000))); // set fee to 0.5% - ammAlice.vote(alice, 500); + ammAlice.vote(alice_, 500); BEAST_EXPECT(ammAlice.expectTradingFee(500)); - env(offer(carol, BTC(10'000'000), USD(10))); + env(offer(carol_, btc(10'000'000), USD(10))); env.close(); - env.require(balance(carol, BTC(1'014'975'874))); - env.require(balance(carol, STAmount{USD, UINT64_C(29'995'02512600184), -11})); + env.require(Balance(carol_, btc(1'014'975'874))); + env.require(Balance(carol_, STAmount{USD, UINT64_C(29'995'02512600184), -11})); BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, - {{Amounts{BTC(5'025126), STAmount{USD, UINT64_C(5'025126), -6}}}})); + {{Amounts{btc(5'025126), STAmount{USD, UINT64_C(5'025126), -6}}}})); }, - {{USD(1000), AMMMPT(1010000000)}}, + {{USD(1000), gAmmmpt(1010000000)}}, 0, std::nullopt, {features}); @@ -5915,28 +5936,28 @@ private: { Env env{*this, features}; Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(30'000), {USD(2'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(30'000), {USD(2'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .pay = 30'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(carol, BTC(5'000000), USD(5))); - AMM const ammAlice(env, alice, USD(1'005), BTC(1'000'000000)); - env(pay(bob, ed, USD(10)), - path(~USD), - sendmax(BTC(15'000000)), - txflags(tfNoRippleDirect)); + env(offer(carol_, btc(5'000000), USD(5))); + AMM const ammAlice(env, alice_, USD(1'005), btc(1'000'000000)); + env(pay(bob_, ed, USD(10)), + Path(~USD), + Sendmax(btc(15'000000)), + Txflags(tfNoRippleDirect)); - env.require(balance(ed, USD(2'010))); - env.require(balance(bob, BTC(29'989'999999))); + env.require(Balance(ed, USD(2'010))); + env.require(Balance(bob_, btc(29'989'999999))); BEAST_EXPECT(ammAlice.expectBalances( - BTC(1'005'000001), + btc(1'005'000001), STAmount{USD, UINT64_C(999'9999999999999), -13}, ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. Same as above but with 0.25% @@ -5944,25 +5965,25 @@ private: { Env env{*this, features}; Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(30'000), {USD(2'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(30'000), {USD(2'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .pay = 30'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(carol, BTC(5'000000), USD(5))); + env(offer(carol_, btc(5'000000), USD(5))); // Set 0.25% fee - AMM const ammAlice(env, alice, USD(1'005), BTC(1'000'000000), false, 250); - env(pay(bob, ed, USD(10)), - path(~USD), - sendmax(BTC(15'000000)), - txflags(tfNoRippleDirect)); - env.require(balance(ed, USD(2'010))); - env.require(balance(bob, BTC(29'989'987453))); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'005'012547), USD(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + AMM const ammAlice(env, alice_, USD(1'005), btc(1'000'000000), false, 250); + env(pay(bob_, ed, USD(10)), + Path(~USD), + Sendmax(btc(15'000000)), + Txflags(tfNoRippleDirect)); + env.require(Balance(ed, USD(2'010))); + env.require(Balance(bob_, btc(29'989'987453))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'005'012547), USD(1'000), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. AMM has a better @@ -5971,25 +5992,25 @@ private: { Env env{*this, features}; Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(30'000), {USD(2'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(30'000), {USD(2'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .pay = 30'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(carol, BTC(10'000000), USD(10))); + env(offer(carol_, btc(10'000000), USD(10))); // Set 1% fee - AMM const ammAlice(env, alice, USD(1'005), BTC(1'000'000000), false, 1'000); - env(pay(bob, ed, USD(10)), - path(~USD), - sendmax(BTC(15'000000)), - txflags(tfNoRippleDirect)); - env.require(balance(ed, USD(2'010))); - env.require(balance(bob, BTC(29'990'000000))); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'000'000000), USD(1'005), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + AMM const ammAlice(env, alice_, USD(1'005), btc(1'000'000000), false, 1'000); + env(pay(bob_, ed, USD(10)), + Path(~USD), + Sendmax(btc(15'000000)), + Txflags(tfNoRippleDirect)); + env.require(Balance(ed, USD(2'010))); + env.require(Balance(bob_, btc(29'990'000000))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'000'000000), USD(1'005), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. AMM has a better @@ -5999,25 +6020,25 @@ private: { Env env{*this, features}; Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(30'000), {USD(2'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(30'000), {USD(2'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .pay = 30'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(carol, BTC(9'000000), USD(9))); + env(offer(carol_, btc(9'000000), USD(9))); // Set 1% fee - AMM const ammAlice(env, alice, USD(1'005), BTC(1'000'000000), false, 1'000); - env(pay(bob, ed, USD(10)), - path(~USD), - sendmax(BTC(15'000000)), - txflags(tfNoRippleDirect)); - env.require(balance(ed, USD(2'010))); - env.require(balance(bob, BTC(29'989'993923))); - BEAST_EXPECT(ammAlice.expectBalances(BTC(1'001'006077), USD(1'004), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + AMM const ammAlice(env, alice_, USD(1'005), btc(1'000'000000), false, 1'000); + env(pay(bob_, ed, USD(10)), + Path(~USD), + Sendmax(btc(15'000000)), + Txflags(tfNoRippleDirect)); + env.require(Balance(ed, USD(2'010))); + env.require(Balance(bob_, btc(29'989'993923))); + BEAST_EXPECT(ammAlice.expectBalances(btc(1'001'006077), USD(1'004), ammAlice.tokens())); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } @@ -6046,76 +6067,76 @@ private: env.fund(XRP(100000), gw, alice, bob, carol, ed, paul, dan, chris, simon, ben, natalie); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = holders, .pay = 40'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; for (auto const& holder : holders) { - env.trust(USD(1'500'000), holder); - env(pay(gw, holder, USD(1'500'000))); + env.trust(usd(1'500'000), holder); + env(pay(gw, holder, usd(1'500'000))); } env.close(); - auto aliceUSD = env.balance(alice, USD); - auto bobUSD = env.balance(bob, USD); - auto carolUSD = env.balance(carol, USD); - auto edUSD = env.balance(ed, USD); - auto paulUSD = env.balance(paul, USD); - auto danUSD = env.balance(dan, USD); - auto chrisUSD = env.balance(chris, USD); - auto simonUSD = env.balance(simon, USD); - auto benUSD = env.balance(ben, USD); - auto natalieUSD = env.balance(natalie, USD); + auto aliceUSD = env.balance(alice, usd); + auto bobUSD = env.balance(bob, usd); + auto carolUSD = env.balance(carol, usd); + auto edUSD = env.balance(ed, usd); + auto paulUSD = env.balance(paul, usd); + auto danUSD = env.balance(dan, usd); + auto chrisUSD = env.balance(chris, usd); + auto simonUSD = env.balance(simon, usd); + auto benUSD = env.balance(ben, usd); + auto natalieUSD = env.balance(natalie, usd); - AMM ammAlice(env, alice, BTC(10'000'000000), USD(10000)); + AMM ammAlice(env, alice, btc(10'000'000000), usd(10000)); BEAST_EXPECT( - ammAlice.expectBalances(BTC(10'000'000000), USD(10'000), IOUAmount{10'000'000})); + ammAlice.expectBalances(btc(10'000'000000), usd(10'000), IOUAmount{10'000'000})); for (int i = 0; i < 10; ++i) { - ammAlice.deposit(ben, STAmount{USD, 1, -10}); - ammAlice.withdrawAll(ben, USD(0)); - ammAlice.deposit(simon, USD(0.1)); - ammAlice.withdrawAll(simon, USD(0)); - ammAlice.deposit(chris, USD(1)); - ammAlice.withdrawAll(chris, USD(0)); - ammAlice.deposit(dan, USD(10)); - ammAlice.withdrawAll(dan, USD(0)); - ammAlice.deposit(bob, USD(100)); - ammAlice.withdrawAll(bob, USD(0)); - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, USD(0)); - ammAlice.deposit(ed, USD(10'000)); - ammAlice.withdrawAll(ed, USD(0)); - ammAlice.deposit(paul, USD(100'000)); - ammAlice.withdrawAll(paul, USD(0)); - ammAlice.deposit(natalie, USD(1'000'000)); - ammAlice.withdrawAll(natalie, USD(0)); + ammAlice.deposit(ben, STAmount{usd, 1, -10}); + ammAlice.withdrawAll(ben, usd(0)); + ammAlice.deposit(simon, usd(0.1)); + ammAlice.withdrawAll(simon, usd(0)); + ammAlice.deposit(chris, usd(1)); + ammAlice.withdrawAll(chris, usd(0)); + ammAlice.deposit(dan, usd(10)); + ammAlice.withdrawAll(dan, usd(0)); + ammAlice.deposit(bob, usd(100)); + ammAlice.withdrawAll(bob, usd(0)); + ammAlice.deposit(carol, usd(1'000)); + ammAlice.withdrawAll(carol, usd(0)); + ammAlice.deposit(ed, usd(10'000)); + ammAlice.withdrawAll(ed, usd(0)); + ammAlice.deposit(paul, usd(100'000)); + ammAlice.withdrawAll(paul, usd(0)); + ammAlice.deposit(natalie, usd(1'000'000)); + ammAlice.withdrawAll(natalie, usd(0)); } BEAST_EXPECT(ammAlice.expectBalances( - BTC(10'000'000000), - STAmount{USD, UINT64_C(10000'0000000001), -10}, + btc(10'000'000000), + STAmount{usd, UINT64_C(10000'0000000001), -10}, IOUAmount{10'000'000})); - env.require(balance(bob, bobUSD)); - env.require(balance(carol, carolUSD)); - env.require(balance(ed, edUSD)); - env.require(balance(paul, paulUSD)); - env.require(balance(dan, danUSD)); - env.require(balance(chris, chrisUSD)); - env.require(balance(simon, simonUSD)); - env.require(balance(ben, benUSD)); - env.require(balance(natalie, natalieUSD)); + env.require(Balance(bob, bobUSD)); + env.require(Balance(carol, carolUSD)); + env.require(Balance(ed, edUSD)); + env.require(Balance(paul, paulUSD)); + env.require(Balance(dan, danUSD)); + env.require(Balance(chris, chrisUSD)); + env.require(Balance(simon, simonUSD)); + env.require(Balance(ben, benUSD)); + env.require(Balance(natalie, natalieUSD)); ammAlice.withdrawAll(alice); BEAST_EXPECT(!ammAlice.ammExists()); - env.require(balance(alice, aliceUSD)); + env.require(Balance(alice, aliceUSD)); } // Same as above but deposit/withdraw MPT from USD/MPT pool @@ -6137,74 +6158,74 @@ private: env.fund(XRP(100000), gw, alice, bob, carol, ed, paul, dan, chris, simon, ben, natalie); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = holders, .pay = 40'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; for (auto const& holder : holders) { - env.trust(USD(1'500'000), holder); - env(pay(gw, holder, USD(1'500'000))); + env.trust(usd(1'500'000), holder); + env(pay(gw, holder, usd(1'500'000))); } env.close(); - auto aliceBTC = env.balance(alice, BTC); - auto bobBTC = env.balance(bob, BTC); - auto carolBTC = env.balance(carol, BTC); - auto edBTC = env.balance(ed, BTC); - auto paulBTC = env.balance(paul, BTC); - auto danBTC = env.balance(dan, BTC); - auto chrisBTC = env.balance(chris, BTC); - auto simonBTC = env.balance(simon, BTC); - auto benBTC = env.balance(ben, BTC); - auto natalieBTC = env.balance(natalie, BTC); + auto aliceBTC = env.balance(alice, btc); + auto bobBTC = env.balance(bob, btc); + auto carolBTC = env.balance(carol, btc); + auto edBTC = env.balance(ed, btc); + auto paulBTC = env.balance(paul, btc); + auto danBTC = env.balance(dan, btc); + auto chrisBTC = env.balance(chris, btc); + auto simonBTC = env.balance(simon, btc); + auto benBTC = env.balance(ben, btc); + auto natalieBTC = env.balance(natalie, btc); - AMM ammAlice(env, alice, BTC(10'000'000000), USD(10000)); + AMM ammAlice(env, alice, btc(10'000'000000), usd(10000)); BEAST_EXPECT( - ammAlice.expectBalances(BTC(10'000'000000), USD(10'000), IOUAmount{10'000'000})); + ammAlice.expectBalances(btc(10'000'000000), usd(10'000), IOUAmount{10'000'000})); for (int i = 0; i < 10; ++i) { - ammAlice.deposit(ben, BTC(1)); - ammAlice.withdrawAll(ben, BTC(0)); - ammAlice.deposit(simon, BTC(1'000)); - ammAlice.withdrawAll(simon, BTC(0)); - ammAlice.deposit(chris, BTC(1)); - ammAlice.withdrawAll(chris, BTC(0)); - ammAlice.deposit(dan, BTC(10)); - ammAlice.withdrawAll(dan, BTC(0)); - ammAlice.deposit(bob, BTC(100)); - ammAlice.withdrawAll(bob, BTC(0)); - ammAlice.deposit(carol, BTC(1'000)); - ammAlice.withdrawAll(carol, BTC(0)); - ammAlice.deposit(ed, BTC(10'000)); - ammAlice.withdrawAll(ed, BTC(0)); - ammAlice.deposit(paul, BTC(100'000)); - ammAlice.withdrawAll(paul, BTC(0)); - ammAlice.deposit(natalie, BTC(1'000'000)); - ammAlice.withdrawAll(natalie, BTC(0)); + ammAlice.deposit(ben, btc(1)); + ammAlice.withdrawAll(ben, btc(0)); + ammAlice.deposit(simon, btc(1'000)); + ammAlice.withdrawAll(simon, btc(0)); + ammAlice.deposit(chris, btc(1)); + ammAlice.withdrawAll(chris, btc(0)); + ammAlice.deposit(dan, btc(10)); + ammAlice.withdrawAll(dan, btc(0)); + ammAlice.deposit(bob, btc(100)); + ammAlice.withdrawAll(bob, btc(0)); + ammAlice.deposit(carol, btc(1'000)); + ammAlice.withdrawAll(carol, btc(0)); + ammAlice.deposit(ed, btc(10'000)); + ammAlice.withdrawAll(ed, btc(0)); + ammAlice.deposit(paul, btc(100'000)); + ammAlice.withdrawAll(paul, btc(0)); + ammAlice.deposit(natalie, btc(1'000'000)); + ammAlice.withdrawAll(natalie, btc(0)); } BEAST_EXPECT( - ammAlice.expectBalances(BTC(10'000'000090), USD(10'000), IOUAmount{10'000'000})); + ammAlice.expectBalances(btc(10'000'000090), usd(10'000), IOUAmount{10'000'000})); - env.require(balance(bob, bobBTC - BTC(10))); - env.require(balance(carol, carolBTC - BTC(10))); - env.require(balance(ed, edBTC - BTC(10))); - env.require(balance(paul, paulBTC - BTC(10))); - env.require(balance(dan, danBTC - BTC(10))); - env.require(balance(chris, chrisBTC - BTC(10))); - env.require(balance(simon, simonBTC - BTC(10))); - env.require(balance(ben, benBTC - BTC(10))); - env.require(balance(natalie, natalieBTC - BTC(10))); + env.require(Balance(bob, bobBTC - btc(10))); + env.require(Balance(carol, carolBTC - btc(10))); + env.require(Balance(ed, edBTC - btc(10))); + env.require(Balance(paul, paulBTC - btc(10))); + env.require(Balance(dan, danBTC - btc(10))); + env.require(Balance(chris, chrisBTC - btc(10))); + env.require(Balance(simon, simonBTC - btc(10))); + env.require(Balance(ben, benBTC - btc(10))); + env.require(Balance(natalie, natalieBTC - btc(10))); ammAlice.withdrawAll(alice); BEAST_EXPECT(!ammAlice.ammExists()); - env.require(balance(alice, aliceBTC + BTC(90))); + env.require(Balance(alice, aliceBTC + btc(90))); } } @@ -6233,9 +6254,9 @@ private: fail(); } - amm.deposit(carol, 1'000); + amm.deposit(carol_, 1'000); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; try { bool found = false; @@ -6260,7 +6281,7 @@ private: fail(); } }, - {{XRP(1000), AMMMPT(1000'000)}}); + {{XRP(1000), gAmmmpt(1000'000)}}); } void @@ -6283,41 +6304,41 @@ private: }; auto prep = [&](Env& env, uint16_t gwTransferFee, uint16_t gw1TransferFee) -> MPTList { - env.fund(XRP(2'000), gw, gw1, alice, bob, carol, ed); - MPTTester USD( + env.fund(XRP(2'000), gw_, gw1, alice_, bob_, carol_, ed); + MPTTester usd( {.env = env, - .issuer = gw, - .holders = {alice, bob, carol, ed}, + .issuer = gw_, + .holders = {alice_, bob_, carol_, ed}, .transferFee = gwTransferFee, .pay = 2'000'000'000, - .flags = MPTDEXFlags}); - MPTTester ETH( + .flags = kMPT_DEX_FLAGS}); + MPTTester eth( {.env = env, .issuer = gw1, - .holders = {alice, bob, carol, ed}, + .holders = {alice_, bob_, carol_, ed}, .transferFee = gw1TransferFee, .pay = 2'000'000'000, - .flags = MPTDEXFlags}); - MPTTester CAN( + .flags = kMPT_DEX_FLAGS}); + MPTTester can( {.env = env, .issuer = gw1, - .holders = {alice, bob, carol, ed}, + .holders = {alice_, bob_, carol_, ed}, .transferFee = gw1TransferFee, .pay = 2'000'000'000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); env.close(); return MPTList{ - .USD = std::move(USD), - .ETH = std::move(ETH), - .CAN = std::move(CAN), + .USD = std::move(usd), + .ETH = std::move(eth), + .CAN = std::move(can), }; }; - std::uint32_t constexpr lowRate = 10'000; - std::uint32_t constexpr highRate = 50'000; + std::uint32_t constexpr kLOW_RATE = 10'000; + std::uint32_t constexpr kHIGH_RATE = 50'000; for (auto const& rates : - {std::make_pair(lowRate, highRate), std::make_pair(highRate, lowRate)}) + {std::make_pair(kLOW_RATE, kHIGH_RATE), std::make_pair(kHIGH_RATE, kLOW_RATE)}) { // Offer Selection @@ -6335,21 +6356,21 @@ private: { Env env(*this, features); auto mpts = prep(env, rates.first, rates.second); - auto USD = mpts.USD; - auto ETH = mpts.ETH; - auto CAN = mpts.CAN; + auto usd = mpts.USD; + auto eth = mpts.ETH; + auto can = mpts.CAN; std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400'000'000), USD(400'000'000)), txflags(tfPassive)); + env(offer(ed, eth(400'000'000), usd(400'000'000)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000'000'000), ETH(1'000'000'000)); - env(pay(carol, bob, USD(100'000'000)), - path(~MPT(USD)), - sendmax(ETH(500'000'000))); + amm.emplace(env, ed, usd(1'000'000'000), eth(1'000'000'000)); + env(pay(carol_, bob_, usd(100'000'000)), + Path(~MPT(usd)), + Sendmax(eth(500'000'000))); env.close(); // CLOB and AMM, AMM is not selected if (i == 2) @@ -6357,14 +6378,14 @@ private: // NOLINTBEGIN(bugprone-unchecked-optional-access) i==2 implies amm is // emplaced (i>0) BEAST_EXPECT(amm->expectBalances( - USD(1'000'000'000), ETH(1'000'000'000), amm->tokens())); + usd(1'000'000'000), eth(1'000'000'000), amm->tokens())); // NOLINTEND(bugprone-unchecked-optional-access) } - env.require(balance(bob, USD(2'100'000'000))); + env.require(Balance(bob_, usd(2'100'000'000))); q[i] = Quality( Amounts{ - ETH(2'000'000'000) - env.balance(carol, MPT(ETH)), - env.balance(bob, MPT(USD)) - USD(2'000'000'000)}); + eth(2'000'000'000) - env.balance(carol_, MPT(eth)), + env.balance(bob_, MPT(usd)) - usd(2'000'000'000)}); } // CLOB is better quality than AMM BEAST_EXPECT(q[0] > q[1]); @@ -6380,37 +6401,37 @@ private: { Env env(*this, features); auto mpts = prep(env, rates.first, rates.second); - auto USD = mpts.USD; - auto ETH = mpts.ETH; - auto CAN = mpts.CAN; + auto usd = mpts.USD; + auto eth = mpts.ETH; + auto can = mpts.CAN; std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400'000'000), USD(400'000'000)), txflags(tfPassive)); + env(offer(ed, eth(400'000'000), usd(400'000'000)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000'000'000), ETH(1'000'000'000)); - env(offer(alice, USD(400'000'000), ETH(400'000'000))); + amm.emplace(env, ed, usd(1'000'000'000), eth(1'000'000'000)); + env(offer(alice_, usd(400'000'000), eth(400'000'000))); env.close(); // AMM is not selected if (i > 0) { // NOLINTBEGIN(bugprone-unchecked-optional-access) emplaced when i > 0 BEAST_EXPECT( - amm->expectBalances(USD(1'000'000'000), ETH(1'000'000'000), amm->tokens())); + amm->expectBalances(usd(1'000'000'000), eth(1'000'000'000), amm->tokens())); // NOLINTEND(bugprone-unchecked-optional-access) } if (i == 0 || i == 2) { // Fully crosses - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } // Fails to cross because AMM is not selected else { - BEAST_EXPECT( - expectOffers(env, alice, 1, {Amounts{USD(400'000'000), ETH(400'000'000)}})); + BEAST_EXPECT(expectOffers( + env, alice_, 1, {Amounts{usd(400'000'000), eth(400'000'000)}})); } BEAST_EXPECT(expectOffers(env, ed, 0)); } @@ -6425,41 +6446,41 @@ private: { Env env(*this, features); auto mpts = prep(env, rates.first, rates.second); - auto USD = mpts.USD; - auto ETH = mpts.ETH; - auto CAN = mpts.CAN; + auto usd = mpts.USD; + auto eth = mpts.ETH; + auto can = mpts.CAN; std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400'000'000), USD(330'000'000)), txflags(tfPassive)); + env(offer(ed, eth(400'000'000), usd(330'000'000)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000'000'000), ETH(1'000'000'000)); - env(pay(carol, bob, USD(100'000'000)), - path(~MPT(USD)), - sendmax(ETH(500'000'000))); + amm.emplace(env, ed, usd(1'000'000'000), eth(1'000'000'000)); + env(pay(carol_, bob_, usd(100'000'000)), + Path(~MPT(usd)), + Sendmax(eth(500'000'000))); env.close(); // AMM and CLOB are selected if (i > 0) { // NOLINTBEGIN(bugprone-unchecked-optional-access) emplaced when i > 0 BEAST_EXPECT(!amm->expectBalances( - USD(1'000'000'000), ETH(1'000'000'000), amm->tokens())); + usd(1'000'000'000), eth(1'000'000'000), amm->tokens())); // NOLINTEND(bugprone-unchecked-optional-access) } if (i == 2) { - if (rates.first == lowRate) + if (rates.first == kLOW_RATE) { BEAST_EXPECT(expectOffers( env, ed, 1, {{Amounts{ - ETH(377'824'111), - USD(311'704'892), + eth(377'824'111), + usd(311'704'892), }}})); } else @@ -6469,16 +6490,16 @@ private: ed, 1, {{Amounts{ - ETH(329'339'263), - USD(271'704'892), + eth(329'339'263), + usd(271'704'892), }}})); } } - env.require(balance(bob, USD(2'100'000'000))); + env.require(Balance(bob_, usd(2'100'000'000))); q[i] = Quality( Amounts{ - ETH(2'000'000'000) - env.balance(carol, MPT(ETH)), - env.balance(bob, MPT(USD)) - USD(2'000'000'000)}); + eth(2'000'000'000) - env.balance(carol_, MPT(eth)), + env.balance(bob_, MPT(usd)) - usd(2'000'000'000)}); } // AMM is better quality BEAST_EXPECT(q[1] > q[0]); @@ -6491,32 +6512,32 @@ private: { Env env(*this, features); auto mpts = prep(env, rates.first, rates.second); - auto USD = mpts.USD; - auto ETH = mpts.ETH; - auto CAN = mpts.CAN; + auto usd = mpts.USD; + auto eth = mpts.ETH; + auto can = mpts.CAN; std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400'000'000), USD(325'000'002)), txflags(tfPassive)); + env(offer(ed, eth(400'000'000), usd(325'000'002)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000'000'000), ETH(1'000'000'000)); - env(offer(alice, USD(325'000'000), ETH(400'000'000))); + amm.emplace(env, ed, usd(1'000'000'000), eth(1'000'000'000)); + env(offer(alice_, usd(325'000'000), eth(400'000'000))); env.close(); // AMM is selected in both cases if (i > 0) { // NOLINTBEGIN(bugprone-unchecked-optional-access) emplaced when i > 0 BEAST_EXPECT(!amm->expectBalances( - USD(1'000'000'000), ETH(1'000'000'000), amm->tokens())); + usd(1'000'000'000), eth(1'000'000'000), amm->tokens())); // NOLINTEND(bugprone-unchecked-optional-access) } // Partially crosses, AMM is selected, CLOB fails // limitQuality if (i == 2) { - if (rates.first == lowRate) + if (rates.first == kLOW_RATE) { // Ed offer is partially crossed. // The updated rounding makes limitQuality @@ -6526,10 +6547,10 @@ private: ed, 1, {{Amounts{ - ETH(121'368'836), - USD(98'612'180), + eth(121'368'836), + usd(98'612'180), }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } else { @@ -6539,10 +6560,10 @@ private: ed, 1, {{Amounts{ - ETH(121'368'836), - USD(98'612'180), + eth(121'368'836), + usd(98'612'180), }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } } } @@ -6569,61 +6590,61 @@ private: { Env env(*this, features); auto mpts = prep(env, rates.first, rates.second); - auto USD = mpts.USD; - auto ETH = mpts.ETH; - auto CAN = mpts.CAN; + auto usd = mpts.USD; + auto eth = mpts.ETH; + auto can = mpts.CAN; std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400'000'000), CAN(375'000'000)), txflags(tfPassive)); - env(offer(ed, CAN(375'000'000), USD(338'000'000))), txflags(tfPassive); + env(offer(ed, eth(400'000'000), can(375'000'000)), Txflags(tfPassive)); + env(offer(ed, can(375'000'000), usd(338'000'000))), Txflags(tfPassive); } if (i > 0) - amm.emplace(env, ed, ETH(1'000'000'000), USD(1'000'000'000)); + amm.emplace(env, ed, eth(1'000'000'000), usd(1'000'000'000)); - env(pay(carol, bob, USD(100'000'000)), - path(~MPT(USD)), - path(~MPT(CAN), ~MPT(USD)), - sendmax(ETH(600'000'000))); + env(pay(carol_, bob_, usd(100'000'000)), + Path(~MPT(usd)), + Path(~MPT(can), ~MPT(usd)), + Sendmax(eth(600'000'000))); env.close(); - env.require(balance(bob, USD(2'100'000'000))); + env.require(Balance(bob_, usd(2'100'000'000))); if (i == 2) { // NOLINTBEGIN(bugprone-unchecked-optional-access) i==2 implies amm is // emplaced (i>0) - if (rates.first == lowRate) + if (rates.first == kLOW_RATE) { // Liquidity is consumed from AMM strand only BEAST_EXPECT(amm->expectBalances( - ETH(1'124'584'936), USD(889'999'993), amm->tokens())); + eth(1'124'584'936), usd(889'999'993), amm->tokens())); } else { BEAST_EXPECT(amm->expectBalances( - ETH(1'103'723'909), USD(906'023'688), amm->tokens())); + eth(1'103'723'909), usd(906'023'688), amm->tokens())); BEAST_EXPECT(expectOffers( env, ed, 2, {{Amounts{ - ETH(327'069'745), - CAN(306'627'886), + eth(327'069'745), + can(306'627'886), }, Amounts{ - CAN(312'843'533), - USD(281'976'305), + can(312'843'533), + usd(281'976'305), }}})); } // NOLINTEND(bugprone-unchecked-optional-access) } q[i] = Quality( Amounts{ - ETH(2'000'000'000) - env.balance(carol, MPT(ETH)), - env.balance(bob, MPT(USD)) - USD(2'000'000'000)}); + eth(2'000'000'000) - env.balance(carol_, MPT(eth)), + env.balance(bob_, MPT(usd)) - usd(2'000'000'000)}); } BEAST_EXPECT(q[1] > q[0]); BEAST_EXPECT(q[2] > q[0] && q[2] < q[1]); @@ -6641,78 +6662,78 @@ private: [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfSingleAsset, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfOneAssetLPToken, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfLimitLPToken, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .asset1Out = MPT(ammAlice[1])(100), .asset2Out = MPT(ammAlice[1])(100), - .err = ter(temBAD_AMM_TOKENS), + .err = Ter(temBAD_AMM_TOKENS), }; ammAlice.withdraw(args); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 2'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); WithdrawArg const args{ .asset1Out = XRP(100), - .asset2Out = BTC(100), - .err = ter(temBAD_AMM_TOKENS), + .asset2Out = btc(100), + .err = Ter(temBAD_AMM_TOKENS), }; ammAlice.withdraw(args); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); testAMM( [&](AMM& ammAlice, Env& env) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::AMMWithdraw; jv[jss::Flags] = tfLimitLPToken; - jv[jss::Account] = alice.human(); + jv[jss::Account] = alice_.human(); ammAlice.setTokens(jv); XRP(100).value().setJson(jv[jss::Amount]); - MPTTester const BTC( + MPTTester const btc( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 2'000, - .flags = tfMPTCanLock | MPTDEXFlags}); - BTC(100).value().setJson(jv[jss::EPrice]); - env(jv, ter(telENV_RPC_FAILED)); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + btc(100).value().setJson(jv[jss::EPrice]); + env(jv, Ter(telENV_RPC_FAILED)); }, - {{XRP(10'000), AMMMPT(10'000)}}); + {{XRP(10'000), gAmmmpt(10'000)}}); } void @@ -6727,33 +6748,33 @@ private: { Env env(*this, features); - fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, carol_}, XRP(1'000'000), {USD(1'000'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 40'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(alice, BTC(1), USD(0.01))); + env(offer(alice_, btc(1), USD(0.01))); env.close(); - AMM const amm(env, gw, BTC(200'000), USD(100'000)); - env(offer(carol, USD(0.49), BTC(1))); + AMM const amm(env, gw_, btc(200'000), USD(100'000)); + env(offer(carol_, USD(0.49), btc(1))); env.close(); if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { - BEAST_EXPECT(amm.expectBalances(BTC(200'000), USD(100'000), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{BTC(1), USD(0.01)}}})); - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{USD(0.49), BTC(1)}}})); + BEAST_EXPECT(amm.expectBalances(btc(200'000), USD(100'000), amm.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{btc(1), USD(0.01)}}})); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{USD(0.49), btc(1)}}})); } if (features[fixAMMv1_1] && features[fixAMMv1_3]) { - BEAST_EXPECT(amm.expectBalances(BTC(200'001), USD(99'999.51), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{BTC(1), USD(0.01)}}})); + BEAST_EXPECT(amm.expectBalances(btc(200'001), USD(99'999.51), amm.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{btc(1), USD(0.01)}}})); // Carol's offer crosses AMM - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } @@ -6761,33 +6782,33 @@ private: { Env env(*this, features); - fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); - MPT const BTC = MPTTester( + fund(env, gw_, {alice_, carol_}, XRP(1'000'000), {USD(1'000'000)}); + MPT const btc = MPTTester( {.env = env, - .issuer = gw, - .holders = {alice, carol}, + .issuer = gw_, + .holders = {alice_, carol_}, .pay = 40'000'000000, - .flags = MPTDEXFlags}); + .flags = kMPT_DEX_FLAGS}); - env(offer(alice, BTC(1), XRP(0.01))); + env(offer(alice_, btc(1), XRP(0.01))); env.close(); - AMM const amm(env, gw, BTC(200'000), XRP(100'000)); - env(offer(carol, XRP(0.49), BTC(1))); + AMM const amm(env, gw_, btc(200'000), XRP(100'000)); + env(offer(carol_, XRP(0.49), btc(1))); env.close(); if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { - BEAST_EXPECT(amm.expectBalances(BTC(200'000), XRP(100'000), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{BTC(1), XRP(0.01)}}})); - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{XRP(0.49), BTC(1)}}})); + BEAST_EXPECT(amm.expectBalances(btc(200'000), XRP(100'000), amm.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{btc(1), XRP(0.01)}}})); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{XRP(0.49), btc(1)}}})); } if (features[fixAMMv1_1] && features[fixAMMv1_3]) { - BEAST_EXPECT(amm.expectBalances(BTC(200'001), XRP(99'999.51), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{BTC(1), XRP(0.01)}}})); + BEAST_EXPECT(amm.expectBalances(btc(200'001), XRP(99'999.51), amm.tokens())); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{btc(1), XRP(0.01)}}})); // Carol's offer crosses AMM - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } } @@ -6805,21 +6826,21 @@ private: env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto const USD = gw["USD"]; - env.trust(USD(100000), alice); - env(pay(gw, alice, USD(50000))); - env.trust(USD(100000), bob); - env(pay(gw, bob, USD(40000))); + auto const usd = gw["USD"]; + env.trust(usd(100000), alice); + env(pay(gw, alice, usd(50000))); + env.trust(usd(100000), bob); + env(pay(gw, bob, usd(40000))); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .pay = 40'000'000000, - .flags = tfMPTCanClawback | tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanClawback | tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(2), USD(1)); + AMM amm(env, alice, btc(2), usd(1)); amm.deposit(alice, IOUAmount{1'876123487565916, -15}); amm.deposit(bob, IOUAmount{1'000}); amm.withdraw(alice, IOUAmount{1'876123487565916, -15}); @@ -6848,28 +6869,28 @@ private: // This lambda function is used to create trustline, MPT. // and create an AMM account. // And also test the callback function. - auto testAMMDeposit = [&](Env& env, std::function cb) { - env.fund(XRP(1'000), gw, alice); + auto testAMMDeposit = [&](Env& env, std::function cb) { + env.fund(XRP(1'000), gw_, alice_); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, - .issuer = gw, - .holders = {alice}, + .issuer = gw_, + .holders = {alice_}, .pay = 30'000, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - AMM amm(env, alice, BTC(100), XRP(100)); + AMM amm(env, alice_, btc(100), XRP(100)); env.close(); - BTC.set({.holder = alice, .flags = tfMPTLock}); - cb(amm, BTC); + btc.set({.holder = alice_, .flags = tfMPTLock}); + cb(amm, btc); }; // Deposit two assets, one of which is frozen, // then we should get tecFROZEN error. { Env env(*this); - testAMMDeposit(env, [&](AMM& amm, MPTTester& BTC) { - amm.deposit(alice, BTC(100), XRP(100), std::nullopt, tfTwoAsset, ter(tecFROZEN)); + testAMMDeposit(env, [&](AMM& amm, MPTTester& btc) { + amm.deposit(alice_, btc(100), XRP(100), std::nullopt, tfTwoAsset, Ter(tecFROZEN)); }); } @@ -6877,9 +6898,9 @@ private: // then we should get tecFROZEN error. { Env env(*this); - testAMMDeposit(env, [&](AMM& amm, MPTTester& BTC) { + testAMMDeposit(env, [&](AMM& amm, MPTTester& btc) { amm.deposit( - alice, BTC(100), std::nullopt, std::nullopt, tfSingleAsset, ter(tecFROZEN)); + alice_, btc(100), std::nullopt, std::nullopt, tfSingleAsset, Ter(tecFROZEN)); }); } @@ -6888,9 +6909,9 @@ private: // when feature AMMClawback is enabled. { Env env(*this); - testAMMDeposit(env, [&](AMM& amm, MPTTester& BTC) { + testAMMDeposit(env, [&](AMM& amm, MPTTester& btc) { amm.deposit( - alice, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, ter(tecFROZEN)); + alice_, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, Ter(tecFROZEN)); }); } } @@ -6901,7 +6922,7 @@ private: testcase("Auto Delete"); using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; { Env env( @@ -6911,11 +6932,11 @@ private: return cfg; }), all); - env.fund(XRP(1'000), gw, alice); - MPTTester const USD({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); - MPTTester const BTC({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); - AMM amm(env, gw, USD(10'000), BTC(10'000)); - for (auto i = 0; i < maxDeletableAMMTrustLines + 10; ++i) + env.fund(XRP(1'000), gw_, alice_); + MPTTester const usd({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); + MPTTester const btc({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); + AMM amm(env, gw_, usd(10'000), btc(10'000)); + for (auto i = 0; i < kMAX_DELETABLE_AMM_TRUST_LINES + 10; ++i) { Account const a{std::to_string(i)}; env.fund(XRP(1'000), a); @@ -6924,35 +6945,35 @@ private: } // The trustlines are partially deleted, // AMM is set to an empty state. - amm.withdrawAll(gw); + amm.withdrawAll(gw_); BEAST_EXPECT(amm.ammExists()); // Bid,Vote,Deposit,Withdraw,SetTrust failing with // tecAMM_EMPTY. Deposit succeeds with tfTwoAssetIfEmpty option. env(amm.bid({ - .account = alice, + .account = alice_, .bidMin = 1000, }), - ter(tecAMM_EMPTY)); - amm.vote({.account = alice, .tfee = 100, .err = ter(tecAMM_EMPTY)}); - amm.withdraw({.account = alice, .tokens = 100, .err = ter(tecAMM_EMPTY)}); - amm.deposit({.account = alice, .asset1In = USD(100), .err = ter(tecAMM_EMPTY)}); - env(trust(alice, STAmount{amm.lptIssue(), 10'000}), ter(tecAMM_EMPTY)); + Ter(tecAMM_EMPTY)); + amm.vote({.account = alice_, .tfee = 100, .err = Ter(tecAMM_EMPTY)}); + amm.withdraw({.account = alice_, .tokens = 100, .err = Ter(tecAMM_EMPTY)}); + amm.deposit({.account = alice_, .asset1In = usd(100), .err = Ter(tecAMM_EMPTY)}); + env(trust(alice_, STAmount{amm.lptIssue(), 10'000}), Ter(tecAMM_EMPTY)); // Can deposit with tfTwoAssetIfEmpty option amm.deposit( - {.account = alice, - .asset1In = USD(1'000), - .asset2In = BTC(1'000), + {.account = alice_, + .asset1In = usd(1'000), + .asset2In = btc(1'000), .flags = tfTwoAssetIfEmpty, .tfee = 1'000}); - BEAST_EXPECT(amm.expectBalances(USD(1'000), BTC(1'000), IOUAmount{1'000})); + BEAST_EXPECT(amm.expectBalances(usd(1'000), btc(1'000), IOUAmount{1'000})); BEAST_EXPECT(amm.expectTradingFee(1'000)); BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0})); // Withdrawing all tokens deletes AMM since the number // of remaining trustlines is less than max - amm.withdrawAll(alice); + amm.withdrawAll(alice_); BEAST_EXPECT(!amm.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(amm.ammAccount()))); } @@ -6965,11 +6986,11 @@ private: return cfg; }), all); - env.fund(XRP(1'000), gw, alice); - MPTTester const USD({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); - MPTTester const BTC({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); - AMM amm(env, gw, USD(10'000), BTC(10'000)); - for (auto i = 0; i < (maxDeletableAMMTrustLines * 2) + 10; ++i) + env.fund(XRP(1'000), gw_, alice_); + MPTTester const usd({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); + MPTTester const btc({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); + AMM amm(env, gw_, usd(10'000), btc(10'000)); + for (auto i = 0; i < (kMAX_DELETABLE_AMM_TRUST_LINES * 2) + 10; ++i) { Account const a{std::to_string(i)}; env.fund(XRP(1'000), a); @@ -6977,19 +6998,19 @@ private: env.close(); } // The trustlines are partially deleted. - amm.withdrawAll(gw); + amm.withdrawAll(gw_); BEAST_EXPECT(amm.ammExists()); // AMMDelete has to be called twice to delete AMM. - amm.ammDelete(alice, ter(tecINCOMPLETE)); + amm.ammDelete(alice_, Ter(tecINCOMPLETE)); BEAST_EXPECT(amm.ammExists()); // Deletes remaining trustlines and deletes AMM. - amm.ammDelete(alice); + amm.ammDelete(alice_); BEAST_EXPECT(!amm.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(amm.ammAccount()))); // Try redundant delete - amm.ammDelete(alice, ter(terNO_AMM)); + amm.ammDelete(alice_, Ter(terNO_AMM)); } { @@ -7000,17 +7021,17 @@ private: return cfg; }), all); - env.fund(XRP(1'000), gw, alice, carol); - MPTTester const USD( - {.env = env, .issuer = gw, .holders = {alice, carol}, .pay = 20'000}); - MPTTester const BTC( - {.env = env, .issuer = gw, .holders = {alice, carol}, .pay = 20'000}); - AMM amm(env, gw, USD(10'000), BTC(10'000)); - amm.deposit({.account = alice, .tokens = 1'000}); - amm.deposit({.account = carol, .tokens = 1'000}); - amm.withdrawAll(alice); - amm.withdrawAll(carol); - amm.withdrawAll(gw); + env.fund(XRP(1'000), gw_, alice_, carol_); + MPTTester const usd( + {.env = env, .issuer = gw_, .holders = {alice_, carol_}, .pay = 20'000}); + MPTTester const btc( + {.env = env, .issuer = gw_, .holders = {alice_, carol_}, .pay = 20'000}); + AMM amm(env, gw_, usd(10'000), btc(10'000)); + amm.deposit({.account = alice_, .tokens = 1'000}); + amm.deposit({.account = carol_, .tokens = 1'000}); + amm.withdrawAll(alice_); + amm.withdrawAll(carol_); + amm.withdrawAll(gw_); BEAST_EXPECT(!amm.ammExists()); } @@ -7025,15 +7046,15 @@ private: }), all); - env.fund(XRP(1'000), gw, alice); - MPT const USD = - MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); - MPT const BTC = - MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 20'000}); + env.fund(XRP(1'000), gw_, alice_); + MPT const usd = + MPTTester({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); + MPT const btc = + MPTTester({.env = env, .issuer = gw_, .holders = {alice_}, .pay = 20'000}); // MPT/MPT pool with MANY trustlines - AMM amm(env, gw, USD(10'000), BTC(10'000)); - for (auto i = 0; i < (maxDeletableAMMTrustLines * 2) + 10; ++i) + AMM amm(env, gw_, usd(10'000), btc(10'000)); + for (auto i = 0; i < (kMAX_DELETABLE_AMM_TRUST_LINES * 2) + 10; ++i) { Account const a{std::to_string(i)}; env.fund(XRP(1'000), a); @@ -7041,16 +7062,16 @@ private: env.close(); } - amm.withdrawAll(gw); + amm.withdrawAll(gw_); // AMM is in empty state, but can't be auto-deleted because of the LPTokens trustlines. - BEAST_EXPECT(amm.expectBalances(USD(0), BTC(0), IOUAmount(0))); + BEAST_EXPECT(amm.expectBalances(usd(0), btc(0), IOUAmount(0))); BEAST_EXPECT(amm.ammExists()); // Critical: MPT/MPT pool + tecINCOMPLETE - amm.ammDelete(alice, ter(tecINCOMPLETE)); + amm.ammDelete(alice_, Ter(tecINCOMPLETE)); BEAST_EXPECT(amm.ammExists()); - amm.ammDelete(alice); + amm.ammDelete(alice_); BEAST_EXPECT(!amm.ammExists()); } } @@ -7058,7 +7079,7 @@ private: void run() override { - FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const all{jtx::testableAmendments()}; testInstanceCreate(); testInvalidInstance(); testInvalidDeposit(all); diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index b25705becc..8e2c0255ef 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -73,15 +73,15 @@ namespace xrpl::test { struct AMM_test : public jtx::AMMTest { // Use small Number mantissas for the life of this test. - NumberMantissaScaleGuard const sg_{xrpl::MantissaRange::mantissa_scale::small}; + NumberMantissaScaleGuard const sg{xrpl::MantissaRange::MantissaScale::Small}; private: static FeatureBitset - testable_amendments() + testableAmendments() { // For now, just disable SAV entirely, which locks in the small Number // mantissas - return jtx::testable_amendments() - featureSingleAssetVault - featureLendingProtocol; + return jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol; } void @@ -101,7 +101,7 @@ private: {}, 0, {}, - {testable_amendments()}); + {testableAmendments()}); #endif // XRP to IOU, without featureSingleAssetVault @@ -113,7 +113,7 @@ private: {}, 0, {}, - {testable_amendments() - featureSingleAssetVault}); + {testableAmendments() - featureSingleAssetVault}); // IOU to IOU testAMM( @@ -125,45 +125,45 @@ private: // IOU to IOU + transfer fee { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000), BTC(0.5)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_}, {USD(20'000), BTC(0.5)}, Fund::All); + env(rate(gw_, 1.25)); env.close(); // no transfer fee on create - AMM const ammAlice(env, alice, USD(20'000), BTC(0.5)); + AMM const ammAlice(env, alice_, USD(20'000), BTC(0.5)); BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(0.5), IOUAmount{100, 0})); - BEAST_EXPECT(expectHolding(env, alice, USD(0))); - BEAST_EXPECT(expectHolding(env, alice, BTC(0))); + BEAST_EXPECT(expectHolding(env, alice_, USD(0))); + BEAST_EXPECT(expectHolding(env, alice_, BTC(0))); } // Require authorization is set, account is authorized { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(fset(gw, asfRequireAuth)); - env(trust(alice, gw["USD"](30'000), 0)); - env(trust(gw, alice["USD"](0), tfSetfAuth)); + env(fset(gw_, asfRequireAuth)); + env(trust(alice_, gw_["USD"](30'000), 0)); + env(trust(gw_, alice_["USD"](0), tfSetfAuth)); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw_, alice_, USD(10'000))); env.close(); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000)); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'000)); } // Cleared global freeze { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env.trust(USD(30'000), alice); + env.trust(USD(30'000), alice_); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw_, alice_, USD(10'000))); env.close(); - env(fset(gw, asfGlobalFreeze)); + env(fset(gw_, asfGlobalFreeze)); env.close(); - AMM const ammAliceFail(env, alice, XRP(10'000), USD(10'000), ter(tecFROZEN)); - env(fclear(gw, asfGlobalFreeze)); + AMM const ammAliceFail(env, alice_, XRP(10'000), USD(10'000), Ter(tecFROZEN)); + env(fclear(gw_, asfGlobalFreeze)); env.close(); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000)); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'000)); } // Trading fee @@ -194,64 +194,64 @@ private: // Can't have both XRP tokens { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(10'000), XRP(10'000), ter(temBAD_AMM_TOKENS)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, XRP(10'000), XRP(10'000), Ter(temBAD_AMM_TOKENS)); BEAST_EXPECT(!ammAlice.ammExists()); } // Can't have both tokens the same IOU { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, USD(10'000), USD(10'000), ter(temBAD_AMM_TOKENS)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, USD(10'000), USD(10'000), Ter(temBAD_AMM_TOKENS)); BEAST_EXPECT(!ammAlice.ammExists()); } // Can't have zero or negative amounts { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(0), USD(10'000), ter(temBAD_AMOUNT)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, XRP(0), USD(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice.ammExists()); - AMM const ammAlice1(env, alice, XRP(10'000), USD(0), ter(temBAD_AMOUNT)); + AMM const ammAlice1(env, alice_, XRP(10'000), USD(0), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice1.ammExists()); - AMM const ammAlice2(env, alice, XRP(10'000), USD(-10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice2(env, alice_, XRP(10'000), USD(-10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice2.ammExists()); - AMM const ammAlice3(env, alice, XRP(-10'000), USD(10'000), ter(temBAD_AMOUNT)); + AMM const ammAlice3(env, alice_, XRP(-10'000), USD(10'000), Ter(temBAD_AMOUNT)); BEAST_EXPECT(!ammAlice3.ammExists()); } // Bad currency { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(10'000), BAD(10'000), ter(temBAD_CURRENCY)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, XRP(10'000), BAD(10'000), Ter(temBAD_CURRENCY)); BEAST_EXPECT(!ammAlice.ammExists()); } // Insufficient IOU balance { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(10'000), USD(40'000), ter(tecUNFUNDED_AMM)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, XRP(10'000), USD(40'000), Ter(tecUNFUNDED_AMM)); BEAST_EXPECT(!ammAlice.ammExists()); } // Insufficient XRP balance { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); - AMM const ammAlice(env, alice, XRP(40'000), USD(10'000), ter(tecUNFUNDED_AMM)); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); + AMM const ammAlice(env, alice_, XRP(40'000), USD(10'000), Ter(tecUNFUNDED_AMM)); BEAST_EXPECT(!ammAlice.ammExists()); } // Invalid trading fee { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); AMM const ammAlice( env, - alice, + alice_, XRP(10'000), USD(10'000), false, @@ -260,22 +260,22 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_FEE)); + Ter(temBAD_FEE)); BEAST_EXPECT(!ammAlice.ammExists()); } // AMM already exists testAMM([&](AMM& ammAlice, Env& env) { - AMM const ammCarol(env, carol, XRP(10'000), USD(10'000), ter(tecDUPLICATE)); + AMM const ammCarol(env, carol_, XRP(10'000), USD(10'000), Ter(tecDUPLICATE)); }); // Invalid flags { Env env{*this}; - fund(env, gw, {alice}, {USD(30'000)}, Fund::All); + fund(env, gw_, {alice_}, {USD(30'000)}, Fund::All); AMM const ammAlice( env, - alice, + alice_, XRP(10'000), USD(10'000), false, @@ -284,7 +284,7 @@ private: tfWithdrawAll, std::nullopt, std::nullopt, - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); BEAST_EXPECT(!ammAlice.ammExists()); } @@ -302,37 +302,37 @@ private: 0, 10, std::nullopt, - seq(1), + Seq(1), std::nullopt, - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); BEAST_EXPECT(!ammAlice.ammExists()); } // Require authorization is set { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(fset(gw, asfRequireAuth)); + env(fset(gw_, asfRequireAuth)); env.close(); - env(trust(gw, alice["USD"](30'000))); + env(trust(gw_, alice_["USD"](30'000))); env.close(); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000), ter(tecNO_AUTH)); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'000), Ter(tecNO_AUTH)); BEAST_EXPECT(!ammAlice.ammExists()); } // Globally frozen { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(fset(gw, asfGlobalFreeze)); + env(fset(gw_, asfGlobalFreeze)); env.close(); - env(trust(gw, alice["USD"](30'000))); + env(trust(gw_, alice_["USD"](30'000))); env.close(); - for (auto const& account : {alice, gw}) + for (auto const& account : {alice_, gw_}) { - AMM const amm(env, account, XRP(10'000), USD(10'000), ter(tecFROZEN)); + AMM const amm(env, account, XRP(10'000), USD(10'000), Ter(tecFROZEN)); BEAST_EXPECT(!amm.ammExists()); } } @@ -340,57 +340,57 @@ private: // Individually frozen { Env env{*this}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(trust(gw, alice["USD"](30'000))); + env(trust(gw_, alice_["USD"](30'000))); env.close(); - env(trust(gw, alice["USD"](0), tfSetFreeze)); + env(trust(gw_, alice_["USD"](0), tfSetFreeze)); env.close(); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000), ter(tecFROZEN)); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'000), Ter(tecFROZEN)); BEAST_EXPECT(!ammAlice.ammExists()); // issuer can create - AMM const amm(env, gw, XRP(10'000), USD(10'000)); + AMM const amm(env, gw_, XRP(10'000), USD(10'000)); } // Insufficient reserve, XRP/IOU { Env env(*this); - auto const starting_xrp = XRP(1'000) + reserve(env, 3) + env.current()->fees().base * 4; - env.fund(starting_xrp, gw); - env.fund(starting_xrp, alice); - env.trust(USD(2'000), alice); + auto const startingXrp = XRP(1'000) + reserve(env, 3) + env.current()->fees().base * 4; + env.fund(startingXrp, gw_); + env.fund(startingXrp, alice_); + env.trust(USD(2'000), alice_); env.close(); - env(pay(gw, alice, USD(2'000))); + env(pay(gw_, alice_, USD(2'000))); env.close(); - env(offer(alice, XRP(101), USD(100))); - env(offer(alice, XRP(102), USD(100))); - AMM const ammAlice(env, alice, XRP(1'000), USD(1'000), ter(tecUNFUNDED_AMM)); + env(offer(alice_, XRP(101), USD(100))); + env(offer(alice_, XRP(102), USD(100))); + AMM const ammAlice(env, alice_, XRP(1'000), USD(1'000), Ter(tecUNFUNDED_AMM)); } // Insufficient reserve, IOU/IOU { Env env(*this); - auto const starting_xrp = reserve(env, 4) + env.current()->fees().base * 5; - env.fund(starting_xrp, gw); - env.fund(starting_xrp, alice); - env.trust(USD(2'000), alice); - env.trust(EUR(2'000), alice); + auto const startingXrp = reserve(env, 4) + env.current()->fees().base * 5; + env.fund(startingXrp, gw_); + env.fund(startingXrp, alice_); + env.trust(USD(2'000), alice_); + env.trust(EUR(2'000), alice_); env.close(); - env(pay(gw, alice, USD(2'000))); - env(pay(gw, alice, EUR(2'000))); + env(pay(gw_, alice_, USD(2'000))); + env(pay(gw_, alice_, EUR(2'000))); env.close(); - env(offer(alice, EUR(101), USD(100))); - env(offer(alice, EUR(102), USD(100))); - AMM const ammAlice(env, alice, EUR(1'000), USD(1'000), ter(tecINSUF_RESERVE_LINE)); + env(offer(alice_, EUR(101), USD(100))); + env(offer(alice_, EUR(102), USD(100))); + AMM const ammAlice(env, alice_, EUR(1'000), USD(1'000), Ter(tecINSUF_RESERVE_LINE)); } // Insufficient fee { Env env(*this); - fund(env, gw, {alice}, XRP(2'000), {USD(2'000), EUR(2'000)}); + fund(env, gw_, {alice_}, XRP(2'000), {USD(2'000), EUR(2'000)}); AMM const ammAlice( env, - alice, + alice_, EUR(1'000), USD(1'000), false, @@ -399,62 +399,62 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(telINSUF_FEE_P)); + Ter(telINSUF_FEE_P)); } // AMM with LPTokens // AMM with one LPToken from another AMM. testAMM([&](AMM& ammAlice, Env& env) { - fund(env, gw, {alice}, {EUR(10'000)}, Fund::TokenOnly); + fund(env, gw_, {alice_}, {EUR(10'000)}, Fund::TokenOnly); AMM const ammAMMToken( env, - alice, + alice_, EUR(10'000), STAmount{ammAlice.lptIssue(), 1'000'000}, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); AMM const ammAMMToken1( env, - alice, + alice_, STAmount{ammAlice.lptIssue(), 1'000'000}, EUR(10'000), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }); // AMM with two LPTokens from other AMMs. testAMM([&](AMM& ammAlice, Env& env) { - fund(env, gw, {alice}, {EUR(10'000)}, Fund::TokenOnly); - AMM const ammAlice1(env, alice, XRP(10'000), EUR(10'000)); + fund(env, gw_, {alice_}, {EUR(10'000)}, Fund::TokenOnly); + AMM const ammAlice1(env, alice_, XRP(10'000), EUR(10'000)); auto const token1 = ammAlice.lptIssue(); auto const token2 = ammAlice1.lptIssue(); AMM const ammAMMTokens( env, - alice, + alice_, STAmount{token1, 1'000'000}, STAmount{token2, 1'000'000}, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }); // Issuer has DefaultRipple disabled { Env env(*this); - env.fund(XRP(30'000), gw); - env(fclear(gw, asfDefaultRipple)); - AMM const ammGw(env, gw, XRP(10'000), USD(10'000), ter(terNO_RIPPLE)); - env.fund(XRP(30'000), alice); - env.trust(USD(30'000), alice); - env(pay(gw, alice, USD(30'000))); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'000), ter(terNO_RIPPLE)); + env.fund(XRP(30'000), gw_); + env(fclear(gw_, asfDefaultRipple)); + AMM const ammGw(env, gw_, XRP(10'000), USD(10'000), Ter(terNO_RIPPLE)); + env.fund(XRP(30'000), alice_); + env.trust(USD(30'000), alice_); + env(pay(gw_, alice_, USD(30'000))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'000), Ter(terNO_RIPPLE)); Account const gw1("gw1"); env.fund(XRP(30'000), gw1); env(fclear(gw1, asfDefaultRipple)); env.trust(USD(30'000), gw1); - env(pay(gw, gw1, USD(30'000))); - auto const USD1 = gw1["USD"]; - AMM const ammGwGw1(env, gw, USD(10'000), USD1(10'000), ter(terNO_RIPPLE)); - env.trust(USD1(30'000), alice); - env(pay(gw1, alice, USD1(30'000))); - AMM const ammAlice1(env, alice, USD(10'000), USD1(10'000), ter(terNO_RIPPLE)); + env(pay(gw_, gw1, USD(30'000))); + auto const usD1 = gw1["USD"]; + AMM const ammGwGw1(env, gw_, USD(10'000), usD1(10'000), Ter(terNO_RIPPLE)); + env.trust(usD1(30'000), alice_); + env(pay(gw1, alice_, usD1(30'000))); + AMM const ammAlice1(env, alice_, USD(10'000), usD1(10'000), Ter(terNO_RIPPLE)); } } @@ -467,7 +467,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Invalid flags - ammAlice.deposit(alice, 1'000'000, std::nullopt, tfWithdrawAll, ter(temINVALID_FLAG)); + ammAlice.deposit(alice_, 1'000'000, std::nullopt, tfWithdrawAll, Ter(temINVALID_FLAG)); // Invalid options std::vector(it), std::get<2>(it), std::get<3>(it), @@ -547,39 +547,39 @@ private: std::nullopt, std::nullopt, std::get<5>(it), - ter(temMALFORMED)); + Ter(temMALFORMED)); } { // bad preflight1 - Json::Value jv = Json::objectValue; - jv[jss::Account] = alice.human(); + json::Value jv = json::ObjectValue; + jv[jss::Account] = alice_.human(); jv[jss::TransactionType] = jss::AMMDeposit; - jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::none); - jv[jss::Asset2] = STIssue(sfAsset, USD).getJson(JsonOptions::none); + jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::KNone); + jv[jss::Asset2] = STIssue(sfAsset, USD).getJson(JsonOptions::KNone); jv[jss::Fee] = "-1"; - env(jv, ter(temBAD_FEE)); + env(jv, Ter(temBAD_FEE)); } // Invalid tokens - ammAlice.deposit(alice, 0, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(alice_, 0, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); ammAlice.deposit( - alice, IOUAmount{-1}, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, IOUAmount{-1}, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); { - Json::Value jv = Json::objectValue; - jv[jss::Account] = alice.human(); + json::Value jv = json::ObjectValue; + jv[jss::Account] = alice_.human(); jv[jss::TransactionType] = jss::AMMDeposit; - jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::none); - jv[jss::Asset2] = STIssue(sfAsset, USD).getJson(JsonOptions::none); - jv[jss::LPTokenOut] = USD(100).value().getJson(JsonOptions::none); + jv[jss::Asset] = STIssue(sfAsset, XRP).getJson(JsonOptions::KNone); + jv[jss::Asset2] = STIssue(sfAsset, USD).getJson(JsonOptions::KNone); + jv[jss::LPTokenOut] = USD(100).value().getJson(JsonOptions::KNone); jv[jss::Flags] = tfLPToken; - env(jv, ter(temBAD_AMM_TOKENS)); + env(jv, Ter(temBAD_AMM_TOKENS)); } // Invalid trading fee ammAlice.deposit( - carol, + carol_, std::nullopt, XRP(200), USD(200), @@ -588,14 +588,14 @@ private: std::nullopt, std::nullopt, 10'000, - ter(temBAD_FEE)); + Ter(temBAD_FEE)); // Invalid tokens - bogus currency { - auto const iss1 = Issue{Currency(0xabc), gw.id()}; - auto const iss2 = Issue{Currency(0xdef), gw.id()}; + auto const iss1 = Issue{Currency(0xabc), gw_.id()}; + auto const iss2 = Issue{Currency(0xdef), gw_.id()}; ammAlice.deposit( - alice, + alice_, 1'000, std::nullopt, std::nullopt, @@ -604,32 +604,32 @@ private: {{iss1, iss2}}, std::nullopt, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); } // Depositing mismatched token, invalid Asset1In.issue ammAlice.deposit( - alice, GBP(100), std::nullopt, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, GBP(100), std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Depositing mismatched token, invalid Asset2In.issue ammAlice.deposit( - alice, USD(100), GBP(100), std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, USD(100), GBP(100), std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Depositing mismatched token, Asset1In.issue == Asset2In.issue ammAlice.deposit( - alice, USD(100), USD(100), std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, USD(100), USD(100), std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Invalid amount value ammAlice.deposit( - alice, USD(0), std::nullopt, std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); + alice_, USD(0), std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); ammAlice.deposit( - alice, USD(-1'000), std::nullopt, std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); + alice_, USD(-1'000), std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); ammAlice.deposit( - alice, USD(10), std::nullopt, USD(-1), std::nullopt, ter(temBAD_AMOUNT)); + alice_, USD(10), std::nullopt, USD(-1), std::nullopt, Ter(temBAD_AMOUNT)); // Bad currency ammAlice.deposit( - alice, BAD(100), std::nullopt, std::nullopt, std::nullopt, ter(temBAD_CURRENCY)); + alice_, BAD(100), std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_CURRENCY)); // Invalid Account Account const bad("bad"); @@ -642,13 +642,13 @@ private: std::nullopt, std::nullopt, std::nullopt, - seq(1), + Seq(1), std::nullopt, - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); // Invalid AMM ammAlice.deposit( - alice, + alice_, 1'000, std::nullopt, std::nullopt, @@ -657,12 +657,12 @@ private: {{USD, GBP}}, std::nullopt, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); // Single deposit: 100000 tokens worth of USD // Amount to deposit exceeds Max ammAlice.deposit( - carol, + carol_, 100'000, USD(200), std::nullopt, @@ -671,12 +671,12 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Single deposit: 100000 tokens worth of XRP // Amount to deposit exceeds Max ammAlice.deposit( - carol, + carol_, 100'000, XRP(200), std::nullopt, @@ -685,50 +685,50 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Deposit amount is invalid // Calculated amount to deposit is 98,000,000 ammAlice.deposit( - alice, + alice_, USD(0), std::nullopt, STAmount{USD, 1, -1}, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); // Calculated amount is 0 ammAlice.deposit( - alice, + alice_, USD(0), std::nullopt, STAmount{USD, 2'000, -6}, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Deposit non-empty AMM ammAlice.deposit( - carol, XRP(100), USD(100), std::nullopt, tfTwoAssetIfEmpty, ter(tecAMM_NOT_EMPTY)); + carol_, XRP(100), USD(100), std::nullopt, tfTwoAssetIfEmpty, Ter(tecAMM_NOT_EMPTY)); }); // Tiny deposit testAMM( [&](AMM& ammAlice, Env& env) { - auto const enabledV1_3 = env.current()->rules().enabled(fixAMMv1_3); - auto const err = !enabledV1_3 ? ter(temBAD_AMOUNT) : ter(tesSUCCESS); + auto const enabledV13 = env.current()->rules().enabled(fixAMMv1_3); + auto const err = !enabledV13 ? Ter(temBAD_AMOUNT) : Ter(tesSUCCESS); // Pre-amendment XRP deposit side is rounded to 0 // and deposit fails. // Post-amendment XRP deposit side is rounded to 1 // and deposit succeeds. - ammAlice.deposit(carol, IOUAmount{1, -4}, std::nullopt, std::nullopt, err); + ammAlice.deposit(carol_, IOUAmount{1, -4}, std::nullopt, std::nullopt, err); // Pre/post-amendment LPTokens is rounded to 0 and deposit // fails with tecAMM_INVALID_TOKENS. ammAlice.deposit( - carol, + carol_, STAmount{USD, 1, -12}, std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }, std::nullopt, 0, @@ -737,20 +737,20 @@ private: // Invalid AMM testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); - ammAlice.deposit(alice, 10'000, std::nullopt, std::nullopt, ter(terNO_AMM)); + ammAlice.withdrawAll(alice_); + ammAlice.deposit(alice_, 10'000, std::nullopt, std::nullopt, Ter(terNO_AMM)); }); // Globally frozen asset testAMM( [&](AMM& ammAlice, Env& env) { - env(fset(gw, asfGlobalFreeze)); + env(fset(gw_, asfGlobalFreeze)); if (!features[featureAMMClawback]) { // If the issuer set global freeze, the holder still can // deposit the other non-frozen token when AMMClawback is // not enabled. - ammAlice.deposit(carol, XRP(100)); + ammAlice.deposit(carol_, XRP(100)); } else { @@ -758,9 +758,9 @@ private: // deposit the other non-frozen token when AMMClawback is // enabled. ammAlice.deposit( - carol, XRP(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, XRP(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); } - for (auto const& account : {carol, gw}) + for (auto const& account : {carol_, gw_}) { ammAlice.deposit( account, @@ -768,11 +768,11 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecFROZEN)); + Ter(tecFROZEN)); ammAlice.deposit( - account, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + account, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - account, XRP(100), USD(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + account, XRP(100), USD(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); } }, std::nullopt, @@ -783,37 +783,37 @@ private: // Individually frozen (AMM) account testAMM( [&](AMM& ammAlice, Env& env) { - env(trust(gw, carol["USD"](0), tfSetFreeze)); + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); if (!features[featureAMMClawback]) { // Can deposit non-frozen token if AMMClawback is not // enabled - ammAlice.deposit(carol, XRP(100)); + ammAlice.deposit(carol_, XRP(100)); } else { // Cannot deposit non-frozen token if the other token is // frozen when AMMClawback is enabled ammAlice.deposit( - carol, XRP(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, XRP(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); } - ammAlice.deposit(carol, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); - env(trust(gw, carol["USD"](0), tfClearFreeze)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); + env(trust(gw_, carol_["USD"](0), tfClearFreeze)); // Individually frozen AMM env(trust( - gw, - STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, + gw_, + STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); env.close(); // Can deposit non-frozen token - ammAlice.deposit(carol, XRP(100)); - ammAlice.deposit(carol, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, XRP(100)); + ammAlice.deposit(carol_, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); }, std::nullopt, 0, @@ -823,82 +823,82 @@ private: // Individually frozen (AMM) account with IOU/IOU AMM testAMM( [&](AMM& ammAlice, Env& env) { - env(trust(gw, carol["USD"](0), tfSetFreeze)); - env(trust(gw, carol["BTC"](0), tfSetFreeze)); + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); + env(trust(gw_, carol_["BTC"](0), tfSetFreeze)); env.close(); - ammAlice.deposit(carol, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecFROZEN)); - env(trust(gw, carol["USD"](0), tfClearFreeze)); + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecFROZEN)); + env(trust(gw_, carol_["USD"](0), tfClearFreeze)); // Individually frozen AMM env(trust( - gw, - STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, + gw_, + STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); env.close(); // Cannot deposit non-frozen token - ammAlice.deposit(carol, 1'000'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.deposit(carol_, 1'000'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); ammAlice.deposit( - carol, USD(100), BTC(0.01), std::nullopt, std::nullopt, ter(tecFROZEN)); + carol_, USD(100), BTC(0.01), std::nullopt, std::nullopt, Ter(tecFROZEN)); }, {{USD(20'000), BTC(0.5)}}); // Deposit unauthorized token. { Env env(*this, features); - env.fund(XRP(1000), gw, alice, bob); - env(fset(gw, asfRequireAuth)); + env.fund(XRP(1000), gw_, alice_, bob_); + env(fset(gw_, asfRequireAuth)); env.close(); - env(trust(gw, alice["USD"](100)), txflags(tfSetfAuth)); - env(trust(alice, gw["USD"](20))); + env(trust(gw_, alice_["USD"](100)), Txflags(tfSetfAuth)); + env(trust(alice_, gw_["USD"](20))); env.close(); - env(pay(gw, alice, gw["USD"](10))); + env(pay(gw_, alice_, gw_["USD"](10))); env.close(); - env(trust(gw, bob["USD"](100))); + env(trust(gw_, bob_["USD"](100))); env.close(); - AMM amm(env, alice, XRP(10), gw["USD"](10), ter(tesSUCCESS)); + AMM amm(env, alice_, XRP(10), gw_["USD"](10), Ter(tesSUCCESS)); env.close(); if (features[featureAMMClawback]) { - // if featureAMMClawback is enabled, bob can not deposit XRP + // if featureAMMClawback is enabled, bob_ can not deposit XRP // because he's not authorized to hold the paired token - // gw["USD"]. + // gw_["USD"]. amm.deposit( - bob, XRP(10), std::nullopt, std::nullopt, std::nullopt, ter(tecNO_AUTH)); + bob_, XRP(10), std::nullopt, std::nullopt, std::nullopt, Ter(tecNO_AUTH)); } else { amm.deposit( - bob, XRP(10), std::nullopt, std::nullopt, std::nullopt, ter(tesSUCCESS)); + bob_, XRP(10), std::nullopt, std::nullopt, std::nullopt, Ter(tesSUCCESS)); } } // Insufficient XRP balance testAMM([&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); // Adds LPT trustline - ammAlice.deposit(bob, XRP(10)); + ammAlice.deposit(bob_, XRP(10)); ammAlice.deposit( - bob, XRP(1'000), std::nullopt, std::nullopt, std::nullopt, ter(tecUNFUNDED_AMM)); + bob_, XRP(1'000), std::nullopt, std::nullopt, std::nullopt, Ter(tecUNFUNDED_AMM)); }); // Insufficient USD balance testAMM([&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {USD(1'000)}, Fund::Acct); + fund(env, gw_, {bob_}, {USD(1'000)}, Fund::Acct); env.close(); ammAlice.deposit( - bob, USD(1'001), std::nullopt, std::nullopt, std::nullopt, ter(tecUNFUNDED_AMM)); + bob_, USD(1'001), std::nullopt, std::nullopt, std::nullopt, Ter(tecUNFUNDED_AMM)); }); // Insufficient USD balance by tokens testAMM([&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {USD(1'000)}, Fund::Acct); + fund(env, gw_, {bob_}, {USD(1'000)}, Fund::Acct); env.close(); ammAlice.deposit( - bob, + bob_, 10'000'000, std::nullopt, std::nullopt, @@ -907,18 +907,18 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); }); // Insufficient XRP balance by tokens testAMM([&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - env.trust(USD(100'000), bob); + env.fund(XRP(1'000), bob_); + env.trust(USD(100'000), bob_); env.close(); - env(pay(gw, bob, USD(90'000))); + env(pay(gw_, bob_, USD(90'000))); env.close(); ammAlice.deposit( - bob, + bob_, 10'000'000, std::nullopt, std::nullopt, @@ -927,79 +927,79 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecUNFUNDED_AMM)); + Ter(tecUNFUNDED_AMM)); }); // Insufficient reserve, XRP/IOU { Env env(*this); - auto const starting_xrp = reserve(env, 4) + env.current()->fees().base * 4; - env.fund(XRP(10'000), gw); - env.fund(XRP(10'000), alice); - env.fund(starting_xrp, carol); - env.trust(USD(2'000), alice); - env.trust(USD(2'000), carol); + auto const startingXrp = reserve(env, 4) + env.current()->fees().base * 4; + env.fund(XRP(10'000), gw_); + env.fund(XRP(10'000), alice_); + env.fund(startingXrp, carol_); + env.trust(USD(2'000), alice_); + env.trust(USD(2'000), carol_); env.close(); - env(pay(gw, alice, USD(2'000))); - env(pay(gw, carol, USD(2'000))); + env(pay(gw_, alice_, USD(2'000))); + env(pay(gw_, carol_, USD(2'000))); env.close(); - env(offer(carol, XRP(100), USD(101))); - env(offer(carol, XRP(100), USD(102))); - AMM ammAlice(env, alice, XRP(1'000), USD(1'000)); + env(offer(carol_, XRP(100), USD(101))); + env(offer(carol_, XRP(100), USD(102))); + AMM ammAlice(env, alice_, XRP(1'000), USD(1'000)); ammAlice.deposit( - carol, + carol_, XRP(100), std::nullopt, std::nullopt, std::nullopt, - ter(tecINSUF_RESERVE_LINE)); + Ter(tecINSUF_RESERVE_LINE)); - env(offer(carol, XRP(100), USD(103))); + env(offer(carol_, XRP(100), USD(103))); ammAlice.deposit( - carol, + carol_, USD(100), std::nullopt, std::nullopt, std::nullopt, - ter(tecINSUF_RESERVE_LINE)); + Ter(tecINSUF_RESERVE_LINE)); } // Insufficient reserve, IOU/IOU { Env env(*this); - auto const starting_xrp = reserve(env, 4) + env.current()->fees().base * 4; - env.fund(XRP(10'000), gw); - env.fund(XRP(10'000), alice); - env.fund(starting_xrp, carol); - env.trust(USD(2'000), alice); - env.trust(EUR(2'000), alice); - env.trust(USD(2'000), carol); - env.trust(EUR(2'000), carol); + auto const startingXrp = reserve(env, 4) + env.current()->fees().base * 4; + env.fund(XRP(10'000), gw_); + env.fund(XRP(10'000), alice_); + env.fund(startingXrp, carol_); + env.trust(USD(2'000), alice_); + env.trust(EUR(2'000), alice_); + env.trust(USD(2'000), carol_); + env.trust(EUR(2'000), carol_); env.close(); - env(pay(gw, alice, USD(2'000))); - env(pay(gw, alice, EUR(2'000))); - env(pay(gw, carol, USD(2'000))); - env(pay(gw, carol, EUR(2'000))); + env(pay(gw_, alice_, USD(2'000))); + env(pay(gw_, alice_, EUR(2'000))); + env(pay(gw_, carol_, USD(2'000))); + env(pay(gw_, carol_, EUR(2'000))); env.close(); - env(offer(carol, XRP(100), USD(101))); - env(offer(carol, XRP(100), USD(102))); - AMM ammAlice(env, alice, XRP(1'000), USD(1'000)); + env(offer(carol_, XRP(100), USD(101))); + env(offer(carol_, XRP(100), USD(102))); + AMM ammAlice(env, alice_, XRP(1'000), USD(1'000)); ammAlice.deposit( - carol, + carol_, XRP(100), std::nullopt, std::nullopt, std::nullopt, - ter(tecINSUF_RESERVE_LINE)); + Ter(tecINSUF_RESERVE_LINE)); } // Invalid min testAMM([&](AMM& ammAlice, Env& env) { // min tokens can't be <= zero - ammAlice.deposit(carol, 0, XRP(100), tfSingleAsset, ter(temBAD_AMM_TOKENS)); - ammAlice.deposit(carol, -1, XRP(100), tfSingleAsset, ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(carol_, 0, XRP(100), tfSingleAsset, Ter(temBAD_AMM_TOKENS)); + ammAlice.deposit(carol_, -1, XRP(100), tfSingleAsset, Ter(temBAD_AMM_TOKENS)); ammAlice.deposit( - carol, + carol_, 0, XRP(100), USD(100), @@ -1008,10 +1008,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); // min amounts can't be <= zero ammAlice.deposit( - carol, + carol_, 1'000, XRP(0), USD(100), @@ -1020,9 +1020,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), USD(-1), @@ -1031,10 +1031,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); // min amount bad currency ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), BAD(100), @@ -1043,10 +1043,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_CURRENCY)); + Ter(temBAD_CURRENCY)); // min amount bad token pair ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), XRP(100), @@ -1055,9 +1055,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); ammAlice.deposit( - carol, + carol_, 1'000, XRP(100), GBP(100), @@ -1066,14 +1066,14 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); }); // Min deposit testAMM([&](AMM& ammAlice, Env& env) { // Equal deposit by tokens ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), USD(1'001), @@ -1082,9 +1082,9 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'001), USD(1'000), @@ -1093,10 +1093,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Equal deposit by asset ammAlice.deposit( - carol, + carol_, 100'001, XRP(100), USD(100), @@ -1105,10 +1105,10 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Single deposit by asset ammAlice.deposit( - carol, + carol_, 488'090, XRP(1'000), std::nullopt, @@ -1117,12 +1117,12 @@ private: std::nullopt, std::nullopt, std::nullopt, - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); }); // Equal deposit, tokens rounded to 0 testAMM([&](AMM& amm, Env& env) { - amm.deposit(DepositArg{.tokens = IOUAmount{1, -12}, .err = ter(tecAMM_INVALID_TOKENS)}); + amm.deposit(DepositArg{.tokens = IOUAmount{1, -12}, .err = Ter(tecAMM_INVALID_TOKENS)}); }); // Equal deposit limit, tokens rounded to 0 @@ -1132,7 +1132,7 @@ private: DepositArg{ .asset1In = STAmount{USD, 1, -15}, .asset2In = XRPAmount{1}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); }, {.pool = {{USD(1'000'000), XRP(1'000'000)}}, .features = {features - fixAMMv1_3}}); testAMM([&](AMM& amm, Env& env) { @@ -1140,13 +1140,13 @@ private: DepositArg{ .asset1In = STAmount{USD, 1, -15}, .asset2In = XRPAmount{1}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); }); // Single deposit by asset, tokens rounded to 0 testAMM([&](AMM& amm, Env& env) { amm.deposit( - DepositArg{.asset1In = STAmount{USD, 1, -15}, .err = ter(tecAMM_INVALID_TOKENS)}); + DepositArg{.asset1In = STAmount{USD, 1, -15}, .err = Ter(tecAMM_INVALID_TOKENS)}); }); // Single deposit by tokens, tokens rounded to 0 @@ -1155,7 +1155,7 @@ private: DepositArg{ .tokens = IOUAmount{1, -10}, .asset1In = STAmount{USD, 1, -15}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); }); // Single deposit with EPrice, tokens rounded to 0 @@ -1164,7 +1164,7 @@ private: DepositArg{ .asset1In = STAmount{USD, 1, -15}, .maxEP = STAmount{USD, 1, -1}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); }); } @@ -1173,19 +1173,19 @@ private: { testcase("Deposit"); - auto const all = testable_amendments(); + auto const all = testableAmendments(); using namespace jtx; // Equal deposit: 1000000 tokens, 10% of the current pool testAMM([&](AMM& ammAlice, Env& env) { auto const baseFee = env.current()->fees().base; - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0})); // 30,000 less deposited 1,000 - BEAST_EXPECT(expectHolding(env, carol, USD(29'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'000))); // 30,000 less deposited 1,000 and 10 drops tx fee - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRPAmount{29'000'000'000 - baseFee})); + BEAST_EXPECT(expectLedgerEntryRoot(env, carol_, XRPAmount{29'000'000'000 - baseFee})); }); // equal asset deposit: unit test to exercise the rounding-down of @@ -1199,8 +1199,8 @@ private: IOUAmount const initLPToken = ammAlice.getLPTokensBalance(); IOUAmount const newLPTokens{deltaLPTokens}; - // carol performs a two-asset deposit - ammAlice.deposit(DepositArg{.account = carol, .tokens = newLPTokens}); + // carol_ performs a two-asset deposit + ammAlice.deposit(DepositArg{.account = carol_, .tokens = newLPTokens}); IOUAmount const finalLPToken = ammAlice.getLPTokensBalance(); @@ -1232,10 +1232,10 @@ private: IOUAmount{1, 7} + newLPTokens)); // 30,000 less deposited depositUSD - BEAST_EXPECT(expectHolding(env, carol, USD(30'000) - depositUSD)); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000) - depositUSD)); // 30,000 less deposited depositXRP and 10 drops tx fee BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRP(30'000) - depositXRP - txfee(env, 1))); + expectLedgerEntryRoot(env, carol_, XRP(30'000) - depositXRP - txFee(env, 1))); }); } @@ -1245,7 +1245,7 @@ private: // to the pool composition not to exceed 100USD. Fail if exceeded. // Deposit 100USD/100XRP testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(100), XRP(100)); + ammAlice.deposit(carol_, USD(100), XRP(100)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), USD(10'100), IOUAmount{10'100'000, 0})); }); @@ -1253,20 +1253,20 @@ private: // Equal limit deposit. // Try to deposit 200USD/100XRP. Is truncated to 100USD/100XRP. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(200), XRP(100)); + ammAlice.deposit(carol_, USD(200), XRP(100)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), USD(10'100), IOUAmount{10'100'000, 0})); }); // Try to deposit 100USD/200XRP. Is truncated to 100USD/100XRP. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(100), XRP(200)); + ammAlice.deposit(carol_, USD(100), XRP(200)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), USD(10'100), IOUAmount{10'100'000, 0})); }); // Single deposit: 1000 USD testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(1'000)); + ammAlice.deposit(carol_, USD(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, UINT64_C(10'999'99999999999), -11}, @@ -1275,21 +1275,21 @@ private: // Single deposit: 1000 XRP testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, XRP(1'000)); + ammAlice.deposit(carol_, XRP(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), USD(10'000), IOUAmount{10'488'088'48170151, -8})); }); // Single deposit: 100000 tokens worth of USD testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 100000, USD(205)); + ammAlice.deposit(carol_, 100000, USD(205)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'000), USD(10'201), IOUAmount{10'100'000, 0})); }); // Single deposit: 100000 tokens worth of XRP testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 100'000, XRP(205)); + ammAlice.deposit(carol_, 100'000, XRP(205)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'201), USD(10'000), IOUAmount{10'100'000, 0})); }); @@ -1297,7 +1297,7 @@ private: // Single deposit with EP not exceeding specified: // 100USD with EP not to exceed 0.1 (AssetIn/TokensOut) testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(1'000), std::nullopt, STAmount{USD, 1, -1}); + ammAlice.deposit(carol_, USD(1'000), std::nullopt, STAmount{USD, 1, -1}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, UINT64_C(10'999'99999999999), -11}, @@ -1307,7 +1307,7 @@ private: // Single deposit with EP not exceeding specified: // 100USD with EP not to exceed 0.002004 (AssetIn/TokensOut) testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(100), std::nullopt, STAmount{USD, 2004, -6}); + ammAlice.deposit(carol_, USD(100), std::nullopt, STAmount{USD, 2004, -6}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, 10'080'16, -2}, IOUAmount{10'040'000, 0})); }); @@ -1315,7 +1315,7 @@ private: // Single deposit with EP not exceeding specified: // 0USD with EP not to exceed 0.002004 (AssetIn/TokensOut) testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(0), std::nullopt, STAmount{USD, 2004, -6}); + ammAlice.deposit(carol_, USD(0), std::nullopt, STAmount{USD, 2004, -6}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, 10'080'16, -2}, IOUAmount{10'040'000, 0})); }); @@ -1323,55 +1323,55 @@ private: // IOU to IOU + transfer fee { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000), BTC(0.5)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_}, {USD(20'000), BTC(0.5)}, Fund::All); + env(rate(gw_, 1.25)); env.close(); - AMM ammAlice(env, alice, USD(20'000), BTC(0.5)); + AMM ammAlice(env, alice_, USD(20'000), BTC(0.5)); BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(0.5), IOUAmount{100, 0})); - BEAST_EXPECT(expectHolding(env, alice, USD(0))); - BEAST_EXPECT(expectHolding(env, alice, BTC(0))); - fund(env, gw, {carol}, {USD(2'000), BTC(0.05)}, Fund::Acct); + BEAST_EXPECT(expectHolding(env, alice_, USD(0))); + BEAST_EXPECT(expectHolding(env, alice_, BTC(0))); + fund(env, gw_, {carol_}, {USD(2'000), BTC(0.05)}, Fund::Acct); // no transfer fee on deposit - ammAlice.deposit(carol, 10); + ammAlice.deposit(carol_, 10); BEAST_EXPECT(ammAlice.expectBalances(USD(22'000), BTC(0.55), IOUAmount{110, 0})); - BEAST_EXPECT(expectHolding(env, carol, USD(0))); - BEAST_EXPECT(expectHolding(env, carol, BTC(0))); + BEAST_EXPECT(expectHolding(env, carol_, USD(0))); + BEAST_EXPECT(expectHolding(env, carol_, BTC(0))); } // Tiny deposits testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, IOUAmount{1, -3}); + ammAlice.deposit(carol_, IOUAmount{1, -3}); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'001}, STAmount{USD, UINT64_C(10'000'000001), -6}, IOUAmount{10'000'000'001, -3})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1, -3})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1, -3})); }); testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, XRPAmount{1}); + ammAlice.deposit(carol_, XRPAmount{1}); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'001}, USD(10'000), IOUAmount{1'000'000'000049999, -8})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{49999, -8})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{49999, -8})); }); testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, STAmount{USD, 1, -10}); + ammAlice.deposit(carol_, STAmount{USD, 1, -10}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, UINT64_C(10'000'00000000008), -11}, IOUAmount{10'000'000'00000004, -8})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{4, -8})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{4, -8})); }); // Issuer create/deposit for (auto const& feat : {all, all - fixAMMv1_3}) { Env env(*this, feat); - env.fund(XRP(30000), gw); - AMM ammGw(env, gw, XRP(10'000), USD(10'000)); + env.fund(XRP(30000), gw_); + AMM ammGw(env, gw_, XRP(10'000), USD(10'000)); BEAST_EXPECT(ammGw.expectBalances(XRP(10'000), USD(10'000), ammGw.tokens())); - ammGw.deposit(gw, 1'000'000); + ammGw.deposit(gw_, 1'000'000); BEAST_EXPECT(ammGw.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000})); - ammGw.deposit(gw, USD(1'000)); + ammGw.deposit(gw_, USD(1'000)); BEAST_EXPECT(ammGw.expectBalances( XRP(11'000), STAmount{USD, UINT64_C(11'999'99999999998), -11}, @@ -1380,9 +1380,9 @@ private: // Issuer deposit testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(gw, 1'000'000); + ammAlice.deposit(gw_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000})); - ammAlice.deposit(gw, USD(1'000)); + ammAlice.deposit(gw_, USD(1'000)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), STAmount{USD, UINT64_C(11'999'99999999998), -11}, @@ -1393,7 +1393,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Equal deposit by tokens ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), USD(1'000), @@ -1407,7 +1407,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Equal deposit by asset ammAlice.deposit( - carol, + carol_, 1'000'000, XRP(1'000), USD(1'000), @@ -1421,7 +1421,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Single deposit by asset ammAlice.deposit( - carol, + carol_, 488'088, XRP(1'000), std::nullopt, @@ -1435,7 +1435,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Single deposit by asset ammAlice.deposit( - carol, + carol_, 488'088, USD(1'000), std::nullopt, @@ -1455,14 +1455,14 @@ private: { testcase("Invalid Withdraw"); - auto const all = testable_amendments(); + auto const all = testableAmendments(); using namespace jtx; testAMM( [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .asset1Out = XRP(100), - .err = ter(tecAMM_BALANCE), + .err = Ter(tecAMM_BALANCE), }; ammAlice.withdraw(args); }, @@ -1472,7 +1472,7 @@ private: [&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .asset1Out = USD(100), - .err = ter(tecAMM_BALANCE), + .err = Ter(tecAMM_BALANCE), }; ammAlice.withdraw(args); }, @@ -1480,23 +1480,23 @@ private: { Env env{*this}; - env.fund(XRP(30'000), gw, alice, bob); + env.fund(XRP(30'000), gw_, alice_, bob_); env.close(); - env(fset(gw, asfRequireAuth)); + env(fset(gw_, asfRequireAuth)); env.close(); - env(trust(alice, gw["USD"](30'000), 0)); - env(trust(gw, alice["USD"](0), tfSetfAuth)); + env(trust(alice_, gw_["USD"](30'000), 0)); + env(trust(gw_, alice_["USD"](0), tfSetfAuth)); // Bob trusts Gateway to owe him USD... - env(trust(bob, gw["USD"](30'000), 0)); + env(trust(bob_, gw_["USD"](30'000), 0)); // ...but Gateway does not authorize Bob to hold its USD. env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw_, alice_, USD(10'000))); env.close(); - AMM ammAlice(env, alice, XRP(10'000), USD(10'000)); + AMM ammAlice(env, alice_, XRP(10'000), USD(10'000)); WithdrawArg const args{ - .account = bob, + .account = bob_, .asset1Out = USD(100), - .err = ter(tecNO_AUTH), + .err = Ter(tecNO_AUTH), }; ammAlice.withdraw(args); } @@ -1504,7 +1504,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { // Invalid flags ammAlice.withdraw( - alice, + alice_, 1'000'000, std::nullopt, std::nullopt, @@ -1512,9 +1512,9 @@ private: tfBurnable, std::nullopt, std::nullopt, - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); ammAlice.withdraw( - alice, + alice_, 1'000'000, std::nullopt, std::nullopt, @@ -1522,7 +1522,7 @@ private: tfTwoAssetIfEmpty, std::nullopt, std::nullopt, - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); // Invalid options std::vector(it), std::get<1>(it), std::get<2>(it), @@ -1594,34 +1594,34 @@ private: std::get<4>(it), std::nullopt, std::nullopt, - ter(std::get<5>(it))); + Ter(std::get<5>(it))); } // Invalid tokens - ammAlice.withdraw(alice, 0, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, 0, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); ammAlice.withdraw( - alice, IOUAmount{-1}, std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + alice_, IOUAmount{-1}, std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Mismatched token, invalid Asset1Out issue - ammAlice.withdraw(alice, GBP(100), std::nullopt, std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, GBP(100), std::nullopt, std::nullopt, Ter(temBAD_AMM_TOKENS)); // Mismatched token, invalid Asset2Out issue - ammAlice.withdraw(alice, USD(100), GBP(100), std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, USD(100), GBP(100), std::nullopt, Ter(temBAD_AMM_TOKENS)); // Mismatched token, Asset1Out.issue == Asset2Out.issue - ammAlice.withdraw(alice, USD(100), USD(100), std::nullopt, ter(temBAD_AMM_TOKENS)); + ammAlice.withdraw(alice_, USD(100), USD(100), std::nullopt, Ter(temBAD_AMM_TOKENS)); // Invalid amount value - ammAlice.withdraw(alice, USD(0), std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); - ammAlice.withdraw(alice, USD(-100), std::nullopt, std::nullopt, ter(temBAD_AMOUNT)); - ammAlice.withdraw(alice, USD(10), std::nullopt, IOUAmount{-1}, ter(temBAD_AMOUNT)); + ammAlice.withdraw(alice_, USD(0), std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); + ammAlice.withdraw(alice_, USD(-100), std::nullopt, std::nullopt, Ter(temBAD_AMOUNT)); + ammAlice.withdraw(alice_, USD(10), std::nullopt, IOUAmount{-1}, Ter(temBAD_AMOUNT)); // Invalid amount/token value, withdraw all tokens from one side // of the pool. - ammAlice.withdraw(alice, USD(10'000), std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); - ammAlice.withdraw(alice, XRP(10'000), std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); + ammAlice.withdraw(alice_, USD(10'000), std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); + ammAlice.withdraw(alice_, XRP(10'000), std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); ammAlice.withdraw( - alice, + alice_, std::nullopt, USD(0), std::nullopt, @@ -1629,10 +1629,10 @@ private: tfOneAssetWithdrawAll, std::nullopt, std::nullopt, - ter(tecAMM_BALANCE)); + Ter(tecAMM_BALANCE)); // Bad currency - ammAlice.withdraw(alice, BAD(100), std::nullopt, std::nullopt, ter(temBAD_CURRENCY)); + ammAlice.withdraw(alice_, BAD(100), std::nullopt, std::nullopt, Ter(temBAD_CURRENCY)); // Invalid Account Account const bad("bad"); @@ -1645,12 +1645,12 @@ private: std::nullopt, std::nullopt, std::nullopt, - seq(1), - ter(terNO_ACCOUNT)); + Seq(1), + Ter(terNO_ACCOUNT)); // Invalid AMM ammAlice.withdraw( - alice, + alice_, 1'000, std::nullopt, std::nullopt, @@ -1658,27 +1658,27 @@ private: std::nullopt, {{USD, GBP}}, std::nullopt, - ter(terNO_AMM)); + Ter(terNO_AMM)); // Carol is not a Liquidity Provider - ammAlice.withdraw(carol, 10'000, std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); + ammAlice.withdraw(carol_, 10'000, std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); // Withdrawing from one side. // XRP by tokens ammAlice.withdraw( - alice, IOUAmount(9'999'999'9999, -4), XRP(0), std::nullopt, ter(tecAMM_BALANCE)); + alice_, IOUAmount(9'999'999'9999, -4), XRP(0), std::nullopt, Ter(tecAMM_BALANCE)); // USD by tokens ammAlice.withdraw( - alice, IOUAmount(9'999'999'9, -1), USD(0), std::nullopt, ter(tecAMM_BALANCE)); + alice_, IOUAmount(9'999'999'9, -1), USD(0), std::nullopt, Ter(tecAMM_BALANCE)); // XRP - ammAlice.withdraw(alice, XRP(10'000), std::nullopt, std::nullopt, ter(tecAMM_BALANCE)); + ammAlice.withdraw(alice_, XRP(10'000), std::nullopt, std::nullopt, Ter(tecAMM_BALANCE)); // USD ammAlice.withdraw( - alice, + alice_, STAmount{USD, UINT64_C(9'999'9999999999999), -13}, std::nullopt, std::nullopt, - ter(tecAMM_BALANCE)); + Ter(tecAMM_BALANCE)); }); testAMM( @@ -1690,9 +1690,9 @@ private: // while leaving a tiny amount in USD pool. // Post-amendment: // Most of the pool is withdrawn with remaining tiny amounts - auto err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS) : ter(tecAMM_BALANCE); + auto err = env.enabled(fixAMMv1_3) ? Ter(tesSUCCESS) : Ter(tecAMM_BALANCE); ammAlice.withdraw( - alice, IOUAmount{9'999'999'9999, -4}, std::nullopt, std::nullopt, err); + alice_, IOUAmount{9'999'999'9999, -4}, std::nullopt, std::nullopt, err); if (env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -1712,9 +1712,9 @@ private: // Equal withdraw but due to XRP precision limit, // this results in full withdraw of XRP pool only, // while leaving a tiny amount in USD pool. - auto err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS) : ter(tecAMM_BALANCE); + auto err = env.enabled(fixAMMv1_3) ? Ter(tesSUCCESS) : Ter(tecAMM_BALANCE); ammAlice.withdraw( - alice, IOUAmount{9'999'999'999999999, -9}, std::nullopt, std::nullopt, err); + alice_, IOUAmount{9'999'999'999999999, -9}, std::nullopt, std::nullopt, err); if (env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -1728,52 +1728,52 @@ private: // Invalid AMM testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); - ammAlice.withdraw(alice, 10'000, std::nullopt, std::nullopt, ter(terNO_AMM)); + ammAlice.withdrawAll(alice_); + ammAlice.withdraw(alice_, 10'000, std::nullopt, std::nullopt, Ter(terNO_AMM)); }); // Globally frozen asset testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit({.account = gw, .asset1In = USD(1'000), .asset2In = XRP(1'000)}); - env(fset(gw, asfGlobalFreeze)); + ammAlice.deposit({.account = gw_, .asset1In = USD(1'000), .asset2In = XRP(1'000)}); + env(fset(gw_, asfGlobalFreeze)); env.close(); // Can withdraw non-frozen token - for (auto const& account : {alice, gw}) + for (auto const& account : {alice_, gw_}) { ammAlice.withdraw(account, XRP(100)); - ammAlice.withdraw(account, USD(100), std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(account, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.withdraw(account, USD(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(account, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); } }); // Individually frozen (AMM) account testAMM([&](AMM& ammAlice, Env& env) { - env(trust(gw, alice["USD"](0), tfSetFreeze)); + env(trust(gw_, alice_["USD"](0), tfSetFreeze)); env.close(); // Can withdraw non-frozen token - ammAlice.withdraw(alice, XRP(100)); - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt, ter(tecFROZEN)); - env(trust(gw, alice["USD"](0), tfClearFreeze)); + ammAlice.withdraw(alice_, XRP(100)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); + env(trust(gw_, alice_["USD"](0), tfClearFreeze)); // Individually frozen AMM env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); + gw_, STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); // Can withdraw non-frozen token - ammAlice.withdraw(alice, XRP(100)); - ammAlice.withdraw(alice, 1'000, std::nullopt, std::nullopt, ter(tecFROZEN)); - ammAlice.withdraw(alice, USD(100), std::nullopt, std::nullopt, ter(tecFROZEN)); + ammAlice.withdraw(alice_, XRP(100)); + ammAlice.withdraw(alice_, 1'000, std::nullopt, std::nullopt, Ter(tecFROZEN)); + ammAlice.withdraw(alice_, USD(100), std::nullopt, std::nullopt, Ter(tecFROZEN)); }); // Carol withdraws more than she owns testAMM([&](AMM& ammAlice, Env&) { // Single deposit of 100000 worth of tokens, // which is 10% of the pool. Carol is LP now. - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0})); ammAlice.withdraw( - carol, 2'000'000, std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, 2'000'000, std::nullopt, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0})); }); @@ -1782,10 +1782,10 @@ private: // to withdraw are 0. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); auto const err = - env.enabled(fixAMMv1_3) ? ter(tecAMM_INVALID_TOKENS) : ter(tecAMM_FAILED); - ammAlice.withdraw(carol, USD(100), std::nullopt, IOUAmount{500, 0}, err); + env.enabled(fixAMMv1_3) ? Ter(tecAMM_INVALID_TOKENS) : Ter(tecAMM_FAILED); + ammAlice.withdraw(carol_, USD(100), std::nullopt, IOUAmount{500, 0}, err); }, std::nullopt, 0, @@ -1795,46 +1795,46 @@ private: // Withdraw with EPrice limit. Fails to withdraw, calculated tokens // to withdraw are greater than the LP shares. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); ammAlice.withdraw( - carol, USD(100), std::nullopt, IOUAmount{600, 0}, ter(tecAMM_INVALID_TOKENS)); + carol_, USD(100), std::nullopt, IOUAmount{600, 0}, Ter(tecAMM_INVALID_TOKENS)); }); // Withdraw with EPrice limit. Fails to withdraw, amount1 // to withdraw is less than 1700USD. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); ammAlice.withdraw( - carol, USD(1'700), std::nullopt, IOUAmount{520, 0}, ter(tecAMM_FAILED)); + carol_, USD(1'700), std::nullopt, IOUAmount{520, 0}, Ter(tecAMM_FAILED)); }); // Deposit/Withdraw the same amount with the trading fee testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(1'000)); + ammAlice.deposit(carol_, USD(1'000)); ammAlice.withdraw( - carol, USD(1'000), std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, USD(1'000), std::nullopt, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); }, std::nullopt, 1'000); testAMM( [&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, XRP(1'000)); + ammAlice.deposit(carol_, XRP(1'000)); ammAlice.withdraw( - carol, XRP(1'000), std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, XRP(1'000), std::nullopt, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); }, std::nullopt, 1'000); // Deposit/Withdraw the same amount fails due to the tokens adjustment testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, STAmount{USD, 1, -6}); + ammAlice.deposit(carol_, STAmount{USD, 1, -6}); ammAlice.withdraw( - carol, + carol_, STAmount{USD, 1, -6}, std::nullopt, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }); // Withdraw close to one side of the pool. Account's LP tokens @@ -1842,9 +1842,9 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { auto const err = - env.enabled(fixAMMv1_3) ? ter(tecINVARIANT_FAILED) : ter(tecAMM_BALANCE); + env.enabled(fixAMMv1_3) ? Ter(tecINVARIANT_FAILED) : Ter(tecAMM_BALANCE); ammAlice.withdraw( - alice, + alice_, STAmount{USD, UINT64_C(9'999'999999999999), -12}, std::nullopt, std::nullopt, @@ -1856,35 +1856,35 @@ private: testAMM([&](AMM& ammAlice, Env&) { // XRP amount to withdraw is 0 ammAlice.withdraw( - alice, IOUAmount{1, -5}, std::nullopt, std::nullopt, ter(tecAMM_FAILED)); + alice_, IOUAmount{1, -5}, std::nullopt, std::nullopt, Ter(tecAMM_FAILED)); // Calculated tokens to withdraw are 0 ammAlice.withdraw( - alice, + alice_, std::nullopt, STAmount{USD, 1, -11}, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); - ammAlice.deposit(carol, STAmount{USD, 1, -10}); + Ter(tecAMM_INVALID_TOKENS)); + ammAlice.deposit(carol_, STAmount{USD, 1, -10}); ammAlice.withdraw( - carol, + carol_, std::nullopt, STAmount{USD, 1, -9}, std::nullopt, - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); ammAlice.withdraw( - carol, std::nullopt, XRPAmount{1}, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, std::nullopt, XRPAmount{1}, std::nullopt, Ter(tecAMM_INVALID_TOKENS)); ammAlice.withdraw( - WithdrawArg{.tokens = IOUAmount{1, -10}, .err = ter(tecAMM_INVALID_TOKENS)}); + WithdrawArg{.tokens = IOUAmount{1, -10}, .err = Ter(tecAMM_INVALID_TOKENS)}); ammAlice.withdraw( WithdrawArg{ .asset1Out = STAmount{USD, 1, -15}, .asset2Out = XRPAmount{1}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); ammAlice.withdraw( WithdrawArg{ .tokens = IOUAmount{1, -10}, .asset1Out = STAmount{USD, 1, -15}, - .err = ter(tecAMM_INVALID_TOKENS)}); + .err = Ter(tecAMM_INVALID_TOKENS)}); }); } @@ -1893,7 +1893,7 @@ private: { testcase("Withdraw"); - auto const all = testable_amendments(); + auto const all = testableAmendments(); using namespace jtx; // Equal withdrawal by Carol: 1000000 of tokens, 10% of the current @@ -1902,27 +1902,27 @@ private: auto const baseFee = env.current()->fees().base.drops(); // Single deposit of 100000 worth of tokens, // which is 10% of the pool. Carol is LP now. - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{11'000'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); // 30,000 less deposited 1,000 - BEAST_EXPECT(expectHolding(env, carol, USD(29'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'000))); // 30,000 less deposited 1,000 and 10 drops tx fee - BEAST_EXPECT(expectLedgerEntryRoot(env, carol, XRPAmount{29'000'000'000 - baseFee})); + BEAST_EXPECT(expectLedgerEntryRoot(env, carol_, XRPAmount{29'000'000'000 - baseFee})); // Carol withdraws all tokens - ammAlice.withdraw(carol, 1'000'000); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + ammAlice.withdraw(carol_, 1'000'000); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); BEAST_EXPECT( - expectLedgerEntryRoot(env, carol, XRPAmount{30'000'000'000 - (2 * baseFee)})); + expectLedgerEntryRoot(env, carol_, XRPAmount{30'000'000'000 - (2 * baseFee)})); }); // Equal withdrawal by tokens 1000000, 10% // of the current pool testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, 1'000'000); + ammAlice.withdraw(alice_, 1'000'000); BEAST_EXPECT(ammAlice.expectBalances(XRP(9'000), USD(9'000), IOUAmount{9'000'000, 0})); }); @@ -1932,20 +1932,20 @@ private: // and proportionally withdraw XRP. It's the latter // in this case - XRP100/USD100. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, XRP(200), USD(100)); + ammAlice.withdraw(alice_, XRP(200), USD(100)); BEAST_EXPECT(ammAlice.expectBalances(XRP(9'900), USD(9'900), IOUAmount{9'900'000, 0})); }); // Equal withdrawal with a limit. XRP100/USD100. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, XRP(100), USD(200)); + ammAlice.withdraw(alice_, XRP(100), USD(200)); BEAST_EXPECT(ammAlice.expectBalances(XRP(9'900), USD(9'900), IOUAmount{9'900'000, 0})); }); // Single withdrawal by amount XRP1000 testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(alice, XRP(1'000)); + ammAlice.withdraw(alice_, XRP(1'000)); if (!env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -1964,42 +1964,42 @@ private: // Single withdrawal by tokens 10000. testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, 10'000, USD(0)); + ammAlice.withdraw(alice_, 10'000, USD(0)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'000), USD(9980.01), IOUAmount{9'990'000, 0})); }); // Withdraw all tokens. testAMM([&](AMM& ammAlice, Env& env) { - env(trust(carol, STAmount{ammAlice.lptIssue(), 10'000})); + env(trust(carol_, STAmount{ammAlice.lptIssue(), 10'000})); // Can TrustSet only for AMM LP tokens - env(trust(carol, STAmount{Issue{EUR.currency, ammAlice.ammAccount()}, 10'000}), - ter(tecNO_PERMISSION)); + env(trust(carol_, STAmount{Issue{EUR.currency, ammAlice.ammAccount()}, 10'000}), + Ter(tecNO_PERMISSION)); env.close(); - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); BEAST_EXPECT(!ammAlice.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(ammAlice.ammAccount()))); // Can create AMM for the XRP/USD pair - AMM const ammCarol(env, carol, XRP(10'000), USD(10'000)); + AMM const ammCarol(env, carol_, XRP(10'000), USD(10'000)); BEAST_EXPECT( ammCarol.expectBalances(XRP(10'000), USD(10'000), IOUAmount{10'000'000, 0})); }); // Single deposit 1000USD, withdraw all tokens in USD testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'000), USD(10'000), IOUAmount{10'000'000, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount(beast::Zero()))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount(beast::Zero()))); }); // Single deposit 1000USD, withdraw all tokens in XRP testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, XRP(0)); + ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdrawAll(carol_, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9'090'909'091), STAmount{USD, UINT64_C(10'999'99999999999), -11}, @@ -2012,12 +2012,12 @@ private: // Since a smaller amount might be deposited due to // the lp tokens adjustment, withdrawing by tokens // is generally preferred to withdrawing by amount. - auto lpTokens = ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdraw(carol, lpTokens, USD(0)); - lpTokens = ammAlice.deposit(carol, STAmount(USD, 1, -6)); - ammAlice.withdraw(carol, lpTokens, USD(0)); - lpTokens = ammAlice.deposit(carol, XRPAmount(1)); - ammAlice.withdraw(carol, lpTokens, XRPAmount(0)); + auto lpTokens = ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdraw(carol_, lpTokens, USD(0)); + lpTokens = ammAlice.deposit(carol_, STAmount(USD, 1, -6)); + ammAlice.withdraw(carol_, lpTokens, USD(0)); + lpTokens = ammAlice.deposit(carol_, XRPAmount(1)); + ammAlice.withdraw(carol_, lpTokens, XRPAmount(0)); if (!env.enabled(fixAMMv1_3)) { BEAST_EXPECT( @@ -2028,7 +2028,7 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(10'000'000'001), USD(10'000), ammAlice.tokens())); } - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, std::nullopt, 0, @@ -2038,27 +2038,27 @@ private: // Single deposit by different accounts and then withdraw // in reverse. testAMM([&](AMM& ammAlice, Env&) { - auto const carolTokens = ammAlice.deposit(carol, USD(1'000)); - auto const aliceTokens = ammAlice.deposit(alice, USD(1'000)); - ammAlice.withdraw(alice, aliceTokens, USD(0)); - ammAlice.withdraw(carol, carolTokens, USD(0)); + auto const carolTokens = ammAlice.deposit(carol_, USD(1'000)); + auto const aliceTokens = ammAlice.deposit(alice_, USD(1'000)); + ammAlice.withdraw(alice_, aliceTokens, USD(0)); + ammAlice.withdraw(carol_, carolTokens, USD(0)); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'000), ammAlice.tokens())); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, ammAlice.tokens())); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, ammAlice.tokens())); }); // Equal deposit 10%, withdraw all tokens testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_); BEAST_EXPECT( ammAlice.expectBalances(XRP(10'000), USD(10'000), IOUAmount{10'000'000, 0})); }); // Equal deposit 10%, withdraw all tokens in USD testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT(ammAlice.expectBalances( XRP(11'000), STAmount{USD, UINT64_C(9'090'909090909092), -12}, @@ -2067,8 +2067,8 @@ private: // Equal deposit 10%, withdraw all tokens in XRP testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdrawAll(carol, XRP(0)); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdrawAll(carol_, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(9'090'909'091), USD(11'000), IOUAmount{10'000'000, 0})); }); @@ -2076,9 +2076,9 @@ private: // Withdraw with EPrice limit. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdraw(carol, USD(100), std::nullopt, IOUAmount{520, 0}); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -8})); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdraw(carol_, USD(100), std::nullopt, IOUAmount{520, 0}); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -8})); if (!env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -2100,17 +2100,17 @@ private: STAmount{USD, UINT64_C(9'372'78106508877), -11}, IOUAmount{10'153'846'15384616, -8})); } - ammAlice.withdrawAll(carol); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + ammAlice.withdrawAll(carol_); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }, {.features = {all, all - fixAMMv1_3, all - fixAMMv1_1 - fixAMMv1_3}, .noLog = true}); // Withdraw with EPrice limit. AssetOut is 0. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdraw(carol, USD(0), std::nullopt, IOUAmount{520, 0}); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{153'846'15384616, -8})); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.withdraw(carol_, USD(0), std::nullopt, IOUAmount{520, 0}); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{153'846'15384616, -8})); if (!env.enabled(fixAMMv1_1) && !env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -2141,32 +2141,32 @@ private: // IOU to IOU + transfer fee { Env env{*this}; - fund(env, gw, {alice}, {USD(20'000), BTC(0.5)}, Fund::All); - env(rate(gw, 1.25)); + fund(env, gw_, {alice_}, {USD(20'000), BTC(0.5)}, Fund::All); + env(rate(gw_, 1.25)); env.close(); // no transfer fee on create - AMM ammAlice(env, alice, USD(20'000), BTC(0.5)); + AMM ammAlice(env, alice_, USD(20'000), BTC(0.5)); BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(0.5), IOUAmount{100, 0})); - BEAST_EXPECT(expectHolding(env, alice, USD(0))); - BEAST_EXPECT(expectHolding(env, alice, BTC(0))); - fund(env, gw, {carol}, {USD(2'000), BTC(0.05)}, Fund::Acct); + BEAST_EXPECT(expectHolding(env, alice_, USD(0))); + BEAST_EXPECT(expectHolding(env, alice_, BTC(0))); + fund(env, gw_, {carol_}, {USD(2'000), BTC(0.05)}, Fund::Acct); // no transfer fee on deposit - ammAlice.deposit(carol, 10); + ammAlice.deposit(carol_, 10); BEAST_EXPECT(ammAlice.expectBalances(USD(22'000), BTC(0.55), IOUAmount{110, 0})); - BEAST_EXPECT(expectHolding(env, carol, USD(0))); - BEAST_EXPECT(expectHolding(env, carol, BTC(0))); + BEAST_EXPECT(expectHolding(env, carol_, USD(0))); + BEAST_EXPECT(expectHolding(env, carol_, BTC(0))); // no transfer fee on withdraw - ammAlice.withdraw(carol, 10); + ammAlice.withdraw(carol_, 10); BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(0.5), IOUAmount{100, 0})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0, 0})); - BEAST_EXPECT(expectHolding(env, carol, USD(2'000))); - BEAST_EXPECT(expectHolding(env, carol, BTC(0.05))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0, 0})); + BEAST_EXPECT(expectHolding(env, carol_, USD(2'000))); + BEAST_EXPECT(expectHolding(env, carol_, BTC(0.05))); } // Tiny withdraw testAMM([&](AMM& ammAlice, Env&) { // By tokens - ammAlice.withdraw(alice, IOUAmount{1, -3}); + ammAlice.withdraw(alice_, IOUAmount{1, -3}); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{9'999'999'999}, STAmount{USD, UINT64_C(9'999'999999), -6}, @@ -2175,7 +2175,7 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // Single XRP pool - ammAlice.withdraw(alice, std::nullopt, XRPAmount{1}); + ammAlice.withdraw(alice_, std::nullopt, XRPAmount{1}); if (!env.enabled(fixAMMv1_3)) { BEAST_EXPECT(ammAlice.expectBalances( @@ -2193,7 +2193,7 @@ private: {all, all - fixAMMv1_3}); testAMM([&](AMM& ammAlice, Env&) { // Single USD pool - ammAlice.withdraw(alice, std::nullopt, STAmount{USD, 1, -10}); + ammAlice.withdraw(alice_, std::nullopt, STAmount{USD, 1, -10}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10'000), STAmount{USD, UINT64_C(9'999'9999999999), -10}, @@ -2203,29 +2203,29 @@ private: // Withdraw close to entire pool // Equal by tokens testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'999'999, -3}); + ammAlice.withdraw(alice_, IOUAmount{9'999'999'999, -3}); BEAST_EXPECT( ammAlice.expectBalances(XRPAmount{1}, STAmount{USD, 1, -6}, IOUAmount{1, -3})); }); // USD by tokens testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'999}, USD(0)); + ammAlice.withdraw(alice_, IOUAmount{9'999'999}, USD(0)); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), STAmount{USD, 1, -10}, IOUAmount{1})); }); // XRP by tokens testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, IOUAmount{9'999'900}, XRP(0)); + ammAlice.withdraw(alice_, IOUAmount{9'999'900}, XRP(0)); BEAST_EXPECT(ammAlice.expectBalances(XRPAmount{1}, USD(10'000), IOUAmount{100})); }); // USD testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, STAmount{USD, UINT64_C(9'999'99999999999), -11}); + ammAlice.withdraw(alice_, STAmount{USD, UINT64_C(9'999'99999999999), -11}); BEAST_EXPECT(ammAlice.expectBalances( XRP(10000), STAmount{USD, 1, -11}, IOUAmount{316227765, -9})); }); // XRP testAMM([&](AMM& ammAlice, Env&) { - ammAlice.withdraw(alice, XRPAmount{9'999'999'999}); + ammAlice.withdraw(alice_, XRPAmount{9'999'999'999}); BEAST_EXPECT(ammAlice.expectBalances(XRPAmount{1}, USD(10'000), IOUAmount{100})); }); } @@ -2244,30 +2244,35 @@ private: tfWithdrawAll, std::nullopt, std::nullopt, - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); // Invalid fee. ammAlice.vote( - std::nullopt, 1'001, std::nullopt, std::nullopt, std::nullopt, ter(temBAD_FEE)); + std::nullopt, 1'001, std::nullopt, std::nullopt, std::nullopt, Ter(temBAD_FEE)); BEAST_EXPECT(ammAlice.expectTradingFee(0)); // Invalid Account Account const bad("bad"); env.memoize(bad); - ammAlice.vote(bad, 1'000, std::nullopt, seq(1), std::nullopt, ter(terNO_ACCOUNT)); + ammAlice.vote(bad, 1'000, std::nullopt, Seq(1), std::nullopt, Ter(terNO_ACCOUNT)); // Invalid AMM - ammAlice.vote(alice, 1'000, std::nullopt, std::nullopt, {{USD, GBP}}, ter(terNO_AMM)); + ammAlice.vote(alice_, 1'000, std::nullopt, std::nullopt, {{USD, GBP}}, Ter(terNO_AMM)); // Account is not LP ammAlice.vote( - carol, 1'000, std::nullopt, std::nullopt, std::nullopt, ter(tecAMM_INVALID_TOKENS)); + carol_, + 1'000, + std::nullopt, + std::nullopt, + std::nullopt, + Ter(tecAMM_INVALID_TOKENS)); }); // Invalid AMM testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); - ammAlice.vote(alice, 1'000, std::nullopt, std::nullopt, std::nullopt, ter(terNO_AMM)); + ammAlice.withdrawAll(alice_); + ammAlice.vote(alice_, 1'000, std::nullopt, std::nullopt, std::nullopt, Ter(terNO_AMM)); }); } @@ -2275,7 +2280,7 @@ private: testFeeVote() { testcase("Fee Vote"); - auto const all = testable_amendments(); + auto const all = testableAmendments(); using namespace jtx; // One vote sets fee to 1%. @@ -2300,7 +2305,7 @@ private: // deposit to succeed if (env.enabled(fixAMMv1_3)) ++fundUSD; - fund(env, gw, {a}, {USD(fundUSD)}, Fund::Acct); + fund(env, gw_, {a}, {USD(fundUSD)}, Fund::Acct); ammAlice.deposit(a, tokens); ammAlice.vote(a, 50 * (i + 1)); if (accounts) @@ -2360,8 +2365,8 @@ private: BEAST_EXPECT(ammAlice.expectTradingFee(175)); for (int i = 0; i < 7; ++i) ammAlice.withdrawAll(accounts[i]); - ammAlice.deposit(carol, 10'000'000); - ammAlice.vote(carol, 1'000); + ammAlice.deposit(carol_, 10'000'000); + ammAlice.vote(carol_, 1'000); // The initial LP set the fee to 1000. Carol gets 50% voting // power, and the new fee is 500. BEAST_EXPECT(ammAlice.expectTradingFee(500)); @@ -2377,12 +2382,12 @@ private: BEAST_EXPECT(ammAlice.expectTradingFee(175)); for (int i = 0; i < 7; ++i) ammAlice.withdraw(accounts[i], 9'000'000); - ammAlice.deposit(carol, 1'000); + ammAlice.deposit(carol_, 1'000); // The vote is not added to the slots - ammAlice.vote(carol, 1'000); + ammAlice.vote(carol_, 1'000); auto const info = ammAlice.ammRpcInfo()[jss::amm][jss::vote_slots]; for (std::uint32_t i = 0; i < info.size(); ++i) - BEAST_EXPECT(info[i][jss::account] != carol.human()); + BEAST_EXPECT(info[i][jss::account] != carol_.human()); // But the slots are refreshed and the fee is changed BEAST_EXPECT(ammAlice.expectTradingFee(82)); }); @@ -2398,92 +2403,92 @@ private: // burn all the LPTokens through a AMMBid transaction { Env env(*this); - fund(env, gw, {alice}, XRP(2'000), {USD(2'000)}); - AMM amm(env, gw, XRP(1'000), USD(1'000), false, 1'000); + fund(env, gw_, {alice_}, XRP(2'000), {USD(2'000)}); + AMM amm(env, gw_, XRP(1'000), USD(1'000), false, 1'000); - // auction slot is owned by the creator of the AMM i.e. gw + // auction slot is owned by the creator of the AMM i.e. gw_ BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0})); - // gw attempts to burn all her LPTokens through a bid transaction + // gw_ attempts to burn all her LPTokens through a bid transaction // this transaction fails because AMMBid transaction can not burn // all the outstanding LPTokens env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = 1'000'000, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); } // burn all the LPTokens through a AMMBid transaction { Env env(*this); - fund(env, gw, {alice}, XRP(2'000), {USD(2'000)}); - AMM amm(env, gw, XRP(1'000), USD(1'000), false, 1'000); + fund(env, gw_, {alice_}, XRP(2'000), {USD(2'000)}); + AMM amm(env, gw_, XRP(1'000), USD(1'000), false, 1'000); - // auction slot is owned by the creator of the AMM i.e. gw + // auction slot is owned by the creator of the AMM i.e. gw_ BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{0})); - // gw burns all but one of its LPTokens through a bid transaction + // gw_ burns all but one of its LPTokens through a bid transaction // this transaction succeeds because the bid price is less than // the total outstanding LPToken balance env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = STAmount{amm.lptIssue(), UINT64_C(999'999)}, }), - ter(tesSUCCESS)) + Ter(tesSUCCESS)) .close(); - // gw must own the auction slot + // gw_ must own the auction slot BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{999'999})); - // 999'999 tokens are burned, only 1 LPToken is owned by gw + // 999'999 tokens are burned, only 1 LPToken is owned by gw_ BEAST_EXPECT(amm.expectBalances(XRP(1'000), USD(1'000), IOUAmount{1})); - // gw owns only 1 LPToken in its balance - BEAST_EXPECT(Number{amm.getLPTokensBalance(gw)} == 1); + // gw_ owns only 1 LPToken in its balance + BEAST_EXPECT(Number{amm.getLPTokensBalance(gw_)} == 1); - // gw attempts to burn the last of its LPTokens in an AMMBid + // gw_ attempts to burn the last of its LPTokens in an AMMBid // transaction. This transaction fails because it would burn all // the remaining LPTokens env(amm.bid({ - .account = gw, + .account = gw_, .bidMin = 1, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); } testAMM([&](AMM& ammAlice, Env& env) { // Invalid flags env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 0, .flags = tfWithdrawAll, }), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Invalid Bid price <= 0 for (auto bid : {0, -100}) { env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = bid, }), - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMax = bid, }), - ter(temBAD_AMOUNT)); + Ter(temBAD_AMOUNT)); } // Invalid Min/Max combination env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 200, .bidMax = 100, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Invalid Account Account const bad("bad"); @@ -2492,8 +2497,8 @@ private: .account = bad, .bidMax = 100, }), - seq(1), - ter(terNO_ACCOUNT)); + Seq(1), + Ter(terNO_ACCOUNT)); // Account is not LP Account const dan("dan"); @@ -2502,49 +2507,49 @@ private: .account = dan, .bidMin = 100, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ .account = dan, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); // Auth account is invalid. env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 100, - .authAccounts = {bob}, + .authAccounts = {bob_}, }), - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); // Invalid Assets env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMax = 100, .assets = {{USD, GBP}}, }), - ter(terNO_AMM)); + Ter(terNO_AMM)); // Invalid Min/Max issue env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMax = STAmount{USD, 100}, }), - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMin = STAmount{USD, 100}, }), - ter(temBAD_AMM_TOKENS)); + Ter(temBAD_AMM_TOKENS)); }); // Invalid AMM testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMax = 100, }), - ter(terNO_AMM)); + Ter(terNO_AMM)); }); // More than four Auth accounts. @@ -2553,62 +2558,62 @@ private: Account const bill("bill"); Account const scott("scott"); Account const james("james"); - env.fund(XRP(1'000), bob, ed, bill, scott, james); + env.fund(XRP(1'000), bob_, ed, bill, scott, james); env.close(); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 100, - .authAccounts = {bob, ed, bill, scott, james}, + .authAccounts = {bob_, ed, bill, scott, james}, }), - ter(temMALFORMED)); + Ter(temMALFORMED)); }); // Bid price exceeds LP owned tokens testAMM([&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(1'000), {USD(100)}, Fund::Acct); - ammAlice.deposit(carol, 1'000'000); - ammAlice.deposit(bob, 10); + fund(env, gw_, {bob_}, XRP(1'000), {USD(100)}, Fund::Acct); + ammAlice.deposit(carol_, 1'000'000); + ammAlice.deposit(bob_, 10); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 1'000'001, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMax = 1'000'001, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 1'000, })); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{1'000})); - // Slot purchase price is more than 1000 but bob only has 10 tokens + // Slot purchase price is more than 1000 but bob_ only has 10 tokens env(ammAlice.bid({ - .account = bob, + .account = bob_, }), - ter(tecAMM_INVALID_TOKENS)); + Ter(tecAMM_INVALID_TOKENS)); }); // Bid all tokens, still own the slot { Env env(*this); - fund(env, gw, {alice, bob}, XRP(1'000), {USD(1'000)}); - AMM amm(env, gw, XRP(10), USD(1'000)); + fund(env, gw_, {alice_, bob_}, XRP(1'000), {USD(1'000)}); + AMM amm(env, gw_, XRP(10), USD(1'000)); auto const lpIssue = amm.lptIssue(); - env.trust(STAmount{lpIssue, 100}, alice); - env.trust(STAmount{lpIssue, 50}, bob); - env(pay(gw, alice, STAmount{lpIssue, 100})); - env(pay(gw, bob, STAmount{lpIssue, 50})); - env(amm.bid({.account = alice, .bidMin = 100})); + env.trust(STAmount{lpIssue, 100}, alice_); + env.trust(STAmount{lpIssue, 50}, bob_); + env(pay(gw_, alice_, STAmount{lpIssue, 100})); + env(pay(gw_, bob_, STAmount{lpIssue, 50})); + env(amm.bid({.account = alice_, .bidMin = 100})); // Alice doesn't have any more tokens, but // she still owns the slot. env(amm.bid({ - .account = bob, + .account = bob_, .bidMax = 50, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); } } @@ -2628,8 +2633,8 @@ private: // Bid 110 tokens. Pay bidMin. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - env(ammAlice.bid({.account = carol, .bidMin = 110})); + ammAlice.deposit(carol_, 1'000'000); + env(ammAlice.bid({.account = carol_, .bidMin = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); // 110 tokens are burned. BEAST_EXPECT( @@ -2643,14 +2648,14 @@ private: // Bid with min/max when the pay price is less than min. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Bid exactly 110. Pay 110 because the pay price is < 110. - env(ammAlice.bid({.account = carol, .bidMin = 110, .bidMax = 110})); + env(ammAlice.bid({.account = carol_, .bidMin = 110, .bidMax = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{10'999'890})); // Bid exactly 180-200. Pay 180 because the pay price is < 180. - env(ammAlice.bid({.account = alice, .bidMin = 180, .bidMax = 200})); + env(ammAlice.bid({.account = alice_, .bidMin = 180, .bidMax = 200})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{180})); BEAST_EXPECT( ammAlice.expectBalances(XRP(11'000), USD(11'000), IOUAmount{10'999'814'5, -1})); @@ -2663,37 +2668,37 @@ private: // Start bid at bidMin 110. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); // Bid, pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})); + env(ammAlice.bid({.account = carol_, .bidMin = 110})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); - ammAlice.deposit(bob, 1'000'000); + fund(env, gw_, {bob_}, {USD(10'000)}, Fund::Acct); + ammAlice.deposit(bob_, 1'000'000); // Bid, pay the computed price. - env(ammAlice.bid({.account = bob})); + env(ammAlice.bid({.account = bob_})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount(1155, -1))); // Bid bidMax fails because the computed price is higher. env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMax = 120, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Bid MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMax = 600})); + env(ammAlice.bid({.account = carol_, .bidMax = 600})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{121'275, -3})); // Bid Min/MaxSlotPrice fails because the computed price is not // in range env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 10, .bidMax = 100, }), - ter(tecAMM_FAILED)); + Ter(tecAMM_FAILED)); // Bid Min/MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMin = 100, .bidMax = 600})); + env(ammAlice.bid({.account = carol_, .bidMin = 100, .bidMax = 600})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{127'33875, -5})); }, std::nullopt, @@ -2704,10 +2709,10 @@ private: // Slot states. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); - fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); - ammAlice.deposit(bob, 1'000'000); + fund(env, gw_, {bob_}, {USD(10'000)}, Fund::Acct); + ammAlice.deposit(bob_, 1'000'000); if (!features[fixAMMv1_3]) { BEAST_EXPECT(ammAlice.expectBalances( @@ -2720,27 +2725,27 @@ private: } // Initial state. Pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + env(ammAlice.bid({.account = carol_, .bidMin = 110})).close(); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); // 1st Interval after close, price for 0th interval. - env(ammAlice.bid({.account = bob})); - env.close(seconds(AUCTION_SLOT_INTERVAL_DURATION + 1)); + env(ammAlice.bid({.account = bob_})); + env.close(seconds(kAUCTION_SLOT_INTERVAL_DURATION + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 1, IOUAmount{1'155, -1})); // 10th Interval after close, price for 1st interval. - env(ammAlice.bid({.account = carol})); - env.close(seconds((10 * AUCTION_SLOT_INTERVAL_DURATION) + 1)); + env(ammAlice.bid({.account = carol_})); + env.close(seconds((10 * kAUCTION_SLOT_INTERVAL_DURATION) + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 10, IOUAmount{121'275, -3})); // 20th Interval (expired) after close, price for 10th interval. - env(ammAlice.bid({.account = bob})); + env(ammAlice.bid({.account = bob_})); env.close( - seconds((AUCTION_SLOT_TIME_INTERVALS * AUCTION_SLOT_INTERVAL_DURATION) + 1)); + seconds((kAUCTION_SLOT_TIME_INTERVALS * kAUCTION_SLOT_INTERVAL_DURATION) + 1)); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, std::nullopt, IOUAmount{127'33875, -5})); // 0 Interval. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + env(ammAlice.bid({.account = carol_, .bidMin = 110})).close(); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, std::nullopt, IOUAmount{110})); // ~321.09 tokens burnt on bidding fees. if (!features[fixAMMv1_3]) @@ -2767,16 +2772,16 @@ private: [&](AMM& ammAlice, Env& env) { Account const dan("dan"); Account const ed("ed"); - fund(env, gw, {bob, dan, ed}, {USD(20'000)}, Fund::Acct); - ammAlice.deposit(bob, 1'000'000); + fund(env, gw_, {bob_, dan, ed}, {USD(20'000)}, Fund::Acct); + ammAlice.deposit(bob_, 1'000'000); ammAlice.deposit(ed, 1'000'000); - ammAlice.deposit(carol, 500'000); + ammAlice.deposit(carol_, 500'000); ammAlice.deposit(dan, 500'000); auto ammTokens = ammAlice.getLPTokensBalance(); env(ammAlice.bid({ - .account = carol, + .account = carol_, .bidMin = 120, - .authAccounts = {bob, ed}, + .authAccounts = {bob_, ed}, })); auto const slotPrice = IOUAmount{5'200}; ammTokens -= slotPrice; @@ -2793,21 +2798,21 @@ private: // Discounted trade for (int i = 0; i < 10; ++i) { - auto tokens = ammAlice.deposit(carol, USD(100)); - ammAlice.withdraw(carol, tokens, USD(0)); - tokens = ammAlice.deposit(bob, USD(100)); - ammAlice.withdraw(bob, tokens, USD(0)); + auto tokens = ammAlice.deposit(carol_, USD(100)); + ammAlice.withdraw(carol_, tokens, USD(0)); + tokens = ammAlice.deposit(bob_, USD(100)); + ammAlice.withdraw(bob_, tokens, USD(0)); tokens = ammAlice.deposit(ed, USD(100)); ammAlice.withdraw(ed, tokens, USD(0)); } - // carol, bob, and ed pay ~0.99USD in fees. + // carol_, bob_, and ed pay ~0.99USD in fees. if (!features[fixAMMv1_1]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'499'00572620545), -11)); BEAST_EXPECT( - env.balance(bob, USD) == STAmount(USD, UINT64_C(18'999'00572616195), -11)); + env.balance(bob_, USD) == STAmount(USD, UINT64_C(18'999'00572616195), -11)); BEAST_EXPECT( env.balance(ed, USD) == STAmount(USD, UINT64_C(18'999'00572611841), -11)); // USD pool is slightly higher because of the fees. @@ -2817,10 +2822,10 @@ private: else { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'499'00572620544), -11)); BEAST_EXPECT( - env.balance(bob, USD) == STAmount(USD, UINT64_C(18'999'00572616194), -11)); + env.balance(bob_, USD) == STAmount(USD, UINT64_C(18'999'00572616194), -11)); BEAST_EXPECT( env.balance(ed, USD) == STAmount(USD, UINT64_C(18'999'0057261184), -10)); // USD pool is slightly higher because of the fees. @@ -2847,7 +2852,7 @@ private: ammAlice.withdraw(dan, tokens, USD(0)); } // dan pays ~9.94USD, which is ~10 times more in fees than - // carol, bob, ed. the discounted fee is 10 times less + // carol_, bob_, ed. the discounted fee is 10 times less // than the trading fee. if (!features[fixAMMv1_1]) { @@ -2857,13 +2862,13 @@ private: BEAST_EXPECT(ammAlice.expectBalances( XRP(13'000), STAmount{USD, UINT64_C(13'012'92609877019), -11}, ammTokens)); // Discounted fee payment - ammAlice.deposit(carol, USD(100)); + ammAlice.deposit(carol_, USD(100)); ammTokens = ammAlice.getLPTokensBalance(); BEAST_EXPECT(ammAlice.expectBalances( XRP(13'000), STAmount{USD, UINT64_C(13'112'92609877019), -11}, ammTokens)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(XRP(110))); env.close(); - // carol pays 100000 drops in fees + // carol_ pays 100000 drops in fees // 99900668XRP swapped in for 100USD BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'100'000'668}, @@ -2900,7 +2905,7 @@ private: ammTokens)); } // Discounted fee payment - ammAlice.deposit(carol, USD(100)); + ammAlice.deposit(carol_, USD(100)); ammTokens = ammAlice.getLPTokensBalance(); if (!features[fixAMMv1_3]) { @@ -2916,9 +2921,9 @@ private: STAmount{USD, UINT64_C(13'112'92609877024), -11}, ammTokens)); } - env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(XRP(110))); env.close(); - // carol pays 100000 drops in fees + // carol_ pays 100000 drops in fees // 99900668XRP swapped in for 100USD if (!features[fixAMMv1_3]) { @@ -2936,10 +2941,10 @@ private: } } // Payment with the trading fee - env(pay(alice, carol, XRP(100)), path(~XRP), sendmax(USD(110))); + env(pay(alice_, carol_, XRP(100)), Path(~XRP), Sendmax(USD(110))); env.close(); - // alice pays ~1.011USD in fees, which is ~10 times more - // than carol's fee + // alice_ pays ~1.011USD in fees, which is ~10 times more + // than carol_'s fee // 100.099431529USD swapped in for 100XRP if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { @@ -2963,33 +2968,33 @@ private: ammTokens)); } // Auction slot expired, no discounted fee - env.close(seconds(TOTAL_TIME_SLOT_SECS + 1)); + env.close(seconds(kTOTAL_TIME_SLOT_SECS + 1)); // clock is parent's based env.close(); if (!features[fixAMMv1_1]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'399'00572620545), -11)); } else if (!features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'399'00572620544), -11)); } ammTokens = ammAlice.getLPTokensBalance(); for (int i = 0; i < 10; ++i) { - auto const tokens = ammAlice.deposit(carol, USD(100)); - ammAlice.withdraw(carol, tokens, USD(0)); + auto const tokens = ammAlice.deposit(carol_, USD(100)); + ammAlice.withdraw(carol_, tokens, USD(0)); } - // carol pays ~9.94USD in fees, which is ~10 times more in + // carol_ pays ~9.94USD in fees, which is ~10 times more in // trading fees vs discounted fee. if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'389'06197177128), -11)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'668}, @@ -2999,7 +3004,7 @@ private: else if (features[fixAMMv1_1] && !features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'389'06197177124), -11)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'668}, @@ -3009,16 +3014,16 @@ private: else { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'389'06197177129), -11)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'671}, STAmount{USD, UINT64_C(13'123'98038488352), -11}, ammTokens)); } - env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(XRP(110))); env.close(); - // carol pays ~1.008XRP in trading fee, which is + // carol_ pays ~1.008XRP in trading fee, which is // ~10 times more than the discounted fee. // 99.815876XRP is swapped in for 100USD if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) @@ -3052,8 +3057,8 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // Bid a tiny amount - auto const tiny = Number{STAmount::cMinValue, STAmount::cMinOffset}; - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{tiny}})); + auto const tiny = Number{STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET}; + env(ammAlice.bid({.account = alice_, .bidMin = IOUAmount{tiny}})); // Auction slot purchase price is equal to the tiny amount // since the minSlotPrice is 0 with no trading fee. BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny})); @@ -3061,8 +3066,8 @@ private: BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'000), ammAlice.tokens())); // Bid the tiny amount env(ammAlice.bid({ - .account = alice, - .bidMin = IOUAmount{STAmount::cMinValue, STAmount::cMinOffset}, + .account = alice_, + .bidMin = IOUAmount{STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET}, })); // Pay slightly higher price BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny * Number{105, -2}})); @@ -3079,18 +3084,18 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMin = IOUAmount{100}, - .authAccounts = {carol}, + .authAccounts = {carol_}, })); - BEAST_EXPECT(ammAlice.expectAuctionSlot({carol})); - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{100}})); + BEAST_EXPECT(ammAlice.expectAuctionSlot({carol_})); + env(ammAlice.bid({.account = alice_, .bidMin = IOUAmount{100}})); BEAST_EXPECT(ammAlice.expectAuctionSlot({})); Account const bob("bob"); Account const dan("dan"); fund(env, {bob, dan}, XRP(1'000)); env(ammAlice.bid({ - .account = alice, + .account = alice_, .bidMin = IOUAmount{100}, .authAccounts = {bob, dan}, })); @@ -3104,24 +3109,24 @@ private: // Bid all tokens, still own the slot and trade at a discount { Env env(*this, features); - fund(env, gw, {alice, bob}, XRP(2'000), {USD(2'000)}); - AMM amm(env, gw, XRP(1'000), USD(1'010), false, 1'000); + fund(env, gw_, {alice_, bob_}, XRP(2'000), {USD(2'000)}); + AMM amm(env, gw_, XRP(1'000), USD(1'010), false, 1'000); auto const lpIssue = amm.lptIssue(); - env.trust(STAmount{lpIssue, 500}, alice); - env.trust(STAmount{lpIssue, 50}, bob); - env(pay(gw, alice, STAmount{lpIssue, 500})); - env(pay(gw, bob, STAmount{lpIssue, 50})); + env.trust(STAmount{lpIssue, 500}, alice_); + env.trust(STAmount{lpIssue, 50}, bob_); + env(pay(gw_, alice_, STAmount{lpIssue, 500})); + env(pay(gw_, bob_, STAmount{lpIssue, 50})); // Alice doesn't have anymore lp tokens - env(amm.bid({.account = alice, .bidMin = 500})); + env(amm.bid({.account = alice_, .bidMin = 500})); BEAST_EXPECT(amm.expectAuctionSlot(100, 0, IOUAmount{500})); - BEAST_EXPECT(expectHolding(env, alice, STAmount{lpIssue, 0})); + BEAST_EXPECT(expectHolding(env, alice_, STAmount{lpIssue, 0})); // But trades with the discounted fee since she still owns the slot. // Alice pays 10011 drops in fees - env(pay(alice, bob, USD(10)), path(~USD), sendmax(XRP(11))); + env(pay(alice_, bob_, USD(10)), Path(~USD), Sendmax(XRP(11))); BEAST_EXPECT(amm.expectBalances( XRPAmount{1'010'010'011}, USD(1'000), IOUAmount{1'004'487'562112089, -9})); // Bob pays the full fee ~0.1USD - env(pay(bob, alice, XRP(10)), path(~XRP), sendmax(USD(11))); + env(pay(bob_, alice_, XRP(10)), Path(~XRP), Sendmax(USD(11))); if (!features[fixAMMv1_1]) { BEAST_EXPECT(amm.expectBalances( @@ -3143,37 +3148,37 @@ private: Env env(*this, features); auto const baseFee = env.current()->fees().base; - fund(env, gw, {alice, bob}, XRP(2'000), {USD(2'000)}); - AMM amm(env, gw, XRP(1'000), USD(1'010), false, 1'000); - Json::Value const tx = amm.bid({.account = alice, .bidMin = 500}); + fund(env, gw_, {alice_, bob_}, XRP(2'000), {USD(2'000)}); + AMM amm(env, gw_, XRP(1'000), USD(1'010), false, 1'000); + json::Value const tx = amm.bid({.account = alice_, .bidMin = 500}); { - auto jtx = env.jt(tx, seq(1), fee(baseFee)); + auto jtx = env.jt(tx, Seq(1), Fee(baseFee)); env.app().config().features.erase(featureAMM); PreflightContext const pfCtx( - env.app(), *jtx.stx, env.current()->rules(), tapNONE, env.journal); + env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal); auto pf = Transactor::invokePreflight(pfCtx); BEAST_EXPECT(pf == temDISABLED); env.app().config().features.insert(featureAMM); } { - auto jtx = env.jt(tx, seq(1), fee(baseFee)); + auto jtx = env.jt(tx, Seq(1), Fee(baseFee)); jtx.jv["TxnSignature"] = "deadbeef"; jtx.stx = env.ust(jtx); PreflightContext const pfCtx( - env.app(), *jtx.stx, env.current()->rules(), tapNONE, env.journal); + env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal); auto pf = Transactor::invokePreflight(pfCtx); BEAST_EXPECT(!isTesSuccess(pf)); } { - auto jtx = env.jt(tx, seq(1), fee(baseFee)); + auto jtx = env.jt(tx, Seq(1), Fee(baseFee)); jtx.jv["Asset2"]["currency"] = "XRP"; jtx.jv["Asset2"].removeMember("issuer"); jtx.stx = env.ust(jtx); PreflightContext const pfCtx( - env.app(), *jtx.stx, env.current()->rules(), tapNONE, env.journal); + env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal); auto pf = Transactor::invokePreflight(pfCtx); BEAST_EXPECT(pf == temBAD_AMM_TOKENS); } @@ -3190,139 +3195,139 @@ private: // Can't pay into AMM account. // Can't pay out since there is no keys - for (auto const& acct : {gw, alice}) + for (auto const& acct : {gw_, alice_}) { { Env env(*this); - fund(env, gw, {alice, carol}, XRP(1'000), {USD(100)}); + fund(env, gw_, {alice_, carol_}, XRP(1'000), {USD(100)}); // XRP balance is below reserve AMM const ammAlice(env, acct, XRP(10), USD(10)); // Pay below reserve - env(pay(carol, ammAlice.ammAccount(), XRP(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(10)), Ter(tecNO_PERMISSION)); // Pay above reserve - env(pay(carol, ammAlice.ammAccount(), XRP(300)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(300)), Ter(tecNO_PERMISSION)); // Pay IOU - env(pay(carol, ammAlice.ammAccount(), USD(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), USD(10)), Ter(tecNO_PERMISSION)); } { Env env(*this); - fund(env, gw, {alice, carol}, XRP(10'000'000), {USD(10'000)}); + fund(env, gw_, {alice_, carol_}, XRP(10'000'000), {USD(10'000)}); // XRP balance is above reserve AMM const ammAlice(env, acct, XRP(1'000'000), USD(100)); // Pay below reserve - env(pay(carol, ammAlice.ammAccount(), XRP(10)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(10)), Ter(tecNO_PERMISSION)); // Pay above reserve - env(pay(carol, ammAlice.ammAccount(), XRP(1'000'000)), ter(tecNO_PERMISSION)); + env(pay(carol_, ammAlice.ammAccount(), XRP(1'000'000)), Ter(tecNO_PERMISSION)); } } // Can't pay into AMM with escrow. testAMM([&](AMM& ammAlice, Env& env) { auto const baseFee = env.current()->fees().base; - env(escrow::create(carol, ammAlice.ammAccount(), XRP(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(carol_, ammAlice.ammAccount(), XRP(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); }); // Can't pay into AMM with paychan. testAMM([&](AMM& ammAlice, Env& env) { - auto const pk = carol.pk(); + auto const pk = carol_.pk(); auto const settleDelay = 100s; NetClock::time_point const cancelAfter = env.current()->header().parentCloseTime + 200s; env(paychan::create( - carol, ammAlice.ammAccount(), XRP(1'000), settleDelay, pk, cancelAfter), - ter(tecNO_PERMISSION)); + carol_, ammAlice.ammAccount(), XRP(1'000), settleDelay, pk, cancelAfter), + Ter(tecNO_PERMISSION)); }); // Can't pay into AMM with checks. testAMM([&](AMM& ammAlice, Env& env) { env(check::create(env.master.id(), ammAlice.ammAccount(), XRP(100)), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); }); // Pay amounts close to one side of the pool testAMM( [&](AMM& ammAlice, Env& env) { // Can't consume whole pool - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, XRP(100)), - path(~XRP), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, XRP(100)), + Path(~XRP), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); // Overflow - env(pay(alice, carol, STAmount{USD, UINT64_C(99'999999999), -9}), - path(~USD), - sendmax(XRP(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, STAmount{USD, UINT64_C(999'99999999), -8}), - path(~USD), - sendmax(XRP(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, STAmount{xrpIssue(), 99'999'999}), - path(~XRP), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{USD, UINT64_C(99'999999999), -9}), + Path(~USD), + Sendmax(XRP(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{USD, UINT64_C(999'99999999), -8}), + Path(~USD), + Sendmax(XRP(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{xrpIssue(), 99'999'999}), + Path(~XRP), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); // Sender doesn't have enough funds - env(pay(alice, carol, USD(99.99)), - path(~USD), - sendmax(XRP(1'000'000'000)), - ter(tecPATH_PARTIAL)); - env(pay(alice, carol, STAmount{xrpIssue(), 99'990'000}), - path(~XRP), - sendmax(USD(1'000'000'000)), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(99.99)), + Path(~USD), + Sendmax(XRP(1'000'000'000)), + Ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, STAmount{xrpIssue(), 99'990'000}), + Path(~XRP), + Sendmax(USD(1'000'000'000)), + Ter(tecPATH_PARTIAL)); }, {{XRP(100), USD(100)}}); // Globally frozen testAMM([&](AMM& ammAlice, Env& env) { - env(fset(gw, asfGlobalFreeze)); + env(fset(gw_, asfGlobalFreeze)); env.close(); - env(pay(alice, carol, USD(1)), - path(~USD), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(XRP(10)), - ter(tecPATH_DRY)); - env(pay(alice, carol, XRP(1)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(USD(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, USD(1)), + Path(~USD), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(XRP(10)), + Ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(USD(10)), + Ter(tecPATH_DRY)); }); // Individually frozen AMM testAMM([&](AMM& ammAlice, Env& env) { env(trust( - gw, STAmount{Issue{gw["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); + gw_, STAmount{Issue{gw_["USD"].currency, ammAlice.ammAccount()}, 0}, tfSetFreeze)); env.close(); - env(pay(alice, carol, USD(1)), - path(~USD), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(XRP(10)), - ter(tecPATH_DRY)); - env(pay(alice, carol, XRP(1)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect), - sendmax(USD(10)), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, USD(1)), + Path(~USD), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(XRP(10)), + Ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect), + Sendmax(USD(10)), + Ter(tecPATH_DRY)); }); // Individually frozen accounts testAMM([&](AMM& ammAlice, Env& env) { - env(trust(gw, carol["USD"](0), tfSetFreeze)); - env(trust(gw, alice["USD"](0), tfSetFreeze)); + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); + env(trust(gw_, alice_["USD"](0), tfSetFreeze)); env.close(); - env(pay(alice, carol, XRP(1)), - path(~XRP), - sendmax(USD(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(tecPATH_DRY)); + env(pay(alice_, carol_, XRP(1)), + Path(~XRP), + Sendmax(USD(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(tecPATH_DRY)); }); } @@ -3341,19 +3346,19 @@ private: // Force one path with tfNoRippleDirect. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); - env(pay(bob, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect)); + env(pay(bob_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // Initial balance 30,000 + 100 - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -3363,16 +3368,16 @@ private: // Payment 100USD for 100XRP, use default path. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); - env(pay(bob, carol, USD(100)), sendmax(XRP(100))); + env(pay(bob_, carol_, USD(100)), Sendmax(XRP(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // Initial balance 30,000 + 100 - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -3383,16 +3388,16 @@ private: // both default path and path, activeStrands has one path. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); - env(pay(bob, carol, USD(100)), path(~USD), sendmax(XRP(100))); + env(pay(bob_, carol_, USD(100)), Path(~USD), Sendmax(XRP(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // Initial balance 30,000 + 100 - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); // Initial balance 30,000 - 100(sendmax) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -3402,30 +3407,30 @@ private: // Payment with limitQuality set. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); // Pays 10USD for 10XRP. A larger payment of ~99.11USD/100XRP // would have been sent has it not been for limitQuality. - env(pay(bob, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(bob_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'010), USD(10'000), ammAlice.tokens())); // Initial balance 30,000 + 10(limited by limitQuality) - BEAST_EXPECT(expectHolding(env, carol, USD(30'010))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'010))); // Initial balance 30,000 - 10(limited by limitQuality) - 10(tx // fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(10) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(10) - txFee(env, 1))); // Fails because of limitQuality. Would have sent // ~98.91USD/110XRP has it not been for limitQuality. - env(pay(bob, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), - ter(tecPATH_DRY)); + env(pay(bob_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality), + Ter(tecPATH_DRY)); env.close(); }, {{XRP(10'000), USD(10'010)}}, @@ -3436,24 +3441,24 @@ private: // Payment with limitQuality and transfer fee set. testAMM( [&](AMM& ammAlice, Env& env) { - env(rate(gw, 1.1)); + env(rate(gw_, 1.1)); env.close(); - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); // Pays 10USD for 10XRP. A larger payment of ~99.11USD/100XRP // would have been sent has it not been for limitQuality and // the transfer fee. - env(pay(bob, carol, USD(100)), - path(~USD), - sendmax(XRP(110)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(bob_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(110)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'010), USD(10'000), ammAlice.tokens())); // 10USD - 10% transfer fee BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(30'009'09090909091), -11})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(30'009'09090909091), -11})); BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(10) - txfee(env, 1))); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(10) - txFee(env, 1))); }, {{XRP(10'000), USD(10'010)}}, 0, @@ -3463,13 +3468,13 @@ private: // Fail when partial payment is not set. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(jtx::XRP(30'000), bob); + env.fund(jtx::XRP(30'000), bob_); env.close(); - env(pay(bob, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(bob_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); }, {{XRP(10'000), USD(10'000)}}, 0, @@ -3482,29 +3487,29 @@ private: // is taken from the offer. { Env env(*this, features); - fund(env, gw, {alice, carol}, {USD(30'000), EUR(30'000)}, Fund::All); + fund(env, gw_, {alice_, carol_}, {USD(30'000), EUR(30'000)}, Fund::All); env.close(); - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); - auto ammEUR_XRP = AMM(env, alice, XRP(10'000), EUR(10'000)); - auto ammUSD_EUR = AMM(env, alice, EUR(10'000), USD(10'000)); - env(offer(alice, XRP(101), USD(100)), txflags(tfPassive)); + auto ammEurXrp = AMM(env, alice_, XRP(10'000), EUR(10'000)); + auto ammUsdEur = AMM(env, alice_, EUR(10'000), USD(10'000)); + env(offer(alice_, XRP(101), USD(100)), Txflags(tfPassive)); env.close(); - env(pay(bob, carol, USD(100)), - path(~EUR, ~USD), - sendmax(XRP(102)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, USD(100)), + Path(~EUR, ~USD), + Sendmax(XRP(102)), + Txflags(tfPartialPayment)); env.close(); - BEAST_EXPECT(ammEUR_XRP.expectBalances( + BEAST_EXPECT(ammEurXrp.expectBalances( XRPAmount(10'030'082'730), STAmount(EUR, UINT64_C(9'970'007498125468), -12), - ammEUR_XRP.tokens())); + ammEurXrp.tokens())); if (!features[fixAMMv1_1]) { - BEAST_EXPECT(ammUSD_EUR.expectBalances( + BEAST_EXPECT(ammUsdEur.expectBalances( STAmount(USD, UINT64_C(9'970'097277662122), -12), STAmount(EUR, UINT64_C(10'029'99250187452), -11), - ammUSD_EUR.tokens())); + ammUsdEur.tokens())); // fixReducedOffersV2 changes the expected results slightly. Amounts const expectedAmounts = env.closed()->rules().enabled(fixReducedOffersV2) @@ -3512,14 +3517,14 @@ private: : Amounts{ XRPAmount(30'201'749), STAmount(USD, UINT64_C(29'90272233787818), -14)}; - BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{expectedAmounts}})); } else { - BEAST_EXPECT(ammUSD_EUR.expectBalances( + BEAST_EXPECT(ammUsdEur.expectBalances( STAmount(USD, UINT64_C(9'970'097277662172), -12), STAmount(EUR, UINT64_C(10'029'99250187452), -11), - ammUSD_EUR.tokens())); + ammUsdEur.tokens())); // fixReducedOffersV2 changes the expected results slightly. Amounts const expectedAmounts = env.closed()->rules().enabled(fixReducedOffersV2) @@ -3527,15 +3532,15 @@ private: : Amounts{ XRPAmount(30'201'749), STAmount(USD, UINT64_C(29'90272233782840), -14)}; - BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{expectedAmounts}})); } // Initial 30,000 + 100 - BEAST_EXPECT(expectHolding(env, carol, STAmount{USD, 30'100})); + BEAST_EXPECT(expectHolding(env, carol_, STAmount{USD, 30'100})); // Initial 1,000 - 30082730(AMM pool) - 70798251(offer) - 10(tx fee) BEAST_EXPECT(expectLedgerEntryRoot( env, - bob, - XRP(1'000) - XRPAmount{30'082'730} - XRPAmount{70'798'251} - txfee(env, 1))); + bob_, + XRP(1'000) - XRPAmount{30'082'730} - XRPAmount{70'798'251} - txFee(env, 1))); } // Default path (with AMM) has a better quality than a non-default path. @@ -3543,19 +3548,19 @@ private: // path ~49XRP/49USD. The rest is taken from the offer. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); + env.fund(XRP(1'000), bob_); env.close(); - env.trust(EUR(2'000), alice); + env.trust(EUR(2'000), alice_); env.close(); - env(pay(gw, alice, EUR(1'000))); - env(offer(alice, XRP(101), EUR(100)), txflags(tfPassive)); + env(pay(gw_, alice_, EUR(1'000))); + env(offer(alice_, XRP(101), EUR(100)), Txflags(tfPassive)); env.close(); - env(offer(alice, EUR(100), USD(100)), txflags(tfPassive)); + env(offer(alice_, EUR(100), USD(100)), Txflags(tfPassive)); env.close(); - env(pay(bob, carol, USD(100)), - path(~EUR, ~USD), - sendmax(XRP(102)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, USD(100)), + Path(~EUR, ~USD), + Sendmax(XRP(102)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(10'050'238'637), @@ -3563,7 +3568,7 @@ private: ammAlice.tokens())); BEAST_EXPECT(expectOffers( env, - alice, + alice_, 2, {{Amounts{XRPAmount(50'487'378), STAmount(EUR, UINT64_C(49'98750312422), -11)}, Amounts{ @@ -3571,13 +3576,13 @@ private: STAmount(USD, UINT64_C(49'98750312422), -11)}}})); // Initial 30,000 + 99.99999999999 BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(30'099'99999999999), -11})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(30'099'99999999999), -11})); // Initial 1,000 - 50238637(AMM pool) - 50512622(offer) - 10(tx // fee) BEAST_EXPECT(expectLedgerEntryRoot( env, - bob, - XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - txfee(env, 1))); + bob_, + XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - txFee(env, 1))); }, std::nullopt, 0, @@ -3588,18 +3593,18 @@ private: // remaining amount is consumed by the offer. testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {USD(100)}, Fund::Acct); + fund(env, gw_, {bob_}, {USD(100)}, Fund::Acct); env.close(); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); + env(offer(bob_, XRP(100), USD(100)), Txflags(tfPassive)); env.close(); - env(pay(alice, carol, USD(200)), sendmax(XRP(200)), txflags(tfPartialPayment)); + env(pay(alice_, carol_, USD(200)), Sendmax(XRP(200)), Txflags(tfPartialPayment)); env.close(); if (!features[fixAMMv1_1]) { BEAST_EXPECT( ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // Initial 30,000 + 200 - BEAST_EXPECT(expectHolding(env, carol, USD(30'200))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'200))); } else { @@ -3608,16 +3613,16 @@ private: STAmount(USD, UINT64_C(10'000'00000000001), -11), ammAlice.tokens())); BEAST_EXPECT(expectHolding( - env, carol, STAmount(USD, UINT64_C(30'199'99999999999), -11))); + env, carol_, STAmount(USD, UINT64_C(30'199'99999999999), -11))); } // Initial 30,000 - 10000(AMM pool LP) - 100(AMM offer) - // - 100(offer) - 10(tx fee) - one reserve BEAST_EXPECT(expectLedgerEntryRoot( env, - alice, + alice_, XRP(30'000) - XRP(10'000) - XRP(100) - XRP(100) - ammCrtFee(env) - - txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -3629,32 +3634,32 @@ private: // Remaining amount is consumed by AMM. { Env env(*this, features); - fund(env, gw, {alice, bob, carol}, XRP(20'000), {USD(2'000)}); + fund(env, gw_, {alice_, bob_, carol_}, XRP(20'000), {USD(2'000)}); env.close(); - env(offer(bob, XRP(50), USD(150)), txflags(tfPassive)); + env(offer(bob_, XRP(50), USD(150)), Txflags(tfPassive)); env.close(); - AMM const ammAlice(env, alice, XRP(1'000), USD(1'050)); - env(pay(alice, carol, USD(200)), sendmax(XRP(200)), txflags(tfPartialPayment)); + AMM const ammAlice(env, alice_, XRP(1'000), USD(1'050)); + env(pay(alice_, carol_, USD(200)), Sendmax(XRP(200)), Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(1'050), USD(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(2'200))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, USD(2'200))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); } // Offer crossing XRP/IOU testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {USD(1'000)}, Fund::Acct); + fund(env, gw_, {bob_}, {USD(1'000)}, Fund::Acct); env.close(); - env(offer(bob, USD(100), XRP(100))); + env(offer(bob_, USD(100), XRP(100))); env.close(); BEAST_EXPECT(ammAlice.expectBalances(XRP(10'100), USD(10'000), ammAlice.tokens())); // Initial 1,000 + 100 - BEAST_EXPECT(expectHolding(env, bob, USD(1'100))); + BEAST_EXPECT(expectHolding(env, bob_, USD(1'100))); // Initial 30,000 - 100(offer) - 10(tx fee) BEAST_EXPECT( - expectLedgerEntryRoot(env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + expectLedgerEntryRoot(env, bob_, XRP(30'000) - XRP(100) - txFee(env, 1))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); }, {{XRP(10'000), USD(10'100)}}, 0, @@ -3665,21 +3670,21 @@ private: // Single path AMM offer testAMM( [&](AMM& ammAlice, Env& env) { - env(rate(gw, 1.25)); + env(rate(gw_, 1.25)); env.close(); // This offer succeeds to cross pre- and post-amendment // because the strand's out amount is small enough to match // limitQuality value and limitOut() function in StrandFlow // doesn't require an adjustment to out value. - env(offer(carol, EUR(100), GBP(100))); + env(offer(carol_, EUR(100), GBP(100))); env.close(); // No transfer fee BEAST_EXPECT(ammAlice.expectBalances(GBP(1'100), EUR(1'000), ammAlice.tokens())); // Initial 30,000 - 100(offer) - 25% transfer fee - BEAST_EXPECT(expectHolding(env, carol, GBP(29'875))); + BEAST_EXPECT(expectHolding(env, carol_, GBP(29'875))); // Initial 30,000 + 100(offer) - BEAST_EXPECT(expectHolding(env, carol, EUR(30'100))); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectHolding(env, carol_, EUR(30'100))); + BEAST_EXPECT(expectOffers(env, bob_, 0)); }, {{GBP(1'000), EUR(1'100)}}, 0, @@ -3688,9 +3693,9 @@ private: // Single-path AMM offer testAMM( [&](AMM& amm, Env& env) { - env(rate(gw, 1.001)); + env(rate(gw_, 1.001)); env.close(); - env(offer(carol, XRP(100), USD(55))); + env(offer(carol_, XRP(100), USD(55))); env.close(); if (!features[fixAMMv1_1]) { @@ -3702,7 +3707,7 @@ private: // with lower quality. Consequently, the offer fails // to cross. BEAST_EXPECT(amm.expectBalances(XRP(1'000), USD(500), amm.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{XRP(100), USD(55)}}})); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{XRP(100), USD(55)}}})); } else { @@ -3720,12 +3725,12 @@ private: // Offer ~91XRP/49.99USD BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, {{Amounts{XRPAmount{9'090'909}, STAmount{USD, 4'99999995, -8}}}})); // Carol pays 0.1% fee on ~50USD =~ 0.05USD BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(29'949'94999999494), -11)); } }, @@ -3735,21 +3740,21 @@ private: {features}); testAMM( [&](AMM& amm, Env& env) { - env(rate(gw, 1.001)); + env(rate(gw_, 1.001)); env.close(); - env(offer(carol, XRP(10), USD(5.5))); + env(offer(carol_, XRP(10), USD(5.5))); env.close(); if (!features[fixAMMv1_1]) { BEAST_EXPECT(amm.expectBalances( XRP(990), STAmount{USD, UINT64_C(505'050505050505), -12}, amm.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } else { BEAST_EXPECT(amm.expectBalances( XRP(990), STAmount{USD, UINT64_C(505'0505050505051), -13}, amm.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } }, {{XRP(1'000), USD(500)}}, @@ -3760,8 +3765,8 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { Account const ed("ed"); - fund(env, gw, {bob, ed}, XRP(30'000), {GBP(2'000), EUR(2'000)}, Fund::Acct); - env(rate(gw, 1.25)); + fund(env, gw_, {bob_, ed}, XRP(30'000), {GBP(2'000), EUR(2'000)}, Fund::Acct); + env(rate(gw_, 1.25)); env.close(); // The auto-bridge is worse quality than AMM, is not consumed // first and initially forces multi-path AMM offer generation. @@ -3769,10 +3774,10 @@ private: // is less than the auto-bridge offers quality. Auto-bridge // offers are consumed afterward. Then the behavior is // different pre-amendment and post-amendment. - env(offer(bob, GBP(10), XRP(10)), txflags(tfPassive)); - env(offer(ed, XRP(10), EUR(10)), txflags(tfPassive)); + env(offer(bob_, GBP(10), XRP(10)), Txflags(tfPassive)); + env(offer(ed, XRP(10), EUR(10)), Txflags(tfPassive)); env.close(); - env(offer(carol, EUR(100), GBP(100))); + env(offer(carol_, EUR(100), GBP(100))); env.close(); if (!features[fixAMMv1_1]) { @@ -3789,24 +3794,24 @@ private: // Consumed offer ~49.32EUR/49.32GBP BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, {Amounts{ STAmount{EUR, UINT64_C(50'684828792831), -12}, STAmount{GBP, UINT64_C(50'684828792831), -12}}})); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); BEAST_EXPECT(expectOffers(env, ed, 0)); // Initial 30,000 - ~47.06(offers = 37.06(AMM) + 10(LOB)) // * 1.25 // = 58.825 = ~29941.17 - // carol bought ~72.93EUR at the cost of ~70.68GBP + // carol_ bought ~72.93EUR at the cost of ~70.68GBP // the offer is partially consumed BEAST_EXPECT(expectHolding( - env, carol, STAmount{GBP, UINT64_C(29'941'16770347333), -11})); + env, carol_, STAmount{GBP, UINT64_C(29'941'16770347333), -11})); // Initial 30,000 + ~49.3(offers = 39.3(AMM) + 10(LOB)) BEAST_EXPECT(expectHolding( - env, carol, STAmount{EUR, UINT64_C(30'049'31517120716), -11})); + env, carol_, STAmount{EUR, UINT64_C(30'049'31517120716), -11})); } else { @@ -3824,27 +3829,27 @@ private: // Consumed offer ~72.93EUR/72.93GBP BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, {Amounts{ STAmount{EUR, UINT64_C(27'06583722134028), -14}, STAmount{GBP, UINT64_C(27'06583722134028), -14}}})); - BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, bob_, 0)); BEAST_EXPECT(expectOffers(env, ed, 0)); // Initial 30,000 - ~70.68(offers = 60.68(AMM) + 10(LOB)) // * 1.25 // = 88.35 = ~29911.64 - // carol bought ~72.93EUR at the cost of ~70.68GBP + // carol_ bought ~72.93EUR at the cost of ~70.68GBP // the offer is partially consumed BEAST_EXPECT(expectHolding( - env, carol, STAmount{GBP, UINT64_C(29'911'64396400896), -11})); + env, carol_, STAmount{GBP, UINT64_C(29'911'64396400896), -11})); // Initial 30,000 + ~72.93(offers = 62.93(AMM) + 10(LOB)) BEAST_EXPECT(expectHolding( - env, carol, STAmount{EUR, UINT64_C(30'072'93416277865), -11})); + env, carol_, STAmount{EUR, UINT64_C(30'072'93416277865), -11})); } // Initial 2000 + 10 = 2010 - BEAST_EXPECT(expectHolding(env, bob, GBP(2'010))); + BEAST_EXPECT(expectHolding(env, bob_, GBP(2'010))); // Initial 2000 - 10 * 1.25 = 1987.5 BEAST_EXPECT(expectHolding(env, ed, EUR(1'987.5))); }, @@ -3857,22 +3862,22 @@ private: // Scenario: // Bob sends 125GBP to pay 80EUR to Carol // Payment execution: - // bob's 125GBP/1.25 = 100GBP + // bob_'s 125GBP/1.25 = 100GBP // 100GBP/100EUR AMM offer - // 100EUR/1.25 = 80EUR paid to carol + // 100EUR/1.25 = 80EUR paid to carol_ testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, {GBP(200), EUR(200)}, Fund::Acct); - env(rate(gw, 1.25)); + fund(env, gw_, {bob_}, {GBP(200), EUR(200)}, Fund::Acct); + env(rate(gw_, 1.25)); env.close(); - env(pay(bob, carol, EUR(100)), - path(~EUR), - sendmax(GBP(125)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, EUR(100)), + Path(~EUR), + Sendmax(GBP(125)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(ammAlice.expectBalances(GBP(1'100), EUR(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectHolding(env, bob, GBP(75))); - BEAST_EXPECT(expectHolding(env, carol, EUR(30'080))); + BEAST_EXPECT(expectHolding(env, bob_, GBP(75))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(30'080))); }, {{GBP(1'000), EUR(1'100)}}, 0, @@ -3886,34 +3891,34 @@ private: // Ed's offer 200EUR/200USD // Bob sends 195.3125CAN to pay 100USD to Carol // Payment execution: - // bob's 195.3125CAN/1.25 = 156.25CAN -> dan's offer + // bob_'s 195.3125CAN/1.25 = 156.25CAN -> dan's offer // 156.25CAN/156.25GBP 156.25GBP/1.25 = 125GBP -> AMM's offer // 125GBP/125EUR 125EUR/1.25 = 100EUR -> ed's offer - // 100EUR/100USD 100USD/1.25 = 80USD paid to carol + // 100EUR/100USD 100USD/1.25 = 80USD paid to carol_ testAMM( [&](AMM& ammAlice, Env& env) { Account const dan("dan"); Account const ed("ed"); - auto const CAN = gw["CAN"]; - fund(env, gw, {dan}, {CAN(200), GBP(200)}, Fund::Acct); - fund(env, gw, {ed}, {EUR(200), USD(200)}, Fund::Acct); - fund(env, gw, {bob}, {CAN(195.3125)}, Fund::Acct); - env(trust(carol, USD(100))); - env(rate(gw, 1.25)); + auto const can = gw_["CAN"]; + fund(env, gw_, {dan}, {can(200), GBP(200)}, Fund::Acct); + fund(env, gw_, {ed}, {EUR(200), USD(200)}, Fund::Acct); + fund(env, gw_, {bob_}, {can(195.3125)}, Fund::Acct); + env(trust(carol_, USD(100))); + env(rate(gw_, 1.25)); env.close(); - env(offer(dan, CAN(200), GBP(200))); + env(offer(dan, can(200), GBP(200))); env(offer(ed, EUR(200), USD(200))); env.close(); - env(pay(bob, carol, USD(100)), - path(~GBP, ~EUR, ~USD), - sendmax(CAN(195.3125)), - txflags(tfPartialPayment)); + env(pay(bob_, carol_, USD(100)), + Path(~GBP, ~EUR, ~USD), + Sendmax(can(195.3125)), + Txflags(tfPartialPayment)); env.close(); - BEAST_EXPECT(expectHolding(env, bob, CAN(0))); - BEAST_EXPECT(expectHolding(env, dan, CAN(356.25), GBP(43.75))); + BEAST_EXPECT(expectHolding(env, bob_, can(0))); + BEAST_EXPECT(expectHolding(env, dan, can(356.25), GBP(43.75))); BEAST_EXPECT(ammAlice.expectBalances(GBP(10'125), EUR(10'000), ammAlice.tokens())); BEAST_EXPECT(expectHolding(env, ed, EUR(300), USD(100))); - BEAST_EXPECT(expectHolding(env, carol, USD(80))); + BEAST_EXPECT(expectHolding(env, carol_, USD(80))); }, {{GBP(10'000), EUR(10'125)}}, 0, @@ -3923,26 +3928,26 @@ private: // Pay amounts close to one side of the pool testAMM( [&](AMM& ammAlice, Env& env) { - env(pay(alice, carol, USD(99.99)), - path(~USD), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, XRP(100)), - path(~XRP), - sendmax(USD(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); - env(pay(alice, carol, STAmount{xrpIssue(), 99'999'900}), - path(~XRP), - sendmax(USD(1)), - txflags(tfPartialPayment), - ter(tesSUCCESS)); + env(pay(alice_, carol_, USD(99.99)), + Path(~USD), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, USD(100)), + Path(~USD), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, XRP(100)), + Path(~XRP), + Sendmax(USD(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); + env(pay(alice_, carol_, STAmount{xrpIssue(), 99'999'900}), + Path(~XRP), + Sendmax(USD(1)), + Txflags(tfPartialPayment), + Ter(tesSUCCESS)); }, {{XRP(100), USD(100)}}, 0, @@ -3952,69 +3957,69 @@ private: // Multiple paths/steps { Env env(*this, features); - auto const ETH = gw["ETH"]; + auto const eth = gw_["ETH"]; fund( env, - gw, - {alice}, + gw_, + {alice_}, XRP(100'000), - {EUR(50'000), BTC(50'000), ETH(50'000), USD(50'000)}); - fund(env, gw, {carol, bob}, XRP(1'000), {USD(200)}, Fund::Acct); - AMM const xrp_eur(env, alice, XRP(10'100), EUR(10'000)); - AMM const eur_btc(env, alice, EUR(10'000), BTC(10'200)); - AMM const btc_usd(env, alice, BTC(10'100), USD(10'000)); - AMM const xrp_usd(env, alice, XRP(10'150), USD(10'200)); - AMM const xrp_eth(env, alice, XRP(10'000), ETH(10'100)); - AMM const eth_eur(env, alice, ETH(10'900), EUR(11'000)); - AMM const eur_usd(env, alice, EUR(10'100), USD(10'000)); - env(pay(bob, carol, USD(100)), - path(~EUR, ~BTC, ~USD), - path(~USD), - path(~ETH, ~EUR, ~USD), - sendmax(XRP(200))); + {EUR(50'000), BTC(50'000), eth(50'000), USD(50'000)}); + fund(env, gw_, {carol_, bob_}, XRP(1'000), {USD(200)}, Fund::Acct); + AMM const xrpEur(env, alice_, XRP(10'100), EUR(10'000)); + AMM const eurBtc(env, alice_, EUR(10'000), BTC(10'200)); + AMM const btcUsd(env, alice_, BTC(10'100), USD(10'000)); + AMM const xrpUsd(env, alice_, XRP(10'150), USD(10'200)); + AMM const xrpEth(env, alice_, XRP(10'000), eth(10'100)); + AMM const ethEur(env, alice_, eth(10'900), EUR(11'000)); + AMM const eurUsd(env, alice_, EUR(10'100), USD(10'000)); + env(pay(bob_, carol_, USD(100)), + Path(~EUR, ~BTC, ~USD), + Path(~USD), + Path(~eth, ~EUR, ~USD), + Sendmax(XRP(200))); if (!features[fixAMMv1_1]) { // XRP-ETH-EUR-USD // This path provides ~26.06USD/26.2XRP - BEAST_EXPECT(xrp_eth.expectBalances( + BEAST_EXPECT(xrpEth.expectBalances( XRPAmount(10'026'208'900), - STAmount{ETH, UINT64_C(10'073'65779244494), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'926'34220755506), -11}, + STAmount{eth, UINT64_C(10'073'65779244494), -11}, + xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + STAmount{eth, UINT64_C(10'926'34220755506), -11}, STAmount{EUR, UINT64_C(10'973'54232078752), -11}, - eth_eur.tokens())); - BEAST_EXPECT(eur_usd.expectBalances( + ethEur.tokens())); + BEAST_EXPECT(eurUsd.expectBalances( STAmount{EUR, UINT64_C(10'126'45767921248), -11}, STAmount{USD, UINT64_C(9'973'93151712086), -11}, - eur_usd.tokens())); + eurUsd.tokens())); // XRP-USD path // This path provides ~73.9USD/74.1XRP - BEAST_EXPECT(xrp_usd.expectBalances( + BEAST_EXPECT(xrpUsd.expectBalances( XRPAmount(10'224'106'246), STAmount{USD, UINT64_C(10'126'06848287914), -11}, - xrp_usd.tokens())); + xrpUsd.tokens())); } else { - BEAST_EXPECT(xrp_eth.expectBalances( + BEAST_EXPECT(xrpEth.expectBalances( XRPAmount(10'026'208'900), - STAmount{ETH, UINT64_C(10'073'65779244461), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'926'34220755539), -11}, + STAmount{eth, UINT64_C(10'073'65779244461), -11}, + xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + STAmount{eth, UINT64_C(10'926'34220755539), -11}, STAmount{EUR, UINT64_C(10'973'5423207872), -10}, - eth_eur.tokens())); - BEAST_EXPECT(eur_usd.expectBalances( + ethEur.tokens())); + BEAST_EXPECT(eurUsd.expectBalances( STAmount{EUR, UINT64_C(10'126'4576792128), -10}, STAmount{USD, UINT64_C(9'973'93151712057), -11}, - eur_usd.tokens())); + eurUsd.tokens())); // XRP-USD path // This path provides ~73.9USD/74.1XRP - BEAST_EXPECT(xrp_usd.expectBalances( + BEAST_EXPECT(xrpUsd.expectBalances( XRPAmount(10'224'106'246), STAmount{USD, UINT64_C(10'126'06848287943), -11}, - xrp_usd.tokens())); + xrpUsd.tokens())); } // XRP-EUR-BTC-USD @@ -4023,100 +4028,96 @@ private: // shows a different distribution: // XRP-EUR-BTC-USD 11.6USD/11.64XRP, XRP-USD 60.7USD/60.8XRP, // XRP-ETH-EUR-USD 27.6USD/27.6XRP - BEAST_EXPECT(xrp_eur.expectBalances(XRP(10'100), EUR(10'000), xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances(EUR(10'000), BTC(10'200), eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances(BTC(10'100), USD(10'000), btc_usd.tokens())); + BEAST_EXPECT(xrpEur.expectBalances(XRP(10'100), EUR(10'000), xrpEur.tokens())); + BEAST_EXPECT(eurBtc.expectBalances(EUR(10'000), BTC(10'200), eurBtc.tokens())); + BEAST_EXPECT(btcUsd.expectBalances(BTC(10'100), USD(10'000), btcUsd.tokens())); - BEAST_EXPECT(expectHolding(env, carol, USD(300))); + BEAST_EXPECT(expectHolding(env, carol_, USD(300))); } // Dependent AMM { Env env(*this, features); - auto const ETH = gw["ETH"]; + auto const eth = gw_["ETH"]; fund( env, - gw, - {alice}, + gw_, + {alice_}, XRP(40'000), - {EUR(50'000), BTC(50'000), ETH(50'000), USD(50'000)}); - fund(env, gw, {carol, bob}, XRP(1000), {USD(200)}, Fund::Acct); - AMM const xrp_eur(env, alice, XRP(10'100), EUR(10'000)); - AMM const eur_btc(env, alice, EUR(10'000), BTC(10'200)); - AMM const btc_usd(env, alice, BTC(10'100), USD(10'000)); - AMM const xrp_eth(env, alice, XRP(10'000), ETH(10'100)); - AMM const eth_eur(env, alice, ETH(10'900), EUR(11'000)); - env(pay(bob, carol, USD(100)), - path(~EUR, ~BTC, ~USD), - path(~ETH, ~EUR, ~BTC, ~USD), - sendmax(XRP(200))); + {EUR(50'000), BTC(50'000), eth(50'000), USD(50'000)}); + fund(env, gw_, {carol_, bob_}, XRP(1000), {USD(200)}, Fund::Acct); + AMM const xrpEur(env, alice_, XRP(10'100), EUR(10'000)); + AMM const eurBtc(env, alice_, EUR(10'000), BTC(10'200)); + AMM const btcUsd(env, alice_, BTC(10'100), USD(10'000)); + AMM const xrpEth(env, alice_, XRP(10'000), eth(10'100)); + AMM const ethEur(env, alice_, eth(10'900), EUR(11'000)); + env(pay(bob_, carol_, USD(100)), + Path(~EUR, ~BTC, ~USD), + Path(~eth, ~EUR, ~BTC, ~USD), + Sendmax(XRP(200))); if (!features[fixAMMv1_1]) { // XRP-EUR-BTC-USD path provides ~17.8USD/~18.7XRP // XRP-ETH-EUR-BTC-USD path provides ~82.2USD/82.4XRP - BEAST_EXPECT(xrp_eur.expectBalances( + BEAST_EXPECT(xrpEur.expectBalances( XRPAmount(10'118'738'472), STAmount{EUR, UINT64_C(9'981'544436337968), -12}, - xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances( + xrpEur.tokens())); + BEAST_EXPECT(eurBtc.expectBalances( STAmount{EUR, UINT64_C(10'101'16096785173), -11}, STAmount{BTC, UINT64_C(10'097'91426968066), -11}, - eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances( - STAmount{BTC, UINT64_C(10'202'08573031934), -11}, - USD(9'900), - btc_usd.tokens())); - BEAST_EXPECT(xrp_eth.expectBalances( + eurBtc.tokens())); + BEAST_EXPECT(btcUsd.expectBalances( + STAmount{BTC, UINT64_C(10'202'08573031934), -11}, USD(9'900), btcUsd.tokens())); + BEAST_EXPECT(xrpEth.expectBalances( XRPAmount(10'082'446'397), - STAmount{ETH, UINT64_C(10'017'41072778012), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'982'58927221988), -11}, + STAmount{eth, UINT64_C(10'017'41072778012), -11}, + xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + STAmount{eth, UINT64_C(10'982'58927221988), -11}, STAmount{EUR, UINT64_C(10'917'2945958103), -10}, - eth_eur.tokens())); + ethEur.tokens())); } else { - BEAST_EXPECT(xrp_eur.expectBalances( + BEAST_EXPECT(xrpEur.expectBalances( XRPAmount(10'118'738'472), STAmount{EUR, UINT64_C(9'981'544436337923), -12}, - xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances( + xrpEur.tokens())); + BEAST_EXPECT(eurBtc.expectBalances( STAmount{EUR, UINT64_C(10'101'16096785188), -11}, STAmount{BTC, UINT64_C(10'097'91426968059), -11}, - eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances( - STAmount{BTC, UINT64_C(10'202'08573031941), -11}, - USD(9'900), - btc_usd.tokens())); - BEAST_EXPECT(xrp_eth.expectBalances( + eurBtc.tokens())); + BEAST_EXPECT(btcUsd.expectBalances( + STAmount{BTC, UINT64_C(10'202'08573031941), -11}, USD(9'900), btcUsd.tokens())); + BEAST_EXPECT(xrpEth.expectBalances( XRPAmount(10'082'446'397), - STAmount{ETH, UINT64_C(10'017'41072777996), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'982'58927222004), -11}, + STAmount{eth, UINT64_C(10'017'41072777996), -11}, + xrpEth.tokens())); + BEAST_EXPECT(ethEur.expectBalances( + STAmount{eth, UINT64_C(10'982'58927222004), -11}, STAmount{EUR, UINT64_C(10'917'2945958102), -10}, - eth_eur.tokens())); + ethEur.tokens())); } - BEAST_EXPECT(expectHolding(env, carol, USD(300))); + BEAST_EXPECT(expectHolding(env, carol_, USD(300))); } // AMM offers limit // Consuming 30 CLOB offers, results in hitting 30 AMM offers limit. testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - fund(env, gw, {bob}, {EUR(400)}, Fund::TokenOnly); - env(trust(alice, EUR(200))); + env.fund(XRP(1'000), bob_); + fund(env, gw_, {bob_}, {EUR(400)}, Fund::TokenOnly); + env(trust(alice_, EUR(200))); for (int i = 0; i < 30; ++i) - env(offer(alice, EUR(1.0 + (0.01 * i)), XRP(1))); + env(offer(alice_, EUR(1.0 + (0.01 * i)), XRP(1))); // This is worse quality offer than 30 offers above. // It will not be consumed because of AMM offers limit. - env(offer(alice, EUR(140), XRP(100))); - env(pay(bob, carol, USD(100)), - path(~XRP, ~USD), - sendmax(EUR(400)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(offer(alice_, EUR(140), XRP(100))); + env(pay(bob_, carol_, USD(100)), + Path(~XRP, ~USD), + Sendmax(EUR(400)), + Txflags(tfPartialPayment | tfNoRippleDirect)); if (!features[fixAMMv1_1]) { // Carol gets ~29.91USD because of the AMM offers limit @@ -4125,7 +4126,7 @@ private: STAmount{USD, UINT64_C(9'970'089730807577), -12}, ammAlice.tokens())); BEAST_EXPECT(expectHolding( - env, carol, STAmount{USD, UINT64_C(30'029'91026919241), -11})); + env, carol_, STAmount{USD, UINT64_C(30'029'91026919241), -11})); } else { @@ -4134,9 +4135,9 @@ private: STAmount{USD, UINT64_C(9'970'089730807827), -12}, ammAlice.tokens())); BEAST_EXPECT(expectHolding( - env, carol, STAmount{USD, UINT64_C(30'029'91026919217), -11})); + env, carol_, STAmount{USD, UINT64_C(30'029'91026919217), -11})); } - BEAST_EXPECT(expectOffers(env, alice, 1, {{{EUR(140), XRP(100)}}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{{EUR(140), XRP(100)}}})); }, std::nullopt, 0, @@ -4145,33 +4146,33 @@ private: // This payment is fulfilled testAMM( [&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - fund(env, gw, {bob}, {EUR(400)}, Fund::TokenOnly); - env(trust(alice, EUR(200))); + env.fund(XRP(1'000), bob_); + fund(env, gw_, {bob_}, {EUR(400)}, Fund::TokenOnly); + env(trust(alice_, EUR(200))); for (int i = 0; i < 29; ++i) - env(offer(alice, EUR(1.0 + (0.01 * i)), XRP(1))); + env(offer(alice_, EUR(1.0 + (0.01 * i)), XRP(1))); // This is worse quality offer than 30 offers above. // It will not be consumed because of AMM offers limit. - env(offer(alice, EUR(140), XRP(100))); - env(pay(bob, carol, USD(100)), - path(~XRP, ~USD), - sendmax(EUR(400)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(offer(alice_, EUR(140), XRP(100))); + env(pay(bob_, carol_, USD(100)), + Path(~XRP, ~USD), + Sendmax(EUR(400)), + Txflags(tfPartialPayment | tfNoRippleDirect)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'101'010'102}, USD(9'900), ammAlice.tokens())); if (!features[fixAMMv1_1]) { // Carol gets ~100USD BEAST_EXPECT(expectHolding( - env, carol, STAmount{USD, UINT64_C(30'099'99999999999), -11})); + env, carol_, STAmount{USD, UINT64_C(30'099'99999999999), -11})); } else { - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); } BEAST_EXPECT(expectOffers( env, - alice, + alice_, 1, {{{STAmount{EUR, UINT64_C(39'1858572), -7}, XRPAmount{27'989'898}}}})); }, @@ -4184,10 +4185,10 @@ private: // quality and is consumed first. { Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(30'000), {USD(30'000)}); - env(offer(bob, XRP(100), USD(100.001))); - AMM const ammAlice(env, alice, XRP(10'000), USD(10'100)); - env(offer(carol, USD(100), XRP(100))); + fund(env, gw_, {alice_, carol_, bob_}, XRP(30'000), {USD(30'000)}); + env(offer(bob_, XRP(100), USD(100.001))); + AMM const ammAlice(env, alice_, XRP(10'000), USD(10'100)); + env(offer(carol_, USD(100), XRP(100))); if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( @@ -4196,7 +4197,7 @@ private: ammAlice.tokens())); BEAST_EXPECT(expectOffers( env, - bob, + bob_, 1, {{{XRPAmount{50'074'629}, STAmount{USD, UINT64_C(50'07513050698), -11}}}})); } @@ -4208,24 +4209,24 @@ private: ammAlice.tokens())); BEAST_EXPECT(expectOffers( env, - bob, + bob_, 1, {{{XRPAmount{50'074'628}, STAmount{USD, UINT64_C(50'07512950697), -11}}}})); - BEAST_EXPECT(expectHolding(env, carol, USD(30'100))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'100))); } } // Individually frozen account testAMM( [&](AMM& ammAlice, Env& env) { - env(trust(gw, carol["USD"](0), tfSetFreeze)); - env(trust(gw, alice["USD"](0), tfSetFreeze)); + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); + env(trust(gw_, alice_["USD"](0), tfSetFreeze)); env.close(); - env(pay(alice, carol, USD(1)), - path(~USD), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(tesSUCCESS)); + env(pay(alice_, carol_, USD(1)), + Path(~USD), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(tesSUCCESS)); }, std::nullopt, 0, @@ -4249,58 +4250,60 @@ private: STAmount{token1, 5'000'000}, 0); // Carol places an order to buy LPTokens - env(offer(carol, STAmount{token1, 5'000'000}, priceXRP)); + env(offer(carol_, STAmount{token1, 5'000'000}, priceXRP)); // Alice places an order to sell LPTokens - env(offer(alice, priceXRP, STAmount{token1, 5'000'000})); + env(offer(alice_, priceXRP, STAmount{token1, 5'000'000})); // Pool's LPTokens balance doesn't change BEAST_EXPECT(ammAlice.expectBalances(XRP(10'000), USD(10'000), IOUAmount{10'000'000})); // Carol is Liquidity Provider - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, IOUAmount{5'000'000})); // Carol votes - ammAlice.vote(carol, 1'000); + ammAlice.vote(carol_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(500)); - ammAlice.vote(carol, 0); + ammAlice.vote(carol_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); // Carol bids - env(ammAlice.bid({.account = carol, .bidMin = 100})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{4'999'900})); + env(ammAlice.bid({.account = carol_, .bidMin = 100})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{4'999'900})); BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{100})); - BEAST_EXPECT(accountBalance(env, carol) == std::to_string(22500000000 - (4 * baseFee))); + BEAST_EXPECT( + accountBalance(env, carol_) == std::to_string(22500000000 - (4 * baseFee))); priceXRP = ammAssetOut( STAmount{XRPAmount{10'000'000'000}}, STAmount{token1, 9'999'900}, STAmount{token1, 4'999'900}, 0); // Carol withdraws - ammAlice.withdrawAll(carol, XRP(0)); - BEAST_EXPECT(accountBalance(env, carol) == std::to_string(29999949999 - (5 * baseFee))); + ammAlice.withdrawAll(carol_, XRP(0)); + BEAST_EXPECT( + accountBalance(env, carol_) == std::to_string(29999949999 - (5 * baseFee))); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'000'000'000} - priceXRP, USD(10'000), IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(alice, IOUAmount{5'000'000})); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + BEAST_EXPECT(ammAlice.expectLPTokens(alice_, IOUAmount{5'000'000})); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); }); // Offer crossing with two AMM LPTokens. testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - fund(env, gw, {alice, carol}, {EUR(10'000)}, Fund::TokenOnly); - AMM ammAlice1(env, alice, XRP(10'000), EUR(10'000)); - ammAlice1.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); + fund(env, gw_, {alice_, carol_}, {EUR(10'000)}, Fund::TokenOnly); + AMM ammAlice1(env, alice_, XRP(10'000), EUR(10'000)); + ammAlice1.deposit(carol_, 1'000'000); auto const token1 = ammAlice.lptIssue(); auto const token2 = ammAlice1.lptIssue(); - env(offer(alice, STAmount{token1, 100}, STAmount{token2, 100}), txflags(tfPassive)); + env(offer(alice_, STAmount{token1, 100}, STAmount{token2, 100}), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1)); - env(offer(carol, STAmount{token2, 100}, STAmount{token1, 100})); + BEAST_EXPECT(expectOffers(env, alice_, 1)); + env(offer(carol_, STAmount{token2, 100}, STAmount{token1, 100})); env.close(); BEAST_EXPECT( - expectHolding(env, alice, STAmount{token1, 10'000'100}) && - expectHolding(env, alice, STAmount{token2, 9'999'900})); + expectHolding(env, alice_, STAmount{token1, 10'000'100}) && + expectHolding(env, alice_, STAmount{token2, 9'999'900})); BEAST_EXPECT( - expectHolding(env, carol, STAmount{token2, 1'000'100}) && - expectHolding(env, carol, STAmount{token1, 999'900})); - BEAST_EXPECT(expectOffers(env, alice, 0) && expectOffers(env, carol, 0)); + expectHolding(env, carol_, STAmount{token2, 1'000'100}) && + expectHolding(env, carol_, STAmount{token1, 999'900})); + BEAST_EXPECT(expectOffers(env, alice_, 0) && expectOffers(env, carol_, 0)); }); // LPs pay LPTokens directly. Must trust set because the trust line @@ -4308,30 +4311,30 @@ private: // trust line. testAMM([&](AMM& ammAlice, Env& env) { auto const token1 = ammAlice.lptIssue(); - env.trust(STAmount{token1, 2'000'000}, carol); + env.trust(STAmount{token1, 2'000'000}, carol_); env.close(); - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); BEAST_EXPECT( - ammAlice.expectLPTokens(alice, IOUAmount{10'000'000, 0}) && - ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); + ammAlice.expectLPTokens(alice_, IOUAmount{10'000'000, 0}) && + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); // Pool balance doesn't change, only tokens moved from // one line to another. - env(pay(alice, carol, STAmount{token1, 100})); + env(pay(alice_, carol_, STAmount{token1, 100})); env.close(); BEAST_EXPECT( // Alice initial token1 10,000,000 - 100 - ammAlice.expectLPTokens(alice, IOUAmount{9'999'900, 0}) && + ammAlice.expectLPTokens(alice_, IOUAmount{9'999'900, 0}) && // Carol initial token1 1,000,000 + 100 - ammAlice.expectLPTokens(carol, IOUAmount{1'000'100, 0})); + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'100, 0})); - env.trust(STAmount{token1, 20'000'000}, alice); + env.trust(STAmount{token1, 20'000'000}, alice_); env.close(); - env(pay(carol, alice, STAmount{token1, 100})); + env(pay(carol_, alice_, STAmount{token1, 100})); env.close(); // Back to the original balance BEAST_EXPECT( - ammAlice.expectLPTokens(alice, IOUAmount{10'000'000, 0}) && - ammAlice.expectLPTokens(carol, IOUAmount{1'000'000, 0})); + ammAlice.expectLPTokens(alice_, IOUAmount{10'000'000, 0}) && + ammAlice.expectLPTokens(carol_, IOUAmount{1'000'000, 0})); }); } @@ -4339,7 +4342,7 @@ private: testAmendment() { testcase("Amendment"); - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; FeatureBitset const noAMM{all - featureAMM}; FeatureBitset const noNumber{all - fixUniversalNumber}; FeatureBitset const noAMMAndNumber{all - featureAMM - fixUniversalNumber}; @@ -4348,16 +4351,16 @@ private: for (auto const& feature : {noAMM, noNumber, noAMMAndNumber}) { Env env{*this, feature}; - fund(env, gw, {alice}, {USD(1'000)}, Fund::All); - AMM amm(env, alice, XRP(1'000), USD(1'000), ter(temDISABLED)); + fund(env, gw_, {alice_}, {USD(1'000)}, Fund::All); + AMM amm(env, alice_, XRP(1'000), USD(1'000), Ter(temDISABLED)); - env(amm.bid({.bidMax = 1000}), ter(temMALFORMED)); - env(amm.bid({}), ter(temDISABLED)); - amm.vote(VoteArg{.tfee = 100, .err = ter(temDISABLED)}); - amm.withdraw(WithdrawArg{.tokens = 100, .err = ter(temMALFORMED)}); - amm.withdraw(WithdrawArg{.err = ter(temDISABLED)}); - amm.deposit(DepositArg{.asset1In = USD(100), .err = ter(temDISABLED)}); - amm.ammDelete(alice, ter(temDISABLED)); + env(amm.bid({.bidMax = 1000}), Ter(temMALFORMED)); + env(amm.bid({}), Ter(temDISABLED)); + amm.vote(VoteArg{.tfee = 100, .err = Ter(temDISABLED)}); + amm.withdraw(WithdrawArg{.tokens = 100, .err = Ter(temMALFORMED)}); + amm.withdraw(WithdrawArg{.err = Ter(temDISABLED)}); + amm.deposit(DepositArg{.asset1In = USD(100), .err = Ter(temDISABLED)}); + amm.ammDelete(alice_, Ter(temDISABLED)); } } @@ -4395,35 +4398,35 @@ private: // for 0 limit. { Env env(*this); - auto const A = Account("A"); - auto const B = Account("B"); - auto const TSTA = A["TST"]; - auto const TSTB = B["TST"]; - auto const C = Account("C"); - auto const D = Account("D"); + auto const a = Account("A"); + auto const b = Account("B"); + auto const tsta = a["TST"]; + auto const tstb = b["TST"]; + auto const c = Account("C"); + auto const d = Account("D"); - env.fund(XRP(10'000), A); - env.fund(XRP(10'000), B); - env.fund(XRP(10'000), C); - env.fund(XRP(10'000), D); + env.fund(XRP(10'000), a); + env.fund(XRP(10'000), b); + env.fund(XRP(10'000), c); + env.fund(XRP(10'000), d); - env.trust(TSTA(10'000), C); - env.trust(TSTB(10'000), C); - env(pay(A, C, TSTA(10'000))); - env(pay(B, C, TSTB(10'000))); - AMM const amm(env, C, TSTA(5'000), TSTB(5'000)); - auto const ammIss = Issue(TSTA.currency, amm.ammAccount()); + env.trust(tsta(10'000), c); + env.trust(tstb(10'000), c); + env(pay(a, c, tsta(10'000))); + env(pay(b, c, tstb(10'000))); + AMM const amm(env, c, tsta(5'000), tstb(5'000)); + auto const ammIss = Issue(tsta.currency, amm.ammAccount()); // Can TrustSet only for AMM LP tokens - env(trust(D, STAmount{ammIss, 10'000}), ter(tecNO_PERMISSION)); + env(trust(d, STAmount{ammIss, 10'000}), Ter(tecNO_PERMISSION)); env.close(); // The payment would fail because of above, but check just in case - env(pay(C, D, STAmount{ammIss, 10}), - sendmax(TSTA(100)), - path(amm.ammAccount()), - txflags(tfPartialPayment | tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(c, d, STAmount{ammIss, 10}), + Sendmax(tsta(100)), + Path(amm.ammAccount()), + Txflags(tfPartialPayment | tfNoRippleDirect), + Ter(tecPATH_DRY)); } } @@ -4433,23 +4436,23 @@ private: testcase("AMMAndCLOB, offer quality change"); using namespace jtx; auto const gw = Account("gw"); - auto const TST = gw["TST"]; - auto const LP1 = Account("LP1"); - auto const LP2 = Account("LP2"); + auto const tst = gw["TST"]; + auto const lP1 = Account("LP1"); + auto const lP2 = Account("LP2"); auto prep = [&](auto const& offerCb, auto const& expectCb) { Env env(*this, features); env.fund(XRP(30'000'000'000), gw); - env(offer(gw, XRP(11'500'000'000), TST(1'000'000'000))); + env(offer(gw, XRP(11'500'000'000), tst(1'000'000'000))); - env.fund(XRP(10'000), LP1); - env.fund(XRP(10'000), LP2); - env(offer(LP1, TST(25), XRPAmount(287'500'000))); + env.fund(XRP(10'000), lP1); + env.fund(XRP(10'000), lP2); + env(offer(lP1, tst(25), XRPAmount(287'500'000))); // Either AMM or CLOB offer offerCb(env); - env(offer(LP2, TST(25), XRPAmount(287'500'000))); + env(offer(lP2, tst(25), XRPAmount(287'500'000))); expectCb(env); }; @@ -4461,10 +4464,10 @@ private: std::string lp2TakerPays; // Execute with AMM first prep( - [&](Env& env) { AMM const amm(env, LP1, TST(25), XRP(250)); }, + [&](Env& env) { AMM const amm(env, lP1, tst(25), XRP(250)); }, [&](Env& env) { - lp2TSTBalance = getAccountLines(env, LP2, TST)["lines"][0u]["balance"].asString(); - auto const offer = getAccountOffers(env, LP2)["offers"][0u]; + lp2TSTBalance = getAccountLines(env, lP2, tst)["lines"][0u]["balance"].asString(); + auto const offer = getAccountOffers(env, lP2)["offers"][0u]; lp2TakerGets = offer["taker_gets"].asString(); lp2TakerPays = offer["taker_pays"]["value"].asString(); }); @@ -4474,25 +4477,25 @@ private: if (!features[fixAMMv1_1]) { env(offer( - LP1, + lP1, XRPAmount{18'095'133}, - STAmount{TST, UINT64_C(1'68737984885388), -14}), - txflags(tfPassive)); + STAmount{tst, UINT64_C(1'68737984885388), -14}), + Txflags(tfPassive)); } else { env(offer( - LP1, + lP1, XRPAmount{18'095'132}, - STAmount{TST, UINT64_C(1'68737976189735), -14}), - txflags(tfPassive)); + STAmount{tst, UINT64_C(1'68737976189735), -14}), + Txflags(tfPassive)); } }, [&](Env& env) { BEAST_EXPECT( lp2TSTBalance == - getAccountLines(env, LP2, TST)["lines"][0u]["balance"].asString()); - auto const offer = getAccountOffers(env, LP2)["offers"][0u]; + getAccountLines(env, lP2, tst)["lines"][0u]["balance"].asString()); + auto const offer = getAccountOffers(env, lP2)["offers"][0u]; BEAST_EXPECT(lp2TakerGets == offer["taker_gets"].asString()); BEAST_EXPECT(lp2TakerPays == offer["taker_pays"]["value"].asString()); }); @@ -4508,25 +4511,25 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // No fee - ammAlice.deposit(carol, USD(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000})); - ammAlice.withdrawAll(carol, USD(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + ammAlice.deposit(carol_, USD(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000})); + ammAlice.withdrawAll(carol_, USD(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{0})); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); // Set fee to 1% - ammAlice.vote(alice, 1'000); + ammAlice.vote(alice_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); // Carol gets fewer LPToken ~994, because of the single deposit // fee - ammAlice.deposit(carol, USD(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{994'981155689671, -12})); - BEAST_EXPECT(expectHolding(env, carol, USD(27'000))); + ammAlice.deposit(carol_, USD(3'000)); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{994'981155689671, -12})); + BEAST_EXPECT(expectHolding(env, carol_, USD(27'000))); // Set fee to 0 - ammAlice.vote(alice, 0); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.vote(alice_, 0); + ammAlice.withdrawAll(carol_, USD(0)); // Carol gets back less than the original deposit BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(29'994'96220068281), -11})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(29'994'96220068281), -11})); }, {{USD(1'000), EUR(1'000)}}, 0, @@ -4537,15 +4540,15 @@ private: // 100USD with EP not to exceed 0.1 (AssetIn/TokensOut). 1% fee. testAMM( [&](AMM& ammAlice, Env& env) { - auto const balance = env.balance(carol, USD); + auto const balance = env.balance(carol_, USD); auto tokensFee = - ammAlice.deposit(carol, USD(1'000), std::nullopt, STAmount{USD, 1, -1}); - auto const deposit = balance - env.balance(carol, USD); - ammAlice.withdrawAll(carol, USD(0)); - ammAlice.vote(alice, 0); + ammAlice.deposit(carol_, USD(1'000), std::nullopt, STAmount{USD, 1, -1}); + auto const deposit = balance - env.balance(carol_, USD); + ammAlice.withdrawAll(carol_, USD(0)); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.deposit(carol, deposit); - // carol pays ~2008 LPTokens in fees or ~0.5% of the no-fee + auto const tokensNoFee = ammAlice.deposit(carol_, deposit); + // carol_ pays ~2008 LPTokens in fees or ~0.5% of the no-fee // LPTokens BEAST_EXPECT(tokensFee == IOUAmount(485'636'0611129, -7)); BEAST_EXPECT(tokensNoFee == IOUAmount(487'644'85901109, -8)); @@ -4559,15 +4562,15 @@ private: // 200USD with EP not to exceed 0.002020 (AssetIn/TokensOut). 1% fee testAMM( [&](AMM& ammAlice, Env& env) { - auto const balance = env.balance(carol, USD); + auto const balance = env.balance(carol_, USD); auto const tokensFee = - ammAlice.deposit(carol, USD(200), std::nullopt, STAmount{USD, 2020, -6}); - auto const deposit = balance - env.balance(carol, USD); - ammAlice.withdrawAll(carol, USD(0)); - ammAlice.vote(alice, 0); + ammAlice.deposit(carol_, USD(200), std::nullopt, STAmount{USD, 2020, -6}); + auto const deposit = balance - env.balance(carol_, USD); + ammAlice.withdrawAll(carol_, USD(0)); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.deposit(carol, deposit); - // carol pays ~475 LPTokens in fees or ~0.5% of the no-fee + auto const tokensNoFee = ammAlice.deposit(carol_, deposit); + // carol_ pays ~475 LPTokens in fees or ~0.5% of the no-fee // LPTokens BEAST_EXPECT(tokensFee == IOUAmount(98'000'00000002, -8)); BEAST_EXPECT(tokensNoFee == IOUAmount(98'475'81871545, -8)); @@ -4581,17 +4584,17 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // No fee - ammAlice.deposit(carol, USD(3'000)); + ammAlice.deposit(carol_, USD(3'000)); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{1'000})); - BEAST_EXPECT(expectHolding(env, carol, USD(27'000))); + BEAST_EXPECT(ammAlice.expectLPTokens(carol_, IOUAmount{1'000})); + BEAST_EXPECT(expectHolding(env, carol_, USD(27'000))); // Set fee to 1% - ammAlice.vote(alice, 1'000); + ammAlice.vote(alice_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); // Single withdrawal. Carol gets ~5USD less than deposited. - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.withdrawAll(carol_, USD(0)); BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(29'994'97487437186), -11})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(29'994'97487437186), -11})); }, {{USD(1'000), EUR(1'000)}}, 0, @@ -4601,10 +4604,10 @@ private: // Withdraw with EPrice limit, 1% fee. testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + ammAlice.deposit(carol_, 1'000'000); auto const tokensFee = - ammAlice.withdraw(carol, USD(100), std::nullopt, IOUAmount{520, 0}); - // carol withdraws ~1,443.44USD + ammAlice.withdraw(carol_, USD(100), std::nullopt, IOUAmount{520, 0}); + // carol_ withdraws ~1,443.44USD auto const balanceAfterWithdraw = [&]() { if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { @@ -4617,33 +4620,33 @@ private: return STAmount(USD, UINT64_C(30'443'43891402713), -11); }(); - BEAST_EXPECT(env.balance(carol, USD) == balanceAfterWithdraw); + BEAST_EXPECT(env.balance(carol_, USD) == balanceAfterWithdraw); // Set to original pool size auto const deposit = balanceAfterWithdraw - USD(29'000); - ammAlice.deposit(carol, deposit); + ammAlice.deposit(carol_, deposit); // fee 0% - ammAlice.vote(alice, 0); + ammAlice.vote(alice_, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); - auto const tokensNoFee = ammAlice.withdraw(carol, deposit); + auto const tokensNoFee = ammAlice.withdraw(carol_, deposit); if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(30'443'43891402717), -11)); } else if (features[fixAMMv1_1] && !features[fixAMMv1_3]) { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(30'443'43891402716), -11)); } else { BEAST_EXPECT( - env.balance(carol, USD) == + env.balance(carol_, USD) == STAmount(USD, UINT64_C(30'443'43891402713), -11)); } - // carol pays ~4008 LPTokens in fees or ~0.5% of the no-fee + // carol_ pays ~4008 LPTokens in fees or ~0.5% of the no-fee // LPTokens if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { @@ -4667,36 +4670,36 @@ private: // Payment, 1% fee testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(1'000), {USD(1'000), EUR(1'000)}, Fund::Acct); + fund(env, gw_, {bob_}, XRP(1'000), {USD(1'000), EUR(1'000)}, Fund::Acct); // Alice contributed 1010EUR and 1000USD to the pool - BEAST_EXPECT(expectHolding(env, alice, EUR(28'990))); - BEAST_EXPECT(expectHolding(env, alice, USD(29'000))); - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + BEAST_EXPECT(expectHolding(env, alice_, EUR(28'990))); + BEAST_EXPECT(expectHolding(env, alice_, USD(29'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); // Carol pays to Alice with no fee - env(pay(carol, alice, EUR(10)), - path(~EUR), - sendmax(USD(10)), - txflags(tfNoRippleDirect)); + env(pay(carol_, alice_, EUR(10)), + Path(~EUR), + Sendmax(USD(10)), + Txflags(tfNoRippleDirect)); env.close(); // Alice has 10EUR more and Carol has 10USD less - BEAST_EXPECT(expectHolding(env, alice, EUR(29'000))); - BEAST_EXPECT(expectHolding(env, alice, USD(29'000))); - BEAST_EXPECT(expectHolding(env, carol, USD(29'990))); + BEAST_EXPECT(expectHolding(env, alice_, EUR(29'000))); + BEAST_EXPECT(expectHolding(env, alice_, USD(29'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'990))); // Set fee to 1% - ammAlice.vote(alice, 1'000); + ammAlice.vote(alice_, 1'000); BEAST_EXPECT(ammAlice.expectTradingFee(1'000)); // Bob pays to Carol with 1% fee - env(pay(bob, carol, USD(10)), - path(~USD), - sendmax(EUR(15)), - txflags(tfNoRippleDirect)); + env(pay(bob_, carol_, USD(10)), + Path(~USD), + Sendmax(EUR(15)), + Txflags(tfNoRippleDirect)); env.close(); // Bob sends 10.1~EUR to pay 10USD BEAST_EXPECT( - expectHolding(env, bob, STAmount{EUR, UINT64_C(989'8989898989899), -13})); + expectHolding(env, bob_, STAmount{EUR, UINT64_C(989'8989898989899), -13})); // Carol got 10USD - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); BEAST_EXPECT(ammAlice.expectBalances( USD(1'000), STAmount{EUR, UINT64_C(1'010'10101010101), -11}, @@ -4711,27 +4714,27 @@ private: testAMM( [&](AMM& ammAlice, Env& env) { // No fee - env(offer(carol, EUR(10), USD(10))); + env(offer(carol_, EUR(10), USD(10))); env.close(); - BEAST_EXPECT(expectHolding(env, carol, USD(29'990))); - BEAST_EXPECT(expectHolding(env, carol, EUR(30'010))); + BEAST_EXPECT(expectHolding(env, carol_, USD(29'990))); + BEAST_EXPECT(expectHolding(env, carol_, EUR(30'010))); // Change pool composition back - env(offer(carol, USD(10), EUR(10))); + env(offer(carol_, USD(10), EUR(10))); env.close(); // Set fee to 0.5% - ammAlice.vote(alice, 500); + ammAlice.vote(alice_, 500); BEAST_EXPECT(ammAlice.expectTradingFee(500)); - env(offer(carol, EUR(10), USD(10))); + env(offer(carol_, EUR(10), USD(10))); env.close(); // Alice gets fewer ~4.97EUR for ~5.02USD, the difference goes // to the pool BEAST_EXPECT( - expectHolding(env, carol, STAmount{USD, UINT64_C(29'995'02512562814), -11})); + expectHolding(env, carol_, STAmount{USD, UINT64_C(29'995'02512562814), -11})); BEAST_EXPECT( - expectHolding(env, carol, STAmount{EUR, UINT64_C(30'004'97487437186), -11})); + expectHolding(env, carol_, STAmount{EUR, UINT64_C(30'004'97487437186), -11})); BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, {{Amounts{ STAmount{EUR, UINT64_C(5'025125628140703), -15}, @@ -4763,26 +4766,26 @@ private: { Env env(*this, features); Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); - env(offer(carol, EUR(5), USD(5))); - AMM const ammAlice(env, alice, USD(1'005), EUR(1'000)); - env(pay(bob, ed, USD(10)), path(~USD), sendmax(EUR(15)), txflags(tfNoRippleDirect)); + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); + env(offer(carol_, EUR(5), USD(5))); + AMM const ammAlice(env, alice_, USD(1'005), EUR(1'000)); + env(pay(bob_, ed, USD(10)), Path(~USD), Sendmax(EUR(15)), Txflags(tfNoRippleDirect)); BEAST_EXPECT(expectHolding(env, ed, USD(2'010))); if (!features[fixAMMv1_1]) { - BEAST_EXPECT(expectHolding(env, bob, EUR(1'990))); + BEAST_EXPECT(expectHolding(env, bob_, EUR(1'990))); BEAST_EXPECT(ammAlice.expectBalances(USD(1'000), EUR(1'005), ammAlice.tokens())); } else { BEAST_EXPECT( - expectHolding(env, bob, STAmount(EUR, UINT64_C(1989'999999999999), -12))); + expectHolding(env, bob_, STAmount(EUR, UINT64_C(1989'999999999999), -12))); BEAST_EXPECT(ammAlice.expectBalances( USD(1'000), STAmount(EUR, UINT64_C(1005'000000000001), -12), ammAlice.tokens())); } - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. Same as above but with 0.25% @@ -4790,16 +4793,16 @@ private: { Env env(*this, features); Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); - env(offer(carol, EUR(5), USD(5))); + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); + env(offer(carol_, EUR(5), USD(5))); // Set 0.25% fee - AMM const ammAlice(env, alice, USD(1'005), EUR(1'000), false, 250); - env(pay(bob, ed, USD(10)), path(~USD), sendmax(EUR(15)), txflags(tfNoRippleDirect)); + AMM const ammAlice(env, alice_, USD(1'005), EUR(1'000), false, 250); + env(pay(bob_, ed, USD(10)), Path(~USD), Sendmax(EUR(15)), Txflags(tfNoRippleDirect)); BEAST_EXPECT(expectHolding(env, ed, USD(2'010))); if (!features[fixAMMv1_1]) { BEAST_EXPECT( - expectHolding(env, bob, STAmount{EUR, UINT64_C(1'989'987453007618), -12})); + expectHolding(env, bob_, STAmount{EUR, UINT64_C(1'989'987453007618), -12})); BEAST_EXPECT(ammAlice.expectBalances( USD(1'000), STAmount{EUR, UINT64_C(1'005'012546992382), -12}, @@ -4808,13 +4811,13 @@ private: else { BEAST_EXPECT( - expectHolding(env, bob, STAmount{EUR, UINT64_C(1'989'987453007628), -12})); + expectHolding(env, bob_, STAmount{EUR, UINT64_C(1'989'987453007628), -12})); BEAST_EXPECT(ammAlice.expectBalances( USD(1'000), STAmount{EUR, UINT64_C(1'005'012546992372), -12}, ammAlice.tokens())); } - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. AMM has a better @@ -4823,15 +4826,15 @@ private: { Env env(*this, features); Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); - env(offer(carol, EUR(10), USD(10))); + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); + env(offer(carol_, EUR(10), USD(10))); // Set 1% fee - AMM const ammAlice(env, alice, USD(1'005), EUR(1'000), false, 1'000); - env(pay(bob, ed, USD(10)), path(~USD), sendmax(EUR(15)), txflags(tfNoRippleDirect)); + AMM const ammAlice(env, alice_, USD(1'005), EUR(1'000), false, 1'000); + env(pay(bob_, ed, USD(10)), Path(~USD), Sendmax(EUR(15)), Txflags(tfNoRippleDirect)); BEAST_EXPECT(expectHolding(env, ed, USD(2'010))); - BEAST_EXPECT(expectHolding(env, bob, EUR(1'990))); + BEAST_EXPECT(expectHolding(env, bob_, EUR(1'990))); BEAST_EXPECT(ammAlice.expectBalances(USD(1'005), EUR(1'000), ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // Payment with AMM and CLOB offer. AMM has a better @@ -4841,16 +4844,17 @@ private: { Env env(*this, features); Account const ed("ed"); - fund(env, gw, {alice, bob, carol, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); - env(offer(carol, EUR(9), USD(9))); + fund(env, gw_, {alice_, bob_, carol_, ed}, XRP(1'000), {USD(2'000), EUR(2'000)}); + env(offer(carol_, EUR(9), USD(9))); // Set 1% fee - AMM const ammAlice(env, alice, USD(1'005), EUR(1'000), false, 1'000); - env(pay(bob, ed, USD(10)), path(~USD), sendmax(EUR(15)), txflags(tfNoRippleDirect)); + AMM const ammAlice(env, alice_, USD(1'005), EUR(1'000), false, 1'000); + env(pay(bob_, ed, USD(10)), Path(~USD), Sendmax(EUR(15)), Txflags(tfNoRippleDirect)); BEAST_EXPECT(expectHolding(env, ed, USD(2'010))); - BEAST_EXPECT(expectHolding(env, bob, STAmount{EUR, UINT64_C(1'989'993923296712), -12})); + BEAST_EXPECT( + expectHolding(env, bob_, STAmount{EUR, UINT64_C(1'989'993923296712), -12})); BEAST_EXPECT(ammAlice.expectBalances( USD(1'004), STAmount{EUR, UINT64_C(1'001'006076703288), -12}, ammAlice.tokens())); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } @@ -4874,7 +4878,7 @@ private: Account const natalie("natalie"); fund( env, - gw, + gw_, {bob, ed, paul, dan, chris, simon, ben, natalie}, {USD(1'500'000)}, Fund::Acct); @@ -4890,8 +4894,8 @@ private: ammAlice.withdrawAll(dan, USD(0)); ammAlice.deposit(bob, USD(100)); ammAlice.withdrawAll(bob, USD(0)); - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(carol_, USD(1'000)); + ammAlice.withdrawAll(carol_, USD(0)); ammAlice.deposit(ed, USD(10'000)); ammAlice.withdrawAll(ed, USD(0)); ammAlice.deposit(paul, USD(100'000)); @@ -4928,15 +4932,15 @@ private: if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) { BEAST_EXPECT(expectHolding( - env, carol, STAmount{USD, UINT64_C(30'000'00000000001), -11})); + env, carol_, STAmount{USD, UINT64_C(30'000'00000000001), -11})); } else if (features[fixAMMv1_1] && !features[fixAMMv1_3]) { - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); } else { - BEAST_EXPECT(expectHolding(env, carol, USD(30'000))); + BEAST_EXPECT(expectHolding(env, carol_, USD(30'000))); } BEAST_EXPECT(expectHolding(env, ed, USD(1'500'000))); BEAST_EXPECT(expectHolding(env, paul, USD(1'500'000))); @@ -4954,26 +4958,26 @@ private: { BEAST_EXPECT(expectHolding(env, natalie, USD(1'500'000))); } - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); BEAST_EXPECT(!ammAlice.ammExists()); if (!features[fixAMMv1_1]) { - BEAST_EXPECT( - expectHolding(env, alice, STAmount{USD, UINT64_C(30'000'0000000013), -10})); + BEAST_EXPECT(expectHolding( + env, alice_, STAmount{USD, UINT64_C(30'000'0000000013), -10})); } else if (features[fixAMMv1_3]) { - BEAST_EXPECT( - expectHolding(env, alice, STAmount{USD, UINT64_C(30'000'0000000003), -10})); + BEAST_EXPECT(expectHolding( + env, alice_, STAmount{USD, UINT64_C(30'000'0000000003), -10})); } else { - BEAST_EXPECT(expectHolding(env, alice, USD(30'000))); + BEAST_EXPECT(expectHolding(env, alice_, USD(30'000))); } - // alice XRP balance is 30,000 initial - 50 AMMCreate fee - + // alice_ XRP balance is 30,000 initial - 50 AMMCreate fee - // 10drops fee BEAST_EXPECT( - accountBalance(env, alice) == + accountBalance(env, alice_) == std::to_string(29950000000 - env.current()->fees().base.drops())); }, std::nullopt, @@ -4994,7 +4998,7 @@ private: Account const natalie("natalie"); fund( env, - gw, + gw_, {bob, ed, paul, dan, chris, simon, ben, natalie}, XRP(2'000'000), {}, @@ -5011,8 +5015,8 @@ private: ammAlice.withdrawAll(dan, XRP(0)); ammAlice.deposit(bob, XRP(100)); ammAlice.withdrawAll(bob, XRP(0)); - ammAlice.deposit(carol, XRP(1'000)); - ammAlice.withdrawAll(carol, XRP(0)); + ammAlice.deposit(carol_, XRP(1'000)); + ammAlice.withdrawAll(carol_, XRP(0)); ammAlice.deposit(ed, XRP(10'000)); ammAlice.withdrawAll(ed, XRP(0)); ammAlice.deposit(paul, XRP(100'000)); @@ -5026,10 +5030,10 @@ private: // No round off with XRP in this test BEAST_EXPECT( ammAlice.expectBalances(XRP(10'000), USD(10'000), IOUAmount{10'000'000})); - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); BEAST_EXPECT(!ammAlice.ammExists()); // 20,000 initial - (deposit+withdraw) * 10 - auto const xrpBalance = (XRP(2'000'000) - txfee(env, 20)).getText(); + auto const xrpBalance = (XRP(2'000'000) - txFee(env, 20)).getText(); BEAST_EXPECT(accountBalance(env, ben) == xrpBalance); BEAST_EXPECT(accountBalance(env, simon) == xrpBalance); BEAST_EXPECT(accountBalance(env, chris) == xrpBalance); @@ -5037,14 +5041,14 @@ private: // 30,000 initial - (deposit+withdraw) * 10 BEAST_EXPECT( - accountBalance(env, carol) == + accountBalance(env, carol_) == std::to_string(30'000'000'000 - (20 * baseFee))); BEAST_EXPECT(accountBalance(env, ed) == xrpBalance); BEAST_EXPECT(accountBalance(env, paul) == xrpBalance); BEAST_EXPECT(accountBalance(env, natalie) == xrpBalance); // 30,000 initial - 50 AMMCreate fee - 10drops withdraw fee BEAST_EXPECT( - accountBalance(env, alice) == std::to_string(29'950'000'000 - baseFee)); + accountBalance(env, alice_) == std::to_string(29'950'000'000 - baseFee)); } else { @@ -5052,22 +5056,22 @@ private: // AMM invariant BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(10'000'000'080), USD(10'000), IOUAmount{10'000'000})); - ammAlice.withdrawAll(alice); + ammAlice.withdrawAll(alice_); BEAST_EXPECT(!ammAlice.ammExists()); - auto const xrpBalance = XRP(2'000'000) - txfee(env, 20) - drops(10); + auto const xrpBalance = XRP(2'000'000) - txFee(env, 20) - drops(10); auto const xrpBalanceText = xrpBalance.getText(); BEAST_EXPECT(accountBalance(env, ben) == xrpBalanceText); BEAST_EXPECT(accountBalance(env, simon) == xrpBalanceText); BEAST_EXPECT(accountBalance(env, chris) == xrpBalanceText); BEAST_EXPECT(accountBalance(env, dan) == xrpBalanceText); BEAST_EXPECT( - accountBalance(env, carol) == + accountBalance(env, carol_) == std::to_string(30'000'000'000 - (20 * baseFee) - 10)); BEAST_EXPECT(accountBalance(env, ed) == (xrpBalance + drops(2)).getText()); BEAST_EXPECT(accountBalance(env, paul) == (xrpBalance + drops(3)).getText()); BEAST_EXPECT(accountBalance(env, natalie) == (xrpBalance + drops(5)).getText()); BEAST_EXPECT( - accountBalance(env, alice) == + accountBalance(env, alice_) == std::to_string(29'950'000'000 - baseFee + 80)); } }, @@ -5083,7 +5087,7 @@ private: testcase("Auto Delete"); using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; { Env env( @@ -5093,9 +5097,9 @@ private: return cfg; }), all); - fund(env, gw, {alice}, XRP(20'000), {USD(10'000)}); - AMM amm(env, gw, XRP(10'000), USD(10'000)); - for (auto i = 0; i < maxDeletableAMMTrustLines + 10; ++i) + fund(env, gw_, {alice_}, XRP(20'000), {USD(10'000)}); + AMM amm(env, gw_, XRP(10'000), USD(10'000)); + for (auto i = 0; i < kMAX_DELETABLE_AMM_TRUST_LINES + 10; ++i) { Account const a{std::to_string(i)}; env.fund(XRP(1'000), a); @@ -5104,26 +5108,26 @@ private: } // The trustlines are partially deleted, // AMM is set to an empty state. - amm.withdrawAll(gw); + amm.withdrawAll(gw_); BEAST_EXPECT(amm.ammExists()); // Bid,Vote,Deposit,Withdraw,TrustSet failing with // tecAMM_EMPTY. Deposit succeeds with tfTwoAssetIfEmpty option. env(amm.bid({ - .account = alice, + .account = alice_, .bidMin = 1000, }), - ter(tecAMM_EMPTY)); + Ter(tecAMM_EMPTY)); amm.vote( - std::nullopt, 100, std::nullopt, std::nullopt, std::nullopt, ter(tecAMM_EMPTY)); - amm.withdraw(alice, 100, std::nullopt, std::nullopt, ter(tecAMM_EMPTY)); + std::nullopt, 100, std::nullopt, std::nullopt, std::nullopt, Ter(tecAMM_EMPTY)); + amm.withdraw(alice_, 100, std::nullopt, std::nullopt, Ter(tecAMM_EMPTY)); amm.deposit( - alice, USD(100), std::nullopt, std::nullopt, std::nullopt, ter(tecAMM_EMPTY)); - env(trust(alice, STAmount{amm.lptIssue(), 10'000}), ter(tecAMM_EMPTY)); + alice_, USD(100), std::nullopt, std::nullopt, std::nullopt, Ter(tecAMM_EMPTY)); + env(trust(alice_, STAmount{amm.lptIssue(), 10'000}), Ter(tecAMM_EMPTY)); // Can deposit with tfTwoAssetIfEmpty option amm.deposit( - alice, + alice_, std::nullopt, XRP(10'000), USD(10'000), @@ -5138,7 +5142,7 @@ private: // Withdrawing all tokens deletes AMM since the number // of remaining trustlines is less than max - amm.withdrawAll(alice); + amm.withdrawAll(alice_); BEAST_EXPECT(!amm.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(amm.ammAccount()))); } @@ -5151,9 +5155,9 @@ private: return cfg; }), all); - fund(env, gw, {alice}, XRP(20'000), {USD(10'000)}); - AMM amm(env, gw, XRP(10'000), USD(10'000)); - for (auto i = 0; i < (maxDeletableAMMTrustLines * 2) + 10; ++i) + fund(env, gw_, {alice_}, XRP(20'000), {USD(10'000)}); + AMM amm(env, gw_, XRP(10'000), USD(10'000)); + for (auto i = 0; i < (kMAX_DELETABLE_AMM_TRUST_LINES * 2) + 10; ++i) { Account const a{std::to_string(i)}; env.fund(XRP(1'000), a); @@ -5161,19 +5165,19 @@ private: env.close(); } // The trustlines are partially deleted. - amm.withdrawAll(gw); + amm.withdrawAll(gw_); BEAST_EXPECT(amm.ammExists()); // AMMDelete has to be called twice to delete AMM. - amm.ammDelete(alice, ter(tecINCOMPLETE)); + amm.ammDelete(alice_, Ter(tecINCOMPLETE)); BEAST_EXPECT(amm.ammExists()); // Deletes remaining trustlines and deletes AMM. - amm.ammDelete(alice); + amm.ammDelete(alice_); BEAST_EXPECT(!amm.ammExists()); BEAST_EXPECT(!env.le(keylet::ownerDir(amm.ammAccount()))); // Try redundant delete - amm.ammDelete(alice, ter(terNO_AMM)); + amm.ammDelete(alice_, Ter(terNO_AMM)); } } @@ -5183,10 +5187,10 @@ private: testcase("Clawback"); using namespace jtx; Env env(*this); - env.fund(XRP(2'000), gw); - env.fund(XRP(2'000), alice); - AMM const amm(env, gw, XRP(1'000), USD(1'000)); - env(fset(gw, asfAllowTrustLineClawback), ter(tecOWNERS)); + env.fund(XRP(2'000), gw_); + env.fund(XRP(2'000), alice_); + AMM const amm(env, gw_, XRP(1'000), USD(1'000)); + env(fset(gw_, asfAllowTrustLineClawback), Ter(tecOWNERS)); } void @@ -5210,8 +5214,8 @@ private: { fail(); } - amm.deposit(carol, 1'000); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + amm.deposit(carol_, 1'000); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; try { bool found = false; @@ -5244,18 +5248,18 @@ private: using namespace jtx; Account const ed("ed"); Account const gw1("gw1"); - auto const ETH = gw1["ETH"]; - auto const CAN = gw1["CAN"]; + auto const eth = gw1["ETH"]; + auto const can = gw1["CAN"]; // These tests are expected to fail if the OwnerPaysFee feature // is ever supported. Updates will need to be made to AMM handling // in the payment engine, and these tests will need to be updated. auto prep = [&](Env& env, auto gwRate, auto gw1Rate) { - fund(env, gw, {alice, carol, bob, ed}, XRP(2'000), {USD(2'000)}); + fund(env, gw_, {alice_, carol_, bob_, ed}, XRP(2'000), {USD(2'000)}); env.fund(XRP(2'000), gw1); - fund(env, gw1, {alice, carol, bob, ed}, {ETH(2'000), CAN(2'000)}, Fund::TokenOnly); - env(rate(gw, gwRate)); + fund(env, gw1, {alice_, carol_, bob_, ed}, {eth(2'000), can(2'000)}, Fund::TokenOnly); + env(rate(gw_, gwRate)); env(rate(gw1, gw1Rate)); env.close(); }; @@ -5281,23 +5285,23 @@ private: std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400), USD(400)), txflags(tfPassive)); + env(offer(ed, eth(400), USD(400)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000), ETH(1'000)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(ETH(500))); + amm.emplace(env, ed, USD(1'000), eth(1'000)); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(eth(500))); env.close(); // CLOB and AMM, AMM is not selected if (i == 2) { - BEAST_EXPECT(amm->expectBalances(USD(1'000), ETH(1'000), amm->tokens())); + BEAST_EXPECT(amm->expectBalances(USD(1'000), eth(1'000), amm->tokens())); } - BEAST_EXPECT(expectHolding(env, bob, USD(2'100))); + BEAST_EXPECT(expectHolding(env, bob_, USD(2'100))); q[i] = Quality( Amounts{ - ETH(2'000) - env.balance(carol, ETH), - env.balance(bob, USD) - USD(2'000)}); + eth(2'000) - env.balance(carol_, eth), + env.balance(bob_, USD) - USD(2'000)}); } // CLOB is better quality than AMM BEAST_EXPECT(q[0] > q[1]); @@ -5316,27 +5320,27 @@ private: std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400), USD(400)), txflags(tfPassive)); + env(offer(ed, eth(400), USD(400)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000), ETH(1'000)); - env(offer(alice, USD(400), ETH(400))); + amm.emplace(env, ed, USD(1'000), eth(1'000)); + env(offer(alice_, USD(400), eth(400))); env.close(); // AMM is not selected if (i > 0) { - BEAST_EXPECT(amm->expectBalances(USD(1'000), ETH(1'000), amm->tokens())); + BEAST_EXPECT(amm->expectBalances(USD(1'000), eth(1'000), amm->tokens())); } if (i == 0 || i == 2) { // Fully crosses - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } // Fails to cross because AMM is not selected else { - BEAST_EXPECT(expectOffers(env, alice, 1, {Amounts{USD(400), ETH(400)}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {Amounts{USD(400), eth(400)}})); } BEAST_EXPECT(expectOffers(env, ed, 0)); } @@ -5354,17 +5358,17 @@ private: std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400), USD(300)), txflags(tfPassive)); + env(offer(ed, eth(400), USD(300)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000), ETH(1'000)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(ETH(500))); + amm.emplace(env, ed, USD(1'000), eth(1'000)); + env(pay(carol_, bob_, USD(100)), Path(~USD), Sendmax(eth(500))); env.close(); // AMM and CLOB are selected if (i > 0) { - BEAST_EXPECT(!amm->expectBalances(USD(1'000), ETH(1'000), amm->tokens())); + BEAST_EXPECT(!amm->expectBalances(USD(1'000), eth(1'000), amm->tokens())); } if (i == 2 && !features[fixAMMv1_1]) { @@ -5377,7 +5381,7 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(378'6327949540823), -13}, + STAmount{eth, UINT64_C(378'6327949540823), -13}, STAmount{USD, UINT64_C(283'9745962155617), -13}}}})); } else @@ -5387,7 +5391,7 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(378'6327949540813), -13}, + STAmount{eth, UINT64_C(378'6327949540813), -13}, STAmount{USD, UINT64_C(283'974596215561), -12}}}})); } } @@ -5400,7 +5404,7 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(325'299461620749), -12}, + STAmount{eth, UINT64_C(325'299461620749), -12}, STAmount{USD, UINT64_C(243'9745962155617), -13}}}})); } else @@ -5410,7 +5414,7 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(325'299461620748), -12}, + STAmount{eth, UINT64_C(325'299461620748), -12}, STAmount{USD, UINT64_C(243'974596215561), -12}}}})); } } @@ -5424,7 +5428,7 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(378'6327949540812), -13}, + STAmount{eth, UINT64_C(378'6327949540812), -13}, STAmount{USD, UINT64_C(283'9745962155609), -13}}}})); } else @@ -5434,15 +5438,15 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(325'2994616207479), -13}, + STAmount{eth, UINT64_C(325'2994616207479), -13}, STAmount{USD, UINT64_C(243'9745962155609), -13}}}})); } } - BEAST_EXPECT(expectHolding(env, bob, USD(2'100))); + BEAST_EXPECT(expectHolding(env, bob_, USD(2'100))); q[i] = Quality( Amounts{ - ETH(2'000) - env.balance(carol, ETH), - env.balance(bob, USD) - USD(2'000)}); + eth(2'000) - env.balance(carol_, eth), + env.balance(bob_, USD) - USD(2'000)}); } // AMM is better quality BEAST_EXPECT(q[1] > q[0]); @@ -5458,17 +5462,17 @@ private: std::optional amm; if (i == 0 || i == 2) { - env(offer(ed, ETH(400), USD(250)), txflags(tfPassive)); + env(offer(ed, eth(400), USD(250)), Txflags(tfPassive)); env.close(); } if (i > 0) - amm.emplace(env, ed, USD(1'000), ETH(1'000)); - env(offer(alice, USD(250), ETH(400))); + amm.emplace(env, ed, USD(1'000), eth(1'000)); + env(offer(alice_, USD(250), eth(400))); env.close(); // AMM is selected in both cases if (i > 0) { - BEAST_EXPECT(!amm->expectBalances(USD(1'000), ETH(1'000), amm->tokens())); + BEAST_EXPECT(!amm->expectBalances(USD(1'000), eth(1'000), amm->tokens())); } // Partially crosses, AMM is selected, CLOB fails // limitQuality @@ -5478,14 +5482,14 @@ private: { if (!features[fixAMMv1_1]) { - BEAST_EXPECT(expectOffers(env, ed, 1, {{Amounts{ETH(400), USD(250)}}})); + BEAST_EXPECT(expectOffers(env, ed, 1, {{Amounts{eth(400), USD(250)}}})); BEAST_EXPECT(expectOffers( env, - alice, + alice_, 1, {{Amounts{ STAmount{USD, UINT64_C(40'5694150420947), -13}, - STAmount{ETH, UINT64_C(64'91106406735152), -14}, + STAmount{eth, UINT64_C(64'91106406735152), -14}, }}})); } else @@ -5498,10 +5502,10 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(335'0889359326475), -13}, + STAmount{eth, UINT64_C(335'0889359326475), -13}, STAmount{USD, UINT64_C(209'4305849579047), -13}, }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } } else @@ -5514,10 +5518,10 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(335'0889359326485), -13}, + STAmount{eth, UINT64_C(335'0889359326485), -13}, STAmount{USD, UINT64_C(209'4305849579053), -13}, }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } else { @@ -5527,10 +5531,10 @@ private: ed, 1, {{Amounts{ - STAmount{ETH, UINT64_C(335'0889359326475), -13}, + STAmount{eth, UINT64_C(335'0889359326475), -13}, STAmount{USD, UINT64_C(209'4305849579047), -13}, }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + BEAST_EXPECT(expectOffers(env, alice_, 0)); } } } @@ -5562,18 +5566,21 @@ private: if (i == 0 || i == 2) { - env(offer(ed, ETH(400), CAN(400)), txflags(tfPassive)); - env(offer(ed, CAN(400), USD(400))), txflags(tfPassive); + env(offer(ed, eth(400), can(400)), Txflags(tfPassive)); + env(offer(ed, can(400), USD(400))), Txflags(tfPassive); env.close(); } if (i > 0) - amm.emplace(env, ed, ETH(1'000), USD(1'000)); + amm.emplace(env, ed, eth(1'000), USD(1'000)); - env(pay(carol, bob, USD(100)), path(~USD), path(~CAN, ~USD), sendmax(ETH(600))); + env(pay(carol_, bob_, USD(100)), + Path(~USD), + Path(~can, ~USD), + Sendmax(eth(600))); env.close(); - BEAST_EXPECT(expectHolding(env, bob, USD(2'100))); + BEAST_EXPECT(expectHolding(env, bob_, USD(2'100))); if (i == 2 && !features[fixAMMv1_1]) { @@ -5581,14 +5588,14 @@ private: { // Liquidity is consumed from AMM strand only BEAST_EXPECT(amm->expectBalances( - STAmount{ETH, UINT64_C(1'176'66038955758), -11}, + STAmount{eth, UINT64_C(1'176'66038955758), -11}, USD(850), amm->tokens())); } else { BEAST_EXPECT(amm->expectBalances( - STAmount{ETH, UINT64_C(1'179'540094339627), -12}, + STAmount{eth, UINT64_C(1'179'540094339627), -12}, STAmount{USD, UINT64_C(847'7880529867501), -13}, amm->tokens())); BEAST_EXPECT(expectOffers( @@ -5596,11 +5603,11 @@ private: ed, 2, {{Amounts{ - STAmount{ETH, UINT64_C(343'3179205198749), -13}, - STAmount{CAN, UINT64_C(343'3179205198749), -13}, + STAmount{eth, UINT64_C(343'3179205198749), -13}, + STAmount{can, UINT64_C(343'3179205198749), -13}, }, Amounts{ - STAmount{CAN, UINT64_C(362'2119470132499), -13}, + STAmount{can, UINT64_C(362'2119470132499), -13}, STAmount{USD, UINT64_C(362'2119470132499), -13}, }}})); } @@ -5611,14 +5618,14 @@ private: { // Liquidity is consumed from AMM strand only BEAST_EXPECT(amm->expectBalances( - STAmount{ETH, UINT64_C(1'176'660389557593), -12}, + STAmount{eth, UINT64_C(1'176'660389557593), -12}, USD(850), amm->tokens())); } else { BEAST_EXPECT(amm->expectBalances( - STAmount{ETH, UINT64_C(1'179'54009433964), -11}, + STAmount{eth, UINT64_C(1'179'54009433964), -11}, STAmount{USD, UINT64_C(847'7880529867501), -13}, amm->tokens())); BEAST_EXPECT(expectOffers( @@ -5626,19 +5633,19 @@ private: ed, 2, {{Amounts{ - STAmount{ETH, UINT64_C(343'3179205198749), -13}, - STAmount{CAN, UINT64_C(343'3179205198749), -13}, + STAmount{eth, UINT64_C(343'3179205198749), -13}, + STAmount{can, UINT64_C(343'3179205198749), -13}, }, Amounts{ - STAmount{CAN, UINT64_C(362'2119470132499), -13}, + STAmount{can, UINT64_C(362'2119470132499), -13}, STAmount{USD, UINT64_C(362'2119470132499), -13}, }}})); } } q[i] = Quality( Amounts{ - ETH(2'000) - env.balance(carol, ETH), - env.balance(bob, USD) - USD(2'000)}); + eth(2'000) - env.balance(carol_, eth), + env.balance(bob_, USD) - USD(2'000)}); } BEAST_EXPECT(q[1] > q[0]); BEAST_EXPECT(q[2] > q[0] && q[2] < q[1]); @@ -5651,7 +5658,7 @@ private: { testcase("Fix Default Inner Object"); using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; auto test = [&](FeatureBitset features, TER const& err1, @@ -5662,18 +5669,18 @@ private: bool closeLedger, std::optional extra = std::nullopt) { Env env(*this, features); - fund(env, gw, {alice}, XRP(1'000), {USD(10)}); - AMM amm(env, gw, XRP(10), USD(10), {.tfee = tfee, .close = closeLedger}); - amm.deposit(alice, USD(10), XRP(10)); - amm.vote(VoteArg{.account = alice, .tfee = tfee, .err = ter(err1)}); - amm.withdraw(WithdrawArg{.account = gw, .asset1Out = USD(1), .err = ter(err2)}); + fund(env, gw_, {alice_}, XRP(1'000), {USD(10)}); + AMM amm(env, gw_, XRP(10), USD(10), {.tfee = tfee, .close = closeLedger}); + amm.deposit(alice_, USD(10), XRP(10)); + amm.vote(VoteArg{.account = alice_, .tfee = tfee, .err = Ter(err1)}); + amm.withdraw(WithdrawArg{.account = gw_, .asset1Out = USD(1), .err = Ter(err2)}); // with the amendment disabled and ledger not closed, // second vote succeeds if the first vote sets the trading fee // to non-zero; if the first vote sets the trading fee to >0 && // <9 then the second withdraw succeeds if the second vote sets // the trading fee so that the discounted fee is non-zero - amm.vote(VoteArg{.account = alice, .tfee = 20, .err = ter(err3)}); - amm.withdraw(WithdrawArg{.account = gw, .asset1Out = USD(2), .err = ter(err4)}); + amm.vote(VoteArg{.account = alice_, .tfee = 20, .err = Ter(err3)}); + amm.withdraw(WithdrawArg{.account = gw_, .asset1Out = USD(2), .err = Ter(err4)}); }; // ledger is closed after each transaction, vote/withdraw don't fail @@ -5732,8 +5739,8 @@ private: Succeed // Both succeed }; using enum Status; - auto const xrpIouAmounts10_100 = TAmounts{XRPAmount{10}, IOUAmount{100}}; - auto const iouXrpAmounts10_100 = TAmounts{IOUAmount{10}, XRPAmount{100}}; + auto const xrpIouAmounts10100 = TAmounts{XRPAmount{10}, IOUAmount{100}}; + auto const iouXrpAmounts10100 = TAmounts{IOUAmount{10}, XRPAmount{100}}; // clang-format off std::vector> const tests = { //Pool In , Pool Out, Quality , Fee, Status @@ -5771,8 +5778,8 @@ private: {"0.009059512633902926", "7994028", Quality{5477511954775533172}, 1000, Fail}, {"1", "1.0", Quality{0}, 100, Fail}, {"1.0", "1", Quality{0}, 100, Fail}, - {"10", "10.0", Quality{xrpIouAmounts10_100}, 100, Fail}, - {"10.0", "10", Quality{iouXrpAmounts10_100}, 100, Fail}, + {"10", "10.0", Quality{xrpIouAmounts10100}, 100, Fail}, + {"10.0", "10", Quality{iouXrpAmounts10100}, 100, Fail}, {"69864389131", "287631.4543025075", Quality{6487623473313516078}, 451, Succeed}, {"4328342973", "12453825.99247381", Quality{6272522264364865181}, 997, Succeed}, {"32347017", "7003.93031579449", Quality{6347261126087916670}, 1000, Succeed}, @@ -5802,7 +5809,7 @@ private: Env const env(*this, features, std::make_unique(&logs)); auto rules = env.current()->rules(); CurrentTransactionRulesGuard const rg(rules); - NumberMantissaScaleGuard const sg(MantissaRange::mantissa_scale::small); + NumberMantissaScaleGuard const sg(MantissaRange::MantissaScale::Small); for (auto const& t : tests) { @@ -5923,7 +5930,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfSingleAsset, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }); @@ -5931,7 +5938,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfOneAssetLPToken, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }); @@ -5939,7 +5946,7 @@ private: testAMM([&](AMM& ammAlice, Env& env) { WithdrawArg const args{ .flags = tfLimitLPToken, - .err = ter(temMALFORMED), + .err = Ter(temMALFORMED), }; ammAlice.withdraw(args); }); @@ -5948,7 +5955,7 @@ private: WithdrawArg const args{ .asset1Out = XRP(100), .asset2Out = XRP(100), - .err = ter(temBAD_AMM_TOKENS), + .err = Ter(temBAD_AMM_TOKENS), }; ammAlice.withdraw(args); }); @@ -5957,20 +5964,20 @@ private: WithdrawArg const args{ .asset1Out = XRP(100), .asset2Out = BAD(100), - .err = ter(temBAD_CURRENCY), + .err = Ter(temBAD_CURRENCY), }; ammAlice.withdraw(args); }); testAMM([&](AMM& ammAlice, Env& env) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::AMMWithdraw; jv[jss::Flags] = tfLimitLPToken; - jv[jss::Account] = alice.human(); + jv[jss::Account] = alice_.human(); ammAlice.setTokens(jv); XRP(100).value().setJson(jv[jss::Amount]); USD(100).value().setJson(jv[jss::EPrice]); - env(jv, ter(temBAD_AMM_TOKENS)); + env(jv, Ter(temBAD_AMM_TOKENS)); }); } @@ -5996,7 +6003,7 @@ private: char const* testCase; double const poolUsdBIT; double const poolUsdGH; - sendmax const sendMaxUsdBIT; + Sendmax const sendMaxUsdBIT; STAmount const sendUsdGH; STAmount const failUsdGH; STAmount const failUsdGHr; @@ -6243,10 +6250,10 @@ private: env.close(); env(pay(trader, trader, input.sendUsdGH), - path(~usdGH), - path(~btcGH, ~usdGH), - sendmax(input.sendMaxUsdBIT), - txflags(tfPartialPayment)); + Path(~usdGH), + Path(~btcGH, ~usdGH), + Sendmax(input.sendMaxUsdBIT), + Txflags(tfPartialPayment)); env.close(); auto const failUsdGH = features[fixAMMv1_1] ? input.failUsdGHr : input.failUsdGH; @@ -6308,12 +6315,12 @@ private: auto [xrpBegin, iouBegin, lptBegin] = amm.balances(XRP, USD); // Set Bob's starting conditions. - env.fund(xrpBob, bob); - env.trust(USD(1'000'000), bob); - env(pay(gw, bob, iouBob)); + env.fund(xrpBob, bob_); + env.trust(USD(1'000'000), bob_); + env(pay(gw_, bob_, iouBob)); env.close(); - env(offer(bob, XRP(6300), USD(100'000))); + env(offer(bob_, XRP(6300), USD(100'000))); env.close(); // Assert that AMM is unchanged. @@ -6322,7 +6329,7 @@ private: {{xrpPool, iouPool}}, 889, std::nullopt, - {testable_amendments() | fixAMMv1_1}); + {testableAmendments() | fixAMMv1_1}); } void @@ -6337,32 +6344,32 @@ private: { Env env(*this, features); - fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); + fund(env, gw_, {alice_, carol_}, XRP(1'000'000), {USD(1'000'000)}); // This offer blocks AMM offer in pre-amendment - env(offer(alice, XRP(1), USD(0.01))); + env(offer(alice_, XRP(1), USD(0.01))); env.close(); - AMM const amm(env, gw, XRP(200'000), USD(100'000)); + AMM const amm(env, gw_, XRP(200'000), USD(100'000)); // The offer doesn't cross AMM in pre-amendment code // It crosses AMM in post-amendment code - env(offer(carol, USD(0.49), XRP(1))); + env(offer(carol_, USD(0.49), XRP(1))); env.close(); if (!features[fixAMMv1_1]) { BEAST_EXPECT(amm.expectBalances(XRP(200'000), USD(100'000), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(1), USD(0.01)}}})); - // Carol's offer is blocked by alice's offer - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{USD(0.49), XRP(1)}}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{XRP(1), USD(0.01)}}})); + // Carol's offer is blocked by alice_'s offer + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{USD(0.49), XRP(1)}}})); } else { BEAST_EXPECT( amm.expectBalances(XRPAmount(200'000'980'005), USD(99'999.51), amm.tokens())); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(1), USD(0.01)}}})); + BEAST_EXPECT(expectOffers(env, alice_, 1, {{Amounts{XRP(1), USD(0.01)}}})); // Carol's offer crosses AMM - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } @@ -6371,40 +6378,40 @@ private: { Env env(*this, features); - fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); + fund(env, gw_, {alice_, carol_}, XRP(1'000'000), {USD(1'000'000)}); // There is no blocking offer - // env(offer(alice, XRP(1), USD(0.01))); + // env(offer(alice_, XRP(1), USD(0.01))); - AMM const amm(env, gw, XRP(200'000), USD(100'000)); + AMM const amm(env, gw_, XRP(200'000), USD(100'000)); // The offer crosses AMM - env(offer(carol, USD(0.49), XRP(1))); + env(offer(carol_, USD(0.49), XRP(1))); env.close(); // The same result as with the blocking offer BEAST_EXPECT( amm.expectBalances(XRPAmount(200'000'980'005), USD(99'999.51), amm.tokens())); // Carol's offer crosses AMM - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } // XRP/USD crosses AMM { Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(1'000)}); + fund(env, gw_, {alice_, carol_, bob_}, XRP(10'000), {USD(1'000)}); // This offer blocks AMM offer in pre-amendment // It crosses AMM in post-amendment code - env(offer(bob, USD(1), XRPAmount(500))); + env(offer(bob_, USD(1), XRPAmount(500))); env.close(); - AMM const amm(env, alice, XRP(1'000), USD(500)); - env(offer(carol, XRP(100), USD(55))); + AMM const amm(env, alice_, XRP(1'000), USD(500)); + env(offer(carol_, XRP(100), USD(55))); env.close(); if (!features[fixAMMv1_1]) { BEAST_EXPECT(amm.expectBalances(XRP(1'000), USD(500), amm.tokens())); - BEAST_EXPECT(expectOffers(env, bob, 1, {{Amounts{USD(1), XRPAmount(500)}}})); - BEAST_EXPECT(expectOffers(env, carol, 1, {{Amounts{XRP(100), USD(55)}}})); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{Amounts{USD(1), XRPAmount(500)}}})); + BEAST_EXPECT(expectOffers(env, carol_, 1, {{Amounts{XRP(100), USD(55)}}})); } else { @@ -6414,10 +6421,10 @@ private: amm.tokens())); BEAST_EXPECT(expectOffers( env, - carol, + carol_, 1, {{Amounts{XRPAmount{9'090'909}, STAmount{USD, 4'99999995, -8}}}})); - BEAST_EXPECT(expectOffers(env, bob, 1, {{Amounts{USD(1), XRPAmount(500)}}})); + BEAST_EXPECT(expectOffers(env, bob_, 1, {{Amounts{USD(1), XRPAmount(500)}}})); } } @@ -6425,15 +6432,15 @@ private: // pre- and post-amendment. { Env env(*this, features); - fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(1'000)}); + fund(env, gw_, {alice_, carol_, bob_}, XRP(10'000), {USD(1'000)}); - AMM const amm(env, alice, XRP(1'000), USD(500)); - env(offer(carol, XRP(100), USD(55))); + AMM const amm(env, alice_, XRP(1'000), USD(500)); + env(offer(carol_, XRP(100), USD(55))); env.close(); BEAST_EXPECT(amm.expectBalances( XRPAmount(909'090'909), STAmount{USD, UINT64_C(550'000000055), -9}, amm.tokens())); BEAST_EXPECT(expectOffers( - env, carol, 1, {{Amounts{XRPAmount{9'090'909}, STAmount{USD, 4'99999995, -8}}}})); + env, carol_, 1, {{Amounts{XRPAmount{9'090'909}, STAmount{USD, 4'99999995, -8}}}})); } } @@ -6447,54 +6454,54 @@ private: { std::string logs; Env env(*this, features, std::make_unique(&logs)); - fund(env, gw, {alice, carol}, XRP(1'000'000'000), {USD(1'000'000'000)}); - AMM amm(env, gw, XRP(2), USD(1)); - amm.deposit(alice, IOUAmount{1'876123487565916, -15}); - amm.deposit(carol, IOUAmount{1'000'000}); - amm.withdrawAll(alice); - BEAST_EXPECT(amm.expectLPTokens(alice, IOUAmount{0})); - amm.withdrawAll(carol); - BEAST_EXPECT(amm.expectLPTokens(carol, IOUAmount{0})); + fund(env, gw_, {alice_, carol_}, XRP(1'000'000'000), {USD(1'000'000'000)}); + AMM amm(env, gw_, XRP(2), USD(1)); + amm.deposit(alice_, IOUAmount{1'876123487565916, -15}); + amm.deposit(carol_, IOUAmount{1'000'000}); + amm.withdrawAll(alice_); + BEAST_EXPECT(amm.expectLPTokens(alice_, IOUAmount{0})); + amm.withdrawAll(carol_); + BEAST_EXPECT(amm.expectLPTokens(carol_, IOUAmount{0})); auto const lpToken = - getAccountLines(env, gw, amm.lptIssue())[jss::lines][0u][jss::balance]; + getAccountLines(env, gw_, amm.lptIssue())[jss::lines][0u][jss::balance]; auto const lpTokenBalance = amm.ammRpcInfo()[jss::amm][jss::lp_token][jss::value]; BEAST_EXPECT(lpToken == "1414.213562373095" && lpTokenBalance == "1414.213562373"); if (!features[fixAMMv1_1]) { - amm.withdrawAll(gw, std::nullopt, ter(tecAMM_BALANCE)); + amm.withdrawAll(gw_, std::nullopt, Ter(tecAMM_BALANCE)); BEAST_EXPECT(amm.ammExists()); } else { - amm.withdrawAll(gw); + amm.withdrawAll(gw_); BEAST_EXPECT(!amm.ammExists()); } } // Last Liquidity Provider is the issuer of two tokens, or not // the issuer - for (auto const& lp : {gw, bob}) + for (auto const& lp : {gw_, bob_}) { Env env(*this, features); - auto const ABC = gw["ABC"]; + auto const abc = gw_["ABC"]; fund( env, - gw, - {alice, carol, bob}, + gw_, + {alice_, carol_, bob_}, XRP(1'000), - {USD(1'000'000'000), ABC(1'000'000'000'000)}); - AMM amm(env, lp, ABC(2'000'000), USD(1)); - amm.deposit(alice, IOUAmount{1'876123487565916, -15}); - amm.deposit(carol, IOUAmount{1'000'000}); - amm.withdrawAll(alice); - amm.withdrawAll(carol); + {USD(1'000'000'000), abc(1'000'000'000'000)}); + AMM amm(env, lp, abc(2'000'000), USD(1)); + amm.deposit(alice_, IOUAmount{1'876123487565916, -15}); + amm.deposit(carol_, IOUAmount{1'000'000}); + amm.withdrawAll(alice_); + amm.withdrawAll(carol_); auto const lpToken = getAccountLines(env, lp, amm.lptIssue())[jss::lines][0u][jss::balance]; auto const lpTokenBalance = amm.ammRpcInfo()[jss::amm][jss::lp_token][jss::value]; BEAST_EXPECT(lpToken == "1414.213562373095" && lpTokenBalance == "1414.213562373"); if (!features[fixAMMv1_1]) { - amm.withdrawAll(lp, std::nullopt, ter(tecAMM_BALANCE)); + amm.withdrawAll(lp, std::nullopt, Ter(tecAMM_BALANCE)); BEAST_EXPECT(amm.ammExists()); } else @@ -6508,35 +6515,35 @@ private: // XRP/IOU { Env env(*this, features); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}); - AMM amm(env, gw, XRP(10), USD(10)); - amm.deposit(alice, 1'000); - auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + fund(env, gw_, {alice_}, XRP(1'000), {USD(1'000)}); + AMM amm(env, gw_, XRP(10), USD(10)); + amm.deposit(alice_, 1'000); + auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw_); BEAST_EXPECT(res && !res.value()); - res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice); + res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice_); BEAST_EXPECT(res && !res.value()); } // IOU/IOU, issuer of both IOU { Env env(*this, features); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000), EUR(1'000)}); - AMM amm(env, gw, EUR(10), USD(10)); - amm.deposit(alice, 1'000); - auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + fund(env, gw_, {alice_}, XRP(1'000), {USD(1'000), EUR(1'000)}); + AMM amm(env, gw_, EUR(10), USD(10)); + amm.deposit(alice_, 1'000); + auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw_); BEAST_EXPECT(res && !res.value()); - res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice); + res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice_); BEAST_EXPECT(res && !res.value()); } // IOU/IOU, issuer of one IOU { Env env(*this, features); Account const gw1("gw1"); - auto const YAN = gw1["YAN"]; - fund(env, gw, {gw1}, XRP(1'000), {USD(1'000)}); - fund(env, gw1, {gw}, XRP(1'000), {YAN(1'000)}, Fund::TokenOnly); - AMM amm(env, gw1, YAN(10), USD(10)); - amm.deposit(gw, 1'000); - auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + auto const yan = gw1["YAN"]; + fund(env, gw_, {gw1}, XRP(1'000), {USD(1'000)}); + fund(env, gw1, {gw_}, XRP(1'000), {yan(1'000)}, Fund::TokenOnly); + AMM amm(env, gw1, yan(10), USD(10)); + amm.deposit(gw_, 1'000); + auto res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw_); BEAST_EXPECT(res && !res.value()); res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw1); BEAST_EXPECT(res && !res.value()); @@ -6551,21 +6558,21 @@ private: // Issuer has clawback enabled Env env(*this, features); - env.fund(XRP(1'000), gw); - env(fset(gw, asfAllowTrustLineClawback)); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}, Fund::Acct); + env.fund(XRP(1'000), gw_); + env(fset(gw_, asfAllowTrustLineClawback)); + fund(env, gw_, {alice_}, XRP(1'000), {USD(1'000)}, Fund::Acct); env.close(); // If featureAMMClawback is not enabled, AMMCreate is not allowed for // clawback-enabled issuer if (!features[featureAMMClawback]) { - AMM const amm(env, gw, XRP(100), USD(100), ter(tecNO_PERMISSION)); - AMM const amm1(env, alice, USD(100), XRP(100), ter(tecNO_PERMISSION)); - env(fclear(gw, asfAllowTrustLineClawback)); + AMM const amm(env, gw_, XRP(100), USD(100), Ter(tecNO_PERMISSION)); + AMM const amm1(env, alice_, USD(100), XRP(100), Ter(tecNO_PERMISSION)); + env(fclear(gw_, asfAllowTrustLineClawback)); env.close(); // Can't be cleared - AMM const amm2(env, gw, XRP(100), USD(100), ter(tecNO_PERMISSION)); + AMM const amm2(env, gw_, XRP(100), USD(100), Ter(tecNO_PERMISSION)); } // If featureAMMClawback is enabled, AMMCreate is allowed for // clawback-enabled issuer. Clawback from the AMM Account is not @@ -6574,8 +6581,8 @@ private: // AMMClawback transaction to claw back from AMM Account. else { - AMM const amm(env, gw, XRP(100), USD(100), ter(tesSUCCESS)); - AMM const amm1(env, alice, USD(100), XRP(200), ter(tecDUPLICATE)); + AMM const amm(env, gw_, XRP(100), USD(100), Ter(tesSUCCESS)); + AMM const amm1(env, alice_, USD(100), XRP(200), Ter(tecDUPLICATE)); // Construct the amount being clawed back using AMM account. // By doing this, we make the clawback transaction's Amount field's @@ -6586,10 +6593,10 @@ private: // `issuer` subfield represents the account being clawed back, which // is confusing. auto const error = - features[featureSingleAssetVault] ? ter{tecPSEUDO_ACCOUNT} : ter{tecAMM_ACCOUNT}; + features[featureSingleAssetVault] ? Ter{tecPSEUDO_ACCOUNT} : Ter{tecAMM_ACCOUNT}; Issue const usd(USD.issue().currency, amm.ammAccount()); auto amount = amountFromString(usd, "10"); - env(claw(gw, amount), error); + env(claw(gw_, amount), error); } } @@ -6600,14 +6607,14 @@ private: using namespace jtx; // This lambda function is used to create trustlines - // between gw and alice, and create an AMM account. + // between gw_ and alice_, and create an AMM account. // And also test the callback function. auto testAMMDeposit = [&](Env& env, std::function cb) { - env.fund(XRP(1'000), gw); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}, Fund::Acct); + env.fund(XRP(1'000), gw_); + fund(env, gw_, {alice_}, XRP(1'000), {USD(1'000)}, Fund::Acct); env.close(); - AMM amm(env, alice, XRP(100), USD(100), ter(tesSUCCESS)); - env(trust(gw, alice["USD"](0), tfSetFreeze)); + AMM amm(env, alice_, XRP(100), USD(100), Ter(tesSUCCESS)); + env(trust(gw_, alice_["USD"](0), tfSetFreeze)); cb(amm); }; @@ -6616,7 +6623,7 @@ private: { Env env(*this, features); testAMMDeposit(env, [&](AMM& amm) { - amm.deposit(alice, USD(100), XRP(100), std::nullopt, tfTwoAsset, ter(tecFROZEN)); + amm.deposit(alice_, USD(100), XRP(100), std::nullopt, tfTwoAsset, Ter(tecFROZEN)); }); } @@ -6626,7 +6633,7 @@ private: Env env(*this, features); testAMMDeposit(env, [&](AMM& amm) { amm.deposit( - alice, USD(100), std::nullopt, std::nullopt, tfSingleAsset, ter(tecFROZEN)); + alice_, USD(100), std::nullopt, std::nullopt, tfSingleAsset, Ter(tecFROZEN)); }); } @@ -6638,7 +6645,7 @@ private: Env env(*this, features); testAMMDeposit(env, [&](AMM& amm) { amm.deposit( - alice, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, ter(tecFROZEN)); + alice_, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, Ter(tecFROZEN)); }); } else @@ -6649,7 +6656,7 @@ private: Env env(*this, features); testAMMDeposit(env, [&](AMM& amm) { amm.deposit( - alice, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, ter(tesSUCCESS)); + alice_, XRP(100), std::nullopt, std::nullopt, tfSingleAsset, Ter(tesSUCCESS)); }); } } @@ -6660,39 +6667,39 @@ private: testcase("Fix Reserve Check On Withdrawal"); using namespace jtx; - auto const err = features[fixAMMv1_2] ? ter(tecINSUFFICIENT_RESERVE) : ter(tesSUCCESS); + auto const err = features[fixAMMv1_2] ? Ter(tecINSUFFICIENT_RESERVE) : Ter(tesSUCCESS); auto test = [&](auto&& cb) { Env env(*this, features); - auto const starting_xrp = reserve(env, 2) + env.current()->fees().base * 5; - env.fund(starting_xrp, gw); - env.fund(starting_xrp, alice); - env.trust(USD(2'000), alice); + auto const startingXrp = reserve(env, 2) + env.current()->fees().base * 5; + env.fund(startingXrp, gw_); + env.fund(startingXrp, alice_); + env.trust(USD(2'000), alice_); env.close(); - env(pay(gw, alice, USD(2'000))); + env(pay(gw_, alice_, USD(2'000))); env.close(); - AMM amm(env, gw, EUR(1'000), USD(1'000)); - amm.deposit(alice, USD(1)); + AMM amm(env, gw_, EUR(1'000), USD(1'000)); + amm.deposit(alice_, USD(1)); cb(amm); }; // Equal withdraw - test([&](AMM& amm) { amm.withdrawAll(alice, std::nullopt, err); }); + test([&](AMM& amm) { amm.withdrawAll(alice_, std::nullopt, err); }); // Equal withdraw with a limit test([&](AMM& amm) { amm.withdraw( WithdrawArg{ - .account = alice, .asset1Out = EUR(0.1), .asset2Out = USD(0.1), .err = err}); + .account = alice_, .asset1Out = EUR(0.1), .asset2Out = USD(0.1), .err = err}); amm.withdraw( WithdrawArg{ - .account = alice, .asset1Out = USD(0.1), .asset2Out = EUR(0.1), .err = err}); + .account = alice_, .asset1Out = USD(0.1), .asset2Out = EUR(0.1), .err = err}); }); // Single withdraw test([&](AMM& amm) { - amm.withdraw(WithdrawArg{.account = alice, .asset1Out = EUR(0.1), .err = err}); - amm.withdraw(WithdrawArg{.account = alice, .asset1Out = USD(0.1)}); + amm.withdraw(WithdrawArg{.account = alice_, .asset1Out = EUR(0.1), .err = err}); + amm.withdraw(WithdrawArg{.account = alice_, .asset1Out = USD(0.1)}); }); } @@ -6705,10 +6712,10 @@ private: testcase("Fail pseudo-account allocation " + suffix); std::string logs; Env env{*this, features, std::make_unique(&logs)}; - env.fund(XRP(30'000), gw, alice); + env.fund(XRP(30'000), gw_, alice_); env.close(); - env(trust(alice, gw["USD"](30'000), 0)); - env(pay(gw, alice, USD(10'000))); + env(trust(alice_, gw_["USD"](30'000), 0)); + env(pay(gw_, alice_, USD(10'000))); env.close(); STAmount const amount = XRP(10'000); @@ -6719,21 +6726,21 @@ private: AccountID const accountId = xrpl::pseudoAccountAddress(*env.current(), keylet.key); env(pay(env.master.id(), accountId, XRP(1000)), - seq(autofill), - fee(autofill), - sig(autofill)); + Seq(kAUTOFILL), + Fee(kAUTOFILL), + Sig(kAUTOFILL)); } AMM const ammAlice( env, - alice, + alice_, amount, amount2, - features[featureSingleAssetVault] ? ter{terADDRESS_COLLISION} : ter{tecDUPLICATE}); + features[featureSingleAssetVault] ? Ter{terADDRESS_COLLISION} : Ter{tecDUPLICATE}); }; - testCase("tecDUPLICATE", testable_amendments() - featureSingleAssetVault); - testCase("terADDRESS_COLLISION", testable_amendments()); + testCase("tecDUPLICATE", testableAmendments() - featureSingleAssetVault); + testCase("terADDRESS_COLLISION", testableAmendments()); } void @@ -6742,39 +6749,39 @@ private: testcase("Deposit and Withdraw Rounding V2"); using namespace jtx; - auto const XPM = gw["XPM"]; + auto const xpm = gw_["XPM"]; STAmount xrpBalance{XRPAmount(692'614'492'126)}; - STAmount xpmBalance{XPM, UINT64_C(18'610'359'80246901), -8}; - STAmount amount{XPM, UINT64_C(6'566'496939465400), -12}; + STAmount xpmBalance{xpm, UINT64_C(18'610'359'80246901), -8}; + STAmount amount{xpm, UINT64_C(6'566'496939465400), -12}; std::uint16_t const tfee = 941; - auto test = [&](auto&& cb, std::uint16_t tfee_) { + auto test = [&](auto&& cb, std::uint16_t tfee) { Env env(*this, features); - env.fund(XRP(1'000'000), gw); - env.fund(XRP(1'000), alice); - env(trust(alice, XPM(7'000))); - env(pay(gw, alice, amount)); + env.fund(XRP(1'000'000), gw_); + env.fund(XRP(1'000), alice_); + env(trust(alice_, xpm(7'000))); + env(pay(gw_, alice_, amount)); - AMM amm(env, gw, xrpBalance, xpmBalance, CreateArg{.tfee = tfee_}); + AMM amm(env, gw_, xrpBalance, xpmBalance, CreateArg{.tfee = tfee}); // AMM LPToken balance required to replicate single deposit failure STAmount const lptAMMBalance{amm.lptIssue(), UINT64_C(3'234'987'266'485968), -6}; auto const burn = IOUAmount{amm.getLPTokensBalance() - lptAMMBalance}; // burn tokens to get to the required AMM state - env(amm.bid(BidArg{.account = gw, .bidMin = burn, .bidMax = burn})); + env(amm.bid(BidArg{.account = gw_, .bidMin = burn, .bidMax = burn})); cb(amm, env); }; test( [&](AMM& amm, Env& env) { - auto const err = env.enabled(fixAMMv1_3) ? ter(tesSUCCESS) : ter(tecUNFUNDED_AMM); - amm.deposit(DepositArg{.account = alice, .asset1In = amount, .err = err}); + auto const err = env.enabled(fixAMMv1_3) ? Ter(tesSUCCESS) : Ter(tecUNFUNDED_AMM); + amm.deposit(DepositArg{.account = alice_, .asset1In = amount, .err = err}); }, tfee); test( [&](AMM& amm, Env& env) { - auto const [amount, amount2, lptAMM] = amm.balances(XRP, XPM); - auto const withdraw = STAmount{XPM, 1, -5}; - amm.withdraw(WithdrawArg{.asset1Out = STAmount{XPM, 1, -5}}); - auto const [amount_, amount2_, lptAMM_] = amm.balances(XRP, XPM); + auto const [amount, amount2, lptAMM] = amm.balances(XRP, xpm); + auto const withdraw = STAmount{xpm, 1, -5}; + amm.withdraw(WithdrawArg{.asset1Out = STAmount{xpm, 1, -5}}); + auto const [amount_, amount2_, lptAMM_] = amm.balances(XRP, xpm); if (!env.enabled(fixAMMv1_3)) { BEAST_EXPECT((amount2 - amount2_) > withdraw); @@ -6792,9 +6799,9 @@ private: { auto const [amount, amount2, lptBalance] = amm.balances(GBP, EUR); - NumberMantissaScaleGuard const sg(MantissaRange::mantissa_scale::small); + NumberMantissaScaleGuard const sg(MantissaRange::MantissaScale::Small); NumberRoundModeGuard const g( - env.enabled(fixAMMv1_3) ? Number::rounding_mode::upward : Number::getround()); + env.enabled(fixAMMv1_3) ? Number::RoundingMode::Upward : Number::getround()); auto const res = root2(amount * amount2); if (shouldFail) @@ -6824,10 +6831,16 @@ private: { testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund( + env, + gw_, + {bob_}, + XRP(10'000'000), + {GBP(100'000), EUR(100'000)}, + Fund::Acct); env.close(); - ammAlice.deposit(DepositArg{.account = bob, .asset1In = deposit}); + ammAlice.deposit(DepositArg{.account = bob_, .asset1In = deposit}); invariant( ammAlice, env, @@ -6843,14 +6856,14 @@ private: // Two-asset proportional deposit (1:1 pool ratio) testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund(env, gw_, {bob_}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); env.close(); STAmount const depositEuro{EUR, UINT64_C(10'1234567890123456), -16}; STAmount const depositGBP{GBP, UINT64_C(10'1234567890123456), -16}; ammAlice.deposit( - DepositArg{.account = bob, .asset1In = depositEuro, .asset2In = depositGBP}); + DepositArg{.account = bob_, .asset1In = depositEuro, .asset2In = depositGBP}); invariant(ammAlice, env, "dep2", false); }, {{GBP(30'000), EUR(30'000)}}, @@ -6863,7 +6876,13 @@ private: { testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund( + env, + gw_, + {bob_}, + XRP(10'000'000), + {GBP(100'000), EUR(100'000)}, + Fund::Acct); env.close(); STAmount const depositEuro{EUR, 1, exponent}; @@ -6871,7 +6890,7 @@ private: ammAlice.deposit( DepositArg{ - .account = bob, .asset1In = depositEuro, .asset2In = depositGBP}); + .account = bob_, .asset1In = depositEuro, .asset2In = depositGBP}); invariant(ammAlice, env, "dep3", exponent != -3 && !env.enabled(fixAMMv1_3)); }, {{GBP(10'000), EUR(30'000)}}, @@ -6883,11 +6902,11 @@ private: // tfLPToken deposit testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund(env, gw_, {bob_}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); env.close(); ammAlice.deposit( - DepositArg{.account = bob, .tokens = IOUAmount{10'1234567890123456, -16}}); + DepositArg{.account = bob_, .tokens = IOUAmount{10'1234567890123456, -16}}); invariant(ammAlice, env, "dep4", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6910,8 +6929,8 @@ private: [&](AMM& ammAlice, Env& env) { fund( env, - gw, - {bob}, + gw_, + {bob_}, XRP(10'000'000), {GBP(100'000), EUR(1'000'000)}, Fund::Acct); @@ -6919,7 +6938,7 @@ private: ammAlice.deposit( DepositArg{ - .account = bob, .tokens = tokens, .asset1In = STAmount{EUR, 1, 6}}); + .account = bob_, .tokens = tokens, .asset1In = STAmount{EUR, 1, 6}}); invariant(ammAlice, env, "dep5", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6932,10 +6951,10 @@ private: // 1'000 GBP with EP not to exceed 5 (GBP/TokensOut) testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund(env, gw_, {bob_}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); env.close(); - ammAlice.deposit(bob, GBP(1'000), std::nullopt, STAmount{GBP, 5}); + ammAlice.deposit(bob_, GBP(1'000), std::nullopt, STAmount{GBP, 5}); invariant(ammAlice, env, "dep6", false); }, {{GBP(30'000), EUR(30'000)}}, @@ -6954,7 +6973,7 @@ private: // tfLPToken mode testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(alice, 1'000); + ammAlice.withdraw(alice_, 1'000); invariant(ammAlice, env, "with1", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6965,7 +6984,7 @@ private: // tfWithdrawAll mode testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(WithdrawArg{.account = alice, .flags = tfWithdrawAll}); + ammAlice.withdraw(WithdrawArg{.account = alice_, .flags = tfWithdrawAll}); invariant(ammAlice, env, "with2", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6978,7 +6997,7 @@ private: [&](AMM& ammAlice, Env& env) { ammAlice.withdraw( WithdrawArg{ - .account = alice, + .account = alice_, .asset1Out = STAmount{GBP, 3'500}, .asset2Out = STAmount{EUR, 15'000}, .flags = tfTwoAsset}); @@ -6998,7 +7017,7 @@ private: [&](AMM& ammAlice, Env& env) { ammAlice.withdraw( WithdrawArg{ - .account = alice, + .account = alice_, .asset1Out = STAmount{GBP, 1'234}, .flags = tfSingleAsset}); invariant(ammAlice, env, "with4", false); @@ -7011,14 +7030,14 @@ private: // tfOneAssetWithdrawAll mode testAMM( [&](AMM& ammAlice, Env& env) { - fund(env, gw, {bob}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); + fund(env, gw_, {bob_}, XRP(10'000'000), {GBP(100'000), EUR(100'000)}, Fund::Acct); env.close(); - ammAlice.deposit(DepositArg{.account = bob, .asset1In = STAmount{GBP, 3'456}}); + ammAlice.deposit(DepositArg{.account = bob_, .asset1In = STAmount{GBP, 3'456}}); ammAlice.withdraw( WithdrawArg{ - .account = bob, + .account = bob_, .asset1Out = STAmount{GBP, 1'000}, .flags = tfOneAssetWithdrawAll}); invariant(ammAlice, env, "with5", false); @@ -7033,7 +7052,7 @@ private: [&](AMM& ammAlice, Env& env) { ammAlice.withdraw( WithdrawArg{ - .account = alice, + .account = alice_, .tokens = 1'000, .asset1Out = STAmount{GBP, 100}, .flags = tfOneAssetLPToken}); @@ -7049,7 +7068,7 @@ private: [&](AMM& ammAlice, Env& env) { ammAlice.withdraw( WithdrawArg{ - .account = alice, + .account = alice_, .asset1Out = STAmount{GBP, 100}, .maxEP = IOUAmount{2}, .flags = tfLimitLPToken}); @@ -7064,7 +7083,7 @@ private: void run() override { - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testInvalidInstance(); testInstanceCreate(); testInvalidDeposit(all); diff --git a/src/test/app/AccountDelete_test.cpp b/src/test/app/AccountDelete_test.cpp index c2ecb91a84..a30691b175 100644 --- a/src/test/app/AccountDelete_test.cpp +++ b/src/test/app/AccountDelete_test.cpp @@ -46,7 +46,7 @@ namespace xrpl::test { -class AccountDelete_test : public beast::unit_test::suite +class AccountDelete_test : public beast::unit_test::Suite { private: // Helper function that verifies the expected DeliveredAmount is present. @@ -57,13 +57,13 @@ private: verifyDeliveredAmount(jtx::Env& env, STAmount const& amount) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; // Verify DeliveredAmount and delivered_amount metadata are correct. // We can't use env.meta() here, because meta() doesn't include // delivered_amount. env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect there to be a DeliveredAmount field. if (!BEAST_EXPECT(meta.isMember(sfDeliveredAmount.jsonName))) @@ -71,13 +71,13 @@ private: // DeliveredAmount and delivered_amount should both be present and // equal amount. - Json::Value const jsonExpect{amount.getJson(JsonOptions::none)}; + json::Value const jsonExpect{amount.getJson(JsonOptions::KNone)}; BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == jsonExpect); BEAST_EXPECT(meta[jss::delivered_amount] == jsonExpect); } // Helper function to create a payment channel. - static Json::Value + static json::Value payChanCreate( jtx::Account const& account, jtx::Account const& to, @@ -86,11 +86,11 @@ private: NetClock::time_point const& cancelAfter, PublicKey const& pk) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::PaymentChannelCreate; jv[jss::Account] = account.human(); jv[jss::Destination] = to.human(); - jv[jss::Amount] = amount.getJson(JsonOptions::none); + jv[jss::Amount] = amount.getJson(JsonOptions::KNone); jv[sfSettleDelay.jsonName] = settleDelay.count(); jv[sfCancelAfter.jsonName] = cancelAfter.time_since_epoch().count() + 2; jv[sfPublicKey.jsonName] = strHex(pk.slice()); @@ -115,24 +115,24 @@ public: env.close(); // Alice can't delete her account and then give herself the XRP. - env(acctdelete(alice, alice), ter(temDST_IS_SRC)); + env(acctdelete(alice, alice), Ter(temDST_IS_SRC)); // alice can't delete her account with a negative fee. - env(acctdelete(alice, becky), fee(drops(-1)), ter(temBAD_FEE)); + env(acctdelete(alice, becky), Fee(drops(-1)), Ter(temBAD_FEE)); // Invalid flags. - env(acctdelete(alice, becky), txflags(tfImmediateOrCancel), ter(temINVALID_FLAG)); + env(acctdelete(alice, becky), Txflags(tfImmediateOrCancel), Ter(temINVALID_FLAG)); // Account deletion has a high fee. Make sure the fee requirement // behaves as we expect. auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, becky), ter(telINSUF_FEE_P)); + env(acctdelete(alice, becky), Ter(telINSUF_FEE_P)); // Try a fee one drop less than the required amount. - env(acctdelete(alice, becky), fee(acctDelFee - drops(1)), ter(telINSUF_FEE_P)); + env(acctdelete(alice, becky), Fee(acctDelFee - drops(1)), Ter(telINSUF_FEE_P)); // alice's account is created too recently to be deleted. - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); // Give becky a trustline. She is no longer deletable. env(trust(becky, gw["USD"](1000))); @@ -150,13 +150,13 @@ public: // Deleting should fail with TOO_SOON, which is a relatively // cheap check compared to validating the contents of her directory. - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); // Close enough ledgers to almost be able to delete alice's account. incLgrSeqForAccDel(env, alice, 1); // alice's account is still created too recently to be deleted. - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); // The most recent delete attempt advanced alice's sequence. So // close two ledgers and her account should be deletable. @@ -171,7 +171,7 @@ public: BEAST_EXPECT(env.closed()->exists(keylet::account(alice.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir(alice.id()))); - env(acctdelete(alice, becky), fee(acctDelFee)); + env(acctdelete(alice, becky), Fee(acctDelFee)); verifyDeliveredAmount(env, aliceOldBalance - acctDelFee); env.close(); @@ -184,20 +184,20 @@ public: } // Attempt to delete becky's account but get stopped by the trust line. - env(acctdelete(becky, carol), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(becky, carol), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // Verify that becky's account is still there by giving her a regular // key. This has the side effect of setting the lsfPasswordSpent bit // on her account root. Account const beck("beck"); - env(regkey(becky, beck), fee(drops(0))); + env(regkey(becky, beck), Fee(drops(0))); env.close(); // Show that the lsfPasswordSpent bit is set by attempting to change // becky's regular key for free again. That fails. Account const reb("reb"); - env(regkey(becky, reb), sig(becky), fee(drops(0)), ter(telINSUF_FEE_P)); + env(regkey(becky, reb), Sig(becky), Fee(drops(0)), Ter(telINSUF_FEE_P)); // Close enough ledgers that becky's failing regkey transaction is // no longer retried. @@ -214,12 +214,12 @@ public: BEAST_EXPECT(env.closed()->exists(keylet::ownerDir(carol.id()))); BEAST_EXPECT(env.closed()->exists(keylet::depositPreauth(carol.id(), becky.id()))); BEAST_EXPECT(env.closed()->exists(keylet::offer(carol.id(), carolOfferSeq))); - BEAST_EXPECT(env.closed()->exists(keylet::ticket(carol.id(), carolTicketSeq))); + BEAST_EXPECT(env.closed()->exists(keylet::kTICKET(carol.id(), carolTicketSeq))); BEAST_EXPECT(env.closed()->exists(keylet::signers(carol.id()))); // Delete carol's account even with stuff in her directory. Show // that multisigning for the delete does not increase carol's fee. - env(acctdelete(carol, becky), fee(acctDelFee), msig(alice)); + env(acctdelete(carol, becky), Fee(acctDelFee), Msig(alice)); verifyDeliveredAmount(env, carolOldBalance - acctDelFee); env.close(); @@ -228,7 +228,7 @@ public: BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir(carol.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::depositPreauth(carol.id(), becky.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::offer(carol.id(), carolOfferSeq))); - BEAST_EXPECT(!env.closed()->exists(keylet::ticket(carol.id(), carolTicketSeq))); + BEAST_EXPECT(!env.closed()->exists(keylet::kTICKET(carol.id(), carolTicketSeq))); BEAST_EXPECT(!env.closed()->exists(keylet::signers(carol.id()))); // Verify that Carol's XRP, minus the fee, was transferred to becky. @@ -236,7 +236,7 @@ public: // Since becky received an influx of XRP, her lsfPasswordSpent bit // is cleared and she can change her regular key for free again. - env(regkey(becky, reb), sig(becky), fee(drops(0))); + env(regkey(becky, reb), Sig(becky), Fee(drops(0))); } } @@ -277,7 +277,7 @@ public: // Delete alice's account. auto const acctDelFee{drops(env.current()->fees().increment)}; auto const aliceBalance{env.balance(alice)}; - env(acctdelete(alice, gw), fee(acctDelFee)); + env(acctdelete(alice, gw), Fee(acctDelFee)); verifyDeliveredAmount(env, aliceBalance - acctDelFee); env.close(); @@ -294,7 +294,7 @@ public: testcase("Owned types"); // We want to test PayChannels with the backlink. - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const alice("alice"); Account const becky("becky"); Account const gw("gw"); @@ -327,8 +327,8 @@ public: env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); - env(acctdelete(becky, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); + env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // Cancel the check, but add an escrow. Again, with the escrow @@ -340,14 +340,14 @@ public: using namespace std::chrono_literals; std::uint32_t const escrowSeq{env.seq(alice)}; env(escrow::create(alice, becky, XRP(333)), - escrow::finish_time(env.now() + 3s), - escrow::cancel_time(env.now() + 4s)); + escrow::kFINISH_TIME(env.now() + 3s), + escrow::kCANCEL_TIME(env.now() + 4s)); env.close(); // alice and becky should be unable to delete their accounts because // of the escrow. - env(acctdelete(alice, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); - env(acctdelete(becky, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); + env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // Now cancel the escrow, but create a payment channel between @@ -358,24 +358,24 @@ public: { Account const gw1("gw1"); Account const carol("carol"); - auto const USD = gw1["USD"]; + auto const usd = gw1["USD"]; env.fund(XRP(100000), carol, gw1); env(fset(gw1, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10000), carol); + env.trust(usd(10000), carol); env.close(); - env(pay(gw1, carol, USD(100))); + env(pay(gw1, carol, usd(100))); env.close(); std::uint32_t const escrowSeq{env.seq(carol)}; - env(escrow::create(carol, becky, USD(1)), - escrow::finish_time(env.now() + 3s), - escrow::cancel_time(env.now() + 4s)); + env(escrow::create(carol, becky, usd(1)), + escrow::kFINISH_TIME(env.now() + 3s), + escrow::kCANCEL_TIME(env.now() + 4s)); env.close(); incLgrSeqForAccDel(env, gw1); - env(acctdelete(gw1, becky), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(gw1, becky), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); env(escrow::cancel(becky, carol, escrowSeq)); @@ -393,8 +393,8 @@ public: // With the PayChannel in place becky and alice should not be // able to delete her account auto const beckyBalance{env.balance(becky)}; - env(acctdelete(alice, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); - env(acctdelete(becky, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); + env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // Alice cancels her PayChannel, which will leave her with only offers @@ -403,7 +403,7 @@ public: // Lambda to close a PayChannel. auto payChanClose = [](jtx::Account const& account, Keylet const& payChanKeylet, PublicKey const& pk) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::PaymentChannelClaim; jv[jss::Flags] = tfClose; jv[jss::Account] = account.human(); @@ -422,7 +422,7 @@ public: env.close(); // alice can't delete her account because of the PayChannel. - env(acctdelete(alice, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // alice closes the PayChannel which should (finally) allow her to @@ -432,7 +432,7 @@ public: // Now alice can successfully delete her account. auto const aliceBalance{env.balance(alice)}; - env(acctdelete(alice, gw), fee(acctDelFee)); + env(acctdelete(alice, gw), Fee(acctDelFee)); verifyDeliveredAmount(env, aliceBalance - acctDelFee); env.close(); } @@ -460,8 +460,8 @@ public: // Alice creates 1001 offers. This is one greater than the number of // directory entries an AccountDelete will remove. std::uint32_t const offerSeq0{env.seq(alice)}; - constexpr int offerCount{1001}; - for (int i{0}; i < offerCount; ++i) + constexpr int kOFFER_COUNT{1001}; + for (int i{0}; i < kOFFER_COUNT; ++i) { env(offer(alice, gw[currency](1), XRP(1))); env.close(); @@ -497,11 +497,11 @@ public: BEAST_EXPECT(closed->exists(aliceOwnerDirKey)); // alice's directory nodes. - for (std::uint32_t i{0}; i < ((offerCount / 32) + 1); ++i) + for (std::uint32_t i{0}; i < ((kOFFER_COUNT / 32) + 1); ++i) BEAST_EXPECT(closed->exists(keylet::page(aliceOwnerDirKey, i))); // alice's offers. - for (std::uint32_t i{0}; i < offerCount; ++i) + for (std::uint32_t i{0}; i < kOFFER_COUNT; ++i) BEAST_EXPECT(closed->exists(keylet::offer(alice.id(), offerSeq0 + i))); } @@ -509,17 +509,17 @@ public: // offers in her directory. auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, gw), fee(acctDelFee), ter(tefTOO_BIG)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tefTOO_BIG)); // Cancel one of alice's offers. Then the account delete can succeed. - env.require(offers(alice, offerCount)); - env(offer_cancel(alice, offerSeq0)); + env.require(offers(alice, kOFFER_COUNT)); + env(offerCancel(alice, offerSeq0)); env.close(); - env.require(offers(alice, offerCount - 1)); + env.require(offers(alice, kOFFER_COUNT - 1)); // alice successfully deletes her account. auto const alicePreDelBal{env.balance(alice)}; - env(acctdelete(alice, gw), fee(acctDelFee)); + env(acctdelete(alice, gw), Fee(acctDelFee)); verifyDeliveredAmount(env, alicePreDelBal - acctDelFee); env.close(); @@ -531,11 +531,11 @@ public: BEAST_EXPECT(!closed->exists(aliceOwnerDirKey)); // alice's former directory nodes. - for (std::uint32_t i{0}; i < ((offerCount / 32) + 1); ++i) + for (std::uint32_t i{0}; i < ((kOFFER_COUNT / 32) + 1); ++i) BEAST_EXPECT(!closed->exists(keylet::page(aliceOwnerDirKey, i))); // alice's former offers. - for (std::uint32_t i{0}; i < offerCount; ++i) + for (std::uint32_t i{0}; i < kOFFER_COUNT; ++i) BEAST_EXPECT(!closed->exists(keylet::offer(alice.id(), offerSeq0 + i))); } } @@ -552,20 +552,20 @@ public: Env env{*this}; Account const alice{"alice"}; Account const gw{"gw"}; - auto const BUX{gw["BUX"]}; + auto const bux{gw["BUX"]}; env.fund(XRP(10000), alice, gw); env.close(); // alice creates an offer that, if crossed, will implicitly create // a trust line. - env(offer(alice, BUX(30), XRP(30))); + env(offer(alice, bux(30), XRP(30))); env.close(); // gw crosses alice's offer. alice should end up with BUX(30). - env(offer(gw, XRP(30), BUX(30))); + env(offer(gw, XRP(30), bux(30))); env.close(); - env.require(balance(alice, BUX(30))); + env.require(Balance(alice, bux(30))); // Close enough ledgers to be able to delete alice's account. incLgrSeqForAccDel(env, alice); @@ -573,10 +573,10 @@ public: // alice and gw can't delete their accounts because of the implicitly // created trust line. auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, gw), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); - env(acctdelete(gw, alice), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(gw, alice), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); { std::shared_ptr const closed{env.closed()}; @@ -605,7 +605,7 @@ public: // Burn a chunk of alice's funds so she only has 1 XRP remaining in // her account. - env(noop(alice), fee(env.balance(alice) - XRP(1))); + env(noop(alice), Fee(env.balance(alice) - XRP(1))); env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; @@ -616,7 +616,7 @@ public: // // The balance of env.master should not change. auto const masterBalance{env.balance(env.master)}; - env(acctdelete(alice, env.master), fee(acctDelFee), ter(terINSUF_FEE_B)); + env(acctdelete(alice, env.master), Fee(acctDelFee), Ter(terINSUF_FEE_B)); env.close(); { std::shared_ptr const closed{env.closed()}; @@ -627,7 +627,7 @@ public: // alice again attempts to delete her account. This time she specifies // her current balance in XRP. Again the transaction fails. BEAST_EXPECT(env.balance(alice) == XRP(1)); - env(acctdelete(alice, env.master), fee(XRP(1)), ter(telINSUF_FEE_P)); + env(acctdelete(alice, env.master), Fee(XRP(1)), Ter(telINSUF_FEE_P)); env.close(); { std::shared_ptr const closed{env.closed()}; @@ -654,14 +654,14 @@ public: std::uint32_t const ticketSeq{env.seq(bob) + 1}; env(ticket::create(bob, 250)); env.close(); - env.require(owners(bob, 250)); + env.require(Owners(bob, 250)); { std::shared_ptr const closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account(bob.id()))); for (std::uint32_t i = 0; i < 250; ++i) { - BEAST_EXPECT(closed->exists(keylet::ticket(bob.id(), ticketSeq + i))); + BEAST_EXPECT(closed->exists(keylet::kTICKET(bob.id(), ticketSeq + i))); } } @@ -672,7 +672,7 @@ public: // of his tickets should be removed from the ledger. auto const acctDelFee{drops(env.current()->fees().increment)}; auto const bobOldBalance{env.balance(bob)}; - env(acctdelete(bob, alice), ticket::use(ticketSeq), fee(acctDelFee)); + env(acctdelete(bob, alice), ticket::Use(ticketSeq), Fee(acctDelFee)); verifyDeliveredAmount(env, bobOldBalance - acctDelFee); env.close(); { @@ -680,7 +680,7 @@ public: BEAST_EXPECT(!closed->exists(keylet::account(bob.id()))); for (std::uint32_t i = 0; i < 250; ++i) { - BEAST_EXPECT(!closed->exists(keylet::ticket(bob.id(), ticketSeq + i))); + BEAST_EXPECT(!closed->exists(keylet::kTICKET(bob.id(), ticketSeq + i))); } } } @@ -716,17 +716,17 @@ public: // becky attempts to delete her account using daria as the destination. // Since daria is not in the ledger the delete attempt fails. auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(becky, daria), fee(acctDelFee), ter(tecNO_DST)); + env(acctdelete(becky, daria), Fee(acctDelFee), Ter(tecNO_DST)); env.close(); // becky attempts to delete her account, but carol requires a // destination tag which becky has omitted. - env(acctdelete(becky, carol), fee(acctDelFee), ter(tecDST_TAG_NEEDED)); + env(acctdelete(becky, carol), Fee(acctDelFee), Ter(tecDST_TAG_NEEDED)); env.close(); // becky attempts to delete her account, but alice won't take her XRP, // so the delete is blocked. - env(acctdelete(becky, alice), fee(acctDelFee), ter(tecNO_PERMISSION)); + env(acctdelete(becky, alice), Fee(acctDelFee), Ter(tecNO_PERMISSION)); env.close(); // alice preauthorizes deposits from becky. Now becky can delete her @@ -735,7 +735,7 @@ public: env.close(); auto const beckyOldBalance{env.balance(becky)}; - env(acctdelete(becky, alice), fee(acctDelFee)); + env(acctdelete(becky, alice), Fee(acctDelFee)); verifyDeliveredAmount(env, beckyOldBalance - acctDelFee); env.close(); } @@ -774,9 +774,9 @@ public: // becky use credentials but they aren't accepted env(acctdelete(becky, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(tecBAD_CREDENTIALS)); env.close(); { @@ -789,9 +789,9 @@ public: // Fail, credentials still not accepted env(acctdelete(becky, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(tecBAD_CREDENTIALS)); env.close(); // becky accept the credentials @@ -800,15 +800,15 @@ public: // Fail, credentials doesn’t belong to carol env(acctdelete(carol, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(tecBAD_CREDENTIALS)); // Fail, no depositPreauth for provided credentials env(acctdelete(becky, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(tecNO_PERMISSION)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(tecNO_PERMISSION)); env.close(); // alice create DepositPreauth Object @@ -817,21 +817,21 @@ public: // becky attempts to delete her account, but alice won't take her // XRP, so the delete is blocked. - env(acctdelete(becky, alice), fee(acctDelFee), ter(tecNO_PERMISSION)); + env(acctdelete(becky, alice), Fee(acctDelFee), Ter(tecNO_PERMISSION)); // becky use empty credentials and can't delete account - env(acctdelete(becky, alice), fee(acctDelFee), credentials::ids({}), ter(temMALFORMED)); + env(acctdelete(becky, alice), Fee(acctDelFee), credentials::Ids({}), Ter(temMALFORMED)); // becky use bad credentials and can't delete account env(acctdelete(becky, alice), - credentials::ids({"48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6E" + credentials::Ids({"48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6E" "A288BE4"}), - fee(acctDelFee), - ter(tecBAD_CREDENTIALS)); + Fee(acctDelFee), + Ter(tecBAD_CREDENTIALS)); env.close(); // becky use credentials and can delete account - env(acctdelete(becky, alice), credentials::ids({credIdx}), fee(acctDelFee)); + env(acctdelete(becky, alice), credentials::Ids({credIdx}), Fee(acctDelFee)); env.close(); { @@ -855,7 +855,7 @@ public: // daria use valid credentials, which aren't required and can // delete her account - env(acctdelete(daria, carol), credentials::ids({credDaria}), fee(acctDelFee)); + env(acctdelete(daria, carol), credentials::Ids({credDaria}), Fee(acctDelFee)); env.close(); // check that credential object deleted too @@ -894,7 +894,7 @@ public: // eaton use valid credentials, but he already authorized // through "Authorized" field. - env(acctdelete(eaton, fred), credentials::ids({credEaton}), fee(acctDelFee)); + env(acctdelete(eaton, fred), credentials::Ids({credEaton}), Fee(acctDelFee)); env.close(); // check that credential object deleted too @@ -929,9 +929,9 @@ public: // credentials are expired // john use credentials but can't delete account env(acctdelete(john, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(tecEXPIRED)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(tecEXPIRED)); env.close(); { @@ -953,7 +953,7 @@ public: Account const becky{"becky"}; Account const carol{"carol"}; - Env env{*this, testable_amendments() - featureCredentials}; + Env env{*this, testableAmendments() - featureCredentials}; env.fund(XRP(100000), alice, becky, carol); env.close(); @@ -977,9 +977,9 @@ public: env.close(); env(acctdelete(becky, alice), - credentials::ids({credIdx}), - fee(acctDelFee), - ter(temDISABLED)); + credentials::Ids({credIdx}), + Fee(acctDelFee), + Ter(temDISABLED)); env.close(); } } @@ -1016,7 +1016,7 @@ public: incLgrSeqForAccDel(env, carol); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(carol, alice), fee(acctDelFee)); + env(acctdelete(carol, alice), Fee(acctDelFee)); env.close(); { // check that credential object deleted too @@ -1058,7 +1058,7 @@ public: incLgrSeqForAccDel(env, becky); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(becky, alice), fee(acctDelFee)); + env(acctdelete(becky, alice), Fee(acctDelFee)); env.close(); { // check that credential object deleted too diff --git a/src/test/app/AccountSet_test.cpp b/src/test/app/AccountSet_test.cpp index 15012abe36..c30553dad9 100644 --- a/src/test/app/AccountSet_test.cpp +++ b/src/test/app/AccountSet_test.cpp @@ -51,7 +51,7 @@ namespace xrpl { -class AccountSet_test : public beast::unit_test::suite +class AccountSet_test : public beast::unit_test::Suite { public: void @@ -76,18 +76,18 @@ public: using namespace test::jtx; Account const alice("alice"); - Env env(*this, testable_amendments()); + Env env(*this, testableAmendments()); env.fund(XRP(10000), noripple(alice)); // Give alice a regular key so she can legally set and clear // her asfDisableMaster flag. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); env.close(); auto testFlags = [this, &alice, &alie, &env]( std::initializer_list goodFlags) { - std::uint32_t const orig_flags = (*env.le(alice))[sfFlags]; + std::uint32_t const origFlags = (*env.le(alice))[sfFlags]; for (std::uint32_t flag{1u}; flag < std::numeric_limits::digits; ++flag) { if (flag == asfNoFreeze) @@ -128,26 +128,26 @@ public: if (std::ranges::find(goodFlags, flag) != goodFlags.end()) { // Good flag - env.require(nflags(alice, flag)); - env(fset(alice, flag), sig(alice)); + env.require(Nflags(alice, flag)); + env(fset(alice, flag), Sig(alice)); env.close(); - env.require(flags(alice, flag)); - env(fclear(alice, flag), sig(alie)); + env.require(Flags(alice, flag)); + env(fclear(alice, flag), Sig(alie)); env.close(); - env.require(nflags(alice, flag)); - std::uint32_t const now_flags = (*env.le(alice))[sfFlags]; - BEAST_EXPECT(now_flags == orig_flags); + env.require(Nflags(alice, flag)); + std::uint32_t const nowFlags = (*env.le(alice))[sfFlags]; + BEAST_EXPECT(nowFlags == origFlags); } else { // Bad flag - BEAST_EXPECT((*env.le(alice))[sfFlags] == orig_flags); - env(fset(alice, flag), sig(alice)); + BEAST_EXPECT((*env.le(alice))[sfFlags] == origFlags); + env(fset(alice, flag), Sig(alice)); env.close(); - BEAST_EXPECT((*env.le(alice))[sfFlags] == orig_flags); - env(fclear(alice, flag), sig(alie)); + BEAST_EXPECT((*env.le(alice))[sfFlags] == origFlags); + env(fclear(alice, flag), Sig(alie)); env.close(); - BEAST_EXPECT((*env.le(alice))[sfFlags] == orig_flags); + BEAST_EXPECT((*env.le(alice))[sfFlags] == origFlags); } } }; @@ -171,17 +171,17 @@ public: Account const alice("alice"); env.fund(XRP(10000), noripple(alice)); - std::uint32_t const orig_flags = (*env.le(alice))[sfFlags]; + std::uint32_t const origFlags = (*env.le(alice))[sfFlags]; // asfAccountTxnID is special and not actually set as a flag, // so we check the field presence instead BEAST_EXPECT(!env.le(alice)->isFieldPresent(sfAccountTxnID)); - env(fset(alice, asfAccountTxnID), sig(alice)); + env(fset(alice, asfAccountTxnID), Sig(alice)); BEAST_EXPECT(env.le(alice)->isFieldPresent(sfAccountTxnID)); env(fclear(alice, asfAccountTxnID)); BEAST_EXPECT(!env.le(alice)->isFieldPresent(sfAccountTxnID)); - std::uint32_t const now_flags = (*env.le(alice))[sfFlags]; - BEAST_EXPECT(now_flags == orig_flags); + std::uint32_t const nowFlags = (*env.le(alice))[sfFlags]; + BEAST_EXPECT(nowFlags == origFlags); } void @@ -196,13 +196,13 @@ public: env.memoize("eric"); env(regkey(alice, "eric")); - env.require(nflags(alice, asfNoFreeze)); - env(fset(alice, asfNoFreeze), sig("eric"), ter(tecNEED_MASTER_KEY)); - env(fset(alice, asfNoFreeze), sig(alice)); - env.require(flags(alice, asfNoFreeze)); - env(fclear(alice, asfNoFreeze), sig(alice)); + env.require(Nflags(alice, asfNoFreeze)); + env(fset(alice, asfNoFreeze), Sig("eric"), Ter(tecNEED_MASTER_KEY)); + env(fset(alice, asfNoFreeze), Sig(alice)); + env.require(Flags(alice, asfNoFreeze)); + env(fclear(alice, asfNoFreeze), Sig(alice)); // verify flag is still set (clear does not clear in this case) - env.require(flags(alice, asfNoFreeze)); + env.require(Flags(alice, asfNoFreeze)); } void @@ -249,7 +249,7 @@ public: } else { - env(jt, ter(telBAD_DOMAIN)); + env(jt, Ter(telBAD_DOMAIN)); } } } @@ -265,7 +265,7 @@ public: env.fund(XRP(10000), alice); auto jt = noop(alice); - auto const rkp = randomKeyPair(KeyType::ed25519); + auto const rkp = randomKeyPair(KeyType::Ed25519); jt[sfMessageKey.fieldName] = strHex(rkp.first.slice()); env(jt); BEAST_EXPECT(strHex((*env.le(alice))[sfMessageKey]) == strHex(rkp.first.slice())); @@ -276,7 +276,7 @@ public: using namespace std::string_literals; jt[sfMessageKey.fieldName] = strHex("NOT_REALLY_A_PUBKEY"s); - env(jt, ter(telBAD_PUBLIC_KEY)); + env(jt, Ter(telBAD_PUBLIC_KEY)); } void @@ -325,7 +325,7 @@ public: void testTransferRate() { - struct test_results + struct TestResults { double set; TER code; @@ -336,7 +336,7 @@ public: using namespace test::jtx; auto doTests = - [this](FeatureBitset const& features, std::initializer_list testData) { + [this](FeatureBitset const& features, std::initializer_list testData) { Env env(*this, features); Account const alice("alice"); @@ -344,7 +344,7 @@ public: for (auto const& r : testData) { - env(rate(alice, r.set), ter(r.code)); + env(rate(alice, r.set), Ter(r.code)); env.close(); // If the field is not present expect the default value @@ -360,7 +360,7 @@ public: }; doTests( - testable_amendments(), + testableAmendments(), {{.set = 1.0, .code = tesSUCCESS, .get = 1.0}, {.set = 1.1, .code = tesSUCCESS, .get = 1.1}, {.set = 2.0, .code = tesSUCCESS, .get = 2.0}, @@ -380,7 +380,7 @@ public: Account const alice("alice"); Account const bob("bob"); Account const gw("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Test gateway with a variety of allowed transfer rates for (double transferRate = 1.0; transferRate <= 2.0; transferRate += 0.03125) @@ -388,22 +388,22 @@ public: Env env(*this); env.fund(XRP(10000), gw, alice, bob); env.close(); - env.trust(USD(10), alice, bob); + env.trust(usd(10), alice, bob); env.close(); env(rate(gw, transferRate)); env.close(); - auto const amount = USD(1); + auto const amount = usd(1); Rate const rate(transferRate * QUALITY_ONE); auto const amountWithRate = toAmount(multiply(amount.value(), rate)); - env(pay(gw, alice, USD(10))); + env(pay(gw, alice, usd(10))); env.close(); - env(pay(alice, bob, USD(1)), sendmax(USD(10))); + env(pay(alice, bob, usd(1)), Sendmax(usd(10))); env.close(); - env.require(balance(alice, USD(10) - amountWithRate)); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(10) - amountWithRate)); + env.require(Balance(bob, usd(1))); } // Since fix1201 was enabled on Nov 14 2017 a rate in excess of @@ -419,7 +419,7 @@ public: Env env(*this); env.fund(XRP(10000), gw, alice, bob); env.close(); - env.trust(USD(10), alice, bob); + env.trust(usd(10), alice, bob); env.close(); // We'd like to use transferRate here, but the transactor @@ -459,15 +459,15 @@ public: return true; }); - auto const amount = USD(1); + auto const amount = usd(1); auto const amountWithRate = toAmount(multiply(amount.value(), Rate(transferRate * QUALITY_ONE))); - env(pay(gw, alice, USD(10))); - env(pay(alice, bob, amount), sendmax(USD(10))); + env(pay(gw, alice, usd(10))); + env(pay(alice, bob, amount), Sendmax(usd(10))); - env.require(balance(alice, USD(10) - amountWithRate)); - env.require(balance(bob, amount)); + env.require(Balance(alice, usd(10) - amountWithRate)); + env.require(Balance(bob, amount)); } } @@ -483,33 +483,33 @@ public: auto jt = fset(alice, asfDisallowXRP); jt[jss::ClearFlag] = asfDisallowXRP; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfRequireAuth); jt[jss::ClearFlag] = asfRequireAuth; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfRequireDest); jt[jss::ClearFlag] = asfRequireDest; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfDisallowXRP); jt[sfFlags.fieldName] = tfAllowXRP; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfRequireAuth); jt[sfFlags.fieldName] = tfOptionalAuth; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfRequireDest); jt[sfFlags.fieldName] = tfOptionalDestTag; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); jt = fset(alice, asfRequireDest); jt[sfFlags.fieldName] = tfAccountSetMask; - env(jt, ter(temINVALID_FLAG)); + env(jt, Ter(temINVALID_FLAG)); - env(fset(alice, asfDisableMaster), sig(alice), ter(tecNO_ALTERNATIVE_KEY)); + env(fset(alice, asfDisableMaster), Sig(alice), Ter(tecNO_ALTERNATIVE_KEY)); } void @@ -533,10 +533,10 @@ public: env.close(); BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); - env(fset(alice, asfRequireAuth), ter(tecOWNERS)); + env(fset(alice, asfRequireAuth), Ter(tecOWNERS)); // Remove the signer list. After that asfRequireAuth should succeed. - env(signers(alice, test::jtx::none)); + env(signers(alice, test::jtx::kNONE)); env.close(); BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); @@ -556,23 +556,23 @@ public: std::uint32_t const ticketSeq{env.seq(alice) + 1}; env(ticket::create(alice, 1)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Try using a ticket that alice doesn't have. - env(noop(alice), ticket::use(ticketSeq + 1), ter(terPRE_TICKET)); + env(noop(alice), ticket::Use(ticketSeq + 1), Ter(terPRE_TICKET)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Actually use alice's ticket. Note that if a transaction consumes // a ticket then the account's sequence number does not advance. std::uint32_t const aliceSeq{env.seq(alice)}; - env(noop(alice), ticket::use(ticketSeq)); + env(noop(alice), ticket::Use(ticketSeq)); env.close(); - env.require(owners(alice, 0), tickets(alice, 0)); + env.require(Owners(alice, 0), tickets(alice, 0)); BEAST_EXPECT(aliceSeq == env.seq(alice)); // Try re-using a ticket that alice already used. - env(noop(alice), ticket::use(ticketSeq), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(ticketSeq), Ter(tefNO_TICKET)); env.close(); } @@ -587,14 +587,14 @@ public: env.fund(XRP(10000), alice); env.close(); - auto jtx = env.jt(noop("alice"), ter(temBAD_SIGNATURE)); + auto jtx = env.jt(noop("alice"), Ter(temBAD_SIGNATURE)); if (!BEAST_EXPECT(jtx.stx)) return; auto stx = std::make_shared(*jtx.stx); stx->at(sfSigningPubKey) = makeSlice(std::string("badkey")); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, *stx, tapNONE, j); + auto const result = xrpl::apply(env.app(), view, *stx, TapNone, j); BEAST_EXPECT(result.ter == temBAD_SIGNATURE); BEAST_EXPECT(!result.applied); return result.applied; diff --git a/src/test/app/AccountTxPaging_test.cpp b/src/test/app/AccountTxPaging_test.cpp index b5b419f9b1..6697be44e0 100644 --- a/src/test/app/AccountTxPaging_test.cpp +++ b/src/test/app/AccountTxPaging_test.cpp @@ -12,10 +12,10 @@ namespace xrpl { -class AccountTxPaging_test : public beast::unit_test::suite +class AccountTxPaging_test : public beast::unit_test::Suite { static bool - checkTransaction(Json::Value const& tx, int sequence, int ledger) + checkTransaction(json::Value const& tx, int sequence, int ledger) { return ( tx[jss::tx][jss::Sequence].asInt() == sequence && @@ -26,16 +26,16 @@ class AccountTxPaging_test : public beast::unit_test::suite next( test::jtx::Env& env, test::jtx::Account const& account, - int ledger_min, - int ledger_max, + int ledgerMin, + int ledgerMax, int limit, bool forward, - Json::Value const& marker = Json::nullValue) + json::Value const& marker = json::NullValue) { - Json::Value jvc; + json::Value jvc; jvc[jss::account] = account.human(); - jvc[jss::ledger_index_min] = ledger_min; - jvc[jss::ledger_index_max] = ledger_max; + jvc[jss::ledger_index_min] = ledgerMin; + jvc[jss::ledger_index_max] = ledgerMax; jvc[jss::forward] = forward; jvc[jss::limit] = limit; if (marker) @@ -51,25 +51,25 @@ class AccountTxPaging_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; - env.fund(XRP(10000), A1, A2, A3); + env.fund(XRP(10000), a1, a2, a3); env.close(); - env.trust(A3["USD"](1000), A1); - env.trust(A2["USD"](1000), A1); - env.trust(A3["USD"](1000), A2); + env.trust(a3["USD"](1000), a1); + env.trust(a2["USD"](1000), a1); + env.trust(a3["USD"](1000), a2); env.close(); for (auto i = 0; i < 5; ++i) { - env(pay(A2, A1, A2["USD"](2))); - env(pay(A3, A1, A3["USD"](2))); - env(offer(A1, XRP(11), A1["USD"](1))); - env(offer(A2, XRP(10), A2["USD"](1))); - env(offer(A3, XRP(9), A3["USD"](1))); + env(pay(a2, a1, a2["USD"](2))); + env(pay(a3, a1, a3["USD"](2))); + env(offer(a1, XRP(11), a1["USD"](1))); + env(offer(a2, XRP(10), a2["USD"](1))); + env(offer(a3, XRP(9), a3["USD"](1))); env.close(); } @@ -94,7 +94,7 @@ class AccountTxPaging_test : public beast::unit_test::suite // page through the results in several ways. { // limit = 2, 3 batches giving the first 6 txs - auto jrr = next(env, A3, 2, 5, 2, true); + auto jrr = next(env, a3, 2, 5, 2, true); auto txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -103,7 +103,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 2, 5, 2, true, jrr[jss::marker]); + jrr = next(env, a3, 2, 5, 2, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -112,7 +112,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 2, 5, 2, true, jrr[jss::marker]); + jrr = next(env, a3, 2, 5, 2, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -123,7 +123,7 @@ class AccountTxPaging_test : public beast::unit_test::suite { // limit 1, 3 requests giving the first 3 txs - auto jrr = next(env, A3, 3, 9, 1, true); + auto jrr = next(env, a3, 3, 9, 1, true); auto txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 1)) return; @@ -131,7 +131,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 1, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 1, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 1)) return; @@ -139,7 +139,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 1, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 1, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 1)) return; @@ -148,7 +148,7 @@ class AccountTxPaging_test : public beast::unit_test::suite return; // continue with limit 3, to end of all txs - jrr = next(env, A3, 3, 9, 3, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -158,7 +158,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -168,7 +168,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -178,7 +178,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, true, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, true, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -189,7 +189,7 @@ class AccountTxPaging_test : public beast::unit_test::suite { // limit 2, descending, 2 batches giving last 4 txs - auto jrr = next(env, A3, 3, 9, 2, false); + auto jrr = next(env, a3, 3, 9, 2, false); auto txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -198,7 +198,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 2, false, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 2, false, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 2)) return; @@ -208,7 +208,7 @@ class AccountTxPaging_test : public beast::unit_test::suite return; // continue with limit 3 until all txs have been seen - jrr = next(env, A3, 3, 9, 3, false, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, false, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -218,7 +218,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, false, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, false, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -228,7 +228,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, false, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, false, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 3)) return; @@ -238,7 +238,7 @@ class AccountTxPaging_test : public beast::unit_test::suite if (!BEAST_EXPECT(jrr[jss::marker])) return; - jrr = next(env, A3, 3, 9, 3, false, jrr[jss::marker]); + jrr = next(env, a3, 3, 9, 3, false, jrr[jss::marker]); txs = jrr[jss::transactions]; if (!BEAST_EXPECT(txs.isArray() && txs.size() == 1)) return; diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 7edaef3821..5d4ca6f745 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -41,7 +41,7 @@ namespace xrpl { -class AmendmentTable_test final : public beast::unit_test::suite +class AmendmentTable_test final : public beast::unit_test::Suite { private: static uint256 @@ -137,12 +137,12 @@ private: template static void - combine_arg(std::vector& dest, std::vector const& src, Args const&... args) + combineArg(std::vector& dest, std::vector const& src, Args const&... args) { assert(dest.capacity() >= dest.size() + src.size()); std::copy(src.begin(), src.end(), std::back_inserter(dest)); if constexpr (sizeof...(args) > 0) - combine_arg(dest, args...); + combineArg(dest, args...); } template @@ -156,7 +156,7 @@ private: { left.reserve(totalsize(left, right, args...)); - combine_arg(left, right, args...); + combineArg(left, right, args...); return left; } @@ -191,7 +191,7 @@ public: Section const& enabled, Section const& vetoed) { - return make_AmendmentTable(app, majorityTime, supported, enabled, vetoed, journal_); + return makeAmendmentTable(app, majorityTime, supported, enabled, vetoed, journal_); } std::unique_ptr @@ -208,7 +208,7 @@ public: std::unique_ptr makeTable(test::jtx::Env& env, std::chrono::seconds majorityTime) { - static std::vector const supported = combine( + static std::vector const kSUPPORTED = combine( makeDefaultYes(yes_), // Use non-intuitive default votes for "enabled_" and "vetoed_" // so that when the tests later explicitly enable or veto them, @@ -218,7 +218,7 @@ public: makeDefaultYes(vetoed_), makeObsolete(obsolete_)); return makeTable( - env.app(), majorityTime, supported, makeSection(enabled_), makeSection(vetoed_)); + env.app(), majorityTime, kSUPPORTED, makeSection(enabled_), makeSection(vetoed_)); } void @@ -275,7 +275,7 @@ public: // Verify that unsupportedID is not in table. uint256 const unsupportedID = amendmentId(unsupported_[0]); { - Json::Value const unsupp = + json::Value const unsupp = table->getJson(unsupportedID, true)[to_string(unsupportedID)]; BEAST_EXPECT(unsupp.size() == 0); } @@ -283,7 +283,7 @@ public: // After vetoing unsupportedID verify that it is in table. table->veto(unsupportedID); { - Json::Value const unsupp = + json::Value const unsupp = table->getJson(unsupportedID, true)[to_string(unsupportedID)]; BEAST_EXPECT(unsupp[jss::vetoed].asBool()); } @@ -471,7 +471,7 @@ public: trustedValidators.reserve(num); for (int i = 0; i < num; ++i) { - auto const& back = ret.emplace_back(randomKeyPair(KeyType::secp256k1)); + auto const& back = ret.emplace_back(randomKeyPair(KeyType::Secp256k1)); trustedValidators.insert(back.first); } table->trustChanged(trustedValidators); @@ -608,14 +608,14 @@ public: uint256 const unsupportedID = amendmentId(unsupported_[0]); { - Json::Value const unsupp = + json::Value const unsupp = table->getJson(unsupportedID, false)[to_string(unsupportedID)]; BEAST_EXPECT(unsupp.size() == 0); } table->veto(unsupportedID); { - Json::Value const unsupp = + json::Value const unsupp = table->getJson(unsupportedID, false)[to_string(unsupportedID)]; BEAST_EXPECT(!unsupp[jss::vetoed].asBool()); } @@ -968,7 +968,7 @@ public: } // Add one new validator to the UNL. - validators.emplace_back(randomKeyPair(KeyType::secp256k1)); + validators.emplace_back(randomKeyPair(KeyType::Secp256k1)); // A lambda that updates the AmendmentTable with the latest // trusted validators. @@ -1165,9 +1165,9 @@ public: testcase("hasUnsupportedEnabled"); using namespace std::chrono_literals; - weeks constexpr w(1); + weeks constexpr kW(1); test::jtx::Env env{*this, makeConfig()}; - auto table = makeTable(env, w); + auto table = makeTable(env, kW); BEAST_EXPECT(!table->hasUnsupportedEnabled()); BEAST_EXPECT(!table->firstUnsupportedExpected()); BEAST_EXPECT(table->needValidatedLedger(1)); @@ -1190,7 +1190,7 @@ public: BEAST_EXPECT(table->hasUnsupportedEnabled()); BEAST_EXPECT( table->firstUnsupportedExpected() && - *table->firstUnsupportedExpected() == NetClock::time_point{t} + w); + *table->firstUnsupportedExpected() == NetClock::time_point{t} + kW); // Make sure the table knows when it needs an update. BEAST_EXPECT(!table->needValidatedLedger(256)); @@ -1212,7 +1212,7 @@ public: void run() override { - FeatureBitset const all{test::jtx::testable_amendments()}; + FeatureBitset const all{test::jtx::testableAmendments()}; testConstruct(); testGet(); diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index 56d398f8f2..8010b1e120 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -74,7 +74,7 @@ namespace xrpl::test { -class Batch_test : public beast::unit_test::suite +class Batch_test : public beast::unit_test::Suite { struct TestLedgerData { @@ -91,8 +91,8 @@ class Batch_test : public beast::unit_test::suite std::string txHash; }; - static Json::Value - getTxByIndex(Json::Value const& jrr, int const index) + static json::Value + getTxByIndex(json::Value const& jrr, int const index) { for (auto const& txn : jrr[jss::result][jss::ledger][jss::transactions]) { @@ -102,10 +102,10 @@ class Batch_test : public beast::unit_test::suite return {}; } - static Json::Value + static json::Value getLastLedger(jtx::Env& env) { - Json::Value params; + json::Value params; params[jss::ledger_index] = env.closed()->seq(); params[jss::transactions] = true; params[jss::expand] = true; @@ -115,7 +115,7 @@ class Batch_test : public beast::unit_test::suite void validateInnerTxn(jtx::Env& env, std::string const& batchID, TestLedgerData const& ledgerResult) { - Json::Value const jrr = env.rpc("tx", ledgerResult.txHash)[jss::result]; + json::Value const jrr = env.rpc("tx", ledgerResult.txHash)[jss::result]; BEAST_EXPECT(jrr[sfTransactionType.jsonName] == ledgerResult.txType); BEAST_EXPECT(jrr[jss::meta][sfTransactionResult.jsonName] == ledgerResult.result); BEAST_EXPECT(jrr[jss::meta][sfParentBatchID.jsonName] == batchID); @@ -132,7 +132,7 @@ class Batch_test : public beast::unit_test::suite auto const txn = getTxByIndex(jrr, ledgerResult.index); BEAST_EXPECT(txn[jss::hash].asString() == ledgerResult.txHash); BEAST_EXPECT(txn.isMember(jss::metaData)); - Json::Value const meta = txn[jss::metaData]; + json::Value const meta = txn[jss::metaData]; BEAST_EXPECT(txn[sfTransactionType.jsonName] == ledgerResult.txType); BEAST_EXPECT(meta[sfTransactionResult.jsonName] == ledgerResult.result); if (ledgerResult.batchID) @@ -145,7 +145,7 @@ class Batch_test : public beast::unit_test::suite submitBatch(jtx::Env& env, TER const& result, Args&&... args) { auto batchTxn = env.jt(std::forward(args)...); - env(batchTxn, jtx::ter(result)); + env(batchTxn, jtx::Ter(result)); auto const ids = batchTxn.stx->getBatchTransactionIDs(); std::vector txIDs; @@ -219,10 +219,10 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto const txResult = withBatch ? ter(tesSUCCESS) : ter(temDISABLED); + auto const txResult = withBatch ? Ter(tesSUCCESS) : Ter(temDISABLED); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), txResult); env.close(); } @@ -232,8 +232,8 @@ class Batch_test : public beast::unit_test::suite // temINVALID_FLAG. If the feature is enabled, the transaction fails // early in checkValidity() { - auto const txResult = withBatch ? ter(telENV_RPC_FAILED) : ter(temINVALID_FLAG); - env(pay(alice, bob, XRP(1)), txflags(tfInnerBatchTxn), txResult); + auto const txResult = withBatch ? Ter(telENV_RPC_FAILED) : Ter(temINVALID_FLAG); + env(pay(alice, bob, XRP(1)), Txflags(tfInnerBatchTxn), txResult); env.close(); } @@ -262,7 +262,7 @@ class Batch_test : public beast::unit_test::suite // temBAD_FEE: preflight1 { - env(batch::outer(alice, env.seq(alice), XRP(-1), tfAllOrNothing), ter(temBAD_FEE)); + env(batch::outer(alice, env.seq(alice), XRP(-1), tfAllOrNothing), Ter(temBAD_FEE)); env.close(); } @@ -271,7 +271,7 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 0); - env(batch::outer(alice, seq, batchFee, tfInnerBatchTxn), ter(telENV_RPC_FAILED)); + env(batch::outer(alice, seq, batchFee, tfInnerBatchTxn), Ter(telENV_RPC_FAILED)); env.close(); } @@ -279,7 +279,7 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 0); - env(batch::outer(alice, seq, batchFee, tfDisallowXRP), ter(temINVALID_FLAG)); + env(batch::outer(alice, seq, batchFee, tfDisallowXRP), Ter(temINVALID_FLAG)); env.close(); } @@ -288,8 +288,8 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 0); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - txflags(tfAllOrNothing | tfOnlyOne), - ter(temINVALID_FLAG)); + Txflags(tfAllOrNothing | tfOnlyOne), + Ter(temINVALID_FLAG)); env.close(); } @@ -297,7 +297,7 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 0); - env(batch::outer(alice, seq, batchFee, tfAllOrNothing), ter(temARRAY_EMPTY)); + env(batch::outer(alice, seq, batchFee, tfAllOrNothing), Ter(temARRAY_EMPTY)); env.close(); } @@ -306,8 +306,8 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 0); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - ter(temARRAY_EMPTY)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + Ter(temARRAY_EMPTY)); env.close(); } @@ -317,16 +317,16 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 9); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - batch::inner(pay(alice, bob, XRP(1)), seq + 3), - batch::inner(pay(alice, bob, XRP(1)), seq + 4), - batch::inner(pay(alice, bob, XRP(1)), seq + 5), - batch::inner(pay(alice, bob, XRP(1)), seq + 6), - batch::inner(pay(alice, bob, XRP(1)), seq + 7), - batch::inner(pay(alice, bob, XRP(1)), seq + 8), - batch::inner(pay(alice, bob, XRP(1)), seq + 9), - ter(telENV_RPC_FAILED)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 3), + batch::Inner(pay(alice, bob, XRP(1)), seq + 4), + batch::Inner(pay(alice, bob, XRP(1)), seq + 5), + batch::Inner(pay(alice, bob, XRP(1)), seq + 6), + batch::Inner(pay(alice, bob, XRP(1)), seq + 7), + batch::Inner(pay(alice, bob, XRP(1)), seq + 8), + batch::Inner(pay(alice, bob, XRP(1)), seq + 9), + Ter(telENV_RPC_FAILED)); env.close(); } @@ -336,10 +336,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto jt = env.jtnofill( batch::outer(alice, env.seq(alice), batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(10)), seq + 1)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(10)), seq + 1)); - env(jt.jv, batch::sig(bob), ter(temREDUNDANT)); + env(jt.jv, batch::Sig(bob), Ter(temREDUNDANT)); env.close(); } @@ -349,9 +349,9 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(batch::outer(alice, seq, batchFee, tfAllOrNothing), seq), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - ter(telENV_RPC_FAILED)); + batch::Inner(batch::outer(alice, seq, batchFee, tfAllOrNothing), seq), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + Ter(telENV_RPC_FAILED)); env.close(); } @@ -360,14 +360,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1[jss::Flags] = 0; auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(temINVALID_FLAG)); + env(jt.jv, batch::Sig(bob), Ter(temINVALID_FLAG)); env.close(); } @@ -377,9 +377,9 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 0, 2); auto jt = env.jt(pay(alice, bob, XRP(1))); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(jt.jv, seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - ter(temBAD_SIGNATURE)); + batch::Inner(jt.jv, seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + Ter(temBAD_SIGNATURE)); env.close(); } @@ -388,16 +388,16 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); auto tx1 = pay(alice, bob, XRP(1)); - tx1[sfSigners.jsonName] = Json::arrayValue; - tx1[sfSigners.jsonName][0U][sfSigner.jsonName] = Json::objectValue; + tx1[sfSigners.jsonName] = json::ArrayValue; + tx1[sfSigners.jsonName][0U][sfSigner.jsonName] = json::ObjectValue; tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfAccount.jsonName] = alice.human(); tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfSigningPubKey.jsonName] = strHex(alice.pk()); tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfTxnSignature.jsonName] = "DEADBEEF"; env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(tx1, seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - ter(temBAD_SIGNER)); + batch::Inner(tx1, seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + Ter(temBAD_SIGNER)); env.close(); } @@ -406,14 +406,14 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(pay(alice, bob, XRP(1)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), seq + 1); tx1[jss::SigningPubKey] = strHex(alice.pk()); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(1)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 2)); - env(jt.jv, ter(temBAD_REGKEY)); + env(jt.jv, Ter(temBAD_REGKEY)); env.close(); } @@ -422,10 +422,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // amount can't be negative - batch::inner(pay(alice, bob, XRP(-1)), seq + 2), - ter(temINVALID_INNER_BATCH)); + batch::Inner(pay(alice, bob, XRP(-1)), seq + 2), + Ter(temINVALID_INNER_BATCH)); env.close(); } @@ -433,12 +433,12 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(pay(alice, bob, XRP(1)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), seq + 1); tx1[jss::Fee] = to_string(env.current()->fees().base); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(2)), seq + 2), - ter(temBAD_FEE)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), + Ter(temBAD_FEE)); env.close(); } @@ -446,12 +446,12 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(pay(alice, bob, XRP(1)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), seq + 1); tx1[jss::Fee] = "-1"; env(batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(2)), seq + 2), - ter(temBAD_FEE)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), + Ter(temBAD_FEE)); env.close(); } @@ -459,21 +459,21 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(pay(alice, bob, XRP(1)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), seq + 1); tx1[jss::Fee] = "1.5"; - env.set_parse_failure_expected(true); + env.setParseFailureExpected(true); try { env(batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(2)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2)); fail("Expected parse_error for fractional fee"); } - catch (jtx::parse_error const&) + catch (jtx::ParseError const&) { BEAST_EXPECT(true); } - env.set_parse_failure_expected(false); + env.setParseFailureExpected(false); } // temSEQ_AND_TICKET: Batch: inner txn cannot have both Sequence @@ -481,12 +481,12 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(pay(alice, bob, XRP(1)), 0, 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(1)), 0, 1); tx1[jss::Sequence] = seq + 1; env(batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(2)), seq + 2), - ter(temSEQ_AND_TICKET)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), + Ter(temSEQ_AND_TICKET)); env.close(); } @@ -496,9 +496,9 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), - ter(temSEQ_AND_TICKET)); + batch::Inner(pay(alice, bob, XRP(1)), 0), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), + Ter(temSEQ_AND_TICKET)); env.close(); } @@ -507,9 +507,9 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 1), - ter(temREDUNDANT)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 1), + Ter(temREDUNDANT)); env.close(); } @@ -518,9 +518,9 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, seq + 1), - batch::inner(pay(alice, bob, XRP(2)), 0, seq + 1), - ter(temREDUNDANT)); + batch::Inner(pay(alice, bob, XRP(1)), 0, seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), 0, seq + 1), + Ter(temREDUNDANT)); env.close(); } @@ -529,9 +529,9 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 1), - ter(temREDUNDANT)); + batch::Inner(pay(alice, bob, XRP(1)), 0, seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 1), + Ter(temREDUNDANT)); env.close(); } @@ -542,10 +542,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 9, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(5)), seq + 2), - batch::sig(bob, carol, alice, bob, carol, alice, bob, carol, alice, alice), - ter(telENV_RPC_FAILED)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(5)), seq + 2), + batch::Sig(bob, carol, alice, bob, carol, alice, bob, carol, alice, alice), + Ter(telENV_RPC_FAILED)); env.close(); } @@ -554,10 +554,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 2, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::sig(alice, bob), - ter(temBAD_SIGNER)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Sig(alice, bob), + Ter(temBAD_SIGNER)); env.close(); } @@ -566,10 +566,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 2, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::sig(bob, bob), - ter(temREDUNDANT)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Sig(bob, bob), + Ter(temREDUNDANT)); env.close(); } @@ -579,10 +579,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(5)), seq + 2), - batch::sig(bob), - ter(temBAD_SIGNER)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(5)), seq + 2), + batch::Sig(bob), + Ter(temBAD_SIGNER)); env.close(); } @@ -591,10 +591,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::sig(carol), - ter(temBAD_SIGNER)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Sig(carol), + Ter(temBAD_SIGNER)); env.close(); } @@ -605,8 +605,8 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 1, 2); auto jt = env.jtnofill( batch::outer(alice, env.seq(alice), batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq)); Serializer msg; serializeBatch(msg, tfAllOrNothing, jt.stx->getBatchTransactionIDs()); @@ -618,7 +618,7 @@ class Batch_test : public beast::unit_test::suite jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfTxnSignature.jsonName] = strHex(Slice{sig.data(), sig.size()}); - env(jt.jv, ter(temBAD_SIGNATURE)); + env(jt.jv, Ter(temBAD_SIGNATURE)); env.close(); } @@ -627,11 +627,11 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 2, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::inner(pay(carol, alice, XRP(5)), env.seq(carol)), - batch::sig(bob), - ter(temBAD_SIGNER)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Inner(pay(carol, alice, XRP(5)), env.seq(carol)), + batch::Sig(bob), + Ter(temBAD_SIGNER)); env.close(); } } @@ -669,10 +669,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(20)), seq + 2), - sig(bob), - ter(tefBAD_AUTH)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(20)), seq + 2), + Sig(bob), + Ter(tefBAD_AUTH)); env.close(); } @@ -684,10 +684,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {dave, carol}), - ter(tefNOT_MULTI_SIGNING)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {dave, carol}), + Ter(tefNOT_MULTI_SIGNING)); env.close(); } @@ -702,10 +702,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, frank}), - ter(tefBAD_SIGNATURE)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, frank}), + Ter(tefBAD_SIGNATURE)); env.close(); } @@ -714,24 +714,24 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, Account("dave", KeyType::ed25519)}), - ter(tefBAD_SIGNATURE)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, Account("dave", KeyType::Ed25519)}), + Ter(tefBAD_SIGNATURE)); env.close(); } // tefMASTER_DISABLED: Master key disabled { env(regkey(elsa, frank)); - env(fset(elsa, asfDisableMaster), sig(elsa)); + env(fset(elsa, asfDisableMaster), Sig(elsa)); auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, elsa}), - ter(tefMASTER_DISABLED)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, elsa}), + Ter(tefMASTER_DISABLED)); env.close(); } @@ -740,10 +740,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, phantom}), - ter(tefBAD_SIGNATURE)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, phantom}), + Ter(tefBAD_SIGNATURE)); env.close(); } @@ -751,12 +751,12 @@ class Batch_test : public beast::unit_test::suite { auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); - Account const davo{"davo", KeyType::ed25519}; + Account const davo{"davo", KeyType::Ed25519}; env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, Reg{dave, davo}}), - ter(tefBAD_SIGNATURE)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, Reg{dave, davo}}), + Ter(tefBAD_SIGNATURE)); env.close(); } @@ -765,12 +765,12 @@ class Batch_test : public beast::unit_test::suite env(regkey(dave, frank)); auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); - Account const davo{"davo", KeyType::ed25519}; + Account const davo{"davo", KeyType::Ed25519}; env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, Reg{dave, davo}}), - ter(tefBAD_SIGNATURE)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, Reg{dave, davo}}), + Ter(tefBAD_SIGNATURE)); env.close(); } @@ -779,10 +779,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 2, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol}), - ter(tefBAD_QUORUM)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol}), + Ter(tefBAD_QUORUM)); env.close(); } @@ -791,10 +791,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 3, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, dave}), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, dave}), + Ter(tesSUCCESS)); env.close(); } @@ -803,11 +803,11 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 4, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(bob, alice, XRP(5)), env.seq(bob)), - batch::msig(bob, {carol, dave}), - msig(bob, carol), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(bob, alice, XRP(5)), env.seq(bob)), + batch::Msig(bob, {carol, dave}), + Msig(bob, carol), + Ter(tesSUCCESS)); env.close(); } @@ -820,10 +820,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, phantom, XRP(1000)), seq + 1), - batch::inner(noop(phantom), ledSeq), - batch::sig(Reg{phantom, carol}), - ter(tefBAD_AUTH)); + batch::Inner(pay(alice, phantom, XRP(1000)), seq + 1), + batch::Inner(noop(phantom), ledSeq), + batch::Sig(Reg{phantom, carol}), + Ter(tefBAD_AUTH)); env.close(); } @@ -833,10 +833,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1000)), seq + 1), - batch::inner(noop(bob), ledSeq), - batch::sig(Reg{bob, carol}), - ter(tefBAD_AUTH)); + batch::Inner(pay(alice, bob, XRP(1000)), seq + 1), + batch::Inner(noop(bob), ledSeq), + batch::Sig(Reg{bob, carol}), + Ter(tefBAD_AUTH)); env.close(); } @@ -846,10 +846,10 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(bob, alice, XRP(2)), env.seq(bob)), - batch::sig(Reg{bob, carol}), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(bob, alice, XRP(2)), env.seq(bob)), + batch::Sig(Reg{bob, carol}), + Ter(tesSUCCESS)); env.close(); } @@ -858,24 +858,24 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(bob, alice, XRP(2)), env.seq(bob)), - batch::sig(bob), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(bob, alice, XRP(2)), env.seq(bob)), + batch::Sig(bob), + Ter(tesSUCCESS)); env.close(); } // tefMASTER_DISABLED: Signed With Master Key Disabled { env(regkey(bob, carol)); - env(fset(bob, asfDisableMaster), sig(bob)); + env(fset(bob, asfDisableMaster), Sig(bob)); auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 1, 2); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(bob, alice, XRP(2)), env.seq(bob)), - batch::sig(bob), - ter(tefMASTER_DISABLED)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(bob, alice, XRP(2)), env.seq(bob)), + batch::Sig(bob), + Ter(tefMASTER_DISABLED)); env.close(); } } @@ -899,14 +899,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1.removeMember(jss::TransactionType); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(telENV_RPC_FAILED)); + env(jt.jv, batch::Sig(bob), Ter(telENV_RPC_FAILED)); env.close(); } @@ -914,14 +914,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1.removeMember(jss::Account); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(telENV_RPC_FAILED)); + env(jt.jv, batch::Sig(bob), Ter(telENV_RPC_FAILED)); env.close(); } @@ -929,14 +929,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1.removeMember(jss::Sequence); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(telENV_RPC_FAILED)); + env(jt.jv, batch::Sig(bob), Ter(telENV_RPC_FAILED)); env.close(); } @@ -944,14 +944,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1.removeMember(jss::Fee); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(telENV_RPC_FAILED)); + env(jt.jv, batch::Sig(bob), Ter(telENV_RPC_FAILED)); env.close(); } @@ -959,14 +959,14 @@ class Batch_test : public beast::unit_test::suite { auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const seq = env.seq(alice); - auto tx1 = batch::inner(pay(alice, bob, XRP(10)), seq + 1); + auto tx1 = batch::Inner(pay(alice, bob, XRP(10)), seq + 1); tx1.removeMember(jss::SigningPubKey); auto jt = env.jtnofill( batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(10)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 2)); - env(jt.jv, batch::sig(bob), ter(telENV_RPC_FAILED)); + env(jt.jv, batch::Sig(bob), Ter(telENV_RPC_FAILED)); env.close(); } } @@ -984,35 +984,35 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(gw, bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(gw, bob, usd(100))); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); // Invalid: Alice Sequence is a past sequence { auto const preAliceSeq = env.seq(alice); auto const preAlice = env.balance(alice); - auto const preAliceUSD = env.balance(alice, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); auto const preBobSeq = env.seq(bob); auto const preBob = env.balance(bob); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), preAliceSeq - 10), - batch::inner(pay(bob, alice, XRP(5)), preBobSeq), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), preAliceSeq - 10), + batch::Inner(pay(bob, alice, XRP(5)), preBobSeq), + batch::Sig(bob)); env.close(); { @@ -1032,29 +1032,29 @@ class Batch_test : public beast::unit_test::suite // Alice pays fee & Bob should not be affected. BEAST_EXPECT(env.seq(alice) == preAliceSeq + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); BEAST_EXPECT(env.seq(bob) == preBobSeq); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } // Invalid: Alice Sequence is a future sequence { auto const preAliceSeq = env.seq(alice); auto const preAlice = env.balance(alice); - auto const preAliceUSD = env.balance(alice, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); auto const preBobSeq = env.seq(bob); auto const preBob = env.balance(bob); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), preAliceSeq + 10), - batch::inner(pay(bob, alice, XRP(5)), preBobSeq), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), preAliceSeq + 10), + batch::Inner(pay(bob, alice, XRP(5)), preBobSeq), + batch::Sig(bob)); env.close(); { @@ -1074,29 +1074,29 @@ class Batch_test : public beast::unit_test::suite // Alice pays fee & Bob should not be affected. BEAST_EXPECT(env.seq(alice) == preAliceSeq + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); BEAST_EXPECT(env.seq(bob) == preBobSeq); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } // Invalid: Bob Sequence is a past sequence { auto const preAliceSeq = env.seq(alice); auto const preAlice = env.balance(alice); - auto const preAliceUSD = env.balance(alice, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); auto const preBobSeq = env.seq(bob); auto const preBob = env.balance(bob); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), preAliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), preBobSeq - 10), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), preAliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), preBobSeq - 10), + batch::Sig(bob)); env.close(); { @@ -1116,29 +1116,29 @@ class Batch_test : public beast::unit_test::suite // Alice pays fee & Bob should not be affected. BEAST_EXPECT(env.seq(alice) == preAliceSeq + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); BEAST_EXPECT(env.seq(bob) == preBobSeq); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } // Invalid: Bob Sequence is a future sequence { auto const preAliceSeq = env.seq(alice); auto const preAlice = env.balance(alice); - auto const preAliceUSD = env.balance(alice, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); auto const preBobSeq = env.seq(bob); auto const preBob = env.balance(bob); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), preAliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), preBobSeq + 10), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), preAliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), preBobSeq + 10), + batch::Sig(bob)); env.close(); { @@ -1158,29 +1158,29 @@ class Batch_test : public beast::unit_test::suite // Alice pays fee & Bob should not be affected. BEAST_EXPECT(env.seq(alice) == preAliceSeq + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); BEAST_EXPECT(env.seq(bob) == preBobSeq); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } // Invalid: Outer and Inner Sequence are the same { auto const preAliceSeq = env.seq(alice); auto const preAlice = env.balance(alice); - auto const preAliceUSD = env.balance(alice, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); auto const preBobSeq = env.seq(bob); auto const preBob = env.balance(bob); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), preAliceSeq), - batch::inner(pay(bob, alice, XRP(5)), preBobSeq), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), preAliceSeq), + batch::Inner(pay(bob, alice, XRP(5)), preBobSeq), + batch::Sig(bob)); env.close(); { @@ -1200,10 +1200,10 @@ class Batch_test : public beast::unit_test::suite // Alice pays fee & Bob should not be affected. BEAST_EXPECT(env.seq(alice) == preAliceSeq + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); BEAST_EXPECT(env.seq(bob) == preBobSeq); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } } @@ -1224,16 +1224,16 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); // Bad Fee: Should be batch::calcBatchFee(env, 0, 2) auto const batchFee = batch::calcBatchFee(env, 0, 1); auto const aliceSeq = env.seq(alice); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(15)), aliceSeq + 2), - ter(telINSUF_FEE_P)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(15)), aliceSeq + 2), + Ter(telINSUF_FEE_P)); env.close(); } @@ -1247,7 +1247,7 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); env(signers(alice, 2, {{bob, 1}, {carol, 1}})); @@ -1257,10 +1257,10 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 1, 2); auto const aliceSeq = env.seq(alice); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(15)), aliceSeq + 2), - msig(bob, carol), - ter(telINSUF_FEE_P)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(15)), aliceSeq + 2), + Msig(bob, carol), + Ter(telINSUF_FEE_P)); env.close(); } @@ -1274,7 +1274,7 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); env(signers(alice, 2, {{bob, 1}, {carol, 1}})); @@ -1285,11 +1285,11 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto const bobSeq = env.seq(bob); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob), - msig(bob, carol), - ter(telINSUF_FEE_P)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob), + Msig(bob, carol), + Ter(telINSUF_FEE_P)); env.close(); } @@ -1303,7 +1303,7 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); env(signers(alice, 2, {{bob, 1}, {carol, 1}})); @@ -1317,11 +1317,11 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto const bobSeq = env.seq(bob); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::msig(bob, {alice, carol}), - msig(bob, carol), - ter(telINSUF_FEE_P)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Msig(bob, {alice, carol}), + Msig(bob, carol), + Ter(telINSUF_FEE_P)); env.close(); } @@ -1334,7 +1334,7 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); // Bad Fee: Should be batch::calcBatchFee(env, 1, 2) @@ -1342,10 +1342,10 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto const bobSeq = env.seq(bob); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob), - ter(telINSUF_FEE_P)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob), + Ter(telINSUF_FEE_P)); env.close(); } @@ -1356,15 +1356,15 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); auto const ammCreate = [&alice](STAmount const& amount, STAmount const& amount2) { - Json::Value jv; + json::Value jv; jv[jss::Account] = alice.human(); - jv[jss::Amount] = amount.getJson(JsonOptions::none); - jv[jss::Amount2] = amount2.getJson(JsonOptions::none); + jv[jss::Amount] = amount.getJson(JsonOptions::KNone); + jv[jss::Amount2] = amount2.getJson(JsonOptions::KNone); jv[jss::TradingFee] = 0; jv[jss::TransactionType] = jss::AMMCreate; return jv; @@ -1373,9 +1373,9 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 0, 2); auto const seq = env.seq(alice); env(batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(ammCreate(XRP(10), USD(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(10)), seq + 2), - ter(telINSUF_FEE_P)); + batch::Inner(ammCreate(XRP(10), usd(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(10)), seq + 2), + Ter(telINSUF_FEE_P)); env.close(); } } @@ -1400,16 +1400,16 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 0, 9); auto const aliceSeq = env.seq(alice); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - ter(telENV_RPC_FAILED)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + Ter(telENV_RPC_FAILED)); env.close(); } @@ -1426,18 +1426,18 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto jt = env.jtnofill( batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq)); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, j); + auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, j); BEAST_EXPECT(!result.applied && result.ter == temARRAY_TOO_LARGE); return result.applied; }); @@ -1455,10 +1455,10 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 9, 2); env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(5)), aliceSeq + 2), - batch::sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob), - ter(telENV_RPC_FAILED)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(5)), aliceSeq + 2), + batch::Sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob), + Ter(telENV_RPC_FAILED)); env.close(); } @@ -1475,12 +1475,12 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto jt = env.jtnofill( batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(5)), aliceSeq + 2), - batch::sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(5)), aliceSeq + 2), + batch::Sig(bob, bob, bob, bob, bob, bob, bob, bob, bob, bob)); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, j); + auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, j); BEAST_EXPECT(!result.applied && result.ter == temARRAY_TOO_LARGE); return result.applied; }); @@ -1500,7 +1500,7 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); @@ -1515,8 +1515,8 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2)); env.close(); std::vector const testCases = { @@ -1546,9 +1546,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 2)); env.close(); std::vector const testCases = { @@ -1575,9 +1575,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // tefNO_AUTH_REQUIRED: trustline auth is not required - batch::inner(trust(alice, USD(1000), tfSetfAuth), seq + 2)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), seq + 2)); env.close(); std::vector const testCases = { @@ -1604,9 +1604,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // terPRE_TICKET: ticket does not exist - batch::inner(trust(alice, USD(1000), tfSetfAuth), 0, seq + 2)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), 0, seq + 2)); env.close(); std::vector const testCases = { @@ -1638,7 +1638,7 @@ class Batch_test : public beast::unit_test::suite auto const carol = Account("carol"); auto const dave = Account("dave"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, dave, gw); env.close(); @@ -1654,11 +1654,11 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 1), + batch::Inner(pay(alice, bob, XRP(9999)), seq + 1), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 2), + batch::Inner(pay(alice, bob, XRP(9999)), seq + 2), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 3)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 3)); env.close(); std::vector const testCases = { @@ -1689,9 +1689,9 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -1720,10 +1720,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 2), - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 2), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -1752,9 +1752,9 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), // tefNO_AUTH_REQUIRED: trustline auth is not required - batch::inner(trust(alice, USD(1000), tfSetfAuth), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -1783,9 +1783,9 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), // terPRE_TICKET: ticket does not exist - batch::inner(trust(alice, USD(1000), tfSetfAuth), 0, seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), 0, seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -1814,15 +1814,15 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfOnlyOne), - batch::inner( + batch::Inner( offer(alice, alice["USD"](100), XRP(100), tfImmediateOrCancel), seq + 1), - batch::inner( + batch::Inner( offer(alice, alice["USD"](100), XRP(100), tfImmediateOrCancel), seq + 2), - batch::inner( + batch::Inner( offer(alice, alice["USD"](100), XRP(100), tfImmediateOrCancel), seq + 3), - batch::inner(pay(alice, bob, XRP(100)), seq + 4), - batch::inner(pay(alice, carol, XRP(100)), seq + 5), - batch::inner(pay(alice, dave, XRP(100)), seq + 6)); + batch::Inner(pay(alice, bob, XRP(100)), seq + 4), + batch::Inner(pay(alice, carol, XRP(100)), seq + 5), + batch::Inner(pay(alice, dave, XRP(100)), seq + 6)); env.close(); std::vector const testCases = { @@ -1855,7 +1855,7 @@ class Batch_test : public beast::unit_test::suite auto const carol = Account("carol"); auto const dave = Account("dave"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, dave, gw); env.close(); @@ -1871,10 +1871,10 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - batch::inner(pay(alice, bob, XRP(2)), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -1902,10 +1902,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), - batch::inner(pay(alice, bob, XRP(3)), seq + 3), - batch::inner(pay(alice, bob, XRP(4)), seq + 4)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(3)), seq + 3), + batch::Inner(pay(alice, bob, XRP(4)), seq + 4)); env.close(); std::vector const testCases = { @@ -1936,11 +1936,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -1970,11 +1970,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // tefNO_AUTH_REQUIRED: trustline auth is not required - batch::inner(trust(alice, USD(1000), tfSetfAuth), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -2003,11 +2003,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // terPRE_TICKET: ticket does not exist - batch::inner(trust(alice, USD(1000), tfSetfAuth), 0, seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), 0, seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -2036,11 +2036,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfUntilFailure), - batch::inner(pay(alice, bob, XRP(100)), seq + 1), - batch::inner(pay(alice, carol, XRP(100)), seq + 2), - batch::inner( + batch::Inner(pay(alice, bob, XRP(100)), seq + 1), + batch::Inner(pay(alice, carol, XRP(100)), seq + 2), + batch::Inner( offer(alice, alice["USD"](100), XRP(100), tfImmediateOrCancel), seq + 3), - batch::inner(pay(alice, dave, XRP(100)), seq + 4)); + batch::Inner(pay(alice, dave, XRP(100)), seq + 4)); env.close(); std::vector const testCases = { @@ -2071,7 +2071,7 @@ class Batch_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); @@ -2086,12 +2086,12 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 2), + batch::Inner(pay(alice, bob, XRP(9999)), seq + 2), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -2122,11 +2122,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // tecUNFUNDED_PAYMENT: alice does not have enough XRP - batch::inner(pay(alice, bob, XRP(9999)), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 4)); + batch::Inner(pay(alice, bob, XRP(9999)), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 4)); env.close(); std::vector const testCases = { @@ -2157,11 +2157,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // tefNO_AUTH_REQUIRED: trustline auth is not required - batch::inner(trust(alice, USD(1000), tfSetfAuth), seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 3)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 3)); env.close(); std::vector const testCases = { @@ -2191,11 +2191,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(2)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(2)), seq + 2), // terPRE_TICKET: ticket does not exist - batch::inner(trust(alice, USD(1000), tfSetfAuth), 0, seq + 3), - batch::inner(pay(alice, bob, XRP(3)), seq + 3)); + batch::Inner(trust(alice, usd(1000), tfSetfAuth), 0, seq + 3), + batch::Inner(pay(alice, bob, XRP(3)), seq + 3)); env.close(); std::vector const testCases = { @@ -2225,9 +2225,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(100)), seq + 1), - batch::inner(pay(alice, carol, XRP(100)), seq + 2), - batch::inner( + batch::Inner(pay(alice, bob, XRP(100)), seq + 1), + batch::Inner(pay(alice, carol, XRP(100)), seq + 2), + batch::Inner( offer(alice, alice["USD"](100), XRP(100), tfImmediateOrCancel), seq + 3)); env.close(); @@ -2312,7 +2312,7 @@ class Batch_test : public beast::unit_test::suite // - has no `Signers` field // + has `tfInnerBatchTxn` flag { - auto txn = batch::inner(pay(alice, bob, XRP(1)), env.seq(alice)); + auto txn = batch::Inner(pay(alice, bob, XRP(1)), env.seq(alice)); txn[sfTxnSignature] = "DEADBEEF"; STParsedJSONObject parsed("test", txn.getTxn()); Serializer s; @@ -2326,7 +2326,7 @@ class Batch_test : public beast::unit_test::suite // - has no `Signers` field // + has `tfInnerBatchTxn` flag { - auto txn = batch::inner(pay(alice, bob, XRP(1)), env.seq(alice)); + auto txn = batch::Inner(pay(alice, bob, XRP(1)), env.seq(alice)); txn[sfSigningPubKey] = strHex(alice.pk()); STParsedJSONObject parsed("test", txn.getTxn()); Serializer s; @@ -2345,8 +2345,8 @@ class Batch_test : public beast::unit_test::suite // + has `Signers` field // + has `tfInnerBatchTxn` flag { - auto txn = batch::inner(pay(alice, bob, XRP(1)), env.seq(alice)); - txn[sfSigners] = Json::arrayValue; + auto txn = batch::Inner(pay(alice, bob, XRP(1)), env.seq(alice)); + txn[sfSigners] = json::ArrayValue; STParsedJSONObject parsed("test", txn.getTxn()); Serializer s; parsed.object->add(s); // NOLINT(bugprone-unchecked-optional-access) @@ -2360,7 +2360,7 @@ class Batch_test : public beast::unit_test::suite { // Fully signed inner batch transaction - auto const txn = batch::inner(pay(alice, bob, XRP(1)), env.seq(alice)); + auto const txn = batch::Inner(pay(alice, bob, XRP(1)), env.seq(alice)); auto const jt = env.jt(txn.getTxn()); STParsedJSONObject parsed("test", jt.jv); @@ -2376,7 +2376,7 @@ class Batch_test : public beast::unit_test::suite // - has no `Signers` field // + has `tfInnerBatchTxn` flag { - auto txn = batch::inner(pay(alice, bob, XRP(1)), env.seq(alice)); + auto txn = batch::Inner(pay(alice, bob, XRP(1)), env.seq(alice)); STParsedJSONObject parsed("test", txn.getTxn()); Serializer s; parsed.object->add(s); // NOLINT(bugprone-unchecked-optional-access) @@ -2401,7 +2401,7 @@ class Batch_test : public beast::unit_test::suite obj.setFieldU32(sfLedgerSequence, seq); obj.setFieldU32(sfFlags, tfInnerBatchTxn); }); - auto txn = batch::inner(amendTx.getJson(JsonOptions::none), env.seq(alice)); + auto txn = batch::Inner(amendTx.getJson(JsonOptions::KNone), env.seq(alice)); STParsedJSONObject parsed("test", txn.getTxn()); Serializer s; parsed.object->add(s); // NOLINT(bugprone-unchecked-optional-access) @@ -2448,9 +2448,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1000)), seq + 1), - batch::inner(fset(bob, asfAllowTrustLineClawback), ledSeq), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(1000)), seq + 1), + batch::Inner(fset(bob, asfAllowTrustLineClawback), ledSeq), + batch::Sig(bob)); env.close(); std::vector const testCases = { @@ -2491,7 +2491,7 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - auto tx1 = batch::inner(noop(alice), seq + 1); + auto tx1 = batch::Inner(noop(alice), seq + 1); std::string domain = "example.com"; tx1[sfDomain] = strHex(domain); auto const [txIDs, batchID] = submitBatch( @@ -2499,7 +2499,7 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), tx1, - batch::inner(pay(alice, bob, XRP(1)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 2)); env.close(); std::vector const testCases = { @@ -2551,10 +2551,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(acctdelete(alice, bob), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(acctdelete(alice, bob), seq + 2), // terNO_ACCOUNT: alice does not exist - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -2594,10 +2594,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfIndependent), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), // tecHAS_OBLIGATIONS: alice has obligations - batch::inner(acctdelete(alice, bob), seq + 2), - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(acctdelete(alice, bob), seq + 2), + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -2635,10 +2635,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(acctdelete(alice, bob), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(acctdelete(alice, bob), seq + 2), // terNO_ACCOUNT: alice does not exist - batch::inner(pay(alice, bob, XRP(2)), seq + 3)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 3)); env.close(); std::vector const testCases = { @@ -2658,7 +2658,7 @@ class Batch_test : public beast::unit_test::suite testcase("loan"); bool const lendingBatchEnabled = !std::ranges::any_of( - Batch::disabledTxTypes, + Batch::kDISABLED_TX_TYPES, [](auto const& disabled) { return disabled == ttLOAN_BROKER_SET; }); using namespace test::jtx; @@ -2699,10 +2699,10 @@ class Batch_test : public beast::unit_test::suite { using namespace loanBroker; env(set(lender, vaultKeylet.key), - managementFeeRate(TenthBips16(100)), - debtMaximum(debtMaximumValue), - coverRateMinimum(TenthBips32(percentageToTenthBips(10))), - coverRateLiquidation(TenthBips32(percentageToTenthBips(25)))); + kMANAGEMENT_FEE_RATE(TenthBips16(100)), + kDEBT_MAXIMUM(debtMaximumValue), + kCOVER_RATE_MINIMUM(TenthBips32(percentageToTenthBips(10))), + kCOVER_RATE_LIQUIDATION(TenthBips32(percentageToTenthBips(25)))); env(coverDeposit(lender, brokerKeylet.key, coverDepositValue)); @@ -2722,16 +2722,16 @@ class Batch_test : public beast::unit_test::suite env, lendingBatchEnabled ? temBAD_SIGNATURE : temINVALID_INNER_BATCH, batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing), - batch::inner( + batch::Inner( env.json( set(lender, brokerKeylet.key, asset(1000).value()), // Not allowed to include the counterparty signature - sig(sfCounterpartySignature, borrower), - sig(none), - fee(none), - seq(none)), + Sig(sfCounterpartySignature, borrower), + Sig(kNONE), + Fee(kNONE), + Seq(kNONE)), lenderSeq + 1), - batch::inner( + batch::Inner( pay(lender, loanKeylet.key, STAmount{asset, asset(500).value()}), lenderSeq + 2)); } @@ -2740,15 +2740,15 @@ class Batch_test : public beast::unit_test::suite env, temINVALID_INNER_BATCH, batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing), - batch::inner( + batch::Inner( env.json( set(lender, brokerKeylet.key, asset(1000).value()), // Counterparty must be set - sig(none), - fee(none), - seq(none)), + Sig(kNONE), + Fee(kNONE), + Seq(kNONE)), lenderSeq + 1), - batch::inner( + batch::Inner( pay(lender, loanKeylet.key, STAmount{asset, asset(500).value()}), lenderSeq + 2)); } @@ -2757,16 +2757,16 @@ class Batch_test : public beast::unit_test::suite env, lendingBatchEnabled ? temBAD_SIGNER : temINVALID_INNER_BATCH, batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing), - batch::inner( + batch::Inner( env.json( set(lender, brokerKeylet.key, asset(1000).value()), // Counterparty must sign the outer transaction - counterparty(borrower.id()), - sig(none), - fee(none), - seq(none)), + kCOUNTERPARTY(borrower.id()), + Sig(kNONE), + Fee(kNONE), + Seq(kNONE)), lenderSeq + 1), - batch::inner( + batch::Inner( pay(lender, loanKeylet.key, STAmount{asset, asset(500).value()}), lenderSeq + 2)); } @@ -2779,15 +2779,15 @@ class Batch_test : public beast::unit_test::suite env, lendingBatchEnabled ? TER(tesSUCCESS) : TER(temINVALID_INNER_BATCH), batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing), - batch::inner( + batch::Inner( env.json( set(lender, brokerKeylet.key, asset(1000).value()), - counterparty(borrower.id()), - sig(none), - fee(none), - seq(none)), + kCOUNTERPARTY(borrower.id()), + Sig(kNONE), + Fee(kNONE), + Seq(kNONE)), lenderSeq + 1), - batch::inner( + batch::Inner( pay( // However, this inner transaction will fail, // because the lender is not allowed to draw the @@ -2796,7 +2796,7 @@ class Batch_test : public beast::unit_test::suite loanKeylet.key, STAmount{asset, asset(500).value()}), lenderSeq + 2), - batch::sig(borrower)); + batch::Sig(borrower)); } env.close(); BEAST_EXPECT(env.le(brokerKeylet)); @@ -2811,16 +2811,16 @@ class Batch_test : public beast::unit_test::suite env, lendingBatchEnabled ? TER(tesSUCCESS) : TER(temINVALID_INNER_BATCH), batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing), - batch::inner( + batch::Inner( env.json( set(lender, brokerKeylet.key, asset(1000).value()), - counterparty(borrower.id()), - sig(none), - fee(none), - seq(none)), + kCOUNTERPARTY(borrower.id()), + Sig(kNONE), + Fee(kNONE), + Seq(kNONE)), lenderSeq + 1), - batch::inner(manage(lender, loanKeylet.key, tfLoanImpair), lenderSeq + 2), - batch::sig(borrower)); + batch::Inner(manage(lender, loanKeylet.key, tfLoanImpair), lenderSeq + 2), + batch::Sig(borrower)); } env.close(); BEAST_EXPECT(env.le(brokerKeylet)); @@ -2845,14 +2845,14 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(gw, bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(gw, bob, usd(100))); env.close(); // success @@ -2861,8 +2861,8 @@ class Batch_test : public beast::unit_test::suite auto const bobSeq = env.seq(bob); auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); - auto const preAliceUSD = env.balance(alice, USD.issue()); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); uint256 const chkID{getCheckIndex(bob, env.seq(bob))}; @@ -2870,9 +2870,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(check::create(bob, alice, USD(10)), bobSeq), - batch::inner(check::cash(alice, chkID, USD(10)), aliceSeq + 1), - batch::sig(bob)); + batch::Inner(check::create(bob, alice, usd(10)), bobSeq), + batch::Inner(check::cash(alice, chkID, usd(10)), aliceSeq + 1), + batch::Sig(bob)); env.close(); std::vector const testCases = { @@ -2893,8 +2893,8 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(bob) == preBob); // Alice pays USD & Bob receives USD - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD + USD(10)); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD - USD(10)); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD + usd(10)); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD - usd(10)); } // failure @@ -2906,8 +2906,8 @@ class Batch_test : public beast::unit_test::suite auto const bobSeq = env.seq(bob); auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); - auto const preAliceUSD = env.balance(alice, USD.issue()); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 2); uint256 const chkID{getCheckIndex(bob, env.seq(bob))}; @@ -2916,9 +2916,9 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfIndependent), // tecDST_TAG_NEEDED - alice has enabled asfRequireDest - batch::inner(check::create(bob, alice, USD(10)), bobSeq), - batch::inner(check::cash(alice, chkID, USD(10)), aliceSeq + 1), - batch::sig(bob)); + batch::Inner(check::create(bob, alice, usd(10)), bobSeq), + batch::Inner(check::cash(alice, chkID, usd(10)), aliceSeq + 1), + batch::Sig(bob)); env.close(); std::vector const testCases = { @@ -2939,8 +2939,8 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(bob) == preBob); // Alice pays USD & Bob receives USD - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD); } } @@ -2957,22 +2957,22 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(gw, bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(gw, bob, usd(100))); env.close(); auto const aliceSeq = env.seq(alice); auto const bobSeq = env.seq(bob); auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); - auto const preAliceUSD = env.balance(alice, USD.issue()); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 1, 3); uint256 const chkID{getCheckIndex(bob, bobSeq + 1)}; @@ -2980,10 +2980,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(ticket::create(bob, 10), bobSeq), - batch::inner(check::create(bob, alice, USD(10)), 0, bobSeq + 1), - batch::inner(check::cash(alice, chkID, USD(10)), aliceSeq + 1), - batch::sig(bob)); + batch::Inner(ticket::create(bob, 10), bobSeq), + batch::Inner(check::create(bob, alice, usd(10)), 0, bobSeq + 1), + batch::Inner(check::cash(alice, chkID, usd(10)), aliceSeq + 1), + batch::Sig(bob)); env.close(); std::vector const testCases = { @@ -2998,8 +2998,8 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(env.seq(bob) == bobSeq + 10 + 1); BEAST_EXPECT(env.balance(alice) == preAlice - batchFee); BEAST_EXPECT(env.balance(bob) == preBob); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD + USD(10)); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD - USD(10)); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD + usd(10)); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD - usd(10)); } void @@ -3016,14 +3016,14 @@ class Batch_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(gw, bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(gw, bob, usd(100))); env.close(); auto const aliceSeq = env.seq(alice); @@ -3032,8 +3032,8 @@ class Batch_test : public beast::unit_test::suite auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); auto const preCarol = env.balance(carol); - auto const preAliceUSD = env.balance(alice, USD.issue()); - auto const preBobUSD = env.balance(bob, USD.issue()); + auto const preAliceUSD = env.balance(alice, usd.issue()); + auto const preBobUSD = env.balance(bob, usd.issue()); auto const batchFee = batch::calcBatchFee(env, 2, 2); uint256 const chkID{getCheckIndex(bob, env.seq(bob))}; @@ -3041,9 +3041,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(carol, carolSeq, batchFee, tfAllOrNothing), - batch::inner(check::create(bob, alice, USD(10)), bobSeq), - batch::inner(check::cash(alice, chkID, USD(10)), aliceSeq), - batch::sig(alice, bob)); + batch::Inner(check::create(bob, alice, usd(10)), bobSeq), + batch::Inner(check::cash(alice, chkID, usd(10)), aliceSeq), + batch::Sig(alice, bob)); env.close(); std::vector const testCases = { @@ -3059,8 +3059,8 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(alice) == preAlice); BEAST_EXPECT(env.balance(bob) == preBob); BEAST_EXPECT(env.balance(carol) == preCarol - batchFee); - BEAST_EXPECT(env.balance(alice, USD.issue()) == preAliceUSD + USD(10)); - BEAST_EXPECT(env.balance(bob, USD.issue()) == preBobUSD - USD(10)); + BEAST_EXPECT(env.balance(alice, usd.issue()) == preAliceUSD + usd(10)); + BEAST_EXPECT(env.balance(bob, usd.issue()) == preBobUSD - usd(10)); } void @@ -3093,9 +3093,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq + 0), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 1), - ticket::use(aliceTicketSeq)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq + 0), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 1), + ticket::Use(aliceTicketSeq)); env.close(); std::vector const testCases = { @@ -3142,8 +3142,8 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq), - batch::inner(pay(alice, bob, XRP(2)), 0, aliceTicketSeq + 1)); + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq), + batch::Inner(pay(alice, bob, XRP(2)), 0, aliceTicketSeq + 1)); env.close(); std::vector const testCases = { @@ -3190,9 +3190,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq), - ticket::use(aliceTicketSeq)); + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq), + ticket::Use(aliceTicketSeq)); env.close(); std::vector const testCases = { @@ -3240,9 +3240,9 @@ class Batch_test : public beast::unit_test::suite auto const carolSeq = env.seq(carol); // AccountSet Txn - auto const noopTxn = env.jt(noop(alice), seq(aliceSeq + 2)); + auto const noopTxn = env.jt(noop(alice), Seq(aliceSeq + 2)); auto const noopTxnID = to_string(noopTxn.stx->getTransactionID()); - env(noopTxn, ter(terPRE_SEQ)); + env(noopTxn, Ter(terPRE_SEQ)); // Batch Txn auto const batchFee = batch::calcBatchFee(env, 1, 2); @@ -3250,9 +3250,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(carol, carolSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 1), - batch::sig(alice)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 1), + batch::Sig(alice)); env.close(); { @@ -3286,8 +3286,8 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); // AccountSet Txn - auto const noopTxn = env.jt(noop(alice), seq(aliceSeq + 1)); - env(noopTxn, ter(terPRE_SEQ)); + auto const noopTxn = env.jt(noop(alice), Seq(aliceSeq + 1)); + env(noopTxn, Ter(terPRE_SEQ)); // Batch Txn auto const batchFee = batch::calcBatchFee(env, 0, 2); @@ -3295,8 +3295,8 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 2)); env.close(); { @@ -3331,11 +3331,11 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq + 1), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq + 1), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 2)); - auto const noopTxn = env.jt(noop(alice), seq(aliceSeq + 1)); - env(noopTxn, ter(tesSUCCESS)); + auto const noopTxn = env.jt(noop(alice), Seq(aliceSeq + 1)); + env(noopTxn, Ter(tesSUCCESS)); env.close(); { @@ -3370,14 +3370,14 @@ class Batch_test : public beast::unit_test::suite env, terPRE_SEQ, batch::outer(carol, carolSeq + 1, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), aliceSeq), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 1), - batch::sig(alice)); + batch::Inner(pay(alice, bob, XRP(1)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 1), + batch::Sig(alice)); // AccountSet Txn - auto const noopTxn = env.jt(noop(carol), seq(carolSeq)); + auto const noopTxn = env.jt(noop(carol), Seq(carolSeq)); auto const noopTxnID = to_string(noopTxn.stx->getTransactionID()); - env(noopTxn, ter(tesSUCCESS)); + env(noopTxn, Ter(tesSUCCESS)); env.close(); { @@ -3426,8 +3426,8 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); // AccountSet Txn - auto const noopTxn = env.jt(noop(alice), ticket::use(aliceTicketSeq + 1)); - env(noopTxn, ter(tesSUCCESS)); + auto const noopTxn = env.jt(noop(alice), ticket::Use(aliceTicketSeq + 1)); + env(noopTxn, Ter(tesSUCCESS)); // Batch Txn auto const batchFee = batch::calcBatchFee(env, 0, 2); @@ -3435,9 +3435,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq), - ticket::use(aliceTicketSeq)); + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq), + ticket::Use(aliceTicketSeq)); env.close(); { @@ -3478,12 +3478,12 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - batch::inner(pay(alice, bob, XRP(2)), aliceSeq), - ticket::use(aliceTicketSeq)); + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq), + ticket::Use(aliceTicketSeq)); // AccountSet Txn - auto const noopTxn = env.jt(noop(alice), ticket::use(aliceTicketSeq + 1)); + auto const noopTxn = env.jt(noop(alice), ticket::Use(aliceTicketSeq + 1)); env(noopTxn); env.close(); @@ -3537,7 +3537,7 @@ class Batch_test : public beast::unit_test::suite uint256 const chkID{getCheckIndex(alice, aliceSeq)}; auto const objTxn = env.jt(check::cash(bob, chkID, XRP(10))); auto const objTxnID = to_string(objTxn.stx->getTransactionID()); - env(objTxn, ter(tecNO_ENTRY)); + env(objTxn, Ter(tecNO_ENTRY)); // Batch Txn auto const batchFee = batch::calcBatchFee(env, 0, 2); @@ -3545,9 +3545,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(check::create(alice, bob, XRP(10)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - ticket::use(aliceTicketSeq)); + batch::Inner(check::create(alice, bob, XRP(10)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + ticket::Use(aliceTicketSeq)); env.close(); { @@ -3585,7 +3585,7 @@ class Batch_test : public beast::unit_test::suite uint256 const chkID{getCheckIndex(alice, aliceSeq)}; auto const objTxn = env.jt(check::create(alice, bob, XRP(10))); auto const objTxnID = to_string(objTxn.stx->getTransactionID()); - env(objTxn, ter(tesSUCCESS)); + env(objTxn, Ter(tesSUCCESS)); // Batch Txn auto const batchFee = batch::calcBatchFee(env, 1, 2); @@ -3593,10 +3593,10 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(check::cash(bob, chkID, XRP(10)), bobSeq), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - ticket::use(aliceTicketSeq), - batch::sig(bob)); + batch::Inner(check::cash(bob, chkID, XRP(10)), bobSeq), + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + ticket::Use(aliceTicketSeq), + batch::Sig(bob)); env.close(); { @@ -3634,14 +3634,14 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, 0, batchFee, tfAllOrNothing), - batch::inner(check::create(alice, bob, XRP(10)), aliceSeq), - batch::inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), - ticket::use(aliceTicketSeq)); + batch::Inner(check::create(alice, bob, XRP(10)), aliceSeq), + batch::Inner(pay(alice, bob, XRP(1)), 0, aliceTicketSeq + 1), + ticket::Use(aliceTicketSeq)); // CheckCash Txn auto const objTxn = env.jt(check::cash(bob, chkID, XRP(10))); auto const objTxnID = to_string(objTxn.stx->getTransactionID()); - env(objTxn, ter(tecNO_ENTRY)); + env(objTxn, Ter(tecNO_ENTRY)); env.close(); { @@ -3683,7 +3683,7 @@ class Batch_test : public beast::unit_test::suite BEAST_EXPECT(!passesLocalChecks(stx, reason)); BEAST_EXPECT(reason == "Cannot submit pseudo transactions."); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, stx, tapNONE, j); + auto const result = xrpl::apply(env.app(), view, stx, TapNone, j); BEAST_EXPECT(!result.applied && result.ter == temINVALID_FLAG); return result.applied; }); @@ -3712,7 +3712,7 @@ class Batch_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob); env.close(); - env(noop(bob), ter(tesSUCCESS)); + env(noop(bob), Ter(tesSUCCESS)); env.close(); auto const aliceSeq = env.seq(alice); @@ -3721,9 +3721,9 @@ class Batch_test : public beast::unit_test::suite auto const bobSeq = env.seq(bob); // Alice Pays Bob (Open Ledger) - auto const payTxn1 = env.jt(pay(alice, bob, XRP(10)), seq(aliceSeq)); + auto const payTxn1 = env.jt(pay(alice, bob, XRP(10)), Seq(aliceSeq)); auto const payTxn1ID = to_string(payTxn1.stx->getTransactionID()); - env(payTxn1, ter(tesSUCCESS)); + env(payTxn1, Ter(tesSUCCESS)); // Alice & Bob Atomic Batch auto const batchFee = batch::calcBatchFee(env, 1, 2); @@ -3731,14 +3731,14 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, aliceSeq + 1, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 2), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 2), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob)); // Bob pays Alice (Open Ledger) - auto const payTxn2 = env.jt(pay(bob, alice, XRP(5)), seq(bobSeq + 1)); + auto const payTxn2 = env.jt(pay(bob, alice, XRP(5)), Seq(bobSeq + 1)); auto const payTxn2ID = to_string(payTxn2.stx->getTransactionID()); - env(payTxn2, ter(terPRE_SEQ)); + env(payTxn2, Ter(terPRE_SEQ)); env.close(); std::vector const testCases = { @@ -3784,7 +3784,7 @@ class Batch_test : public beast::unit_test::suite makeSmallQueueConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features, nullptr, - beast::severities::kError}; + beast::severities::KError}; auto alice = Account("alice"); auto bob = Account("bob"); @@ -3802,7 +3802,7 @@ class Batch_test : public beast::unit_test::suite env(noop(alice)); checkMetrics(*this, env, 0, std::nullopt, 3, 2); - env(noop(carol), ter(terQUEUED)); + env(noop(carol), Ter(terQUEUED)); checkMetrics(*this, env, 1, std::nullopt, 3, 2); auto const aliceSeq = env.seq(alice); @@ -3812,10 +3812,10 @@ class Batch_test : public beast::unit_test::suite // Queue Batch { env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob), - ter(terQUEUED)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob), + Ter(terQUEUED)); } checkMetrics(*this, env, 2, std::nullopt, 3, 2); @@ -3823,10 +3823,10 @@ class Batch_test : public beast::unit_test::suite // Replace Queued Batch { env(batch::outer(alice, aliceSeq, openLedgerFee(env, batchFee), tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob), + Ter(tesSUCCESS)); env.close(); } @@ -3840,7 +3840,7 @@ class Batch_test : public beast::unit_test::suite makeSmallQueueConfig({{"minimum_txn_in_ledger_standalone", "2"}}), features, nullptr, - beast::severities::kError}; + beast::severities::KError}; auto alice = Account("alice"); auto bob = Account("bob"); @@ -3864,15 +3864,15 @@ class Batch_test : public beast::unit_test::suite // Batch Successful { env(batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), aliceSeq + 1), - batch::inner(pay(bob, alice, XRP(5)), bobSeq), - batch::sig(bob), - ter(tesSUCCESS)); + batch::Inner(pay(alice, bob, XRP(10)), aliceSeq + 1), + batch::Inner(pay(bob, alice, XRP(5)), bobSeq), + batch::Sig(bob), + Ter(tesSUCCESS)); } checkMetrics(*this, env, 0, std::nullopt, 3, 2); - env(noop(carol), ter(terQUEUED)); + env(noop(carol), Ter(terQUEUED)); checkMetrics(*this, env, 1, std::nullopt, 3, 2); } } @@ -3885,7 +3885,7 @@ class Batch_test : public beast::unit_test::suite using namespace test::jtx; using namespace std::literals; - Env env(*this, envconfig(), features, nullptr, beast::severities::kDisabled); + Env env(*this, envconfig(), features, nullptr, beast::severities::KDisabled); auto alice = Account("alice"); auto bob = Account("bob"); @@ -3893,7 +3893,7 @@ class Batch_test : public beast::unit_test::suite env.close(); auto submitTx = [&](std::uint32_t flags) -> uint256 { - auto jt = env.jt(pay(alice, bob, XRP(1)), txflags(flags)); + auto jt = env.jt(pay(alice, bob, XRP(1)), Txflags(flags)); Serializer s; jt.stx->add(s); env.app().getOPs().submitTransaction(jt.stx); @@ -3901,13 +3901,13 @@ class Batch_test : public beast::unit_test::suite }; auto processTxn = [&](std::uint32_t flags) -> uint256 { - auto jt = env.jt(pay(alice, bob, XRP(1)), txflags(flags)); + auto jt = env.jt(pay(alice, bob, XRP(1)), Txflags(flags)); Serializer s; jt.stx->add(s); std::string reason; auto transaction = std::make_shared(jt.stx, reason, env.app()); env.app().getOPs().processTransaction( - transaction, false, true, NetworkOPs::FailHard::yes); + transaction, false, true, NetworkOPs::FailHard::Yes); return transaction->getID(); }; @@ -3941,7 +3941,7 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); @@ -3954,14 +3954,14 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 0, 2); auto const seq = env.seq(alice); - auto tx = batch::inner(pay(alice, bob, XRP(1)), seq + 1); + auto tx = batch::Inner(pay(alice, bob, XRP(1)), seq + 1); tx[jss::Delegate] = bob.human(); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), tx, - batch::inner(pay(alice, bob, XRP(2)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2)); env.close(); std::vector const testCases = { @@ -3987,7 +3987,7 @@ class Batch_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); @@ -4002,15 +4002,15 @@ class Batch_test : public beast::unit_test::suite auto const aliceSeq = env.seq(alice); auto const bobSeq = env.seq(bob); - auto tx = batch::inner(pay(bob, alice, XRP(1)), bobSeq); + auto tx = batch::Inner(pay(bob, alice, XRP(1)), bobSeq); tx[jss::Delegate] = carol.human(); auto const [txIDs, batchID] = submitBatch( env, tesSUCCESS, batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing), tx, - batch::inner(pay(alice, bob, XRP(2)), aliceSeq + 1), - batch::sig(bob)); + batch::Inner(pay(alice, bob, XRP(2)), aliceSeq + 1), + batch::Sig(bob)); env.close(); std::vector const testCases = { @@ -4038,7 +4038,7 @@ class Batch_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, gw); env.close(); @@ -4051,7 +4051,7 @@ class Batch_test : public beast::unit_test::suite auto const batchFee = batch::calcBatchFee(env, 0, 2); auto const seq = env.seq(alice); - auto tx = batch::inner(noop(alice), seq + 1); + auto tx = batch::Inner(noop(alice), seq + 1); std::string const domain = "example.com"; tx[sfDomain.jsonName] = strHex(domain); tx[jss::Delegate] = bob.human(); @@ -4060,7 +4060,7 @@ class Batch_test : public beast::unit_test::suite tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), tx, - batch::inner(pay(alice, bob, XRP(2)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(2)), seq + 2)); env.close(); std::vector const testCases = { @@ -4101,7 +4101,7 @@ class Batch_test : public beast::unit_test::suite auto const seq = env.seq(alice); auto const batchFee = batch::calcBatchFee(env, 0, 2); - Json::Value jv1; + json::Value jv1; jv1[sfTransactionType] = jss::MPTokenIssuanceSet; jv1[sfAccount] = alice.human(); jv1[sfDelegate] = bob.human(); @@ -4109,7 +4109,7 @@ class Batch_test : public beast::unit_test::suite jv1[sfMPTokenIssuanceID] = to_string(mptID); jv1[sfFlags] = tfMPTLock; - Json::Value jv2; + json::Value jv2; jv2[sfTransactionType] = jss::MPTokenIssuanceSet; jv2[sfAccount] = alice.human(); jv2[sfDelegate] = bob.human(); @@ -4121,8 +4121,8 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(jv1, seq + 1), - batch::inner(jv2, seq + 2)); + batch::Inner(jv1, seq + 1), + batch::Inner(jv2, seq + 2)); env.close(); std::vector const testCases = { @@ -4162,8 +4162,8 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(gw, seq, batchFee, tfAllOrNothing), - batch::inner(jv1, seq + 1), - batch::inner(jv2, seq + 2)); + batch::Inner(jv1, seq + 1), + batch::Inner(jv2, seq + 2)); env.close(); std::vector const testCases = { @@ -4201,9 +4201,9 @@ class Batch_test : public beast::unit_test::suite env, tesSUCCESS, batch::outer(gw, seq, batchFee, tfIndependent), - batch::inner(jv1, seq + 1), + batch::Inner(jv1, seq + 1), // terNO_DELEGATE_PERMISSION: not authorized to clear freeze - batch::inner(jv2, seq + 2)); + batch::Inner(jv2, seq + 2)); env.close(); std::vector const testCases = { @@ -4258,7 +4258,7 @@ class Batch_test : public beast::unit_test::suite auto const baseFee = env.current()->fees().base; auto const aliceSeq = env.seq(alice); env(fset(bob, asfRequireDest)); - auto jtx = env.jt(pay(alice, bob, XRP(1)), seq(aliceSeq)); + auto jtx = env.jt(pay(alice, bob, XRP(1)), Seq(aliceSeq)); Serializer s; jtx.stx->add(s); @@ -4278,7 +4278,7 @@ class Batch_test : public beast::unit_test::suite { auto const baseFee = env.current()->fees().base; auto const aliceSeq = env.seq(alice); - auto jtx = env.jt(pay(alice, bob, XRP(1)), seq(aliceSeq + 1)); + auto jtx = env.jt(pay(alice, bob, XRP(1)), Seq(aliceSeq + 1)); Serializer s; jtx.stx->add(s); @@ -4318,10 +4318,10 @@ class Batch_test : public beast::unit_test::suite XRPAmount const batchFee = batch::calcBatchFee(env, 0, 2); auto jtx = env.jt( batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(batch::outer(alice, seq, batchFee, tfAllOrNothing), seq), - batch::inner(pay(alice, bob, XRP(1)), seq + 2)); + batch::Inner(batch::outer(alice, seq, batchFee, tfAllOrNothing), seq), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2)); XRPAmount const txBaseFee = getBaseFee(jtx); - BEAST_EXPECT(txBaseFee == XRPAmount(INITIAL_XRP)); + BEAST_EXPECT(txBaseFee == XRPAmount(kINITIAL_XRP)); } // bad: Raw Transactions array exceeds max entries. @@ -4331,18 +4331,18 @@ class Batch_test : public beast::unit_test::suite auto jtx = env.jt( batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(alice, bob, XRP(1)), seq + 2), - batch::inner(pay(alice, bob, XRP(1)), seq + 3), - batch::inner(pay(alice, bob, XRP(1)), seq + 4), - batch::inner(pay(alice, bob, XRP(1)), seq + 5), - batch::inner(pay(alice, bob, XRP(1)), seq + 6), - batch::inner(pay(alice, bob, XRP(1)), seq + 7), - batch::inner(pay(alice, bob, XRP(1)), seq + 8), - batch::inner(pay(alice, bob, XRP(1)), seq + 9)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(alice, bob, XRP(1)), seq + 2), + batch::Inner(pay(alice, bob, XRP(1)), seq + 3), + batch::Inner(pay(alice, bob, XRP(1)), seq + 4), + batch::Inner(pay(alice, bob, XRP(1)), seq + 5), + batch::Inner(pay(alice, bob, XRP(1)), seq + 6), + batch::Inner(pay(alice, bob, XRP(1)), seq + 7), + batch::Inner(pay(alice, bob, XRP(1)), seq + 8), + batch::Inner(pay(alice, bob, XRP(1)), seq + 9)); XRPAmount const txBaseFee = getBaseFee(jtx); - BEAST_EXPECT(txBaseFee == XRPAmount(INITIAL_XRP)); + BEAST_EXPECT(txBaseFee == XRPAmount(kINITIAL_XRP)); } // bad: Signers array exceeds max entries. @@ -4352,11 +4352,11 @@ class Batch_test : public beast::unit_test::suite auto jtx = env.jt( batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(10)), seq + 1), - batch::inner(pay(alice, bob, XRP(5)), seq + 2), - batch::sig(bob, carol, alice, bob, carol, alice, bob, carol, alice, alice)); + batch::Inner(pay(alice, bob, XRP(10)), seq + 1), + batch::Inner(pay(alice, bob, XRP(5)), seq + 2), + batch::Sig(bob, carol, alice, bob, carol, alice, bob, carol, alice, alice)); XRPAmount const txBaseFee = getBaseFee(jtx); - BEAST_EXPECT(txBaseFee == XRPAmount(INITIAL_XRP)); + BEAST_EXPECT(txBaseFee == XRPAmount(kINITIAL_XRP)); } // good: @@ -4365,8 +4365,8 @@ class Batch_test : public beast::unit_test::suite XRPAmount const batchFee = batch::calcBatchFee(env, 0, 2); auto jtx = env.jt( batch::outer(alice, seq, batchFee, tfAllOrNothing), - batch::inner(pay(alice, bob, XRP(1)), seq + 1), - batch::inner(pay(bob, alice, XRP(2)), seq + 2)); + batch::Inner(pay(alice, bob, XRP(1)), seq + 1), + batch::Inner(pay(bob, alice, XRP(2)), seq + 2)); XRPAmount const txBaseFee = getBaseFee(jtx); BEAST_EXPECT(txBaseFee == batchFee); } @@ -4413,7 +4413,7 @@ public: { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeats(sa - fixBatchInnerSigs); testWithFeats(sa); } diff --git a/src/test/app/CheckMPT_test.cpp b/src/test/app/CheckMPT_test.cpp index fb9d413e6e..418b7a4a71 100644 --- a/src/test/app/CheckMPT_test.cpp +++ b/src/test/app/CheckMPT_test.cpp @@ -51,7 +51,7 @@ namespace xrpl { -class CheckMPT_test : public beast::unit_test::suite +class CheckMPT_test : public beast::unit_test::Suite { // Helper function that returns the Checks on an account. static std::vector> @@ -73,11 +73,11 @@ class CheckMPT_test : public beast::unit_test::suite verifyDeliveredAmount(test::jtx::Env& env, STAmount const& amount) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; // Verify DeliveredAmount and delivered_amount metadata are correct. env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect there to be a DeliveredAmount field. if (!BEAST_EXPECT(meta.isMember(sfDeliveredAmount.jsonName))) @@ -85,8 +85,8 @@ class CheckMPT_test : public beast::unit_test::suite // DeliveredAmount and delivered_amount should both be present and // equal amount. - BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == amount.getJson(JsonOptions::none)); - BEAST_EXPECT(meta[jss::delivered_amount] == amount.getJson(JsonOptions::none)); + BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == amount.getJson(JsonOptions::KNone)); + BEAST_EXPECT(meta[jss::delivered_amount] == amount.getJson(JsonOptions::KNone)); } void @@ -106,12 +106,12 @@ class CheckMPT_test : public beast::unit_test::suite STAmount const startBalance{XRP(1'000).value()}; env.fund(startBalance, gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw}); + MPT const usd = MPTTester({.env = env, .issuer = gw}); // Note that no MPToken has been set up for alice, but alice can // still write a check for USD. You don't have to have the funds // necessary to cover a check in order to write a check. - auto writeTwoChecks = [&env, &USD, this](Account const& from, Account const& to) { + auto writeTwoChecks = [&env, &usd, this](Account const& from, Account const& to) { std::uint32_t const fromOwnerCount{ownerCount(env, from)}; std::uint32_t const toOwnerCount{ownerCount(env, to)}; @@ -121,14 +121,14 @@ class CheckMPT_test : public beast::unit_test::suite env(check::create(from, to, XRP(2000))); env.close(); - env(check::create(from, to, USD(50))); + env(check::create(from, to, usd(50))); env.close(); BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount + 2); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount + 2); - env.require(owners(from, fromOwnerCount + 2)); - env.require(owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); + env.require(Owners(from, fromOwnerCount + 2)); + env.require(Owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); }; // from to writeTwoChecks(alice, bob); @@ -142,44 +142,44 @@ class CheckMPT_test : public beast::unit_test::suite using namespace std::chrono_literals; std::size_t const aliceCount{checksOnAccount(env, alice).size()}; std::size_t const bobCount{checksOnAccount(env, bob).size()}; - env(check::create(alice, bob, USD(50)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(50)), Expiration(env.now() + 1s)); env.close(); - env(check::create(alice, bob, USD(50)), source_tag(2)); + env(check::create(alice, bob, usd(50)), SourceTag(2)); env.close(); - env(check::create(alice, bob, USD(50)), dest_tag(3)); + env(check::create(alice, bob, usd(50)), DestTag(3)); env.close(); - env(check::create(alice, bob, USD(50)), invoice_id(uint256{4})); + env(check::create(alice, bob, usd(50)), InvoiceId(uint256{4})); env.close(); - env(check::create(alice, bob, USD(50)), - expiration(env.now() + 1s), - source_tag(12), - dest_tag(13), - invoice_id(uint256{4})); + env(check::create(alice, bob, usd(50)), + Expiration(env.now() + 1s), + SourceTag(12), + DestTag(13), + InvoiceId(uint256{4})); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 5); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 5); // Use a regular key and also multisign to create a check. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), sig(alie)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), Sig(alie)); env.close(); // alice uses her regular key to create a check. - env(check::create(alice, bob, USD(50)), sig(alie)); + env(check::create(alice, bob, usd(50)), Sig(alie)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 6); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 6); // alice uses multisigning to create a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::create(alice, bob, USD(50)), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::create(alice, bob, usd(50)), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 7); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 7); @@ -201,13 +201,13 @@ class CheckMPT_test : public beast::unit_test::suite STAmount const startBalance{XRP(1'000).value()}; env.fund(startBalance, gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw}); + MPT const usd = MPTTester({.env = env, .issuer = gw}); /* * Attempt to create two checks from `from` to `to` and * require they both result in error/success code `expected` */ - auto writeTwoChecksDI = [&env, &USD, this]( + auto writeTwoChecksDI = [&env, &usd, this]( Account const& from, Account const& to, TER expected) { std::uint32_t const fromOwnerCount{ownerCount(env, from)}; std::uint32_t const toOwnerCount{ownerCount(env, to)}; @@ -215,10 +215,10 @@ class CheckMPT_test : public beast::unit_test::suite std::size_t const fromCkCount{checksOnAccount(env, from).size()}; std::size_t const toCkCount{checksOnAccount(env, to).size()}; - env(check::create(from, to, XRP(2000)), ter(expected)); + env(check::create(from, to, XRP(2000)), Ter(expected)); env.close(); - env(check::create(from, to, USD(50)), ter(expected)); + env(check::create(from, to, usd(50)), Ter(expected)); env.close(); if (expected == tesSUCCESS) @@ -226,16 +226,16 @@ class CheckMPT_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount + 2); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount + 2); - env.require(owners(from, fromOwnerCount + 2)); - env.require(owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); + env.require(Owners(from, fromOwnerCount + 2)); + env.require(Owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); return; } BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount); - env.require(owners(from, fromOwnerCount)); - env.require(owners(to, to == from ? fromOwnerCount : toOwnerCount)); + env.require(Owners(from, fromOwnerCount)); + env.require(Owners(to, to == from ? fromOwnerCount : toOwnerCount)); }; // enable the DisallowIncoming flag on both bob and alice @@ -282,64 +282,64 @@ class CheckMPT_test : public beast::unit_test::suite STAmount const startBalance{XRP(1'000).value()}; env.fund(startBalance, gw1, gwF, alice, bob); - auto USDM = MPTTester({.env = env, .issuer = gw1, .flags = MPTDEXFlags | tfMPTCanLock}); - MPT const USD = USDM; + auto usdm = MPTTester({.env = env, .issuer = gw1, .flags = kMPT_DEX_FLAGS | tfMPTCanLock}); + MPT const usd = usdm; // Bad fee. - env(check::create(alice, bob, USD(50)), fee(drops(-10)), ter(temBAD_FEE)); + env(check::create(alice, bob, usd(50)), Fee(drops(-10)), Ter(temBAD_FEE)); env.close(); // Bad flags. - env(check::create(alice, bob, USD(50)), txflags(tfImmediateOrCancel), ter(temINVALID_FLAG)); + env(check::create(alice, bob, usd(50)), Txflags(tfImmediateOrCancel), Ter(temINVALID_FLAG)); env.close(); // Check to self. - env(check::create(alice, alice, XRP(10)), ter(temREDUNDANT)); + env(check::create(alice, alice, XRP(10)), Ter(temREDUNDANT)); env.close(); // Bad amount. - env(check::create(alice, bob, drops(-1)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, drops(-1)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, drops(0)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, drops(0)), Ter(temBAD_AMOUNT)); env.close(); env(check::create(alice, bob, drops(1))); env.close(); - env(check::create(alice, bob, USD(-1)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, usd(-1)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, USD(0)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, usd(0)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); { - MPT const BAD(makeMptID(0, xrpAccount())); - env(check::create(alice, bob, BAD(2)), ter(temBAD_CURRENCY)); + MPT const bad(makeMptID(0, xrpAccount())); + env(check::create(alice, bob, bad(2)), Ter(temBAD_CURRENCY)); env.close(); } // Bad expiration. - env(check::create(alice, bob, USD(50)), - expiration(NetClock::time_point{}), - ter(temBAD_EXPIRATION)); + env(check::create(alice, bob, usd(50)), + Expiration(NetClock::time_point{}), + Ter(temBAD_EXPIRATION)); env.close(); // Destination does not exist. Account const bogie{"bogie"}; - env(check::create(alice, bogie, USD(50)), ter(tecNO_DST)); + env(check::create(alice, bogie, usd(50)), Ter(tecNO_DST)); env.close(); // Require destination tag. env(fset(bob, asfRequireDest)); env.close(); - env(check::create(alice, bob, USD(50)), ter(tecDST_TAG_NEEDED)); + env(check::create(alice, bob, usd(50)), Ter(tecDST_TAG_NEEDED)); env.close(); - env(check::create(alice, bob, USD(50)), dest_tag(11)); + env(check::create(alice, bob, usd(50)), DestTag(11)); env.close(); env(fclear(bob, asfRequireDest)); @@ -347,78 +347,79 @@ class CheckMPT_test : public beast::unit_test::suite { // Globally frozen asset. env.close(); - auto USFM = MPTTester({.env = env, .issuer = gwF, .flags = MPTDEXFlags | tfMPTCanLock}); - MPT const USF = USFM; - USFM.set({.flags = tfMPTLock}); + auto usfm = + MPTTester({.env = env, .issuer = gwF, .flags = kMPT_DEX_FLAGS | tfMPTCanLock}); + MPT const usf = usfm; + usfm.set({.flags = tfMPTLock}); - env(check::create(alice, bob, USF(50)), ter(tecLOCKED)); + env(check::create(alice, bob, usf(50)), Ter(tecLOCKED)); env.close(); - USFM.set({.flags = tfMPTUnlock}); + usfm.set({.flags = tfMPTUnlock}); - env(check::create(alice, bob, USF(50))); + env(check::create(alice, bob, usf(50))); env.close(); } { // Frozen MPT. Check creation should be similar to payment // behavior in the face of locked MPT. - USDM.authorizeHolders({alice, bob}); - env(pay(gw1, alice, USD(25))); - env(pay(gw1, bob, USD(25))); + usdm.authorizeHolders({alice, bob}); + env(pay(gw1, alice, usd(25))); + env(pay(gw1, bob, usd(25))); env.close(); - USDM.set({.holder = alice, .flags = tfMPTLock}); + usdm.set({.holder = alice, .flags = tfMPTLock}); // Setting MPT locked prevents alice from // creating a check for USD ore receiving a check. This is different // from IOU where alice can receive checks from bob or gw. env.close(); - env(check::create(alice, bob, USD(50)), ter(tecLOCKED)); + env(check::create(alice, bob, usd(50)), Ter(tecLOCKED)); env.close(); // Note that IOU returns tecPATH_DRY in this case. // IOU's internal error is terNO_LINE, which is // considered ter re-triable and changed to tecPATH_DRY. - env(pay(alice, bob, USD(1)), ter(tecPATH_DRY)); + env(pay(alice, bob, usd(1)), Ter(tecPATH_DRY)); env.close(); - env(check::create(bob, alice, USD(50)), ter(tecLOCKED)); + env(check::create(bob, alice, usd(50)), Ter(tecLOCKED)); env.close(); - env(pay(bob, alice, USD(1)), ter(tecPATH_DRY)); + env(pay(bob, alice, usd(1)), Ter(tecPATH_DRY)); env.close(); - env(check::create(gw1, alice, USD(50)), ter(tecLOCKED)); + env(check::create(gw1, alice, usd(50)), Ter(tecLOCKED)); env.close(); - env(pay(gw1, alice, USD(1))); + env(pay(gw1, alice, usd(1))); env.close(); // Clear that lock. Now check creation works. - USDM.set({.holder = alice, .flags = tfMPTUnlock}); - env(check::create(alice, bob, USD(50))); + usdm.set({.holder = alice, .flags = tfMPTUnlock}); + env(check::create(alice, bob, usd(50))); env.close(); - env(check::create(bob, alice, USD(50))); + env(check::create(bob, alice, usd(50))); env.close(); - env(check::create(gw1, alice, USD(50))); + env(check::create(gw1, alice, usd(50))); env.close(); } // Expired expiration. - env(check::create(alice, bob, USD(50)), expiration(env.now()), ter(tecEXPIRED)); + env(check::create(alice, bob, usd(50)), Expiration(env.now()), Ter(tecEXPIRED)); env.close(); using namespace std::chrono_literals; - env(check::create(alice, bob, USD(50)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(50)), Expiration(env.now() + 1s)); env.close(); // Insufficient reserve. Account const cheri{"cheri"}; env.fund(env.current()->fees().accountReserve(1) - drops(1), cheri); - env(check::create(cheri, bob, USD(50)), - fee(drops(env.current()->fees().base)), - ter(tecINSUFFICIENT_RESERVE)); + env(check::create(cheri, bob, usd(50)), + Fee(drops(env.current()->fees().base)), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); env(pay(bob, cheri, drops(env.current()->fees().base + 1))); env.close(); - env(check::create(cheri, bob, USD(50))); + env(check::create(cheri, bob, usd(50))); env.close(); } @@ -439,64 +440,64 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 105}); // alice writes the check before she gets the funds. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(100))); + env(check::create(alice, bob, usd(100))); env.close(); // bob attempts to cash the check. Should fail. - env(check::cash(bob, chkId1, USD(100)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(100)), Ter(tecPATH_PARTIAL)); env.close(); // alice gets almost enough funds. bob tries and fails again. - env(pay(gw, alice, USD(95))); + env(pay(gw, alice, usd(95))); env.close(); - env(check::cash(bob, chkId1, USD(100)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(100)), Ter(tecPATH_PARTIAL)); env.close(); // alice gets the last of the necessary funds. - env(pay(gw, alice, USD(5))); + env(pay(gw, alice, usd(5))); env.close(); // bob for more than the check's SendMax. env.close(); - env(check::cash(bob, chkId1, USD(105)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(105)), Ter(tecPATH_PARTIAL)); env.close(); // bob asks for exactly the check amount and the check clears. // MPT is authorized automatically - env(check::cash(bob, chkId1, USD(100))); + env(check::cash(bob, chkId1, usd(100))); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(100))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(100))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob tries to cash the same check again, which fails. - env(check::cash(bob, chkId1, USD(100)), ter(tecNO_ENTRY)); + env(check::cash(bob, chkId1, usd(100)), Ter(tecNO_ENTRY)); env.close(); // bob pays alice USD(70) so he can try another case. - env(pay(bob, alice, USD(70))); + env(pay(bob, alice, usd(70))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(70))); + env(check::create(alice, bob, usd(70))); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); // bob cashes the check for less than the face amount. That works, // consumes the check, and bob receives as much as he asked for. - env(check::cash(bob, chkId2, USD(50))); + env(check::cash(bob, chkId2, usd(50))); env.close(); - env.require(balance(alice, USD(20))); - env.require(balance(bob, USD(80))); + env.require(Balance(alice, usd(20))); + env.require(Balance(bob, usd(80))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -505,19 +506,19 @@ class CheckMPT_test : public beast::unit_test::suite // alice writes two checks for USD(20), although she only has // USD(20). uint256 const chkId3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(20))); + env(check::create(alice, bob, usd(20))); env.close(); uint256 const chkId4{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(20))); + env(check::create(alice, bob, usd(20))); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(checksOnAccount(env, bob).size() == 2); // bob cashes the second check for the face amount. - env(check::cash(bob, chkId4, USD(20))); + env(check::cash(bob, chkId4, usd(20))); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(100))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(100))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -525,10 +526,10 @@ class CheckMPT_test : public beast::unit_test::suite // bob is not allowed to cash the last check for USD(0), he must // use check::cancel instead. - env(check::cash(bob, chkId3, USD(0)), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId3, usd(0)), Ter(temBAD_AMOUNT)); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(100))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(100))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -542,29 +543,29 @@ class CheckMPT_test : public beast::unit_test::suite // neither a payment to bob or caching can exceed that limit. // Payment of 200 USD fails. - env(pay(gw, bob, USD(200)), ter(tecPATH_PARTIAL)); + env(pay(gw, bob, usd(200)), Ter(tecPATH_PARTIAL)); env.close(); uint256 const chkId20{getCheckIndex(gw, env.seq(gw))}; - env(check::create(gw, bob, USD(200))); + env(check::create(gw, bob, usd(200))); env.close(); // Cashing a check for 200 USD fails. - env(check::cash(bob, chkId20, USD(200)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId20, usd(200)), Ter(tecPATH_PARTIAL)); env.close(); - env.require(balance(bob, USD(100))); + env.require(Balance(bob, usd(100))); // Clean up this most recent experiment so the rest of the // tests work. - env(pay(bob, gw, USD(100))); + env(pay(bob, gw, usd(100))); env(check::cancel(bob, chkId20)); } // ... so bob cancels alice's remaining check. env(check::cancel(bob, chkId3)); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(0))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(0))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -576,66 +577,66 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 20}); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // alice creates several checks ahead of time. uint256 const chkId9{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(9))); + env(check::create(alice, bob, usd(9))); env.close(); uint256 const chkId8{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(8))); + env(check::create(alice, bob, usd(8))); env.close(); uint256 const chkId7{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(7))); + env(check::create(alice, bob, usd(7))); env.close(); uint256 const chkId6{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(6))); + env(check::create(alice, bob, usd(6))); env.close(); // bob attempts to cash a check for the amount on the check. // Should fail, since alice doesn't have the funds. - env(check::cash(bob, chkId9, check::DeliverMin(USD(9))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId9, check::DeliverMin(usd(9))), Ter(tecPATH_PARTIAL)); env.close(); // bob sets a DeliverMin of 7 and gets all that alice has. - env(check::cash(bob, chkId9, check::DeliverMin(USD(7)))); - verifyDeliveredAmount(env, USD(8)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId9, check::DeliverMin(usd(7)))); + verifyDeliveredAmount(env, usd(8)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 3); BEAST_EXPECT(checksOnAccount(env, bob).size() == 3); BEAST_EXPECT(ownerCount(env, alice) == 4); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob pays alice USD(7) so he can use another check. - env(pay(bob, alice, USD(7))); + env(pay(bob, alice, usd(7))); env.close(); // Using DeliverMin for the SendMax value of the check (and no // transfer fees) should work just like setting Amount. - env(check::cash(bob, chkId7, check::DeliverMin(USD(7)))); - verifyDeliveredAmount(env, USD(7)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId7, check::DeliverMin(usd(7)))); + verifyDeliveredAmount(env, usd(7)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(checksOnAccount(env, bob).size() == 2); BEAST_EXPECT(ownerCount(env, alice) == 3); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob pays alice USD(8) so he can use the last two checks. - env(pay(bob, alice, USD(8))); + env(pay(bob, alice, usd(8))); env.close(); // alice has USD(8). If bob uses the check for USD(6) and uses a // DeliverMin of 4, he should get the SendMax value of the check. - env(check::cash(bob, chkId6, check::DeliverMin(USD(4)))); - verifyDeliveredAmount(env, USD(6)); - env.require(balance(alice, USD(2))); - env.require(balance(bob, USD(6))); + env(check::cash(bob, chkId6, check::DeliverMin(usd(4)))); + verifyDeliveredAmount(env, usd(6)); + env.require(Balance(alice, usd(2))); + env.require(Balance(bob, usd(6))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -643,10 +644,10 @@ class CheckMPT_test : public beast::unit_test::suite // bob cashes the last remaining check setting a DeliverMin. // of exactly alice's remaining USD. - env(check::cash(bob, chkId8, check::DeliverMin(USD(2)))); - verifyDeliveredAmount(env, USD(2)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId8, check::DeliverMin(usd(2)))); + verifyDeliveredAmount(env, usd(2)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -657,44 +658,44 @@ class CheckMPT_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(1000), gw, alice, bob); - auto USDM = MPTTester( + auto usdm = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, - .flags = MPTDEXFlags | tfMPTRequireAuth, + .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth, .maxAmt = 20}); - MPT const USD = USDM; - USDM.authorize({.holder = alice}); + MPT const usd = usdm; + usdm.authorize({.holder = alice}); env.close(); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // alice writes a check to bob for USD. bob can't cash it // because he is not authorized to hold gw["USD"]. uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(7))); + env(check::create(alice, bob, usd(7))); env.close(); - env(check::cash(bob, chkId, USD(7)), ter(tecNO_AUTH)); + env(check::cash(bob, chkId, usd(7)), Ter(tecNO_AUTH)); env.close(); // Now give bob MPT for USD. bob still can't cash the // check because he is not authorized. - USDM.authorize({.account = bob}); + usdm.authorize({.account = bob}); env.close(); - env(check::cash(bob, chkId, USD(7)), ter(tecNO_AUTH)); + env(check::cash(bob, chkId, usd(7)), Ter(tecNO_AUTH)); env.close(); // bob gets authorization to hold USD. - USDM.authorize({.holder = bob}); + usdm.authorize({.holder = bob}); env.close(); - env(check::cash(bob, chkId, check::DeliverMin(USD(4)))); - STAmount const bobGot = USD(7); + env(check::cash(bob, chkId, check::DeliverMin(usd(4)))); + STAmount const bobGot = usd(7); verifyDeliveredAmount(env, bobGot); - env.require(balance(alice, USD(8) - bobGot)); - env.require(balance(bob, bobGot)); + env.require(Balance(alice, usd(8) - bobGot)); + env.require(Balance(bob, bobGot)); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); @@ -707,39 +708,39 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 20}); // alice creates her checks ahead of time. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // Give bob a regular key and signers - Account const bobby{"bobby", KeyType::secp256k1}; + Account const bobby{"bobby", KeyType::Secp256k1}; env(regkey(bob, bobby)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(bob, 2, {{bogie, 1}, {demon, 1}}), sig(bobby)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(bob, 2, {{bogie, 1}, {demon, 1}}), Sig(bobby)); env.close(); int const signersCount = 1; BEAST_EXPECT(ownerCount(env, bob) == signersCount + 1); // bob uses his regular key to cash a check. - env(check::cash(bob, chkId1, (USD(1))), sig(bobby)); + env(check::cash(bob, chkId1, (usd(1))), Sig(bobby)); env.close(); - env.require(balance(alice, USD(7))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(7))); + env.require(Balance(bob, usd(1))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -747,10 +748,10 @@ class CheckMPT_test : public beast::unit_test::suite // bob uses multisigning to cash a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::cash(bob, chkId2, (USD(2))), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::cash(bob, chkId2, (usd(2))), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); - env.require(balance(alice, USD(5))); - env.require(balance(bob, USD(3))); + env.require(Balance(alice, usd(5))); + env.require(Balance(bob, usd(3))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -775,7 +776,7 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob); // Set gw's transfer rate and see the consequences when cashing a check. - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, @@ -783,36 +784,36 @@ class CheckMPT_test : public beast::unit_test::suite .maxAmt = 1'000}); env.close(); - env(pay(gw, alice, USD(1'000))); + env(pay(gw, alice, usd(1'000))); env.close(); // alice writes a check with a SendMax of USD(125). The most bob // can get is USD(100) because of the transfer rate. uint256 const chkId125{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(125))); + env(check::create(alice, bob, usd(125))); env.close(); // alice writes another check that won't get cashed until the transfer // rate changes so we can see the rate applies when the check is // cashed, not when it is created. #if 0 - uint256 const chkId120{getCheckIndex(alice, env.seq(alice))}; + uint256 const chkId120{getCheckIndex(alice, env.Seq(alice))}; env(check::create(alice, bob, USD(120))); env.close(); #endif // bob attempts to cash the check for face value. Should fail. - env(check::cash(bob, chkId125, USD(125)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId125, usd(125)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkId125, check::DeliverMin(USD(101))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId125, check::DeliverMin(usd(101))), Ter(tecPATH_PARTIAL)); env.close(); // bob decides that he'll accept anything USD(75) or up. // He gets USD(100). - env(check::cash(bob, chkId125, check::DeliverMin(USD(75)))); - verifyDeliveredAmount(env, USD(100)); - env.require(balance(alice, USD(1'000 - 125))); - env.require(balance(bob, USD(0 + 100))); + env(check::cash(bob, chkId125, check::DeliverMin(usd(75)))); + verifyDeliveredAmount(env, usd(100)); + env.require(Balance(alice, usd(1'000 - 125))); + env.require(Balance(bob, usd(0 + 100))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); @@ -825,8 +826,8 @@ class CheckMPT_test : public beast::unit_test::suite // rate applies to the actual value transferred. env(check::cash(bob, chkId120, USD(50))); env.close(); - env.require(balance(alice, USD(1000 - 125 - 60))); - env.require(balance(bob, USD(0 + 100 + 50))); + env.Require(Balance(alice, USD(1000 - 125 - 60))); + env.Require(Balance(bob, USD(0 + 100 + 50))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 0); BEAST_EXPECT(checksOnAccount(env, bob).size() == 0); #endif @@ -850,29 +851,29 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1000), gw, alice, bob, zoe); - auto USDM = MPTTester( + auto usdm = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .maxAmt = maxAmt}); - MPT const USD = USDM; + MPT const usd = usdm; - env(pay(gw, alice, USD(20))); + env(pay(gw, alice, usd(20))); env.close(); - USDM.authorize({.account = bob}); + usdm.authorize({.account = bob}); // bob tries to cash a non-existent check from alice. { uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::cash(bob, chkId, USD(20)), ter(tecNO_ENTRY)); + env(check::cash(bob, chkId, usd(20)), Ter(tecNO_ENTRY)); env.close(); } // alice creates her checks ahead of time. uint256 const chkIdU{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(20))); + env(check::create(alice, bob, usd(20))); env.close(); uint256 const chkIdX{getCheckIndex(alice, env.seq(alice))}; @@ -881,54 +882,54 @@ class CheckMPT_test : public beast::unit_test::suite using namespace std::chrono_literals; uint256 const chkIdExp{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdFroz1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkIdFroz2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); uint256 const chkIdFroz3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(3))); + env(check::create(alice, bob, usd(3))); env.close(); uint256 const chkIdNoDest1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkIdHasDest2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2)), dest_tag(7)); + env(check::create(alice, bob, usd(2)), DestTag(7)); env.close(); // Same set of failing cases for both MPT and XRP check cashing. auto failingCases = [&env, &gw, &alice, &bob]( uint256 const& chkId, STAmount const& amount) { // Bad fee. - env(check::cash(bob, chkId, amount), fee(drops(-10)), ter(temBAD_FEE)); + env(check::cash(bob, chkId, amount), Fee(drops(-10)), Ter(temBAD_FEE)); env.close(); // Bad flags. env(check::cash(bob, chkId, amount), - txflags(tfImmediateOrCancel), - ter(temINVALID_FLAG)); + Txflags(tfImmediateOrCancel), + Ter(temINVALID_FLAG)); env.close(); // Missing both Amount and DeliverMin. { - Json::Value tx{check::cash(bob, chkId, amount)}; + json::Value tx{check::cash(bob, chkId, amount)}; tx.removeMember(sfAmount.jsonName); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); env.close(); } // Both Amount and DeliverMin present. { - Json::Value tx{check::cash(bob, chkId, amount)}; - tx[sfDeliverMin.jsonName] = amount.getJson(JsonOptions::none); - env(tx, ter(temMALFORMED)); + json::Value tx{check::cash(bob, chkId, amount)}; + tx[sfDeliverMin.jsonName] = amount.getJson(JsonOptions::KNone); + env(tx, Ter(temMALFORMED)); env.close(); } @@ -936,9 +937,9 @@ class CheckMPT_test : public beast::unit_test::suite { STAmount neg{amount}; neg.negate(); - env(check::cash(bob, chkId, neg), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId, neg), Ter(temBAD_AMOUNT)); env.close(); - env(check::cash(bob, chkId, amount.zeroed()), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId, amount.zeroed()), Ter(temBAD_AMOUNT)); env.close(); } @@ -948,21 +949,21 @@ class CheckMPT_test : public beast::unit_test::suite Issue const badIssue{badCurrency(), amount.getIssuer()}; STAmount badAmount{amount}; badAmount.setIssue(Issue{badCurrency(), amount.getIssuer()}); - env(check::cash(bob, chkId, badAmount), ter(temBAD_CURRENCY)); + env(check::cash(bob, chkId, badAmount), Ter(temBAD_CURRENCY)); env.close(); } // Not destination cashing check. - env(check::cash(alice, chkId, amount), ter(tecNO_PERMISSION)); + env(check::cash(alice, chkId, amount), Ter(tecNO_PERMISSION)); env.close(); - env(check::cash(gw, chkId, amount), ter(tecNO_PERMISSION)); + env(check::cash(gw, chkId, amount), Ter(tecNO_PERMISSION)); env.close(); // Currency mismatch. { - MPT const EUR = MPTTester({.env = env, .issuer = gw}); - STAmount const badAmount{EUR, amount}; - env(check::cash(bob, chkId, badAmount), ter(temMALFORMED)); + MPT const eur = MPTTester({.env = env, .issuer = gw}); + STAmount const badAmount{eur, amount}; + env(check::cash(bob, chkId, badAmount), Ter(temMALFORMED)); env.close(); } @@ -970,25 +971,25 @@ class CheckMPT_test : public beast::unit_test::suite // Every MPT is unique. There is no USD MPT with different issuers. // Amount bigger than SendMax. - env(check::cash(bob, chkId, amount + amount), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, amount + amount), Ter(tecPATH_PARTIAL)); env.close(); // DeliverMin bigger than SendMax. - env(check::cash(bob, chkId, check::DeliverMin(amount + amount)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, check::DeliverMin(amount + amount)), Ter(tecPATH_PARTIAL)); env.close(); }; failingCases(chkIdX, XRP(10)); - failingCases(chkIdU, USD(20)); + failingCases(chkIdU, usd(20)); // Verify that those two checks really were cashable. - env(check::cash(bob, chkIdU, USD(20))); + env(check::cash(bob, chkIdU, usd(20))); env.close(); env(check::cash(bob, chkIdX, check::DeliverMin(XRP(10)))); verifyDeliveredAmount(env, XRP(10)); // Try to cash an expired check. - env(check::cash(bob, chkIdExp, XRP(10)), ter(tecEXPIRED)); + env(check::cash(bob, chkIdExp, XRP(10)), Ter(tecEXPIRED)); env.close(); // Cancel the expired check. Anyone can cancel an expired check. @@ -997,103 +998,103 @@ class CheckMPT_test : public beast::unit_test::suite // Can we cash a check with frozen MPT? { - env(pay(bob, alice, USD(20))); + env(pay(bob, alice, usd(20))); env.close(); - env.require(balance(alice, USD(20))); - env.require(balance(bob, USD(0))); + env.require(Balance(alice, usd(20))); + env.require(Balance(bob, usd(0))); // Global freeze - USDM.set({.flags = tfMPTLock}); + usdm.set({.flags = tfMPTLock}); // MPTLocked flag is set and the account is not the issuer of MPT - env(check::cash(bob, chkIdFroz1, USD(1)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz1, usd(1)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkIdFroz1, check::DeliverMin(USD(1))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz1, check::DeliverMin(usd(1))), Ter(tecPATH_PARTIAL)); env.close(); - USDM.set({.flags = tfMPTUnlock}); + usdm.set({.flags = tfMPTUnlock}); // No longer frozen. Success. - env(check::cash(bob, chkIdFroz1, USD(1))); + env(check::cash(bob, chkIdFroz1, usd(1))); env.close(); - env.require(balance(alice, USD(19))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(19))); + env.require(Balance(bob, usd(1))); // Freeze individual MPT. - USDM.set({.holder = alice, .flags = tfMPTLock}); - env(check::cash(bob, chkIdFroz2, USD(2)), ter(tecPATH_PARTIAL)); + usdm.set({.holder = alice, .flags = tfMPTLock}); + env(check::cash(bob, chkIdFroz2, usd(2)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkIdFroz2, check::DeliverMin(USD(1))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz2, check::DeliverMin(usd(1))), Ter(tecPATH_PARTIAL)); env.close(); // Clear that freeze. Now check cashing works. - USDM.set({.holder = alice, .flags = tfMPTUnlock}); - env(check::cash(bob, chkIdFroz2, USD(2))); + usdm.set({.holder = alice, .flags = tfMPTUnlock}); + env(check::cash(bob, chkIdFroz2, usd(2))); env.close(); - env.require(balance(alice, USD(17))); - env.require(balance(bob, USD(3))); + env.require(Balance(alice, usd(17))); + env.require(Balance(bob, usd(3))); // Freeze bob's MPT. bob can't cash the check. - USDM.set({.holder = bob, .flags = tfMPTLock}); - env(check::cash(bob, chkIdFroz3, USD(3)), ter(tecLOCKED)); + usdm.set({.holder = bob, .flags = tfMPTLock}); + env(check::cash(bob, chkIdFroz3, usd(3)), Ter(tecLOCKED)); env.close(); - env(check::cash(bob, chkIdFroz3, check::DeliverMin(USD(1))), ter(tecLOCKED)); + env(check::cash(bob, chkIdFroz3, check::DeliverMin(usd(1))), Ter(tecLOCKED)); env.close(); // Clear that freeze. Now check cashing works again. - USDM.set({.holder = bob, .flags = tfMPTUnlock}); + usdm.set({.holder = bob, .flags = tfMPTUnlock}); env.close(); - env(check::cash(bob, chkIdFroz3, check::DeliverMin(USD(1)))); - verifyDeliveredAmount(env, USD(3)); - env.require(balance(alice, USD(14))); - env.require(balance(bob, USD(6))); + env(check::cash(bob, chkIdFroz3, check::DeliverMin(usd(1)))); + verifyDeliveredAmount(env, usd(3)); + env.require(Balance(alice, usd(14))); + env.require(Balance(bob, usd(6))); } { // Set the RequireDest flag on bob's account (after the check // was created) then cash a check without a destination tag. env(fset(bob, asfRequireDest)); env.close(); - env(check::cash(bob, chkIdNoDest1, USD(1)), ter(tecDST_TAG_NEEDED)); + env(check::cash(bob, chkIdNoDest1, usd(1)), Ter(tecDST_TAG_NEEDED)); env.close(); - env(check::cash(bob, chkIdNoDest1, check::DeliverMin(USD(1))), ter(tecDST_TAG_NEEDED)); + env(check::cash(bob, chkIdNoDest1, check::DeliverMin(usd(1))), Ter(tecDST_TAG_NEEDED)); env.close(); // bob can cash a check with a destination tag. - env(check::cash(bob, chkIdHasDest2, USD(2))); + env(check::cash(bob, chkIdHasDest2, usd(2))); env.close(); - env.require(balance(alice, USD(12))); - env.require(balance(bob, USD(8))); + env.require(Balance(alice, usd(12))); + env.require(Balance(bob, usd(8))); // Clear the RequireDest flag on bob's account so he can // cash the check with no DestinationTag. env(fclear(bob, asfRequireDest)); env.close(); - env(check::cash(bob, chkIdNoDest1, USD(1))); + env(check::cash(bob, chkIdNoDest1, usd(1))); env.close(); - env.require(balance(alice, USD(11))); - env.require(balance(bob, USD(9))); + env.require(Balance(alice, usd(11))); + env.require(Balance(bob, usd(9))); } // OutstandingAmount exceeds MaximumAmount { // Already at maximum - BEAST_EXPECT(env.balance(gw, USDM) == USDM(-maxAmt)); + BEAST_EXPECT(env.balance(gw, usdm) == usdm(-maxAmt)); uint256 const chkId{getCheckIndex(gw, env.seq(gw))}; - env(check::create(gw, bob, USDM(10))); + env(check::create(gw, bob, usdm(10))); env.close(); // Exceeds MaximumAmount (20 + 10) = 30 > 20 - env(check::cash(bob, chkId, USDM(10)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, usdm(10)), Ter(tecPATH_PARTIAL)); env.close(); // Redeem some tokens (20 - 9) = 11 - env(pay(alice, gw, USDM(9))); + env(pay(alice, gw, usdm(9))); env.close(); // Still exceeds MaximumAmount (11 + 10) = 21 > 20 - env(check::cash(bob, chkId, USDM(10)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, usdm(10)), Ter(tecPATH_PARTIAL)); env.close(); } } @@ -1116,12 +1117,12 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob, zoe); - MPT const USD = MPTTester({.env = env, .issuer = gw}); + MPT const usd = MPTTester({.env = env, .issuer = gw}); // alice creates her checks ahead of time. // Three ordinary checks with no expiration. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; @@ -1129,39 +1130,39 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); uint256 const chkId3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); // Three checks that expire in 10 minutes. using namespace std::chrono_literals; uint256 const chkIdNotExp1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 600s)); env.close(); uint256 const chkIdNotExp2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 600s)); env.close(); uint256 const chkIdNotExp3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 600s)); env.close(); // Three checks that expire in one second. uint256 const chkIdExp1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdExp2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdExp3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 1s)); env.close(); // Two checks to cancel using a regular key and using multisigning. uint256 const chkIdReg{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); uint256 const chkIdMSig{getCheckIndex(alice, env.seq(alice))}; @@ -1181,7 +1182,7 @@ class CheckMPT_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, alice).size() == 9); BEAST_EXPECT(ownerCount(env, alice) == 9); - env(check::cancel(zoe, chkId3), ter(tecNO_PERMISSION)); + env(check::cancel(zoe, chkId3), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 9); BEAST_EXPECT(ownerCount(env, alice) == 9); @@ -1197,7 +1198,7 @@ class CheckMPT_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, alice).size() == 7); BEAST_EXPECT(ownerCount(env, alice) == 7); - env(check::cancel(zoe, chkIdNotExp3), ter(tecNO_PERMISSION)); + env(check::cancel(zoe, chkIdNotExp3), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 7); BEAST_EXPECT(ownerCount(env, alice) == 7); @@ -1219,32 +1220,32 @@ class CheckMPT_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 4); // Use a regular key and also multisign to cancel checks. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), sig(alie)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), Sig(alie)); env.close(); int const signersCount{1}; // alice uses her regular key to cancel a check. - env(check::cancel(alice, chkIdReg), sig(alie)); + env(check::cancel(alice, chkIdReg), Sig(alie)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 3); BEAST_EXPECT(ownerCount(env, alice) == signersCount + 3); // alice uses multisigning to cancel a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::cancel(alice, chkIdMSig), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::cancel(alice, chkIdMSig), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(ownerCount(env, alice) == signersCount + 2); // Creator and destination cancel the remaining unexpired checks. - env(check::cancel(alice, chkId3), sig(alice)); + env(check::cancel(alice, chkId3), Sig(alice)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == signersCount + 1); @@ -1271,7 +1272,7 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, bob); env.close(); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 1'000}); // alice and bob grab enough tickets for all the following @@ -1287,8 +1288,8 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); // MPT + 10 tickets - env.require(owners(alice, 11)); - env.require(owners(bob, 11)); + env.require(Owners(alice, 11)); + env.require(Owners(bob, 11)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1296,62 +1297,62 @@ class CheckMPT_test : public beast::unit_test::suite env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); - env(pay(gw, alice, USD(900))); + env(pay(gw, alice, usd(900))); env.close(); // alice creates four checks; two XRP, two MPT. Bob will cash // one of each and cancel one of each. uint256 const chkIdXrp1{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, XRP(200)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, XRP(200)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdXrp2{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, XRP(300)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, XRP(300)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdUsd1{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, USD(200)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, usd(200)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdUsd2{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, USD(300)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, usd(300)), ticket::Use(aliceTicketSeq++)); env.close(); // Alice used four tickets but created four checks. - env.require(owners(alice, 11)); + env.require(Owners(alice, 11)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).size() == 4); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(bob, 11)); + env.require(Owners(bob, 11)); BEAST_EXPECT(env.seq(bob) == bobSeq); // Bob cancels two of alice's checks. - env(check::cancel(bob, chkIdXrp1), ticket::use(bobTicketSeq++)); - env(check::cancel(bob, chkIdUsd2), ticket::use(bobTicketSeq++)); + env(check::cancel(bob, chkIdXrp1), ticket::Use(bobTicketSeq++)); + env(check::cancel(bob, chkIdUsd2), ticket::Use(bobTicketSeq++)); env.close(); - env.require(owners(alice, 9)); + env.require(Owners(alice, 9)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(bob, 9)); + env.require(Owners(bob, 9)); BEAST_EXPECT(env.seq(bob) == bobSeq); // Bob cashes alice's two remaining checks. - env(check::cash(bob, chkIdXrp2, XRP(300)), ticket::use(bobTicketSeq++)); - env(check::cash(bob, chkIdUsd1, USD(200)), ticket::use(bobTicketSeq++)); + env(check::cash(bob, chkIdXrp2, XRP(300)), ticket::Use(bobTicketSeq++)); + env(check::cash(bob, chkIdUsd1, usd(200)), ticket::Use(bobTicketSeq++)); env.close(); auto const baseFee = env.current()->fees().base; - env.require(owners(alice, 7)); + env.require(Owners(alice, 7)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(balance(alice, USD(700))); - env.require(balance(alice, XRP(700) - 6 * baseFee)); - env.require(owners(bob, 7)); + env.require(Balance(alice, usd(700))); + env.require(Balance(alice, XRP(700) - 6 * baseFee)); + env.require(Owners(bob, 7)); BEAST_EXPECT(env.seq(bob) == bobSeq); - env.require(balance(bob, USD(200))); - env.require(balance(bob, XRP(1'300) - 6 * baseFee)); + env.require(Balance(bob, usd(200))); + env.require(Balance(bob, XRP(1'300) - 6 * baseFee)); } void @@ -1369,7 +1370,7 @@ class CheckMPT_test : public beast::unit_test::suite struct AccountOwns { using iterator = hash_map::iterator; - beast::unit_test::suite& suite; + beast::unit_test::Suite& suite; Env& env; Account const acct; std::size_t owners{0}; @@ -1378,16 +1379,12 @@ class CheckMPT_test : public beast::unit_test::suite bool const requireAuth; AccountOwns( - beast::unit_test::suite& s, + beast::unit_test::Suite& s, Env& e, Account a, - bool isIssuer_, - bool requireAuth_ = false) - : suite(s) - , env(e) - , acct(std::move(a)) - , isIssuer(isIssuer_) - , requireAuth(requireAuth_) + bool isIssuer, + bool requireAuth = false) + : suite(s), env(e), acct(std::move(a)), isIssuer(isIssuer), requireAuth(requireAuth) { } @@ -1424,7 +1421,7 @@ class CheckMPT_test : public beast::unit_test::suite Throw("AccountOwns: must be issuer"); if (auto const& it = mpts.find(s); it != mpts.end()) return it->second[s]; - auto flags = MPTDEXFlags | tfMPTCanLock; + auto flags = kMPT_DEX_FLAGS | tfMPTCanLock; if (requireAuth) flags |= tfMPTRequireAuth; auto [it, _] = @@ -1513,7 +1510,7 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(5'000), noripple(gw1)); env.close(); - MPT const CK8 = gw1["CK8"]; + MPT const cK8 = gw1["CK8"]; gw1.verifyOwners(__LINE__); Account const yui{"yui"}; @@ -1525,10 +1522,10 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, yui, CK8(99))); + env(check::create(gw1, yui, cK8(99))); env.close(); - env(check::cash(yui, chkId, CK8(99)), ter(tecINSUFFICIENT_RESERVE)); + env(check::cash(yui, chkId, cK8(99)), Ter(tecINSUFFICIENT_RESERVE)); env.close(); alice.verifyOwners(__LINE__); @@ -1536,8 +1533,8 @@ class CheckMPT_test : public beast::unit_test::suite // the check succeeds and creates the trust line. env(pay(env.master, yui, XRP(51))); env.close(); - env(check::cash(yui, chkId, CK8(99))); - verifyDeliveredAmount(env, CK8(99)); + env(check::cash(yui, chkId, cK8(99))); + verifyDeliveredAmount(env, cK8(99)); env.close(); BEAST_EXPECT(ownerCount(env, yui) == 1); @@ -1563,11 +1560,11 @@ class CheckMPT_test : public beast::unit_test::suite BEAST_EXPECT((*env.le(bob))[sfFlags] == 0); // Use offers to automatically create MPT - MPT const OF1 = gw1["OF1"]; - env(offer(gw1, XRP(98), OF1(98))); + MPT const oF1 = gw1["OF1"]; + env(offer(gw1, XRP(98), oF1(98))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF1.issuanceID, alice)) == nullptr); - env(offer(alice, OF1(98), XRP(98))); + BEAST_EXPECT(env.le(keylet::mptoken(oF1.issuanceID, alice)) == nullptr); + env(offer(alice, oF1(98), XRP(98))); ++alice.owners; env.close(); @@ -1580,14 +1577,14 @@ class CheckMPT_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK1 = gw1["CK1"]; + MPT const cK1 = gw1["CK1"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK1(98))); + env(check::create(gw1, alice, cK1(98))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK1.issuanceID, alice)) == nullptr); - env(check::cash(alice, chkId, CK1(98))); + BEAST_EXPECT(env.le(keylet::mptoken(cK1.issuanceID, alice)) == nullptr); + env(check::cash(alice, chkId, cK1(98))); ++alice.owners; - verifyDeliveredAmount(env, CK1(98)); + verifyDeliveredAmount(env, cK1(98)); env.close(); // gw1's check should be consumed. @@ -1607,17 +1604,17 @@ class CheckMPT_test : public beast::unit_test::suite // Use offers to automatically create MPT. // Transfer of assets using offers does not require rippling. // So bob's offer is successfully crossed which creates MPT. - MPT const OF1 = gw1["OF1"]; - env(offer(alice, XRP(97), OF1(97))); + MPT const oF1 = gw1["OF1"]; + env(offer(alice, XRP(97), oF1(97))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF1, bob)) == nullptr); - env(offer(bob, OF1(97), XRP(97))); + BEAST_EXPECT(env.le(keylet::mptoken(oF1, bob)) == nullptr); + env(offer(bob, oF1(97), XRP(97))); ++bob.owners; env.close(); // Both offers should be consumed. - env.require(balance(alice, OF1(1))); - env.require(balance(bob, OF1(97))); + env.require(Balance(alice, oF1(1))); + env.require(Balance(bob, oF1(97))); // bob now has an owner count of 1 due to new MPT. gw1.verifyOwners(__LINE__); @@ -1630,16 +1627,16 @@ class CheckMPT_test : public beast::unit_test::suite // requires rippling through the currency's issuer, rippling doesn't // impact MPT. Even though gw1 does not have rippling enabled, the // check cash succeeds for MPT and MPT is created. - MPT const CK1 = gw1["CK1"]; + MPT const cK1 = gw1["CK1"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK1(97))); + env(check::create(alice, bob, cK1(97))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK1, bob)) == nullptr); - env(check::cash(bob, chkId, CK1(97))); + BEAST_EXPECT(env.le(keylet::mptoken(cK1, bob)) == nullptr); + env(check::cash(bob, chkId, cK1(97))); ++bob.owners; env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF1, bob)) != nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(oF1, bob)) != nullptr); gw1.verifyOwners(__LINE__); alice.verifyOwners(__LINE__); @@ -1654,11 +1651,11 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); // Use offers to automatically create the trust line. - MPT const OF2 = gw1["OF2"]; - env(offer(gw1, XRP(96), OF2(96))); + MPT const oF2 = gw1["OF2"]; + env(offer(gw1, XRP(96), oF2(96))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF2, alice)) == nullptr); - env(offer(alice, OF2(96), XRP(96))); + BEAST_EXPECT(env.le(keylet::mptoken(oF2, alice)) == nullptr); + env(offer(alice, oF2(96), XRP(96))); ++alice.owners; env.close(); @@ -1670,14 +1667,14 @@ class CheckMPT_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK2 = gw1["CK2"]; + MPT const cK2 = gw1["CK2"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK2(96))); + env(check::create(gw1, alice, cK2(96))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK2, alice)) == nullptr); - env(check::cash(alice, chkId, CK2(96))); + BEAST_EXPECT(env.le(keylet::mptoken(cK2, alice)) == nullptr); + env(check::cash(alice, chkId, cK2(96))); ++alice.owners; - verifyDeliveredAmount(env, CK2(96)); + verifyDeliveredAmount(env, cK2(96)); env.close(); // gw1's check should be consumed. @@ -1695,12 +1692,12 @@ class CheckMPT_test : public beast::unit_test::suite // non-issuer to non-issuer should work. // Use offers to automatically create MPT. - MPT const OF2 = gw1["OF2"]; - env(offer(alice, XRP(95), OF2(95))); + MPT const oF2 = gw1["OF2"]; + env(offer(alice, XRP(95), oF2(95))); env.close(); // alice already has OF2 MPT - BEAST_EXPECT(env.le(keylet::mptoken(OF2, alice)) != nullptr); - env(offer(bob, OF2(95), XRP(95))); + BEAST_EXPECT(env.le(keylet::mptoken(oF2, alice)) != nullptr); + env(offer(bob, oF2(95), XRP(95))); ++bob.owners; env.close(); @@ -1710,14 +1707,14 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK2 = gw1["CK2"]; + MPT const cK2 = gw1["CK2"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK2(95))); + env(check::create(alice, bob, cK2(95))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK2, bob)) == nullptr); - env(check::cash(bob, chkId, CK2(95))); + BEAST_EXPECT(env.le(keylet::mptoken(cK2, bob)) == nullptr); + env(check::cash(bob, chkId, cK2(95))); ++bob.owners; - verifyDeliveredAmount(env, CK2(95)); + verifyDeliveredAmount(env, cK2(95)); env.close(); // bob's owner count should increase due to the new MPT. @@ -1740,11 +1737,11 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); // Use offers to automatically create MPT. - MPT const OF3 = gw1["OF3"]; - env(offer(gw1, XRP(94), OF3(94))); + MPT const oF3 = gw1["OF3"]; + env(offer(gw1, XRP(94), oF3(94))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF3, alice)) == nullptr); - env(offer(alice, OF3(94), XRP(94))); + BEAST_EXPECT(env.le(keylet::mptoken(oF3, alice)) == nullptr); + env(offer(alice, oF3(94), XRP(94))); ++alice.owners; env.close(); @@ -1757,14 +1754,14 @@ class CheckMPT_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK3 = gw1["CK3"]; + MPT const cK3 = gw1["CK3"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK3(94))); + env(check::create(gw1, alice, cK3(94))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK3, alice)) == nullptr); - env(check::cash(alice, chkId, CK3(94))); + BEAST_EXPECT(env.le(keylet::mptoken(cK3, alice)) == nullptr); + env(check::cash(alice, chkId, cK3(94))); ++alice.owners; - verifyDeliveredAmount(env, CK3(94)); + verifyDeliveredAmount(env, cK3(94)); env.close(); // gw1's check should be consumed. @@ -1782,11 +1779,11 @@ class CheckMPT_test : public beast::unit_test::suite // automatic MPT creation. // Use offers to automatically create MPT. - MPT const OF3 = gw1["OF3"]; - env(offer(alice, XRP(93), OF3(93))); + MPT const oF3 = gw1["OF3"]; + env(offer(alice, XRP(93), oF3(93))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF3, alice)) != nullptr); - env(offer(bob, OF3(93), XRP(93))); + BEAST_EXPECT(env.le(keylet::mptoken(oF3, alice)) != nullptr); + env(offer(bob, oF3(93), XRP(93))); ++bob.owners; env.close(); @@ -1796,14 +1793,14 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK3 = gw1["CK3"]; + MPT const cK3 = gw1["CK3"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK3(93))); + env(check::create(alice, bob, cK3(93))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK3, bob)) == nullptr); - env(check::cash(bob, chkId, CK3(93))); + BEAST_EXPECT(env.le(keylet::mptoken(cK3, bob)) == nullptr); + env(check::cash(bob, chkId, cK3(93))); ++bob.owners; - verifyDeliveredAmount(env, CK3(93)); + verifyDeliveredAmount(env, cK3(93)); env.close(); // bob's owner count should increase due to the new MPT. @@ -1820,11 +1817,11 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); // Use offers to automatically create MPT. - MPT const OF4 = gw1["OF4"]; - env(offer(gw1, XRP(92), OF4(92))); + MPT const oF4 = gw1["OF4"]; + env(offer(gw1, XRP(92), oF4(92))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF4, alice)) == nullptr); - env(offer(alice, OF4(92), XRP(92))); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, alice)) == nullptr); + env(offer(alice, oF4(92), XRP(92))); ++alice.owners; env.close(); @@ -1834,13 +1831,13 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK4 = gw1["CK4"]; + MPT const cK4 = gw1["CK4"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, bob, CK4(92))); + env(check::create(gw1, bob, cK4(92))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, bob)) == nullptr); - env(check::cash(bob, chkId, CK4(92))); - verifyDeliveredAmount(env, CK4(92)); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, bob)) == nullptr); + env(check::cash(bob, chkId, cK4(92))); + verifyDeliveredAmount(env, cK4(92)); ++bob.owners; env.close(); @@ -1850,8 +1847,8 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // clean up - gw1.cleanup(OF4, alice); - gw1.cleanup(CK4, bob); + gw1.cleanup(oF4, alice); + gw1.cleanup(cK4, bob); } //-------------- lsfMPTLock, check written by issuer -------------- @@ -1860,12 +1857,12 @@ class CheckMPT_test : public beast::unit_test::suite // MPT from being created. // Use offers to automatically create MPT. - MPT const OF4 = gw1["OF4"]; - gw1.set(OF4, tfMPTLock); - env(offer(gw1, XRP(92), OF4(92)), ter(tecFROZEN)); + MPT const oF4 = gw1["OF4"]; + gw1.set(oF4, tfMPTLock); + env(offer(gw1, XRP(92), oF4(92)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF4, alice)) == nullptr); - env(offer(alice, OF4(92), XRP(92)), ter(tecFROZEN)); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, alice)) == nullptr); + env(offer(alice, oF4(92), XRP(92)), Ter(tecFROZEN)); env.close(); // No one's owner count should have changed. @@ -1874,13 +1871,13 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK4 = gw1["CK4"]; - gw1.set(CK4, tfMPTLock); + MPT const cK4 = gw1["CK4"]; + gw1.set(cK4, tfMPTLock); uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK4(92)), ter(tecLOCKED)); + env(check::create(gw1, alice, cK4(92)), Ter(tecLOCKED)); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, alice)) == nullptr); - env(check::cash(alice, chkId, CK4(92)), ter(tecNO_ENTRY)); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, alice)) == nullptr); + env(check::cash(alice, chkId, cK4(92)), Ter(tecNO_ENTRY)); env.close(); // No one's owner count should have changed. @@ -1890,12 +1887,12 @@ class CheckMPT_test : public beast::unit_test::suite // Because gw1 has set tfMPTLock, neither MPT // is created. - BEAST_EXPECT(env.le(keylet::mptoken(OF4, alice)) == nullptr); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, alice)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, alice)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, alice)) == nullptr); // clear global freeze - gw1.set(OF4, tfMPTUnlock); - gw1.set(CK4, tfMPTUnlock); + gw1.set(oF4, tfMPTUnlock); + gw1.set(cK4, tfMPTUnlock); } //------------ lsfGlobalFreeze, check written by non-issuer ------------ @@ -1904,13 +1901,13 @@ class CheckMPT_test : public beast::unit_test::suite // automatic MPT creation between non-issuers. // Use offers to automatically create MPT. - MPT const OF4 = gw1["OF4"]; - gw1.authorize(OF4, alice); - gw1.pay(gw1, alice, OF4(91)); - env(offer(alice, XRP(91), OF4(91))); + MPT const oF4 = gw1["OF4"]; + gw1.authorize(oF4, alice); + gw1.pay(gw1, alice, oF4(91)); + env(offer(alice, XRP(91), oF4(91))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF4, alice)) != nullptr); - env(offer(bob, OF4(91), XRP(91))); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, alice)) != nullptr); + env(offer(bob, oF4(91), XRP(91))); ++bob.owners; env.close(); @@ -1921,14 +1918,14 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK4 = gw1["CK4"]; + MPT const cK4 = gw1["CK4"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK4(91))); + env(check::create(alice, bob, cK4(91))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, bob)) == nullptr); - gw1.authorize(CK4, alice); - gw1.pay(gw1, alice, CK4(91)); - env(check::cash(bob, chkId, CK4(91))); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, bob)) == nullptr); + gw1.authorize(cK4, alice); + gw1.pay(gw1, alice, cK4(91)); + env(check::cash(bob, chkId, cK4(91))); ++bob.owners; env.close(); @@ -1939,10 +1936,10 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // cleanup - gw1.cleanup(OF4, alice); - gw1.cleanup(CK4, alice); - gw1.cleanup(OF4, bob); - gw1.cleanup(CK4, bob); + gw1.cleanup(oF4, alice); + gw1.cleanup(cK4, alice); + gw1.cleanup(oF4, bob); + gw1.cleanup(cK4, bob); } //------------ lsfMPTLock, check written by non-issuer ------------ @@ -1951,12 +1948,12 @@ class CheckMPT_test : public beast::unit_test::suite // no automatic MPT creation between non-issuers. // Use offers to automatically create MPT. - MPT const OF4 = gw1["OF4"]; - gw1.set(OF4, tfMPTLock); - env(offer(alice, XRP(91), OF4(91)), ter(tecFROZEN)); + MPT const oF4 = gw1["OF4"]; + gw1.set(oF4, tfMPTLock); + env(offer(alice, XRP(91), oF4(91)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF4, alice)) == nullptr); - env(offer(bob, OF4(91), XRP(91)), ter(tecFROZEN)); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, alice)) == nullptr); + env(offer(bob, oF4(91), XRP(91)), Ter(tecFROZEN)); env.close(); // No one's owner count should have changed. @@ -1965,13 +1962,13 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK4 = gw1["CK4"]; - gw1.set(CK4, tfMPTLock); + MPT const cK4 = gw1["CK4"]; + gw1.set(cK4, tfMPTLock); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK4(91)), ter(tecLOCKED)); + env(check::create(alice, bob, cK4(91)), Ter(tecLOCKED)); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, bob)) == nullptr); - env(check::cash(bob, chkId, CK4(91)), ter(tecNO_ENTRY)); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, bob)) == nullptr); + env(check::cash(bob, chkId, cK4(91)), Ter(tecNO_ENTRY)); env.close(); // No one's owner count should have changed. @@ -1981,11 +1978,11 @@ class CheckMPT_test : public beast::unit_test::suite // Because gw1 has set lsfGlobalFreeze, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::mptoken(OF4, bob)) == nullptr); - BEAST_EXPECT(env.le(keylet::mptoken(CK4, bob)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(oF4, bob)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(cK4, bob)) == nullptr); - gw1.set(OF4, tfMPTUnlock); - gw1.set(CK4, tfMPTUnlock); + gw1.set(oF4, tfMPTUnlock); + gw1.set(cK4, tfMPTUnlock); } //-------------- lsfRequireAuth, check written by issuer --------------- @@ -2004,11 +2001,11 @@ class CheckMPT_test : public beast::unit_test::suite env.close(); // Use offers to automatically create MPT. - MPT const OF5 = gw2["OF5"]; - env(offer(gw2, XRP(92), OF5(92))); + MPT const oF5 = gw2["OF5"]; + env(offer(gw2, XRP(92), oF5(92))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF5, alice)) == nullptr); - env(offer(alice, OF5(92), XRP(92))); + BEAST_EXPECT(env.le(keylet::mptoken(oF5, alice)) == nullptr); + env(offer(alice, oF5(92), XRP(92))); ++alice.owners; env.close(); @@ -2018,13 +2015,13 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create MPT. - MPT const CK5 = gw2["CK5"]; + MPT const cK5 = gw2["CK5"]; uint256 const chkId{getCheckIndex(gw2, env.seq(gw2))}; - env(check::create(gw2, alice, CK5(92))); + env(check::create(gw2, alice, cK5(92))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, alice)) == nullptr); - env(check::cash(alice, chkId, CK5(92))); - verifyDeliveredAmount(env, CK5(92)); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, alice)) == nullptr); + env(check::cash(alice, chkId, cK5(92))); + verifyDeliveredAmount(env, cK5(92)); ++alice.owners; env.close(); @@ -2034,8 +2031,8 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // cleanup - gw2.cleanup(OF5, alice); - gw2.cleanup(CK5, alice); + gw2.cleanup(oF5, alice); + gw2.cleanup(cK5, alice); } // Fund new gw to test since gw2 has MPTokenIssuance already created. @@ -2045,13 +2042,13 @@ class CheckMPT_test : public beast::unit_test::suite env.fund(XRP(5'000), gw3); env.close(); // Use offers to automatically create the trust line. - MPT const OF5 = gw3["OF5"]; + MPT const oF5 = gw3["OF5"]; std::uint32_t const gw3OfferSeq = {env.seq(gw3)}; - env(offer(gw3, XRP(92), OF5(92))); + env(offer(gw3, XRP(92), oF5(92))); ++gw3.owners; env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(OF5, alice)) == nullptr); - env(offer(alice, OF5(92), XRP(92)), ter(tecNO_AUTH)); + BEAST_EXPECT(env.le(keylet::mptoken(oF5, alice)) == nullptr); + env(offer(alice, oF5(92), XRP(92)), Ter(tecNO_AUTH)); env.close(); // gw3 should still own the offer, but no one else's owner @@ -2061,19 +2058,19 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Since we don't need it anymore, remove gw3's offer. - env(offer_cancel(gw3, gw3OfferSeq)); + env(offerCancel(gw3, gw3OfferSeq)); --gw3.owners; env.close(); gw3.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK5 = gw3["CK5"]; + MPT const cK5 = gw3["CK5"]; uint256 const chkId{getCheckIndex(gw3, env.seq(gw3))}; - env(check::create(gw3, alice, CK5(92))); + env(check::create(gw3, alice, cK5(92))); ++gw3.owners; env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, alice)) == nullptr); - env(check::cash(alice, chkId, CK5(92)), ter(tecNO_AUTH)); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, alice)) == nullptr); + env(check::cash(alice, chkId, cK5(92)), Ter(tecNO_AUTH)); env.close(); // gw3 should still own the check, but no one else's owner @@ -2084,8 +2081,8 @@ class CheckMPT_test : public beast::unit_test::suite // Because gw3 has set lsfRequireAuth, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::mptoken(OF5, alice)) == nullptr); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, alice)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(oF5, alice)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, alice)) == nullptr); // Since we don't need it anymore, remove gw3's check. env(check::cancel(gw3, chkId)); @@ -2100,12 +2097,12 @@ class CheckMPT_test : public beast::unit_test::suite // automatic MPT creation between non-issuers. // Use offers to automatically create MPT. - MPT const OF5 = gw2["OF5"]; - gw2.authorize(OF5, alice); - gw2.pay(gw2, alice, OF5(91)); - env(offer(alice, XRP(91), OF5(91))); + MPT const oF5 = gw2["OF5"]; + gw2.authorize(oF5, alice); + gw2.pay(gw2, alice, oF5(91)); + env(offer(alice, XRP(91), oF5(91))); env.close(); - env(offer(bob, OF5(91), XRP(91))); + env(offer(bob, oF5(91), XRP(91))); ++bob.owners; env.close(); @@ -2115,14 +2112,14 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK5 = gw2["CK5"]; - gw2.authorize(CK5, alice); - gw2.pay(gw2, alice, CK5(91)); + MPT const cK5 = gw2["CK5"]; + gw2.authorize(cK5, alice); + gw2.pay(gw2, alice, cK5(91)); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK5(91))); + env(check::create(alice, bob, cK5(91))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, bob)) == nullptr); - env(check::cash(bob, chkId, CK5(91))); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, bob)) == nullptr); + env(check::cash(bob, chkId, cK5(91))); ++bob.owners; env.close(); @@ -2139,11 +2136,11 @@ class CheckMPT_test : public beast::unit_test::suite // no automatic MPT creation between non-issuers. // Use offers to automatically create the trust line. - MPT const OF5 = gw3["OF5"]; - env(offer(alice, XRP(91), OF5(91)), ter(tecUNFUNDED_OFFER)); + MPT const oF5 = gw3["OF5"]; + env(offer(alice, XRP(91), oF5(91)), Ter(tecUNFUNDED_OFFER)); env.close(); - env(offer(bob, OF5(91), XRP(91)), ter(tecNO_AUTH)); - BEAST_EXPECT(env.le(keylet::mptoken(OF5, bob)) == nullptr); + env(offer(bob, oF5(91), XRP(91)), Ter(tecNO_AUTH)); + BEAST_EXPECT(env.le(keylet::mptoken(oF5, bob)) == nullptr); env.close(); gw3.verifyOwners(__LINE__); @@ -2151,12 +2148,12 @@ class CheckMPT_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - MPT const CK5 = gw3["CK5"]; + MPT const cK5 = gw3["CK5"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK5(91))); + env(check::create(alice, bob, cK5(91))); env.close(); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, bob)) == nullptr); - env(check::cash(bob, chkId, CK5(91)), ter(tecPATH_PARTIAL)); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, bob)) == nullptr); + env(check::cash(bob, chkId, cK5(91)), Ter(tecPATH_PARTIAL)); env.close(); // Delete alice's check since it is no longer needed. @@ -2170,8 +2167,8 @@ class CheckMPT_test : public beast::unit_test::suite // Because gw3 has set lsfRequireAuth, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::mptoken(OF5, bob)) == nullptr); - BEAST_EXPECT(env.le(keylet::mptoken(CK5, bob)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(oF5, bob)) == nullptr); + BEAST_EXPECT(env.le(keylet::mptoken(cK5, bob)) == nullptr); } } @@ -2193,7 +2190,7 @@ public: run() override { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeats(sa); testMPTCreation(sa); diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index f2c7ab3a38..ad44ff5729 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -49,7 +49,7 @@ namespace xrpl { -class Check_test : public beast::unit_test::suite +class Check_test : public beast::unit_test::Suite { static uint256 getCheckIndex(AccountID const& account, std::uint32_t uSequence) @@ -77,11 +77,11 @@ class Check_test : public beast::unit_test::suite verifyDeliveredAmount(test::jtx::Env& env, STAmount const& amount) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; // Verify DeliveredAmount and delivered_amount metadata are correct. env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect there to be a DeliveredAmount field. if (!BEAST_EXPECT(meta.isMember(sfDeliveredAmount.jsonName))) @@ -89,8 +89,8 @@ class Check_test : public beast::unit_test::suite // DeliveredAmount and delivered_amount should both be present and // equal amount. - BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == amount.getJson(JsonOptions::none)); - BEAST_EXPECT(meta[jss::delivered_amount] == amount.getJson(JsonOptions::none)); + BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == amount.getJson(JsonOptions::KNone)); + BEAST_EXPECT(meta[jss::delivered_amount] == amount.getJson(JsonOptions::KNone)); } void @@ -135,7 +135,7 @@ class Check_test : public beast::unit_test::suite Account const gw{"gateway"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env{*this, features}; @@ -146,7 +146,7 @@ class Check_test : public beast::unit_test::suite // Note that no trust line has been set up for alice, but alice can // still write a check for USD. You don't have to have the funds // necessary to cover a check in order to write a check. - auto writeTwoChecks = [&env, &USD, this](Account const& from, Account const& to) { + auto writeTwoChecks = [&env, &usd, this](Account const& from, Account const& to) { std::uint32_t const fromOwnerCount{ownerCount(env, from)}; std::uint32_t const toOwnerCount{ownerCount(env, to)}; @@ -156,14 +156,14 @@ class Check_test : public beast::unit_test::suite env(check::create(from, to, XRP(2000))); env.close(); - env(check::create(from, to, USD(50))); + env(check::create(from, to, usd(50))); env.close(); BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount + 2); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount + 2); - env.require(owners(from, fromOwnerCount + 2)); - env.require(owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); + env.require(Owners(from, fromOwnerCount + 2)); + env.require(Owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); }; // from to writeTwoChecks(alice, bob); @@ -177,44 +177,44 @@ class Check_test : public beast::unit_test::suite using namespace std::chrono_literals; std::size_t const aliceCount{checksOnAccount(env, alice).size()}; std::size_t const bobCount{checksOnAccount(env, bob).size()}; - env(check::create(alice, bob, USD(50)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(50)), Expiration(env.now() + 1s)); env.close(); - env(check::create(alice, bob, USD(50)), source_tag(2)); + env(check::create(alice, bob, usd(50)), SourceTag(2)); env.close(); - env(check::create(alice, bob, USD(50)), dest_tag(3)); + env(check::create(alice, bob, usd(50)), DestTag(3)); env.close(); - env(check::create(alice, bob, USD(50)), invoice_id(uint256{4})); + env(check::create(alice, bob, usd(50)), InvoiceId(uint256{4})); env.close(); - env(check::create(alice, bob, USD(50)), - expiration(env.now() + 1s), - source_tag(12), - dest_tag(13), - invoice_id(uint256{4})); + env(check::create(alice, bob, usd(50)), + Expiration(env.now() + 1s), + SourceTag(12), + DestTag(13), + InvoiceId(uint256{4})); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 5); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 5); // Use a regular key and also multisign to create a check. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), sig(alie)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), Sig(alie)); env.close(); // alice uses her regular key to create a check. - env(check::create(alice, bob, USD(50)), sig(alie)); + env(check::create(alice, bob, usd(50)), Sig(alie)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 6); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 6); // alice uses multisigning to create a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::create(alice, bob, USD(50)), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::create(alice, bob, usd(50)), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == aliceCount + 7); BEAST_EXPECT(checksOnAccount(env, bob).size() == bobCount + 7); @@ -230,7 +230,7 @@ class Check_test : public beast::unit_test::suite Account const gw{"gateway"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env{*this, features}; @@ -242,7 +242,7 @@ class Check_test : public beast::unit_test::suite * Attempt to create two checks from `from` to `to` and * require they both result in error/success code `expected` */ - auto writeTwoChecksDI = [&env, &USD, this]( + auto writeTwoChecksDI = [&env, &usd, this]( Account const& from, Account const& to, TER expected) { std::uint32_t const fromOwnerCount{ownerCount(env, from)}; std::uint32_t const toOwnerCount{ownerCount(env, to)}; @@ -250,10 +250,10 @@ class Check_test : public beast::unit_test::suite std::size_t const fromCkCount{checksOnAccount(env, from).size()}; std::size_t const toCkCount{checksOnAccount(env, to).size()}; - env(check::create(from, to, XRP(2000)), ter(expected)); + env(check::create(from, to, XRP(2000)), Ter(expected)); env.close(); - env(check::create(from, to, USD(50)), ter(expected)); + env(check::create(from, to, usd(50)), Ter(expected)); env.close(); if (isTesSuccess(expected)) @@ -261,16 +261,16 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount + 2); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount + 2); - env.require(owners(from, fromOwnerCount + 2)); - env.require(owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); + env.require(Owners(from, fromOwnerCount + 2)); + env.require(Owners(to, to == from ? fromOwnerCount + 2 : toOwnerCount)); return; } BEAST_EXPECT(checksOnAccount(env, from).size() == fromCkCount); BEAST_EXPECT(checksOnAccount(env, to).size() == toCkCount); - env.require(owners(from, fromOwnerCount)); - env.require(owners(to, to == from ? fromOwnerCount : toOwnerCount)); + env.require(Owners(from, fromOwnerCount)); + env.require(Owners(to, to == from ? fromOwnerCount : toOwnerCount)); }; // enable the DisallowIncoming flag on both bob and alice @@ -311,7 +311,7 @@ class Check_test : public beast::unit_test::suite Account const gwF{"gatewayFrozen"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw1["USD"]}; + IOU const usd{gw1["USD"]}; Env env{*this, features}; @@ -320,93 +320,93 @@ class Check_test : public beast::unit_test::suite env.close(); // Bad fee. - env(check::create(alice, bob, USD(50)), fee(drops(-10)), ter(temBAD_FEE)); + env(check::create(alice, bob, usd(50)), Fee(drops(-10)), Ter(temBAD_FEE)); env.close(); // Bad flags. - env(check::create(alice, bob, USD(50)), txflags(tfImmediateOrCancel), ter(temINVALID_FLAG)); + env(check::create(alice, bob, usd(50)), Txflags(tfImmediateOrCancel), Ter(temINVALID_FLAG)); env.close(); // Check to self. - env(check::create(alice, alice, XRP(10)), ter(temREDUNDANT)); + env(check::create(alice, alice, XRP(10)), Ter(temREDUNDANT)); env.close(); // Bad amount. - env(check::create(alice, bob, drops(-1)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, drops(-1)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, drops(0)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, drops(0)), Ter(temBAD_AMOUNT)); env.close(); env(check::create(alice, bob, drops(1))); env.close(); - env(check::create(alice, bob, USD(-1)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, usd(-1)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, USD(0)), ter(temBAD_AMOUNT)); + env(check::create(alice, bob, usd(0)), Ter(temBAD_AMOUNT)); env.close(); - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); { - IOU const BAD{gw1, badCurrency()}; - env(check::create(alice, bob, BAD(2)), ter(temBAD_CURRENCY)); + IOU const bad{gw1, badCurrency()}; + env(check::create(alice, bob, bad(2)), Ter(temBAD_CURRENCY)); env.close(); } // Bad expiration. - env(check::create(alice, bob, USD(50)), - expiration(NetClock::time_point{}), - ter(temBAD_EXPIRATION)); + env(check::create(alice, bob, usd(50)), + Expiration(NetClock::time_point{}), + Ter(temBAD_EXPIRATION)); env.close(); // Destination does not exist. Account const bogie{"bogie"}; - env(check::create(alice, bogie, USD(50)), ter(tecNO_DST)); + env(check::create(alice, bogie, usd(50)), Ter(tecNO_DST)); env.close(); // Require destination tag. env(fset(bob, asfRequireDest)); env.close(); - env(check::create(alice, bob, USD(50)), ter(tecDST_TAG_NEEDED)); + env(check::create(alice, bob, usd(50)), Ter(tecDST_TAG_NEEDED)); env.close(); - env(check::create(alice, bob, USD(50)), dest_tag(11)); + env(check::create(alice, bob, usd(50)), DestTag(11)); env.close(); env(fclear(bob, asfRequireDest)); env.close(); { // Globally frozen asset. - IOU const USF{gwF["USF"]}; + IOU const usf{gwF["USF"]}; env(fset(gwF, asfGlobalFreeze)); env.close(); - env(check::create(alice, bob, USF(50)), ter(tecFROZEN)); + env(check::create(alice, bob, usf(50)), Ter(tecFROZEN)); env.close(); - env(check::create(gwF, bob, USF(50)), ter(tecFROZEN)); + env(check::create(gwF, bob, usf(50)), Ter(tecFROZEN)); env.close(); env(fclear(gwF, asfGlobalFreeze)); env.close(); - env(check::create(alice, bob, USF(50))); + env(check::create(alice, bob, usf(50))); env.close(); - env(check::create(gwF, bob, USF(50))); + env(check::create(gwF, bob, usf(50))); env.close(); } { // Frozen trust line. Check creation should be similar to payment // behavior in the face of frozen trust lines. - env.trust(USD(1000), alice); - env.trust(USD(1000), bob); + env.trust(usd(1000), alice); + env.trust(usd(1000), bob); env.close(); - env(pay(gw1, alice, USD(25))); - env(pay(gw1, bob, USD(25))); + env(pay(gw1, alice, usd(25))); + env(pay(gw1, bob, usd(25))); env.close(); // Setting trustline freeze in one direction prevents alice from @@ -414,58 +414,58 @@ class Check_test : public beast::unit_test::suite // to create a check for USD to alice. env(trust(gw1, alice["USD"](0), tfSetFreeze)); env.close(); - env(check::create(alice, bob, USD(50)), ter(tecFROZEN)); + env(check::create(alice, bob, usd(50)), Ter(tecFROZEN)); env.close(); - env(pay(alice, bob, USD(1)), ter(tecPATH_DRY)); + env(pay(alice, bob, usd(1)), Ter(tecPATH_DRY)); env.close(); - env(check::create(bob, alice, USD(50))); + env(check::create(bob, alice, usd(50))); env.close(); - env(pay(bob, alice, USD(1))); + env(pay(bob, alice, usd(1))); env.close(); - env(check::create(gw1, alice, USD(50))); + env(check::create(gw1, alice, usd(50))); env.close(); - env(pay(gw1, alice, USD(1))); + env(pay(gw1, alice, usd(1))); env.close(); // Clear that freeze. Now check creation works. env(trust(gw1, alice["USD"](0), tfClearFreeze)); env.close(); - env(check::create(alice, bob, USD(50))); + env(check::create(alice, bob, usd(50))); env.close(); - env(check::create(bob, alice, USD(50))); + env(check::create(bob, alice, usd(50))); env.close(); - env(check::create(gw1, alice, USD(50))); + env(check::create(gw1, alice, usd(50))); env.close(); // Freezing in the other direction does not effect alice's USD // check creation, but prevents bob and gw1 from writing a check // for USD to alice. - env(trust(alice, USD(0), tfSetFreeze)); + env(trust(alice, usd(0), tfSetFreeze)); env.close(); - env(check::create(alice, bob, USD(50))); + env(check::create(alice, bob, usd(50))); env.close(); - env(pay(alice, bob, USD(1))); + env(pay(alice, bob, usd(1))); env.close(); - env(check::create(bob, alice, USD(50)), ter(tecFROZEN)); + env(check::create(bob, alice, usd(50)), Ter(tecFROZEN)); env.close(); - env(pay(bob, alice, USD(1)), ter(tecPATH_DRY)); + env(pay(bob, alice, usd(1)), Ter(tecPATH_DRY)); env.close(); - env(check::create(gw1, alice, USD(50)), ter(tecFROZEN)); + env(check::create(gw1, alice, usd(50)), Ter(tecFROZEN)); env.close(); - env(pay(gw1, alice, USD(1)), ter(tecPATH_DRY)); + env(pay(gw1, alice, usd(1)), Ter(tecPATH_DRY)); env.close(); // Clear that freeze. - env(trust(alice, USD(0), tfClearFreeze)); + env(trust(alice, usd(0), tfClearFreeze)); env.close(); } // Expired expiration. - env(check::create(alice, bob, USD(50)), expiration(env.now()), ter(tecEXPIRED)); + env(check::create(alice, bob, usd(50)), Expiration(env.now()), Ter(tecEXPIRED)); env.close(); using namespace std::chrono_literals; - env(check::create(alice, bob, USD(50)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(50)), Expiration(env.now() + 1s)); env.close(); // Insufficient reserve. @@ -473,15 +473,15 @@ class Check_test : public beast::unit_test::suite env.fund(env.current()->fees().accountReserve(1) - drops(1), cheri); env.close(); - env(check::create(cheri, bob, USD(50)), - fee(drops(env.current()->fees().base)), - ter(tecINSUFFICIENT_RESERVE)); + env(check::create(cheri, bob, usd(50)), + Fee(drops(env.current()->fees().base)), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); env(pay(bob, cheri, drops(env.current()->fees().base + 1))); env.close(); - env(check::create(cheri, bob, USD(50))); + env(check::create(cheri, bob, usd(50))); env.close(); } @@ -507,8 +507,8 @@ class Check_test : public beast::unit_test::suite uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; env(check::create(alice, bob, XRP(10))); env.close(); - env.require(balance(alice, startBalance - drops(baseFeeDrops))); - env.require(balance(bob, startBalance)); + env.require(Balance(alice, startBalance - drops(baseFeeDrops))); + env.require(Balance(bob, startBalance)); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -516,8 +516,8 @@ class Check_test : public beast::unit_test::suite env(check::cash(bob, chkId, XRP(10))); env.close(); - env.require(balance(alice, startBalance - XRP(10) - drops(baseFeeDrops))); - env.require(balance(bob, startBalance + XRP(10) - drops(baseFeeDrops))); + env.require(Balance(alice, startBalance - XRP(10) - drops(baseFeeDrops))); + env.require(Balance(bob, startBalance + XRP(10) - drops(baseFeeDrops))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -527,8 +527,8 @@ class Check_test : public beast::unit_test::suite env(pay(env.master, alice, XRP(10) + drops(baseFeeDrops))); env(pay(bob, env.master, XRP(10) - drops(baseFeeDrops * 2))); env.close(); - env.require(balance(alice, startBalance)); - env.require(balance(bob, startBalance)); + env.require(Balance(alice, startBalance)); + env.require(Balance(bob, startBalance)); } { // Write a check that chews into alice's reserve. @@ -539,10 +539,10 @@ class Check_test : public beast::unit_test::suite env.close(); // bob tries to cash for more than the check amount. - env(check::cash(bob, chkId, checkAmount + drops(1)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, checkAmount + drops(1)), Ter(tecPATH_PARTIAL)); env.close(); env(check::cash(bob, chkId, check::DeliverMin(checkAmount + drops(1))), - ter(tecPATH_PARTIAL)); + Ter(tecPATH_PARTIAL)); env.close(); // bob cashes exactly the check amount. This is successful @@ -550,8 +550,8 @@ class Check_test : public beast::unit_test::suite // check is consumed. env(check::cash(bob, chkId, check::DeliverMin(checkAmount))); verifyDeliveredAmount(env, drops(checkAmount.mantissa())); - env.require(balance(alice, reserve)); - env.require(balance(bob, startBalance + checkAmount - drops(baseFeeDrops * 3))); + env.require(Balance(alice, reserve)); + env.require(Balance(bob, startBalance + checkAmount - drops(baseFeeDrops * 3))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -561,8 +561,8 @@ class Check_test : public beast::unit_test::suite env(pay(env.master, alice, checkAmount + drops(baseFeeDrops))); env(pay(bob, env.master, checkAmount - drops(baseFeeDrops * 4))); env.close(); - env.require(balance(alice, startBalance)); - env.require(balance(bob, startBalance)); + env.require(Balance(alice, startBalance)); + env.require(Balance(bob, startBalance)); } { // Write a check that goes one drop past what alice can pay. @@ -574,14 +574,14 @@ class Check_test : public beast::unit_test::suite // bob tries to cash for exactly the check amount. Fails because // alice is one drop shy of funding the check. - env(check::cash(bob, chkId, checkAmount), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, checkAmount), Ter(tecPATH_PARTIAL)); env.close(); // bob decides to get what he can from the bounced check. env(check::cash(bob, chkId, check::DeliverMin(drops(1)))); verifyDeliveredAmount(env, drops(checkAmount.mantissa() - 1)); - env.require(balance(alice, reserve)); - env.require(balance(bob, startBalance + checkAmount - drops(baseFeeDrops * 2 + 1))); + env.require(Balance(alice, reserve)); + env.require(Balance(bob, startBalance + checkAmount - drops(baseFeeDrops * 2 + 1))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -591,8 +591,8 @@ class Check_test : public beast::unit_test::suite env(pay(env.master, alice, checkAmount + drops(baseFeeDrops - 1))); env(pay(bob, env.master, checkAmount - drops(baseFeeDrops * 3 + 1))); env.close(); - env.require(balance(alice, startBalance)); - env.require(balance(bob, startBalance)); + env.require(Balance(alice, startBalance)); + env.require(Balance(bob, startBalance)); } } @@ -607,7 +607,7 @@ class Check_test : public beast::unit_test::suite Account const gw{"gateway"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; { // Simple IOU check cashed with Amount (with failures). Env env{*this, features}; @@ -617,67 +617,68 @@ class Check_test : public beast::unit_test::suite // alice writes the check before she gets the funds. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); // bob attempts to cash the check. Should fail. - env(check::cash(bob, chkId1, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); // alice gets almost enough funds. bob tries and fails again. - env(trust(alice, USD(20))); + env(trust(alice, usd(20))); env.close(); - env(pay(gw, alice, USD(9.5))); + env(pay(gw, alice, usd(9.5))); env.close(); - env(check::cash(bob, chkId1, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); // alice gets the last of the necessary funds. bob tries again // and fails because he hasn't got a trust line for USD. - env(pay(gw, alice, USD(0.5))); + env(pay(gw, alice, usd(0.5))); env.close(); // bob sets up the trust line, but not at a high enough limit. - env(trust(bob, USD(9.5))); + env(trust(bob, usd(9.5))); env.close(); // bob sets the trust line limit high enough but asks for more // than the check's SendMax. - env(trust(bob, USD(10.5))); + env(trust(bob, usd(10.5))); env.close(); - env(check::cash(bob, chkId1, USD(10.5)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId1, usd(10.5)), Ter(tecPATH_PARTIAL)); env.close(); // bob asks for exactly the check amount and the check clears. - env(check::cash(bob, chkId1, USD(10))); + env(check::cash(bob, chkId1, usd(10))); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(10))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(10))); + BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob tries to cash the same check again, which fails. - env(check::cash(bob, chkId1, USD(10)), ter(tecNO_ENTRY)); + env(check::cash(bob, chkId1, usd(10)), Ter(tecNO_ENTRY)); env.close(); // bob pays alice USD(7) so he can try another case. - env(pay(bob, alice, USD(7))); + env(pay(bob, alice, usd(7))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(7))); + env(check::create(alice, bob, usd(7))); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); // bob cashes the check for less than the face amount. That works, // consumes the check, and bob receives as much as he asked for. - env(check::cash(bob, chkId2, USD(5))); + env(check::cash(bob, chkId2, usd(5))); env.close(); - env.require(balance(alice, USD(2))); - env.require(balance(bob, USD(8))); + env.require(Balance(alice, usd(2))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -685,19 +686,19 @@ class Check_test : public beast::unit_test::suite // alice writes two checks for USD(2), although she only has USD(2). uint256 const chkId3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); uint256 const chkId4{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(checksOnAccount(env, bob).size() == 2); // bob cashes the second check for the face amount. - env(check::cash(bob, chkId4, USD(2))); + env(check::cash(bob, chkId4, usd(2))); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(10))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(10))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -705,10 +706,10 @@ class Check_test : public beast::unit_test::suite // bob is not allowed to cash the last check for USD(0), he must // use check::cancel instead. - env(check::cash(bob, chkId3, USD(0)), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId3, usd(0)), Ter(temBAD_AMOUNT)); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(10))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(10))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -724,27 +725,27 @@ class Check_test : public beast::unit_test::suite // a check can. // Payment of 20 USD fails. - env(pay(gw, bob, USD(20)), ter(tecPATH_PARTIAL)); + env(pay(gw, bob, usd(20)), Ter(tecPATH_PARTIAL)); env.close(); uint256 const chkId20{getCheckIndex(gw, env.seq(gw))}; - env(check::create(gw, bob, USD(20))); + env(check::create(gw, bob, usd(20))); env.close(); // However cashing a check for 20 USD succeeds. - env(check::cash(bob, chkId20, USD(20))); + env(check::cash(bob, chkId20, usd(20))); env.close(); - env.require(balance(bob, USD(30))); + env.require(Balance(bob, usd(30))); // Clean up this most recent experiment so the rest of the // tests work. - env(pay(bob, gw, USD(20))); + env(pay(bob, gw, usd(20))); // ... so bob cancels alice's remaining check. env(check::cancel(bob, chkId3)); env.close(); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(10))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(10))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -757,66 +758,66 @@ class Check_test : public beast::unit_test::suite env.fund(XRP(1000), gw, alice, bob); env.close(); - env(trust(alice, USD(20))); - env(trust(bob, USD(20))); + env(trust(alice, usd(20))); + env(trust(bob, usd(20))); env.close(); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // alice creates several checks ahead of time. uint256 const chkId9{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(9))); + env(check::create(alice, bob, usd(9))); env.close(); uint256 const chkId8{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(8))); + env(check::create(alice, bob, usd(8))); env.close(); uint256 const chkId7{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(7))); + env(check::create(alice, bob, usd(7))); env.close(); uint256 const chkId6{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(6))); + env(check::create(alice, bob, usd(6))); env.close(); // bob attempts to cash a check for the amount on the check. // Should fail, since alice doesn't have the funds. - env(check::cash(bob, chkId9, check::DeliverMin(USD(9))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId9, check::DeliverMin(usd(9))), Ter(tecPATH_PARTIAL)); env.close(); // bob sets a DeliverMin of 7 and gets all that alice has. - env(check::cash(bob, chkId9, check::DeliverMin(USD(7)))); - verifyDeliveredAmount(env, USD(8)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId9, check::DeliverMin(usd(7)))); + verifyDeliveredAmount(env, usd(8)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 3); BEAST_EXPECT(checksOnAccount(env, bob).size() == 3); BEAST_EXPECT(ownerCount(env, alice) == 4); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob pays alice USD(7) so he can use another check. - env(pay(bob, alice, USD(7))); + env(pay(bob, alice, usd(7))); env.close(); // Using DeliverMin for the SendMax value of the check (and no // transfer fees) should work just like setting Amount. - env(check::cash(bob, chkId7, check::DeliverMin(USD(7)))); - verifyDeliveredAmount(env, USD(7)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId7, check::DeliverMin(usd(7)))); + verifyDeliveredAmount(env, usd(7)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(checksOnAccount(env, bob).size() == 2); BEAST_EXPECT(ownerCount(env, alice) == 3); BEAST_EXPECT(ownerCount(env, bob) == 1); // bob pays alice USD(8) so he can use the last two checks. - env(pay(bob, alice, USD(8))); + env(pay(bob, alice, usd(8))); env.close(); // alice has USD(8). If bob uses the check for USD(6) and uses a // DeliverMin of 4, he should get the SendMax value of the check. - env(check::cash(bob, chkId6, check::DeliverMin(USD(4)))); - verifyDeliveredAmount(env, USD(6)); - env.require(balance(alice, USD(2))); - env.require(balance(bob, USD(6))); + env(check::cash(bob, chkId6, check::DeliverMin(usd(4)))); + verifyDeliveredAmount(env, usd(6)); + env.require(Balance(alice, usd(2))); + env.require(Balance(bob, usd(6))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -824,10 +825,10 @@ class Check_test : public beast::unit_test::suite // bob cashes the last remaining check setting a DeliverMin. // of exactly alice's remaining USD. - env(check::cash(bob, chkId8, check::DeliverMin(USD(2)))); - verifyDeliveredAmount(env, USD(2)); - env.require(balance(alice, USD(0))); - env.require(balance(bob, USD(8))); + env(check::cash(bob, chkId8, check::DeliverMin(usd(2)))); + verifyDeliveredAmount(env, usd(2)); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, usd(8))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -840,31 +841,31 @@ class Check_test : public beast::unit_test::suite env.fund(XRP(1000), gw, alice, bob); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, alice["USD"](100)), txflags(tfSetfAuth)); - env(trust(alice, USD(20))); + env(trust(gw, alice["USD"](100)), Txflags(tfSetfAuth)); + env(trust(alice, usd(20))); env.close(); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // alice writes a check to bob for USD. bob can't cash it // because he is not authorized to hold gw["USD"]. uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(7))); + env(check::create(alice, bob, usd(7))); env.close(); - env(check::cash(bob, chkId, USD(7)), ter(tecNO_AUTH)); + env(check::cash(bob, chkId, usd(7)), Ter(tecNO_AUTH)); env.close(); // Now give bob a trustline for USD. bob still can't cash the // check because he is not authorized. - env(trust(bob, USD(5))); + env(trust(bob, usd(5))); env.close(); - env(check::cash(bob, chkId, USD(7)), ter(tecNO_AUTH)); + env(check::cash(bob, chkId, usd(7)), Ter(tecNO_AUTH)); env.close(); // bob gets authorization to hold gw["USD"]. - env(trust(gw, bob["USD"](1)), txflags(tfSetfAuth)); + env(trust(gw, bob["USD"](1)), Txflags(tfSetfAuth)); env.close(); // Two possible outcomes here depending on whether cashing a @@ -874,11 +875,11 @@ class Check_test : public beast::unit_test::suite // his trust limit. // o If it can build a trust line, then the check is allowed to // exceed the trust limit and bob gets the full transfer. - env(check::cash(bob, chkId, check::DeliverMin(USD(4)))); - STAmount const bobGot = USD(7); + env(check::cash(bob, chkId, check::DeliverMin(usd(4)))); + STAmount const bobGot = usd(7); verifyDeliveredAmount(env, bobGot); - env.require(balance(alice, USD(8) - bobGot)); - env.require(balance(bob, bobGot)); + env.require(Balance(alice, usd(8) - bobGot)); + env.require(Balance(bob, bobGot)); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); @@ -894,36 +895,36 @@ class Check_test : public beast::unit_test::suite // alice creates her checks ahead of time. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); - env(trust(alice, USD(20))); - env(trust(bob, USD(20))); + env(trust(alice, usd(20))); + env(trust(bob, usd(20))); env.close(); - env(pay(gw, alice, USD(8))); + env(pay(gw, alice, usd(8))); env.close(); // Give bob a regular key and signers - Account const bobby{"bobby", KeyType::secp256k1}; + Account const bobby{"bobby", KeyType::Secp256k1}; env(regkey(bob, bobby)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(bob, 2, {{bogie, 1}, {demon, 1}}), sig(bobby)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(bob, 2, {{bogie, 1}, {demon, 1}}), Sig(bobby)); env.close(); BEAST_EXPECT(ownerCount(env, bob) == 2); // bob uses his regular key to cash a check. - env(check::cash(bob, chkId1, (USD(1))), sig(bobby)); + env(check::cash(bob, chkId1, (usd(1))), Sig(bobby)); env.close(); - env.require(balance(alice, USD(7))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(7))); + env.require(Balance(bob, usd(1))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -931,10 +932,10 @@ class Check_test : public beast::unit_test::suite // bob uses multisigning to cash a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::cash(bob, chkId2, (USD(2))), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::cash(bob, chkId2, (usd(2))), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); - env.require(balance(alice, USD(5))); - env.require(balance(bob, USD(3))); + env.require(Balance(alice, usd(5))); + env.require(Balance(bob, usd(3))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -953,17 +954,17 @@ class Check_test : public beast::unit_test::suite Account const gw{"gateway"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env.close(); - env(pay(gw, alice, USD(1000))); + env(pay(gw, alice, usd(1000))); env.close(); // Set gw's transfer rate and see the consequences when cashing a check. @@ -973,28 +974,28 @@ class Check_test : public beast::unit_test::suite // alice writes a check with a SendMax of USD(125). The most bob // can get is USD(100) because of the transfer rate. uint256 const chkId125{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(125))); + env(check::create(alice, bob, usd(125))); env.close(); // alice writes another check that won't get cashed until the transfer // rate changes so we can see the rate applies when the check is // cashed, not when it is created. uint256 const chkId120{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(120))); + env(check::create(alice, bob, usd(120))); env.close(); // bob attempts to cash the check for face value. Should fail. - env(check::cash(bob, chkId125, USD(125)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId125, usd(125)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkId125, check::DeliverMin(USD(101))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId125, check::DeliverMin(usd(101))), Ter(tecPATH_PARTIAL)); env.close(); // bob decides that he'll accept anything USD(75) or up. // He gets USD(100). - env(check::cash(bob, chkId125, check::DeliverMin(USD(75)))); - verifyDeliveredAmount(env, USD(100)); - env.require(balance(alice, USD(1000 - 125))); - env.require(balance(bob, USD(0 + 100))); + env(check::cash(bob, chkId125, check::DeliverMin(usd(75)))); + verifyDeliveredAmount(env, usd(100)); + env.require(Balance(alice, usd(1000 - 125))); + env.require(Balance(bob, usd(0 + 100))); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(checksOnAccount(env, bob).size() == 1); @@ -1004,10 +1005,10 @@ class Check_test : public beast::unit_test::suite // bob cashes the second check for less than the face value. The new // rate applies to the actual value transferred. - env(check::cash(bob, chkId120, USD(50))); + env(check::cash(bob, chkId120, usd(50))); env.close(); - env.require(balance(alice, USD(1000 - 125 - 60))); - env.require(balance(bob, USD(0 + 100 + 50))); + env.require(Balance(alice, usd(1000 - 125 - 60))); + env.require(Balance(bob, usd(0 + 100 + 50))); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(checksOnAccount(env, bob).empty()); } @@ -1023,17 +1024,17 @@ class Check_test : public beast::unit_test::suite Account const gw{"gateway"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env.close(); - env(pay(gw, alice, USD(1000))); + env(pay(gw, alice, usd(1000))); env.close(); // @@ -1041,29 +1042,29 @@ class Check_test : public beast::unit_test::suite // // Provide lambdas that return a qualityInPercent and qualityOutPercent. - auto qIn = [](double percent) { return qualityInPercent(percent); }; - auto qOut = [](double percent) { return qualityOutPercent(percent); }; + auto qIn = [](double percent) { return QualityInPercent(percent); }; + auto qOut = [](double percent) { return QualityOutPercent(percent); }; // There are two test lambdas: one for a Payment and one for a Check. // This shows whether a Payment and a Check behave the same. - auto testNonIssuerQPay = [&env, &alice, &bob, &USD]( + auto testNonIssuerQPay = [&env, &alice, &bob, &usd]( Account const& truster, IOU const& iou, auto const& inOrOut, double pct, double amount) { // Capture bob's and alice's balances so we can test at the end. - STAmount const aliceStart{env.balance(alice, USD).value()}; - STAmount const bobStart{env.balance(bob, USD).value()}; + STAmount const aliceStart{env.balance(alice, usd).value()}; + STAmount const bobStart{env.balance(bob, usd).value()}; // Set the modified quality. env(trust(truster, iou(1000)), inOrOut(pct)); env.close(); - env(pay(alice, bob, USD(amount)), sendmax(USD(10))); + env(pay(alice, bob, usd(amount)), Sendmax(usd(10))); env.close(); - env.require(balance(alice, aliceStart - USD(10))); - env.require(balance(bob, bobStart + USD(10))); + env.require(Balance(alice, aliceStart - usd(10))); + env.require(Balance(bob, bobStart + usd(10))); // Return the quality to the unmodified state so it doesn't // interfere with upcoming tests. @@ -1071,28 +1072,28 @@ class Check_test : public beast::unit_test::suite env.close(); }; - auto testNonIssuerQCheck = [&env, &alice, &bob, &USD]( + auto testNonIssuerQCheck = [&env, &alice, &bob, &usd]( Account const& truster, IOU const& iou, auto const& inOrOut, double pct, double amount) { // Capture bob's and alice's balances so we can test at the end. - STAmount const aliceStart{env.balance(alice, USD).value()}; - STAmount const bobStart{env.balance(bob, USD).value()}; + STAmount const aliceStart{env.balance(alice, usd).value()}; + STAmount const bobStart{env.balance(bob, usd).value()}; // Set the modified quality. env(trust(truster, iou(1000)), inOrOut(pct)); env.close(); uint256 const chkId = getCheckIndex(alice, env.seq(alice)); - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); - env(check::cash(bob, chkId, USD(amount))); + env(check::cash(bob, chkId, usd(amount))); env.close(); - env.require(balance(alice, aliceStart - USD(10))); - env.require(balance(bob, bobStart + USD(10))); + env.require(Balance(alice, aliceStart - usd(10))); + env.require(Balance(bob, bobStart + usd(10))); // Return the quality to the unmodified state so it doesn't // interfere with upcoming tests. @@ -1131,7 +1132,7 @@ class Check_test : public beast::unit_test::suite // // There are two test lambdas for the same reason as before. - auto testIssuerQPay = [&env, &gw, &alice, &USD]( + auto testIssuerQPay = [&env, &gw, &alice, &usd]( Account const& truster, IOU const& iou, auto const& inOrOut, @@ -1142,21 +1143,21 @@ class Check_test : public beast::unit_test::suite double max2) { // Capture alice's balance so we can test at the end. It doesn't // make any sense to look at the balance of a gateway. - STAmount const aliceStart{env.balance(alice, USD).value()}; + STAmount const aliceStart{env.balance(alice, usd).value()}; // Set the modified quality. env(trust(truster, iou(1000)), inOrOut(pct)); env.close(); // alice pays gw. - env(pay(alice, gw, USD(amt1)), sendmax(USD(max1))); + env(pay(alice, gw, usd(amt1)), Sendmax(usd(max1))); env.close(); - env.require(balance(alice, aliceStart - USD(10))); + env.require(Balance(alice, aliceStart - usd(10))); // gw pays alice. - env(pay(gw, alice, USD(amt2)), sendmax(USD(max2))); + env(pay(gw, alice, usd(amt2)), Sendmax(usd(max2))); env.close(); - env.require(balance(alice, aliceStart)); + env.require(Balance(alice, aliceStart)); // Return the quality to the unmodified state so it doesn't // interfere with upcoming tests. @@ -1164,7 +1165,7 @@ class Check_test : public beast::unit_test::suite env.close(); }; - auto testIssuerQCheck = [&env, &gw, &alice, &USD]( + auto testIssuerQCheck = [&env, &gw, &alice, &usd]( Account const& truster, IOU const& iou, auto const& inOrOut, @@ -1175,7 +1176,7 @@ class Check_test : public beast::unit_test::suite double max2) { // Capture alice's balance so we can test at the end. It doesn't // make any sense to look at the balance of the issuer. - STAmount const aliceStart{env.balance(alice, USD).value()}; + STAmount const aliceStart{env.balance(alice, usd).value()}; // Set the modified quality. env(trust(truster, iou(1000)), inOrOut(pct)); @@ -1183,21 +1184,21 @@ class Check_test : public beast::unit_test::suite // alice writes check to gw. gw cashes. uint256 const chkAliceId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, gw, USD(max1))); + env(check::create(alice, gw, usd(max1))); env.close(); - env(check::cash(gw, chkAliceId, USD(amt1))); + env(check::cash(gw, chkAliceId, usd(amt1))); env.close(); - env.require(balance(alice, aliceStart - USD(10))); + env.require(Balance(alice, aliceStart - usd(10))); // gw writes check to alice. alice cashes. uint256 const chkGwId{getCheckIndex(gw, env.seq(gw))}; - env(check::create(gw, alice, USD(max2))); + env(check::create(gw, alice, usd(max2))); env.close(); - env(check::cash(alice, chkGwId, USD(amt2))); + env(check::cash(alice, chkGwId, usd(amt2))); env.close(); - env.require(balance(alice, aliceStart)); + env.require(Balance(alice, aliceStart)); // Return the quality to the unmodified state so it doesn't // interfere with upcoming tests. @@ -1232,7 +1233,7 @@ class Check_test : public beast::unit_test::suite Account const alice{"alice"}; Account const bob{"bob"}; Account const zoe{"zoe"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env(*this, features); @@ -1240,25 +1241,25 @@ class Check_test : public beast::unit_test::suite env.close(); // Now set up alice's trustline. - env(trust(alice, USD(20))); + env(trust(alice, usd(20))); env.close(); - env(pay(gw, alice, USD(20))); + env(pay(gw, alice, usd(20))); env.close(); // Now set up bob's trustline. - env(trust(bob, USD(20))); + env(trust(bob, usd(20))); env.close(); // bob tries to cash a non-existent check from alice. { uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::cash(bob, chkId, USD(20)), ter(tecNO_ENTRY)); + env(check::cash(bob, chkId, usd(20)), Ter(tecNO_ENTRY)); env.close(); } // alice creates her checks ahead of time. uint256 const chkIdU{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(20))); + env(check::create(alice, bob, usd(20))); env.close(); uint256 const chkIdX{getCheckIndex(alice, env.seq(alice))}; @@ -1267,66 +1268,66 @@ class Check_test : public beast::unit_test::suite using namespace std::chrono_literals; uint256 const chkIdExp{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdFroz1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkIdFroz2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2))); + env(check::create(alice, bob, usd(2))); env.close(); uint256 const chkIdFroz3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(3))); + env(check::create(alice, bob, usd(3))); env.close(); uint256 const chkIdFroz4{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(4))); + env(check::create(alice, bob, usd(4))); env.close(); uint256 const chkIdFroz4ToIssuer{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, gw, USD(4))); + env(check::create(alice, gw, usd(4))); env.close(); uint256 const chkIdFroz4Issuer{getCheckIndex(gw, env.seq(gw))}; - env(check::create(gw, alice, USD(4))); + env(check::create(gw, alice, usd(4))); env.close(); uint256 const chkIdNoDest1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(1))); + env(check::create(alice, bob, usd(1))); env.close(); uint256 const chkIdHasDest2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(2)), dest_tag(7)); + env(check::create(alice, bob, usd(2)), DestTag(7)); env.close(); // Same set of failing cases for both IOU and XRP check cashing. auto failingCases = [&env, &gw, &alice, &bob]( uint256 const& chkId, STAmount const& amount) { // Bad fee. - env(check::cash(bob, chkId, amount), fee(drops(-10)), ter(temBAD_FEE)); + env(check::cash(bob, chkId, amount), Fee(drops(-10)), Ter(temBAD_FEE)); env.close(); // Bad flags. env(check::cash(bob, chkId, amount), - txflags(tfImmediateOrCancel), - ter(temINVALID_FLAG)); + Txflags(tfImmediateOrCancel), + Ter(temINVALID_FLAG)); env.close(); // Missing both Amount and DeliverMin. { - Json::Value tx{check::cash(bob, chkId, amount)}; + json::Value tx{check::cash(bob, chkId, amount)}; tx.removeMember(sfAmount.jsonName); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); env.close(); } // Both Amount and DeliverMin present. { - Json::Value tx{check::cash(bob, chkId, amount)}; - tx[sfDeliverMin.jsonName] = amount.getJson(JsonOptions::none); - env(tx, ter(temMALFORMED)); + json::Value tx{check::cash(bob, chkId, amount)}; + tx[sfDeliverMin.jsonName] = amount.getJson(JsonOptions::KNone); + env(tx, Ter(temMALFORMED)); env.close(); } @@ -1334,9 +1335,9 @@ class Check_test : public beast::unit_test::suite { STAmount neg{amount}; neg.negate(); - env(check::cash(bob, chkId, neg), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId, neg), Ter(temBAD_AMOUNT)); env.close(); - env(check::cash(bob, chkId, amount.zeroed()), ter(temBAD_AMOUNT)); + env(check::cash(bob, chkId, amount.zeroed()), Ter(temBAD_AMOUNT)); env.close(); } @@ -1346,14 +1347,14 @@ class Check_test : public beast::unit_test::suite Issue const badIssue{badCurrency(), amount.getIssuer()}; STAmount badAmount{amount}; badAmount.setIssue(Issue{badCurrency(), amount.getIssuer()}); - env(check::cash(bob, chkId, badAmount), ter(temBAD_CURRENCY)); + env(check::cash(bob, chkId, badAmount), Ter(temBAD_CURRENCY)); env.close(); } // Not destination cashing check. - env(check::cash(alice, chkId, amount), ter(tecNO_PERMISSION)); + env(check::cash(alice, chkId, amount), Ter(tecNO_PERMISSION)); env.close(); - env(check::cash(gw, chkId, amount), ter(tecNO_PERMISSION)); + env(check::cash(gw, chkId, amount), Ter(tecNO_PERMISSION)); env.close(); // Currency mismatch. @@ -1361,7 +1362,7 @@ class Check_test : public beast::unit_test::suite IOU const wrongCurrency{gw["EUR"]}; STAmount badAmount{amount}; badAmount.setIssue(wrongCurrency); - env(check::cash(bob, chkId, badAmount), ter(temMALFORMED)); + env(check::cash(bob, chkId, badAmount), Ter(temMALFORMED)); env.close(); } @@ -1370,30 +1371,30 @@ class Check_test : public beast::unit_test::suite IOU const wrongIssuer{alice["USD"]}; STAmount badAmount{amount}; badAmount.setIssue(wrongIssuer); - env(check::cash(bob, chkId, badAmount), ter(temMALFORMED)); + env(check::cash(bob, chkId, badAmount), Ter(temMALFORMED)); env.close(); } // Amount bigger than SendMax. - env(check::cash(bob, chkId, amount + amount), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, amount + amount), Ter(tecPATH_PARTIAL)); env.close(); // DeliverMin bigger than SendMax. - env(check::cash(bob, chkId, check::DeliverMin(amount + amount)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkId, check::DeliverMin(amount + amount)), Ter(tecPATH_PARTIAL)); env.close(); }; failingCases(chkIdX, XRP(10)); - failingCases(chkIdU, USD(20)); + failingCases(chkIdU, usd(20)); // Verify that those two checks really were cashable. - env(check::cash(bob, chkIdU, USD(20))); + env(check::cash(bob, chkIdU, usd(20))); env.close(); env(check::cash(bob, chkIdX, check::DeliverMin(XRP(10)))); verifyDeliveredAmount(env, XRP(10)); // Try to cash an expired check. - env(check::cash(bob, chkIdExp, XRP(10)), ter(tecEXPIRED)); + env(check::cash(bob, chkIdExp, XRP(10)), Ter(tecEXPIRED)); env.close(); // Cancel the expired check. Anyone can cancel an expired check. @@ -1402,117 +1403,117 @@ class Check_test : public beast::unit_test::suite // Can we cash a check with frozen currency? { - env(pay(bob, alice, USD(20))); + env(pay(bob, alice, usd(20))); env.close(); - env.require(balance(alice, USD(20))); - env.require(balance(bob, USD(0))); + env.require(Balance(alice, usd(20))); + env.require(Balance(bob, usd(0))); // Global freeze env(fset(gw, asfGlobalFreeze)); env.close(); - env(check::cash(bob, chkIdFroz1, USD(1)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz1, usd(1)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkIdFroz1, check::DeliverMin(USD(0.5))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz1, check::DeliverMin(usd(0.5))), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(gw, chkIdFroz4ToIssuer, USD(1)), ter(tecPATH_PARTIAL)); + env(check::cash(gw, chkIdFroz4ToIssuer, usd(1)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(gw, chkIdFroz4ToIssuer, check::DeliverMin(USD(0.5))), - ter(tecPATH_PARTIAL)); + env(check::cash(gw, chkIdFroz4ToIssuer, check::DeliverMin(usd(0.5))), + Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(alice, chkIdFroz4Issuer, USD(1)), ter(tecFROZEN)); + env(check::cash(alice, chkIdFroz4Issuer, usd(1)), Ter(tecFROZEN)); env.close(); - env(check::cash(alice, chkIdFroz4Issuer, check::DeliverMin(USD(0.5))), ter(tecFROZEN)); + env(check::cash(alice, chkIdFroz4Issuer, check::DeliverMin(usd(0.5))), Ter(tecFROZEN)); env.close(); env(fclear(gw, asfGlobalFreeze)); env.close(); // No longer frozen. Success. - env(check::cash(bob, chkIdFroz1, USD(1))); + env(check::cash(bob, chkIdFroz1, usd(1))); env.close(); - env.require(balance(alice, USD(19))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(19))); + env.require(Balance(bob, usd(1))); - env(check::cash(gw, chkIdFroz4ToIssuer, USD(1))); + env(check::cash(gw, chkIdFroz4ToIssuer, usd(1))); env.close(); // Freeze individual trustlines. env(trust(gw, alice["USD"](0), tfSetFreeze)); env.close(); - env(check::cash(bob, chkIdFroz2, USD(2)), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz2, usd(2)), Ter(tecPATH_PARTIAL)); env.close(); - env(check::cash(bob, chkIdFroz2, check::DeliverMin(USD(1))), ter(tecPATH_PARTIAL)); + env(check::cash(bob, chkIdFroz2, check::DeliverMin(usd(1))), Ter(tecPATH_PARTIAL)); env.close(); // Clear that freeze. Now check cashing works. env(trust(gw, alice["USD"](0), tfClearFreeze)); env.close(); - env(check::cash(bob, chkIdFroz2, USD(2))); + env(check::cash(bob, chkIdFroz2, usd(2))); env.close(); - env.require(balance(alice, USD(16))); - env.require(balance(bob, USD(3))); + env.require(Balance(alice, usd(16))); + env.require(Balance(bob, usd(3))); // Freeze bob's trustline. bob can't cash the check. env(trust(gw, bob["USD"](0), tfSetFreeze)); env.close(); - env(check::cash(bob, chkIdFroz3, USD(3)), ter(tecFROZEN)); + env(check::cash(bob, chkIdFroz3, usd(3)), Ter(tecFROZEN)); env.close(); - env(check::cash(bob, chkIdFroz3, check::DeliverMin(USD(1))), ter(tecFROZEN)); + env(check::cash(bob, chkIdFroz3, check::DeliverMin(usd(1))), Ter(tecFROZEN)); env.close(); // Clear that freeze. Now check cashing works again. env(trust(gw, bob["USD"](0), tfClearFreeze)); env.close(); - env(check::cash(bob, chkIdFroz3, check::DeliverMin(USD(1)))); - verifyDeliveredAmount(env, USD(3)); - env.require(balance(alice, USD(13))); - env.require(balance(bob, USD(6))); + env(check::cash(bob, chkIdFroz3, check::DeliverMin(usd(1)))); + verifyDeliveredAmount(env, usd(3)); + env.require(Balance(alice, usd(13))); + env.require(Balance(bob, usd(6))); // Set bob's freeze bit in the other direction. Check // cashing fails. - env(trust(bob, USD(20), tfSetFreeze)); + env(trust(bob, usd(20), tfSetFreeze)); env.close(); - env(check::cash(bob, chkIdFroz4, USD(4)), ter(terNO_LINE)); + env(check::cash(bob, chkIdFroz4, usd(4)), Ter(terNO_LINE)); env.close(); - env(check::cash(bob, chkIdFroz4, check::DeliverMin(USD(1))), ter(terNO_LINE)); + env(check::cash(bob, chkIdFroz4, check::DeliverMin(usd(1))), Ter(terNO_LINE)); env.close(); // Clear bob's freeze bit and the check should be cashable. - env(trust(bob, USD(20), tfClearFreeze)); + env(trust(bob, usd(20), tfClearFreeze)); env.close(); - env(check::cash(bob, chkIdFroz4, USD(4))); + env(check::cash(bob, chkIdFroz4, usd(4))); env.close(); - env.require(balance(alice, USD(9))); - env.require(balance(bob, USD(10))); + env.require(Balance(alice, usd(9))); + env.require(Balance(bob, usd(10))); } { // Set the RequireDest flag on bob's account (after the check // was created) then cash a check without a destination tag. env(fset(bob, asfRequireDest)); env.close(); - env(check::cash(bob, chkIdNoDest1, USD(1)), ter(tecDST_TAG_NEEDED)); + env(check::cash(bob, chkIdNoDest1, usd(1)), Ter(tecDST_TAG_NEEDED)); env.close(); - env(check::cash(bob, chkIdNoDest1, check::DeliverMin(USD(0.5))), - ter(tecDST_TAG_NEEDED)); + env(check::cash(bob, chkIdNoDest1, check::DeliverMin(usd(0.5))), + Ter(tecDST_TAG_NEEDED)); env.close(); // bob can cash a check with a destination tag. - env(check::cash(bob, chkIdHasDest2, USD(2))); + env(check::cash(bob, chkIdHasDest2, usd(2))); env.close(); - env.require(balance(alice, USD(7))); - env.require(balance(bob, USD(12))); + env.require(Balance(alice, usd(7))); + env.require(Balance(bob, usd(12))); // Clear the RequireDest flag on bob's account so he can // cash the check with no DestinationTag. env(fclear(bob, asfRequireDest)); env.close(); - env(check::cash(bob, chkIdNoDest1, USD(1))); + env(check::cash(bob, chkIdNoDest1, usd(1))); env.close(); - env.require(balance(alice, USD(6))); - env.require(balance(bob, USD(13))); + env.require(Balance(alice, usd(6))); + env.require(Balance(bob, usd(13))); } } @@ -1528,7 +1529,7 @@ class Check_test : public beast::unit_test::suite Account const alice{"alice"}; Account const bob{"bob"}; Account const zoe{"zoe"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; { Env env{*this, features}; @@ -1539,7 +1540,7 @@ class Check_test : public beast::unit_test::suite // alice creates her checks ahead of time. // Three ordinary checks with no expiration. uint256 const chkId1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); uint256 const chkId2{getCheckIndex(alice, env.seq(alice))}; @@ -1547,39 +1548,39 @@ class Check_test : public beast::unit_test::suite env.close(); uint256 const chkId3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); // Three checks that expire in 10 minutes. using namespace std::chrono_literals; uint256 const chkIdNotExp1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 600s)); env.close(); uint256 const chkIdNotExp2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 600s)); env.close(); uint256 const chkIdNotExp3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 600s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 600s)); env.close(); // Three checks that expire in one second. uint256 const chkIdExp1{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdExp2{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, XRP(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, XRP(10)), Expiration(env.now() + 1s)); env.close(); uint256 const chkIdExp3{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10)), expiration(env.now() + 1s)); + env(check::create(alice, bob, usd(10)), Expiration(env.now() + 1s)); env.close(); // Two checks to cancel using a regular key and using multisigning. uint256 const chkIdReg{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, USD(10))); + env(check::create(alice, bob, usd(10))); env.close(); uint256 const chkIdMSig{getCheckIndex(alice, env.seq(alice))}; @@ -1599,7 +1600,7 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, alice).size() == 9); BEAST_EXPECT(ownerCount(env, alice) == 9); - env(check::cancel(zoe, chkId3), ter(tecNO_PERMISSION)); + env(check::cancel(zoe, chkId3), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 9); BEAST_EXPECT(ownerCount(env, alice) == 9); @@ -1615,7 +1616,7 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT(checksOnAccount(env, alice).size() == 7); BEAST_EXPECT(ownerCount(env, alice) == 7); - env(check::cancel(zoe, chkIdNotExp3), ter(tecNO_PERMISSION)); + env(check::cancel(zoe, chkIdNotExp3), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 7); BEAST_EXPECT(ownerCount(env, alice) == 7); @@ -1637,30 +1638,30 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 4); // Use a regular key and also multisign to cancel checks. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); env.close(); - Account const bogie{"bogie", KeyType::secp256k1}; - Account const demon{"demon", KeyType::ed25519}; - env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), sig(alie)); + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const demon{"demon", KeyType::Ed25519}; + env(signers(alice, 2, {{bogie, 1}, {demon, 1}}), Sig(alie)); env.close(); // alice uses her regular key to cancel a check. - env(check::cancel(alice, chkIdReg), sig(alie)); + env(check::cancel(alice, chkIdReg), Sig(alie)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 3); BEAST_EXPECT(ownerCount(env, alice) == 4); // alice uses multisigning to cancel a check. XRPAmount const baseFeeDrops{env.current()->fees().base}; - env(check::cancel(alice, chkIdMSig), msig(bogie, demon), fee(3 * baseFeeDrops)); + env(check::cancel(alice, chkIdMSig), Msig(bogie, demon), Fee(3 * baseFeeDrops)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(ownerCount(env, alice) == 3); // Creator and destination cancel the remaining unexpired checks. - env(check::cancel(alice, chkId3), sig(alice)); + env(check::cancel(alice, chkId3), Sig(alice)); env.close(); BEAST_EXPECT(checksOnAccount(env, alice).size() == 1); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -1690,18 +1691,18 @@ class Check_test : public beast::unit_test::suite // Bad fee. env(check::cancel(bob, getCheckIndex(alice, env.seq(alice))), - fee(drops(-10)), - ter(temBAD_FEE)); + Fee(drops(-10)), + Ter(temBAD_FEE)); env.close(); // Bad flags. env(check::cancel(bob, getCheckIndex(alice, env.seq(alice))), - txflags(tfImmediateOrCancel), - ter(temINVALID_FLAG)); + Txflags(tfImmediateOrCancel), + Ter(temINVALID_FLAG)); env.close(); // Non-existent check. - env(check::cancel(bob, getCheckIndex(alice, env.seq(alice))), ter(tecNO_ENTRY)); + env(check::cancel(bob, getCheckIndex(alice, env.seq(alice))), Ter(tecNO_ENTRY)); env.close(); } @@ -1726,10 +1727,10 @@ class Check_test : public beast::unit_test::suite env(check::cash(bob, chkId, check::DeliverMin(XRP(100)))); // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // DeliveredAmount and delivered_amount are present. BEAST_EXPECT(meta.isMember(sfDeliveredAmount.jsonName)); @@ -1746,7 +1747,7 @@ class Check_test : public beast::unit_test::suite Account const gw{"gw"}; Account const alice{"alice"}; Account const bob{"bob"}; - IOU const USD{gw["USD"]}; + IOU const usd{gw["USD"]}; Env env{*this, features}; env.fund(XRP(1000), gw, alice, bob); @@ -1764,15 +1765,15 @@ class Check_test : public beast::unit_test::suite std::uint32_t const bobSeq{env.seq(bob)}; env.close(); - env.require(owners(alice, 10)); - env.require(owners(bob, 10)); + env.require(Owners(alice, 10)); + env.require(Owners(bob, 10)); // alice gets enough USD to write a few checks. - env(trust(alice, USD(1000)), ticket::use(aliceTicketSeq++)); - env(trust(bob, USD(1000)), ticket::use(bobTicketSeq++)); + env(trust(alice, usd(1000)), ticket::Use(aliceTicketSeq++)); + env(trust(bob, usd(1000)), ticket::Use(bobTicketSeq++)); env.close(); - env.require(owners(alice, 10)); - env.require(owners(bob, 10)); + env.require(Owners(alice, 10)); + env.require(Owners(bob, 10)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1780,60 +1781,60 @@ class Check_test : public beast::unit_test::suite env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); - env(pay(gw, alice, USD(900))); + env(pay(gw, alice, usd(900))); env.close(); // alice creates four checks; two XRP, two IOU. Bob will cash // one of each and cancel one of each. uint256 const chkIdXrp1{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, XRP(200)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, XRP(200)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdXrp2{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, XRP(300)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, XRP(300)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdUsd1{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, USD(200)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, usd(200)), ticket::Use(aliceTicketSeq++)); uint256 const chkIdUsd2{getCheckIndex(alice, aliceTicketSeq)}; - env(check::create(alice, bob, USD(300)), ticket::use(aliceTicketSeq++)); + env(check::create(alice, bob, usd(300)), ticket::Use(aliceTicketSeq++)); env.close(); // Alice used four tickets but created four checks. - env.require(owners(alice, 10)); + env.require(Owners(alice, 10)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).size() == 4); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(bob, 10)); + env.require(Owners(bob, 10)); BEAST_EXPECT(env.seq(bob) == bobSeq); // Bob cancels two of alice's checks. - env(check::cancel(bob, chkIdXrp1), ticket::use(bobTicketSeq++)); - env(check::cancel(bob, chkIdUsd2), ticket::use(bobTicketSeq++)); + env(check::cancel(bob, chkIdXrp1), ticket::Use(bobTicketSeq++)); + env(check::cancel(bob, chkIdUsd2), ticket::Use(bobTicketSeq++)); env.close(); - env.require(owners(alice, 8)); + env.require(Owners(alice, 8)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).size() == 2); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(bob, 8)); + env.require(Owners(bob, 8)); BEAST_EXPECT(env.seq(bob) == bobSeq); // Bob cashes alice's two remaining checks. - env(check::cash(bob, chkIdXrp2, XRP(300)), ticket::use(bobTicketSeq++)); - env(check::cash(bob, chkIdUsd1, USD(200)), ticket::use(bobTicketSeq++)); + env(check::cash(bob, chkIdXrp2, XRP(300)), ticket::Use(bobTicketSeq++)); + env(check::cash(bob, chkIdUsd1, usd(200)), ticket::Use(bobTicketSeq++)); env.close(); - env.require(owners(alice, 6)); + env.require(Owners(alice, 6)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(checksOnAccount(env, alice).empty()); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(balance(alice, USD(700))); + env.require(Balance(alice, usd(700))); - env.require(owners(bob, 6)); + env.require(Owners(bob, 6)); BEAST_EXPECT(env.seq(bob) == bobSeq); - env.require(balance(bob, USD(200))); + env.require(Balance(bob, usd(200))); } void @@ -1851,7 +1852,7 @@ class Check_test : public beast::unit_test::suite // An account that independently tracks its owner count. struct AccountOwns { - beast::unit_test::suite& suite; + beast::unit_test::Suite& suite; Env const& env; Account const acct; std::size_t owners; @@ -1899,7 +1900,7 @@ class Check_test : public beast::unit_test::suite env.fund(XRP(5000), noripple(gw1)); env.close(); - IOU const CK8 = gw1["CK8"]; + IOU const cK8 = gw1["CK8"]; gw1.verifyOwners(__LINE__); Account const yui{"yui"}; @@ -1911,10 +1912,10 @@ class Check_test : public beast::unit_test::suite env.close(); uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, yui, CK8(99))); + env(check::create(gw1, yui, cK8(99))); env.close(); - env(check::cash(yui, chkId, CK8(99)), ter(tecNO_LINE_INSUF_RESERVE)); + env(check::cash(yui, chkId, cK8(99)), Ter(tecNO_LINE_INSUF_RESERVE)); env.close(); alice.verifyOwners(__LINE__); @@ -1922,8 +1923,8 @@ class Check_test : public beast::unit_test::suite // the check succeeds and creates the trust line. env(pay(env.master, yui, XRP(51))); env.close(); - env(check::cash(yui, chkId, CK8(99))); - verifyDeliveredAmount(env, CK8(99)); + env(check::cash(yui, chkId, cK8(99))); + verifyDeliveredAmount(env, cK8(99)); env.close(); BEAST_EXPECT(ownerCount(env, yui) == 1); @@ -2018,11 +2019,11 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT((*env.le(bob))[sfFlags] == 0); // Use offers to automatically create the trust line. - IOU const OF1 = gw1["OF1"]; - env(offer(gw1, XRP(98), OF1(98))); + IOU const oF1 = gw1["OF1"]; + env(offer(gw1, XRP(98), oF1(98))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, OF1.currency)) == nullptr); - env(offer(alice, OF1(98), XRP(98))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, oF1.currency)) == nullptr); + env(offer(alice, oF1(98), XRP(98))); ++alice.owners; env.close(); @@ -2035,14 +2036,14 @@ class Check_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK1 = gw1["CK1"]; + IOU const cK1 = gw1["CK1"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK1(98))); + env(check::create(gw1, alice, cK1(98))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, CK1.currency)) == nullptr); - env(check::cash(alice, chkId, CK1(98))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, cK1.currency)) == nullptr); + env(check::cash(alice, chkId, cK1(98))); ++alice.owners; - verifyDeliveredAmount(env, CK1(98)); + verifyDeliveredAmount(env, cK1(98)); env.close(); // gw1's check should be consumed. @@ -2053,7 +2054,7 @@ class Check_test : public beast::unit_test::suite // alice's automatically created trust line bumps her owner count. alice.verifyOwners(__LINE__); - cmpTrustLines(gw1, alice, OF1, CK1); + cmpTrustLines(gw1, alice, oF1, cK1); } //--------- No account root flags, check written by non-issuer --------- { @@ -2065,17 +2066,17 @@ class Check_test : public beast::unit_test::suite // So bob's offer is successfully crossed which creates the // trust line. AccountOwns const gw1{.suite = *this, .env = env, .acct = "gw1", .owners = 0}; - IOU const OF1 = gw1["OF1"]; - env(offer(alice, XRP(97), OF1(97))); + IOU const oF1 = gw1["OF1"]; + env(offer(alice, XRP(97), oF1(97))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, OF1.currency)) == nullptr); - env(offer(bob, OF1(97), XRP(97))); + BEAST_EXPECT(env.le(keylet::line(alice, bob, oF1.currency)) == nullptr); + env(offer(bob, oF1(97), XRP(97))); ++bob.owners; env.close(); // Both offers should be consumed. - env.require(balance(alice, OF1(1))); - env.require(balance(bob, OF1(97))); + env.require(Balance(alice, oF1(1))); + env.require(Balance(bob, oF1(97))); // bob now has an owner count of 1 due to the new trust line. gw1.verifyOwners(__LINE__); @@ -2088,16 +2089,16 @@ class Check_test : public beast::unit_test::suite // rippling through the currency's issuer. Since gw1 does not // have rippling enabled the check cash fails and bob does not // have a trust line created. - IOU const CK1 = gw1["CK1"]; + IOU const cK1 = gw1["CK1"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK1(97))); + env(check::create(alice, bob, cK1(97))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, CK1.currency)) == nullptr); - env(check::cash(bob, chkId, CK1(97)), ter(terNO_RIPPLE)); + BEAST_EXPECT(env.le(keylet::line(alice, bob, cK1.currency)) == nullptr); + env(check::cash(bob, chkId, cK1(97)), Ter(terNO_RIPPLE)); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, bob, OF1.currency)) != nullptr); - BEAST_EXPECT(env.le(keylet::line(gw1, bob, CK1.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, bob, oF1.currency)) != nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, bob, cK1.currency)) == nullptr); // Delete alice's check since it is no longer needed. env(check::cancel(alice, chkId)); @@ -2118,11 +2119,11 @@ class Check_test : public beast::unit_test::suite env.close(); // Use offers to automatically create the trust line. - IOU const OF2 = gw1["OF2"]; - env(offer(gw1, XRP(96), OF2(96))); + IOU const oF2 = gw1["OF2"]; + env(offer(gw1, XRP(96), oF2(96))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, OF2.currency)) == nullptr); - env(offer(alice, OF2(96), XRP(96))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, oF2.currency)) == nullptr); + env(offer(alice, oF2(96), XRP(96))); ++alice.owners; env.close(); @@ -2135,14 +2136,14 @@ class Check_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK2 = gw1["CK2"]; + IOU const cK2 = gw1["CK2"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK2(96))); + env(check::create(gw1, alice, cK2(96))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, CK2.currency)) == nullptr); - env(check::cash(alice, chkId, CK2(96))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, cK2.currency)) == nullptr); + env(check::cash(alice, chkId, cK2(96))); ++alice.owners; - verifyDeliveredAmount(env, CK2(96)); + verifyDeliveredAmount(env, cK2(96)); env.close(); // gw1's check should be consumed. @@ -2153,7 +2154,7 @@ class Check_test : public beast::unit_test::suite // alice's automatically created trust line bumps her owner count. alice.verifyOwners(__LINE__); - cmpTrustLines(gw1, alice, OF2, CK2); + cmpTrustLines(gw1, alice, oF2, cK2); } //----------- lsfDefaultRipple, check written by non-issuer ------------ { @@ -2162,11 +2163,11 @@ class Check_test : public beast::unit_test::suite // Use offers to automatically create the trust line. AccountOwns const gw1{.suite = *this, .env = env, .acct = "gw1", .owners = 0}; - IOU const OF2 = gw1["OF2"]; - env(offer(alice, XRP(95), OF2(95))); + IOU const oF2 = gw1["OF2"]; + env(offer(alice, XRP(95), oF2(95))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, OF2.currency)) == nullptr); - env(offer(bob, OF2(95), XRP(95))); + BEAST_EXPECT(env.le(keylet::line(alice, bob, oF2.currency)) == nullptr); + env(offer(bob, oF2(95), XRP(95))); ++bob.owners; env.close(); @@ -2176,14 +2177,14 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK2 = gw1["CK2"]; + IOU const cK2 = gw1["CK2"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK2(95))); + env(check::create(alice, bob, cK2(95))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, CK2.currency)) == nullptr); - env(check::cash(bob, chkId, CK2(95))); + BEAST_EXPECT(env.le(keylet::line(alice, bob, cK2.currency)) == nullptr); + env(check::cash(bob, chkId, cK2(95))); ++bob.owners; - verifyDeliveredAmount(env, CK2(95)); + verifyDeliveredAmount(env, cK2(95)); env.close(); // bob's owner count should increase due to the new trust line. @@ -2191,7 +2192,7 @@ class Check_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); bob.verifyOwners(__LINE__); - cmpTrustLines(alice, bob, OF2, CK2); + cmpTrustLines(alice, bob, oF2, cK2); } //-------------- lsfDepositAuth, check written by issuer --------------- @@ -2209,11 +2210,11 @@ class Check_test : public beast::unit_test::suite env.close(); // Use offers to automatically create the trust line. - IOU const OF3 = gw1["OF3"]; - env(offer(gw1, XRP(94), OF3(94))); + IOU const oF3 = gw1["OF3"]; + env(offer(gw1, XRP(94), oF3(94))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, OF3.currency)) == nullptr); - env(offer(alice, OF3(94), XRP(94))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, oF3.currency)) == nullptr); + env(offer(alice, oF3(94), XRP(94))); ++alice.owners; env.close(); @@ -2226,14 +2227,14 @@ class Check_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK3 = gw1["CK3"]; + IOU const cK3 = gw1["CK3"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK3(94))); + env(check::create(gw1, alice, cK3(94))); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, CK3.currency)) == nullptr); - env(check::cash(alice, chkId, CK3(94))); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, cK3.currency)) == nullptr); + env(check::cash(alice, chkId, cK3(94))); ++alice.owners; - verifyDeliveredAmount(env, CK3(94)); + verifyDeliveredAmount(env, cK3(94)); env.close(); // gw1's check should be consumed. @@ -2244,7 +2245,7 @@ class Check_test : public beast::unit_test::suite // alice's automatically created trust line bumps her owner count. alice.verifyOwners(__LINE__); - cmpTrustLines(gw1, alice, OF3, CK3); + cmpTrustLines(gw1, alice, oF3, cK3); } //------------ lsfDepositAuth, check written by non-issuer ------------- { @@ -2253,11 +2254,11 @@ class Check_test : public beast::unit_test::suite // Use offers to automatically create the trust line. AccountOwns const gw1{.suite = *this, .env = env, .acct = "gw1", .owners = 0}; - IOU const OF3 = gw1["OF3"]; - env(offer(alice, XRP(93), OF3(93))); + IOU const oF3 = gw1["OF3"]; + env(offer(alice, XRP(93), oF3(93))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, OF3.currency)) == nullptr); - env(offer(bob, OF3(93), XRP(93))); + BEAST_EXPECT(env.le(keylet::line(alice, bob, oF3.currency)) == nullptr); + env(offer(bob, oF3(93), XRP(93))); ++bob.owners; env.close(); @@ -2267,14 +2268,14 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK3 = gw1["CK3"]; + IOU const cK3 = gw1["CK3"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK3(93))); + env(check::create(alice, bob, cK3(93))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, CK3.currency)) == nullptr); - env(check::cash(bob, chkId, CK3(93))); + BEAST_EXPECT(env.le(keylet::line(alice, bob, cK3.currency)) == nullptr); + env(check::cash(bob, chkId, cK3(93))); ++bob.owners; - verifyDeliveredAmount(env, CK3(93)); + verifyDeliveredAmount(env, cK3(93)); env.close(); // bob's owner count should increase due to the new trust line. @@ -2282,7 +2283,7 @@ class Check_test : public beast::unit_test::suite alice.verifyOwners(__LINE__); bob.verifyOwners(__LINE__); - cmpTrustLines(alice, bob, OF3, CK3); + cmpTrustLines(alice, bob, oF3, cK3); } //-------------- lsfGlobalFreeze, check written by issuer -------------- @@ -2294,11 +2295,11 @@ class Check_test : public beast::unit_test::suite env.close(); // Use offers to automatically create the trust line. - IOU const OF4 = gw1["OF4"]; - env(offer(gw1, XRP(92), OF4(92)), ter(tecFROZEN)); + IOU const oF4 = gw1["OF4"]; + env(offer(gw1, XRP(92), oF4(92)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, OF4.currency)) == nullptr); - env(offer(alice, OF4(92), XRP(92)), ter(tecFROZEN)); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, oF4.currency)) == nullptr); + env(offer(alice, oF4(92), XRP(92)), Ter(tecFROZEN)); env.close(); // No one's owner count should have changed. @@ -2307,12 +2308,12 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK4 = gw1["CK4"]; + IOU const cK4 = gw1["CK4"]; uint256 const chkId{getCheckIndex(gw1, env.seq(gw1))}; - env(check::create(gw1, alice, CK4(92)), ter(tecFROZEN)); + env(check::create(gw1, alice, cK4(92)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, CK4.currency)) == nullptr); - env(check::cash(alice, chkId, CK4(92)), ter(tecNO_ENTRY)); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, cK4.currency)) == nullptr); + env(check::cash(alice, chkId, cK4(92)), Ter(tecNO_ENTRY)); env.close(); // No one's owner count should have changed. @@ -2322,8 +2323,8 @@ class Check_test : public beast::unit_test::suite // Because gw1 has set lsfGlobalFreeze, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::line(gw1, alice, OF4.currency)) == nullptr); - BEAST_EXPECT(env.le(keylet::line(gw1, alice, CK4.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, oF4.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, alice, cK4.currency)) == nullptr); } //------------ lsfGlobalFreeze, check written by non-issuer ------------ { @@ -2332,11 +2333,11 @@ class Check_test : public beast::unit_test::suite // Use offers to automatically create the trust line. AccountOwns const gw1{.suite = *this, .env = env, .acct = "gw1", .owners = 0}; - IOU const OF4 = gw1["OF4"]; - env(offer(alice, XRP(91), OF4(91)), ter(tecFROZEN)); + IOU const oF4 = gw1["OF4"]; + env(offer(alice, XRP(91), oF4(91)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, OF4.currency)) == nullptr); - env(offer(bob, OF4(91), XRP(91)), ter(tecFROZEN)); + BEAST_EXPECT(env.le(keylet::line(alice, bob, oF4.currency)) == nullptr); + env(offer(bob, oF4(91), XRP(91)), Ter(tecFROZEN)); env.close(); // No one's owner count should have changed. @@ -2345,12 +2346,12 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK4 = gw1["CK4"]; + IOU const cK4 = gw1["CK4"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK4(91)), ter(tecFROZEN)); + env(check::create(alice, bob, cK4(91)), Ter(tecFROZEN)); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, CK4.currency)) == nullptr); - env(check::cash(bob, chkId, CK4(91)), ter(tecNO_ENTRY)); + BEAST_EXPECT(env.le(keylet::line(alice, bob, cK4.currency)) == nullptr); + env(check::cash(bob, chkId, cK4(91)), Ter(tecNO_ENTRY)); env.close(); // No one's owner count should have changed. @@ -2360,8 +2361,8 @@ class Check_test : public beast::unit_test::suite // Because gw1 has set lsfGlobalFreeze, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::line(gw1, bob, OF4.currency)) == nullptr); - BEAST_EXPECT(env.le(keylet::line(gw1, bob, CK4.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, bob, oF4.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw1, bob, cK4.currency)) == nullptr); } //-------------- lsfRequireAuth, check written by issuer --------------- @@ -2380,13 +2381,13 @@ class Check_test : public beast::unit_test::suite env.close(); // Use offers to automatically create the trust line. - IOU const OF5 = gw2["OF5"]; + IOU const oF5 = gw2["OF5"]; std::uint32_t const gw2OfferSeq = {env.seq(gw2)}; - env(offer(gw2, XRP(92), OF5(92))); + env(offer(gw2, XRP(92), oF5(92))); ++gw2.owners; env.close(); - BEAST_EXPECT(env.le(keylet::line(gw2, alice, OF5.currency)) == nullptr); - env(offer(alice, OF5(92), XRP(92)), ter(tecNO_LINE)); + BEAST_EXPECT(env.le(keylet::line(gw2, alice, oF5.currency)) == nullptr); + env(offer(alice, oF5(92), XRP(92)), Ter(tecNO_LINE)); env.close(); // gw2 should still own the offer, but no one else's owner @@ -2396,19 +2397,19 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Since we don't need it any more, remove gw2's offer. - env(offer_cancel(gw2, gw2OfferSeq)); + env(offerCancel(gw2, gw2OfferSeq)); --gw2.owners; env.close(); gw2.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK5 = gw2["CK5"]; + IOU const cK5 = gw2["CK5"]; uint256 const chkId{getCheckIndex(gw2, env.seq(gw2))}; - env(check::create(gw2, alice, CK5(92))); + env(check::create(gw2, alice, cK5(92))); ++gw2.owners; env.close(); - BEAST_EXPECT(env.le(keylet::line(gw2, alice, CK5.currency)) == nullptr); - env(check::cash(alice, chkId, CK5(92)), ter(tecNO_AUTH)); + BEAST_EXPECT(env.le(keylet::line(gw2, alice, cK5.currency)) == nullptr); + env(check::cash(alice, chkId, cK5(92)), Ter(tecNO_AUTH)); env.close(); // gw2 should still own the check, but no one else's owner @@ -2419,8 +2420,8 @@ class Check_test : public beast::unit_test::suite // Because gw2 has set lsfRequireAuth, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::line(gw2, alice, OF5.currency)) == nullptr); - BEAST_EXPECT(env.le(keylet::line(gw2, alice, CK5.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw2, alice, oF5.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw2, alice, cK5.currency)) == nullptr); // Since we don't need it any more, remove gw2's check. env(check::cancel(gw2, chkId)); @@ -2435,11 +2436,11 @@ class Check_test : public beast::unit_test::suite // Use offers to automatically create the trust line. AccountOwns const gw2{.suite = *this, .env = env, .acct = "gw2", .owners = 0}; - IOU const OF5 = gw2["OF5"]; - env(offer(alice, XRP(91), OF5(91)), ter(tecUNFUNDED_OFFER)); + IOU const oF5 = gw2["OF5"]; + env(offer(alice, XRP(91), oF5(91)), Ter(tecUNFUNDED_OFFER)); env.close(); - env(offer(bob, OF5(91), XRP(91)), ter(tecNO_LINE)); - BEAST_EXPECT(env.le(keylet::line(gw2, bob, OF5.currency)) == nullptr); + env(offer(bob, oF5(91), XRP(91)), Ter(tecNO_LINE)); + BEAST_EXPECT(env.le(keylet::line(gw2, bob, oF5.currency)) == nullptr); env.close(); gw2.verifyOwners(__LINE__); @@ -2447,12 +2448,12 @@ class Check_test : public beast::unit_test::suite bob.verifyOwners(__LINE__); // Use check cashing to automatically create the trust line. - IOU const CK5 = gw2["CK5"]; + IOU const cK5 = gw2["CK5"]; uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, bob, CK5(91))); + env(check::create(alice, bob, cK5(91))); env.close(); - BEAST_EXPECT(env.le(keylet::line(alice, bob, CK5.currency)) == nullptr); - env(check::cash(bob, chkId, CK5(91)), ter(tecPATH_PARTIAL)); + BEAST_EXPECT(env.le(keylet::line(alice, bob, cK5.currency)) == nullptr); + env(check::cash(bob, chkId, cK5(91)), Ter(tecPATH_PARTIAL)); env.close(); // Delete alice's check since it is no longer needed. @@ -2466,8 +2467,8 @@ class Check_test : public beast::unit_test::suite // Because gw2 has set lsfRequireAuth, neither trust line // is created. - BEAST_EXPECT(env.le(keylet::line(gw2, bob, OF5.currency)) == nullptr); - BEAST_EXPECT(env.le(keylet::line(gw2, bob, CK5.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw2, bob, oF5.currency)) == nullptr); + BEAST_EXPECT(env.le(keylet::line(gw2, bob, cK5.currency)) == nullptr); } } @@ -2494,7 +2495,7 @@ public: run() override { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeats(sa); testTrustLineCreation(sa); } diff --git a/src/test/app/Clawback_test.cpp b/src/test/app/Clawback_test.cpp index 8efcece295..5d0ecf022d 100644 --- a/src/test/app/Clawback_test.cpp +++ b/src/test/app/Clawback_test.cpp @@ -26,11 +26,11 @@ namespace xrpl { -class Clawback_test : public beast::unit_test::suite +class Clawback_test : public beast::unit_test::Suite { template static std::string - to_string(T const& t) + toString(T const& t) { return boost::lexical_cast(t); } @@ -81,16 +81,16 @@ class Clawback_test : public beast::unit_test::suite // set asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // clear asfAllowTrustLineClawback does nothing env(fclear(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // asfNoFreeze cannot be set when asfAllowTrustLineClawback is set - env.require(nflags(alice, asfNoFreeze)); - env(fset(alice, asfNoFreeze), ter(tecNO_PERMISSION)); + env.require(Nflags(alice, asfNoFreeze)); + env(fset(alice, asfNoFreeze), Ter(tecNO_PERMISSION)); env.close(); } @@ -103,20 +103,20 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - env.require(nflags(alice, asfNoFreeze)); + env.require(Nflags(alice, asfNoFreeze)); // set asfNoFreeze env(fset(alice, asfNoFreeze)); env.close(); // NoFreeze is set - env.require(flags(alice, asfNoFreeze)); + env.require(Flags(alice, asfNoFreeze)); // asfAllowTrustLineClawback cannot be set if asfNoFreeze is set - env(fset(alice, asfAllowTrustLineClawback), ter(tecNO_PERMISSION)); + env(fset(alice, asfAllowTrustLineClawback), Ter(tecNO_PERMISSION)); env.close(); - env.require(nflags(alice, asfAllowTrustLineClawback)); + env.require(Nflags(alice, asfAllowTrustLineClawback)); } // Test that asfAllowTrustLineClawback is not allowed when owner dir is @@ -130,25 +130,25 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; - env.require(nflags(alice, asfAllowTrustLineClawback)); + auto const usd = alice["USD"]; + env.require(Nflags(alice, asfAllowTrustLineClawback)); // alice issues 10 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(10))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(10))); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 1); // alice fails to enable clawback because she has trustline with bob - env(fset(alice, asfAllowTrustLineClawback), ter(tecOWNERS)); + env(fset(alice, asfAllowTrustLineClawback), Ter(tecOWNERS)); env.close(); // bob sets trustline to default limit and pays alice back to delete // the trustline - env(trust(bob, USD(0), 0)); - env(pay(bob, alice, USD(10))); + env(trust(bob, usd(0), 0)); + env(pay(bob, alice, usd(10))); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 0); @@ -156,7 +156,7 @@ class Clawback_test : public beast::unit_test::suite // alice now is able to set asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 0); @@ -172,14 +172,14 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - env.require(nflags(alice, asfAllowTrustLineClawback)); + env.require(Nflags(alice, asfAllowTrustLineClawback)); // alice attempts to set asfAllowTrustLineClawback flag while // amendment is disabled. no error is returned, but the flag remains // to be unset. env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(nflags(alice, asfAllowTrustLineClawback)); + env.require(Nflags(alice, asfAllowTrustLineClawback)); // now enable clawback amendment env.enableFeature(featureClawback); @@ -188,7 +188,7 @@ class Clawback_test : public beast::unit_test::suite // asfAllowTrustLineClawback can be set env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); } } @@ -210,20 +210,20 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - env.require(nflags(alice, asfAllowTrustLineClawback)); + env.require(Nflags(alice, asfAllowTrustLineClawback)); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice issues 10 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(10))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(10))); env.close(); - env.require(balance(bob, alice["USD"](10))); - env.require(balance(alice, bob["USD"](-10))); + env.require(Balance(bob, alice["USD"](10))); + env.require(Balance(alice, bob["USD"](-10))); // clawback fails because amendment is disabled - env(claw(alice, bob["USD"](5)), ter(temDISABLED)); + env(claw(alice, bob["USD"](5)), Ter(temDISABLED)); env.close(); // now enable clawback amendment @@ -231,11 +231,11 @@ class Clawback_test : public beast::unit_test::suite env.close(); // clawback fails because asfAllowTrustLineClawback has not been set - env(claw(alice, bob["USD"](5)), ter(tecNO_PERMISSION)); + env(claw(alice, bob["USD"](5)), Ter(tecNO_PERMISSION)); env.close(); - env.require(balance(bob, alice["USD"](10))); - env.require(balance(alice, bob["USD"](-10))); + env.require(Balance(bob, alice["USD"](10))); + env.require(Balance(alice, bob["USD"](-10))); } // Test that Clawback tx fails for the following: @@ -258,55 +258,55 @@ class Clawback_test : public beast::unit_test::suite // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice issues 10 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(10))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(10))); env.close(); - env.require(balance(bob, alice["USD"](10))); - env.require(balance(alice, bob["USD"](-10))); + env.require(Balance(bob, alice["USD"](10))); + env.require(Balance(alice, bob["USD"](-10))); // fails due to invalid flag - env(claw(alice, bob["USD"](5)), txflags(0x00008000), ter(temINVALID_FLAG)); + env(claw(alice, bob["USD"](5)), Txflags(0x00008000), Ter(temINVALID_FLAG)); env.close(); // fails due to negative amount - env(claw(alice, bob["USD"](-5)), ter(temBAD_AMOUNT)); + env(claw(alice, bob["USD"](-5)), Ter(temBAD_AMOUNT)); env.close(); // fails due to zero amount - env(claw(alice, bob["USD"](0)), ter(temBAD_AMOUNT)); + env(claw(alice, bob["USD"](0)), Ter(temBAD_AMOUNT)); env.close(); // fails because amount is in XRP - env(claw(alice, XRP(10)), ter(temBAD_AMOUNT)); + env(claw(alice, XRP(10)), Ter(temBAD_AMOUNT)); env.close(); // fails when `issuer` field in `amount` is not token holder // NOTE: we are using the `issuer` field for the token holder - env(claw(alice, alice["USD"](5)), ter(temBAD_AMOUNT)); + env(claw(alice, alice["USD"](5)), Ter(temBAD_AMOUNT)); env.close(); // bob pays alice back, trustline has a balance of 0 - env(pay(bob, alice, USD(10))); + env(pay(bob, alice, usd(10))); env.close(); // bob still owns the trustline that has 0 balance BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 1); - env.require(balance(bob, alice["USD"](0))); - env.require(balance(alice, bob["USD"](0))); + env.require(Balance(bob, alice["USD"](0))); + env.require(Balance(alice, bob["USD"](0))); // clawback fails because because balance is 0 - env(claw(alice, bob["USD"](5)), ter(tecINSUFFICIENT_FUNDS)); + env(claw(alice, bob["USD"](5)), Ter(tecINSUFFICIENT_FUNDS)); env.close(); // set the limit to default, which should delete the trustline - env(trust(bob, USD(0), 0)); + env(trust(bob, usd(0), 0)); env.close(); // bob no longer owns the trustline @@ -314,7 +314,7 @@ class Clawback_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, bob) == 0); // clawback fails because trustline does not exist - env(claw(alice, bob["USD"](5)), ter(tecNO_LINE)); + env(claw(alice, bob["USD"](5)), Ter(tecNO_LINE)); env.close(); } } @@ -341,10 +341,10 @@ class Clawback_test : public beast::unit_test::suite // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // bob, the token holder, does not exist - env(claw(alice, bob["USD"](5)), ter(terNO_ACCOUNT)); + env(claw(alice, bob["USD"](5)), Ter(terNO_ACCOUNT)); env.close(); } @@ -360,29 +360,29 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob, cindy); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // cindy sets asfAllowTrustLineClawback env(fset(cindy, asfAllowTrustLineClawback)); env.close(); - env.require(flags(cindy, asfAllowTrustLineClawback)); + env.require(Flags(cindy, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(1000))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(1000))); env.close(); - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // cindy tries to claw from bob, and fails because trustline does // not exist - env(claw(cindy, bob["USD"](200)), ter(tecNO_LINE)); + env(claw(cindy, bob["USD"](200)), Ter(tecNO_LINE)); env.close(); } @@ -402,18 +402,18 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; - auto const CAD = bob["CAD"]; + auto const usd = alice["USD"]; + auto const cad = bob["CAD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // bob sets asfAllowTrustLineClawback env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowTrustLineClawback)); + env.require(Flags(bob, asfAllowTrustLineClawback)); // alice issues 10 USD to bob. // bob then attempts to submit a clawback tx to claw USD from alice. @@ -422,16 +422,16 @@ class Clawback_test : public beast::unit_test::suite { // bob creates a trustline with alice, and alice sends 10 USD to // bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(10))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(10))); env.close(); - env.require(balance(bob, alice["USD"](10))); - env.require(balance(alice, bob["USD"](-10))); + env.require(Balance(bob, alice["USD"](10))); + env.require(Balance(alice, bob["USD"](-10))); // bob cannot claw back USD from alice because he's not the // issuer - env(claw(bob, alice["USD"](5)), ter(tecNO_PERMISSION)); + env(claw(bob, alice["USD"](5)), Ter(tecNO_PERMISSION)); env.close(); } @@ -442,16 +442,16 @@ class Clawback_test : public beast::unit_test::suite { // alice creates a trustline with bob, and bob sends 10 CAD to // alice - env.trust(CAD(1000), alice); - env(pay(bob, alice, CAD(10))); + env.trust(cad(1000), alice); + env(pay(bob, alice, cad(10))); env.close(); - env.require(balance(bob, alice["CAD"](-10))); - env.require(balance(alice, bob["CAD"](10))); + env.require(Balance(bob, alice["CAD"](-10))); + env.require(Balance(alice, bob["CAD"](10))); // alice cannot claw back CAD from bob because she's not the // issuer - env(claw(alice, bob["CAD"](5)), ter(tecNO_PERMISSION)); + env(claw(alice, bob["CAD"](5)), Ter(tecNO_PERMISSION)); env.close(); } } @@ -472,36 +472,36 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(1000))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(1000))); env.close(); - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // alice claws back 200 USD from bob env(claw(alice, bob["USD"](200))); env.close(); // bob should have 800 USD left - env.require(balance(bob, alice["USD"](800))); - env.require(balance(alice, bob["USD"](-800))); + env.require(Balance(bob, alice["USD"](800))); + env.require(Balance(alice, bob["USD"](-800))); // alice claws back 800 USD from bob again env(claw(alice, bob["USD"](800))); env.close(); // trustline has a balance of 0 - env.require(balance(bob, alice["USD"](0))); - env.require(balance(alice, bob["USD"](0))); + env.require(Balance(bob, alice["USD"](0))); + env.require(Balance(alice, bob["USD"](0))); } void @@ -527,12 +527,12 @@ class Clawback_test : public beast::unit_test::suite // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // bob sets asfAllowTrustLineClawback env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowTrustLineClawback)); + env.require(Flags(bob, asfAllowTrustLineClawback)); // alice sends 1000 USD to cindy env.trust(alice["USD"](1000), cindy); @@ -549,24 +549,24 @@ class Clawback_test : public beast::unit_test::suite env.close(); // cindy has 800 USD left in alice's trustline after clawed by alice - env.require(balance(cindy, alice["USD"](800))); - env.require(balance(alice, cindy["USD"](-800))); + env.require(Balance(cindy, alice["USD"](800))); + env.require(Balance(alice, cindy["USD"](-800))); // cindy still has 1000 USD in bob's trustline - env.require(balance(cindy, bob["USD"](1000))); - env.require(balance(bob, cindy["USD"](-1000))); + env.require(Balance(cindy, bob["USD"](1000))); + env.require(Balance(bob, cindy["USD"](-1000))); // bob claws back 600 USD from cindy env(claw(bob, cindy["USD"](600))); env.close(); // cindy has 400 USD left in bob's trustline after clawed by bob - env.require(balance(cindy, bob["USD"](400))); - env.require(balance(bob, cindy["USD"](-400))); + env.require(Balance(cindy, bob["USD"](400))); + env.require(Balance(bob, cindy["USD"](-400))); // cindy still has 800 USD in alice's trustline - env.require(balance(cindy, alice["USD"](800))); - env.require(balance(alice, cindy["USD"](-800))); + env.require(Balance(cindy, alice["USD"](800))); + env.require(Balance(alice, cindy["USD"](-800))); } // alice issues USD to both bob and cindy. @@ -582,52 +582,52 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob, cindy); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice sends 600 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(600))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(600))); env.close(); - env.require(balance(alice, bob["USD"](-600))); - env.require(balance(bob, alice["USD"](600))); + env.require(Balance(alice, bob["USD"](-600))); + env.require(Balance(bob, alice["USD"](600))); // alice sends 1000 USD to cindy - env.trust(USD(1000), cindy); - env(pay(alice, cindy, USD(1000))); + env.trust(usd(1000), cindy); + env(pay(alice, cindy, usd(1000))); env.close(); - env.require(balance(alice, cindy["USD"](-1000))); - env.require(balance(cindy, alice["USD"](1000))); + env.require(Balance(alice, cindy["USD"](-1000))); + env.require(Balance(cindy, alice["USD"](1000))); // alice claws back 500 USD from bob env(claw(alice, bob["USD"](500))); env.close(); // bob's balance is reduced - env.require(balance(alice, bob["USD"](-100))); - env.require(balance(bob, alice["USD"](100))); + env.require(Balance(alice, bob["USD"](-100))); + env.require(Balance(bob, alice["USD"](100))); // cindy's balance is unchanged - env.require(balance(alice, cindy["USD"](-1000))); - env.require(balance(cindy, alice["USD"](1000))); + env.require(Balance(alice, cindy["USD"](-1000))); + env.require(Balance(cindy, alice["USD"](1000))); // alice claws back 300 USD from cindy env(claw(alice, cindy["USD"](300))); env.close(); // bob's balance is unchanged - env.require(balance(alice, bob["USD"](-100))); - env.require(balance(bob, alice["USD"](100))); + env.require(Balance(alice, bob["USD"](-100))); + env.require(Balance(bob, alice["USD"](100))); // cindy's balance is reduced - env.require(balance(alice, cindy["USD"](-700))); - env.require(balance(cindy, alice["USD"](700))); + env.require(Balance(alice, cindy["USD"](-700))); + env.require(Balance(cindy, alice["USD"](700))); } } @@ -654,12 +654,12 @@ class Clawback_test : public beast::unit_test::suite // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // bob sets asfAllowTrustLineClawback env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowTrustLineClawback)); + env.require(Flags(bob, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(alice["USD"](1000), bob); @@ -670,8 +670,8 @@ class Clawback_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, bob) == 1); // bob is the holder, and alice is the issuer - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // bob issues 1500 USD to alice env.trust(bob["USD"](1500), alice); @@ -683,15 +683,15 @@ class Clawback_test : public beast::unit_test::suite // bob has negative 500 USD because bob issued 500 USD more than alice // bob can now been seen as the issuer, while alice is the holder - env.require(balance(bob, alice["USD"](-500))); - env.require(balance(alice, bob["USD"](500))); + env.require(Balance(bob, alice["USD"](-500))); + env.require(Balance(alice, bob["USD"](500))); // At this point, both alice and bob are the issuers of USD // and can send USD to each other through one trustline // alice fails to clawback. Even though she is also an issuer, // the trustline balance is positive from her perspective - env(claw(alice, bob["USD"](200)), ter(tecNO_PERMISSION)); + env(claw(alice, bob["USD"](200)), Ter(tecNO_PERMISSION)); env.close(); // bob is able to successfully clawback from alice because @@ -699,8 +699,8 @@ class Clawback_test : public beast::unit_test::suite env(claw(bob, alice["USD"](200))); env.close(); - env.require(balance(bob, alice["USD"](-300))); - env.require(balance(alice, bob["USD"](300))); + env.require(Balance(bob, alice["USD"](-300))); + env.require(Balance(alice, bob["USD"](300))); // alice pays bob 1000 USD env(pay(alice, bob, alice["USD"](1000))); @@ -708,19 +708,19 @@ class Clawback_test : public beast::unit_test::suite // bob's balance becomes positive from his perspective because // alice issued more USD than the balance - env.require(balance(bob, alice["USD"](700))); - env.require(balance(alice, bob["USD"](-700))); + env.require(Balance(bob, alice["USD"](700))); + env.require(Balance(alice, bob["USD"](-700))); // bob is now the holder and fails to clawback - env(claw(bob, alice["USD"](200)), ter(tecNO_PERMISSION)); + env(claw(bob, alice["USD"](200)), Ter(tecNO_PERMISSION)); env.close(); // alice successfully claws back env(claw(alice, bob["USD"](200))); env.close(); - env.require(balance(bob, alice["USD"](500))); - env.require(balance(alice, bob["USD"](-500))); + env.require(Balance(bob, alice["USD"](500))); + env.require(Balance(alice, bob["USD"](-500))); } void @@ -738,26 +738,26 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(1000))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(1000))); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 1); - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // set limit to default, - env(trust(bob, USD(0), 0)); + env(trust(bob, usd(0), 0)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -788,20 +788,20 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(1000))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(1000))); env.close(); - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // freeze trustline env(trust(alice, bob["USD"](0), tfSetFreeze)); @@ -812,11 +812,11 @@ class Clawback_test : public beast::unit_test::suite env.close(); // bob should have 800 USD left - env.require(balance(bob, alice["USD"](800))); - env.require(balance(alice, bob["USD"](-800))); + env.require(Balance(bob, alice["USD"](800))); + env.require(Balance(alice, bob["USD"](-800))); // trustline remains frozen - BEAST_EXPECT(getLineFreezeFlag(env, alice, bob, USD.currency)); + BEAST_EXPECT(getLineFreezeFlag(env, alice, bob, usd.currency)); } void @@ -834,20 +834,20 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(1000))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(1000))); env.close(); - env.require(balance(bob, alice["USD"](1000))); - env.require(balance(alice, bob["USD"](-1000))); + env.require(Balance(bob, alice["USD"](1000))); + env.require(Balance(alice, bob["USD"](-1000))); // alice tries to claw back 2000 USD env(claw(alice, bob["USD"](2000))); @@ -855,8 +855,8 @@ class Clawback_test : public beast::unit_test::suite // check alice and bob's balance. // alice was only able to claw back 1000 USD at maximum - env.require(balance(bob, alice["USD"](0))); - env.require(balance(alice, bob["USD"](0))); + env.require(Balance(bob, alice["USD"](0))); + env.require(Balance(alice, bob["USD"](0))); // bob still owns the trustline because trustline is not in default // state @@ -864,7 +864,7 @@ class Clawback_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, bob) == 1); // set limit to default, - env(trust(bob, USD(0), 0)); + env(trust(bob, usd(0), 0)); env.close(); // verify that bob's trustline was deleted @@ -886,20 +886,20 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; // alice sets asfAllowTrustLineClawback env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // alice issues 100 USD to bob - env.trust(USD(1000), bob); - env(pay(alice, bob, USD(100))); + env.trust(usd(1000), bob); + env(pay(alice, bob, usd(100))); env.close(); - env.require(balance(bob, alice["USD"](100))); - env.require(balance(alice, bob["USD"](-100))); + env.require(Balance(bob, alice["USD"](100))); + env.require(Balance(alice, bob["USD"](-100))); // alice creates 10 tickets std::uint32_t ticketCnt = 10; @@ -913,7 +913,7 @@ class Clawback_test : public beast::unit_test::suite while (ticketCnt > 0) { // alice claws back 5 USD using a ticket - env(claw(alice, bob["USD"](5)), ticket::use(aliceTicketSeq++)); + env(claw(alice, bob["USD"](5)), ticket::Use(aliceTicketSeq++)); env.close(); ticketCnt--; @@ -922,8 +922,8 @@ class Clawback_test : public beast::unit_test::suite } // alice clawed back 50 USD total, trustline has 50 USD remaining - env.require(balance(bob, alice["USD"](50))); - env.require(balance(alice, bob["USD"](-50))); + env.require(Balance(bob, alice["USD"](50))); + env.require(Balance(alice, bob["USD"](-50))); // Verify that the account sequence numbers did not advance. BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -949,7 +949,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testWithFeats(all - featureMPTokensV1); testWithFeats(all); diff --git a/src/test/app/Credentials_test.cpp b/src/test/app/Credentials_test.cpp index 3c9a658aca..fa180d0603 100644 --- a/src/test/app/Credentials_test.cpp +++ b/src/test/app/Credentials_test.cpp @@ -34,7 +34,7 @@ namespace xrpl::test { -struct Credentials_test : public beast::unit_test::suite +struct Credentials_test : public beast::unit_test::Suite { void testSuccessful(FeatureBitset features) @@ -59,7 +59,7 @@ struct Credentials_test : public beast::unit_test::suite env.close(); // Test Create credentials - env(credentials::create(subject, issuer, credType), credentials::uri(uri)); + env(credentials::create(subject, issuer, credType), credentials::Uri(uri)); env.close(); { auto const sleCred = env.le(credKey); @@ -127,7 +127,7 @@ struct Credentials_test : public beast::unit_test::suite auto const credKey = credentials::keylet(issuer, issuer, credType); - env(credentials::create(issuer, issuer, credType), credentials::uri(uri)); + env(credentials::create(issuer, issuer, credType), credentials::Uri(uri)); env.close(); { auto const sleCred = env.le(credKey); @@ -202,7 +202,7 @@ struct Credentials_test : public beast::unit_test::suite for (int i = 0; i < delta; ++i) env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(issuer, other), fee(acctDelFee)); + env(acctdelete(issuer, other), Fee(acctDelFee)); env.close(); } @@ -239,7 +239,7 @@ struct Credentials_test : public beast::unit_test::suite for (int i = 0; i < delta; ++i) env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(issuer, other), fee(acctDelFee)); + env(acctdelete(issuer, other), Fee(acctDelFee)); env.close(); } @@ -274,7 +274,7 @@ struct Credentials_test : public beast::unit_test::suite for (int i = 0; i < delta; ++i) env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(subject, other), fee(acctDelFee)); + env(acctdelete(subject, other), Fee(acctDelFee)); env.close(); } @@ -311,7 +311,7 @@ struct Credentials_test : public beast::unit_test::suite for (int i = 0; i < delta; ++i) env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(subject, other), fee(acctDelFee)); + env(acctdelete(subject, other), Fee(acctDelFee)); env.close(); } @@ -430,43 +430,43 @@ struct Credentials_test : public beast::unit_test::suite testcase("Credentials fail, no subject param."); auto jv = credentials::create(subject, issuer, credType); jv.removeMember(jss::Subject); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { auto jv = credentials::create(subject, issuer, credType); jv[jss::Subject] = to_string(xrpAccount()); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { testcase("Credentials fail, no credentialType param."); auto jv = credentials::create(subject, issuer, credType); jv.removeMember(sfCredentialType.jsonName); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { testcase("Credentials fail, empty credentialType param."); auto jv = credentials::create(subject, issuer, ""); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { testcase( "Credentials fail, credentialType length > " "maxCredentialTypeLength."); - constexpr std::string_view longCredType = + constexpr std::string_view kLONG_CRED_TYPE = "abcdefghijklmnopqrstuvwxyz01234567890qwertyuiop[]" "asdfghjkl;'zxcvbnm8237tr28weufwldebvfv8734t07p"; - static_assert(longCredType.size() > maxCredentialTypeLength); - auto jv = credentials::create(subject, issuer, longCredType); - env(jv, ter(temMALFORMED)); + static_assert(kLONG_CRED_TYPE.size() > kMAX_CREDENTIAL_TYPE_LENGTH); + auto jv = credentials::create(subject, issuer, kLONG_CRED_TYPE); + env(jv, Ter(temMALFORMED)); } { testcase("Credentials fail, URI length > 256."); - constexpr std::string_view longURI = + constexpr std::string_view kLONG_URI = "abcdefghijklmnopqrstuvwxyz01234567890qwertyuiop[]" "asdfghjkl;'zxcvbnm8237tr28weufwldebvfv8734t07p " "9hfup;wDJFBVSD8f72 " @@ -475,17 +475,17 @@ struct Credentials_test : public beast::unit_test::suite "vujhgWQIE7F6WEUYFGWUKEYFVQW87FGWOEFWEFUYWVEF8723GFWEFB" "WULE" "fv28o37gfwEFB3872TFO8GSDSDVD"; - static_assert(longURI.size() > maxCredentialURILength); + static_assert(kLONG_URI.size() > kMAX_CREDENTIAL_URI_LENGTH); env(credentials::create(subject, issuer, credType), - credentials::uri(longURI), - ter(temMALFORMED)); + credentials::Uri(kLONG_URI), + Ter(temMALFORMED)); } { testcase("Credentials fail, URI empty."); env(credentials::create(subject, issuer, credType), - credentials::uri(""), - ter(temMALFORMED)); + credentials::Uri(""), + Ter(temMALFORMED)); } { @@ -495,7 +495,7 @@ struct Credentials_test : public beast::unit_test::suite uint32_t const t = env.current()->header().parentCloseTime.time_since_epoch().count() - 1; jv[sfExpiration.jsonName] = t; - env(jv, ter(tecEXPIRED)); + env(jv, Ter(tecEXPIRED)); } { @@ -503,7 +503,7 @@ struct Credentials_test : public beast::unit_test::suite auto jv = credentials::create(subject, issuer, credType); jv[jss::Fee] = -1; - env(jv, ter(temBAD_FEE)); + env(jv, Ter(temBAD_FEE)); } { @@ -511,7 +511,7 @@ struct Credentials_test : public beast::unit_test::suite auto const jv = credentials::create(subject, issuer, credType); env(jv); env.close(); - env(jv, ter(tecDUPLICATE)); + env(jv, Ter(tecDUPLICATE)); env.close(); // check credential still present @@ -544,9 +544,9 @@ struct Credentials_test : public beast::unit_test::suite // NOLINTNEXTLINE(readability-suspicious-call-argument) auto const jv = credentials::create(issuer, subject, credType); - env(jv, ter(tecDIR_FULL)); + env(jv, Ter(tecDIR_FULL)); // Free one directory entry by using a ticket - env(noop(issuer), ticket::use(issuerSeq + 40)); + env(noop(issuer), ticket::Use(issuerSeq + 40)); // Fill subject directory env(ticket::create(subject, 63)); @@ -556,7 +556,7 @@ struct Credentials_test : public beast::unit_test::suite keylet::ownerDir(subject.id()), directory::adjustOwnerNode); BEAST_EXPECT(res2); - env(jv, ter(tecDIR_FULL)); + env(jv, Ter(tecDIR_FULL)); // End test env.close(); @@ -573,7 +573,7 @@ struct Credentials_test : public beast::unit_test::suite { testcase("Credentials fail, subject doesn't exist."); auto const jv = credentials::create(subject, issuer, credType); - env(jv, ter(tecNO_TARGET)); + env(jv, Ter(tecNO_TARGET)); } } @@ -588,7 +588,7 @@ struct Credentials_test : public beast::unit_test::suite testcase("Credentials fail, not enough reserve."); { auto const jv = credentials::create(subject, issuer, credType); - env(jv, ter(tecINSUFFICIENT_RESERVE)); + env(jv, Ter(tecINSUFFICIENT_RESERVE)); env.close(); } } @@ -611,7 +611,7 @@ struct Credentials_test : public beast::unit_test::suite { testcase("CredentialsAccept fail, Credential doesn't exist."); - env(credentials::accept(subject, issuer, credType), ter(tecNO_ENTRY)); + env(credentials::accept(subject, issuer, credType), Ter(tecNO_ENTRY)); env.close(); } @@ -619,14 +619,14 @@ struct Credentials_test : public beast::unit_test::suite testcase("CredentialsAccept fail, invalid Issuer account."); auto jv = credentials::accept(subject, issuer, credType); jv[jss::Issuer] = to_string(xrpAccount()); - env(jv, ter(temINVALID_ACCOUNT_ID)); + env(jv, Ter(temINVALID_ACCOUNT_ID)); env.close(); } { testcase("CredentialsAccept fail, invalid credentialType param."); auto jv = credentials::accept(subject, issuer, ""); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } } @@ -642,7 +642,7 @@ struct Credentials_test : public beast::unit_test::suite env(credentials::create(subject, issuer, credType)); env.close(); - env(credentials::accept(subject, issuer, credType), ter(tecINSUFFICIENT_RESERVE)); + env(credentials::accept(subject, issuer, credType), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // check credential still present @@ -674,12 +674,12 @@ struct Credentials_test : public beast::unit_test::suite testcase("CredentialsAccept fail, invalid fee."); auto jv = credentials::accept(subject, issuer, credType); jv[jss::Fee] = -1; - env(jv, ter(temBAD_FEE)); + env(jv, Ter(temBAD_FEE)); testcase("CredentialsAccept fail, lsfAccepted already set."); env(credentials::accept(subject, issuer, credType)); env.close(); - env(credentials::accept(subject, issuer, credType), ter(tecDUPLICATE)); + env(credentials::accept(subject, issuer, credType), Ter(tecDUPLICATE)); env.close(); // check credential still present @@ -708,7 +708,7 @@ struct Credentials_test : public beast::unit_test::suite env.close(); // credentials are expired now - env(credentials::accept(subject, issuer, credType2), ter(tecEXPIRED)); + env(credentials::accept(subject, issuer, credType2), Ter(tecEXPIRED)); env.close(); // check that expired credentials were deleted @@ -741,11 +741,11 @@ struct Credentials_test : public beast::unit_test::suite for (int i = 0; i < delta; ++i) env.close(); auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(issuer, other), fee(acctDelFee)); + env(acctdelete(issuer, other), Fee(acctDelFee)); // can't accept - no issuer account jv = credentials::accept(subject, issuer, credType); - env(jv, ter(tecNO_ISSUER)); + env(jv, Ter(tecNO_ISSUER)); env.close(); // check that expired credentials were deleted @@ -777,7 +777,7 @@ struct Credentials_test : public beast::unit_test::suite { testcase("CredentialsDelete fail, no Credentials."); - env(credentials::deleteCred(subject, subject, issuer, credType), ter(tecNO_ENTRY)); + env(credentials::deleteCred(subject, subject, issuer, credType), Ter(tecNO_ENTRY)); env.close(); } @@ -785,7 +785,7 @@ struct Credentials_test : public beast::unit_test::suite testcase("CredentialsDelete fail, invalid Subject account."); auto jv = credentials::deleteCred(subject, subject, issuer, credType); jv[jss::Subject] = to_string(xrpAccount()); - env(jv, ter(temINVALID_ACCOUNT_ID)); + env(jv, Ter(temINVALID_ACCOUNT_ID)); env.close(); } @@ -793,14 +793,14 @@ struct Credentials_test : public beast::unit_test::suite testcase("CredentialsDelete fail, invalid Issuer account."); auto jv = credentials::deleteCred(subject, subject, issuer, credType); jv[jss::Issuer] = to_string(xrpAccount()); - env(jv, ter(temINVALID_ACCOUNT_ID)); + env(jv, Ter(temINVALID_ACCOUNT_ID)); env.close(); } { testcase("CredentialsDelete fail, invalid credentialType param."); auto jv = credentials::deleteCred(subject, subject, issuer, ""); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { @@ -811,7 +811,7 @@ struct Credentials_test : public beast::unit_test::suite // Other account can't delete credentials without expiration env(credentials::deleteCred(other, subject, issuer, credType2), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); // check credential still present @@ -841,7 +841,7 @@ struct Credentials_test : public beast::unit_test::suite // Other account can't delete credentials that not expired env(credentials::deleteCred(other, subject, issuer, credType), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); // check credential still present @@ -864,7 +864,7 @@ struct Credentials_test : public beast::unit_test::suite auto jv = credentials::deleteCred(subject, subject, issuer, credType); jv.removeMember(jss::Subject); jv.removeMember(jss::Issuer); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); env.close(); } @@ -873,14 +873,14 @@ struct Credentials_test : public beast::unit_test::suite auto jv = credentials::deleteCred(subject, subject, issuer, credType); jv[jss::Fee] = -1; - env(jv, ter(temBAD_FEE)); + env(jv, Ter(temBAD_FEE)); env.close(); } { testcase("deleteSLE fail, bad SLE."); auto view = - std::make_shared(env.current().get(), ApplyFlags::tapNONE); + std::make_shared(env.current().get(), ApplyFlags::TapNone); auto ter = xrpl::credentials::deleteSLE(*view, {}, env.journal); BEAST_EXPECT(ter == tecNO_ENTRY); } @@ -905,9 +905,9 @@ struct Credentials_test : public beast::unit_test::suite { testcase("Credentials fail, Feature is not enabled."); - env(credentials::create(subject, issuer, credType), ter(temDISABLED)); - env(credentials::accept(subject, issuer, credType), ter(temDISABLED)); - env(credentials::deleteCred(subject, subject, issuer, credType), ter(temDISABLED)); + env(credentials::create(subject, issuer, credType), Ter(temDISABLED)); + env(credentials::accept(subject, issuer, credType), Ter(temDISABLED)); + env(credentials::deleteCred(subject, subject, issuer, credType), Ter(temDISABLED)); } } } @@ -938,7 +938,7 @@ struct Credentials_test : public beast::unit_test::suite std::string txHash0, txHash1; { - Json::Value params; + json::Value params; params[jss::account] = subject.human(); auto const jv = env.rpc("json", "account_tx", to_string(params))[jss::result]; @@ -952,7 +952,7 @@ struct Credentials_test : public beast::unit_test::suite } { - Json::Value params; + json::Value params; params[jss::account] = issuer.human(); auto const jv = env.rpc("json", "account_tx", to_string(params))[jss::result]; @@ -969,7 +969,7 @@ struct Credentials_test : public beast::unit_test::suite testcase("account_objects"); std::string objectIdx; { - Json::Value params; + json::Value params; params[jss::account] = subject.human(); auto jv = env.rpc("json", "account_objects", to_string(params))[jss::result]; @@ -981,7 +981,7 @@ struct Credentials_test : public beast::unit_test::suite } { - Json::Value params; + json::Value params; params[jss::account] = issuer.human(); auto jv = env.rpc("json", "account_objects", to_string(params))[jss::result]; @@ -1014,15 +1014,15 @@ struct Credentials_test : public beast::unit_test::suite env.close(); { - ter const expected(enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS)); + Ter const expected(enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS)); env(credentials::create(subject, issuer, credType), - txflags(tfTransferable), + Txflags(tfTransferable), expected); env(credentials::accept(subject, issuer, credType), - txflags(tfSellNFToken), + Txflags(tfSellNFToken), expected); env(credentials::deleteCred(subject, subject, issuer, credType), - txflags(tfPassive), + Txflags(tfPassive), expected); } } @@ -1032,7 +1032,7 @@ struct Credentials_test : public beast::unit_test::suite run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testSuccessful(all); testCredentialsDelete(all); testCreateFailed(all); diff --git a/src/test/app/CrossingLimitsMPT_test.cpp b/src/test/app/CrossingLimitsMPT_test.cpp index 8efacaae21..e9a9861a3a 100644 --- a/src/test/app/CrossingLimitsMPT_test.cpp +++ b/src/test/app/CrossingLimitsMPT_test.cpp @@ -18,7 +18,7 @@ namespace xrpl::test { -class CrossingLimitsMPT_test : public beast::unit_test::suite +class CrossingLimitsMPT_test : public beast::unit_test::Suite { public: void @@ -32,32 +32,32 @@ public: auto const gw = Account("gateway"); env.fund(XRP(100'000'000), gw, "alice", "bob", "carol", "dan"); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"bob", "dan"}, .maxAmt = 2}); - env(pay(gw, "bob", USD(1))); - env(pay(gw, "dan", USD(1))); - n_offers(env, 2'000, "bob", XRP(1), USD(1)); - n_offers(env, 1, "dan", XRP(1), USD(1)); + env(pay(gw, "bob", usd(1))); + env(pay(gw, "dan", usd(1))); + nOffers(env, 2'000, "bob", XRP(1), usd(1)); + nOffers(env, 1, "dan", XRP(1), usd(1)); // Alice offers to buy 1000 XRP for 1000 USD. She takes Bob's first // offer, removes 999 more as unfunded, then hits the step limit. - env(offer("alice", USD(1'000), XRP(1'000))); - env.require(balance("alice", USD(1))); - env.require(owners("alice", 2)); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1'001)); - env.require(balance("dan", USD(1))); - env.require(owners("dan", 2)); + env(offer("alice", usd(1'000), XRP(1'000))); + env.require(Balance("alice", usd(1))); + env.require(Owners("alice", 2)); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1'001)); + env.require(Balance("dan", usd(1))); + env.require(Owners("dan", 2)); // Carol offers to buy 1000 XRP for 1000 USD. She removes Bob's next // 1000 offers as unfunded and hits the step limit. - env(offer("carol", USD(1'000), XRP(1'000))); - env.require(balance("carol", USD(none))); - env.require(owners("carol", 1)); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1)); - env.require(balance("dan", USD(1))); - env.require(owners("dan", 2)); + env(offer("carol", usd(1'000), XRP(1'000))); + env.require(Balance("carol", usd(kNONE))); + env.require(Owners("carol", 1)); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1)); + env.require(Balance("dan", usd(1))); + env.require(Owners("dan", 2)); } void @@ -74,27 +74,27 @@ public: env.fund(XRP(100'000'000), gw, "alice", "bob", "carol"); int const bobsOfferCount = maxConsumed + 150; - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"bob"}, .maxAmt = bobsOfferCount}); - env(pay(gw, "bob", USD(bobsOfferCount))); + env(pay(gw, "bob", usd(bobsOfferCount))); env.close(); - n_offers(env, bobsOfferCount, "bob", XRP(1), USD(1)); + nOffers(env, bobsOfferCount, "bob", XRP(1), usd(1)); // Alice offers to buy Bob's offers. However, she hits the offer // crossing limit, so she can't buy them all at once. - env(offer("alice", USD(bobsOfferCount), XRP(bobsOfferCount))); + env(offer("alice", usd(bobsOfferCount), XRP(bobsOfferCount))); env.close(); - env.require(balance("alice", USD(maxConsumed))); - env.require(balance("bob", USD(150))); - env.require(owners("bob", 150 + 1)); + env.require(Balance("alice", usd(maxConsumed))); + env.require(Balance("bob", usd(150))); + env.require(Owners("bob", 150 + 1)); // Carol offers to buy 1000 XRP for 1000 USD. She takes Bob's // remaining 150 offers without hitting a limit. - env(offer("carol", USD(1'000), XRP(1'000))); + env(offer("carol", usd(1'000), XRP(1'000))); env.close(); - env.require(balance("carol", USD(150))); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1)); + env.require(Balance("carol", usd(150))); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1)); } void @@ -112,47 +112,47 @@ public: int const maxConsumed = 1'000; int const evitaOfferCount{maxConsumed + 49}; - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {"bob", "alice", "carol", "evita"}, .maxAmt = 2'000 + evitaOfferCount + 1}); - env(pay(gw, "alice", USD(1000))); - env(pay(gw, "carol", USD(1))); - env(pay(gw, "evita", USD(evitaOfferCount + 1))); + env(pay(gw, "alice", usd(1000))); + env(pay(gw, "carol", usd(1))); + env(pay(gw, "evita", usd(evitaOfferCount + 1))); // Give carol an extra 150 (unfunded) offers when we're using Taker // to accommodate that difference. int const carolOfferCount{700}; - n_offers(env, 400, "alice", XRP(1), USD(1)); - n_offers(env, carolOfferCount, "carol", XRP(1), USD(1)); - n_offers(env, evitaOfferCount, "evita", XRP(1), USD(1)); + nOffers(env, 400, "alice", XRP(1), usd(1)); + nOffers(env, carolOfferCount, "carol", XRP(1), usd(1)); + nOffers(env, evitaOfferCount, "evita", XRP(1), usd(1)); // Bob offers to buy 1000 XRP for 1000 USD. He takes all 400 USD from // Alice's offers, 1 USD from Carol's and then removes 599 of Carol's // offers as unfunded, before hitting the step limit. - env(offer("bob", USD(1000), XRP(1000))); - env.require(balance("bob", USD(401))); - env.require(balance("alice", USD(600))); - env.require(owners("alice", 1)); - env.require(balance("carol", USD(0))); - env.require(owners("carol", carolOfferCount - 599)); - env.require(balance("evita", USD(evitaOfferCount + 1))); - env.require(owners("evita", evitaOfferCount + 1)); + env(offer("bob", usd(1000), XRP(1000))); + env.require(Balance("bob", usd(401))); + env.require(Balance("alice", usd(600))); + env.require(Owners("alice", 1)); + env.require(Balance("carol", usd(0))); + env.require(Owners("carol", carolOfferCount - 599)); + env.require(Balance("evita", usd(evitaOfferCount + 1))); + env.require(Owners("evita", evitaOfferCount + 1)); // Dan offers to buy maxConsumed + 50 XRP USD. He removes all of // Carol's remaining offers as unfunded, then takes // (maxConsumed - 100) USD from Evita's, hitting the crossing limit. - env(offer("dan", USD(maxConsumed + 50), XRP(maxConsumed + 50))); - env.require(balance("dan", USD(maxConsumed - 100))); - env.require(owners("dan", 2)); - env.require(balance("alice", USD(600))); - env.require(owners("alice", 1)); - env.require(balance("carol", USD(0))); - env.require(owners("carol", 1)); - env.require(balance("evita", USD(150))); - env.require(owners("evita", 150)); + env(offer("dan", usd(maxConsumed + 50), XRP(maxConsumed + 50))); + env.require(Balance("dan", usd(maxConsumed - 100))); + env.require(Owners("dan", 2)); + env.require(Balance("alice", usd(600))); + env.require(Owners("alice", 1)); + env.require(Balance("carol", usd(0))); + env.require(Owners("carol", 1)); + env.require(Balance("evita", usd(150))); + env.require(Owners("evita", 150)); } void @@ -193,31 +193,31 @@ public: env.fund(XRP(100'000'000), gw, alice, bob, carol); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol}, - .limit = maxMPTokenAmount}); - auto const EUR = issue2( + .limit = kMAX_MP_TOKEN_AMOUNT}); + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {bob}, - .limit = maxMPTokenAmount}); + .limit = kMAX_MP_TOKEN_AMOUNT}); - env(pay(gw, alice, USD(4'000))); - env(pay(gw, carol, USD(3))); + env(pay(gw, alice, usd(4'000))); + env(pay(gw, carol, usd(3))); // Notice the strand with the 800 unfunded offers has the // initial best quality - n_offers(env, 2'000, alice, EUR(2), XRP(1)); - n_offers(env, 100, alice, XRP(1), USD(4)); - n_offers(env, 801, carol, XRP(1), - USD(3)); // only one offer is funded - n_offers(env, 1'000, alice, XRP(1), USD(3)); + nOffers(env, 2'000, alice, eur(2), XRP(1)); + nOffers(env, 100, alice, XRP(1), usd(4)); + nOffers(env, 801, carol, XRP(1), + usd(3)); // only one offer is funded + nOffers(env, 1'000, alice, XRP(1), usd(3)); - n_offers(env, 1, alice, EUR(500), USD(500)); + nOffers(env, 1, alice, eur(500), usd(500)); // Bob offers to buy 2000 USD for 2000 EUR; He starts with 2000 // EUR @@ -258,21 +258,21 @@ public: // Alice spent 1497 USD (100*4 + 199*3 + 500) // Alice has 2503 remaining (4000 - 1497) // Alice received 1100 EUR (200 + 400 + 500) - env(pay(gw, bob, EUR(2'000))); + env(pay(gw, bob, eur(2'000))); env.close(); - env(offer(bob, USD(4'000), EUR(4'000))); + env(offer(bob, usd(4'000), eur(4'000))); env.close(); - env.require(balance(bob, USD(1'500))); - env.require(balance(bob, EUR(900))); + env.require(Balance(bob, usd(1'500))); + env.require(Balance(bob, eur(900))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(2'503))); - env.require(balance(alice, EUR(1'100))); + env.require(Balance(alice, usd(2'503))); + env.require(Balance(alice, eur(1'100))); auto const numAOffers = 2'000 + 100 + 1'000 + 1 - (2 * 100 + 2 * 199 + 1 + 1); env.require(offers(alice, numAOffers)); - env.require(owners(alice, numAOffers + 2)); + env.require(Owners(alice, numAOffers + 2)); env.require(offers(carol, 0)); }; @@ -284,32 +284,32 @@ public: env.fund(XRP(100'000'000), gw, alice, bob, carol); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol}, - .limit = maxMPTokenAmount}); - auto const EUR = issue2( + .limit = kMAX_MP_TOKEN_AMOUNT}); + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {bob}, - .limit = maxMPTokenAmount}); + .limit = kMAX_MP_TOKEN_AMOUNT}); - env(pay(gw, alice, USD(4'000))); - env(pay(gw, carol, USD(3))); + env(pay(gw, alice, usd(4'000))); + env(pay(gw, carol, usd(3))); // Notice the strand with the 800 unfunded offers does not have // the initial best quality - n_offers(env, 1, alice, EUR(1), USD(10)); - n_offers(env, 2'000, alice, EUR(2), XRP(1)); - n_offers(env, 100, alice, XRP(1), USD(4)); - n_offers(env, 801, carol, XRP(1), - USD(3)); // only one offer is funded - n_offers(env, 1'000, alice, XRP(1), USD(3)); + nOffers(env, 1, alice, eur(1), usd(10)); + nOffers(env, 2'000, alice, eur(2), XRP(1)); + nOffers(env, 100, alice, XRP(1), usd(4)); + nOffers(env, 801, carol, XRP(1), + usd(3)); // only one offer is funded + nOffers(env, 1'000, alice, XRP(1), usd(3)); - n_offers(env, 1, alice, EUR(499), USD(499)); + nOffers(env, 1, alice, eur(499), usd(499)); // Bob offers to buy 2000 USD for 2000 EUR; He starts with 2000 // EUR @@ -345,22 +345,22 @@ public: // She started with 4000 so has 2494 USD remaining. // Alice received 200 + 400 + 500 = 1100 EUR env.close(); - env(pay(gw, bob, EUR(2'000))); + env(pay(gw, bob, eur(2'000))); env.close(); - env(offer(bob, USD(4'000), EUR(4'000))); + env(offer(bob, usd(4'000), eur(4'000))); env.close(); - env.require(balance(bob, USD(1'509))); - env.require(balance(bob, EUR(900))); + env.require(Balance(bob, usd(1'509))); + env.require(Balance(bob, eur(900))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(2'494))); - env.require(balance(alice, EUR(1'100))); + env.require(Balance(alice, usd(2'494))); + env.require(Balance(alice, eur(1'100))); auto const numAOffers = 1 + 2'000 + 100 + 1'000 + 1 - (1 + 2 * 100 + 2 * 199 + 1 + 1); env.require(offers(alice, numAOffers)); - env.require(owners(alice, numAOffers + 2)); + env.require(Owners(alice, numAOffers + 2)); env.require(offers(carol, 0)); }; @@ -383,9 +383,9 @@ public: env.fund(XRP(100'000'000), gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(8'000))); + env(pay(gw, alice, usd(8'000))); env.close(); // The new flow cross handles consuming excessive offers differently @@ -407,28 +407,28 @@ public: // second set will consume 998, which is not over the limit and the // payment stops. So 2*998, or 1996 is the expected value when // `FlowSortStrands` is enabled. - n_offers(env, 998, alice, XRP(1.00), USD(1)); - n_offers(env, 998, alice, XRP(0.99), USD(1)); - n_offers(env, 998, alice, XRP(0.98), USD(1)); - n_offers(env, 998, alice, XRP(0.97), USD(1)); - n_offers(env, 998, alice, XRP(0.96), USD(1)); - n_offers(env, 998, alice, XRP(0.95), USD(1)); + nOffers(env, 998, alice, XRP(1.00), usd(1)); + nOffers(env, 998, alice, XRP(0.99), usd(1)); + nOffers(env, 998, alice, XRP(0.98), usd(1)); + nOffers(env, 998, alice, XRP(0.97), usd(1)); + nOffers(env, 998, alice, XRP(0.96), usd(1)); + nOffers(env, 998, alice, XRP(0.95), usd(1)); auto const expectedTER = tesSUCCESS; - env(offer(bob, USD(8'000), XRP(8'000)), ter(expectedTER)); + env(offer(bob, usd(8'000), XRP(8'000)), Ter(expectedTER)); env.close(); - auto const expectedUSD = USD(1'996); + auto const expectedUSD = usd(1'996); - env.require(balance(bob, expectedUSD)); + env.require(Balance(bob, expectedUSD)); } void run() override { using namespace jtx; - auto const features = testable_amendments(); + auto const features = testableAmendments(); testStepLimit(features); testCrossingLimit(features); testStepAndCrossingLimit(features); diff --git a/src/test/app/CrossingLimits_test.cpp b/src/test/app/CrossingLimits_test.cpp index 0cbe57a464..331afddad1 100644 --- a/src/test/app/CrossingLimits_test.cpp +++ b/src/test/app/CrossingLimits_test.cpp @@ -16,7 +16,7 @@ namespace xrpl::test { -class CrossingLimits_test : public beast::unit_test::suite +class CrossingLimits_test : public beast::unit_test::Suite { public: void @@ -28,35 +28,35 @@ public: Env env(*this, features); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000000), gw, "alice", "bob", "carol", "dan"); - env.trust(USD(1), "bob"); - env(pay(gw, "bob", USD(1))); - env.trust(USD(1), "dan"); - env(pay(gw, "dan", USD(1))); - n_offers(env, 2000, "bob", XRP(1), USD(1)); - n_offers(env, 1, "dan", XRP(1), USD(1)); + env.trust(usd(1), "bob"); + env(pay(gw, "bob", usd(1))); + env.trust(usd(1), "dan"); + env(pay(gw, "dan", usd(1))); + nOffers(env, 2000, "bob", XRP(1), usd(1)); + nOffers(env, 1, "dan", XRP(1), usd(1)); // Alice offers to buy 1000 XRP for 1000 USD. She takes Bob's first // offer, removes 999 more as unfunded, then hits the step limit. - env(offer("alice", USD(1000), XRP(1000))); - env.require(balance("alice", USD(1))); - env.require(owners("alice", 2)); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1001)); - env.require(balance("dan", USD(1))); - env.require(owners("dan", 2)); + env(offer("alice", usd(1000), XRP(1000))); + env.require(Balance("alice", usd(1))); + env.require(Owners("alice", 2)); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1001)); + env.require(Balance("dan", usd(1))); + env.require(Owners("dan", 2)); // Carol offers to buy 1000 XRP for 1000 USD. She removes Bob's next // 1000 offers as unfunded and hits the step limit. - env(offer("carol", USD(1000), XRP(1000))); - env.require(balance("carol", USD(none))); - env.require(owners("carol", 1)); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1)); - env.require(balance("dan", USD(1))); - env.require(owners("dan", 2)); + env(offer("carol", usd(1000), XRP(1000))); + env.require(Balance("carol", usd(kNONE))); + env.require(Owners("carol", 1)); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1)); + env.require(Balance("dan", usd(1))); + env.require(Owners("dan", 2)); } void @@ -68,33 +68,33 @@ public: Env env(*this, features); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // The payment engine allows 1000 offers to cross. int const maxConsumed = 1000; env.fund(XRP(100000000), gw, "alice", "bob", "carol"); int const bobOfferCount = maxConsumed + 150; - env.trust(USD(bobOfferCount), "bob"); - env(pay(gw, "bob", USD(bobOfferCount))); + env.trust(usd(bobOfferCount), "bob"); + env(pay(gw, "bob", usd(bobOfferCount))); env.close(); - n_offers(env, bobOfferCount, "bob", XRP(1), USD(1)); + nOffers(env, bobOfferCount, "bob", XRP(1), usd(1)); // Alice offers to buy Bob's offers. However she hits the offer // crossing limit, so she can't buy them all at once. - env(offer("alice", USD(bobOfferCount), XRP(bobOfferCount))); + env(offer("alice", usd(bobOfferCount), XRP(bobOfferCount))); env.close(); - env.require(balance("alice", USD(maxConsumed))); - env.require(balance("bob", USD(150))); - env.require(owners("bob", 150 + 1)); + env.require(Balance("alice", usd(maxConsumed))); + env.require(Balance("bob", usd(150))); + env.require(Owners("bob", 150 + 1)); // Carol offers to buy 1000 XRP for 1000 USD. She takes Bob's // remaining 150 offers without hitting a limit. - env(offer("carol", USD(1000), XRP(1000))); + env(offer("carol", usd(1000), XRP(1000))); env.close(); - env.require(balance("carol", USD(150))); - env.require(balance("bob", USD(0))); - env.require(owners("bob", 1)); + env.require(Balance("carol", usd(150))); + env.require(Balance("bob", usd(0))); + env.require(Owners("bob", 1)); } void @@ -106,7 +106,7 @@ public: Env env(*this, features); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000000), gw, "alice", "bob", "carol", "dan", "evita"); @@ -114,43 +114,43 @@ public: int const maxConsumed = 1000; int const evitaOfferCount{maxConsumed + 49}; - env.trust(USD(1000), "alice"); - env(pay(gw, "alice", USD(1000))); - env.trust(USD(1000), "carol"); - env(pay(gw, "carol", USD(1))); - env.trust(USD(evitaOfferCount + 1), "evita"); - env(pay(gw, "evita", USD(evitaOfferCount + 1))); + env.trust(usd(1000), "alice"); + env(pay(gw, "alice", usd(1000))); + env.trust(usd(1000), "carol"); + env(pay(gw, "carol", usd(1))); + env.trust(usd(evitaOfferCount + 1), "evita"); + env(pay(gw, "evita", usd(evitaOfferCount + 1))); // The payment engine has a limit of 1000 funded or unfunded offers. int const carolsOfferCount{700}; - n_offers(env, 400, "alice", XRP(1), USD(1)); - n_offers(env, carolsOfferCount, "carol", XRP(1), USD(1)); - n_offers(env, evitaOfferCount, "evita", XRP(1), USD(1)); + nOffers(env, 400, "alice", XRP(1), usd(1)); + nOffers(env, carolsOfferCount, "carol", XRP(1), usd(1)); + nOffers(env, evitaOfferCount, "evita", XRP(1), usd(1)); // Bob offers to buy 1000 XRP for 1000 USD. He takes all 400 USD from // Alice's offers, 1 USD from Carol's and then removes 599 of Carol's // offers as unfunded, before hitting the step limit. - env(offer("bob", USD(1000), XRP(1000))); - env.require(balance("bob", USD(401))); - env.require(balance("alice", USD(600))); - env.require(owners("alice", 1)); - env.require(balance("carol", USD(0))); - env.require(owners("carol", carolsOfferCount - 599)); - env.require(balance("evita", USD(evitaOfferCount + 1))); - env.require(owners("evita", evitaOfferCount + 1)); + env(offer("bob", usd(1000), XRP(1000))); + env.require(Balance("bob", usd(401))); + env.require(Balance("alice", usd(600))); + env.require(Owners("alice", 1)); + env.require(Balance("carol", usd(0))); + env.require(Owners("carol", carolsOfferCount - 599)); + env.require(Balance("evita", usd(evitaOfferCount + 1))); + env.require(Owners("evita", evitaOfferCount + 1)); // Dan offers to buy maxConsumed + 50 XRP USD. He removes all of // Carol's remaining offers as unfunded, then takes // (maxConsumed - 100) USD from Evita's, hitting the crossing limit. - env(offer("dan", USD(maxConsumed + 50), XRP(maxConsumed + 50))); - env.require(balance("dan", USD(maxConsumed - 100))); - env.require(owners("dan", 2)); - env.require(balance("alice", USD(600))); - env.require(owners("alice", 1)); - env.require(balance("carol", USD(0))); - env.require(owners("carol", 1)); - env.require(balance("evita", USD(150))); - env.require(owners("evita", 150)); + env(offer("dan", usd(maxConsumed + 50), XRP(maxConsumed + 50))); + env.require(Balance("dan", usd(maxConsumed - 100))); + env.require(Owners("dan", 2)); + env.require(Balance("alice", usd(600))); + env.require(Owners("alice", 1)); + env.require(Balance("carol", usd(0))); + env.require(Owners("carol", 1)); + env.require(Balance("evita", usd(150))); + env.require(Owners("evita", 150)); } void @@ -173,8 +173,8 @@ public: auto const bob = Account("bob"); auto const carol = Account("carol"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; // There are two almost identical tests. There is a strand with a large // number of unfunded offers that will cause the strand to be marked dry @@ -192,19 +192,19 @@ public: env.fund(XRP(100000000), gw, alice, bob, carol); - env.trust(USD(4000), alice); - env(pay(gw, alice, USD(4000))); - env.trust(USD(1000), carol); - env(pay(gw, carol, USD(3))); + env.trust(usd(4000), alice); + env(pay(gw, alice, usd(4000))); + env.trust(usd(1000), carol); + env(pay(gw, carol, usd(3))); // Notice the strand with the 800 unfunded offers has the initial // best quality - n_offers(env, 2000, alice, EUR(2), XRP(1)); - n_offers(env, 100, alice, XRP(1), USD(4)); - n_offers(env, 801, carol, XRP(1), USD(3)); // only one offer is funded - n_offers(env, 1000, alice, XRP(1), USD(3)); + nOffers(env, 2000, alice, eur(2), XRP(1)); + nOffers(env, 100, alice, XRP(1), usd(4)); + nOffers(env, 801, carol, XRP(1), usd(3)); // only one offer is funded + nOffers(env, 1000, alice, XRP(1), usd(3)); - n_offers(env, 1, alice, EUR(500), USD(500)); + nOffers(env, 1, alice, eur(500), usd(500)); // Bob offers to buy 2000 USD for 2000 EUR; He starts with 2000 EUR // 1. The best quality is the autobridged offers that take 2 EUR @@ -244,23 +244,23 @@ public: // Alice spent 1497 USD (100*4 + 199*3 + 500) // Alice has 2503 remaining (4000 - 1497) // Alice received 1100 EUR (200 + 400 + 500) - env.trust(EUR(10000), bob); + env.trust(eur(10000), bob); env.close(); - env(pay(gw, bob, EUR(2000))); + env(pay(gw, bob, eur(2000))); env.close(); - env(offer(bob, USD(4000), EUR(4000))); + env(offer(bob, usd(4000), eur(4000))); env.close(); - env.require(balance(bob, USD(1500))); - env.require(balance(bob, EUR(900))); + env.require(Balance(bob, usd(1500))); + env.require(Balance(bob, eur(900))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(2503))); - env.require(balance(alice, EUR(1100))); + env.require(Balance(alice, usd(2503))); + env.require(Balance(alice, eur(1100))); auto const numAOffers = 2000 + 100 + 1000 + 1 - (2 * 100 + 2 * 199 + 1 + 1); env.require(offers(alice, numAOffers)); - env.require(owners(alice, numAOffers + 2)); + env.require(Owners(alice, numAOffers + 2)); env.require(offers(carol, 0)); } @@ -269,20 +269,20 @@ public: env.fund(XRP(100000000), gw, alice, bob, carol); - env.trust(USD(4000), alice); - env(pay(gw, alice, USD(4000))); - env.trust(USD(1000), carol); - env(pay(gw, carol, USD(3))); + env.trust(usd(4000), alice); + env(pay(gw, alice, usd(4000))); + env.trust(usd(1000), carol); + env(pay(gw, carol, usd(3))); // Notice the strand with the 800 unfunded offers does not have the // initial best quality - n_offers(env, 1, alice, EUR(1), USD(10)); - n_offers(env, 2000, alice, EUR(2), XRP(1)); - n_offers(env, 100, alice, XRP(1), USD(4)); - n_offers(env, 801, carol, XRP(1), USD(3)); // only one offer is funded - n_offers(env, 1000, alice, XRP(1), USD(3)); + nOffers(env, 1, alice, eur(1), usd(10)); + nOffers(env, 2000, alice, eur(2), XRP(1)); + nOffers(env, 100, alice, XRP(1), usd(4)); + nOffers(env, 801, carol, XRP(1), usd(3)); // only one offer is funded + nOffers(env, 1000, alice, XRP(1), usd(3)); - n_offers(env, 1, alice, EUR(499), USD(499)); + nOffers(env, 1, alice, eur(499), usd(499)); // Bob offers to buy 2000 USD for 2000 EUR; He starts with 2000 EUR // 1. The best quality is the offer that takes 1 EUR and gives 10 @@ -315,23 +315,23 @@ public: // Alice spent 10 + 100*4 + 199*3 + 499 = 1506 USD. She // started with 4000 so has 2494 USD remaining. Alice // received 200 + 400 + 500 = 1100 EUR - env.trust(EUR(10000), bob); + env.trust(eur(10000), bob); env.close(); - env(pay(gw, bob, EUR(2000))); + env(pay(gw, bob, eur(2000))); env.close(); - env(offer(bob, USD(4000), EUR(4000))); + env(offer(bob, usd(4000), eur(4000))); env.close(); - env.require(balance(bob, USD(1509))); - env.require(balance(bob, EUR(900))); + env.require(Balance(bob, usd(1509))); + env.require(Balance(bob, eur(900))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(2494))); - env.require(balance(alice, EUR(1100))); + env.require(Balance(alice, usd(2494))); + env.require(Balance(alice, eur(1100))); auto const numAOffers = 1 + 2000 + 100 + 1000 + 1 - (1 + 2 * 100 + 2 * 199 + 1 + 1); env.require(offers(alice, numAOffers)); - env.require(owners(alice, numAOffers + 2)); + env.require(Owners(alice, numAOffers + 2)); env.require(offers(carol, 0)); } @@ -348,17 +348,17 @@ public: auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env(*this, features); env.fund(XRP(100000000), gw, alice, bob); - env.trust(USD(8000), alice); - env.trust(USD(8000), bob); + env.trust(usd(8000), alice); + env.trust(usd(8000), bob); env.close(); - env(pay(gw, alice, USD(8000))); + env(pay(gw, alice, usd(8000))); env.close(); // The new flow cross handles consuming excessive offers differently @@ -376,17 +376,17 @@ public: // offers consumes 998 offers, the second set will consume 998, which is // not over the limit and the payment stops. So 2*998, or 1996 is the // expected value. - n_offers(env, 998, alice, XRP(1.00), USD(1)); - n_offers(env, 998, alice, XRP(0.99), USD(1)); - n_offers(env, 998, alice, XRP(0.98), USD(1)); - n_offers(env, 998, alice, XRP(0.97), USD(1)); - n_offers(env, 998, alice, XRP(0.96), USD(1)); - n_offers(env, 998, alice, XRP(0.95), USD(1)); + nOffers(env, 998, alice, XRP(1.00), usd(1)); + nOffers(env, 998, alice, XRP(0.99), usd(1)); + nOffers(env, 998, alice, XRP(0.98), usd(1)); + nOffers(env, 998, alice, XRP(0.97), usd(1)); + nOffers(env, 998, alice, XRP(0.96), usd(1)); + nOffers(env, 998, alice, XRP(0.95), usd(1)); - env(offer(bob, USD(8000), XRP(8000)), ter(tesSUCCESS)); + env(offer(bob, usd(8000), XRP(8000)), Ter(tesSUCCESS)); env.close(); - env.require(balance(bob, USD(1996))); + env.require(Balance(bob, usd(1996))); } void @@ -400,7 +400,7 @@ public: testOfferOverflow(features); }; using namespace jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testAll(sa); testAll(sa - featurePermissionedDEX); } diff --git a/src/test/app/DID_test.cpp b/src/test/app/DID_test.cpp index bd3ea59971..496dfed059 100644 --- a/src/test/app/DID_test.cpp +++ b/src/test/app/DID_test.cpp @@ -17,7 +17,7 @@ namespace xrpl::test { -struct DID_test : public beast::unit_test::suite +struct DID_test : public beast::unit_test::Suite { void testEnabled(FeatureBitset features) @@ -33,11 +33,11 @@ struct DID_test : public beast::unit_test::suite env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); - env(did::setValid(alice), ter(temDISABLED)); + env(did::setValid(alice), Ter(temDISABLED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); - env(did::del(alice), ter(temDISABLED)); + env(did::del(alice), Ter(temDISABLED)); env.close(); } @@ -63,7 +63,7 @@ struct DID_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); // alice does not have enough XRP to cover the reserve for a DID - env(did::setValid(alice), ter(tecINSUFFICIENT_RESERVE)); + env(did::setValid(alice), Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -73,7 +73,7 @@ struct DID_test : public beast::unit_test::suite env.close(); // alice still does not have enough XRP for the reserve of a DID. - env(did::setValid(alice), ter(tecINSUFFICIENT_RESERVE)); + env(did::setValid(alice), Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -110,40 +110,40 @@ struct DID_test : public beast::unit_test::suite // invalid flags BEAST_EXPECT(ownerCount(env, alice) == 0); - env(did::setValid(alice), txflags(0x00010000), ter(temINVALID_FLAG)); + env(did::setValid(alice), Txflags(0x00010000), Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // no fields - env(did::set(alice), ter(temEMPTY_DID)); + env(did::set(alice), Ter(temEMPTY_DID)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // all empty fields - env(did::set(alice), did::uri(""), did::document(""), did::data(""), ter(temEMPTY_DID)); + env(did::set(alice), did::Uri(""), did::Document(""), did::Data(""), Ter(temEMPTY_DID)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // uri is too long std::string const longString(257, 'a'); - env(did::set(alice), did::uri(longString), ter(temMALFORMED)); + env(did::set(alice), did::Uri(longString), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // document is too long - env(did::set(alice), did::document(longString), ter(temMALFORMED)); + env(did::set(alice), did::Document(longString), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // attestation is too long - env(did::set(alice), did::document("data"), did::data(longString), ter(temMALFORMED)); + env(did::set(alice), did::Document("data"), did::Data(longString), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // some empty fields, some optional fields // pre-fix amendment auto const fixEnabled = env.current()->rules().enabled(fixEmptyDID); - env(did::set(alice), did::uri(""), fixEnabled ? ter(tecEMPTY_DID) : ter(tesSUCCESS)); + env(did::set(alice), did::Uri(""), fixEnabled ? Ter(tecEMPTY_DID) : Ter(tesSUCCESS)); env.close(); auto const expectedOwnerReserve = fixEnabled ? 0 : 1; BEAST_EXPECT(ownerCount(env, alice) == expectedOwnerReserve); @@ -169,7 +169,7 @@ struct DID_test : public beast::unit_test::suite // invalid flags BEAST_EXPECT(ownerCount(env, alice) == 0); - env(did::del(alice), txflags(0x00010000), ter(temINVALID_FLAG)); + env(did::del(alice), Txflags(0x00010000), Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -177,7 +177,7 @@ struct DID_test : public beast::unit_test::suite // doApply // DID doesn't exist - env(did::del(alice), ter(tecNO_ENTRY)); + env(did::del(alice), Ter(tecNO_ENTRY)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); } @@ -205,31 +205,31 @@ struct DID_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, charlie) == 0); // only URI - env(did::set(alice), did::uri("uri")); + env(did::set(alice), did::Uri("uri")); BEAST_EXPECT(ownerCount(env, alice) == 1); // only DIDDocument - env(did::set(bob), did::document("data")); + env(did::set(bob), did::Document("data")); BEAST_EXPECT(ownerCount(env, bob) == 1); // only Data - env(did::set(charlie), did::data("data")); + env(did::set(charlie), did::Data("data")); BEAST_EXPECT(ownerCount(env, charlie) == 1); // URI + Data - env(did::set(dave), did::uri("uri"), did::data("attest")); + env(did::set(dave), did::Uri("uri"), did::Data("attest")); BEAST_EXPECT(ownerCount(env, dave) == 1); // URI + DIDDocument - env(did::set(edna), did::uri("uri"), did::document("data")); + env(did::set(edna), did::Uri("uri"), did::Document("data")); BEAST_EXPECT(ownerCount(env, edna) == 1); // DIDDocument + Data - env(did::set(francis), did::document("data"), did::data("attest")); + env(did::set(francis), did::Document("data"), did::Data("attest")); BEAST_EXPECT(ownerCount(env, francis) == 1); // URI + DIDDocument + Data - env(did::set(george), did::uri("uri"), did::document("data"), did::data("attest")); + env(did::set(george), did::Uri("uri"), did::Document("data"), did::Data("attest")); BEAST_EXPECT(ownerCount(env, george) == 1); } @@ -251,7 +251,7 @@ struct DID_test : public beast::unit_test::suite // Create DID std::string const initialURI = "uri"; { - env(did::set(alice), did::uri(initialURI)); + env(did::set(alice), did::Uri(initialURI)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(sleDID); @@ -262,7 +262,7 @@ struct DID_test : public beast::unit_test::suite // Try to delete URI, fails because no elements are set { - env(did::set(alice), did::uri(""), ter(tecEMPTY_DID)); + env(did::set(alice), did::Uri(""), Ter(tecEMPTY_DID)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(checkVL((*sleDID)[sfURI], initialURI)); @@ -273,7 +273,7 @@ struct DID_test : public beast::unit_test::suite // Set DIDDocument std::string const initialDocument = "data"; { - env(did::set(alice), did::document(initialDocument)); + env(did::set(alice), did::Document(initialDocument)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(checkVL((*sleDID)[sfURI], initialURI)); @@ -284,7 +284,7 @@ struct DID_test : public beast::unit_test::suite // Set Data std::string const initialData = "attest"; { - env(did::set(alice), did::data(initialData)); + env(did::set(alice), did::Data(initialData)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(checkVL((*sleDID)[sfURI], initialURI)); @@ -294,7 +294,7 @@ struct DID_test : public beast::unit_test::suite // Remove URI { - env(did::set(alice), did::uri("")); + env(did::set(alice), did::Uri("")); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(!sleDID->isFieldPresent(sfURI)); @@ -304,7 +304,7 @@ struct DID_test : public beast::unit_test::suite // Remove Data { - env(did::set(alice), did::data("")); + env(did::set(alice), did::Data("")); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(!sleDID->isFieldPresent(sfURI)); @@ -315,7 +315,7 @@ struct DID_test : public beast::unit_test::suite // Remove Data + set URI std::string const secondURI = "uri2"; { - env(did::set(alice), did::uri(secondURI), did::document("")); + env(did::set(alice), did::Uri(secondURI), did::Document("")); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(checkVL((*sleDID)[sfURI], secondURI)); @@ -326,7 +326,7 @@ struct DID_test : public beast::unit_test::suite // Remove URI + set DIDDocument std::string const secondDocument = "data2"; { - env(did::set(alice), did::uri(""), did::document(secondDocument)); + env(did::set(alice), did::Uri(""), did::Document(secondDocument)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(!sleDID->isFieldPresent(sfURI)); @@ -337,7 +337,7 @@ struct DID_test : public beast::unit_test::suite // Remove DIDDocument + set Data std::string const secondData = "randomData"; { - env(did::set(alice), did::document(""), did::data(secondData)); + env(did::set(alice), did::Document(""), did::Data(secondData)); BEAST_EXPECT(ownerCount(env, alice) == 1); auto const sleDID = env.le(keylet::did(alice.id())); BEAST_EXPECT(!sleDID->isFieldPresent(sfURI)); @@ -358,7 +358,7 @@ struct DID_test : public beast::unit_test::suite run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; FeatureBitset const emptyDID{fixEmptyDID}; testEnabled(all); testAccountReserve(all); diff --git a/src/test/app/DNS_test.cpp b/src/test/app/DNS_test.cpp index 3997da60db..c7e65fd995 100644 --- a/src/test/app/DNS_test.cpp +++ b/src/test/app/DNS_test.cpp @@ -18,13 +18,13 @@ namespace xrpl::test { -class DNS_test : public beast::unit_test::suite +class DNS_test : public beast::unit_test::Suite { using endpoint_type = boost::asio::ip::tcp::endpoint; using error_code = boost::system::error_code; std::weak_ptr work_; endpoint_type lastEndpoint_; - parsedURL pUrl_; + ParsedUrl pUrl_; std::string port_; jtx::Env env_; std::map resolved_; diff --git a/src/test/app/Delegate_test.cpp b/src/test/app/Delegate_test.cpp index fdcbbc7a1d..6ec4c250f6 100644 --- a/src/test/app/Delegate_test.cpp +++ b/src/test/app/Delegate_test.cpp @@ -53,7 +53,7 @@ #include namespace xrpl::test { -class Delegate_test : public beast::unit_test::suite +class Delegate_test : public beast::unit_test::Suite { void testFeatureDisabled(FeatureBitset features) @@ -68,14 +68,14 @@ class Delegate_test : public beast::unit_test::suite env.fund(XRP(1000000), gw, alice, bob); env.close(); - auto res = features[featurePermissionDelegationV1_1] ? ter(tesSUCCESS) : ter(temDISABLED); + auto res = features[featurePermissionDelegationV1_1] ? Ter(tesSUCCESS) : Ter(temDISABLED); // can not set Delegate when feature disabled env(delegate::set(gw, alice, {"Payment"}), res); env.close(); // can not send delegating transaction when feature disabled - env(pay(gw, bob, XRP(100)), delegate::as(alice), res); + env(pay(gw, bob, XRP(100)), delegate::As(alice), res); } void @@ -92,7 +92,7 @@ class Delegate_test : public beast::unit_test::suite // delegating an empty permission list when the delegate ledger object // does not exist is not allowed - env(delegate::set(gw, alice, {}), ter(tecNO_ENTRY)); + env(delegate::set(gw, alice, {}), Ter(tecNO_ENTRY)); env.close(); auto const permissions = std::vector{ @@ -102,7 +102,7 @@ class Delegate_test : public beast::unit_test::suite // this lambda function is used to compare the json value of ledger // entry response with the given vector of permissions. - auto comparePermissions = [&](Json::Value const& jle, + auto comparePermissions = [&](json::Value const& jle, std::vector const& permissions, Account const& account, Account const& authorize) { @@ -181,29 +181,29 @@ class Delegate_test : public beast::unit_test::suite "TrustSet", "NFTokenMint", "NFTokenBurn"}), - ter(temARRAY_TOO_LARGE)); + Ter(temARRAY_TOO_LARGE)); } // alice can not authorize herself { - env(delegate::set(alice, alice, {"Payment"}), ter(temMALFORMED)); + env(delegate::set(alice, alice, {"Payment"}), Ter(temMALFORMED)); } // bad fee { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::DelegateSet; jv[jss::Account] = gw.human(); jv[sfAuthorize.jsonName] = alice.human(); - Json::Value permissionsJson(Json::arrayValue); - Json::Value permissionValue; + json::Value permissionsJson(json::ArrayValue); + json::Value permissionValue; permissionValue[sfPermissionValue.jsonName] = "Payment"; - Json::Value permissionObj; + json::Value permissionObj; permissionObj[sfPermission.jsonName] = permissionValue; permissionsJson.append(permissionObj); jv[sfPermissions.jsonName] = permissionsJson; jv[sfFee.jsonName] = -1; - env(jv, ter(temBAD_FEE)); + env(jv, Ter(temBAD_FEE)); } // when provided permissions contains duplicate values, should return @@ -218,25 +218,25 @@ class Delegate_test : public beast::unit_test::suite "TrustlineAuthorize", "CheckCreate", "TrustlineAuthorize"}), - ter(temMALFORMED)); + Ter(temMALFORMED)); } // when authorizing account which does not exist, should return // tecNO_TARGET { - env(delegate::set(gw, Account("unknown"), {"Payment"}), ter(tecNO_TARGET)); + env(delegate::set(gw, Account("unknown"), {"Payment"}), Ter(tecNO_TARGET)); } // non-delegable transaction { - env(delegate::set(gw, alice, {"SetRegularKey"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"AccountSet"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"SignerListSet"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"DelegateSet"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"EnableAmendment"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"UNLModify"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"SetFee"}), ter(temMALFORMED)); - env(delegate::set(gw, alice, {"Batch"}), ter(temMALFORMED)); + env(delegate::set(gw, alice, {"SetRegularKey"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"AccountSet"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"SignerListSet"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"DelegateSet"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"EnableAmendment"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"UNLModify"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"SetFee"}), Ter(temMALFORMED)); + env(delegate::set(gw, alice, {"Batch"}), Ter(temMALFORMED)); } } @@ -258,7 +258,7 @@ class Delegate_test : public beast::unit_test::suite env.close(); // alice does not have enough reserve to create Delegate - env(delegate::set(alice, bob, {"Payment"}), ter(tecINSUFFICIENT_RESERVE)); + env(delegate::set(alice, bob, {"Payment"}), Ter(tecINSUFFICIENT_RESERVE)); } // reserve recovered after deleting delegation object @@ -279,7 +279,7 @@ class Delegate_test : public beast::unit_test::suite env.close(); // alice does not have enough reserve to create another delegation object - env(delegate::set(alice, carol, {"Payment"}), ter(tecINSUFFICIENT_RESERVE)); + env(delegate::set(alice, carol, {"Payment"}), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // deleting delegation object recovers 1 reserve @@ -306,10 +306,10 @@ class Delegate_test : public beast::unit_test::suite // bob set DID on behalf of alice, but alice does not have enough // reserve - env(did::set(alice), did::uri("uri"), delegate::as(bob), ter(tecINSUFFICIENT_RESERVE)); + env(did::set(alice), did::Uri("uri"), delegate::As(bob), Ter(tecINSUFFICIENT_RESERVE)); // bob can set DID for himself because he has enough reserve - env(did::set(bob), did::uri("uri")); + env(did::set(bob), did::Uri("uri")); env.close(); } } @@ -339,7 +339,7 @@ class Delegate_test : public beast::unit_test::suite auto const bobBalance = env.balance(bob); auto const carolBalance = env.balance(carol); - env(pay(alice, carol, XRP(100)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(pay(alice, carol, XRP(100)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -359,7 +359,7 @@ class Delegate_test : public beast::unit_test::suite auto const sendAmt = XRP(100); auto const feeAmt = XRP(10); - env(pay(alice, carol, sendAmt), fee(feeAmt), delegate::as(bob)); + env(pay(alice, carol, sendAmt), Fee(feeAmt), delegate::As(bob)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance - sendAmt); BEAST_EXPECT(env.balance(bob) == bobBalance - feeAmt); @@ -378,9 +378,9 @@ class Delegate_test : public beast::unit_test::suite auto const carolBalance = env.balance(carol); env(pay(alice, carol, XRP(100)), - fee(XRP(2000)), - delegate::as(bob), - ter(terINSUF_FEE_B)); + Fee(XRP(2000)), + delegate::As(bob), + Ter(terINSUF_FEE_B)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -413,7 +413,7 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(alice, bob, {"Payment"})); env.close(); - env.require(balance(alice, paymentAmount + reserve)); + env.require(Balance(alice, paymentAmount + reserve)); return std::make_tuple(alice, bob, carol, paymentAmount, highFee, reserve); }; @@ -431,7 +431,7 @@ class Delegate_test : public beast::unit_test::suite auto const bobBalance = env.balance(bob); auto const carolBalance = env.balance(carol); - env(pay(alice, carol, paymentAmount), fee(highFee), ter(tecUNFUNDED_PAYMENT)); + env(pay(alice, carol, paymentAmount), Fee(highFee), Ter(tecUNFUNDED_PAYMENT)); // tec consumes the fee from Alice; carol and bob are unaffected. BEAST_EXPECT(env.balance(alice) == aliceBalance - highFee); @@ -449,12 +449,12 @@ class Delegate_test : public beast::unit_test::suite auto const bobPrePay = env.balance(bob, XRP); auto const carolPrePay = env.balance(carol, XRP); - env(pay(alice, carol, paymentAmount), delegate::as(bob), fee(highFee)); + env(pay(alice, carol, paymentAmount), delegate::As(bob), Fee(highFee)); env.close(); - env.require(balance(alice, alicePrePay - paymentAmount)); - env.require(balance(bob, bobPrePay - highFee)); - env.require(balance(carol, carolPrePay + paymentAmount)); + env.require(Balance(alice, alicePrePay - paymentAmount)); + env.require(Balance(bob, bobPrePay - highFee)); + env.require(Balance(carol, carolPrePay + paymentAmount)); } } @@ -481,15 +481,15 @@ class Delegate_test : public beast::unit_test::suite // After paying for this transaction, bob's balance will // dip below the base reserve - env(pay(alice, carol, XRP(1)), delegate::as(bob)); + env(pay(alice, carol, XRP(1)), delegate::As(bob)); env.close(); // Bob's balance is now less than the base reserve. BEAST_EXPECT(env.balance(bob, XRP) < baseReserve); - env.require(balance(bob, bobPreTx - drops(baseFee))); + env.require(Balance(bob, bobPreTx - drops(baseFee))); // Alice's balance only decreased by the 1.0 XRP she sent. - env.require(balance(alice, alicePreTx - XRP(1))); + env.require(Balance(alice, alicePreTx - XRP(1))); } // The delegated account has enough balance for the fee, but delegator @@ -519,11 +519,11 @@ class Delegate_test : public beast::unit_test::suite auto const carolPrePay = env.balance(carol, XRP); // Bob pays the fee, but Alice has insufficient balance to send XRP(10). - env(pay(alice, carol, XRP(10)), delegate::as(bob), ter(tecUNFUNDED_PAYMENT)); + env(pay(alice, carol, XRP(10)), delegate::As(bob), Ter(tecUNFUNDED_PAYMENT)); - env.require(balance(alice, alicePrePay)); - env.require(balance(bob, bobPrePay - drops(baseFee))); - env.require(balance(carol, carolPrePay)); + env.require(Balance(alice, alicePrePay)); + env.require(Balance(bob, bobPrePay - drops(baseFee))); + env.require(Balance(carol, carolPrePay)); } } @@ -552,28 +552,28 @@ class Delegate_test : public beast::unit_test::suite for (auto i = 0; i < 20; ++i) { - // bob is the delegated account, his sequence won't increment - env(pay(alice, carol, XRP(10)), fee(XRP(10)), delegate::as(bob)); + // bob is the delegated account, his sequence won't kINCREMENT + env(pay(alice, carol, XRP(10)), Fee(XRP(10)), delegate::As(bob)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); BEAST_EXPECT(env.seq(bob) == bobSeq); aliceSeq = env.seq(alice); - // bob sends payment for himself, his sequence will increment - env(pay(bob, carol, XRP(10)), fee(XRP(10))); + // bob sends payment for himself, his sequence will kINCREMENT + env(pay(bob, carol, XRP(10)), Fee(XRP(10))); BEAST_EXPECT(env.seq(alice) == aliceSeq); BEAST_EXPECT(env.seq(bob) == bobSeq + 1); bobSeq = env.seq(bob); - // alice is the delegated account, her sequence won't increment - env(pay(bob, carol, XRP(10)), fee(XRP(10)), delegate::as(alice)); + // alice is the delegated account, her sequence won't kINCREMENT + env(pay(bob, carol, XRP(10)), Fee(XRP(10)), delegate::As(alice)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); BEAST_EXPECT(env.seq(bob) == bobSeq + 1); bobSeq = env.seq(bob); - // alice sends payment for herself, her sequence will increment - env(pay(alice, carol, XRP(10)), fee(XRP(10))); + // alice sends payment for herself, her sequence will kINCREMENT + env(pay(alice, carol, XRP(10)), Fee(XRP(10))); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); BEAST_EXPECT(env.seq(bob) == bobSeq); aliceSeq = env.seq(alice); @@ -622,7 +622,7 @@ class Delegate_test : public beast::unit_test::suite // alice deletes account, this will remove the Delegate object from // both alice's and bob's owner directories auto const deleteFee = drops(env.current()->fees().increment); - env(acctdelete(alice, carol), fee(deleteFee)); + env(acctdelete(alice, carol), Fee(deleteFee)); env.close(); BEAST_EXPECT(!env.closed()->exists(keylet::account(alice.id()))); @@ -677,7 +677,7 @@ class Delegate_test : public beast::unit_test::suite // bob's owner directories so alice's delegation does not survive // a potential account resurrection. auto const deleteFee = drops(env.current()->fees().increment); - env(acctdelete(bob, carol), fee(deleteFee)); + env(acctdelete(bob, carol), Fee(deleteFee)); env.close(); BEAST_EXPECT(!env.closed()->exists(keylet::account(bob.id()))); @@ -694,7 +694,7 @@ class Delegate_test : public beast::unit_test::suite BEAST_EXPECT(sleAlice2->getFieldU32(sfOwnerCount) == 0); auto const aliceDeleteFee = drops(env.current()->fees().increment); - env(acctdelete(alice, carol), fee(aliceDeleteFee)); + env(acctdelete(alice, carol), Fee(aliceDeleteFee)); env.close(); BEAST_EXPECT(!env.closed()->exists(keylet::account(alice.id()))); @@ -740,7 +740,7 @@ class Delegate_test : public beast::unit_test::suite auto const daveBalance = env.balance(dave); auto const deleteFee = drops(env.current()->fees().increment); - env(acctdelete(bob, dave), fee(deleteFee)); + env(acctdelete(bob, dave), Fee(deleteFee)); env.close(); // bob's account and directory are gone @@ -785,44 +785,44 @@ class Delegate_test : public beast::unit_test::suite auto carolBalance = env.balance(carol, XRP); // can not send transaction on one's own behalf - env(pay(alice, bob, XRP(50)), delegate::as(alice), ter(temBAD_SIGNER)); - env.require(balance(alice, aliceBalance)); + env(pay(alice, bob, XRP(50)), delegate::As(alice), Ter(temBAD_SIGNER)); + env.require(Balance(alice, aliceBalance)); env(delegate::set(alice, bob, {"Payment"})); env.close(); - env.require(balance(alice, aliceBalance - drops(baseFee))); + env.require(Balance(alice, aliceBalance - drops(baseFee))); aliceBalance = env.balance(alice, XRP); // bob pays 50 XRP to carol on behalf of alice - env(pay(alice, carol, XRP(50)), delegate::as(bob)); + env(pay(alice, carol, XRP(50)), delegate::As(bob)); env.close(); - env.require(balance(alice, aliceBalance - XRP(50))); - env.require(balance(carol, carolBalance + XRP(50))); + env.require(Balance(alice, aliceBalance - XRP(50))); + env.require(Balance(carol, carolBalance + XRP(50))); // bob pays the fee - env.require(balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(bob, bobBalance - drops(baseFee))); aliceBalance = env.balance(alice, XRP); bobBalance = env.balance(bob, XRP); carolBalance = env.balance(carol, XRP); // bob pays 50 XRP to bob self on behalf of alice - env(pay(alice, bob, XRP(50)), delegate::as(bob)); + env(pay(alice, bob, XRP(50)), delegate::As(bob)); env.close(); - env.require(balance(alice, aliceBalance - XRP(50))); - env.require(balance(bob, bobBalance + XRP(50) - drops(baseFee))); + env.require(Balance(alice, aliceBalance - XRP(50))); + env.require(Balance(bob, bobBalance + XRP(50) - drops(baseFee))); aliceBalance = env.balance(alice, XRP); bobBalance = env.balance(bob, XRP); // bob pay 50 XRP to alice herself on behalf of alice - env(pay(alice, alice, XRP(50)), delegate::as(bob), ter(temREDUNDANT)); + env(pay(alice, alice, XRP(50)), delegate::As(bob), Ter(temREDUNDANT)); env.close(); // bob does not have permission to create check - env(check::create(alice, bob, XRP(10)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(check::create(alice, bob, XRP(10)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // carol does not have permission to create check env(check::create(alice, bob, XRP(10)), - delegate::as(carol), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(carol), + Ter(terNO_DELEGATE_PERMISSION)); } void @@ -838,14 +838,14 @@ class Delegate_test : public beast::unit_test::suite Account const bob{"bob"}; Account const gw{"gateway"}; Account const gw2{"gateway2"}; - auto const USD = gw["USD"]; - auto const EUR = gw2["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw2["EUR"]; env.fund(XRP(10000), alice); env.fund(XRP(20000), bob); env.fund(XRP(40000), gw, gw2); - env.trust(USD(200), alice); - env.trust(EUR(400), gw); + env.trust(usd(200), alice); + env.trust(eur(400), gw); env.close(); XRPAmount const baseFee{env.current()->fees().base}; @@ -855,85 +855,85 @@ class Delegate_test : public beast::unit_test::suite auto gw2Balance = env.balance(gw2, XRP); // delegate ledger object is not created yet - env(pay(gw, alice, USD(50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); - env.require(balance(bob, bobBalance)); + env(pay(gw, alice, usd(50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); + env.require(Balance(bob, bobBalance)); // gw gives bob burn permission env(delegate::set(gw, bob, {"PaymentBurn"})); env.close(); - env.require(balance(gw, gwBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance - drops(baseFee))); gwBalance = env.balance(gw, XRP); // bob sends a payment transaction on behalf of gw - env(pay(gw, alice, USD(50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(pay(gw, alice, usd(50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env.close(); - env.require(balance(bob, bobBalance)); + env.require(Balance(bob, bobBalance)); // gw gives bob mint permission, alice gives bob burn permission env(delegate::set(gw, bob, {"PaymentMint"})); env(delegate::set(alice, bob, {"PaymentBurn"})); env.close(); - env.require(balance(alice, aliceBalance - drops(baseFee))); - env.require(balance(gw, gwBalance - drops(baseFee))); + env.require(Balance(alice, aliceBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance - drops(baseFee))); aliceBalance = env.balance(alice, XRP); gwBalance = env.balance(gw, XRP); // can not send XRP - env(pay(gw, alice, XRP(50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(pay(gw, alice, XRP(50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env.close(); - env.require(balance(bob, bobBalance)); + env.require(Balance(bob, bobBalance)); // mint 50 USD - env(pay(gw, alice, USD(50)), delegate::as(bob)); + env(pay(gw, alice, usd(50)), delegate::As(bob)); env.close(); - env.require(balance(bob, bobBalance - drops(baseFee))); - env.require(balance(gw, gwBalance)); - env.require(balance(gw, alice["USD"](-50))); - env.require(balance(alice, USD(50))); - BEAST_EXPECT(env.balance(bob, USD) == USD(0)); + env.require(Balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance)); + env.require(Balance(gw, alice["USD"](-50))); + env.require(Balance(alice, usd(50))); + BEAST_EXPECT(env.balance(bob, usd) == usd(0)); bobBalance = env.balance(bob, XRP); // burn 30 USD - env(pay(alice, gw, USD(30)), delegate::as(bob)); + env(pay(alice, gw, usd(30)), delegate::As(bob)); env.close(); - env.require(balance(bob, bobBalance - drops(baseFee))); - env.require(balance(gw, gwBalance)); - env.require(balance(gw, alice["USD"](-20))); - env.require(balance(alice, USD(20))); - BEAST_EXPECT(env.balance(bob, USD) == USD(0)); + env.require(Balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance)); + env.require(Balance(gw, alice["USD"](-20))); + env.require(Balance(alice, usd(20))); + BEAST_EXPECT(env.balance(bob, usd) == usd(0)); bobBalance = env.balance(bob, XRP); // bob has both mint and burn permissions env(delegate::set(gw, bob, {"PaymentMint", "PaymentBurn"})); env.close(); - env.require(balance(gw, gwBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance - drops(baseFee))); gwBalance = env.balance(gw, XRP); // mint 100 USD for gw - env(pay(gw, alice, USD(100)), delegate::as(bob)); + env(pay(gw, alice, usd(100)), delegate::As(bob)); env.close(); - env.require(balance(gw, alice["USD"](-120))); - env.require(balance(alice, USD(120))); - env.require(balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(gw, alice["USD"](-120))); + env.require(Balance(alice, usd(120))); + env.require(Balance(bob, bobBalance - drops(baseFee))); bobBalance = env.balance(bob, XRP); // gw2 pays gw 200 EUR - env(pay(gw2, gw, EUR(200))); + env(pay(gw2, gw, eur(200))); env.close(); - env.require(balance(gw2, gw2Balance - drops(baseFee))); + env.require(Balance(gw2, gw2Balance - drops(baseFee))); gw2Balance = env.balance(gw2, XRP); - env.require(balance(gw2, gw["EUR"](-200))); - env.require(balance(gw, EUR(200))); + env.require(Balance(gw2, gw["EUR"](-200))); + env.require(Balance(gw, eur(200))); // burn 100 EUR for gw - env(pay(gw, gw2, EUR(100)), delegate::as(bob)); + env(pay(gw, gw2, eur(100)), delegate::As(bob)); env.close(); - env.require(balance(gw2, gw["EUR"](-100))); - env.require(balance(gw, EUR(100))); - env.require(balance(bob, bobBalance - drops(baseFee))); - env.require(balance(gw, gwBalance)); - env.require(balance(gw2, gw2Balance)); - env.require(balance(alice, aliceBalance)); + env.require(Balance(gw2, gw["EUR"](-100))); + env.require(Balance(gw, eur(100))); + env.require(Balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance)); + env.require(Balance(gw2, gw2Balance)); + env.require(Balance(alice, aliceBalance)); } // test PaymentMint won't affect Payment transaction level delegation. @@ -942,12 +942,12 @@ class Delegate_test : public beast::unit_test::suite Account const alice{"alice"}; Account const bob{"bob"}; Account const gw{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice); env.fund(XRP(20000), bob); env.fund(XRP(40000), gw); - env.trust(USD(200), alice); + env.trust(usd(200), alice); env.close(); XRPAmount const baseFee{env.current()->fees().base}; @@ -959,30 +959,30 @@ class Delegate_test : public beast::unit_test::suite // gw gives bob PaymentBurn permission env(delegate::set(gw, bob, {"PaymentBurn"})); env.close(); - env.require(balance(gw, gwBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance - drops(baseFee))); gwBalance = env.balance(gw, XRP); // bob can not mint on behalf of gw because he only has burn // permission - env(pay(gw, alice, USD(50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(pay(gw, alice, usd(50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env.close(); - env.require(balance(bob, bobBalance)); + env.require(Balance(bob, bobBalance)); // gw gives bob Payment permission as well env(delegate::set(gw, bob, {"PaymentBurn", "Payment"})); env.close(); - env.require(balance(gw, gwBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance - drops(baseFee))); gwBalance = env.balance(gw, XRP); // bob now can mint on behalf of gw - env(pay(gw, alice, USD(50)), delegate::as(bob)); + env(pay(gw, alice, usd(50)), delegate::As(bob)); env.close(); - env.require(balance(bob, bobBalance - drops(baseFee))); - env.require(balance(gw, gwBalance)); - env.require(balance(alice, aliceBalance)); - env.require(balance(gw, alice["USD"](-50))); - env.require(balance(alice, USD(50))); - BEAST_EXPECT(env.balance(bob, USD) == USD(0)); + env.require(Balance(bob, bobBalance - drops(baseFee))); + env.require(Balance(gw, gwBalance)); + env.require(Balance(alice, aliceBalance)); + env.require(Balance(gw, alice["USD"](-50))); + env.require(Balance(alice, usd(50))); + BEAST_EXPECT(env.balance(bob, usd) == usd(0)); } // disallow cross currency payment with only PaymentBurn/PaymentMint @@ -993,71 +993,71 @@ class Delegate_test : public beast::unit_test::suite Account const bob{"bob"}; Account const gw{"gateway"}; Account const carol{"carol"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(50000), alice); - env.trust(USD(50000), bob); - env.trust(USD(50000), carol); - env(pay(gw, alice, USD(10000))); - env(pay(gw, bob, USD(10000))); - env(pay(gw, carol, USD(10000))); + env.trust(usd(50000), alice); + env.trust(usd(50000), bob); + env.trust(usd(50000), carol); + env(pay(gw, alice, usd(10000))); + env(pay(gw, bob, usd(10000))); + env(pay(gw, carol, usd(10000))); env.close(); // PaymentMint { - env(offer(carol, XRP(100), USD(501))); + env(offer(carol, XRP(100), usd(501))); BEAST_EXPECT(expectOffers(env, carol, 1)); env(delegate::set(gw, bob, {"PaymentMint"})); env.close(); // bob can not send cross currency payment on behalf of the gw, // even with PaymentMint permission and gw being the issuer. - env(pay(gw, alice, USD(5000)), - sendmax(XRP(1001)), - txflags(tfPartialPayment), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + env(pay(gw, alice, usd(5000)), + Sendmax(XRP(1001)), + Txflags(tfPartialPayment), + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); BEAST_EXPECT(expectOffers(env, carol, 1)); - env(pay(gw, alice, USD(5000)), - path(~XRP), - txflags(tfPartialPayment), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + env(pay(gw, alice, usd(5000)), + Path(~XRP), + Txflags(tfPartialPayment), + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); BEAST_EXPECT(expectOffers(env, carol, 1)); // succeed with direct payment - env(pay(gw, alice, USD(100)), delegate::as(bob)); + env(pay(gw, alice, usd(100)), delegate::As(bob)); env.close(); } // PaymentBurn { - env(offer(bob, XRP(100), USD(501))); + env(offer(bob, XRP(100), usd(501))); BEAST_EXPECT(expectOffers(env, bob, 1)); env(delegate::set(alice, bob, {"PaymentBurn"})); env.close(); // bob can not send cross currency payment on behalf of alice, // even with PaymentBurn permission and gw being the issuer. - env(pay(alice, gw, USD(5000)), - sendmax(XRP(1001)), - txflags(tfPartialPayment), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + env(pay(alice, gw, usd(5000)), + Sendmax(XRP(1001)), + Txflags(tfPartialPayment), + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); BEAST_EXPECT(expectOffers(env, bob, 1)); - env(pay(alice, gw, USD(5000)), - path(~XRP), - txflags(tfPartialPayment), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + env(pay(alice, gw, usd(5000)), + Path(~XRP), + Txflags(tfPartialPayment), + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); BEAST_EXPECT(expectOffers(env, bob, 1)); // succeed with direct payment - env(pay(alice, gw, USD(100)), delegate::as(bob)); + env(pay(alice, gw, usd(100)), delegate::As(bob)); env.close(); } } @@ -1076,7 +1076,7 @@ class Delegate_test : public beast::unit_test::suite mpt.authorize({.account = alice}); mpt.authorize({.account = bob}); - auto const MPT = mpt["MPT"]; + auto const MPT = mpt["MPT"]; // NOLINT(readability-identifier-naming) env(pay(gw, alice, MPT(500))); env(pay(gw, bob, MPT(500))); env.close(); @@ -1088,7 +1088,7 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(gw, bob, {"PaymentMint"})); env.close(); - env(pay(gw, alice, MPT(50)), delegate::as(bob)); + env(pay(gw, alice, MPT(50)), delegate::As(bob)); BEAST_EXPECT(env.balance(alice, MPT) == aliceMPT + MPT(50)); BEAST_EXPECT(env.balance(bob, MPT) == bobMPT); aliceMPT = env.balance(alice, MPT); @@ -1099,7 +1099,7 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(alice, bob, {"PaymentBurn"})); env.close(); - env(pay(alice, gw, MPT(50)), delegate::as(bob)); + env(pay(alice, gw, MPT(50)), delegate::As(bob)); BEAST_EXPECT(env.balance(alice, MPT) == aliceMPT - MPT(50)); BEAST_EXPECT(env.balance(bob, MPT) == bobMPT); aliceMPT = env.balance(alice, MPT); @@ -1109,11 +1109,11 @@ class Delegate_test : public beast::unit_test::suite { env(delegate::set(alice, bob, {"PaymentBurn", "PaymentMint", "Payment"})); env.close(); - env(pay(alice, gw, MPT(50)), delegate::as(bob)); + env(pay(alice, gw, MPT(50)), delegate::As(bob)); BEAST_EXPECT(env.balance(alice, MPT) == aliceMPT - MPT(50)); BEAST_EXPECT(env.balance(bob, MPT) == bobMPT); aliceMPT = env.balance(alice, MPT); - env(pay(alice, bob, MPT(100)), delegate::as(bob)); + env(pay(alice, bob, MPT(100)), delegate::As(bob)); BEAST_EXPECT(env.balance(alice, MPT) == aliceMPT - MPT(100)); BEAST_EXPECT(env.balance(bob, MPT) == bobMPT + MPT(100)); } @@ -1140,7 +1140,7 @@ class Delegate_test : public beast::unit_test::suite env.close(); // bob can not create trustline on behalf of alice because he only // has unfreeze permission - env(trust(alice, gw["USD"](50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(trust(alice, gw["USD"](50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env.close(); // alice creates trustline by herself @@ -1153,89 +1153,89 @@ class Delegate_test : public beast::unit_test::suite // unsupported flags env(trust(alice, gw["USD"](50), tfSetNoRipple), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env(trust(alice, gw["USD"](50), tfClearNoRipple), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env(trust(gw, gw["USD"](0), alice, tfSetDeepFreeze), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env(trust(gw, gw["USD"](0), alice, tfClearDeepFreeze), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); // supported flags with wrong permission env(trust(gw, gw["USD"](0), alice, tfSetfAuth), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env(trust(gw, gw["USD"](0), alice, tfSetFreeze), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); env(delegate::set(gw, bob, {"TrustlineAuthorize"})); env.close(); env(trust(gw, gw["USD"](0), alice, tfClearFreeze), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); // although trustline authorize is granted, bob can not change the // limit number env(trust(gw, gw["USD"](50), alice, tfSetfAuth), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); // supported flags with correct permission - env(trust(gw, gw["USD"](0), alice, tfSetfAuth), delegate::as(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetfAuth), delegate::As(bob)); env.close(); env(delegate::set(gw, bob, {"TrustlineAuthorize", "TrustlineFreeze"})); env.close(); - env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::as(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::As(bob)); env.close(); env(delegate::set(gw, bob, {"TrustlineAuthorize", "TrustlineUnfreeze"})); env.close(); - env(trust(gw, gw["USD"](0), alice, tfClearFreeze), delegate::as(bob)); + env(trust(gw, gw["USD"](0), alice, tfClearFreeze), delegate::As(bob)); env.close(); // but bob can not freeze trustline because he no longer has freeze // permission env(trust(gw, gw["USD"](0), alice, tfSetFreeze), - delegate::as(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Ter(terNO_DELEGATE_PERMISSION)); // cannot update LimitAmount with granular permission, both high and // low account - env(trust(alice, gw["USD"](100)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); - env(trust(gw, alice["USD"](100)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(trust(alice, gw["USD"](100)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); + env(trust(gw, alice["USD"](100)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // can not set QualityIn or QualityOut auto tx = trust(alice, gw["USD"](50)); tx["QualityIn"] = "1000"; - env(tx, delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(tx, delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); auto tx2 = trust(alice, gw["USD"](50)); tx2["QualityOut"] = "1000"; - env(tx2, delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(tx2, delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); auto tx3 = trust(gw, alice["USD"](50)); tx3["QualityIn"] = "1000"; - env(tx3, delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(tx3, delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); auto tx4 = trust(gw, alice["USD"](50)); tx4["QualityOut"] = "1000"; - env(tx4, delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(tx4, delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // granting TrustSet can make it work env(delegate::set(gw, bob, {"TrustSet"})); env.close(); auto tx5 = trust(gw, alice["USD"](50)); tx5["QualityOut"] = "1000"; - env(tx5, delegate::as(bob)); + env(tx5, delegate::As(bob)); auto tx6 = trust(alice, gw["USD"](50)); tx6["QualityOut"] = "1000"; - env(tx6, delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(tx6, delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env(delegate::set(alice, bob, {"TrustSet"})); env.close(); - env(tx6, delegate::as(bob)); + env(tx6, delegate::As(bob)); } // test mix of transaction level delegation and granular delegation @@ -1249,11 +1249,11 @@ class Delegate_test : public beast::unit_test::suite env.close(); // bob does not have permission - env(trust(alice, gw["USD"](50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(trust(alice, gw["USD"](50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env(delegate::set(alice, bob, {"TrustlineUnfreeze", "NFTokenCreateOffer"})); env.close(); // bob still does not have permission - env(trust(alice, gw["USD"](50)), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(trust(alice, gw["USD"](50)), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // add TrustSet permission and some unrelated permission env(delegate::set( @@ -1261,7 +1261,7 @@ class Delegate_test : public beast::unit_test::suite bob, {"TrustlineUnfreeze", "NFTokenCreateOffer", "TrustSet", "AccountTransferRateSet"})); env.close(); - env(trust(alice, gw["USD"](50)), delegate::as(bob)); + env(trust(alice, gw["USD"](50)), delegate::As(bob)); env.close(); env(delegate::set( @@ -1272,15 +1272,15 @@ class Delegate_test : public beast::unit_test::suite // since bob has TrustSet permission, he does not need // TrustlineFreeze granular permission to freeze the trustline - env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::as(bob)); - env(trust(gw, gw["USD"](0), alice, tfClearFreeze), delegate::as(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::As(bob)); + env(trust(gw, gw["USD"](0), alice, tfClearFreeze), delegate::As(bob)); // bob can perform all the operations regarding TrustSet - env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::as(bob)); - env(trust(gw, gw["USD"](0), alice, tfSetDeepFreeze), delegate::as(bob)); - env(trust(gw, gw["USD"](0), alice, tfClearDeepFreeze), delegate::as(bob)); - env(trust(gw, gw["USD"](0), alice, tfSetfAuth), delegate::as(bob)); - env(trust(alice, gw["USD"](50), tfSetNoRipple), delegate::as(bob)); - env(trust(alice, gw["USD"](50), tfClearNoRipple), delegate::as(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetFreeze), delegate::As(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetDeepFreeze), delegate::As(bob)); + env(trust(gw, gw["USD"](0), alice, tfClearDeepFreeze), delegate::As(bob)); + env(trust(gw, gw["USD"](0), alice, tfSetfAuth), delegate::As(bob)); + env(trust(alice, gw["USD"](50), tfSetNoRipple), delegate::As(bob)); + env(trust(alice, gw["USD"](50), tfClearNoRipple), delegate::As(bob)); } // tfFullyCanonicalSig won't block delegated transaction @@ -1298,7 +1298,7 @@ class Delegate_test : public beast::unit_test::suite env(delegate::set(gw, bob, {"TrustlineAuthorize"})); env.close(); env(trust(gw, gw["USD"](0), alice, tfSetfAuth | tfFullyCanonicalSig), - delegate::as(bob)); + delegate::As(bob)); } } @@ -1334,7 +1334,7 @@ class Delegate_test : public beast::unit_test::suite // correct permission for domain set env(delegate::set(alice, bob, {"TrustlineUnfreeze", "AccountEmailHashSet"})); env.close(); - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // alice give granular permission of AccountDomainSet to bob env(delegate::set(alice, bob, {"AccountDomainSet"})); @@ -1353,7 +1353,7 @@ class Delegate_test : public beast::unit_test::suite std::string const failDomain = "fail_domain_update"; jt[sfFlags] = tfRequireAuth; jt[sfDomain] = strHex(failDomain); - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // reset flag number jt[sfFlags] = 0; @@ -1362,7 +1362,7 @@ class Delegate_test : public beast::unit_test::suite jt[sfDomain] = strHex(domain); std::string const mh("5F31A79367DC3137FADA860C05742EE6"); jt[sfEmailHash] = mh; - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // alice give granular permission of AccountEmailHashSet to bob env(delegate::set(alice, bob, {"AccountDomainSet", "AccountEmailHashSet"})); @@ -1372,9 +1372,9 @@ class Delegate_test : public beast::unit_test::suite BEAST_EXPECT((*env.le(alice))[sfDomain] == makeSlice(domain)); // bob does not have permission to set message key for alice - auto const rkp = randomKeyPair(KeyType::ed25519); + auto const rkp = randomKeyPair(KeyType::Ed25519); jt[sfMessageKey] = strHex(rkp.first.slice()); - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // alice give granular permission of AccountMessageKeySet to bob env(delegate::set( @@ -1389,7 +1389,7 @@ class Delegate_test : public beast::unit_test::suite BEAST_EXPECT(!env.le(alice)->isFieldPresent(sfMessageKey)); // bob does not have permission to set transfer rate for alice - env(rate(alice, 2.0), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(rate(alice, 2.0), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // alice give granular permission of AccountTransferRateSet to bob env(delegate::set( @@ -1402,12 +1402,12 @@ class Delegate_test : public beast::unit_test::suite env.close(); auto jtRate = rate(alice, 2.0); jtRate[sfDelegate] = bob.human(); - env(jtRate, delegate::as(bob)); + env(jtRate, delegate::As(bob)); BEAST_EXPECT((*env.le(alice))[sfTransferRate] == 2000000000); // bob does not have permission to set ticksize for alice jt[sfTickSize] = 8; - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // alice give granular permission of AccountTickSizeSet to bob env(delegate::set( @@ -1423,22 +1423,22 @@ class Delegate_test : public beast::unit_test::suite BEAST_EXPECT((*env.le(alice))[sfTickSize] == 8); // can not set asfRequireAuth flag for alice - env(fset(alice, asfRequireAuth), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fset(alice, asfRequireAuth), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // reset Delegate will delete the Delegate // object env(delegate::set(alice, bob, {})); // bib still does not have permission to set asfRequireAuth for // alice - env(fset(alice, asfRequireAuth), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fset(alice, asfRequireAuth), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // alice can set for herself env(fset(alice, asfRequireAuth)); - env.require(flags(alice, asfRequireAuth)); + env.require(Flags(alice, asfRequireAuth)); env.close(); // can not update tick size because bob no longer has permission jt[sfTickSize] = 7; - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); env(delegate::set( alice, bob, {"AccountDomainSet", "AccountEmailHashSet", "AccountMessageKeySet"})); @@ -1452,7 +1452,7 @@ class Delegate_test : public beast::unit_test::suite jv2[sfDomain] = strHex(domain); jv2[sfDelegate] = bob.human(); jv2[sfWalletLocator] = locator; - env(jv2, ter(terNO_DELEGATE_PERMISSION)); + env(jv2, Ter(terNO_DELEGATE_PERMISSION)); } // can not set AccountSet flags on behalf of other account @@ -1465,13 +1465,13 @@ class Delegate_test : public beast::unit_test::suite auto testSetClearFlag = [&](std::uint32_t flag) { // bob can not set flag on behalf of alice - env(fset(alice, flag), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fset(alice, flag), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // alice set by herself env(fset(alice, flag)); env.close(); - env.require(flags(alice, flag)); + env.require(Flags(alice, flag)); // bob can not clear on behalf of alice - env(fclear(alice, flag), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fclear(alice, flag), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); }; // testSetClearFlag(asfNoFreeze); @@ -1494,17 +1494,17 @@ class Delegate_test : public beast::unit_test::suite testSetClearFlag(asfGlobalFreeze); // bob can not set asfAccountTxnID on behalf of alice - env(fset(alice, asfAccountTxnID), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fset(alice, asfAccountTxnID), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env(fset(alice, asfAccountTxnID)); env.close(); BEAST_EXPECT(env.le(alice)->isFieldPresent(sfAccountTxnID)); - env(fclear(alice, asfAccountTxnID), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fclear(alice, asfAccountTxnID), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // bob can not set asfAuthorizedNFTokenMinter on behalf of alice - Json::Value jt = fset(alice, asfAuthorizedNFTokenMinter); + json::Value jt = fset(alice, asfAuthorizedNFTokenMinter); jt[sfDelegate] = bob.human(); jt[sfNFTokenMinter] = bob.human(); - env(jt, ter(terNO_DELEGATE_PERMISSION)); + env(jt, Ter(terNO_DELEGATE_PERMISSION)); // bob gives alice some permissions env(delegate::set( @@ -1514,21 +1514,21 @@ class Delegate_test : public beast::unit_test::suite // since we can not set asfNoFreeze if asfAllowTrustLineClawback is // set, which can not be clear either. Test alice set asfNoFreeze on // behalf of bob. - env(fset(alice, asfNoFreeze), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fset(alice, asfNoFreeze), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); env(fset(bob, asfNoFreeze)); env.close(); - env.require(flags(bob, asfNoFreeze)); + env.require(Flags(bob, asfNoFreeze)); // alice can not clear on behalf of bob - env(fclear(alice, asfNoFreeze), delegate::as(bob), ter(terNO_DELEGATE_PERMISSION)); + env(fclear(alice, asfNoFreeze), delegate::As(bob), Ter(terNO_DELEGATE_PERMISSION)); // bob can not set asfDisableMaster on behalf of alice - Account const bobKey{"bobKey", KeyType::secp256k1}; + Account const bobKey{"bobKey", KeyType::Secp256k1}; env(regkey(bob, bobKey)); env.close(); env(fset(alice, asfDisableMaster), - delegate::as(bob), - sig(bob), - ter(terNO_DELEGATE_PERMISSION)); + delegate::As(bob), + Sig(bob), + Ter(terNO_DELEGATE_PERMISSION)); } // tfFullyCanonicalSig won't block delegated transaction @@ -1693,7 +1693,7 @@ class Delegate_test : public beast::unit_test::suite auto bobBalance = env.balance(bob); auto carolBalance = env.balance(carol); - env(pay(alice, carol, XRP(100)), fee(XRP(10)), delegate::as(bob), sig(bob)); + env(pay(alice, carol, XRP(100)), Fee(XRP(10)), delegate::As(bob), Sig(bob)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance - XRP(100)); BEAST_EXPECT(env.balance(bob) == bobBalance - XRP(10)); @@ -1722,10 +1722,10 @@ class Delegate_test : public beast::unit_test::suite auto carolBalance = env.balance(carol); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - sig(alice), - ter(tefBAD_AUTH)); + Fee(XRP(10)), + delegate::As(bob), + Sig(alice), + Ter(tefBAD_AUTH)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -1748,20 +1748,20 @@ class Delegate_test : public beast::unit_test::suite auto carolBalance = env.balance(carol); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - sig(carol), - ter(terNO_DELEGATE_PERMISSION)); + Fee(XRP(10)), + delegate::As(bob), + Sig(carol), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); BEAST_EXPECT(env.balance(carol) == carolBalance); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - sig(alice), - ter(terNO_DELEGATE_PERMISSION)); + Fee(XRP(10)), + delegate::As(bob), + Sig(alice), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -1781,20 +1781,20 @@ class Delegate_test : public beast::unit_test::suite auto carolBalance = env.balance(carol); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - sig(alice), - ter(terNO_DELEGATE_PERMISSION)); + Fee(XRP(10)), + delegate::As(bob), + Sig(alice), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); BEAST_EXPECT(env.balance(carol) == carolBalance); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - sig(carol), - ter(terNO_DELEGATE_PERMISSION)); + Fee(XRP(10)), + delegate::As(bob), + Sig(carol), + Ter(terNO_DELEGATE_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -1829,7 +1829,7 @@ class Delegate_test : public beast::unit_test::suite auto dariaBalance = env.balance(daria); auto edwardBalance = env.balance(edward); - env(pay(alice, carol, XRP(100)), fee(XRP(10)), delegate::as(bob), msig(daria, edward)); + env(pay(alice, carol, XRP(100)), Fee(XRP(10)), delegate::As(bob), Msig(daria, edward)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance - XRP(100)); BEAST_EXPECT(env.balance(bob) == bobBalance - XRP(10)); @@ -1867,10 +1867,10 @@ class Delegate_test : public beast::unit_test::suite auto edwardBalance = env.balance(edward); env(pay(alice, carol, XRP(100)), - fee(XRP(10)), - delegate::as(bob), - msig(daria, edward), - ter(tefBAD_QUORUM)); + Fee(XRP(10)), + delegate::As(bob), + Msig(daria, edward), + Ter(tefBAD_QUORUM)); env.close(); BEAST_EXPECT(env.balance(alice) == aliceBalance); BEAST_EXPECT(env.balance(bob) == bobBalance); @@ -1892,16 +1892,16 @@ class Delegate_test : public beast::unit_test::suite env.fund(XRP(100000), alice, bob); env.close(); - auto buildRequest = [&](auto value) -> Json::Value { - Json::Value jv; + auto buildRequest = [&](auto value) -> json::Value { + json::Value jv; jv[jss::TransactionType] = jss::DelegateSet; jv[jss::Account] = alice.human(); jv[sfAuthorize.jsonName] = bob.human(); - Json::Value permissionsJson(Json::arrayValue); - Json::Value permissionValue; + json::Value permissionsJson(json::ArrayValue); + json::Value permissionValue; permissionValue[sfPermissionValue.jsonName] = value; - Json::Value permissionObj; + json::Value permissionObj; permissionObj[sfPermission.jsonName] = permissionValue; permissionsJson.append(permissionObj); jv[sfPermissions.jsonName] = permissionsJson; @@ -1914,7 +1914,7 @@ class Delegate_test : public beast::unit_test::suite for (auto value : {0, 100000, 54321}) { auto jv = buildRequest(value); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } } @@ -1973,7 +1973,7 @@ class Delegate_test : public beast::unit_test::suite env.fund(XRP(100000), alice, bob); env.close(); - env(delegate::set(alice, bob, {tx}), ter(temMALFORMED)); + env(delegate::set(alice, bob, {tx}), Ter(temMALFORMED)); }; for (auto const& tx : txRequiredFeatures) @@ -2010,7 +2010,7 @@ class Delegate_test : public beast::unit_test::suite #undef TRANSACTION #define TRANSACTION(tag, value, name, txDelegable, ...) \ - if (txDelegable == xrpl::delegable) \ + if (txDelegable == xrpl::Delegable) \ { \ delegableCount++; \ } @@ -2067,7 +2067,7 @@ class Delegate_test : public beast::unit_test::suite void run() override { - FeatureBitset const all = jtx::testable_amendments(); + FeatureBitset const all = jtx::testableAmendments(); testFeatureDisabled(all - featurePermissionDelegationV1_1); testFeatureDisabled(all); diff --git a/src/test/app/DeliverMin_test.cpp b/src/test/app/DeliverMin_test.cpp index 4b3b6d34ad..eae0893b10 100644 --- a/src/test/app/DeliverMin_test.cpp +++ b/src/test/app/DeliverMin_test.cpp @@ -18,113 +18,113 @@ namespace xrpl::test { -class DeliverMin_test : public beast::unit_test::suite +class DeliverMin_test : public beast::unit_test::Suite { public: void - test_convert_all_of_an_asset(FeatureBitset features) + testConvertAllOfAnAsset(FeatureBitset features) { testcase("Convert all of an asset using DeliverMin"); using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", gw); env.close(); - env.trust(USD(100), "alice", "bob", "carol"); + env.trust(usd(100), "alice", "bob", "carol"); env.close(); - env(pay("alice", "bob", USD(10)), deliver_min(USD(10)), ter(temBAD_AMOUNT)); - env(pay("alice", "bob", USD(10)), - deliver_min(USD(-5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay("alice", "bob", USD(10)), - deliver_min(XRP(5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay("alice", "bob", USD(10)), - deliver_min(Account("carol")["USD"](5)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay("alice", "bob", USD(10)), - deliver_min(USD(15)), - txflags(tfPartialPayment), - ter(temBAD_AMOUNT)); - env(pay(gw, "carol", USD(50))); - env(offer("carol", XRP(5), USD(5))); - env(pay("alice", "bob", USD(10)), - paths(XRP), - deliver_min(USD(7)), - txflags(tfPartialPayment), - sendmax(XRP(5)), - ter(tecPATH_PARTIAL)); - env.require(balance("alice", XRP(10000) - drops(env.current()->fees().base))); - env.require(balance("bob", XRP(10000))); + env(pay("alice", "bob", usd(10)), DeliverMin(usd(10)), Ter(temBAD_AMOUNT)); + env(pay("alice", "bob", usd(10)), + DeliverMin(usd(-5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay("alice", "bob", usd(10)), + DeliverMin(XRP(5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay("alice", "bob", usd(10)), + DeliverMin(Account("carol")["USD"](5)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay("alice", "bob", usd(10)), + DeliverMin(usd(15)), + Txflags(tfPartialPayment), + Ter(temBAD_AMOUNT)); + env(pay(gw, "carol", usd(50))); + env(offer("carol", XRP(5), usd(5))); + env(pay("alice", "bob", usd(10)), + Paths(XRP), + DeliverMin(usd(7)), + Txflags(tfPartialPayment), + Sendmax(XRP(5)), + Ter(tecPATH_PARTIAL)); + env.require(Balance("alice", XRP(10000) - drops(env.current()->fees().base))); + env.require(Balance("bob", XRP(10000))); } { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", gw); env.close(); - env.trust(USD(1000), "alice", "bob"); + env.trust(usd(1000), "alice", "bob"); env.close(); - env(pay(gw, "bob", USD(100))); - env(offer("bob", XRP(100), USD(100))); - env(pay("alice", "alice", USD(10000)), - paths(XRP), - deliver_min(USD(100)), - txflags(tfPartialPayment), - sendmax(XRP(100))); - env.require(balance("alice", USD(100))); + env(pay(gw, "bob", usd(100))); + env(offer("bob", XRP(100), usd(100))); + env(pay("alice", "alice", usd(10000)), + Paths(XRP), + DeliverMin(usd(100)), + Txflags(tfPartialPayment), + Sendmax(XRP(100))); + env.require(Balance("alice", usd(100))); } { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", gw); env.close(); - env.trust(USD(1000), "bob", "carol"); + env.trust(usd(1000), "bob", "carol"); env.close(); - env(pay(gw, "bob", USD(200))); - env(offer("bob", XRP(100), USD(100))); - env(offer("bob", XRP(1000), USD(100))); - env(offer("bob", XRP(10000), USD(100))); - env(pay("alice", "carol", USD(10000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(1000)), - ter(tecPATH_PARTIAL)); - env(pay("alice", "carol", USD(10000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(1100))); - env.require(balance("bob", USD(0))); - env.require(balance("carol", USD(200))); + env(pay(gw, "bob", usd(200))); + env(offer("bob", XRP(100), usd(100))); + env(offer("bob", XRP(1000), usd(100))); + env(offer("bob", XRP(10000), usd(100))); + env(pay("alice", "carol", usd(10000)), + Paths(XRP), + DeliverMin(usd(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(1000)), + Ter(tecPATH_PARTIAL)); + env(pay("alice", "carol", usd(10000)), + Paths(XRP), + DeliverMin(usd(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(1100))); + env.require(Balance("bob", usd(0))); + env.require(Balance("carol", usd(200))); } { Env env(*this, features); env.fund(XRP(10000), "alice", "bob", "carol", "dan", gw); env.close(); - env.trust(USD(1000), "bob", "carol", "dan"); + env.trust(usd(1000), "bob", "carol", "dan"); env.close(); - env(pay(gw, "bob", USD(100))); - env(pay(gw, "dan", USD(100))); - env(offer("bob", XRP(100), USD(100))); - env(offer("bob", XRP(1000), USD(100))); - env(offer("dan", XRP(100), USD(100))); - env(pay("alice", "carol", USD(10000)), - paths(XRP), - deliver_min(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(200))); - env.require(balance("bob", USD(0))); - env.require(balance("carol", USD(200))); - env.require(balance("dan", USD(0))); + env(pay(gw, "bob", usd(100))); + env(pay(gw, "dan", usd(100))); + env(offer("bob", XRP(100), usd(100))); + env(offer("bob", XRP(1000), usd(100))); + env(offer("dan", XRP(100), usd(100))); + env(pay("alice", "carol", usd(10000)), + Paths(XRP), + DeliverMin(usd(200)), + Txflags(tfPartialPayment), + Sendmax(XRP(200))); + env.require(Balance("bob", usd(0))); + env.require(Balance("carol", usd(200))); + env.require(Balance("dan", usd(0))); } } @@ -132,9 +132,9 @@ public: run() override { using namespace jtx; - auto const sa = testable_amendments(); - test_convert_all_of_an_asset(sa - featurePermissionedDEX); - test_convert_all_of_an_asset(sa); + auto const sa = testableAmendments(); + testConvertAllOfAnAsset(sa - featurePermissionedDEX); + testConvertAllOfAnAsset(sa); } }; diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index c9773cba8b..e0b48d8572 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -61,7 +61,7 @@ hasDepositAuth(jtx::Env const& env, jtx::Account const& acct) return ((*env.le(acct))[sfFlags] & lsfDepositAuth) == lsfDepositAuth; } -struct DepositAuth_test : public beast::unit_test::suite +struct DepositAuth_test : public beast::unit_test::Suite { void testEnable() @@ -97,45 +97,45 @@ struct DepositAuth_test : public beast::unit_test::suite Account const bob{"bob"}; Account const carol{"carol"}; Account const gw{"gw"}; - IOU const USD = gw["USD"]; + IOU const usd = gw["USD"]; Env env(*this); env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob); + env.trust(usd(1000), alice, bob); env.close(); - env(pay(gw, alice, USD(150))); - env(offer(carol, USD(100), XRP(100))); + env(pay(gw, alice, usd(150))); + env(offer(carol, usd(100), XRP(100))); env.close(); // Make sure bob's trust line is all set up so he can receive USD. - env(pay(alice, bob, USD(50))); + env(pay(alice, bob, usd(50))); env.close(); // bob sets the lsfDepositAuth flag. - env(fset(bob, asfDepositAuth), require(flags(bob, asfDepositAuth))); + env(fset(bob, asfDepositAuth), Require(Flags(bob, asfDepositAuth))); env.close(); // None of the following payments should succeed. - auto failedIouPayments = [this, &env, &alice, &bob, &USD]() { - env.require(flags(bob, asfDepositAuth)); + auto failedIouPayments = [this, &env, &alice, &bob, &usd]() { + env.require(Flags(bob, asfDepositAuth)); // Capture bob's balances before hand to confirm they don't change. PrettyAmount const bobXrpBalance{env.balance(bob, XRP)}; - PrettyAmount const bobUsdBalance{env.balance(bob, USD)}; + PrettyAmount const bobUsdBalance{env.balance(bob, usd)}; - env(pay(alice, bob, USD(50)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, usd(50)), Ter(tecNO_PERMISSION)); env.close(); // Note that even though alice is paying bob in XRP, the payment // is still not allowed since the payment passes through an offer. - env(pay(alice, bob, drops(1)), sendmax(USD(1)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, drops(1)), Sendmax(usd(1)), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(bobXrpBalance == env.balance(bob, XRP)); - BEAST_EXPECT(bobUsdBalance == env.balance(bob, USD)); + BEAST_EXPECT(bobUsdBalance == env.balance(bob, usd)); }; // Test when bob has an XRP balance > base reserve. @@ -143,23 +143,23 @@ struct DepositAuth_test : public beast::unit_test::suite // Set bob's XRP balance == base reserve. Also demonstrate that // bob can make payments while his lsfDepositAuth flag is set. - env(pay(bob, alice, USD(25))); + env(pay(bob, alice, usd(25))); env.close(); { STAmount const bobPaysXRP{env.balance(bob, XRP) - reserve(env, 1)}; XRPAmount const bobPaysFee{reserve(env, 1) - reserve(env, 0)}; - env(pay(bob, alice, bobPaysXRP), fee(bobPaysFee)); + env(pay(bob, alice, bobPaysXRP), Fee(bobPaysFee)); env.close(); } // Test when bob's XRP balance == base reserve. BEAST_EXPECT(env.balance(bob, XRP) == reserve(env, 0)); - BEAST_EXPECT(env.balance(bob, USD) == USD(25)); + BEAST_EXPECT(env.balance(bob, usd) == usd(25)); failedIouPayments(); // Test when bob has an XRP balance == 0. - env(noop(bob), fee(reserve(env, 0))); + env(noop(bob), Fee(reserve(env, 0))); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == XRP(0)); @@ -172,10 +172,10 @@ struct DepositAuth_test : public beast::unit_test::suite env(fclear(bob, asfDepositAuth)); env.close(); - env(pay(alice, bob, USD(50))); + env(pay(alice, bob, usd(50))); env.close(); - env(pay(alice, bob, drops(1)), sendmax(USD(1))); + env(pay(alice, bob, drops(1)), Sendmax(usd(1))); env.close(); } @@ -197,12 +197,12 @@ struct DepositAuth_test : public beast::unit_test::suite env.close(); // bob sets the lsfDepositAuth flag. - env(fset(bob, asfDepositAuth), fee(drops(baseFee))); + env(fset(bob, asfDepositAuth), Fee(drops(baseFee))); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(baseFee)); // bob has more XRP than the base reserve. Any XRP payment should fail. - env(pay(alice, bob, drops(1)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, drops(1)), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == XRP(10000) - drops(baseFee)); @@ -210,7 +210,7 @@ struct DepositAuth_test : public beast::unit_test::suite { STAmount const bobPaysXRP{env.balance(bob, XRP) - reserve(env, 1)}; XRPAmount const bobPaysFee{reserve(env, 1) - reserve(env, 0)}; - env(pay(bob, alice, bobPaysXRP), fee(bobPaysFee)); + env(pay(bob, alice, bobPaysXRP), Fee(bobPaysFee)); env.close(); } @@ -222,16 +222,16 @@ struct DepositAuth_test : public beast::unit_test::suite // bob has exactly the base reserve + 1. No payment should succeed. BEAST_EXPECT(env.balance(bob, XRP) == reserve(env, 0) + drops(1)); - env(pay(alice, bob, drops(1)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, drops(1)), Ter(tecNO_PERMISSION)); env.close(); // Take bob down to a balance of 0 XRP. - env(noop(bob), fee(reserve(env, 0) + drops(1))); + env(noop(bob), Fee(reserve(env, 0) + drops(1))); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == drops(0)); // We should not be able to pay bob more than the base reserve. - env(pay(alice, bob, reserve(env, 0) + drops(1)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, reserve(env, 0) + drops(1)), Ter(tecNO_PERMISSION)); env.close(); // However a payment of exactly the base reserve should succeed. @@ -245,17 +245,17 @@ struct DepositAuth_test : public beast::unit_test::suite BEAST_EXPECT(env.balance(bob, XRP) == (reserve(env, 0) + reserve(env, 0))); // bob's above the threshold again. Any payment should fail. - env(pay(alice, bob, drops(1)), ter(tecNO_PERMISSION)); + env(pay(alice, bob, drops(1)), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == (reserve(env, 0) + reserve(env, 0))); // Take bob back down to a zero XRP balance. - env(noop(bob), fee(env.balance(bob, XRP))); + env(noop(bob), Fee(env.balance(bob, XRP))); env.close(); BEAST_EXPECT(env.balance(bob, XRP) == drops(0)); // bob should not be able to clear lsfDepositAuth. - env(fclear(bob, asfDepositAuth), ter(terINSUF_FEE_B)); + env(fclear(bob, asfDepositAuth), Ter(terINSUF_FEE_B)); env.close(); // We should be able to pay bob 1 drop now. @@ -271,7 +271,7 @@ struct DepositAuth_test : public beast::unit_test::suite // request to clear lsfDepositAuth. So the balance should be zero // and lsfDepositAuth should be cleared. BEAST_EXPECT(env.balance(bob, XRP) == drops(0)); - env.require(nflags(bob, asfDepositAuth)); + env.require(Nflags(bob, asfDepositAuth)); // Since bob no longer has lsfDepositAuth set we should be able to // pay him more than the base reserve. @@ -294,8 +294,8 @@ struct DepositAuth_test : public beast::unit_test::suite Account const alice("alice"); Account const bob("bob"); - IOU const USD1(gw1["USD"]); - IOU const USD2(gw2["USD"]); + IOU const usD1(gw1["USD"]); + IOU const usD2(gw2["USD"]); auto testIssuer = [&](FeatureBitset const& features, bool noRipplePrev, @@ -307,15 +307,15 @@ struct DepositAuth_test : public beast::unit_test::suite env.close(); env(trust(gw1, alice["USD"](10), noRipplePrev ? tfSetNoRipple : 0)); env(trust(gw1, bob["USD"](10), noRippleNext ? tfSetNoRipple : 0)); - env.trust(USD1(10), alice, bob); + env.trust(usD1(10), alice, bob); - env(pay(gw1, alice, USD1(10))); + env(pay(gw1, alice, usD1(10))); if (withDepositAuth) env(fset(gw1, asfDepositAuth)); TER const result = (noRippleNext && noRipplePrev) ? TER{tecPATH_DRY} : TER{tesSUCCESS}; - env(pay(alice, bob, USD1(10)), path(gw1), ter(result)); + env(pay(alice, bob, usD1(10)), Path(gw1), Ter(result)); }; auto testNonIssuer = [&](FeatureBitset const& features, @@ -326,15 +326,15 @@ struct DepositAuth_test : public beast::unit_test::suite env.fund(XRP(10000), gw1, gw2, alice); env.close(); - env(trust(alice, USD1(10), noRipplePrev ? tfSetNoRipple : 0)); - env(trust(alice, USD2(10), noRippleNext ? tfSetNoRipple : 0)); - env(pay(gw2, alice, USD2(10))); + env(trust(alice, usD1(10), noRipplePrev ? tfSetNoRipple : 0)); + env(trust(alice, usD2(10), noRippleNext ? tfSetNoRipple : 0)); + env(pay(gw2, alice, usD2(10))); if (withDepositAuth) env(fset(alice, asfDepositAuth)); TER const result = (noRippleNext && noRipplePrev) ? TER{tecPATH_DRY} : TER{tesSUCCESS}; - env(pay(gw1, gw2, USD2(10)), path(alice), sendmax(USD1(10)), ter(result)); + env(pay(gw1, gw2, usD2(10)), Path(alice), Sendmax(usD1(10)), Ter(result)); }; // Test every combo of noRipplePrev, noRippleNext, and withDepositAuth @@ -344,10 +344,10 @@ struct DepositAuth_test : public beast::unit_test::suite auto const noRippleNext = i & 0x2; auto const withDepositAuth = i & 0x4; testIssuer( - testable_amendments(), noRipplePrev != 0, noRippleNext != 0, withDepositAuth != 0); + testableAmendments(), noRipplePrev != 0, noRippleNext != 0, withDepositAuth != 0); testNonIssuer( - testable_amendments(), noRipplePrev != 0, noRippleNext != 0, withDepositAuth != 0); + testableAmendments(), noRipplePrev != 0, noRippleNext != 0, withDepositAuth != 0); } } @@ -361,16 +361,16 @@ struct DepositAuth_test : public beast::unit_test::suite } }; -static Json::Value +static json::Value ledgerEntryDepositPreauth( jtx::Env& env, jtx::Account const& acc, std::vector const& auth) { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::deposit_preauth][jss::owner] = acc.human(); - jvParams[jss::deposit_preauth][jss::authorized_credentials] = Json::arrayValue; + jvParams[jss::deposit_preauth][jss::authorized_credentials] = json::ArrayValue; auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]); for (auto const& o : auth) { @@ -379,7 +379,7 @@ ledgerEntryDepositPreauth( return env.rpc("json", "ledger_entry", to_string(jvParams)); } -struct DepositPreauth_test : public beast::unit_test::suite +struct DepositPreauth_test : public beast::unit_test::Suite { void testEnable() @@ -400,14 +400,14 @@ struct DepositPreauth_test : public beast::unit_test::suite // Add a DepositPreauth to alice. env(deposit::auth(alice, becky)); env.close(); - env.require(owners(alice, 1)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 1)); + env.require(Owners(becky, 0)); // Remove a DepositPreauth from alice. env(deposit::unauth(alice, becky)); env.close(); - env.require(owners(alice, 0)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 0)); + env.require(Owners(becky, 0)); } { // Verify that an account can be preauthorized and unauthorized @@ -425,21 +425,21 @@ struct DepositPreauth_test : public beast::unit_test::suite std::uint32_t aliceTicketSeq{env.seq(alice)}; // Add a DepositPreauth to alice. - env(deposit::auth(alice, becky), ticket::use(--aliceTicketSeq)); + env(deposit::auth(alice, becky), ticket::Use(--aliceTicketSeq)); env.close(); // Alice uses a ticket but gains a preauth entry. env.require(tickets(alice, 1)); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(becky, 0)); + env.require(Owners(becky, 0)); // Remove a DepositPreauth from alice. - env(deposit::unauth(alice, becky), ticket::use(--aliceTicketSeq)); + env(deposit::unauth(alice, becky), ticket::Use(--aliceTicketSeq)); env.close(); env.require(tickets(alice, 0)); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); BEAST_EXPECT(env.seq(alice) == aliceSeq); - env.require(owners(becky, 0)); + env.require(Owners(becky, 0)); } } @@ -461,104 +461,104 @@ struct DepositPreauth_test : public beast::unit_test::suite env.memoize(carol); // Add DepositPreauth to an unfunded account. - env(deposit::auth(alice, becky), seq(1), ter(terNO_ACCOUNT)); + env(deposit::auth(alice, becky), Seq(1), Ter(terNO_ACCOUNT)); env.fund(XRP(10000), alice, becky); env.close(); // Bad fee. - env(deposit::auth(alice, becky), fee(drops(-10)), ter(temBAD_FEE)); + env(deposit::auth(alice, becky), Fee(drops(-10)), Ter(temBAD_FEE)); env.close(); // Bad flags. - env(deposit::auth(alice, becky), txflags(tfSell), ter(temINVALID_FLAG)); + env(deposit::auth(alice, becky), Txflags(tfSell), Ter(temINVALID_FLAG)); env.close(); { // Neither auth not unauth. - Json::Value tx{deposit::auth(alice, becky)}; + json::Value tx{deposit::auth(alice, becky)}; tx.removeMember(sfAuthorize.jsonName); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); env.close(); } { // Both auth and unauth. - Json::Value tx{deposit::auth(alice, becky)}; + json::Value tx{deposit::auth(alice, becky)}; tx[sfUnauthorize.jsonName] = becky.human(); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); env.close(); } { // Alice authorizes a zero account. - Json::Value tx{deposit::auth(alice, becky)}; + json::Value tx{deposit::auth(alice, becky)}; tx[sfAuthorize.jsonName] = to_string(xrpAccount()); - env(tx, ter(temINVALID_ACCOUNT_ID)); + env(tx, Ter(temINVALID_ACCOUNT_ID)); env.close(); } // alice authorizes herself. - env(deposit::auth(alice, alice), ter(temCANNOT_PREAUTH_SELF)); + env(deposit::auth(alice, alice), Ter(temCANNOT_PREAUTH_SELF)); env.close(); // alice authorizes an unfunded account. - env(deposit::auth(alice, carol), ter(tecNO_TARGET)); + env(deposit::auth(alice, carol), Ter(tecNO_TARGET)); env.close(); // alice successfully authorizes becky. - env.require(owners(alice, 0)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 0)); + env.require(Owners(becky, 0)); env(deposit::auth(alice, becky)); env.close(); - env.require(owners(alice, 1)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 1)); + env.require(Owners(becky, 0)); // alice attempts to create a duplicate authorization. - env(deposit::auth(alice, becky), ter(tecDUPLICATE)); + env(deposit::auth(alice, becky), Ter(tecDUPLICATE)); env.close(); - env.require(owners(alice, 1)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 1)); + env.require(Owners(becky, 0)); // carol attempts to preauthorize but doesn't have enough reserve. env.fund(drops(249'999'999), carol); env.close(); - env(deposit::auth(carol, becky), ter(tecINSUFFICIENT_RESERVE)); + env(deposit::auth(carol, becky), Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(carol, 0)); - env.require(owners(becky, 0)); + env.require(Owners(carol, 0)); + env.require(Owners(becky, 0)); // carol gets enough XRP to (barely) meet the reserve. env(pay(alice, carol, drops(env.current()->fees().base + 1))); env.close(); env(deposit::auth(carol, becky)); env.close(); - env.require(owners(carol, 1)); - env.require(owners(becky, 0)); + env.require(Owners(carol, 1)); + env.require(Owners(becky, 0)); // But carol can't meet the reserve for another pre-authorization. - env(deposit::auth(carol, alice), ter(tecINSUFFICIENT_RESERVE)); + env(deposit::auth(carol, alice), Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(carol, 1)); - env.require(owners(becky, 0)); - env.require(owners(alice, 1)); + env.require(Owners(carol, 1)); + env.require(Owners(becky, 0)); + env.require(Owners(alice, 1)); // alice attempts to remove an authorization she doesn't have. - env(deposit::unauth(alice, carol), ter(tecNO_ENTRY)); + env(deposit::unauth(alice, carol), Ter(tecNO_ENTRY)); env.close(); - env.require(owners(alice, 1)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 1)); + env.require(Owners(becky, 0)); // alice successfully removes her authorization of becky. env(deposit::unauth(alice, becky)); env.close(); - env.require(owners(alice, 0)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 0)); + env.require(Owners(becky, 0)); // alice removes becky again and gets an error. - env(deposit::unauth(alice, becky), ter(tecNO_ENTRY)); + env(deposit::unauth(alice, becky), Ter(tecNO_ENTRY)); env.close(); - env.require(owners(alice, 0)); - env.require(owners(becky, 0)); + env.require(Owners(alice, 0)); + env.require(Owners(becky, 0)); } void @@ -570,7 +570,7 @@ struct DepositPreauth_test : public beast::unit_test::suite Account const alice{"alice"}; Account const becky{"becky"}; Account const gw{"gw"}; - IOU const USD(gw["USD"]); + IOU const usd(gw["USD"]); { // The initial implementation of DepositAuth had a bug where an @@ -580,19 +580,19 @@ struct DepositPreauth_test : public beast::unit_test::suite env.fund(XRP(5000), alice, becky, gw); env.close(); - env.trust(USD(1000), alice); - env.trust(USD(1000), becky); + env.trust(usd(1000), alice); + env.trust(usd(1000), becky); env.close(); - env(pay(gw, alice, USD(500))); + env(pay(gw, alice, usd(500))); env.close(); - env(offer(alice, XRP(100), USD(100), tfPassive), require(offers(alice, 1))); + env(offer(alice, XRP(100), usd(100), tfPassive), Require(offers(alice, 1))); env.close(); // becky pays herself USD (10) by consuming part of alice's offer. // Make sure the payment works if PaymentAuth is not involved. - env(pay(becky, becky, USD(10)), path(~USD), sendmax(XRP(10))); + env(pay(becky, becky, usd(10)), Path(~usd), Sendmax(XRP(10))); env.close(); // becky decides to require authorization for deposits. @@ -600,7 +600,7 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // becky pays herself again. - env(pay(becky, becky, USD(10)), path(~USD), sendmax(XRP(10)), ter(tesSUCCESS)); + env(pay(becky, becky, usd(10)), Path(~usd), Sendmax(XRP(10)), Ter(tesSUCCESS)); env.close(); { @@ -614,13 +614,13 @@ struct DepositPreauth_test : public beast::unit_test::suite TER const expectTer(!supportsCredentials ? TER(temDISABLED) : TER(tesSUCCESS)); - env(deposit::authCredentials(becky, {{carol, credType}}), ter(expectTer)); + env(deposit::authCredentials(becky, {{carol, credType}}), Ter(expectTer)); env.close(); // gw accept credentials - env(credentials::create(gw, carol, credType), ter(expectTer)); + env(credentials::create(gw, carol, credType), Ter(expectTer)); env.close(); - env(credentials::accept(gw, carol, credType), ter(expectTer)); + env(credentials::accept(gw, carol, credType), Ter(expectTer)); env.close(); auto jv = credentials::ledgerEntry(env, gw, carol, credType); @@ -629,7 +629,7 @@ struct DepositPreauth_test : public beast::unit_test::suite : "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6" "EA288BE4"; - env(pay(gw, becky, USD(100)), credentials::ids({credIdx}), ter(expectTer)); + env(pay(gw, becky, usd(100)), credentials::Ids({credIdx}), Ter(expectTer)); env.close(); } } @@ -642,17 +642,17 @@ struct DepositPreauth_test : public beast::unit_test::suite env.fund(XRP(5000), alice, becky, carol, gw); env.close(); - env.trust(USD(1000), alice); - env.trust(USD(1000), becky); - env.trust(USD(1000), carol); + env.trust(usd(1000), alice); + env.trust(usd(1000), becky); + env.trust(usd(1000), carol); env.close(); - env(pay(gw, alice, USD(1000))); + env(pay(gw, alice, usd(1000))); env.close(); // Make XRP and IOU payments from alice to becky. Should be fine. env(pay(alice, becky, XRP(100))); - env(pay(alice, becky, USD(100))); + env(pay(alice, becky, usd(100))); env.close(); // becky decides to require authorization for deposits. @@ -660,8 +660,8 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // alice can no longer pay becky. - env(pay(alice, becky, XRP(100)), ter(tecNO_PERMISSION)); - env(pay(alice, becky, USD(100)), ter(tecNO_PERMISSION)); + env(pay(alice, becky, XRP(100)), Ter(tecNO_PERMISSION)); + env(pay(alice, becky, usd(100)), Ter(tecNO_PERMISSION)); env.close(); // becky preauthorizes carol for deposit, which doesn't provide @@ -670,8 +670,8 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // alice still can't pay becky. - env(pay(alice, becky, XRP(100)), ter(tecNO_PERMISSION)); - env(pay(alice, becky, USD(100)), ter(tecNO_PERMISSION)); + env(pay(alice, becky, XRP(100)), Ter(tecNO_PERMISSION)); + env(pay(alice, becky, usd(100)), Ter(tecNO_PERMISSION)); env.close(); // becky preauthorizes alice for deposit. @@ -680,7 +680,7 @@ struct DepositPreauth_test : public beast::unit_test::suite // alice can now pay becky. env(pay(alice, becky, XRP(100))); - env(pay(alice, becky, USD(100))); + env(pay(alice, becky, usd(100))); env.close(); // alice decides to require authorization for deposits. @@ -689,8 +689,8 @@ struct DepositPreauth_test : public beast::unit_test::suite // Even though alice is authorized to pay becky, becky is not // authorized to pay alice. - env(pay(becky, alice, XRP(100)), ter(tecNO_PERMISSION)); - env(pay(becky, alice, USD(100)), ter(tecNO_PERMISSION)); + env(pay(becky, alice, XRP(100)), Ter(tecNO_PERMISSION)); + env(pay(becky, alice, usd(100)), Ter(tecNO_PERMISSION)); env.close(); // becky unauthorizes carol. Should have no impact on alice. @@ -698,15 +698,15 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); env(pay(alice, becky, XRP(100))); - env(pay(alice, becky, USD(100))); + env(pay(alice, becky, usd(100))); env.close(); // becky unauthorizes alice. alice now can't pay becky. env(deposit::unauth(becky, alice)); env.close(); - env(pay(alice, becky, XRP(100)), ter(tecNO_PERMISSION)); - env(pay(alice, becky, USD(100)), ter(tecNO_PERMISSION)); + env(pay(alice, becky, XRP(100)), Ter(tecNO_PERMISSION)); + env(pay(alice, becky, usd(100)), Ter(tecNO_PERMISSION)); env.close(); // becky decides to remove authorization for deposits. Now @@ -715,7 +715,7 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); env(pay(alice, becky, XRP(100))); - env(pay(alice, becky, USD(100))); + env(pay(alice, becky, usd(100))); env.close(); } @@ -734,7 +734,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { testcase("Payment failure with disabled credentials rule."); - Env env(*this, testable_amendments() - featureCredentials); + Env env(*this, testableAmendments() - featureCredentials); env.fund(XRP(5000), issuer, bob, alice); env.close(); @@ -744,7 +744,7 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // Setup DepositPreauth object failed - amendent is not supported - env(deposit::authCredentials(bob, {{issuer, credType}}), ter(temDISABLED)); + env(deposit::authCredentials(bob, {{issuer, credType}}), Ter(temDISABLED)); env.close(); // But can create old DepositPreauth @@ -756,7 +756,7 @@ struct DepositPreauth_test : public beast::unit_test::suite std::string const invalidIdx = "0E0B04ED60588A758B67E21FBBE95AC5A63598BA951761DC0EC9C08D7E" "01E034"; - env(pay(alice, bob, XRP(10)), credentials::ids({invalidIdx}), ter(temDISABLED)); + env(pay(alice, bob, XRP(10)), credentials::Ids({invalidIdx}), Ter(temDISABLED)); env.close(); } @@ -795,13 +795,13 @@ struct DepositPreauth_test : public beast::unit_test::suite // Alice can't pay - empty credentials array { auto jv = pay(alice, bob, XRP(100)); - jv[sfCredentialIDs.jsonName] = Json::arrayValue; - env(jv, ter(temMALFORMED)); + jv[sfCredentialIDs.jsonName] = json::ArrayValue; + env(jv, Ter(temMALFORMED)); env.close(); } // Alice can't pay - not accepted credentials - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx}), ter(tecBAD_CREDENTIALS)); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx}), Ter(tecBAD_CREDENTIALS)); env.close(); // Alice accept the credentials @@ -809,18 +809,18 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // Now Alice can pay - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx})); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx})); env.close(); // Alice can pay Maria without depositPreauth enabled - env(pay(alice, maria, XRP(250)), credentials::ids({credIdx})); + env(pay(alice, maria, XRP(250)), credentials::Ids({credIdx})); env.close(); // john can accept payment with old depositPreauth and valid // credentials env(fset(john, asfDepositAuth)); env(deposit::auth(john, alice)); - env(pay(alice, john, XRP(100)), credentials::ids({credIdx})); + env(pay(alice, john, XRP(100)), credentials::Ids({credIdx})); env.close(); } @@ -845,7 +845,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { // Success as destination didn't enable pre-authorization so // valid credentials will not fail - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx})); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx})); } // Bob require pre-authorization @@ -854,12 +854,12 @@ struct DepositPreauth_test : public beast::unit_test::suite { // Fail as destination didn't setup DepositPreauth object - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx}), ter(tecNO_PERMISSION)); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx}), Ter(tecNO_PERMISSION)); } // Bob setup DepositPreauth object, duplicates is not allowed env(deposit::authCredentials(bob, {{issuer, credType}, {issuer, credType}}), - ter(temMALFORMED)); + Ter(temMALFORMED)); // Bob setup DepositPreauth object env(deposit::authCredentials(bob, {{issuer, credType}})); @@ -871,15 +871,15 @@ struct DepositPreauth_test : public beast::unit_test::suite "01E034"; // Alice can't pay with non-existing credentials env(pay(alice, bob, XRP(100)), - credentials::ids({invalidIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({invalidIdx}), + Ter(tecBAD_CREDENTIALS)); } { // maria can't pay using valid credentials but issued for // different account env(pay(maria, bob, XRP(100)), - credentials::ids({credIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Ter(tecBAD_CREDENTIALS)); } { @@ -894,15 +894,15 @@ struct DepositPreauth_test : public beast::unit_test::suite // Alice can't pay with invalid set of valid credentials env(pay(alice, bob, XRP(100)), - credentials::ids({credIdx, credIdx2}), - ter(tecNO_PERMISSION)); + credentials::Ids({credIdx, credIdx2}), + Ter(tecNO_PERMISSION)); } // Error, duplicate credentials - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx, credIdx}), ter(temMALFORMED)); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx, credIdx}), Ter(temMALFORMED)); // Alice can pay - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx})); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx})); env.close(); } } @@ -929,62 +929,62 @@ struct DepositPreauth_test : public beast::unit_test::suite { // both included [AuthorizeCredentials UnauthorizeCredentials] auto jv = deposit::authCredentials(bob, {{issuer, credType}}); - jv[sfUnauthorizeCredentials.jsonName] = Json::arrayValue; - env(jv, ter(temMALFORMED)); + jv[sfUnauthorizeCredentials.jsonName] = json::ArrayValue; + env(jv, Ter(temMALFORMED)); } { // both included [Unauthorize, AuthorizeCredentials] auto jv = deposit::authCredentials(bob, {{issuer, credType}}); jv[sfUnauthorize.jsonName] = issuer.human(); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { // both included [Authorize, AuthorizeCredentials] auto jv = deposit::authCredentials(bob, {{issuer, credType}}); jv[sfAuthorize.jsonName] = issuer.human(); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { // both included [Unauthorize, UnauthorizeCredentials] auto jv = deposit::unauthCredentials(bob, {{issuer, credType}}); jv[sfUnauthorize.jsonName] = issuer.human(); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { // both included [Authorize, UnauthorizeCredentials] auto jv = deposit::unauthCredentials(bob, {{issuer, credType}}); jv[sfAuthorize.jsonName] = issuer.human(); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { // AuthorizeCredentials is empty auto jv = deposit::authCredentials(bob, {}); - env(jv, ter(temARRAY_EMPTY)); + env(jv, Ter(temARRAY_EMPTY)); } { // invalid issuer auto jv = deposit::authCredentials(bob, {}); auto& arr(jv[sfAuthorizeCredentials.jsonName]); - Json::Value cred = Json::objectValue; + json::Value cred = json::ObjectValue; cred[jss::Issuer] = to_string(xrpAccount()); cred[sfCredentialType.jsonName] = strHex(std::string_view(credType)); - Json::Value credParent; + json::Value credParent; credParent[jss::Credential] = cred; arr.append(std::move(credParent)); - env(jv, ter(temINVALID_ACCOUNT_ID)); + env(jv, Ter(temINVALID_ACCOUNT_ID)); } { // empty credential type auto jv = deposit::authCredentials(bob, {{issuer, {}}}); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } { @@ -994,14 +994,14 @@ struct DepositPreauth_test : public beast::unit_test::suite auto const& z = credType; auto jv = deposit::authCredentials( bob, {{a, z}, {b, z}, {c, z}, {d, z}, {e, z}, {f, z}, {g, z}, {h, z}, {i, z}}); - env(jv, ter(temARRAY_TOO_LARGE)); + env(jv, Ter(temARRAY_TOO_LARGE)); } { // Can't create with non-existing issuer Account const rick{"rick"}; auto jv = deposit::authCredentials(bob, {{rick, credType}}); - env(jv, ter(tecNO_ISSUER)); + env(jv, Ter(tecNO_ISSUER)); env.close(); } @@ -1011,12 +1011,12 @@ struct DepositPreauth_test : public beast::unit_test::suite env.fund(env.current()->fees().accountReserve(0), john); env.close(); auto jv = deposit::authCredentials(john, {{issuer, credType}}); - env(jv, ter(tecINSUFFICIENT_RESERVE)); + env(jv, Ter(tecINSUFFICIENT_RESERVE)); } { // NO deposit object exists - env(deposit::unauthCredentials(bob, {{issuer, credType}}), ter(tecNO_ENTRY)); + env(deposit::unauthCredentials(bob, {{issuer, credType}}), Ter(tecNO_ENTRY)); } // Create DepositPreauth object @@ -1045,7 +1045,7 @@ struct DepositPreauth_test : public beast::unit_test::suite } // can't create duplicate - env(deposit::authCredentials(bob, {{issuer, credType}}), ter(tecDUPLICATE)); + env(deposit::authCredentials(bob, {{issuer, credType}}), Ter(tecDUPLICATE)); } // Delete DepositPreauth object @@ -1071,7 +1071,7 @@ struct DepositPreauth_test : public beast::unit_test::suite Account const alice{"alice"}; Account const bob{"bob"}; Account const gw{"gw"}; - IOU const USD = gw["USD"]; + IOU const usd = gw["USD"]; Account const zelda{"zelda"}; { @@ -1124,14 +1124,14 @@ struct DepositPreauth_test : public beast::unit_test::suite { // Alice can pay - env(pay(alice, bob, XRP(100)), credentials::ids({credIdx, credIdx2})); + env(pay(alice, bob, XRP(100)), credentials::Ids({credIdx, credIdx2})); env.close(); env.close(); // Ledger closed, time increased, alice can't pay anymore env(pay(alice, bob, XRP(100)), - credentials::ids({credIdx, credIdx2}), - ter(tecEXPIRED)); + credentials::Ids({credIdx, credIdx2}), + Ter(tecEXPIRED)); env.close(); { @@ -1183,7 +1183,7 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); // credentials are expired - env(pay(gw, bob, USD(150)), credentials::ids({credIdx}), ter(tecEXPIRED)); + env(pay(gw, bob, usd(150)), credentials::Ids({credIdx}), Ter(tecEXPIRED)); env.close(); // check that expired credentials were deleted @@ -1232,12 +1232,12 @@ struct DepositPreauth_test : public beast::unit_test::suite env.close(); auto const seq = env.seq(alice); - env(escrow::create(alice, bob, XRP(1000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bob, XRP(1000)), escrow::kFINISH_TIME(env.now() + 1s)); env.close(); // zelda can't finish escrow with invalid credentials { - env(escrow::finish(zelda, alice, seq), credentials::ids({}), ter(temMALFORMED)); + env(escrow::finish(zelda, alice, seq), credentials::Ids({}), Ter(temMALFORMED)); env.close(); } @@ -1248,16 +1248,16 @@ struct DepositPreauth_test : public beast::unit_test::suite "01E034"; env(escrow::finish(zelda, alice, seq), - credentials::ids({invalidIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({invalidIdx}), + Ter(tecBAD_CREDENTIALS)); env.close(); } { // Ledger closed, time increased, zelda can't finish escrow env(escrow::finish(zelda, alice, seq), - credentials::ids({credIdx}), - fee(1500), - ter(tecEXPIRED)); + credentials::Ids({credIdx}), + Fee(1500), + Ter(tecEXPIRED)); env.close(); } @@ -1346,7 +1346,7 @@ struct DepositPreauth_test : public beast::unit_test::suite for (int i = 0; i < 10; ++i) { std::ranges::shuffle(credentials, gen); - env(deposit::authCredentials(stock, credentials), ter(tecDUPLICATE)); + env(deposit::authCredentials(stock, credentials), Ter(tecDUPLICATE)); } } @@ -1361,7 +1361,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { auto credentials2 = copyCredentials; credentials2.push_back(c); - env(deposit::authCredentials(stock, credentials2), ter(temMALFORMED)); + env(deposit::authCredentials(stock, credentials2), Ter(temMALFORMED)); } // create batch of credentials and save their hashes @@ -1385,7 +1385,7 @@ struct DepositPreauth_test : public beast::unit_test::suite auto credentialIDs2 = credentialIDs; credentialIDs2.push_back(h); - env(pay(alice, bob, XRP(100)), credentials::ids(credentialIDs2), ter(temMALFORMED)); + env(pay(alice, bob, XRP(100)), credentials::Ids(credentialIDs2), Ter(temMALFORMED)); } } } @@ -1395,7 +1395,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { testEnable(); testInvalid(); - auto const supported{jtx::testable_amendments()}; + auto const supported{jtx::testableAmendments()}; testPayment(supported - featureCredentials); testPayment(supported); testCredentialsPayment(); diff --git a/src/test/app/Discrepancy_test.cpp b/src/test/app/Discrepancy_test.cpp index b01b11aa11..0d3460dd2a 100644 --- a/src/test/app/Discrepancy_test.cpp +++ b/src/test/app/Discrepancy_test.cpp @@ -22,7 +22,7 @@ namespace xrpl { -class Discrepancy_test : public beast::unit_test::suite +class Discrepancy_test : public beast::unit_test::Suite { // This is a legacy test ported from js/coffee. The ledger // state was originally setup via a saved ledger file and the relevant @@ -36,64 +36,64 @@ class Discrepancy_test : public beast::unit_test::suite using namespace test::jtx; Env env{*this, features}; - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; - Account const A5{"A5"}; - Account const A6{"A6"}; - Account const A7{"A7"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; + Account const a5{"A5"}; + Account const a6{"A6"}; + Account const a7{"A7"}; - env.fund(XRP(2000), A1); - env.fund(XRP(1000), A2, A6, A7); - env.fund(XRP(5000), A3); - env.fund(XRP(1000000), A4); - env.fund(XRP(600000), A5); + env.fund(XRP(2000), a1); + env.fund(XRP(1000), a2, a6, a7); + env.fund(XRP(5000), a3); + env.fund(XRP(1000000), a4); + env.fund(XRP(600000), a5); env.close(); - env(trust(A1, A3["CNY"](200000))); - env(pay(A3, A1, A3["CNY"](31))); + env(trust(a1, a3["CNY"](200000))); + env(pay(a3, a1, a3["CNY"](31))); env.close(); - env(trust(A1, A2["JPY"](1000000))); - env(pay(A2, A1, A2["JPY"](729117))); + env(trust(a1, a2["JPY"](1000000))); + env(pay(a2, a1, a2["JPY"](729117))); env.close(); - env(trust(A4, A2["JPY"](10000000))); - env(pay(A2, A4, A2["JPY"](470056))); + env(trust(a4, a2["JPY"](10000000))); + env(pay(a2, a4, a2["JPY"](470056))); env.close(); - env(trust(A5, A3["CNY"](50000))); - env(pay(A3, A5, A3["CNY"](8683))); + env(trust(a5, a3["CNY"](50000))); + env(pay(a3, a5, a3["CNY"](8683))); env.close(); - env(trust(A6, A3["CNY"](3000))); - env(pay(A3, A6, A3["CNY"](293))); + env(trust(a6, a3["CNY"](3000))); + env(pay(a3, a6, a3["CNY"](293))); env.close(); - env(trust(A7, A6["CNY"](50000))); - env(pay(A6, A7, A6["CNY"](261))); + env(trust(a7, a6["CNY"](50000))); + env(pay(a6, a7, a6["CNY"](261))); env.close(); - env(offer(A4, XRP(49147), A2["JPY"](34501))); - env(offer(A5, A3["CNY"](3150), XRP(80086))); - env(offer(A7, XRP(1233), A6["CNY"](25))); + env(offer(a4, XRP(49147), a2["JPY"](34501))); + env(offer(a5, a3["CNY"](3150), XRP(80086))); + env(offer(a7, XRP(1233), a6["CNY"](25))); env.close(); test::PathSet const payPaths{ - test::Path{A2["JPY"], A2}, - test::Path{XRP, A2["JPY"], A2}, - test::Path{A6, XRP, A2["JPY"], A2}}; + test::TestPath{a2["JPY"], a2}, + test::TestPath{XRP, a2["JPY"], a2}, + test::TestPath{a6, XRP, a2["JPY"], a2}}; - env(pay(A1, A1, A2["JPY"](1000)), - json(payPaths.json()), - txflags(tfPartialPayment), - sendmax(A3["CNY"](56))); + env(pay(a1, a1, a2["JPY"](1000)), + Json(payPaths.json()), + Txflags(tfPartialPayment), + Sendmax(a3["CNY"](56))); env.close(); - Json::Value jrq2; + json::Value jrq2; jrq2[jss::binary] = false; - jrq2[jss::transaction] = env.tx()->getJson(JsonOptions::none)[jss::hash]; + jrq2[jss::transaction] = env.tx()->getJson(JsonOptions::KNone)[jss::hash]; jrq2[jss::id] = 3; auto jrr = env.rpc("json", "tx", to_string(jrq2))[jss::result]; uint64_t const fee{jrr[jss::Fee].asUInt()}; @@ -103,7 +103,7 @@ class Discrepancy_test : public beast::unit_test::suite BEAST_EXPECT(meta[sfAffectedNodes.fieldName].size() == 9); for (auto const& an : meta[sfAffectedNodes.fieldName]) { - Json::Value node; + json::Value node; if (an.isMember(sfCreatedNode.fieldName)) { node = an[sfCreatedNode.fieldName]; @@ -119,10 +119,10 @@ class Discrepancy_test : public beast::unit_test::suite if (node && node[sfLedgerEntryType.fieldName] == jss::AccountRoot) { - Json::Value prevFields = node.isMember(sfPreviousFields.fieldName) + json::Value prevFields = node.isMember(sfPreviousFields.fieldName) ? node[sfPreviousFields.fieldName] : node[sfNewFields.fieldName]; - Json::Value finalFields = node.isMember(sfFinalFields.fieldName) + json::Value finalFields = node.isMember(sfFinalFields.fieldName) ? node[sfFinalFields.fieldName] : node[sfNewFields.fieldName]; if (prevFields) @@ -147,7 +147,7 @@ public: run() override { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testXRPDiscrepancy(sa - featurePermissionedDEX); testXRPDiscrepancy(sa); } diff --git a/src/test/app/EscrowToken_test.cpp b/src/test/app/EscrowToken_test.cpp index d77043a624..bf7cf90bf2 100644 --- a/src/test/app/EscrowToken_test.cpp +++ b/src/test/app/EscrowToken_test.cpp @@ -43,7 +43,7 @@ namespace xrpl::test { -struct EscrowToken_test : public beast::unit_test::suite +struct EscrowToken_test : public beast::unit_test::Suite { static uint64_t mptEscrowed(jtx::Env const& env, jtx::Account const& account, jtx::MPT const& mpt) @@ -66,7 +66,7 @@ struct EscrowToken_test : public beast::unit_test::suite static jtx::PrettyAmount issuerBalance(jtx::Env& env, jtx::Account const& account, Issue const& issue) { - Json::Value params; + json::Value params; params[jss::account] = account.human(); auto jrr = env.rpc("json", "gateway_balances", to_string(params)); auto const result = jrr[jss::result]; @@ -80,7 +80,7 @@ struct EscrowToken_test : public beast::unit_test::suite static jtx::PrettyAmount issuerEscrowed(jtx::Env& env, jtx::Account const& account, Issue const& issue) { - Json::Value params; + json::Value params; params[jss::account] = account.human(); auto jrr = env.rpc("json", "gateway_balances", to_string(params)); auto const result = jrr[jss::result]; @@ -107,39 +107,39 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); env.close(); - auto const createResult = withTokenEscrow ? ter(tesSUCCESS) : ter(temBAD_AMOUNT); - auto const finishResult = withTokenEscrow ? ter(tesSUCCESS) : ter(tecNO_TARGET); + auto const createResult = withTokenEscrow ? Ter(tesSUCCESS) : Ter(temBAD_AMOUNT); + auto const finishResult = withTokenEscrow ? Ter(tesSUCCESS) : Ter(tecNO_TARGET); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), createResult); env.close(); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), finishResult); env.close(); auto const seq2 = env.seq(alice); - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), createResult); env.close(); env(escrow::cancel(bob, alice, seq2), finishResult); @@ -154,25 +154,25 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); env.close(); auto const seq1 = env.seq(alice); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_TARGET)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_TARGET)); env.close(); - env(escrow::cancel(bob, alice, seq1), ter(tecNO_TARGET)); + env(escrow::cancel(bob, alice, seq1), Ter(tecNO_TARGET)); env.close(); } } @@ -190,56 +190,56 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); env.close(); // Create Escrow #1 & #2 auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); auto const seq2 = env.seq(alice); - env(escrow::create(alice, bob, USD(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 3s), - fee(baseFee), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 3s), + Fee(baseFee), + Ter(tesSUCCESS)); env.close(); // Clear the asfAllowTrustLineLocking flag env(fclear(gw, asfAllowTrustLineLocking)); env.close(); - env.require(nflags(gw, asfAllowTrustLineLocking)); + env.require(Nflags(gw, asfAllowTrustLineLocking)); // Cannot Create Escrow without asfAllowTrustLineLocking - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); // Can finish the escrow created before the flag was cleared env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // Can cancel the escrow created before the flag was cleared - env(escrow::cancel(bob, alice, seq2), ter(tesSUCCESS)); + env(escrow::cancel(bob, alice, seq2), Ter(tesSUCCESS)); env.close(); } @@ -256,13 +256,13 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); - env(escrow::create(alice, bob, USD(1)), - escrow::finish_time(env.now() + 1s), - fee(XRP(-1)), - ter(temBAD_FEE)); + env(escrow::create(alice, bob, usd(1)), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(XRP(-1)), + Ter(temBAD_FEE)); env.close(); } @@ -273,14 +273,14 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); - env(escrow::create(alice, bob, USD(-1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(temBAD_AMOUNT)); + env(escrow::create(alice, bob, usd(-1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(temBAD_AMOUNT)); env.close(); } @@ -291,14 +291,14 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const BAD = IOU(gw, badCurrency()); + auto const bad = IOU(gw, badCurrency()); env.fund(XRP(5000), alice, bob, gw); - env(escrow::create(alice, bob, BAD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(temBAD_CURRENCY)); + env(escrow::create(alice, bob, bad(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(temBAD_CURRENCY)); env.close(); } } @@ -317,14 +317,14 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); - env(escrow::create(gw, alice, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, alice, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } @@ -335,16 +335,16 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob); env.close(); env.memoize(gw); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_ISSUER)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_ISSUER)); env.close(); } @@ -355,20 +355,20 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); env.close(); - env(escrow::create(gw, alice, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, alice, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } @@ -379,15 +379,15 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_LINE)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_LINE)); env.close(); } @@ -400,19 +400,19 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env(fset(gw, asfRequireAuth)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -423,21 +423,21 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const aliceUSD = alice["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, aliceUSD(10'000)), txflags(tfSetfAuth)); - env.trust(USD(10'000), alice, bob); + env(trust(gw, aliceUSD(10'000)), Txflags(tfSetfAuth)); + env.trust(usd(10'000), alice, bob); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -448,27 +448,27 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const baseFee = env.current()->fees().base; env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // set freeze on alice trustline - env(trust(gw, USD(10'000), alice, tfSetFreeze)); + env(trust(gw, usd(10'000), alice, tfSetFreeze)); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecFROZEN)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); } @@ -479,27 +479,27 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const baseFee = env.current()->fees().base; env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze)); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecFROZEN)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); } @@ -510,20 +510,20 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const baseFee = env.current()->fees().base; env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecINSUFFICIENT_FUNDS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_FUNDS)); env.close(); } @@ -534,23 +534,23 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const baseFee = env.current()->fees().base; env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); - env(escrow::create(alice, bob, USD(10'001)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecINSUFFICIENT_FUNDS)); + env(escrow::create(alice, bob, usd(10'001)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_FUNDS)); env.close(); } @@ -560,27 +560,27 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const baseFee = env.current()->fees().base; env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100000000000000000), alice); - env.trust(USD(100000000000000000), bob); + env.trust(usd(100000000000000000), alice); + env.trust(usd(100000000000000000), bob); env.close(); - env(pay(gw, alice, USD(10000000000000000))); - env(pay(gw, bob, USD(1))); + env(pay(gw, alice, usd(10000000000000000))); + env(pay(gw, bob, usd(1))); env.close(); bool const largeMantissa = features[featureSingleAssetVault] || features[featureLendingProtocol]; // alice cannot create escrow for 1/10 iou - precision loss - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(largeMantissa ? (TER)tesSUCCESS : (TER)tecPRECISION_LOSS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(largeMantissa ? (TER)tesSUCCESS : (TER)tecPRECISION_LOSS)); env.close(); } } @@ -599,43 +599,43 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const aliceUSD = alice["USD"]; auto const bobUSD = bob["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, aliceUSD(10'000)), txflags(tfSetfAuth)); - env(trust(gw, bobUSD(10'000)), txflags(tfSetfAuth)); - env.trust(USD(10'000), alice, bob); + env(trust(gw, aliceUSD(10'000)), Txflags(tfSetfAuth)); + env(trust(gw, bobUSD(10'000)), Txflags(tfSetfAuth)); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env(pay(bob, gw, USD(10'000))); - env(trust(gw, bobUSD(0)), txflags(tfSetfAuth)); - env(trust(bob, USD(0))); + env(pay(bob, gw, usd(10'000))); + env(trust(gw, bobUSD(0)), Txflags(tfSetfAuth)); + env(trust(bob, usd(0))); env.close(); - env.trust(USD(10'000), bob); + env.trust(usd(10'000), bob); env.close(); // bob cannot finish because he is not authorized env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_AUTH)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -646,33 +646,33 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); // bob cannot finish because of deep freeze env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecFROZEN)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); } } @@ -693,31 +693,31 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, gw); env.fund(acctReserve + (incReserve - 1), bob); env.close(); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice); + env.trust(usd(10'000), alice); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw, alice, usd(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // bob cannot finish because insufficient reserve to create line env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_LINE_INSUF_RESERVE)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_LINE_INSUF_RESERVE)); env.close(); } @@ -728,30 +728,30 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env.close(); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice); + env.trust(usd(10'000), alice); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw, alice, usd(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // alice cannot finish because bob does not have a trustline env(escrow::finish(alice, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_LINE)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_LINE)); env.close(); } @@ -762,33 +762,33 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env.close(); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(1000), alice, bob); + env.trust(usd(1000), alice, bob); env.close(); - env(pay(gw, alice, USD(1000))); + env(pay(gw, alice, usd(1000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(5)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(5)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env.trust(USD(1), bob); + env.trust(usd(1), bob); env.close(); // alice cannot finish because bob's limit is too low env(escrow::finish(alice, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecLIMIT_EXCEEDED)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecLIMIT_EXCEEDED)); env.close(); } @@ -799,39 +799,39 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env.close(); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(1000), alice, bob); + env.trust(usd(1000), alice, bob); env.close(); - env(pay(gw, alice, USD(1000))); + env(pay(gw, alice, usd(1000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(5)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(5)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env.trust(USD(1), bob); + env.trust(usd(1), bob); env.close(); // bob can finish even if bob's limit is too low - auto const bobPreLimit = env.limit(bob, USD); + auto const bobPreLimit = env.limit(bob, usd); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // bob's limit is not changed - BEAST_EXPECT(env.limit(bob, USD) == bobPreLimit); + BEAST_EXPECT(env.limit(bob, usd) == bobPreLimit); } } @@ -849,39 +849,39 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const aliceUSD = alice["USD"]; auto const bobUSD = bob["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, aliceUSD(10'000)), txflags(tfSetfAuth)); - env(trust(gw, bobUSD(10'000)), txflags(tfSetfAuth)); - env.trust(USD(10'000), alice, bob); + env(trust(gw, aliceUSD(10'000)), Txflags(tfSetfAuth)); + env(trust(gw, bobUSD(10'000)), Txflags(tfSetfAuth)); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, USD(1)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee), + Ter(tesSUCCESS)); env.close(); - env(pay(alice, gw, USD(9'999))); - env(trust(gw, aliceUSD(0)), txflags(tfSetfAuth)); - env(trust(alice, USD(0))); + env(pay(alice, gw, usd(9'999))); + env(trust(gw, aliceUSD(0)), Txflags(tfSetfAuth)); + env(trust(alice, usd(0))); env.close(); - env.trust(USD(10'000), alice); + env.trust(usd(10'000), alice); env.close(); // alice cannot cancel because she is not authorized - env(escrow::cancel(bob, alice, seq1), fee(baseFee), ter(tecNO_AUTH)); + env(escrow::cancel(bob, alice, seq1), Fee(baseFee), Ter(tecNO_AUTH)); env.close(); } } @@ -899,79 +899,79 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(5'000))); - env(pay(gw, bob, USD(5'000))); + env(pay(gw, alice, usd(5'000))); + env(pay(gw, bob, usd(5'000))); env.close(); - auto const outstandingUSD = USD(10'000); + auto const outstandingUSD = usd(10'000); // Create & Finish Escrow auto const seq1 = env.seq(alice); { - auto const preAliceUSD = env.balance(alice, USD); - auto const preBobUSD = env.balance(bob, USD); - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceUSD = env.balance(alice, usd); + auto const preBobUSD = env.balance(bob, usd); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAliceUSD - USD(1'000)); - BEAST_EXPECT(env.balance(bob, USD) == preBobUSD); - BEAST_EXPECT(issuerBalance(env, gw, USD) == outstandingUSD - USD(1'000)); - BEAST_EXPECT(issuerEscrowed(env, gw, USD) == USD(1'000)); + BEAST_EXPECT(env.balance(alice, usd) == preAliceUSD - usd(1'000)); + BEAST_EXPECT(env.balance(bob, usd) == preBobUSD); + BEAST_EXPECT(issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000)); + BEAST_EXPECT(issuerEscrowed(env, gw, usd) == usd(1'000)); } { - auto const preAliceUSD = env.balance(alice, USD); - auto const preBobUSD = env.balance(bob, USD); + auto const preAliceUSD = env.balance(alice, usd); + auto const preBobUSD = env.balance(bob, usd); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAliceUSD); - BEAST_EXPECT(env.balance(bob, USD) == preBobUSD + USD(1'000)); - BEAST_EXPECT(issuerBalance(env, gw, USD) == outstandingUSD); - BEAST_EXPECT(issuerEscrowed(env, gw, USD) == USD(0)); + BEAST_EXPECT(env.balance(alice, usd) == preAliceUSD); + BEAST_EXPECT(env.balance(bob, usd) == preBobUSD + usd(1'000)); + BEAST_EXPECT(issuerBalance(env, gw, usd) == outstandingUSD); + BEAST_EXPECT(issuerEscrowed(env, gw, usd) == usd(0)); } // Create & Cancel Escrow auto const seq2 = env.seq(alice); { - auto const preAliceUSD = env.balance(alice, USD); - auto const preBobUSD = env.balance(bob, USD); - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceUSD = env.balance(alice, usd); + auto const preBobUSD = env.balance(bob, usd); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAliceUSD - USD(1'000)); - BEAST_EXPECT(env.balance(bob, USD) == preBobUSD); - BEAST_EXPECT(issuerBalance(env, gw, USD) == outstandingUSD - USD(1'000)); - BEAST_EXPECT(issuerEscrowed(env, gw, USD) == USD(1'000)); + BEAST_EXPECT(env.balance(alice, usd) == preAliceUSD - usd(1'000)); + BEAST_EXPECT(env.balance(bob, usd) == preBobUSD); + BEAST_EXPECT(issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000)); + BEAST_EXPECT(issuerEscrowed(env, gw, usd) == usd(1'000)); } { - auto const preAliceUSD = env.balance(alice, USD); - auto const preBobUSD = env.balance(bob, USD); - env(escrow::cancel(bob, alice, seq2), ter(tesSUCCESS)); + auto const preAliceUSD = env.balance(alice, usd); + auto const preBobUSD = env.balance(bob, usd); + env(escrow::cancel(bob, alice, seq2), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAliceUSD + USD(1'000)); - BEAST_EXPECT(env.balance(bob, USD) == preBobUSD); - BEAST_EXPECT(issuerBalance(env, gw, USD) == outstandingUSD); - BEAST_EXPECT(issuerEscrowed(env, gw, USD) == USD(0)); + BEAST_EXPECT(env.balance(alice, usd) == preAliceUSD + usd(1'000)); + BEAST_EXPECT(env.balance(bob, usd) == preBobUSD); + BEAST_EXPECT(issuerBalance(env, gw, usd) == outstandingUSD); + BEAST_EXPECT(issuerEscrowed(env, gw, usd) == usd(0)); } } @@ -985,7 +985,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { testcase("IOU Metadata to self"); @@ -993,18 +993,18 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(5000), alice, bob, carol, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob, carol); + env.trust(usd(10'000), alice, bob, carol); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); - env(pay(gw, carol, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); + env(pay(gw, carol, usd(5000))); env.close(); auto const aseq = env.seq(alice); auto const bseq = env.seq(bob); - env(escrow::create(alice, alice, USD(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 500s)); + env(escrow::create(alice, alice, usd(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 500s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1026,9 +1026,9 @@ struct EscrowToken_test : public beast::unit_test::suite std::find(iod.begin(), iod.end(), aa) != iod.end()); } - env(escrow::create(bob, bob, USD(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + env(escrow::create(bob, bob, usd(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1104,22 +1104,22 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(5000), alice, bob, carol, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob, carol); + env.trust(usd(10'000), alice, bob, carol); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, bob, USD(5000))); - env(pay(gw, carol, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, bob, usd(5000))); + env(pay(gw, carol, usd(5000))); env.close(); auto const aseq = env.seq(alice); auto const bseq = env.seq(bob); - env(escrow::create(alice, bob, USD(1'000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bob, usd(1'000)), escrow::kFINISH_TIME(env.now() + 1s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); - env(escrow::create(bob, carol, USD(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + env(escrow::create(bob, carol, usd(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1238,22 +1238,22 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(5000), alice, carol, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, carol); + env.trust(usd(10'000), alice, carol); env.close(); - env(pay(gw, alice, USD(5000))); - env(pay(gw, carol, USD(5000))); + env(pay(gw, alice, usd(5000))); + env(pay(gw, carol, usd(5000))); env.close(); auto const aseq = env.seq(alice); - env(escrow::create(alice, gw, USD(1'000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, gw, usd(1'000)), escrow::kFINISH_TIME(env.now() + 1s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); - env(escrow::create(gw, carol, USD(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, carol, usd(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Ter(tecNO_PERMISSION)); env.close(5s); auto const ag = env.le(keylet::escrow(alice.id(), aseq)); @@ -1370,47 +1370,47 @@ struct EscrowToken_test : public beast::unit_test::suite { Env env{*this, features}; auto const baseFee = env.current()->fees().base; - auto const USD = t.gw["USD"]; + auto const usd = t.gw["USD"]; env.fund(XRP(5000), t.src, t.dst, t.gw); env(fset(t.gw, asfAllowTrustLineLocking)); env.close(); if (t.hasTrustline) { - env.trust(USD(100'000), t.src, t.dst); + env.trust(usd(100'000), t.src, t.dst); } else { - env.trust(USD(100'000), t.src); + env.trust(usd(100'000), t.src); } env.close(); - env(pay(t.gw, t.src, USD(10'000))); + env(pay(t.gw, t.src, usd(10'000))); if (t.hasTrustline) - env(pay(t.gw, t.dst, USD(10'000))); + env(pay(t.gw, t.dst, usd(10'000))); env.close(); // src can create escrow auto const seq1 = env.seq(t.src); - auto const delta = USD(1'000); + auto const delta = usd(1'000); env(escrow::create(t.src, t.dst, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // dst can finish escrow - auto const preSrc = env.balance(t.src, USD); - auto const preDst = env.balance(t.dst, USD); + auto const preSrc = env.balance(t.src, usd); + auto const preDst = env.balance(t.dst, usd); env(escrow::finish(t.dst, t.src, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(t.src, USD) == preSrc); - BEAST_EXPECT(env.balance(t.dst, USD) == preDst + delta); + BEAST_EXPECT(env.balance(t.src, usd) == preSrc); + BEAST_EXPECT(env.balance(t.dst, usd) == preDst + delta); } } @@ -1434,22 +1434,22 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account{"alice"}; Env env{*this, features}; auto const baseFee = env.current()->fees().base; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(5000), alice, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100'000), alice); + env.trust(usd(100'000), alice); env.close(); - env(pay(gw, alice, USD(10'000))); + env(pay(gw, alice, usd(10'000))); env.close(); // issuer cannot create escrow - env(escrow::create(gw, alice, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, alice, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } @@ -1469,43 +1469,43 @@ struct EscrowToken_test : public beast::unit_test::suite { Env env{*this, features}; auto const baseFee = env.current()->fees().base; - auto const USD = t.dst["USD"]; + auto const usd = t.dst["USD"]; env.fund(XRP(5000), t.dst, t.src); env(fset(t.dst, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100'000), t.src); + env.trust(usd(100'000), t.src); env.close(); - env(pay(t.dst, t.src, USD(10'000))); + env(pay(t.dst, t.src, usd(10'000))); env.close(); // issuer can receive escrow auto const seq1 = env.seq(t.src); - auto const preSrc = env.balance(t.src, USD); - env(escrow::create(t.src, t.dst, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + auto const preSrc = env.balance(t.src, usd); + env(escrow::create(t.src, t.dst, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // issuer can finish escrow, no dest trustline env(escrow::finish(t.dst, t.src, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); auto const preAmount = 10'000; - BEAST_EXPECT(preSrc == USD(preAmount)); + BEAST_EXPECT(preSrc == usd(preAmount)); auto const postAmount = 9000; - BEAST_EXPECT(env.balance(t.src, USD) == USD(postAmount)); - BEAST_EXPECT(env.balance(t.dst, USD) == USD(0)); + BEAST_EXPECT(env.balance(t.src, usd) == usd(postAmount)); + BEAST_EXPECT(env.balance(t.dst, usd) == usd(0)); } // issuer is source and destination { auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), gw); @@ -1513,11 +1513,11 @@ struct EscrowToken_test : public beast::unit_test::suite env.close(); // issuer cannot receive escrow - env(escrow::create(gw, gw, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, gw, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } } @@ -1533,7 +1533,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // test locked rate { @@ -1543,34 +1543,34 @@ struct EscrowToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineLocking)); env(rate(gw, 1.25)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, USD); + auto const preAlice = env.balance(alice, usd); auto const seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); auto const transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); // bob can finish escrow env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAlice - delta); - BEAST_EXPECT(env.balance(bob, USD) == USD(10'100)); + BEAST_EXPECT(env.balance(alice, usd) == preAlice - delta); + BEAST_EXPECT(env.balance(bob, usd) == usd(10'100)); } // test rate change - higher { @@ -1580,21 +1580,21 @@ struct EscrowToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineLocking)); env(rate(gw, 1.25)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, USD); + auto const preAlice = env.balance(alice, usd); auto const seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); auto transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); @@ -1605,13 +1605,13 @@ struct EscrowToken_test : public beast::unit_test::suite // bob can finish escrow - rate unchanged env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAlice - delta); - BEAST_EXPECT(env.balance(bob, USD) == USD(10'100)); + BEAST_EXPECT(env.balance(alice, usd) == preAlice - delta); + BEAST_EXPECT(env.balance(bob, usd) == usd(10'100)); } // test rate change - lower @@ -1622,21 +1622,21 @@ struct EscrowToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineLocking)); env(rate(gw, 1.25)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, USD); + auto const preAlice = env.balance(alice, usd); auto const seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); auto transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); @@ -1647,13 +1647,13 @@ struct EscrowToken_test : public beast::unit_test::suite // bob can finish escrow - rate changed env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAlice - delta); - BEAST_EXPECT(env.balance(bob, USD) == USD(10125)); + BEAST_EXPECT(env.balance(alice, usd) == preAlice - delta); + BEAST_EXPECT(env.balance(bob, usd) == usd(10125)); } // test cancel doesn't charge rate @@ -1664,21 +1664,21 @@ struct EscrowToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineLocking)); env(rate(gw, 1.25)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, USD); + auto const preAlice = env.balance(alice, usd); auto const seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 3s), - fee(baseFee)); + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 3s), + Fee(baseFee)); env.close(); auto transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); @@ -1688,11 +1688,11 @@ struct EscrowToken_test : public beast::unit_test::suite env.close(); // alice can cancel escrow - rate is not charged - env(escrow::cancel(alice, alice, seq1), fee(baseFee)); + env(escrow::cancel(alice, alice, seq1), Fee(baseFee)); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == preAlice); - BEAST_EXPECT(env.balance(bob, USD) == USD(10000)); + BEAST_EXPECT(env.balance(alice, usd) == preAlice); + BEAST_EXPECT(env.balance(bob, usd) == usd(10000)); } } @@ -1706,7 +1706,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // test LimitAmount { @@ -1715,29 +1715,29 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(1'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(10'000), alice, bob); + env.trust(usd(10'000), alice, bob); env.close(); - env(pay(gw, alice, USD(1'000))); - env(pay(gw, bob, USD(1'000))); + env(pay(gw, alice, usd(1'000))); + env(pay(gw, bob, usd(1'000))); env.close(); // alice can create escrow auto seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // bob can finish - auto const preBobLimit = env.limit(bob, USD); + auto const preBobLimit = env.limit(bob, usd); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - auto const postBobLimit = env.limit(bob, USD); + auto const postBobLimit = env.limit(bob, usd); // bob's limit is NOT changed BEAST_EXPECT(postBobLimit == preBobLimit); } @@ -1754,7 +1754,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const aliceUSD = alice["USD"]; auto const bobUSD = bob["USD"]; @@ -1765,43 +1765,43 @@ struct EscrowToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineLocking)); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, aliceUSD(10'000)), txflags(tfSetfAuth)); - env(trust(alice, USD(10'000))); - env(trust(bob, USD(10'000))); + env(trust(gw, aliceUSD(10'000)), Txflags(tfSetfAuth)); + env(trust(alice, usd(10'000))); + env(trust(bob, usd(10'000))); env.close(); - env(pay(gw, alice, USD(1'000))); + env(pay(gw, alice, usd(1'000))); env.close(); // alice cannot create escrow - fails without auth auto seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); // set auth on bob - env(trust(gw, bobUSD(10'000)), txflags(tfSetfAuth)); - env(trust(bob, USD(10'000))); + env(trust(gw, bobUSD(10'000)), Txflags(tfSetfAuth)); + env(trust(bob, usd(10'000))); env.close(); - env(pay(gw, bob, USD(1'000))); + env(pay(gw, bob, usd(1'000))); env.close(); // alice can create escrow - bob has auth seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // bob can finish env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); } @@ -1816,7 +1816,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // test Global Freeze { @@ -1825,25 +1825,25 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); env(fset(gw, asfGlobalFreeze)); env.close(); // setup transaction auto seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); // create escrow fails - frozen trustline env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecFROZEN)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); // clear global freeze @@ -1853,9 +1853,9 @@ struct EscrowToken_test : public beast::unit_test::suite // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set global freeze @@ -1864,9 +1864,9 @@ struct EscrowToken_test : public beast::unit_test::suite // bob finish escrow success regardless of frozen assets env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); // clear global freeze @@ -1876,9 +1876,9 @@ struct EscrowToken_test : public beast::unit_test::suite // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set global freeze @@ -1886,7 +1886,7 @@ struct EscrowToken_test : public beast::unit_test::suite env.close(); // bob cancel escrow success regardless of frozen assets - env(escrow::cancel(bob, alice, seq1), fee(baseFee)); + env(escrow::cancel(bob, alice, seq1), Fee(baseFee)); env.close(); } @@ -1898,71 +1898,71 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // set freeze on alice trustline - env(trust(gw, USD(10'000), alice, tfSetFreeze)); + env(trust(gw, usd(10'000), alice, tfSetFreeze)); env.close(); // setup transaction auto seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); // create escrow fails - frozen trustline env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecFROZEN)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); // clear freeze on alice trustline - env(trust(gw, USD(10'000), alice, tfClearFreeze)); + env(trust(gw, usd(10'000), alice, tfClearFreeze)); env.close(); // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze)); env.close(); // bob finish escrow success regardless of frozen assets env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); // reset freeze on bob and alice trustline - env(trust(gw, USD(10'000), alice, tfClearFreeze)); - env(trust(gw, USD(10'000), bob, tfClearFreeze)); + env(trust(gw, usd(10'000), alice, tfClearFreeze)); + env(trust(gw, usd(10'000), bob, tfClearFreeze)); env.close(); // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze)); env.close(); // bob cancel escrow success regardless of frozen assets - env(escrow::cancel(bob, alice, seq1), fee(baseFee)); + env(escrow::cancel(bob, alice, seq1), Fee(baseFee)); env.close(); } @@ -1974,72 +1974,72 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env(trust(alice, USD(100'000))); - env(trust(bob, USD(100'000))); + env(trust(alice, usd(100'000))); + env(trust(bob, usd(100'000))); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // set freeze on alice trustline - env(trust(gw, USD(10'000), alice, tfSetFreeze | tfSetDeepFreeze)); + env(trust(gw, usd(10'000), alice, tfSetFreeze | tfSetDeepFreeze)); env.close(); // setup transaction auto seq1 = env.seq(alice); - auto const delta = USD(125); + auto const delta = usd(125); // create escrow fails - frozen trustline env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecFROZEN)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); // clear freeze on alice trustline - env(trust(gw, USD(10'000), alice, tfClearFreeze | tfClearDeepFreeze)); + env(trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze)); env.close(); // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); env.close(); // bob finish escrow fails because of deep frozen assets env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecFROZEN)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecFROZEN)); env.close(); // reset freeze on alice and bob trustline - env(trust(gw, USD(10'000), alice, tfClearFreeze | tfClearDeepFreeze)); - env(trust(gw, USD(10'000), bob, tfClearFreeze | tfClearDeepFreeze)); + env(trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze)); + env(trust(gw, usd(10'000), bob, tfClearFreeze | tfClearDeepFreeze)); env.close(); // create escrow success seq1 = env.seq(alice); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // set freeze on bob trustline - env(trust(gw, USD(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); + env(trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze)); env.close(); // bob cancel escrow fails because of deep frozen assets - env(escrow::cancel(bob, alice, seq1), fee(baseFee), ter(tesSUCCESS)); + env(escrow::cancel(bob, alice, seq1), Fee(baseFee), Ter(tesSUCCESS)); env.close(); } } @@ -2054,7 +2054,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { // test tecPATH_PARTIAL // ie. has 10'000, escrow 1'000 then try to pay 10'000 @@ -2063,21 +2063,21 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); // create escrow success - auto const delta = USD(1'000); + auto const delta = usd(1'000); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - env(pay(alice, gw, USD(10'000)), ter(tecPATH_PARTIAL)); + env(pay(alice, gw, usd(10'000)), Ter(tecPATH_PARTIAL)); } { // test tecINSUFFICIENT_FUNDS @@ -2087,25 +2087,25 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100'000), alice); - env.trust(USD(100'000), bob); + env.trust(usd(100'000), alice); + env.trust(usd(100'000), bob); env.close(); - env(pay(gw, alice, USD(10'000))); - env(pay(gw, bob, USD(10'000))); + env(pay(gw, alice, usd(10'000))); + env(pay(gw, bob, usd(10'000))); env.close(); - auto const delta = USD(1'000); + auto const delta = usd(1'000); env(escrow::create(alice, bob, delta), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - env(escrow::create(alice, bob, USD(10'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecINSUFFICIENT_FUNDS)); + env(escrow::create(alice, bob, usd(10'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_FUNDS)); env.close(); } } @@ -2120,7 +2120,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // test min create precision loss { @@ -2129,37 +2129,37 @@ struct EscrowToken_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); env(fset(gw, asfAllowTrustLineLocking)); env.close(); - env.trust(USD(100000000000000000), alice); - env.trust(USD(100000000000000000), bob); + env.trust(usd(100000000000000000), alice); + env.trust(usd(100000000000000000), bob); env.close(); - env(pay(gw, alice, USD(10000000000000000))); - env(pay(gw, bob, USD(1))); + env(pay(gw, alice, usd(10000000000000000))); + env(pay(gw, bob, usd(1))); env.close(); bool const largeMantissa = features[featureSingleAssetVault] || features[featureLendingProtocol]; // alice cannot create escrow for 1/10 iou - precision loss - env(escrow::create(alice, bob, USD(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(largeMantissa ? (TER)tesSUCCESS : (TER)tecPRECISION_LOSS)); + env(escrow::create(alice, bob, usd(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(largeMantissa ? (TER)tesSUCCESS : (TER)tecPRECISION_LOSS)); env.close(); auto const seq1 = env.seq(alice); // alice can create escrow for 1'000 iou - env(escrow::create(alice, bob, USD(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, usd(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // bob finish escrow success env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); } } @@ -2186,32 +2186,32 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); - auto const createResult = withTokenEscrow ? ter(tesSUCCESS) : ter(temBAD_AMOUNT); - auto const finishResult = withTokenEscrow ? ter(tesSUCCESS) : ter(tecNO_TARGET); + auto const createResult = withTokenEscrow ? Ter(tesSUCCESS) : Ter(temBAD_AMOUNT); + auto const finishResult = withTokenEscrow ? Ter(tesSUCCESS) : Ter(tecNO_TARGET); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), + env(escrow::create(alice, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), createResult); env.close(); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), finishResult); env.close(); auto const seq2 = env.seq(alice); - env(escrow::create(alice, bob, MPT(1'000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), + env(escrow::create(alice, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), createResult); env.close(); env(escrow::cancel(bob, alice, seq2), finishResult); @@ -2236,17 +2236,17 @@ struct EscrowToken_test : public beast::unit_test::suite auto const gw = Account("gw"); env.fund(XRP(1'000), alice, bob, gw); - Json::Value jv = escrow::create(alice, bob, XRP(1)); + json::Value jv = escrow::create(alice, bob, XRP(1)); jv.removeMember(jss::Amount); jv[jss::Amount][jss::mpt_issuance_id] = "00000004A407AF5856CCF3C42619DAA925813FC955C72983"; jv[jss::Amount][jss::value] = "-1"; - auto const result = withMPT ? ter(temBAD_AMOUNT) : ter(temDISABLED); + auto const result = withMPT ? Ter(temBAD_AMOUNT) : Ter(temDISABLED); env(jv, - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), result); env.close(); } @@ -2264,16 +2264,16 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); - env(escrow::create(alice, bob, MPT(-1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(temBAD_AMOUNT)); + env(escrow::create(alice, bob, mpt(-1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(temBAD_AMOUNT)); env.close(); } } @@ -2296,15 +2296,15 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); - env(escrow::create(gw, alice, MPT(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(gw, alice, mpt(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } @@ -2319,14 +2319,14 @@ struct EscrowToken_test : public beast::unit_test::suite env.close(); auto const mpt = xrpl::test::jtx::MPT(alice.name(), makeMptID(env.seq(alice), alice)); - Json::Value jv = escrow::create(alice, bob, mpt(2)); + json::Value jv = escrow::create(alice, bob, mpt(2)); jv[jss::Amount][jss::mpt_issuance_id] = "00000004A407AF5856CCF3C42619DAA925813FC955C72983"; env(jv, - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecOBJECT_NOT_FOUND)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecOBJECT_NOT_FOUND)); env.close(); } @@ -2342,16 +2342,16 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); - env(escrow::create(alice, bob, MPT(3)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(alice, bob, mpt(3)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } @@ -2366,13 +2366,13 @@ struct EscrowToken_test : public beast::unit_test::suite MPTTester mptGw(env, gw, {.holders = {alice, bob}}); mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); - auto const MPT = mptGw["MPT"]; + auto const mpt = mptGw["MPT"]; - env(escrow::create(alice, bob, MPT(4)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecOBJECT_NOT_FOUND)); + env(escrow::create(alice, bob, mpt(4)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecOBJECT_NOT_FOUND)); env.close(); } @@ -2391,18 +2391,18 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = gw, .holder = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); // unauthorize account mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); - env(escrow::create(alice, bob, MPT(5)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, mpt(5)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -2423,19 +2423,19 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.authorize({.account = gw, .holder = alice}); mptGw.authorize({.account = bob}); mptGw.authorize({.account = gw, .holder = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // unauthorize dest mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize}); - env(escrow::create(alice, bob, MPT(6)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, mpt(6)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -2454,19 +2454,19 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // lock account mptGw.set({.account = gw, .holder = alice, .flags = tfMPTLock}); - env(escrow::create(alice, bob, MPT(7)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecLOCKED)); + env(escrow::create(alice, bob, mpt(7)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecLOCKED)); env.close(); } @@ -2485,19 +2485,19 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // lock dest mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock}); - env(escrow::create(alice, bob, MPT(8)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecLOCKED)); + env(escrow::create(alice, bob, mpt(8)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecLOCKED)); env.close(); } @@ -2513,16 +2513,16 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); - env(escrow::create(alice, bob, MPT(9)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, mpt(9)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -2539,15 +2539,15 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, bob, MPT(10))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, bob, mpt(10))); env.close(); - env(escrow::create(alice, bob, MPT(11)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecINSUFFICIENT_FUNDS)); + env(escrow::create(alice, bob, mpt(11)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_FUNDS)); env.close(); } @@ -2564,16 +2564,16 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10))); - env(pay(gw, bob, MPT(10))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10))); + env(pay(gw, bob, mpt(10))); env.close(); - env(escrow::create(alice, bob, MPT(11)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecINSUFFICIENT_FUNDS)); + env(escrow::create(alice, bob, mpt(11)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_FUNDS)); env.close(); } } @@ -2602,27 +2602,27 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.authorize({.account = gw, .holder = alice}); mptGw.authorize({.account = bob}); mptGw.authorize({.account = gw, .holder = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // unauthorize dest mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize}); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_AUTH)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); } @@ -2637,7 +2637,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const seq1 = env.seq(alice); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); auto sleNew = std::make_shared(keylet::escrow(alice, seq1)); MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}}; STAmount const amt(mpt, 10); @@ -2649,10 +2649,10 @@ struct EscrowToken_test : public beast::unit_test::suite }); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecOBJECT_NOT_FOUND)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecOBJECT_NOT_FOUND)); env.close(); } @@ -2671,27 +2671,27 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(8)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(8)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // lock dest mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock}); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecLOCKED)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecLOCKED)); env.close(); } } @@ -2720,23 +2720,23 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecINSUFFICIENT_RESERVE)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); } @@ -2754,23 +2754,23 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); } @@ -2789,23 +2789,23 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); env(escrow::finish(carol, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); env.close(); } } @@ -2834,23 +2834,23 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.authorize({.account = gw, .holder = alice}); mptGw.authorize({.account = bob}); mptGw.authorize({.account = gw, .holder = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::cancel_time(env.now() + 2s), - escrow::condition(escrow::cb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCANCEL_TIME(env.now() + 2s), + escrow::kCONDITION(escrow::kCB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // unauthorize account mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); - env(escrow::cancel(bob, alice, seq1), ter(tecNO_AUTH)); + env(escrow::cancel(bob, alice, seq1), Ter(tecNO_AUTH)); env.close(); } @@ -2864,7 +2864,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const seq1 = env.seq(alice); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); auto sleNew = std::make_shared(keylet::escrow(alice, seq1)); MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}}; STAmount const amt(mpt, 10); @@ -2875,7 +2875,7 @@ struct EscrowToken_test : public beast::unit_test::suite return true; }); - env(escrow::cancel(bob, alice, seq1), fee(baseFee), ter(tecOBJECT_NOT_FOUND)); + env(escrow::cancel(bob, alice, seq1), Fee(baseFee), Ter(tecOBJECT_NOT_FOUND)); env.close(); } } @@ -2901,166 +2901,166 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = carol}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, carol, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, carol, mpt(10'000))); env.close(); - auto outstandingMPT = env.balance(gw, MPT); + auto outstandingMPT = env.balance(gw, mpt); // Create & Finish Escrow auto const seq1 = env.seq(alice); { - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - env(escrow::create(alice, bob, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + env(escrow::create(alice, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 1'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 1'000); } { - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT + MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT + mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } // Create & Cancel Escrow auto const seq2 = env.seq(alice); { - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - env(escrow::create(alice, bob, MPT(1'000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + env(escrow::create(alice, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 1'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 1'000); } { - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - env(escrow::cancel(bob, alice, seq2), ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + env(escrow::cancel(bob, alice, seq2), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT + MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT + mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } // Self Escrow Create & Finish { auto const seq = env.seq(alice); - auto const preAliceMPT = env.balance(alice, MPT); - env(escrow::create(alice, alice, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + env(escrow::create(alice, alice, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 1'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 1'000); env(escrow::finish(alice, alice, seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } // Self Escrow Create & Cancel { auto const seq = env.seq(alice); - auto const preAliceMPT = env.balance(alice, MPT); - env(escrow::create(alice, alice, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + env(escrow::create(alice, alice, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 1'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 1'000); - env(escrow::cancel(alice, alice, seq), ter(tesSUCCESS)); + env(escrow::cancel(alice, alice, seq), Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } // Multiple Escrows { - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - auto const preCarolMPT = env.balance(carol, MPT); - env(escrow::create(alice, bob, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + auto const preCarolMPT = env.balance(carol, mpt); + env(escrow::create(alice, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env(escrow::create(carol, bob, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(carol, bob, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(carol, MPT) == preCarolMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, carol, MPT) == 1'000); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 2'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(carol, mpt) == preCarolMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, carol, mpt) == 1'000); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 2'000); } // Max MPT Amount Issued (Escrow 1 MPT) @@ -3076,44 +3076,44 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(maxMPTokenAmount))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(kMAX_MP_TOKEN_AMOUNT))); env.close(); - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - auto const outstandingMPT = env.balance(gw, MPT); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + auto const outstandingMPT = env.balance(gw, mpt); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(1)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 1); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 1); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); BEAST_EXPECT( - !env.le(keylet::mptoken(MPT.mpt(), alice))->isFieldPresent(sfLockedAmount)); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT + MPT(1)); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); - BEAST_EXPECT(!env.le(keylet::mptIssuance(MPT.mpt()))->isFieldPresent(sfLockedAmount)); + !env.le(keylet::mptoken(mpt.mpt(), alice))->isFieldPresent(sfLockedAmount)); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT + mpt(1)); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); + BEAST_EXPECT(!env.le(keylet::mptIssuance(mpt.mpt()))->isFieldPresent(sfLockedAmount)); } // Max MPT Amount Issued (Escrow Max MPT) @@ -3129,57 +3129,57 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(maxMPTokenAmount))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(kMAX_MP_TOKEN_AMOUNT))); env.close(); - auto const preAliceMPT = env.balance(alice, MPT); - auto const preBobMPT = env.balance(bob, MPT); - auto const outstandingMPT = env.balance(gw, MPT); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preBobMPT = env.balance(bob, mpt); + auto const outstandingMPT = env.balance(gw, mpt); // Escrow Max MPT - 10 auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(maxMPTokenAmount - 10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(kMAX_MP_TOKEN_AMOUNT - 10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // Escrow 10 MPT auto const seq2 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(maxMPTokenAmount)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == maxMPTokenAmount); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == maxMPTokenAmount); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(kMAX_MP_TOKEN_AMOUNT)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == kMAX_MP_TOKEN_AMOUNT); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == kMAX_MP_TOKEN_AMOUNT); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); env(escrow::finish(bob, alice, seq2), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(maxMPTokenAmount)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(bob, MPT) == preBobMPT + MPT(maxMPTokenAmount)); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == outstandingMPT); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(kMAX_MP_TOKEN_AMOUNT)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(bob, mpt) == preBobMPT + mpt(kMAX_MP_TOKEN_AMOUNT)); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == outstandingMPT); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } } @@ -3202,16 +3202,16 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); auto const aseq = env.seq(alice); auto const bseq = env.seq(bob); - env(escrow::create(alice, alice, MPT(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 500s)); + env(escrow::create(alice, alice, mpt(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 500s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -3233,9 +3233,9 @@ struct EscrowToken_test : public beast::unit_test::suite std::find(iod.begin(), iod.end(), aa) == iod.end()); } - env(escrow::create(bob, bob, MPT(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + env(escrow::create(bob, bob, mpt(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -3295,21 +3295,21 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); mptGw.authorize({.account = carol}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); - env(pay(gw, carol, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); + env(pay(gw, carol, mpt(10'000))); env.close(); auto const aseq = env.seq(alice); auto const bseq = env.seq(bob); - env(escrow::create(alice, bob, MPT(1'000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bob, mpt(1'000)), escrow::kFINISH_TIME(env.now() + 1s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); - env(escrow::create(bob, carol, MPT(1'000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + env(escrow::create(bob, carol, mpt(1'000)), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -3413,40 +3413,40 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); // issuer can be destination auto const seq1 = env.seq(alice); - auto const preAliceMPT = env.balance(alice, MPT); - auto const preOutstanding = env.balance(gw, MPT); - auto const preEscrowed = issuerMPTEscrowed(env, MPT); - BEAST_EXPECT(preOutstanding == MPT(-10'000)); + auto const preAliceMPT = env.balance(alice, mpt); + auto const preOutstanding = env.balance(gw, mpt); + auto const preEscrowed = issuerMPTEscrowed(env, mpt); + BEAST_EXPECT(preOutstanding == mpt(-10'000)); BEAST_EXPECT(preEscrowed == 0); - env(escrow::create(alice, gw, MPT(1'000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, gw, mpt(1'000)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 1'000); - BEAST_EXPECT(env.balance(gw, MPT) == preOutstanding); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == preEscrowed + 1'000); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 1'000); + BEAST_EXPECT(env.balance(gw, mpt) == preOutstanding); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == preEscrowed + 1'000); // issuer (dest) can finish escrow env(escrow::finish(gw, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAliceMPT - MPT(1'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == preOutstanding + MPT(1'000)); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == preEscrowed); + BEAST_EXPECT(env.balance(alice, mpt) == preAliceMPT - mpt(1'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == preOutstanding + mpt(1'000)); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == preEscrowed); } } @@ -3461,7 +3461,7 @@ struct EscrowToken_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // test locked rate: finish { @@ -3479,43 +3479,43 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, MPT); + auto const preAlice = env.balance(alice, mpt); auto const seq1 = env.seq(alice); - auto const delta = MPT(125); - env(escrow::create(alice, bob, MPT(125)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + auto const delta = mpt(125); + env(escrow::create(alice, bob, mpt(125)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); auto const transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 125); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 125); - BEAST_EXPECT(env.balance(gw, MPT) == MPT(-20'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 125); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 125); + BEAST_EXPECT(env.balance(gw, mpt) == mpt(-20'000)); // bob can finish escrow env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAlice - delta); - BEAST_EXPECT(env.balance(bob, MPT) == MPT(10'100)); + BEAST_EXPECT(env.balance(alice, mpt) == preAlice - delta); + BEAST_EXPECT(env.balance(bob, mpt) == mpt(10'100)); auto const escrowedWithFix = env.current()->rules().enabled(fixTokenEscrowV1) ? 0 : 25; auto const outstandingWithFix = - env.current()->rules().enabled(fixTokenEscrowV1) ? MPT(19'975) : MPT(20'000); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == escrowedWithFix); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == escrowedWithFix); - BEAST_EXPECT(env.balance(gw, MPT) == -outstandingWithFix); + env.current()->rules().enabled(fixTokenEscrowV1) ? mpt(19'975) : mpt(20'000); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == escrowedWithFix); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == escrowedWithFix); + BEAST_EXPECT(env.balance(gw, mpt) == -outstandingWithFix); } // test locked rate: cancel @@ -3534,34 +3534,34 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, MPT); - auto const preBob = env.balance(bob, MPT); + auto const preAlice = env.balance(alice, mpt); + auto const preBob = env.balance(bob, mpt); auto const seq1 = env.seq(alice); - auto const delta = MPT(125); - env(escrow::create(alice, bob, MPT(125)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 3s), - fee(baseFee * 150)); + auto const delta = mpt(125); + env(escrow::create(alice, bob, mpt(125)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 3s), + Fee(baseFee * 150)); env.close(); auto const transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); // alice can cancel escrow - env(escrow::cancel(alice, alice, seq1), fee(baseFee)); + env(escrow::cancel(alice, alice, seq1), Fee(baseFee)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAlice); - BEAST_EXPECT(env.balance(bob, MPT) == preBob); - BEAST_EXPECT(env.balance(gw, MPT) == MPT(-20'000)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == preAlice); + BEAST_EXPECT(env.balance(bob, mpt) == preBob); + BEAST_EXPECT(env.balance(gw, mpt) == mpt(-20'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); } // test locked rate: issuer is destination @@ -3580,38 +3580,38 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // alice can create escrow w/ xfer rate - auto const preAlice = env.balance(alice, MPT); + auto const preAlice = env.balance(alice, mpt); auto const seq1 = env.seq(alice); - auto const delta = MPT(125); - env(escrow::create(alice, gw, MPT(125)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + auto const delta = mpt(125); + env(escrow::create(alice, gw, mpt(125)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); auto const transferRate = escrow::rate(env, alice, seq1); BEAST_EXPECT(transferRate.value == std::uint32_t(1'000'000'000 * 1.25)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 125); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 125); - BEAST_EXPECT(env.balance(gw, MPT) == MPT(-20'000)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 125); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 125); + BEAST_EXPECT(env.balance(gw, mpt) == mpt(-20'000)); // bob can finish escrow env(escrow::finish(gw, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == preAlice - delta); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); - BEAST_EXPECT(issuerMPTEscrowed(env, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == MPT(-19'875)); + BEAST_EXPECT(env.balance(alice, mpt) == preAlice - delta); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); + BEAST_EXPECT(issuerMPTEscrowed(env, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == mpt(-19'875)); } } @@ -3637,24 +3637,24 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.authorize({.account = gw, .holder = alice}); mptGw.authorize({.account = bob}); mptGw.authorize({.account = gw, .holder = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); auto seq = env.seq(alice); - auto const delta = MPT(125); + auto const delta = mpt(125); // alice can create escrow - is authorized - env(escrow::create(alice, bob, MPT(100)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(100)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // bob can finish escrow - is authorized env(escrow::finish(bob, alice, seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); } @@ -3678,18 +3678,18 @@ struct EscrowToken_test : public beast::unit_test::suite .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // alice create escrow auto seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(100)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(100)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150)); env.close(); // lock account & dest @@ -3698,10 +3698,10 @@ struct EscrowToken_test : public beast::unit_test::suite // bob cannot finish env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecLOCKED)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecLOCKED)); env.close(); // bob can cancel @@ -3726,35 +3726,35 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); // alice cannot create escrow to non issuer - env(escrow::create(alice, bob, MPT(100)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150), - ter(tecNO_AUTH)); + env(escrow::create(alice, bob, mpt(100)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150), + Ter(tecNO_AUTH)); env.close(); // Escrow Create & Finish { // alice an create escrow to issuer auto seq = env.seq(alice); - env(escrow::create(alice, gw, MPT(100)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, gw, mpt(100)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); // gw can finish env(escrow::finish(gw, alice, seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); env.close(); } @@ -3762,11 +3762,11 @@ struct EscrowToken_test : public beast::unit_test::suite { // alice an create escrow to issuer auto seq = env.seq(alice); - env(escrow::create(alice, gw, MPT(100)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150)); + env(escrow::create(alice, gw, mpt(100)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150)); env.close(); // alice can cancel @@ -3795,37 +3795,37 @@ struct EscrowToken_test : public beast::unit_test::suite {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); mptGw.authorize({.account = bob}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); - env(pay(gw, bob, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); + env(pay(gw, bob, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); - env(pay(alice, gw, MPT(10'000)), ter(tecPATH_PARTIAL)); - env(pay(alice, gw, MPT(9'990))); - env(pay(bob, gw, MPT(10'000))); - BEAST_EXPECT(env.balance(alice, MPT) == MPT(0)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 10); - BEAST_EXPECT(env.balance(bob, MPT) == MPT(0)); - BEAST_EXPECT(mptEscrowed(env, bob, MPT) == 0); - BEAST_EXPECT(env.balance(gw, MPT) == MPT(-10)); + env(pay(alice, gw, mpt(10'000)), Ter(tecPATH_PARTIAL)); + env(pay(alice, gw, mpt(9'990))); + env(pay(bob, gw, mpt(10'000))); + BEAST_EXPECT(env.balance(alice, mpt) == mpt(0)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 10); + BEAST_EXPECT(env.balance(bob, mpt) == mpt(0)); + BEAST_EXPECT(mptEscrowed(env, bob, mpt) == 0); + BEAST_EXPECT(env.balance(gw, mpt) == mpt(-10)); mptGw.authorize({.account = bob, .flags = tfMPTUnauthorize}); mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 1, .err = tecHAS_OBLIGATIONS}); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env(pay(bob, gw, MPT(10))); + env(pay(bob, gw, mpt(10))); mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 0}); } @@ -3843,37 +3843,37 @@ struct EscrowToken_test : public beast::unit_test::suite mptGw.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer}); mptGw.authorize({.account = alice}); - auto const MPT = mptGw["MPT"]; - env(pay(gw, alice, MPT(10'000))); + auto const mpt = mptGw["MPT"]; + env(pay(gw, alice, mpt(10'000))); env.close(); auto const seq1 = env.seq(alice); - env(escrow::create(alice, bob, MPT(10)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + env(escrow::create(alice, bob, mpt(10)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - env(pay(alice, gw, MPT(9'990))); + env(pay(alice, gw, mpt(9'990))); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == MPT(0)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 10); + BEAST_EXPECT(env.balance(alice, mpt) == mpt(0)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 10); mptGw.authorize( {.account = alice, .flags = tfMPTUnauthorize, .err = tecHAS_OBLIGATIONS}); env(escrow::finish(bob, alice, seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); - BEAST_EXPECT(env.balance(alice, MPT) == MPT(0)); - BEAST_EXPECT(mptEscrowed(env, alice, MPT) == 0); + BEAST_EXPECT(env.balance(alice, mpt) == mpt(0)); + BEAST_EXPECT(mptEscrowed(env, alice, mpt) == 0); mptGw.authorize({.account = alice, .flags = tfMPTUnauthorize}); - BEAST_EXPECT(!env.le(keylet::mptoken(MPT.mpt(), alice))); + BEAST_EXPECT(!env.le(keylet::mptoken(mpt.mpt(), alice))); } } @@ -3923,7 +3923,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; for (FeatureBitset const& feats : {all - featureSingleAssetVault - featureLendingProtocol, all}) { diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 77d51f2758..408e9c4edf 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -34,7 +34,7 @@ namespace xrpl::test { -struct Escrow_test : public beast::unit_test::suite +struct Escrow_test : public beast::unit_test::Suite { void testEnablement(FeatureBitset features) @@ -47,30 +47,30 @@ struct Escrow_test : public beast::unit_test::suite Env env(*this, features); auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); - env(escrow::create("alice", "bob", XRP(1000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create("alice", "bob", XRP(1000)), escrow::kFINISH_TIME(env.now() + 1s)); env.close(); auto const seq1 = env.seq("alice"); env(escrow::create("alice", "bob", XRP(1000)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); env.close(); env(escrow::finish("bob", "alice", seq1), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); auto const seq2 = env.seq("alice"); env(escrow::create("alice", "bob", XRP(1000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s), + Fee(baseFee * 150)); env.close(); - env(escrow::cancel("bob", "alice", seq2), fee(baseFee * 150)); + env(escrow::cancel("bob", "alice", seq2), Fee(baseFee * 150)); } void @@ -90,14 +90,14 @@ struct Escrow_test : public beast::unit_test::suite auto const ts = env.now() + 97s; auto const seq = env.seq("alice"); - env(escrow::create("alice", "bob", XRP(1000)), escrow::finish_time(ts)); + env(escrow::create("alice", "bob", XRP(1000)), escrow::kFINISH_TIME(ts)); // Advance the ledger, verifying that the finish won't complete // prematurely. for (; env.now() < ts; env.close()) - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150)); } { @@ -112,23 +112,23 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); env(escrow::create("alice", "bob", XRP(1000)), - escrow::condition(escrow::cb1), - escrow::cancel_time(ts)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(ts)); // Advance the ledger, verifying that the cancel won't complete // prematurely. for (; env.now() < ts; env.close()) - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); // Verify that a finish won't work anymore. env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); // Verify that the cancel will succeed - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150)); } { @@ -144,22 +144,22 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); env(escrow::create("alice", "bob", XRP(1000)), - escrow::finish_time(fts), - escrow::cancel_time(cts)); + escrow::kFINISH_TIME(fts), + escrow::kCANCEL_TIME(cts)); // Advance the ledger, verifying that the finish and cancel won't // complete prematurely. for (; env.now() < fts; env.close()) { - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); } // Verify that a cancel still won't work - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); // And verify that a finish will - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150)); } { @@ -175,28 +175,28 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); env(escrow::create("alice", "bob", XRP(1000)), - escrow::finish_time(fts), - escrow::cancel_time(cts)); + escrow::kFINISH_TIME(fts), + escrow::kCANCEL_TIME(cts)); // Advance the ledger, verifying that the finish and cancel won't // complete prematurely. for (; env.now() < fts; env.close()) { - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); } // Continue advancing, verifying that the cancel won't complete // prematurely. At this point a finish would succeed. for (; env.now() < cts; env.close()) - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); // Verify that finish will no longer work, since we are past the // cancel activation time. - env(escrow::finish("bob", "alice", seq), fee(baseFee * 150), ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Fee(baseFee * 150), Ter(tecNO_PERMISSION)); // And verify that a cancel will succeed. - env(escrow::cancel("bob", "alice", seq), fee(baseFee * 150)); + env(escrow::cancel("bob", "alice", seq), Fee(baseFee * 150)); } } @@ -219,16 +219,16 @@ struct Escrow_test : public beast::unit_test::suite // required: env(fset(bob, asfRequireDest)); env(escrow::create(alice, bob, XRP(1000)), - escrow::finish_time(env.now() + 1s), - ter(tecDST_TAG_NEEDED)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(tecDST_TAG_NEEDED)); // set source and dest tags auto const seq = env.seq(alice); env(escrow::create(alice, bob, XRP(1000)), - escrow::finish_time(env.now() + 1s), - stag(1), - dtag(2)); + escrow::kFINISH_TIME(env.now() + 1s), + Stag(1), + Dtag(2)); auto const sle = env.le(keylet::escrow(alice.id(), seq)); BEAST_EXPECT(sle); @@ -259,7 +259,7 @@ struct Escrow_test : public beast::unit_test::suite env.fund(XRP(5000), "bob", "george"); env(fset("george", asfDisallowXRP)); - env(escrow::create("bob", "george", XRP(10)), escrow::finish_time(env.now() + 1s)); + env(escrow::create("bob", "george", XRP(10)), escrow::kFINISH_TIME(env.now() + 1s)); } } @@ -278,34 +278,34 @@ struct Escrow_test : public beast::unit_test::suite // Creating an escrow with only a cancel time is not allowed: env(escrow::create("alice", "bob", XRP(100)), - escrow::cancel_time(env.now() + 90s), - fee(baseFee * 150), - ter(temMALFORMED)); + escrow::kCANCEL_TIME(env.now() + 90s), + Fee(baseFee * 150), + Ter(temMALFORMED)); - // Creating an escrow with only a cancel time and a condition is + // Creating an escrow with only a cancel time and a kCONDITION is // allowed: auto const seq = env.seq("alice"); env(escrow::create("alice", "bob", XRP(100)), - escrow::cancel_time(env.now() + 90s), - escrow::condition(escrow::cb1), - fee(baseFee * 150)); + escrow::kCANCEL_TIME(env.now() + 90s), + escrow::kCONDITION(escrow::kCB1), + Fee(baseFee * 150)); env.close(); env(escrow::finish("carol", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150)); BEAST_EXPECT(env.balance("bob") == XRP(5100)); // Creating an escrow with only a cancel time and a finish time is // allowed: auto const seqFt = env.seq("alice"); env(escrow::create("alice", "bob", XRP(100)), - escrow::finish_time(env.now()), // Set finish time to now so that - // we can call finish immediately. - escrow::cancel_time(env.now() + 50s), - fee(baseFee * 150)); + escrow::kFINISH_TIME(env.now()), // Set finish time to now so that + // we can call finish immediately. + escrow::kCANCEL_TIME(env.now() + 50s), + Fee(baseFee * 150)); env.close(); - env(escrow::finish("carol", "alice", seqFt), fee(150 * baseFee)); + env(escrow::finish("carol", "alice", seqFt), Fee(150 * baseFee)); BEAST_EXPECT(env.balance("bob") == XRP(5200)); // 5100 (from last transaction) + 100 } @@ -324,25 +324,25 @@ struct Escrow_test : public beast::unit_test::suite // temINVALID_FLAG env(escrow::create("alice", "bob", XRP(1000)), - escrow::finish_time(env.now() + 5s), - txflags(tfPassive), - ter(temINVALID_FLAG)); + escrow::kFINISH_TIME(env.now() + 5s), + Txflags(tfPassive), + Ter(temINVALID_FLAG)); // Finish time is in the past env(escrow::create("alice", "bob", XRP(1000)), - escrow::finish_time(env.now() - 5s), - ter(tecNO_PERMISSION)); + escrow::kFINISH_TIME(env.now() - 5s), + Ter(tecNO_PERMISSION)); // Cancel time is in the past env(escrow::create("alice", "bob", XRP(1000)), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() - 5s), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() - 5s), + Ter(tecNO_PERMISSION)); // no destination account env(escrow::create("alice", "carol", XRP(1000)), - escrow::finish_time(env.now() + 1s), - ter(tecNO_DST)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(tecNO_DST)); env.fund(XRP(5000), "carol"); @@ -351,61 +351,61 @@ struct Escrow_test : public beast::unit_test::suite { // tecNO_PERMISSION: token escrow is enabled but the issuer did not // set the asfAllowTrustLineLocking flag - auto const txResult = withTokenEscrow ? ter(tecNO_PERMISSION) : ter(temBAD_AMOUNT); + auto const txResult = withTokenEscrow ? Ter(tecNO_PERMISSION) : Ter(temBAD_AMOUNT); env(escrow::create("alice", "carol", Account("alice")["USD"](500)), - escrow::finish_time(env.now() + 5s), + escrow::kFINISH_TIME(env.now() + 5s), txResult); } // Sending zero or no XRP: env(escrow::create("alice", "carol", XRP(0)), - escrow::finish_time(env.now() + 1s), - ter(temBAD_AMOUNT)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(temBAD_AMOUNT)); env(escrow::create("alice", "carol", XRP(-1000)), - escrow::finish_time(env.now() + 1s), - ter(temBAD_AMOUNT)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(temBAD_AMOUNT)); // Fail if neither CancelAfter nor FinishAfter are specified: - env(escrow::create("alice", "carol", XRP(1)), ter(temBAD_EXPIRATION)); + env(escrow::create("alice", "carol", XRP(1)), Ter(temBAD_EXPIRATION)); - // Fail if neither a FinishTime nor a condition are attached: + // Fail if neither a FinishTime nor a kCONDITION are attached: env(escrow::create("alice", "carol", XRP(1)), - escrow::cancel_time(env.now() + 1s), - ter(temMALFORMED)); + escrow::kCANCEL_TIME(env.now() + 1s), + Ter(temMALFORMED)); // Fail if FinishAfter has already passed: env(escrow::create("alice", "carol", XRP(1)), - escrow::finish_time(env.now() - 1s), - ter(tecNO_PERMISSION)); + escrow::kFINISH_TIME(env.now() - 1s), + Ter(tecNO_PERMISSION)); // If both CancelAfter and FinishAfter are set, then CancelAfter must // be strictly later than FinishAfter. env(escrow::create("alice", "carol", XRP(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 10s), - escrow::cancel_time(env.now() + 10s), - ter(temBAD_EXPIRATION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 10s), + escrow::kCANCEL_TIME(env.now() + 10s), + Ter(temBAD_EXPIRATION)); env(escrow::create("alice", "carol", XRP(1)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 10s), - escrow::cancel_time(env.now() + 5s), - ter(temBAD_EXPIRATION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 10s), + escrow::kCANCEL_TIME(env.now() + 5s), + Ter(temBAD_EXPIRATION)); // Carol now requires the use of a destination tag env(fset("carol", asfRequireDest)); // missing destination tag env(escrow::create("alice", "carol", XRP(1)), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s), - ter(tecDST_TAG_NEEDED)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s), + Ter(tecDST_TAG_NEEDED)); // Success! env(escrow::create("alice", "carol", XRP(1)), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s), - dtag(1)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s), + Dtag(1)); { // Fail if the sender wants to send more than he has: auto const accountReserve = drops(env.current()->fees().reserve); @@ -413,41 +413,41 @@ struct Escrow_test : public beast::unit_test::suite env.fund(accountReserve + accountIncrement + XRP(50), "daniel"); env(escrow::create("daniel", "bob", XRP(51)), - escrow::finish_time(env.now() + 1s), - ter(tecUNFUNDED)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(tecUNFUNDED)); env.fund(accountReserve + accountIncrement + XRP(50), "evan"); env(escrow::create("evan", "bob", XRP(50)), - escrow::finish_time(env.now() + 1s), - ter(tecUNFUNDED)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(tecUNFUNDED)); env.fund(accountReserve, "frank"); env(escrow::create("frank", "bob", XRP(1)), - escrow::finish_time(env.now() + 1s), - ter(tecINSUFFICIENT_RESERVE)); + escrow::kFINISH_TIME(env.now() + 1s), + Ter(tecINSUFFICIENT_RESERVE)); } { // Specify incorrect sequence number env.fund(XRP(5000), "hannah"); auto const seq = env.seq("hannah"); env(escrow::create("hannah", "hannah", XRP(10)), - escrow::finish_time(env.now() + 1s), - fee(150 * baseFee)); + escrow::kFINISH_TIME(env.now() + 1s), + Fee(150 * baseFee)); env.close(); - env(escrow::finish("hannah", "hannah", seq + 7), fee(150 * baseFee), ter(tecNO_TARGET)); + env(escrow::finish("hannah", "hannah", seq + 7), Fee(150 * baseFee), Ter(tecNO_TARGET)); } - { // Try to specify a condition for a non-conditional payment + { // Try to specify a kCONDITION for a non-conditional payment env.fund(XRP(5000), "ivan"); auto const seq = env.seq("ivan"); - env(escrow::create("ivan", "ivan", XRP(10)), escrow::finish_time(env.now() + 1s)); + env(escrow::create("ivan", "ivan", XRP(10)), escrow::kFINISH_TIME(env.now() + 1s)); env.close(); env(escrow::finish("ivan", "ivan", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); } } @@ -465,21 +465,21 @@ struct Escrow_test : public beast::unit_test::suite auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); - env(escrow::create("alice", "alice", XRP(1000)), escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + env(escrow::create("alice", "alice", XRP(1000)), escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("bob", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Ter(tecNO_PERMISSION)); env.close(); // Cancel continues to not be possible - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); // Finish should succeed. Verify funds. env(escrow::finish("bob", "alice", seq)); - env.require(balance("alice", XRP(5000) - drops(baseFee))); + env.require(Balance("alice", XRP(5000) - drops(baseFee))); } { // Unconditionally pay from Alice to Bob. Zelda (neither source nor @@ -489,25 +489,25 @@ struct Escrow_test : public beast::unit_test::suite auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); - env(escrow::create("alice", "bob", XRP(1000)), escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + env(escrow::create("alice", "bob", XRP(1000)), escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. - env(escrow::cancel("zelda", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("zelda", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("zelda", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("zelda", "alice", seq), Ter(tecNO_PERMISSION)); env.close(); // Cancel continues to not be possible - env(escrow::cancel("zelda", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("zelda", "alice", seq), Ter(tecNO_PERMISSION)); // Finish should succeed. Verify funds. env(escrow::finish("zelda", "alice", seq)); env.close(); - env.require(balance("alice", XRP(4000) - drops(baseFee))); - env.require(balance("bob", XRP(6000))); - env.require(balance("zelda", XRP(5000) - drops(4 * baseFee))); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); + env.require(Balance("bob", XRP(6000))); + env.require(Balance("zelda", XRP(5000) - drops(4 * baseFee))); } { // Bob sets DepositAuth so only Bob can finish the escrow. @@ -519,32 +519,32 @@ struct Escrow_test : public beast::unit_test::suite env.close(); auto const seq = env.seq("alice"); - env(escrow::create("alice", "bob", XRP(1000)), escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + env(escrow::create("alice", "bob", XRP(1000)), escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. - env(escrow::cancel("zelda", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("alice", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("zelda", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("alice", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("bob", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("zelda", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("alice", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("zelda", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("alice", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Ter(tecNO_PERMISSION)); env.close(); // Cancel continues to not be possible. Finish will only succeed for // Bob, because of DepositAuth. - env(escrow::cancel("zelda", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("alice", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("zelda", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("alice", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("zelda", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("alice", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("zelda", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("alice", "alice", seq), Ter(tecNO_PERMISSION)); env(escrow::finish("bob", "alice", seq)); env.close(); - env.require(balance("alice", XRP(4000) - (baseFee * 5))); - env.require(balance("bob", XRP(6000) - (baseFee * 5))); - env.require(balance("zelda", XRP(5000) - (baseFee * 4))); + env.require(Balance("alice", XRP(4000) - (baseFee * 5))); + env.require(Balance("bob", XRP(6000) - (baseFee * 5))); + env.require(Balance("zelda", XRP(5000) - (baseFee * 4))); } { // Bob sets DepositAuth but preauthorizes Zelda, so Zelda can @@ -559,20 +559,20 @@ struct Escrow_test : public beast::unit_test::suite env.close(); auto const seq = env.seq("alice"); - env(escrow::create("alice", "bob", XRP(1000)), escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + env(escrow::create("alice", "bob", XRP(1000)), escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); env.close(); // DepositPreauth allows Finish to succeed for either Zelda or // Bob. But Finish won't succeed for Alice since she is not // preauthorized. - env(escrow::finish("alice", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::finish("alice", "alice", seq), Ter(tecNO_PERMISSION)); env(escrow::finish("zelda", "alice", seq)); env.close(); - env.require(balance("alice", XRP(4000) - (baseFee * 2))); - env.require(balance("bob", XRP(6000) - (baseFee * 2))); - env.require(balance("zelda", XRP(5000) - (baseFee * 1))); + env.require(Balance("alice", XRP(4000) - (baseFee * 2))); + env.require(Balance("bob", XRP(6000) - (baseFee * 2))); + env.require(Balance("zelda", XRP(5000) - (baseFee * 1))); } { // Conditional @@ -581,40 +581,40 @@ struct Escrow_test : public beast::unit_test::suite env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow::create("alice", "alice", XRP(1000)), - escrow::condition(escrow::cb2), - escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + escrow::kCONDITION(escrow::kCB2), + escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); // Not enough time has elapsed for a finish and canceling isn't // possible. - env(escrow::cancel("alice", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("alice", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("alice", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("alice", "alice", seq), Ter(tecNO_PERMISSION)); env(escrow::finish("alice", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee), - ter(tecNO_PERMISSION)); - env(escrow::finish("bob", "alice", seq), ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee), + Ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Ter(tecNO_PERMISSION)); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee), + Ter(tecNO_PERMISSION)); env.close(); // Cancel continues to not be possible. Finish is possible but - // requires the fulfillment associated with the escrow. - env(escrow::cancel("alice", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); - env(escrow::finish("bob", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); - env(escrow::finish("alice", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); + // requires the kFULFILLMENT associated with the escrow. + env(escrow::cancel("alice", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); + env(escrow::finish("bob", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("alice", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); env.close(); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee)); } { // Self-escrowed conditional with DepositAuth. @@ -624,14 +624,14 @@ struct Escrow_test : public beast::unit_test::suite env.fund(XRP(5000), "alice", "bob"); auto const seq = env.seq("alice"); env(escrow::create("alice", "alice", XRP(1000)), - escrow::condition(escrow::cb3), - escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + escrow::kCONDITION(escrow::kCB3), + escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); env.close(); // Finish is now possible but requires the cryptocondition. - env(escrow::finish("bob", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); - env(escrow::finish("alice", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("bob", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("alice", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); // Enable deposit authorization. After this only Alice can finish // the escrow. @@ -639,19 +639,19 @@ struct Escrow_test : public beast::unit_test::suite env.close(); env(escrow::finish("alice", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee), + Ter(tecNO_PERMISSION)); env(escrow::finish("alice", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee)); } { // Self-escrowed conditional with DepositAuth and DepositPreauth. @@ -661,9 +661,9 @@ struct Escrow_test : public beast::unit_test::suite env.fund(XRP(5000), "alice", "bob", "zelda"); auto const seq = env.seq("alice"); env(escrow::create("alice", "alice", XRP(1000)), - escrow::condition(escrow::cb3), - escrow::finish_time(env.now() + 5s)); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + escrow::kCONDITION(escrow::kCB3), + escrow::kFINISH_TIME(env.now() + 5s)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); env.close(); // Alice preauthorizes Zelda for deposit, even though Alice has not @@ -672,9 +672,9 @@ struct Escrow_test : public beast::unit_test::suite env.close(); // Finish is now possible but requires the cryptocondition. - env(escrow::finish("alice", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); - env(escrow::finish("bob", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); - env(escrow::finish("zelda", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("alice", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("bob", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); + env(escrow::finish("zelda", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); // Alice enables deposit authorization. After this only Alice or // Zelda (because Zelda is preauthorized) can finish the escrow. @@ -682,19 +682,19 @@ struct Escrow_test : public beast::unit_test::suite env.close(); env(escrow::finish("alice", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee), + Ter(tecNO_PERMISSION)); env(escrow::finish("zelda", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee)); } } @@ -713,87 +713,87 @@ struct Escrow_test : public beast::unit_test::suite auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(escrow::cb1), - escrow::cancel_time(env.now() + 1s)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(env.now() + 1s)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - env.require(balance("alice", XRP(4000) - drops(baseFee))); - env.require(balance("carol", XRP(5000))); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); + env.require(Balance("carol", XRP(5000))); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - // Attempt to finish without a fulfillment - env(escrow::finish("bob", "alice", seq), ter(tecCRYPTOCONDITION_ERROR)); + // Attempt to finish without a kFULFILLMENT + env(escrow::finish("bob", "alice", seq), Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - // Attempt to finish with a condition instead of a fulfillment + // Attempt to finish with a kCONDITION instead of a kFULFILLMENT env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::cb1), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kCB1), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::cb2), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kCB2), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::cb3), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kCB3), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - // Attempt to finish with an incorrect condition and various + // Attempt to finish with an incorrect kCONDITION and various // combinations of correct and incorrect fulfillments. env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb1), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - // Attempt to finish with the correct condition & fulfillment + // Attempt to finish with the correct kCONDITION & kFULFILLMENT env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(150 * baseFee)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(150 * baseFee)); // SLE removed on finish BEAST_EXPECT(!env.le(keylet::escrow(Account("alice").id(), seq))); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); - env.require(balance("carol", XRP(6000))); - env(escrow::cancel("bob", "alice", seq), ter(tecNO_TARGET)); + env.require(Balance("carol", XRP(6000))); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_TARGET)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); - env(escrow::cancel("bob", "carol", 1), ter(tecNO_TARGET)); + env(escrow::cancel("bob", "carol", 1), Ter(tecNO_TARGET)); } - { // Test cancel when condition is present + { // Test cancel when kCONDITION is present Env env(*this, features); auto const baseFee = env.current()->fees().base; env.fund(XRP(5000), "alice", "bob", "carol"); auto const seq = env.seq("alice"); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(escrow::cb2), - escrow::cancel_time(env.now() + 1s)); + escrow::kCONDITION(escrow::kCB2), + escrow::kCANCEL_TIME(env.now() + 1s)); env.close(); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); // balance restored on cancel env(escrow::cancel("bob", "alice", seq)); - env.require(balance("alice", XRP(5000) - drops(baseFee))); + env.require(Balance("alice", XRP(5000) - drops(baseFee))); // SLE removed on cancel BEAST_EXPECT(!env.le(keylet::escrow(Account("alice").id(), seq))); } @@ -804,29 +804,29 @@ struct Escrow_test : public beast::unit_test::suite env.close(); auto const seq = env.seq("alice"); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(escrow::cb3), - escrow::cancel_time(env.now() + 1s)); + escrow::kCONDITION(escrow::kCB3), + escrow::kCANCEL_TIME(env.now() + 1s)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); // cancel fails before expiration - env(escrow::cancel("bob", "alice", seq), ter(tecNO_PERMISSION)); + env(escrow::cancel("bob", "alice", seq), Ter(tecNO_PERMISSION)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); env.close(); // finish fails after expiration env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee), + Ter(tecNO_PERMISSION)); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); - env.require(balance("carol", XRP(5000))); + env.require(Balance("carol", XRP(5000))); } { // Test long & short conditions during creation Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); std::vector v; - v.resize(escrow::cb1.size() + 2, 0x78); - std::memcpy(v.data() + 1, escrow::cb1.data(), escrow::cb1.size()); + v.resize(escrow::kCB1.size() + 2, 0x78); + std::memcpy(v.data() + 1, escrow::kCB1.data(), escrow::kCB1.size()); auto const p = v.data(); auto const s = v.size(); @@ -834,64 +834,64 @@ struct Escrow_test : public beast::unit_test::suite auto const ts = env.now() + 1s; // All these are expected to fail, because the - // condition we pass in is malformed in some way + // kCONDITION we pass in is malformed in some way env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p, s}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p, s}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p, s - 1}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p, s - 1}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p, s - 2}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p, s - 2}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p + 1, s - 1}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p + 1, s - 1}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p + 1, s - 3}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p + 1, s - 3}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p + 2, s - 2}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p + 2, s - 2}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p + 2, s - 3}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{p + 2, s - 3}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); auto const seq = env.seq("alice"); auto const baseFee = env.current()->fees().base; env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{p + 1, s - 2}), - escrow::cancel_time(ts), - fee(10 * baseFee)); + escrow::kCONDITION(Slice{p + 1, s - 2}), + escrow::kCANCEL_TIME(ts), + Fee(10 * baseFee)); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(150 * baseFee)); - env.require(balance("alice", XRP(4000) - drops(10 * baseFee))); - env.require(balance("bob", XRP(5000) - drops(150 * baseFee))); - env.require(balance("carol", XRP(6000))); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(150 * baseFee)); + env.require(Balance("alice", XRP(4000) - drops(10 * baseFee))); + env.require(Balance("bob", XRP(5000) - drops(150 * baseFee))); + env.require(Balance("carol", XRP(6000))); } { // Test long and short conditions & fulfillments during finish Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); std::vector cv; - cv.resize(escrow::cb2.size() + 2, 0x78); - std::memcpy(cv.data() + 1, escrow::cb2.data(), escrow::cb2.size()); + cv.resize(escrow::kCB2.size() + 2, 0x78); + std::memcpy(cv.data() + 1, escrow::kCB2.data(), escrow::kCB2.size()); auto const cp = cv.data(); auto const cs = cv.size(); std::vector fv; - fv.resize(escrow::fb2.size() + 2, 0x13); - std::memcpy(fv.data() + 1, escrow::fb2.data(), escrow::fb2.size()); + fv.resize(escrow::kFB2.size() + 2, 0x13); + std::memcpy(fv.data() + 1, escrow::kFB2.data(), escrow::kFB2.size()); auto const fp = fv.data(); auto const fs = fv.size(); @@ -899,181 +899,181 @@ struct Escrow_test : public beast::unit_test::suite auto const ts = env.now() + 1s; // All these are expected to fail, because the - // condition we pass in is malformed in some way + // kCONDITION we pass in is malformed in some way env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp, cs}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp, cs}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp, cs - 1}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp, cs - 1}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp, cs - 2}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp, cs - 2}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp + 1, cs - 1}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp + 1, cs - 1}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp + 1, cs - 3}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp + 1, cs - 3}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp + 2, cs - 2}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp + 2, cs - 2}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp + 2, cs - 3}), - escrow::cancel_time(ts), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{cp + 2, cs - 3}), + escrow::kCANCEL_TIME(ts), + Ter(temMALFORMED)); auto const seq = env.seq("alice"); auto const baseFee = env.current()->fees().base; env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::cancel_time(ts), - fee(10 * baseFee)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kCANCEL_TIME(ts), + Fee(10 * baseFee)); // Now, try to fulfill using the same sequence of // malformed conditions. env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp, cs}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp, cs}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp, cs - 1}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp, cs - 1}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp, cs - 2}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp, cs - 2}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 1}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 1}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 3}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 3}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 2, cs - 2}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 2, cs - 2}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 2, cs - 3}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 2, cs - 3}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); - // Now, using the correct condition, try malformed fulfillments: + // Now, using the correct kCONDITION, try malformed fulfillments: env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp, fs}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp, fs}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp, fs - 1}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp, fs - 1}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp, fs - 2}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp, fs - 2}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp + 1, fs - 1}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp + 1, fs - 1}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp + 1, fs - 3}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp + 1, fs - 3}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp + 1, fs - 3}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp + 1, fs - 3}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp + 2, fs - 2}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp + 2, fs - 2}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{cp + 1, cs - 2}), - escrow::fulfillment(Slice{fp + 2, fs - 3}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{cp + 1, cs - 2}), + escrow::kFULFILLMENT(Slice{fp + 2, fs - 3}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); // Now try for the right one env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb2), - escrow::fulfillment(escrow::fb2), - fee(150 * baseFee)); - env.require(balance("alice", XRP(4000) - drops(10 * baseFee))); - env.require(balance("carol", XRP(6000))); + escrow::kCONDITION(escrow::kCB2), + escrow::kFULFILLMENT(escrow::kFB2), + Fee(150 * baseFee)); + env.require(Balance("alice", XRP(4000) - drops(10 * baseFee))); + env.require(Balance("carol", XRP(6000))); } - { // Test empty condition during creation and - // empty condition & fulfillment during finish + { // Test empty kCONDITION during creation and + // empty kCONDITION & kFULFILLMENT during finish Env env(*this, features); env.fund(XRP(5000), "alice", "bob", "carol"); env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(Slice{}), - escrow::cancel_time(env.now() + 1s), - ter(temMALFORMED)); + escrow::kCONDITION(Slice{}), + escrow::kCANCEL_TIME(env.now() + 1s), + Ter(temMALFORMED)); auto const seq = env.seq("alice"); auto const baseFee = env.current()->fees().base; env(escrow::create("alice", "carol", XRP(1000)), - escrow::condition(escrow::cb3), - escrow::cancel_time(env.now() + 1s)); + escrow::kCONDITION(escrow::kCB3), + escrow::kCANCEL_TIME(env.now() + 1s)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{}), - escrow::fulfillment(Slice{}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{}), + escrow::kFULFILLMENT(Slice{}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(Slice{}), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(Slice{}), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); env(escrow::finish("bob", "alice", seq), - escrow::condition(Slice{}), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee), - ter(tecCRYPTOCONDITION_ERROR)); + escrow::kCONDITION(Slice{}), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee), + Ter(tecCRYPTOCONDITION_ERROR)); // Assemble finish that is missing the Condition or the Fulfillment // since either both must be present, or neither can: env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - ter(temMALFORMED)); + escrow::kCONDITION(escrow::kCB3), + Ter(temMALFORMED)); env(escrow::finish("bob", "alice", seq), - escrow::fulfillment(escrow::fb3), - ter(temMALFORMED)); + escrow::kFULFILLMENT(escrow::kFB3), + Ter(temMALFORMED)); // Now finish it. env(escrow::finish("bob", "alice", seq), - escrow::condition(escrow::cb3), - escrow::fulfillment(escrow::fb3), - fee(150 * baseFee)); - env.require(balance("carol", XRP(6000))); - env.require(balance("alice", XRP(4000) - drops(baseFee))); + escrow::kCONDITION(escrow::kCB3), + escrow::kFULFILLMENT(escrow::kFB3), + Fee(150 * baseFee)); + env.require(Balance("carol", XRP(6000))); + env.require(Balance("alice", XRP(4000) - drops(baseFee))); } - { // Test a condition other than PreimageSha256, which + { // Test a kCONDITION other than PreimageSha256, which // would require a separate amendment Env env(*this, features); env.fund(XRP(5000), "alice", "bob"); @@ -1087,9 +1087,9 @@ struct Escrow_test : public beast::unit_test::suite // FIXME: this transaction should, eventually, return temDISABLED // instead of temMALFORMED. env(escrow::create("alice", "bob", XRP(1000)), - escrow::condition(cb), - escrow::cancel_time(env.now() + 1s), - ter(temMALFORMED)); + escrow::kCONDITION(cb), + escrow::kCANCEL_TIME(env.now() + 1s), + Ter(temMALFORMED)); } } @@ -1112,8 +1112,8 @@ struct Escrow_test : public beast::unit_test::suite auto const bseq = env.seq(bruce); env(escrow::create(alice, alice, XRP(1000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 500s)); + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 500s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1129,8 +1129,8 @@ struct Escrow_test : public beast::unit_test::suite } env(escrow::create(bruce, bruce, XRP(1000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1187,13 +1187,13 @@ struct Escrow_test : public beast::unit_test::suite auto const aseq = env.seq(alice); auto const bseq = env.seq(bruce); - env(escrow::create(alice, bruce, XRP(1000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bruce, XRP(1000)), escrow::kFINISH_TIME(env.now() + 1s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); env(escrow::create(bruce, carol, XRP(1000)), - escrow::finish_time(env.now() + 1s), - escrow::cancel_time(env.now() + 2s)); + escrow::kFINISH_TIME(env.now() + 1s), + escrow::kCANCEL_TIME(env.now() + 2s)); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); env.close(5s); @@ -1296,11 +1296,11 @@ struct Escrow_test : public beast::unit_test::suite { auto const jtx = env.jt( escrow::create("alice", "carol", XRP(1000)), - escrow::finish_time(env.now() + 1s), - seq(1), - fee(baseFee)); + escrow::kFINISH_TIME(env.now() + 1s), + Seq(1), + Fee(baseFee)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); @@ -1308,9 +1308,9 @@ struct Escrow_test : public beast::unit_test::suite } { - auto const jtx = env.jt(escrow::cancel("bob", "alice", 3), seq(1), fee(baseFee)); + auto const jtx = env.jt(escrow::cancel("bob", "alice", 3), Seq(1), Fee(baseFee)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); @@ -1318,9 +1318,9 @@ struct Escrow_test : public beast::unit_test::suite } { - auto const jtx = env.jt(escrow::finish("bob", "alice", 3), seq(1), fee(baseFee)); + auto const jtx = env.jt(escrow::finish("bob", "alice", 3), Seq(1), Fee(baseFee)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(baseFee)); @@ -1352,12 +1352,12 @@ struct Escrow_test : public beast::unit_test::suite // bob creates a bunch of tickets because he will be burning // through them with tec transactions. Just because we can // we'll use them up starting from largest and going smaller. - constexpr static std::uint32_t bobTicketCount{20}; - env(ticket::create(bob, bobTicketCount)); + constexpr static std::uint32_t kBOB_TICKET_COUNT{20}; + env(ticket::create(bob, kBOB_TICKET_COUNT)); env.close(); std::uint32_t bobTicket{env.seq(bob)}; env.require(tickets(alice, 1)); - env.require(tickets(bob, bobTicketCount)); + env.require(tickets(bob, kBOB_TICKET_COUNT)); // Note that from here on all transactions use tickets. No account // root sequences should change. @@ -1369,33 +1369,33 @@ struct Escrow_test : public beast::unit_test::suite std::uint32_t const escrowSeq = aliceTicket; env(escrow::create(alice, bob, XRP(1000)), - escrow::finish_time(ts), - ticket::use(aliceTicket)); + escrow::kFINISH_TIME(ts), + ticket::Use(aliceTicket)); BEAST_EXPECT(env.seq(alice) == aliceRootSeq); env.require(tickets(alice, 0)); - env.require(tickets(bob, bobTicketCount)); + env.require(tickets(bob, kBOB_TICKET_COUNT)); // Advance the ledger, verifying that the finish won't complete // prematurely. Note that each tec consumes one of bob's tickets. for (; env.now() < ts; env.close()) { env(escrow::finish(bob, alice, escrowSeq), - fee(150 * baseFee), - ticket::use(--bobTicket), - ter(tecNO_PERMISSION)); + Fee(150 * baseFee), + ticket::Use(--bobTicket), + Ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); } // bob tries to re-use a ticket, which is rejected. env(escrow::finish(bob, alice, escrowSeq), - fee(150 * baseFee), - ticket::use(bobTicket), - ter(tefNO_TICKET)); + Fee(150 * baseFee), + ticket::Use(bobTicket), + Ter(tefNO_TICKET)); // bob uses one of his remaining tickets. Success! env(escrow::finish(bob, alice, escrowSeq), - fee(150 * baseFee), - ticket::use(--bobTicket)); + Fee(150 * baseFee), + ticket::Use(--bobTicket)); env.close(); BEAST_EXPECT(env.seq(bob) == bobRootSeq); } @@ -1412,12 +1412,12 @@ struct Escrow_test : public beast::unit_test::suite // bob creates a bunch of tickets because he will be burning // through them with tec transactions. - constexpr std::uint32_t bobTicketCount{20}; + constexpr std::uint32_t kBOB_TICKET_COUNT{20}; std::uint32_t bobTicket{env.seq(bob) + 1}; - env(ticket::create(bob, bobTicketCount)); + env(ticket::create(bob, kBOB_TICKET_COUNT)); env.close(); env.require(tickets(alice, 1)); - env.require(tickets(bob, bobTicketCount)); + env.require(tickets(bob, kBOB_TICKET_COUNT)); // Note that from here on all transactions use tickets. No account // root sequences should change. @@ -1429,37 +1429,37 @@ struct Escrow_test : public beast::unit_test::suite std::uint32_t const escrowSeq = aliceTicket; env(escrow::create(alice, bob, XRP(1000)), - escrow::condition(escrow::cb1), - escrow::cancel_time(ts), - ticket::use(aliceTicket)); + escrow::kCONDITION(escrow::kCB1), + escrow::kCANCEL_TIME(ts), + ticket::Use(aliceTicket)); BEAST_EXPECT(env.seq(alice) == aliceRootSeq); env.require(tickets(alice, 0)); - env.require(tickets(bob, bobTicketCount)); + env.require(tickets(bob, kBOB_TICKET_COUNT)); // Advance the ledger, verifying that the cancel won't complete // prematurely. for (; env.now() < ts; env.close()) { env(escrow::cancel(bob, alice, escrowSeq), - fee(150 * baseFee), - ticket::use(bobTicket++), - ter(tecNO_PERMISSION)); + Fee(150 * baseFee), + ticket::Use(bobTicket++), + Ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); } // Verify that a finish won't work anymore. env(escrow::finish(bob, alice, escrowSeq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(150 * baseFee), - ticket::use(bobTicket++), - ter(tecNO_PERMISSION)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(150 * baseFee), + ticket::Use(bobTicket++), + Ter(tecNO_PERMISSION)); BEAST_EXPECT(env.seq(bob) == bobRootSeq); // Verify that the cancel succeeds. env(escrow::cancel(bob, alice, escrowSeq), - fee(150 * baseFee), - ticket::use(bobTicket++)); + Fee(150 * baseFee), + ticket::Use(bobTicket++)); env.close(); BEAST_EXPECT(env.seq(bob) == bobRootSeq); @@ -1491,7 +1491,7 @@ struct Escrow_test : public beast::unit_test::suite env.close(); auto const seq = env.seq(alice); - env(escrow::create(alice, bob, XRP(1000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bob, XRP(1000)), escrow::kFINISH_TIME(env.now() + 1s)); env.close(); env(fset(bob, asfDepositAuth)); @@ -1502,7 +1502,7 @@ struct Escrow_test : public beast::unit_test::suite std::string const credIdx = "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B" "E4"; - env(escrow::finish(bob, alice, seq), credentials::ids({credIdx}), ter(temDISABLED)); + env(escrow::finish(bob, alice, seq), credentials::Ids({credIdx}), Ter(temDISABLED)); } { @@ -1517,7 +1517,7 @@ struct Escrow_test : public beast::unit_test::suite std::string const credIdx = jv[jss::result][jss::index].asString(); auto const seq = env.seq(alice); - env(escrow::create(alice, bob, XRP(1000)), escrow::finish_time(env.now() + 50s)); + env(escrow::create(alice, bob, XRP(1000)), escrow::kFINISH_TIME(env.now() + 50s)); env.close(); // Bob require pre-authorization @@ -1526,8 +1526,8 @@ struct Escrow_test : public beast::unit_test::suite // Fail, credentials not accepted env(escrow::finish(carol, alice, seq), - credentials::ids({credIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Ter(tecBAD_CREDENTIALS)); env.close(); @@ -1536,20 +1536,20 @@ struct Escrow_test : public beast::unit_test::suite // Fail, credentials doesn’t belong to root account env(escrow::finish(dillon, alice, seq), - credentials::ids({credIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Ter(tecBAD_CREDENTIALS)); // Fail, no depositPreauth env(escrow::finish(carol, alice, seq), - credentials::ids({credIdx}), - ter(tecNO_PERMISSION)); + credentials::Ids({credIdx}), + Ter(tecNO_PERMISSION)); env(deposit::authCredentials(bob, {{zelda, credType}})); env.close(); // Success env.close(); - env(escrow::finish(carol, alice, seq), credentials::ids({credIdx})); + env(escrow::finish(carol, alice, seq), credentials::Ids({credIdx})); env.close(); } @@ -1570,7 +1570,7 @@ struct Escrow_test : public beast::unit_test::suite std::string const credIdx = jv[jss::result][jss::index].asString(); auto const seq = env.seq(alice); - env(escrow::create(alice, bob, XRP(1000)), escrow::finish_time(env.now() + 50s)); + env(escrow::create(alice, bob, XRP(1000)), escrow::kFINISH_TIME(env.now() + 50s)); // time advance env.close(); env.close(); @@ -1580,7 +1580,7 @@ struct Escrow_test : public beast::unit_test::suite env.close(); // Succeed, Bob doesn't require pre-authorization - env(escrow::finish(carol, alice, seq), credentials::ids({credIdx})); + env(escrow::finish(carol, alice, seq), credentials::Ids({credIdx})); env.close(); { @@ -1595,7 +1595,7 @@ struct Escrow_test : public beast::unit_test::suite .asString(); auto const seq = env.seq(alice); - env(escrow::create(alice, bob, XRP(1000)), escrow::finish_time(env.now() + 1s)); + env(escrow::create(alice, bob, XRP(1000)), escrow::kFINISH_TIME(env.now() + 1s)); env.close(); // Bob require pre-authorization @@ -1605,7 +1605,7 @@ struct Escrow_test : public beast::unit_test::suite env.close(); // Use any valid credentials if account == dst - env(escrow::finish(bob, alice, seq), credentials::ids({credIdxBob})); + env(escrow::finish(bob, alice, seq), credentials::Ids({credIdxBob})); env.close(); } } @@ -1633,7 +1633,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testWithFeats(all); testWithFeats(all - featureTokenEscrow); testTags(all - fixIncludeKeyletFields); diff --git a/src/test/app/FeeVote_test.cpp b/src/test/app/FeeVote_test.cpp index e24b54c82a..8300b458b6 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -134,7 +134,7 @@ createInvalidFeeTx( bool applyFeeAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx) { - auto const res = apply(env.app(), view, tx, ApplyFlags::tapNONE, env.journal); + auto const res = apply(env.app(), view, tx, ApplyFlags::TapNone, env.journal); return isTesSuccess(res.ter); } @@ -203,7 +203,7 @@ getTxs(std::shared_ptr const& txSet) return txs; }; -class FeeVote_test : public beast::unit_test::suite +class FeeVote_test : public beast::unit_test::Suite { void testSetup() @@ -212,7 +212,7 @@ class FeeVote_test : public beast::unit_test::suite { // defaults Section const config; - auto setup = setup_FeeVote(config); + auto setup = setupFeeVote(config); BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee); BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve); BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve); @@ -221,7 +221,7 @@ class FeeVote_test : public beast::unit_test::suite Section config; config.append( {"reference_fee = 50", "account_reserve = 1234567", "owner_reserve = 1234"}); - auto setup = setup_FeeVote(config); + auto setup = setupFeeVote(config); BEAST_EXPECT(setup.reference_fee == 50); BEAST_EXPECT(setup.account_reserve == 1234567); BEAST_EXPECT(setup.owner_reserve == 1234); @@ -231,7 +231,7 @@ class FeeVote_test : public beast::unit_test::suite config.append( {"reference_fee = blah", "account_reserve = yada", "owner_reserve = foo"}); // Illegal values are ignored, and the defaults left unchanged - auto setup = setup_FeeVote(config); + auto setup = setupFeeVote(config); BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee); BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve); BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve); @@ -241,7 +241,7 @@ class FeeVote_test : public beast::unit_test::suite config.append( {"reference_fee = -50", "account_reserve = -1234567", "owner_reserve = -1234"}); // Illegal values are ignored, and the defaults left unchanged - auto setup = setup_FeeVote(config); + auto setup = setupFeeVote(config); BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee); BEAST_EXPECT(setup.account_reserve == static_cast(-1234567)); BEAST_EXPECT(setup.owner_reserve == static_cast(-1234)); @@ -255,7 +255,7 @@ class FeeVote_test : public beast::unit_test::suite "account_reserve = " + big64, "owner_reserve = " + big64}); // Illegal values are ignored, and the defaults left unchanged - auto setup = setup_FeeVote(config); + auto setup = setupFeeVote(config); BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee); BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve); BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve); @@ -269,9 +269,9 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees disabled (legacy format) { - jtx::Env env(*this, jtx::testable_amendments() - featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() - featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -299,9 +299,9 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees enabled (new format) { - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -332,9 +332,9 @@ class FeeVote_test : public beast::unit_test::suite testcase("Fee Transaction Validation"); { - jtx::Env env(*this, jtx::testable_amendments() - featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() - featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -354,9 +354,9 @@ class FeeVote_test : public beast::unit_test::suite } { - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -381,9 +381,9 @@ class FeeVote_test : public beast::unit_test::suite { testcase("Pseudo Transaction Properties"); - jtx::Env env(*this, jtx::testable_amendments()); + jtx::Env env(*this, jtx::testableAmendments()); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -420,9 +420,9 @@ class FeeVote_test : public beast::unit_test::suite { testcase("Multiple Fee Updates"); - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -468,9 +468,9 @@ class FeeVote_test : public beast::unit_test::suite { testcase("Wrong Ledger Sequence"); - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -499,9 +499,9 @@ class FeeVote_test : public beast::unit_test::suite { testcase("Partial Field Updates"); - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -545,9 +545,9 @@ class FeeVote_test : public beast::unit_test::suite { testcase("Single Invalid Transaction"); - jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + jtx::Env env(*this, jtx::testableAmendments() | featureXRPFees); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -584,18 +584,18 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees enabled { - Env env(*this, testable_amendments() | featureXRPFees); - auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote")); + Env env(*this, testableAmendments() | featureXRPFees); + auto feeVote = makeFeeVote(setup, env.app().getJournal("FeeVote")); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, env.app().getNodeFamily()); auto sec = randomSecretKey(); - auto pub = derivePublicKey(KeyType::secp256k1, sec); + auto pub = derivePublicKey(KeyType::Secp256k1, sec); auto val = std::make_shared( env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) { @@ -614,18 +614,18 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees disabled (legacy format) { - Env env(*this, testable_amendments() - featureXRPFees); - auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote")); + Env env(*this, testableAmendments() - featureXRPFees); + auto feeVote = makeFeeVote(setup, env.app().getJournal("FeeVote")); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, env.app().getNodeFamily()); auto sec = randomSecretKey(); - auto pub = derivePublicKey(KeyType::secp256k1, sec); + auto pub = derivePublicKey(KeyType::Secp256k1, sec); auto val = std::make_shared( env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [](STValidation& v) { @@ -654,16 +654,16 @@ class FeeVote_test : public beast::unit_test::suite setup.account_reserve = 1234567; setup.owner_reserve = 7654321; - Env env(*this, testable_amendments() | featureXRPFees); + Env env(*this, testableAmendments() | featureXRPFees); // establish what the current fees are BEAST_EXPECT(env.current()->fees().base == XRPAmount{UNIT_TEST_REFERENCE_FEE}); BEAST_EXPECT(env.current()->fees().reserve == XRPAmount{200'000'000}); BEAST_EXPECT(env.current()->fees().increment == XRPAmount{50'000'000}); - auto feeVote = make_FeeVote(setup, env.app().getJournal("FeeVote")); + auto feeVote = makeFeeVote(setup, env.app().getJournal("FeeVote")); auto ledger = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -683,7 +683,7 @@ class FeeVote_test : public beast::unit_test::suite for (int i = 0; i < 5; i++) { auto sec = randomSecretKey(); - auto pub = derivePublicKey(KeyType::secp256k1, sec); + auto pub = derivePublicKey(KeyType::Secp256k1, sec); auto val = std::make_shared( env.app().getTimeKeeper().now(), pub, sec, calcNodeID(pub), [&](STValidation& v) { diff --git a/src/test/app/FixNFTokenPageLinks_test.cpp b/src/test/app/FixNFTokenPageLinks_test.cpp index 56484bb396..f77d924c94 100644 --- a/src/test/app/FixNFTokenPageLinks_test.cpp +++ b/src/test/app/FixNFTokenPageLinks_test.cpp @@ -30,16 +30,16 @@ namespace xrpl { -class FixNFTokenPageLinks_test : public beast::unit_test::suite +class FixNFTokenPageLinks_test : public beast::unit_test::Suite { // Helper function that returns the number of nfts owned by an account. static std::uint32_t nftCount(test::jtx::Env& env, test::jtx::Account const& acct) { - Json::Value params; + json::Value params; params[jss::account] = acct.human(); params[jss::type] = "state"; - Json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); + json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); return nfts[jss::result][jss::account_nfts].size(); }; @@ -88,7 +88,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite std::uint32_t const intTaxon = (i / 16) + (((i & 0b10000) != 0u) ? 2 : 0); uint32_t const extTaxon = internalTaxon(owner, intTaxon); nfts.push_back(token::getNextID(env, owner, extTaxon, tfTransferable)); - env(token::mint(owner, extTaxon), txflags(tfTransferable)); + env(token::mint(owner, extTaxon), Txflags(tfTransferable)); env.close(); } @@ -99,14 +99,14 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Verify that the owner does indeed have exactly three pages // of NFTs with 32 entries in each page. { - Json::Value params; + json::Value params; params[jss::account] = owner.human(); auto resp = env.rpc("json", "account_objects", to_string(params)); - Json::Value const& acctObjs = resp[jss::result][jss::account_objects]; + json::Value const& acctObjs = resp[jss::result][jss::account_objects]; int pageCount = 0; - for (Json::UInt i = 0; i < acctObjs.size(); ++i) + for (json::UInt i = 0; i < acctObjs.size(); ++i) { if (BEAST_EXPECT( acctObjs[i].isMember(sfNFTokens.jsonName) && @@ -135,14 +135,14 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite { // Verify that the LedgerStateFix transaction is disabled // without the fixNFTokenPageLinks amendment. - Env env{*this, testable_amendments() - fixNFTokenPageLinks}; + Env env{*this, testableAmendments() - fixNFTokenPageLinks}; env.fund(XRP(1000), alice); auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(alice, alice), fee(linkFixFee), ter(temDISABLED)); + env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(temDISABLED)); } - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; env.fund(XRP(1000), alice); std::uint32_t const ticketSeq = env.seq(alice); env(ticket::create(alice, 1)); @@ -151,42 +151,42 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite { // Fail preflight1. Can't combine AccountTxnID and ticket. - Json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); tx[sfAccountTxnID.jsonName] = "00000000000000000000000000000000" "00000000000000000000000000000000"; - env(tx, ticket::use(ticketSeq), ter(temINVALID)); + env(tx, ticket::Use(ticketSeq), Ter(temINVALID)); } // Fee too low. - env(ledgerStateFix::nftPageLinks(alice, alice), ter(telINSUF_FEE_P)); + env(ledgerStateFix::nftPageLinks(alice, alice), Ter(telINSUF_FEE_P)); // Invalid flags. auto const linkFixFee = drops(env.current()->fees().increment); env(ledgerStateFix::nftPageLinks(alice, alice), - fee(linkFixFee), - txflags(tfPassive), - ter(temINVALID_FLAG)); + Fee(linkFixFee), + Txflags(tfPassive), + Ter(temINVALID_FLAG)); { // ledgerStateFix::nftPageLinks requires an Owner field. - Json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); tx.removeMember(sfOwner.jsonName); - env(tx, fee(linkFixFee), ter(temINVALID)); + env(tx, Fee(linkFixFee), Ter(temINVALID)); } { // Invalid LedgerFixType codes. - Json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); tx[sfLedgerFixType.jsonName] = 0; - env(tx, fee(linkFixFee), ter(tefINVALID_LEDGER_FIX_TYPE)); + env(tx, Fee(linkFixFee), Ter(tefINVALID_LEDGER_FIX_TYPE)); tx[sfLedgerFixType.jsonName] = 200; - env(tx, fee(linkFixFee), ter(tefINVALID_LEDGER_FIX_TYPE)); + env(tx, Fee(linkFixFee), Ter(tefINVALID_LEDGER_FIX_TYPE)); } // Preclaim Account const carol("carol"); env.memoize(carol); - env(ledgerStateFix::nftPageLinks(alice, carol), fee(linkFixFee), ter(tecOBJECT_NOT_FOUND)); + env(ledgerStateFix::nftPageLinks(alice, carol), Fee(linkFixFee), Ter(tecOBJECT_NOT_FOUND)); } void @@ -198,7 +198,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite Account const alice("alice"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; env.fund(XRP(1000), alice); // These cases all return the same TER code, but they exercise @@ -207,22 +207,22 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Owner has no pages to fix. auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(alice, alice), fee(linkFixFee), ter(tecFAILED_PROCESSING)); + env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); // Alice has only one page. - env(token::mint(alice), txflags(tfTransferable)); + env(token::mint(alice), Txflags(tfTransferable)); env.close(); - env(ledgerStateFix::nftPageLinks(alice, alice), fee(linkFixFee), ter(tecFAILED_PROCESSING)); + env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); // Alice has at least three pages. for (std::uint32_t i = 0; i < 64; ++i) { - env(token::mint(alice), txflags(tfTransferable)); + env(token::mint(alice), Txflags(tfTransferable)); env.close(); } - env(ledgerStateFix::nftPageLinks(alice, alice), fee(linkFixFee), ter(tecFAILED_PROCESSING)); + env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); } void @@ -245,7 +245,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite Account const carol("carol"); Account const daria("daria"); - Env env{*this, testable_amendments() - fixNFTokenPageLinks}; + Env env{*this, testableAmendments() - fixNFTokenPageLinks}; env.fund(XRP(1000), alice, bob, carol, daria); //********************************************************************** @@ -260,7 +260,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Get the index of the middle page. uint256 const aliceMiddleNFTokenPageIndex = [&env, &alice]() { - auto lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(alice)); return lastNFTokenPage->at(sfPreviousPageMin); }(); @@ -283,12 +283,12 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Removing the last token from the last page deletes the last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - BEAST_EXPECT(!env.le(keylet::nftpage_max(alice))); + BEAST_EXPECT(!env.le(keylet::nftpageMax(alice))); // alice's "middle" page is still present, but has no links. { auto aliceMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), aliceMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), aliceMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(aliceMiddleNFTokenPage)) return; @@ -308,7 +308,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Get the index of the middle page. uint256 const bobMiddleNFTokenPageIndex = [&env, &bob]() { - auto lastNFTokenPage = env.le(keylet::nftpage_max(bob)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(bob)); return lastNFTokenPage->at(sfPreviousPageMin); }(); @@ -325,13 +325,13 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Removing the last token from the last page deletes the last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - BEAST_EXPECT(!env.le(keylet::nftpage_max(bob))); + BEAST_EXPECT(!env.le(keylet::nftpageMax(bob))); // bob's "middle" page is still present, but has lost the // NextPageMin field. { auto bobMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(bob), bobMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(bob), bobMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(bobMiddleNFTokenPage)) return; @@ -351,7 +351,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Get the index of the middle page. uint256 const carolMiddleNFTokenPageIndex = [&env, &carol]() { - auto lastNFTokenPage = env.le(keylet::nftpage_max(carol)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(carol)); return lastNFTokenPage->at(sfPreviousPageMin); }(); @@ -361,7 +361,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite for (int i = 0; i < 32; ++i) { uint256 const offerIndex = keylet::nftoffer(carol, env.seq(carol)).key; - env(token::createOffer(carol, carolNFTs.back(), XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(carol, carolNFTs.back(), XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(daria, offerIndex)); @@ -376,12 +376,12 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Removing the last token from the last page deletes the last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - BEAST_EXPECT(!env.le(keylet::nftpage_max(carol))); + BEAST_EXPECT(!env.le(keylet::nftpageMax(carol))); // carol's "middle" page is still present, but has lost the // NextPageMin field. auto carolMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(carol), carolMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(carol), carolMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(carolMiddleNFTokenPage)) return; @@ -395,7 +395,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite for (uint256 const& nft : dariaNFTs) { uint256 const offerIndex = keylet::nftoffer(carol, env.seq(carol)).key; - env(token::createOffer(carol, nft, drops(1)), token::owner(daria)); + env(token::createOffer(carol, nft, drops(1)), token::Owner(daria)); env.close(); env(token::acceptBuyOffer(daria, offerIndex)); @@ -412,7 +412,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // carol's "middle" page is present and still has no NextPageMin field. { auto carolMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(carol), carolMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(carol), carolMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(carolMiddleNFTokenPage)) return; @@ -421,7 +421,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite } // carol has a "last" page again, but it has no PreviousPageMin field. { - auto carolLastNFTokenPage = env.le(keylet::nftpage_max(carol)); + auto carolLastNFTokenPage = env.le(keylet::nftpageMax(carol)); BEAST_EXPECT(!carolLastNFTokenPage->isFieldPresent(sfPreviousPageMin)); BEAST_EXPECT(!carolLastNFTokenPage->isFieldPresent(sfNextPageMin)); @@ -432,7 +432,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite //********************************************************************** // Verify that the LedgerStateFix transaction is not enabled. auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(daria, alice), fee(linkFixFee), ter(temDISABLED)); + env(ledgerStateFix::nftPageLinks(daria, alice), Fee(linkFixFee), Ter(temDISABLED)); // Wait 15 ledgers so the LedgerStateFix transaction is no longer // retried. @@ -449,12 +449,12 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Verify that alice's NFToken directory is still damaged. // alice's last page should still be missing. - BEAST_EXPECT(!env.le(keylet::nftpage_max(alice))); + BEAST_EXPECT(!env.le(keylet::nftpageMax(alice))); // alice's "middle" page is still present and has no links. { auto aliceMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), aliceMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), aliceMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(aliceMiddleNFTokenPage)) return; @@ -468,12 +468,12 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite env(noop(daria)); // daria fixes the links in alice's NFToken directory. - env(ledgerStateFix::nftPageLinks(daria, alice), fee(linkFixFee)); + env(ledgerStateFix::nftPageLinks(daria, alice), Fee(linkFixFee)); env.close(); // alice's last page should now be present and include no links. { - auto aliceLastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto aliceLastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(aliceLastNFTokenPage)) return; @@ -483,7 +483,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // alice's middle page should be gone. BEAST_EXPECT( - !env.le(keylet::nftpage(keylet::nftpage_min(alice), aliceMiddleNFTokenPageIndex))); + !env.le(keylet::nftpage(keylet::nftpageMin(alice), aliceMiddleNFTokenPageIndex))); BEAST_EXPECT(nftCount(env, alice) == 32); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -495,12 +495,12 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // Verify that bob's NFToken directory is still damaged. // bob's last page should still be missing. - BEAST_EXPECT(!env.le(keylet::nftpage_max(bob))); + BEAST_EXPECT(!env.le(keylet::nftpageMax(bob))); // bob's "middle" page is still present and missing NextPageMin. { auto bobMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(bob), bobMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(bob), bobMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(bobMiddleNFTokenPage)) return; @@ -509,13 +509,13 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite } // daria fixes the links in bob's NFToken directory. - env(ledgerStateFix::nftPageLinks(daria, bob), fee(linkFixFee)); + env(ledgerStateFix::nftPageLinks(daria, bob), Fee(linkFixFee)); env.close(); // bob's last page should now be present and include a previous // link but no next link. { - auto const lastPageKeylet = keylet::nftpage_max(bob); + auto const lastPageKeylet = keylet::nftpageMax(bob); auto const bobLastNFTokenPage = env.le(lastPageKeylet); if (!BEAST_EXPECT(bobLastNFTokenPage)) return; @@ -526,7 +526,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite auto const bobNewFirstNFTokenPage = env.le( keylet::nftpage( - keylet::nftpage_min(bob), bobLastNFTokenPage->at(sfPreviousPageMin))); + keylet::nftpageMin(bob), bobLastNFTokenPage->at(sfPreviousPageMin))); if (!BEAST_EXPECT(bobNewFirstNFTokenPage)) return; @@ -537,7 +537,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite } // bob's middle page should be gone. - BEAST_EXPECT(!env.le(keylet::nftpage(keylet::nftpage_min(bob), bobMiddleNFTokenPageIndex))); + BEAST_EXPECT(!env.le(keylet::nftpage(keylet::nftpageMin(bob), bobMiddleNFTokenPageIndex))); BEAST_EXPECT(nftCount(env, bob) == 64); BEAST_EXPECT(ownerCount(env, bob) == 2); @@ -551,7 +551,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // carol's "middle" page is present and has no NextPageMin field. { auto carolMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(carol), carolMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(carol), carolMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(carolMiddleNFTokenPage)) return; @@ -560,21 +560,21 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite } // carol has a "last" page, but it has no PreviousPageMin field. { - auto carolLastNFTokenPage = env.le(keylet::nftpage_max(carol)); + auto carolLastNFTokenPage = env.le(keylet::nftpageMax(carol)); BEAST_EXPECT(!carolLastNFTokenPage->isFieldPresent(sfPreviousPageMin)); BEAST_EXPECT(!carolLastNFTokenPage->isFieldPresent(sfNextPageMin)); } // carol fixes the links in their own NFToken directory. - env(ledgerStateFix::nftPageLinks(carol, carol), fee(linkFixFee)); + env(ledgerStateFix::nftPageLinks(carol, carol), Fee(linkFixFee)); env.close(); { // carol's "middle" page is present and now has a NextPageMin field. - auto const lastPageKeylet = keylet::nftpage_max(carol); + auto const lastPageKeylet = keylet::nftpageMax(carol); auto carolMiddleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(carol), carolMiddleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(carol), carolMiddleNFTokenPageIndex)); if (!BEAST_EXPECT(carolMiddleNFTokenPage)) return; @@ -596,7 +596,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite // carol also has a "first" page that includes a NextPageMin field. auto carolFirstNFTokenPage = env.le( keylet::nftpage( - keylet::nftpage_min(carol), carolMiddleNFTokenPage->at(sfPreviousPageMin))); + keylet::nftpageMin(carol), carolMiddleNFTokenPage->at(sfPreviousPageMin))); if (!BEAST_EXPECT(carolFirstNFTokenPage)) return; diff --git a/src/test/app/FlowMPT_test.cpp b/src/test/app/FlowMPT_test.cpp index a94d48beb4..9bb91755c8 100644 --- a/src/test/app/FlowMPT_test.cpp +++ b/src/test/app/FlowMPT_test.cpp @@ -45,7 +45,7 @@ namespace xrpl::test { -struct FlowMPT_test : public beast::unit_test::suite +struct FlowMPT_test : public beast::unit_test::Suite { using Accounts = std::vector; @@ -64,22 +64,22 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(100))); - env(pay(alice, bob, USD(10)), paths(USD)); - env.require(balance(bob, USD(10))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + env(pay(gw, alice, usd(100))); + env(pay(alice, bob, usd(10)), Paths(usd)); + env.require(Balance(bob, usd(10))); } { // Partial payments Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(100))); - env(pay(alice, bob, USD(110)), paths(USD), ter(tecPATH_PARTIAL)); - env.require(balance(bob, USD(0))); - env(pay(alice, bob, USD(110)), paths(USD), txflags(tfPartialPayment)); - env.require(balance(bob, USD(100))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + env(pay(gw, alice, usd(100))); + env(pay(alice, bob, usd(110)), Paths(usd), Ter(tecPATH_PARTIAL)); + env.require(Balance(bob, usd(0))); + env(pay(alice, bob, usd(110)), Paths(usd), Txflags(tfPartialPayment)); + env.require(Balance(bob, usd(100))); } { @@ -90,25 +90,25 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), gw, alice, bob, carol); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {bob}}); - env(pay(gw, alice, USD(100))); - env(pay(gw, bob, EUR(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, bob, eur(100))); - env(offer(alice, EUR(4), USD(4))); + env(offer(alice, eur(4), usd(4))); env.close(); - env(pay(bob, carol, USD(5)), - sendmax(EUR(4)), - txflags(tfLimitQuality | tfPartialPayment), - ter(tecPATH_DRY)); - env.require(balance(carol, USD(0))); + env(pay(bob, carol, usd(5)), + Sendmax(eur(4)), + Txflags(tfLimitQuality | tfPartialPayment), + Ter(tecPATH_DRY)); + env.require(Balance(carol, usd(0))); - env(pay(bob, carol, USD(5)), sendmax(EUR(4)), txflags(tfPartialPayment)); - env.require(balance(carol, USD(4))); + env(pay(bob, carol, usd(5)), Sendmax(eur(4)), Txflags(tfPartialPayment)); + env.require(Balance(carol, usd(4))); }; testHelper2TokensMix(test); } @@ -134,23 +134,23 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, BTC(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, btc(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, BTC(50), USD(50))); + env(offer(bob, btc(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(BTC(50))); + env(pay(alice, carol, usd(50)), Path(~usd), Sendmax(btc(50))); - env.require(balance(alice, BTC(0))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, BTC(50), USD(50))); + env.require(Balance(alice, btc(0))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), usd(50))); }; testHelper2TokensMix(test); } @@ -162,25 +162,25 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, BTC(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, btc(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, BTC(50), XRP(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, btc(50), XRP(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~XRP, ~USD), sendmax(BTC(50))); + env(pay(alice, carol, usd(50)), Path(~XRP, ~usd), Sendmax(btc(50))); - env.require(balance(alice, BTC(0))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, XRP(50), USD(50))); - BEAST_EXPECT(!isOffer(env, bob, BTC(50), XRP(50))); + env.require(Balance(alice, btc(0))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, XRP(50), usd(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), XRP(50))); }; testHelper2TokensMix(test); } @@ -191,22 +191,22 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - MPT const BTC = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, bob, USD(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(XRP(50))); + env(pay(alice, carol, usd(50)), Path(~usd), Sendmax(XRP(50))); // fee: MPTokenAuthorize * 2(EUR, USD) + pay - env.require(balance(alice, XRP(10'000 - 50) - txfee(env, 3))); + env.require(Balance(alice, XRP(10'000 - 50) - txFee(env, 3))); // fee: MPTokenAuthorize * 2(EUR, USD) + offer - env.require(balance(bob, XRP(10'000 + 50) - txfee(env, 3))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, XRP(50), USD(50))); + env.require(Balance(bob, XRP(10'000 + 50) - txFee(env, 3))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, XRP(50), usd(50))); } { // simple USD -> XRP through offer and sendmax @@ -215,20 +215,20 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - MPT const BTC = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, USD(50))); + env(pay(gw, alice, usd(50))); - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); - env(pay(alice, carol, XRP(50)), path(~XRP), sendmax(USD(50))); + env(pay(alice, carol, XRP(50)), Path(~XRP), Sendmax(usd(50))); - env.require(balance(alice, USD(0))); - env.require(balance(bob, XRP(10'000 - 50) - txfee(env, 3))); - env.require(balance(bob, USD(50))); - env.require(balance(carol, XRP(10'000 + 50) - txfee(env, 2))); - BEAST_EXPECT(!isOffer(env, bob, USD(50), XRP(50))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, XRP(10'000 - 50) - txFee(env, 3))); + env.require(Balance(bob, usd(50))); + env.require(Balance(carol, XRP(10'000 + 50) - txFee(env, 2))); + BEAST_EXPECT(!isOffer(env, bob, usd(50), XRP(50))); } { // test unfunded offers are removed when payment succeeds @@ -238,41 +238,41 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}}); - auto const EUR = issue3( + auto const eur = issue3( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, USD(50))); - env(pay(gw, bob, EUR(50))); + env(pay(gw, alice, btc(60))); + env(pay(gw, bob, usd(50))); + env(pay(gw, bob, eur(50))); - env(offer(bob, BTC(50), USD(50))); - env(offer(bob, BTC(40), EUR(50))); - env(offer(bob, EUR(50), USD(50))); + env(offer(bob, btc(50), usd(50))); + env(offer(bob, btc(40), eur(50))); + env(offer(bob, eur(50), usd(50))); // unfund offer - env(pay(bob, gw, EUR(50))); - env.require(balance(bob, EUR(0))); - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(40), EUR(50))); - BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50))); + env(pay(bob, gw, eur(50))); + env.require(Balance(bob, eur(0))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(50))); + BEAST_EXPECT(isOffer(env, bob, btc(40), eur(50))); + BEAST_EXPECT(isOffer(env, bob, eur(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), path(~EUR, ~USD), sendmax(BTC(60))); + env(pay(alice, carol, usd(50)), Path(~usd), Path(~eur, ~usd), Sendmax(btc(60))); - env.require(balance(alice, BTC(10))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(bob, EUR(0))); - env.require(balance(carol, USD(50))); + env.require(Balance(alice, btc(10))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(bob, eur(0))); + env.require(Balance(carol, usd(50))); // used in the payment - BEAST_EXPECT(!isOffer(env, bob, BTC(50), USD(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), usd(50))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(40), EUR(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(40), eur(50))); // unfunded, but should not yet be found unfunded - BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50))); + BEAST_EXPECT(isOffer(env, bob, eur(50), usd(50))); }; testHelper3TokensMix(test); } @@ -291,61 +291,61 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000}); - auto const EUR = issue3( + auto const eur = issue3( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000}); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, USD(6'000))); - env(pay(gw, bob, EUR(5'000))); - env(pay(gw, carol, EUR(100))); + env(pay(gw, alice, btc(60))); + env(pay(gw, bob, usd(6'000))); + env(pay(gw, bob, eur(5'000))); + env(pay(gw, carol, eur(100))); - env(offer(bob, BTC(50), USD(5'000))); - env(offer(bob, BTC(60), EUR(5'000))); - env(offer(carol, BTC(1'000), EUR(100))); - env(offer(bob, EUR(5'000), USD(5'000))); + env(offer(bob, btc(50), usd(5'000))); + env(offer(bob, btc(60), eur(5'000))); + env(offer(carol, btc(1'000), eur(100))); + env(offer(bob, eur(5'000), usd(5'000))); // unfund offer - env(pay(bob, gw, EUR(5'000))); - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(5'000))); - BEAST_EXPECT(isOffer(env, bob, BTC(60), EUR(5'000))); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000), EUR(100))); + env(pay(bob, gw, eur(5'000))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(5'000))); + BEAST_EXPECT(isOffer(env, bob, btc(60), eur(5'000))); + BEAST_EXPECT(isOffer(env, carol, btc(1'000), eur(100))); auto flowJournal = env.app().getLogs().journal("Flow"); auto const flowResult = [&] { - STAmount const deliver(USD(5'100)); - STAmount smax(BTC(61)); - PaymentSandbox sb(env.current().get(), tapNONE); + STAmount const deliver(usd(5'100)); + STAmount smax(btc(61)); + PaymentSandbox sb(env.current().get(), TapNone); STPathSet paths; - auto IPE = [](Asset const& asset) { + auto ipe = [](Asset const& asset) { return STPathElement( - STPathElement::typeAsset | STPathElement::typeIssuer, + STPathElement::TypeAsset | STPathElement::TypeIssuer, xrpAccount(), asset, asset.getIssuer()); }; { // BTC -> USD - STPath const p1({IPE(USD)}); - paths.push_back(p1); + STPath const p1({ipe(usd)}); + paths.pushBack(p1); // BTC -> EUR -> USD - STPath const p2({IPE(EUR), IPE(USD)}); - paths.push_back(p2); + STPath const p2({ipe(eur), ipe(usd)}); + paths.pushBack(p2); } return flow( @@ -357,7 +357,7 @@ struct FlowMPT_test : public beast::unit_test::suite false, false, true, - OfferCrossing::no, + OfferCrossing::No, std::nullopt, smax, std::nullopt, @@ -368,7 +368,7 @@ struct FlowMPT_test : public beast::unit_test::suite env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { if (flowResult.removableOffers.empty()) return false; - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); for (auto const& o : flowResult.removableOffers) { if (auto ok = sb.peek(keylet::offer(o))) @@ -380,10 +380,10 @@ struct FlowMPT_test : public beast::unit_test::suite // used in payment, but since payment failed should // be untouched - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(5'000))); - BEAST_EXPECT(isOffer(env, carol, BTC(1'000), EUR(100))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(5'000))); + BEAST_EXPECT(isOffer(env, carol, btc(1'000), eur(100))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(60), EUR(5'000))); + BEAST_EXPECT(!isOffer(env, bob, btc(60), eur(5'000))); }; testHelper3TokensMix(test); } @@ -400,17 +400,17 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10'000), alice, bob, carol, gw); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}}); - auto const EUR = issue1( + auto const eur = issue1( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, USD(1'000))); - env(pay(gw, bob, EUR(1'000))); + env(pay(gw, alice, usd(1'000))); + env(pay(gw, bob, eur(1'000))); Keylet const bobUsdOffer = keylet::offer(bob, env.seq(bob)); - env(offer(bob, USD(10), drops(2)), txflags(tfPassive)); - env(offer(bob, drops(1), EUR(1'000)), txflags(tfPassive)); + env(offer(bob, usd(10), drops(2)), Txflags(tfPassive)); + env(offer(bob, drops(1), eur(1'000)), Txflags(tfPassive)); bool const reducedOffersV2 = features[fixReducedOffersV2]; @@ -420,17 +420,17 @@ struct FlowMPT_test : public beast::unit_test::suite // remaining fractional offer would block the order // book. TER const expectedTER = reducedOffersV2 ? TER(tecPATH_DRY) : TER(tesSUCCESS); - env(pay(alice, carol, EUR(1)), - path(~XRP, ~EUR), - sendmax(USD(4)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(expectedTER)); + env(pay(alice, carol, eur(1)), + Path(~XRP, ~eur), + Sendmax(usd(4)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(expectedTER)); if (!reducedOffersV2) { - env.require(balance(carol, EUR(1))); - env.require(balance(bob, USD(4))); - env.require(balance(bob, EUR(999))); + env.require(Balance(carol, eur(1))); + env.require(Balance(bob, usd(4))); + env.require(Balance(bob, eur(999))); // Show that bob's USD offer is now a blocker. std::shared_ptr const usdOffer = env.le(bobUsdOffer); @@ -479,17 +479,17 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .transferFee = 25'000, .maxAmt = 1'000}); - env(pay(gw, alice, USD(50))); - env.require(balance(alice, USD(50))); - env(pay(alice, bob, USD(40)), sendmax(USD(50))); - env.require(balance(bob, USD(40)), balance(alice, USD(0))); + env(pay(gw, alice, usd(50))); + env.require(Balance(alice, usd(50))); + env(pay(alice, bob, usd(40)), Sendmax(usd(50))); + env.require(Balance(bob, usd(40)), Balance(alice, usd(0))); } { // transfer rate is not charged when issuer is src or @@ -498,17 +498,17 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .transferFee = 25'000, .maxAmt = 1'000}); - env(pay(gw, alice, USD(50))); - env.require(balance(alice, USD(50))); - env(pay(alice, gw, USD(40)), sendmax(USD(40))); - env.require(balance(alice, USD(10))); + env(pay(gw, alice, usd(50))); + env.require(Balance(alice, usd(50))); + env(pay(alice, gw, usd(40)), Sendmax(usd(40))); + env.require(Balance(alice, usd(10))); } { // transfer fee on an offer @@ -516,7 +516,7 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, @@ -524,20 +524,20 @@ struct FlowMPT_test : public beast::unit_test::suite .maxAmt = 10'000}); // scale by 1 - env(pay(gw, bob, USD(650))); + env(pay(gw, bob, usd(650))); - env(offer(bob, XRP(50), USD(500))); + env(offer(bob, XRP(50), usd(500))); - env(pay(alice, carol, USD(500)), - path(~USD), - sendmax(XRP(50)), - txflags(tfPartialPayment)); + env(pay(alice, carol, usd(500)), + Path(~usd), + Sendmax(XRP(50)), + Txflags(tfPartialPayment)); // bob pays 25% on 500USD -> 100USD; 400USD goes to carol env.require( - balance(alice, XRP(10'000 - 50) - txfee(env, 2)), - balance(bob, USD(150)), - balance(carol, USD(400))); + Balance(alice, XRP(10'000 - 50) - txFee(env, 2)), + Balance(bob, usd(150)), + Balance(carol, usd(400))); } { // Transfer fee two consecutive offers @@ -547,14 +547,14 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 1'000, .transferFee = 25'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, @@ -562,19 +562,19 @@ struct FlowMPT_test : public beast::unit_test::suite .limit = 1'000, .transferFee = 25'000}); - env(pay(gw, bob, USD(50))); - env(pay(gw, bob, EUR(50))); + env(pay(gw, bob, usd(50))); + env(pay(gw, bob, eur(50))); - env(offer(bob, XRP(50), USD(50))); - env(offer(bob, USD(50), EUR(50))); + env(offer(bob, XRP(50), usd(50))); + env(offer(bob, usd(50), eur(50))); - env(pay(alice, carol, EUR(40)), - path(~USD, ~EUR), - sendmax(XRP(40)), - txflags(tfPartialPayment)); + env(pay(alice, carol, eur(40)), + Path(~usd, ~eur), + Sendmax(XRP(40)), + Txflags(tfPartialPayment)); // +1 for fset in helperIssueIOU - using tEUR = std::decay_t; - auto const fee = txfee(env, 3); + using tEUR = std::decay_t; + auto const fee = txFee(env, 3); // bob pays 25% on 40USD (40 since sendmax is 40XRP) // 8USD goes to gw and 32USD goes back to bob -> // bob's USD balance is 42USD. USD/EUR offer is 32USD/32EUR. @@ -583,18 +583,18 @@ struct FlowMPT_test : public beast::unit_test::suite auto const carolEUR = [&]() { if constexpr (std::is_same_v) { - return EUR(25.6); + return eur(25.6); } else { - return EUR(25); + return eur(25); } }(); env.require( - balance(alice, XRP(10'000 - 40) - fee), - balance(bob, USD(42)), - balance(bob, EUR(18)), - balance(carol, carolEUR)); + Balance(alice, XRP(10'000 - 40) - fee), + Balance(bob, usd(42)), + Balance(bob, eur(18)), + Balance(carol, carolEUR)); }; testHelper2TokensMix(test); } @@ -605,16 +605,16 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .transferFee = 25'000, .maxAmt = 1'000}); - env(offer(gw, XRP(100), USD(100))); - env(pay(alice, bob, USD(100)), sendmax(XRP(100)), txflags(tfPartialPayment)); - env.require(balance(alice, XRP(10'000 - 100) - txfee(env, 2)), balance(bob, USD(80))); + env(offer(gw, XRP(100), usd(100))); + env(pay(alice, bob, usd(100)), Sendmax(XRP(100)), Txflags(tfPartialPayment)); + env.require(Balance(alice, XRP(10'000 - 100) - txFee(env, 2)), Balance(bob, usd(80))); } { // Offer where the owner is also the issuer, sender pays @@ -623,16 +623,16 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, .transferFee = 25'000, .maxAmt = 1'000}); - env(offer(gw, XRP(125), USD(125))); - env(pay(alice, bob, USD(100)), sendmax(XRP(200))); - env.require(balance(alice, XRP(10'000 - 125) - txfee(env, 2)), balance(bob, USD(100))); + env(offer(gw, XRP(125), usd(125))); + env(pay(alice, bob, usd(100)), Sendmax(XRP(200))); + env.require(Balance(alice, XRP(10'000 - 125) - txFee(env, 2)), Balance(bob, usd(100))); } } @@ -655,13 +655,13 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(reserve(env, 5), bob); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol, bob}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {alice, carol, bob}}); - env(pay(gw, alice, EUR(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, eur(50))); + env(pay(gw, bob, usd(50))); // Bob has _just_ slightly less than 50 xrp available // If his owner count changes, he will have more liquidity. @@ -671,16 +671,16 @@ struct FlowMPT_test : public beast::unit_test::suite // second call will return tecPATH_DRY, but the entire path // should not be marked as dry. This is the second error // case to test (when flowV1 is used). - env(offer(bob, EUR(50), XRP(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, eur(50), XRP(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(1'000'000)), - path(~XRP, ~USD), - sendmax(EUR(500)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice, carol, usd(1'000'000)), + Path(~XRP, ~usd), + Sendmax(eur(500)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - auto const carolUSD = env.balance(carol, USD).value(); - BEAST_EXPECT(carolUSD > USD(0) && carolUSD < USD(50)); + auto const carolUSD = env.balance(carol, usd).value(); + BEAST_EXPECT(carolUSD > usd(0) && carolUSD < usd(50)); }; testHelper2TokensMix(test); } @@ -706,18 +706,18 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, bob, USD(100))); - env(offer(bob, XRP(50), USD(50))); - env(offer(bob, XRP(100), USD(50))); + env(pay(gw, bob, usd(100))); + env(offer(bob, XRP(50), usd(50))); + env(offer(bob, XRP(100), usd(50))); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice, carol, usd(100)), + Path(~usd), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); - env.require(balance(carol, USD(50))); + env.require(Balance(carol, usd(50))); } } @@ -770,21 +770,21 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(reserve(env, 3) + f * 4, alice); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw1, .holders = {alice}, .limit = 20'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw2, .holders = {alice}, .limit = 20'000}); - env(pay(gw1, alice, USD(10))); - env(pay(gw2, alice, EUR(10'000))); + env(pay(gw1, alice, usd(10))); + env(pay(gw2, alice, eur(10'000))); env.close(); - env(offer(alice, USD(5'000), EUR(6'000))); + env(offer(alice, usd(5'000), eur(6'000))); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(10))); - env.require(balance(alice, EUR(10'000))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(10))); + env.require(Balance(alice, eur(10'000))); auto aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); @@ -792,31 +792,31 @@ struct FlowMPT_test : public beast::unit_test::suite { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(6'000)); - BEAST_EXPECT(offer[sfTakerPays] == USD(5'000)); + BEAST_EXPECT(offer[sfTakerGets] == eur(6'000)); + BEAST_EXPECT(offer[sfTakerPays] == usd(5'000)); } - env(pay(alice, alice, EUR(6'000)), sendmax(USD(5'000)), txflags(tfPartialPayment)); + env(pay(alice, alice, eur(6'000)), Sendmax(usd(5'000)), Txflags(tfPartialPayment)); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(10))); - env.require(balance(alice, EUR(10'000))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(10))); + env.require(Balance(alice, eur(10'000))); aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); for (auto const& offerPtr : aliceOffers) { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - if constexpr (std::is_same_v, IOU>) + if constexpr (std::is_same_v, IOU>) { - BEAST_EXPECT(offer[sfTakerGets] == EUR(5'988)); + BEAST_EXPECT(offer[sfTakerGets] == eur(5'988)); } else { - BEAST_EXPECT(offer[sfTakerGets] == EUR(5'989)); + BEAST_EXPECT(offer[sfTakerGets] == eur(5'989)); } - BEAST_EXPECT(offer[sfTakerPays] == USD(4'990)); + BEAST_EXPECT(offer[sfTakerPays] == usd(4'990)); } }; testHelper2TokensMix(test); @@ -846,9 +846,9 @@ struct FlowMPT_test : public beast::unit_test::suite auto const alice = Account("alice"); auto initMPT = [&](Env& env) { - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw1, .holders = {alice}, .maxAmt = 506}); - MPT const EUR = + MPT const eur = MPTTester({.env = env, .issuer = gw2, .holders = {alice}, .maxAmt = 606}); // Payment's engine last step overflows // OutstandingAmount since it doesn't know if the @@ -857,11 +857,11 @@ struct FlowMPT_test : public beast::unit_test::suite // Note remaining takerGets is 541 rather than 540 due to integral // rounding. XRP has a similar result. return TokenData{ - .gets = EUR, .pays = USD, .remTakerGets = EUR(541), .remTakerPays = USD(450)}; + .gets = eur, .pays = usd, .remTakerGets = eur(541), .remTakerPays = usd(450)}; }; auto initXRP = [&](Env& env) { - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw1, .holders = {alice}, .maxAmt = 1'000}); // Payment's engine last step overflows // OutstandingAmount since it doesn't know if the @@ -869,37 +869,37 @@ struct FlowMPT_test : public beast::unit_test::suite // available. Consequently, the entire offer is crossed. // Note remaining takerGets is 540.000001 rather than 540 due to // integral rounding. - return TokenData{ + return TokenData{ .gets = XRP, - .pays = USD, + .pays = usd, .remTakerGets = XRP(540.000001), - .remTakerPays = USD(450)}; + .remTakerPays = usd(450)}; }; auto initIOU = [&](Env& env) { - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; - env(trust(alice, USD(506))); - env(trust(alice, EUR(606))); + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; + env(trust(alice, usd(506))); + env(trust(alice, eur(606))); env.close(); // Payment's engine last step is limited by alice's // trustline - 606. Therefore, only 6EUR is delivered // and the offer is partially crossed. return TokenData{ - .gets = EUR, .pays = USD, .remTakerGets = EUR(594), .remTakerPays = USD(495)}; + .gets = eur, .pays = usd, .remTakerGets = eur(594), .remTakerPays = usd(495)}; }; auto initIOU1 = [&](Env& env) { - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; - env(trust(alice, USD(1'000))); - env(trust(alice, EUR(1'000))); + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; + env(trust(alice, usd(1'000))); + env(trust(alice, eur(1'000))); env.close(); // Payment's engine last step is not limited by alice's // trustline. Therefore, the entire offer is crossed. // This the same result as with MPT. return TokenData{ - .gets = EUR, .pays = USD, .remTakerGets = EUR(540), .remTakerPays = USD(450)}; + .gets = eur, .pays = usd, .remTakerGets = eur(540), .remTakerPays = usd(450)}; }; auto test = [&](auto&& initToken) { @@ -912,28 +912,28 @@ struct FlowMPT_test : public beast::unit_test::suite auto const tok = initToken(env); - auto const& TOK1 = tok.pays; - auto const& TOK2 = tok.gets; - bool const isTakerGetsXRP = isXRP(Asset{TOK2}); + auto const& toK1 = tok.pays; + auto const& toK2 = tok.gets; + bool const isTakerGetsXRP = isXRP(Asset{toK2}); std::uint32_t const ownerCnt = isTakerGetsXRP ? 2 : 3; - env(pay(gw1, alice, TOK1(500))); + env(pay(gw1, alice, toK1(500))); if (!isTakerGetsXRP) - env(pay(gw2, alice, TOK2(600))); + env(pay(gw2, alice, toK2(600))); env.close(); - env(offer(alice, TOK1(500), TOK2(600))); + env(offer(alice, toK1(500), toK2(600))); env.close(); - env.require(owners(alice, ownerCnt)); - env.require(balance(alice, TOK1(500))); + env.require(Owners(alice, ownerCnt)); + env.require(Balance(alice, toK1(500))); if (isTakerGetsXRP) { - env.require(balance(alice, TOK2(2'000) - 2 * f)); + env.require(Balance(alice, toK2(2'000) - 2 * f)); } else { - env.require(balance(alice, TOK2(600))); + env.require(Balance(alice, toK2(600))); } auto aliceOffers = offersOnAccount(env, alice); @@ -942,22 +942,22 @@ struct FlowMPT_test : public beast::unit_test::suite { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == TOK2(600)); - BEAST_EXPECT(offer[sfTakerPays] == TOK1(500)); + BEAST_EXPECT(offer[sfTakerGets] == toK2(600)); + BEAST_EXPECT(offer[sfTakerPays] == toK1(500)); } - env(pay(alice, alice, TOK2(60)), sendmax(TOK1(50)), txflags(tfPartialPayment)); + env(pay(alice, alice, toK2(60)), Sendmax(toK1(50)), Txflags(tfPartialPayment)); env.close(); - env.require(owners(alice, ownerCnt)); - env.require(balance(alice, TOK1(500))); + env.require(Owners(alice, ownerCnt)); + env.require(Balance(alice, toK1(500))); if (isTakerGetsXRP) { - env.require(balance(alice, TOK2(2'000) - 3 * f)); + env.require(Balance(alice, toK2(2'000) - 3 * f)); } else { - env.require(balance(alice, TOK2(600))); + env.require(Balance(alice, toK2(600))); } aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); @@ -995,18 +995,18 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 20}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 20}); - env(pay(gw, alice, USD(10))); - env(offer(alice, XRP(50'000), USD(10))); + env(pay(gw, alice, usd(10))); + env(offer(alice, XRP(50'000), usd(10))); // Consuming the offer changes the owner count, which could // also cause liquidity to decrease in the forward pass - auto const toSend = consumeOffer ? USD(10) : USD(9); + auto const toSend = consumeOffer ? usd(10) : usd(9); env(pay(alice, alice, toSend), - path(~USD), - sendmax(XRP(20'000)), - txflags(tfPartialPayment | tfNoRippleDirect)); + Path(~usd), + Sendmax(XRP(20'000)), + Txflags(tfPartialPayment | tfNoRippleDirect)); } void @@ -1025,21 +1025,21 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(100'000), alice, bob, gw); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 20E+17}); // scale by 17 - STAmount const tinyAmt1{USD, 9'000'000'000'000'000ll, 0, false, STAmount::unchecked{}}; - STAmount const tinyAmt3{USD, 9'000'000'000'000'003ll, 0, false, STAmount::unchecked{}}; + STAmount const tinyAmt1{usd, 9'000'000'000'000'000ll, 0, false, STAmount::Unchecked{}}; + STAmount const tinyAmt3{usd, 9'000'000'000'000'003ll, 0, false, STAmount::Unchecked{}}; env(offer(gw, drops(9'000'000'000), tinyAmt3)); env(pay(alice, bob, tinyAmt1), - path(~USD), - sendmax(drops(9'000'000'000)), - txflags(tfNoRippleDirect)); + Path(~usd), + Sendmax(drops(9'000'000'000)), + Txflags(tfNoRippleDirect)); - BEAST_EXPECT(!isOffer(env, gw, XRP(0), USD(0))); + BEAST_EXPECT(!isOffer(env, gw, XRP(0), usd(0))); } { // Test forward @@ -1051,22 +1051,22 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(100'000), alice, bob, gw); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 20E+17}); // scale by 17 - STAmount const tinyAmt1{USD, 9'000'000'000'000'000ll, 0, false, STAmount::unchecked{}}; - STAmount const tinyAmt3{USD, 9'000'000'000'000'003ll, 0, false, STAmount::unchecked{}}; + STAmount const tinyAmt1{usd, 9'000'000'000'000'000ll, 0, false, STAmount::Unchecked{}}; + STAmount const tinyAmt3{usd, 9'000'000'000'000'003ll, 0, false, STAmount::Unchecked{}}; env(pay(gw, alice, tinyAmt1)); env(offer(gw, tinyAmt3, drops(9'000'000'000))); env(pay(alice, bob, drops(9'000'000'000)), - path(~XRP), - sendmax(USD(static_cast(1E+17))), - txflags(tfNoRippleDirect)); + Path(~XRP), + Sendmax(usd(static_cast(1E+17))), + Txflags(tfNoRippleDirect)); - BEAST_EXPECT(!isOffer(env, gw, USD(0), XRP(0))); + BEAST_EXPECT(!isOffer(env, gw, usd(0), XRP(0))); } } @@ -1085,43 +1085,43 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, gw); // scale by 16 - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 100E+16}); env( pay(gw, alice, // 12.55.... - STAmount{USD, std::uint64_t(1255555555555555ull), 2, false})); + STAmount{usd, std::uint64_t(1255555555555555ull), 2, false})); env(offer( gw, // 5.0... - STAmount{USD, std::uint64_t(5000000000000000ull), 1, false}, + STAmount{usd, std::uint64_t(5000000000000000ull), 1, false}, XRP(1000))); env(offer( gw, // .555... - STAmount{USD, std::uint64_t(5555555555555555ull), 0, false}, + STAmount{usd, std::uint64_t(5555555555555555ull), 0, false}, XRP(10))); env(offer( gw, // 4.44.... - STAmount{USD, std::uint64_t(4444444444444444ull), 1, false}, + STAmount{usd, std::uint64_t(4444444444444444ull), 1, false}, XRP(.1))); env(offer( alice, // 17 - STAmount{USD, std::uint64_t(1700000000000000ull), 0, false}, + STAmount{usd, std::uint64_t(1700000000000000ull), 0, false}, XRP(.001))); env(pay(alice, bob, XRP(10'000)), - path(~XRP), - sendmax(USD(static_cast(100E+16))), - txflags(tfPartialPayment | tfNoRippleDirect)); + Path(~XRP), + Sendmax(usd(static_cast(100E+16))), + Txflags(tfPartialPayment | tfNoRippleDirect)); } void @@ -1144,21 +1144,21 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(reserve(env, 2) + fee * 4, gw); // scale by 5 - MPT const CTB = MPTTester( + MPT const ctb = MPTTester( {.env = env, .issuer = gw, .holders = {ann}, .transferFee = 2'000, // 2% .maxAmt = 1'000'000}); - env(pay(gw, ann, CTB(285'600))); + env(pay(gw, ann, ctb(285'600))); env.close(); - env(offer(ann, drops(365'611'702'030), CTB(571'300))); + env(offer(ann, drops(365'611'702'030), ctb(571'300))); env.close(); // This payment caused assert. - env(pay(ann, ann, CTB(68'700)), sendmax(drops(20'000'000'000)), txflags(tfPartialPayment)); + env(pay(ann, ann, ctb(68'700)), Sendmax(drops(20'000'000'000)), Txflags(tfPartialPayment)); } void @@ -1173,9 +1173,9 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(10000), alice); - MPT const USD; + MPT const usd; - env(pay(alice, alice, USD(100)), path(~USD), ter(temBAD_PATH)); + env(pay(alice, alice, usd(100)), Path(~usd), Ter(temBAD_PATH)); } void @@ -1194,25 +1194,25 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(10'000), alice, bob, gw); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); - env(offer(alice, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(alice, USD(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), EUR(100)), txflags(tfPassive)); + env(offer(alice, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(alice, usd(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), eur(100)), Txflags(tfPassive)); env.close(); TER const expectedTer = TER{temBAD_PATH_LOOP}; - env(pay(alice, bob, EUR(1)), - path(~USD, ~XRP, ~EUR), - sendmax(XRP(1)), - txflags(tfNoRippleDirect), - ter(expectedTer)); + env(pay(alice, bob, eur(1)), + Path(~usd, ~XRP, ~eur), + Sendmax(XRP(1)), + Txflags(tfNoRippleDirect), + Ter(expectedTer)); }; testHelper2TokensMix(test); } @@ -1221,23 +1221,23 @@ struct FlowMPT_test : public beast::unit_test::suite auto test = [&](auto&& issue1, auto&& issue2) { Env env(*this); env.fund(XRP(10'000), alice, bob, gw); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); - env(offer(alice, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(alice, EUR(100), XRP(100)), txflags(tfPassive)); + env(offer(alice, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(alice, eur(100), XRP(100)), Txflags(tfPassive)); env.close(); // EUR -> //XRP -> //USD ->XRP env(pay(alice, bob, XRP(1)), - path(~XRP, ~USD, ~XRP), - sendmax(EUR(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + Path(~XRP, ~usd, ~XRP), + Sendmax(eur(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper2TokensMix(test); } @@ -1248,28 +1248,28 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(10'000), alice, bob, gw); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob}}); - auto const JPY = + auto const jpy = issue3({.env = env, .token = "JPY", .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); - env(pay(gw, alice, JPY(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); + env(pay(gw, alice, jpy(100))); env.close(); - env(offer(alice, USD(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), EUR(100)), txflags(tfPassive)); - env(offer(alice, EUR(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), JPY(100)), txflags(tfPassive)); + env(offer(alice, usd(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), eur(100)), Txflags(tfPassive)); + env(offer(alice, eur(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), jpy(100)), Txflags(tfPassive)); env.close(); - env(pay(alice, bob, JPY(1)), - path(~XRP, ~EUR, ~XRP, ~JPY), - sendmax(USD(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, bob, jpy(1)), + Path(~XRP, ~eur, ~XRP, ~jpy), + Sendmax(usd(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper3TokensMix(test); } @@ -1291,16 +1291,16 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}, .maxAmt = 100}); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); - env(pay(alice, carol, USD(100))); + env(pay(alice, carol, usd(100))); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); } // Direct payment between holders. Partial payment limited @@ -1310,16 +1310,16 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}, .maxAmt = 100}); - env(pay(gw, alice, USD(80))); + env(pay(gw, alice, usd(80))); - env(pay(alice, carol, USD(100)), txflags(tfPartialPayment)); + env(pay(alice, carol, usd(100)), Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-80)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); - BEAST_EXPECT(env.balance(carol, USD) == USD(80)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-80)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); + BEAST_EXPECT(env.balance(carol, usd) == usd(80)); } // Direct payment between holders. Partial payment limited @@ -1330,17 +1330,17 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .maxAmt = 100}); - env(pay(gw, bob, USD(20))); - env(pay(gw, alice, USD(80))); + env(pay(gw, bob, usd(20))); + env(pay(gw, alice, usd(80))); - env(pay(alice, carol, USD(100)), txflags(tfPartialPayment)); + env(pay(alice, carol, usd(100)), Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); - BEAST_EXPECT(env.balance(carol, USD) == USD(80)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); + BEAST_EXPECT(env.balance(carol, usd) == usd(80)); } // Cross-currency payment holder to holder. Holder owns an @@ -1351,18 +1351,18 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}, .maxAmt = 100}); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); - env(offer(alice, XRP(100), USD(100))); + env(offer(alice, XRP(100), usd(100))); - env(pay(bob, carol, USD(100)), sendmax(XRP(100)), path(~USD)); + env(pay(bob, carol, usd(100)), Sendmax(XRP(100)), Path(~usd)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); } // Cross-currency payment holder to holder. Issuer owns an @@ -1374,21 +1374,21 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {carol}, .maxAmt = 100}); - env(pay(gw, carol, USD(100))); + env(pay(gw, carol, usd(100))); - env(offer(gw, XRP(100), USD(100))); + env(offer(gw, XRP(100), usd(100))); - env(pay(alice, carol, USD(100)), - sendmax(XRP(100)), - path(~USD), - txflags(tfPartialPayment), - ter(tecPATH_DRY)); + env(pay(alice, carol, usd(100)), + Sendmax(XRP(100)), + Path(~usd), + Txflags(tfPartialPayment), + Ter(tecPATH_DRY)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); } // Cross-currency payment holder to holder. Issuer owns an @@ -1399,20 +1399,20 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {carol}, .maxAmt = 100}); - env(pay(gw, carol, USD(80))); + env(pay(gw, carol, usd(80))); - env(offer(gw, XRP(100), USD(100))); + env(offer(gw, XRP(100), usd(100))); - env(pay(alice, carol, USD(100)), - sendmax(XRP(100)), - path(~USD), - txflags(tfPartialPayment)); + env(pay(alice, carol, usd(100)), + Sendmax(XRP(100)), + Path(~usd), + Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); } // Cross-currency payment holder to holder. Holder owns an @@ -1423,17 +1423,17 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = 100}); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); - env(offer(alice, USD(100), XRP(100))); + env(offer(alice, usd(100), XRP(100))); - env(pay(gw, alice, XRP(100)), sendmax(USD(100)), path(~XRP), ter(tecPATH_PARTIAL)); + env(pay(gw, alice, XRP(100)), Sendmax(usd(100)), Path(~XRP), Ter(tecPATH_PARTIAL)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(alice, USD) == USD(100)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(100)); } // Cross-currency payment issuer to holder. Holder owns an @@ -1448,31 +1448,31 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol}, .limit = 100}); - using tUSD = std::decay_t; - auto const EUR = issue2( + using tUSD = std::decay_t; + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, carol}, .limit = 100}); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); - env(offer(alice, EUR(100), USD(100))); + env(offer(alice, eur(100), usd(100))); - env(pay(gw, carol, USD(100)), sendmax(EUR(100)), path(~USD)); + env(pay(gw, carol, usd(100)), Sendmax(eur(100)), Path(~usd)); if constexpr (std::is_same_v) - BEAST_EXPECT(env.balance(gw, USD) == USD(-100)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(100)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); + BEAST_EXPECT(env.balance(alice, eur) == eur(100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); }; testHelper2TokensMix(test); } @@ -1484,19 +1484,19 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {carol}, .maxAmt = 120}); - env(pay(gw, carol, USD(100))); + env(pay(gw, carol, usd(100))); - env(offer(carol, XRP(100), USD(100))); + env(offer(carol, XRP(100), usd(100))); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfPartialPayment)); + env(pay(alice, carol, usd(100)), + Path(~usd), + Sendmax(XRP(100)), + Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); } // Cross-currency payment holder to holder. Offer is owned @@ -1507,19 +1507,19 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {carol}, .maxAmt = 100}); - env(pay(gw, carol, USD(100))); + env(pay(gw, carol, usd(100))); - env(offer(carol, XRP(100), USD(100))); + env(offer(carol, XRP(100), usd(100))); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfPartialPayment)); + env(pay(alice, carol, usd(100)), + Path(~usd), + Sendmax(XRP(100)), + Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); } // Cross-currency payment holder to holder. Multiple offers @@ -1531,66 +1531,66 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol, bob}, .limit = 1'000}); - using tUSD = std::decay_t; - auto const EUR = issue2( + using tUSD = std::decay_t; + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, carol, bob}, .limit = 1'000}); - using tEUR = std::decay_t; + using tEUR = std::decay_t; - env(pay(gw, alice, USD(600))); - env(pay(gw, carol, EUR(700))); + env(pay(gw, alice, usd(600))); + env(pay(gw, carol, eur(700))); - env(offer(alice, EUR(100), USD(105))); - env(offer(gw, EUR(100), USD(104))); - env(offer(gw, EUR(100), USD(103))); - env(offer(gw, EUR(100), USD(102))); - env(offer(gw, EUR(100), USD(101))); - env(offer(gw, EUR(100), USD(100))); + env(offer(alice, eur(100), usd(105))); + env(offer(gw, eur(100), usd(104))); + env(offer(gw, eur(100), usd(103))); + env(offer(gw, eur(100), usd(102))); + env(offer(gw, eur(100), usd(101))); + env(offer(gw, eur(100), usd(100))); - env(pay(carol, bob, USD(2'000)), - sendmax(EUR(2'000)), - path(~USD), - txflags(tfPartialPayment)); + env(pay(carol, bob, usd(2'000)), + Sendmax(eur(2'000)), + Path(~usd), + Txflags(tfPartialPayment)); if constexpr (std::is_same_v) { - BEAST_EXPECT(env.balance(gw, USD) == USD(-1'000)); - BEAST_EXPECT(env.balance(alice, USD) == USD(495)); - BEAST_EXPECT(env.balance(bob, USD) == USD(505)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-1'000)); + BEAST_EXPECT(env.balance(alice, usd) == usd(495)); + BEAST_EXPECT(env.balance(bob, usd) == usd(505)); } else { - BEAST_EXPECT(env.balance(gw, USD) == USD(0)); - BEAST_EXPECT(env.balance(alice, USD) == USD(495)); + BEAST_EXPECT(env.balance(gw, usd) == usd(0)); + BEAST_EXPECT(env.balance(alice, usd) == usd(495)); // all offers are consumed since the limit is different // for the holders - BEAST_EXPECT(env.balance(bob, USD) == USD(615)); + BEAST_EXPECT(env.balance(bob, usd) == usd(615)); } if constexpr (std::is_same_v) { if constexpr (std::is_same_v) { - BEAST_EXPECT(env.balance(carol, EUR) == EUR(210)); + BEAST_EXPECT(env.balance(carol, eur) == eur(210)); } else { // carol sells 600USD since all offers are consumed - BEAST_EXPECT(env.balance(carol, EUR) == EUR(100)); + BEAST_EXPECT(env.balance(carol, eur) == eur(100)); } } else { BEAST_EXPECT( - env.balance(carol, EUR) == STAmount(EUR, UINT64_C(209'9009900990099), -13)); + env.balance(carol, eur) == STAmount(eur, UINT64_C(209'9009900990099), -13)); } // 100/101 is partially crossed (90/91) and 100/100 is // unfunded when MPT. All offers are consumed if IOU. @@ -1609,29 +1609,29 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}, .maxAmt = 2'000}); - env(pay(gw, carol, USD(1'000))); - env(pay(gw, alice, USD(600))); + env(pay(gw, carol, usd(1'000))); + env(pay(gw, alice, usd(600))); - env(offer(gw, XRP(5), USD(11))); - env(offer(gw, XRP(6), USD(13))); - env(offer(carol, XRP(7), USD(15))); - env(offer(carol, XRP(17), USD(35))); - env(offer(carol, XRP(23), USD(47))); - env(offer(alice, XRP(10), USD(19))); - env(offer(alice, XRP(15), USD(28))); - env(offer(alice, XRP(25), USD(46))); + env(offer(gw, XRP(5), usd(11))); + env(offer(gw, XRP(6), usd(13))); + env(offer(carol, XRP(7), usd(15))); + env(offer(carol, XRP(17), usd(35))); + env(offer(carol, XRP(23), usd(47))); + env(offer(alice, XRP(10), usd(19))); + env(offer(alice, XRP(15), usd(28))); + env(offer(alice, XRP(25), usd(46))); - env(pay(carol, carol, USD(200)), sendmax(XRP(100)), txflags(tfPartialPayment)); + env(pay(carol, carol, usd(200)), Sendmax(XRP(100)), Txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-1'624)); - BEAST_EXPECT(env.balance(carol, USD) == USD(1'102)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-1'624)); + BEAST_EXPECT(env.balance(carol, usd) == usd(1'102)); env.require(offers(carol, 0)); env.require(offers(gw, 0)); // 100 XRP's = 5+6+7+17+23+10+15+17(25-8) - BEAST_EXPECT(isOffer(env, alice, XRP(8), USD(15))); + BEAST_EXPECT(isOffer(env, alice, XRP(8), usd(15))); } // Cross-currency payment holder to holder. Multiple offers @@ -1640,21 +1640,21 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(1'000), gw, alice, carol, bob); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .maxAmt = 30}); - env(pay(gw, alice, USD(12))); // 12, 15, 20 - env(pay(gw, bob, USD(5))); // 5, 5, 10 + env(pay(gw, alice, usd(12))); // 12, 15, 20 + env(pay(gw, bob, usd(5))); // 5, 5, 10 - env(offer(alice, XRP(10), USD(12))); - env(offer(gw, XRP(10), USD(11))); - env(offer(bob, XRP(10), USD(10))); + env(offer(alice, XRP(10), usd(12))); + env(offer(gw, XRP(10), usd(11))); + env(offer(bob, XRP(10), usd(10))); - env(pay(carol, bob, USD(30)), sendmax(XRP(30)), txflags(tfPartialPayment), path(~USD)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-28)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); + env(pay(carol, bob, usd(30)), Sendmax(XRP(30)), Txflags(tfPartialPayment), Path(~usd)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-28)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); // 12+11+5 - BEAST_EXPECT(env.balance(bob, USD) == USD(28)); + BEAST_EXPECT(env.balance(bob, usd) == usd(28)); } // Cross-currency payment two steps. Second book step @@ -1702,42 +1702,42 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob, dan, john, ed, sam, bill); env.close(); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .maxAmt = d.maxAmt}); - auto const EUR = gw["EUR"]; + auto const eur = gw["EUR"]; - env(pay(gw, alice, USD(100))); - env(pay(gw, carol, USD(100))); - env(pay(gw, bob, USD(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, carol, usd(100))); + env(pay(gw, bob, usd(100))); - BEAST_EXPECT(env.balance(gw, USD) == USD(-300)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-300)); - env(trust(john, EUR(100))); - env(trust(dan, EUR(100))); - env(trust(ed, EUR(100))); - env(trust(bill, EUR(d.dstTrustLimit))); + env(trust(john, eur(100))); + env(trust(dan, eur(100))); + env(trust(ed, eur(100))); + env(trust(bill, eur(d.dstTrustLimit))); - env(pay(gw, john, EUR(100))); - env(pay(gw, dan, EUR(100))); - env(pay(gw, ed, EUR(100))); + env(pay(gw, john, eur(100))); + env(pay(gw, dan, eur(100))); + env(pay(gw, ed, eur(100))); env.close(); // Sell USD - env(offer(alice, XRP(100), USD(100))); + env(offer(alice, XRP(100), usd(100))); env.close(); // close after each create to ensure // the order - env(offer(carol, XRP(100), USD(100))); + env(offer(carol, XRP(100), usd(100))); env.close(); if (!d.lastGwBuyUSD) { - env(offer(gw, XRP(100), USD(100))); + env(offer(gw, XRP(100), usd(100))); env.close(); } - env(offer(bob, XRP(100), USD(100))); + env(offer(bob, XRP(100), usd(100))); env.close(); if (d.lastGwBuyUSD) { - env(offer(gw, XRP(100), USD(100))); + env(offer(gw, XRP(100), usd(100))); env.close(); } BEAST_EXPECT(expectOffers(env, alice, 1)); @@ -1746,36 +1746,36 @@ struct FlowMPT_test : public beast::unit_test::suite BEAST_EXPECT(expectOffers(env, bob, 1)); // Buy USD - env(offer(john, USD(100), EUR(100))); + env(offer(john, usd(100), eur(100))); env.close(); - env(offer(gw, USD(100), EUR(100))); + env(offer(gw, usd(100), eur(100))); env.close(); - env(offer(dan, USD(100), EUR(100))); + env(offer(dan, usd(100), eur(100))); env.close(); - env(offer(ed, USD(100), EUR(100))); + env(offer(ed, usd(100), eur(100))); env.close(); BEAST_EXPECT(expectOffers(env, john, 1)); BEAST_EXPECT(expectOffers(env, gw, 2)); BEAST_EXPECT(expectOffers(env, dan, 1)); BEAST_EXPECT(expectOffers(env, ed, 1)); - env(pay(sam, bill, EUR(400)), - sendmax(XRP(d.sendMax)), - path(~USD, ~EUR), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(sam, bill, eur(400)), + Sendmax(XRP(d.sendMax)), + Path(~usd, ~eur), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); auto const baseFee = env.current()->fees().base.drops(); - BEAST_EXPECT(env.balance(bill, EUR) == EUR(d.dstExpectEUR)); - BEAST_EXPECT(env.balance(john, USD) == USD(100)); - BEAST_EXPECT(env.balance(dan, USD) == USD(d.expDanBuyUSD)); - BEAST_EXPECT(env.balance(ed, USD) == USD(d.expEdBuyUSD)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-d.outstandingUSD)); - BEAST_EXPECT(env.balance(alice, USD) == USD(0)); - BEAST_EXPECT(env.balance(carol, USD) == USD(0)); - BEAST_EXPECT(env.balance(bob, USD) == USD(100 - d.expBobSellUSD)); + BEAST_EXPECT(env.balance(bill, eur) == eur(d.dstExpectEUR)); + BEAST_EXPECT(env.balance(john, usd) == usd(100)); + BEAST_EXPECT(env.balance(dan, usd) == usd(d.expDanBuyUSD)); + BEAST_EXPECT(env.balance(ed, usd) == usd(d.expEdBuyUSD)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-d.outstandingUSD)); + BEAST_EXPECT(env.balance(alice, usd) == usd(0)); + BEAST_EXPECT(env.balance(carol, usd) == usd(0)); + BEAST_EXPECT(env.balance(bob, usd) == usd(100 - d.expBobSellUSD)); BEAST_EXPECT( - env.balance(gw) == XRPAmount{d.expGwXRP * DROPS_PER_XRP - baseFee * 9}); + env.balance(gw) == XRPAmount{d.expGwXRP * kDROPS_PER_XRP - baseFee * 9}); BEAST_EXPECT(expectOffers(env, john, 0)); BEAST_EXPECT(expectOffers(env, gw, d.expOffersGw)); BEAST_EXPECT(expectOffers(env, dan, d.expOffersDan())); @@ -1863,46 +1863,46 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob, ed); env.close(); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .maxAmt = d.maxAmt}); - env(pay(gw, alice, USD(300))); + env(pay(gw, alice, usd(300))); env.close(); - env(offer(carol, USD(100), XRP(100))); + env(offer(carol, usd(100), XRP(100))); env.close(); if (!d.lastGwBuyUSD) { - env(offer(gw, USD(d.gwOffer), XRP(d.gwOffer))); + env(offer(gw, usd(d.gwOffer), XRP(d.gwOffer))); env.close(); } - env(offer(bob, USD(100), XRP(100))); + env(offer(bob, usd(100), XRP(100))); env.close(); if (d.lastGwBuyUSD) { - env(offer(gw, USD(d.gwOffer), XRP(d.gwOffer))); + env(offer(gw, usd(d.gwOffer), XRP(d.gwOffer))); env.close(); } BEAST_EXPECT(expectOffers(env, carol, 1)); BEAST_EXPECT(expectOffers(env, bob, 1)); BEAST_EXPECT(expectOffers(env, gw, 1)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-300)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-300)); env(pay(alice, ed, XRP(300)), - sendmax(USD(d.sendMax)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect)); + Sendmax(usd(d.sendMax)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); auto const baseFee = env.current()->fees().base.drops(); - BEAST_EXPECT(env.balance(alice, USD) == USD(300 - d.sendMax)); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); - BEAST_EXPECT(env.balance(bob, USD) == USD(d.expBobBuyUSD)); + BEAST_EXPECT(env.balance(alice, usd) == usd(300 - d.sendMax)); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); + BEAST_EXPECT(env.balance(bob, usd) == usd(d.expBobBuyUSD)); BEAST_EXPECT(env.balance(ed) == XRP(d.dstExpectXRP)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-d.outstandingUSD)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-d.outstandingUSD)); BEAST_EXPECT( - env.balance(gw) == XRPAmount{d.expGwXRP * DROPS_PER_XRP - baseFee * 3}); + env.balance(gw) == XRPAmount{d.expGwXRP * kDROPS_PER_XRP - baseFee * 3}); BEAST_EXPECT(expectOffers(env, carol, 0)); BEAST_EXPECT(expectOffers(env, bob, d.expOffersBob())); BEAST_EXPECT(expectOffers(env, gw, d.expOffersGw)); @@ -1970,52 +1970,52 @@ struct FlowMPT_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob, ed); env.close(); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {carol, bob, ed}, .maxAmt = d.maxAmt}); if (d.initDst != 0) - env(pay(gw, ed, USD(d.initDst))); - env(pay(gw, carol, USD(100))); - env(pay(gw, bob, USD(100))); + env(pay(gw, ed, usd(d.initDst))); + env(pay(gw, carol, usd(100))); + env(pay(gw, bob, usd(100))); env.close(); - env(offer(carol, XRP(100), USD(100))); + env(offer(carol, XRP(100), usd(100))); env.close(); if (!d.lastGwBuyUSD) { - env(offer(gw, XRP(d.gwOffer), USD(d.gwOffer))); + env(offer(gw, XRP(d.gwOffer), usd(d.gwOffer))); env.close(); } - env(offer(bob, XRP(100), USD(100))); + env(offer(bob, XRP(100), usd(100))); env.close(); if (d.lastGwBuyUSD) { - env(offer(gw, XRP(d.gwOffer), USD(d.gwOffer))); + env(offer(gw, XRP(d.gwOffer), usd(d.gwOffer))); env.close(); } BEAST_EXPECT(expectOffers(env, carol, 1)); BEAST_EXPECT(expectOffers(env, bob, 1)); BEAST_EXPECT(expectOffers(env, gw, 1)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-200 - d.initDst)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-200 - d.initDst)); - env(pay(alice, ed, USD(300)), - sendmax(XRP(d.sendMax)), - path(~USD), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(alice, ed, usd(300)), + Sendmax(XRP(d.sendMax)), + Path(~usd), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); auto const baseFee = env.current()->fees().base.drops(); BEAST_EXPECT( - env.balance(alice) == XRPAmount{d.expAliceXRP * DROPS_PER_XRP - baseFee}); - BEAST_EXPECT(env.balance(carol, USD) == USD(0)); - BEAST_EXPECT(env.balance(bob, USD) == USD(100 - d.expBobSellUSD)); - BEAST_EXPECT(env.balance(ed, USD) == USD(d.dstExpectUSD)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-d.outstandingUSD)); + env.balance(alice) == XRPAmount{d.expAliceXRP * kDROPS_PER_XRP - baseFee}); + BEAST_EXPECT(env.balance(carol, usd) == usd(0)); + BEAST_EXPECT(env.balance(bob, usd) == usd(100 - d.expBobSellUSD)); + BEAST_EXPECT(env.balance(ed, usd) == usd(d.dstExpectUSD)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-d.outstandingUSD)); BEAST_EXPECT( env.balance(gw) == XRPAmount{ - d.expGwXRP * DROPS_PER_XRP - baseFee * (4 + (d.initDst != 0 ? 1 : 0))}); + d.expGwXRP * kDROPS_PER_XRP - baseFee * (4 + (d.initDst != 0 ? 1 : 0))}); BEAST_EXPECT(expectOffers(env, carol, 0)); BEAST_EXPECT(expectOffers(env, bob, d.expOffersBob())); BEAST_EXPECT(expectOffers(env, gw, d.expOffersGw)); @@ -2077,21 +2077,21 @@ struct FlowMPT_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(1'000), gw, alice, carol); - MPT const USD = MPTTester({.env = env, .issuer = gw, .maxAmt = 300}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .maxAmt = 300}); - env(offer(carol, USD(400), XRP(400))); - env(offer(gw, USD(100), XRP(100))); + env(offer(carol, usd(400), XRP(400))); + env(offer(gw, usd(100), XRP(100))); BEAST_EXPECT(expectOffers(env, carol, 1)); BEAST_EXPECT(expectOffers(env, gw, 1)); env(pay(gw, alice, XRP(500)), - sendmax(USD(sendMax)), - path(~XRP), - txflags(tfPartialPayment | tfNoRippleDirect)); + Sendmax(usd(sendMax)), + Path(~XRP), + Txflags(tfPartialPayment | tfNoRippleDirect)); BEAST_EXPECT(env.balance(alice) == XRP(dstXRP)); - BEAST_EXPECT(env.balance(gw, USD) == USD(-300)); - BEAST_EXPECT(env.balance(carol, USD) == USD(300)); + BEAST_EXPECT(env.balance(gw, usd) == usd(-300)); + BEAST_EXPECT(env.balance(carol, usd) == usd(300)); BEAST_EXPECT(expectOffers(env, carol, 0)); BEAST_EXPECT(expectOffers(env, gw, expGwOffers)); }; @@ -2136,7 +2136,7 @@ struct FlowMPT_test : public beast::unit_test::suite run() override { using namespace jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testLimitQuality(); testXRPPathLoop(); testWithFeats(sa); diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 8f096a970f..c6f4cf59d1 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -67,7 +67,7 @@ getNoRippleFlag( return false; // silence warning } -struct Flow_test : public beast::unit_test::suite +struct Flow_test : public beast::unit_test::Suite { void testDirectStep(FeatureBitset features) @@ -80,22 +80,22 @@ struct Flow_test : public beast::unit_test::suite auto const carol = Account("carol"); auto const dan = Account("dan"); auto const erin = Account("erin"); - auto const USDA = alice["USD"]; - auto const USDB = bob["USD"]; - auto const USDC = carol["USD"]; - auto const USDD = dan["USD"]; + auto const usda = alice["USD"]; + auto const usdb = bob["USD"]; + auto const usdc = carol["USD"]; + auto const usdd = dan["USD"]; auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { // Pay USD, trivial path Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(alice, bob, USD(10)), paths(USD)); - env.require(balance(bob, USD(10))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(alice, bob, usd(10)), Paths(usd)); + env.require(Balance(bob, usd(10))); } { // XRP transfer @@ -104,8 +104,8 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob); env.close(); env(pay(alice, bob, XRP(100))); - env.require(balance(bob, XRP(10000 + 100))); - env.require(balance(alice, xrpMinusFee(env, 10000 - 100))); + env.require(Balance(bob, XRP(10000 + 100))); + env.require(Balance(alice, xrpMinusFee(env, 10000 - 100))); } { // Partial payments @@ -113,12 +113,12 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(alice, bob, USD(110)), paths(USD), ter(tecPATH_PARTIAL)); - env.require(balance(bob, USD(0))); - env(pay(alice, bob, USD(110)), paths(USD), txflags(tfPartialPayment)); - env.require(balance(bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(alice, bob, usd(110)), Paths(usd), Ter(tecPATH_PARTIAL)); + env.require(Balance(bob, usd(0))); + env(pay(alice, bob, usd(110)), Paths(usd), Txflags(tfPartialPayment)); + env.require(Balance(bob, usd(100))); } { // Pay by rippling through accounts, use path finder @@ -126,11 +126,11 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, dan); env.close(); - env.trust(USDA(10), bob); - env.trust(USDB(10), carol); - env.trust(USDC(10), dan); - env(pay(alice, dan, USDC(10)), paths(USDA)); - env.require(balance(bob, USDA(10)), balance(carol, USDB(10)), balance(dan, USDC(10))); + env.trust(usda(10), bob); + env.trust(usdb(10), carol); + env.trust(usdc(10), dan); + env(pay(alice, dan, usdc(10)), Paths(usda)); + env.require(Balance(bob, usda(10)), Balance(carol, usdb(10)), Balance(dan, usdc(10))); } { // Pay by rippling through accounts, specify path @@ -139,19 +139,19 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, dan); env.close(); - env.trust(USDA(10), bob); - env.trust(USDB(10), alice, carol); - env.trust(USDC(10), dan); + env.trust(usda(10), bob); + env.trust(usdb(10), alice, carol); + env.trust(usdc(10), dan); env(rate(bob, 1.1)); // alice will redeem to bob; a transfer fee will be charged - env(pay(bob, alice, USDB(6))); - env(pay(alice, dan, USDC(5)), - path(bob, carol), - sendmax(USDA(6)), - txflags(tfNoRippleDirect)); - env.require(balance(dan, USDC(5))); - env.require(balance(alice, USDB(0.5))); + env(pay(bob, alice, usdb(6))); + env(pay(alice, dan, usdc(5)), + Path(bob, carol), + Sendmax(usda(6)), + Txflags(tfNoRippleDirect)); + env.require(Balance(dan, usdc(5))); + env.require(Balance(alice, usdb(0.5))); } { // Pay by rippling through accounts, specify path and transfer fee @@ -160,17 +160,17 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, dan); env.close(); - env.trust(USDA(10), bob); - env.trust(USDB(10), alice, carol); - env.trust(USDC(10), dan); + env.trust(usda(10), bob); + env.trust(usdb(10), alice, carol); + env.trust(usdc(10), dan); env(rate(bob, 1.1)); - env(pay(alice, dan, USDC(5)), - path(bob, carol), - sendmax(USDA(6)), - txflags(tfNoRippleDirect)); - env.require(balance(dan, USDC(5))); - env.require(balance(bob, USDA(5))); + env(pay(alice, dan, usdc(5)), + Path(bob, carol), + Sendmax(usda(6)), + Txflags(tfNoRippleDirect)); + env.require(Balance(dan, usdc(5))); + env.require(Balance(bob, usda(5))); } { // test best quality path is taken @@ -179,23 +179,23 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, dan, erin); env.close(); - env.trust(USDA(10), bob, carol); - env.trust(USDB(10), dan); - env.trust(USDC(10), alice, dan); - env.trust(USDD(20), erin); + env.trust(usda(10), bob, carol); + env.trust(usdb(10), dan); + env.trust(usdc(10), alice, dan); + env.trust(usdd(20), erin); env(rate(bob, 1)); env(rate(carol, 1.1)); // Pay alice so she redeems to carol and a transfer fee is charged - env(pay(carol, alice, USDC(10))); - env(pay(alice, erin, USDD(5)), - path(carol, dan), - path(bob, dan), - txflags(tfNoRippleDirect)); + env(pay(carol, alice, usdc(10))); + env(pay(alice, erin, usdd(5)), + Path(carol, dan), + Path(bob, dan), + Txflags(tfNoRippleDirect)); - env.require(balance(erin, USDD(5))); - env.require(balance(dan, USDB(5))); - env.require(balance(dan, USDC(0))); + env.require(Balance(erin, usdd(5))); + env.require(Balance(dan, usdb(5))); + env.require(Balance(dan, usdc(0))); } { // Limit quality @@ -203,17 +203,17 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol); env.close(); - env.trust(USDA(10), bob); - env.trust(USDB(10), carol); + env.trust(usda(10), bob); + env.trust(usdb(10), carol); - env(pay(alice, carol, USDB(5)), - sendmax(USDA(4)), - txflags(tfLimitQuality | tfPartialPayment), - ter(tecPATH_DRY)); - env.require(balance(carol, USDB(0))); + env(pay(alice, carol, usdb(5)), + Sendmax(usda(4)), + Txflags(tfLimitQuality | tfPartialPayment), + Ter(tecPATH_DRY)); + env.require(Balance(carol, usdb(0))); - env(pay(alice, carol, USDB(5)), sendmax(USDA(4)), txflags(tfPartialPayment)); - env.require(balance(carol, USDB(4))); + env(pay(alice, carol, usdb(5)), Sendmax(usda(4)), Txflags(tfPartialPayment)); + env.require(Balance(carol, usdb(4))); } } @@ -227,10 +227,10 @@ struct Flow_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const dan = Account("dan"); - auto const USDA = alice["USD"]; - auto const USDB = bob["USD"]; - auto const USDC = carol["USD"]; - auto const USDD = dan["USD"]; + auto const usda = alice["USD"]; + auto const usdb = bob["USD"]; + auto const usdc = carol["USD"]; + auto const usdd = dan["USD"]; // Dan -> Bob -> Alice -> Carol; vary bobDanQIn and bobAliceQOut for (auto bobDanQIn : {80, 100, 120}) @@ -240,27 +240,27 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, dan); env.close(); - env(trust(bob, USDD(100)), qualityInPercent(bobDanQIn)); - env(trust(bob, USDA(100)), qualityOutPercent(bobAliceQOut)); - env(trust(carol, USDA(100))); + env(trust(bob, usdd(100)), QualityInPercent(bobDanQIn)); + env(trust(bob, usda(100)), QualityOutPercent(bobAliceQOut)); + env(trust(carol, usda(100))); - env(pay(alice, bob, USDA(100))); - env.require(balance(bob, USDA(100))); - env(pay(dan, carol, USDA(10)), - path(bob), - sendmax(USDD(100)), - txflags(tfNoRippleDirect)); - env.require(balance(bob, USDA(90))); + env(pay(alice, bob, usda(100))); + env.require(Balance(bob, usda(100))); + env(pay(dan, carol, usda(10)), + Path(bob), + Sendmax(usdd(100)), + Txflags(tfNoRippleDirect)); + env.require(Balance(bob, usda(90))); if (bobAliceQOut > bobDanQIn) { env.require( - balance(bob, USDD(10.0 * double(bobAliceQOut) / double(bobDanQIn)))); + Balance(bob, usdd(10.0 * double(bobAliceQOut) / double(bobDanQIn)))); } else { - env.require(balance(bob, USDD(10))); + env.require(Balance(bob, usdd(10))); } - env.require(balance(carol, USDA(10))); + env.require(Balance(carol, usda(10))); } } @@ -271,14 +271,14 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol); env.close(); - env(trust(bob, USDA(10))); - env(trust(carol, USDA(10)), qualityInPercent(carolAliceQIn)); + env(trust(bob, usda(10))); + env(trust(carol, usda(10)), QualityInPercent(carolAliceQIn)); - env(pay(alice, bob, USDA(10))); - env.require(balance(bob, USDA(10))); - env(pay(bob, carol, USDA(5)), sendmax(USDA(10))); + env(pay(alice, bob, usda(10))); + env.require(Balance(bob, usda(10))); + env(pay(bob, carol, usda(5)), Sendmax(usda(10))); auto const effectiveQ = carolAliceQIn > 100 ? 1.0 : carolAliceQIn / 100.0; - env.require(balance(bob, USDA(10.0 - (5.0 / effectiveQ)))); + env.require(Balance(bob, usda(10.0 - (5.0 / effectiveQ)))); } // bob -> alice -> carol; bobAliceQOut varies. @@ -287,14 +287,14 @@ struct Flow_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol); env.close(); - env(trust(bob, USDA(10)), qualityOutPercent(bobAliceQOut)); - env(trust(carol, USDA(10))); + env(trust(bob, usda(10)), QualityOutPercent(bobAliceQOut)); + env(trust(carol, usda(10))); - env(pay(alice, bob, USDA(10))); - env.require(balance(bob, USDA(10))); - env(pay(bob, carol, USDA(5)), sendmax(USDA(5))); - env.require(balance(carol, USDA(5))); - env.require(balance(bob, USDA(10 - 5))); + env(pay(alice, bob, usda(10))); + env.require(Balance(bob, usda(10))); + env(pay(bob, carol, usda(5)), Sendmax(usda(5))); + env.require(Balance(carol, usda(5))); + env.require(Balance(bob, usda(10 - 5))); } } @@ -306,9 +306,9 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; + auto const eur = gw["EUR"]; Account const alice("alice"); Account const bob("bob"); Account const carol("carol"); @@ -319,21 +319,21 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); - env(pay(gw, alice, BTC(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, btc(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, BTC(50), USD(50))); + env(offer(bob, btc(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(BTC(50))); + env(pay(alice, carol, usd(50)), Path(~usd), Sendmax(btc(50))); - env.require(balance(alice, BTC(0))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, BTC(50), USD(50))); + env.require(Balance(alice, btc(0))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), usd(50))); } { // simple IOU/XRP XRP/IOU offer @@ -341,23 +341,23 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); - env(pay(gw, alice, BTC(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, btc(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, BTC(50), XRP(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, btc(50), XRP(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~XRP, ~USD), sendmax(BTC(50))); + env(pay(alice, carol, usd(50)), Path(~XRP, ~usd), Sendmax(btc(50))); - env.require(balance(alice, BTC(0))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, XRP(50), USD(50))); - BEAST_EXPECT(!isOffer(env, bob, BTC(50), XRP(50))); + env.require(Balance(alice, btc(0))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, XRP(50), usd(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), XRP(50))); } { // simple XRP -> USD through offer and sendmax @@ -365,20 +365,20 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); - env(pay(gw, bob, USD(50))); + env(pay(gw, bob, usd(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), sendmax(XRP(50))); + env(pay(alice, carol, usd(50)), Path(~usd), Sendmax(XRP(50))); - env.require(balance(alice, xrpMinusFee(env, 10000 - 50))); - env.require(balance(bob, xrpMinusFee(env, 10000 + 50))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(50))); - BEAST_EXPECT(!isOffer(env, bob, XRP(50), USD(50))); + env.require(Balance(alice, xrpMinusFee(env, 10000 - 50))); + env.require(Balance(bob, xrpMinusFee(env, 10000 + 50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(carol, usd(50))); + BEAST_EXPECT(!isOffer(env, bob, XRP(50), usd(50))); } { // simple USD -> XRP through offer and sendmax @@ -386,20 +386,20 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); - env(pay(gw, alice, USD(50))); + env(pay(gw, alice, usd(50))); - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); - env(pay(alice, carol, XRP(50)), path(~XRP), sendmax(USD(50))); + env(pay(alice, carol, XRP(50)), Path(~XRP), Sendmax(usd(50))); - env.require(balance(alice, USD(0))); - env.require(balance(bob, xrpMinusFee(env, 10000 - 50))); - env.require(balance(bob, USD(50))); - env.require(balance(carol, XRP(10000 + 50))); - BEAST_EXPECT(!isOffer(env, bob, USD(50), XRP(50))); + env.require(Balance(alice, usd(0))); + env.require(Balance(bob, xrpMinusFee(env, 10000 - 50))); + env.require(Balance(bob, usd(50))); + env.require(Balance(carol, XRP(10000 + 50))); + BEAST_EXPECT(!isOffer(env, bob, usd(50), XRP(50))); } { // test unfunded offers are removed when payment succeeds @@ -407,37 +407,37 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, USD(50))); - env(pay(gw, bob, EUR(50))); + env(pay(gw, alice, btc(60))); + env(pay(gw, bob, usd(50))); + env(pay(gw, bob, eur(50))); - env(offer(bob, BTC(50), USD(50))); - env(offer(bob, BTC(40), EUR(50))); - env(offer(bob, EUR(50), USD(50))); + env(offer(bob, btc(50), usd(50))); + env(offer(bob, btc(40), eur(50))); + env(offer(bob, eur(50), usd(50))); // unfund offer - env(pay(bob, gw, EUR(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(40), EUR(50))); - BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50))); + env(pay(bob, gw, eur(50))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(50))); + BEAST_EXPECT(isOffer(env, bob, btc(40), eur(50))); + BEAST_EXPECT(isOffer(env, bob, eur(50), usd(50))); - env(pay(alice, carol, USD(50)), path(~USD), path(~EUR, ~USD), sendmax(BTC(60))); + env(pay(alice, carol, usd(50)), Path(~usd), Path(~eur, ~usd), Sendmax(btc(60))); - env.require(balance(alice, BTC(10))); - env.require(balance(bob, BTC(50))); - env.require(balance(bob, USD(0))); - env.require(balance(bob, EUR(0))); - env.require(balance(carol, USD(50))); + env.require(Balance(alice, btc(10))); + env.require(Balance(bob, btc(50))); + env.require(Balance(bob, usd(0))); + env.require(Balance(bob, eur(0))); + env.require(Balance(carol, usd(50))); // used in the payment - BEAST_EXPECT(!isOffer(env, bob, BTC(50), USD(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(50), usd(50))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(40), EUR(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(40), eur(50))); // unfunded, but should not yet be found unfunded - BEAST_EXPECT(isOffer(env, bob, EUR(50), USD(50))); + BEAST_EXPECT(isOffer(env, bob, eur(50), usd(50))); } { // test unfunded offers are returned when the payment fails. @@ -452,46 +452,46 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); - env(pay(gw, alice, BTC(60))); - env(pay(gw, bob, USD(60))); - env(pay(gw, bob, EUR(50))); - env(pay(gw, carol, EUR(1))); + env(pay(gw, alice, btc(60))); + env(pay(gw, bob, usd(60))); + env(pay(gw, bob, eur(50))); + env(pay(gw, carol, eur(1))); - env(offer(bob, BTC(50), USD(50))); - env(offer(bob, BTC(60), EUR(50))); - env(offer(carol, BTC(1000), EUR(1))); - env(offer(bob, EUR(50), USD(50))); + env(offer(bob, btc(50), usd(50))); + env(offer(bob, btc(60), eur(50))); + env(offer(carol, btc(1000), eur(1))); + env(offer(bob, eur(50), usd(50))); // unfund offer - env(pay(bob, gw, EUR(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(50))); - BEAST_EXPECT(isOffer(env, bob, BTC(60), EUR(50))); - BEAST_EXPECT(isOffer(env, carol, BTC(1000), EUR(1))); + env(pay(bob, gw, eur(50))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(50))); + BEAST_EXPECT(isOffer(env, bob, btc(60), eur(50))); + BEAST_EXPECT(isOffer(env, carol, btc(1000), eur(1))); auto flowJournal = env.app().getJournal("Flow"); auto const flowResult = [&] { - STAmount const deliver(USD(51)); - STAmount smax(BTC(61)); - PaymentSandbox sb(env.current().get(), tapNONE); + STAmount const deliver(usd(51)); + STAmount smax(btc(61)); + PaymentSandbox sb(env.current().get(), TapNone); STPathSet paths; - auto IPE = [](Issue const& iss) { + auto ipe = [](Issue const& iss) { return STPathElement( - STPathElement::typeCurrency | STPathElement::typeIssuer, + STPathElement::TypeCurrency | STPathElement::TypeIssuer, xrpAccount(), iss.currency, iss.account); }; { // BTC -> USD - STPath const p1({IPE(USD)}); - paths.push_back(p1); + STPath const p1({ipe(usd)}); + paths.pushBack(p1); // BTC -> EUR -> USD - STPath const p2({IPE(EUR), IPE(USD)}); - paths.push_back(p2); + STPath const p2({ipe(eur), ipe(usd)}); + paths.pushBack(p2); } return flow( @@ -503,7 +503,7 @@ struct Flow_test : public beast::unit_test::suite false, false, true, - OfferCrossing::no, + OfferCrossing::No, std::nullopt, smax, std::nullopt, @@ -514,7 +514,7 @@ struct Flow_test : public beast::unit_test::suite env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { if (flowResult.removableOffers.empty()) return false; - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); for (auto const& o : flowResult.removableOffers) { if (auto ok = sb.peek(keylet::offer(o))) @@ -525,10 +525,10 @@ struct Flow_test : public beast::unit_test::suite }); // used in payment, but since payment failed should be untouched - BEAST_EXPECT(isOffer(env, bob, BTC(50), USD(50))); - BEAST_EXPECT(isOffer(env, carol, BTC(1000), EUR(1))); + BEAST_EXPECT(isOffer(env, bob, btc(50), usd(50))); + BEAST_EXPECT(isOffer(env, carol, btc(1000), eur(1))); // found unfunded - BEAST_EXPECT(!isOffer(env, bob, BTC(60), EUR(50))); + BEAST_EXPECT(!isOffer(env, bob, btc(60), eur(50))); } { // Do not produce more in the forward pass than the reverse pass @@ -542,15 +542,15 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); - env(pay(gw, alice, USD(1000))); - env(pay(gw, bob, EUR(1000))); + env(pay(gw, alice, usd(1000))); + env(pay(gw, bob, eur(1000))); Keylet const bobUsdOffer = keylet::offer(bob, env.seq(bob)); - env(offer(bob, USD(1), drops(2)), txflags(tfPassive)); - env(offer(bob, drops(1), EUR(1000)), txflags(tfPassive)); + env(offer(bob, usd(1), drops(2)), Txflags(tfPassive)); + env(offer(bob, drops(1), eur(1000)), Txflags(tfPassive)); bool const reducedOffersV2 = features[fixReducedOffersV2]; @@ -559,17 +559,17 @@ struct Flow_test : public beast::unit_test::suite // than USD(0.5), then the remaining fractional offer would // block the order book. TER const expectedTER = reducedOffersV2 ? TER(tecPATH_DRY) : TER(tesSUCCESS); - env(pay(alice, carol, EUR(1)), - path(~XRP, ~EUR), - sendmax(USD(0.4)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(expectedTER)); + env(pay(alice, carol, eur(1)), + Path(~XRP, ~eur), + Sendmax(usd(0.4)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(expectedTER)); if (!reducedOffersV2) { - env.require(balance(carol, EUR(1))); - env.require(balance(bob, USD(0.4))); - env.require(balance(bob, EUR(999))); + env.require(Balance(carol, eur(1))); + env.require(Balance(bob, usd(0.4))); + env.require(Balance(bob, eur(999))); // Show that bob's USD offer is now a blocker. std::shared_ptr const usdOffer = env.le(bobUsdOffer); @@ -603,9 +603,9 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; + auto const eur = gw["EUR"]; Account const alice("alice"); Account const bob("bob"); Account const carol("carol"); @@ -616,10 +616,10 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, gw); env.close(); env(rate(gw, 1.25)); - env.trust(USD(1000), alice, bob); - env(offer(gw, XRP(125), USD(125))); - env(pay(alice, bob, USD(100)), sendmax(XRP(200))); - env.require(balance(alice, xrpMinusFee(env, 10000 - 125)), balance(bob, USD(100))); + env.trust(usd(1000), alice, bob); + env(offer(gw, XRP(125), usd(125))); + env(pay(alice, bob, usd(100)), Sendmax(XRP(200))); + env.require(Balance(alice, xrpMinusFee(env, 10000 - 125)), Balance(bob, usd(100))); } void @@ -630,8 +630,8 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; Account const alice("alice"); Account const bob("bob"); Account const carol("carol"); @@ -641,11 +641,11 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, carol, gw); env.fund(reserve(env, 5), bob); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); - env(pay(gw, alice, EUR(50))); - env(pay(gw, bob, USD(50))); + env(pay(gw, alice, eur(50))); + env(pay(gw, bob, usd(50))); // Bob has _just_ slightly less than 50 xrp available // If his owner count changes, he will have more liquidity. @@ -654,16 +654,16 @@ struct Flow_test : public beast::unit_test::suite // recursive calls to the EUR/XRP offer. The second call will return // tecPATH_DRY, but the entire path should not be marked as dry. This // is the second error case to test (when flowV1 is used). - env(offer(bob, EUR(50), XRP(50))); - env(offer(bob, XRP(50), USD(50))); + env(offer(bob, eur(50), XRP(50))); + env(offer(bob, XRP(50), usd(50))); - env(pay(alice, carol, USD(1000000)), - path(~XRP, ~USD), - sendmax(EUR(500)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice, carol, usd(1000000)), + Path(~XRP, ~usd), + Sendmax(eur(500)), + Txflags(tfNoRippleDirect | tfPartialPayment)); - auto const carolUSD = env.balance(carol, USD).value(); - BEAST_EXPECT(carolUSD > USD(0) && carolUSD < USD(50)); + auto const carolUSD = env.balance(carol, usd).value(); + BEAST_EXPECT(carolUSD > usd(0) && carolUSD < usd(50)); } void @@ -677,7 +677,7 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Account const alice("alice"); Account const bob("bob"); Account const carol("carol"); @@ -688,17 +688,17 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(100), alice, bob, carol); - env(pay(gw, bob, USD(100))); - env(offer(bob, XRP(50), USD(50))); - env(offer(bob, XRP(100), USD(50))); + env.trust(usd(100), alice, bob, carol); + env(pay(gw, bob, usd(100))); + env(offer(bob, XRP(50), usd(50))); + env(offer(bob, XRP(100), usd(50))); - env(pay(alice, carol, USD(100)), - path(~USD), - sendmax(XRP(100)), - txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); + env(pay(alice, carol, usd(100)), + Path(~usd), + Sendmax(XRP(100)), + Txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); - env.require(balance(carol, USD(50))); + env.require(Balance(carol, usd(50))); } } @@ -737,8 +737,8 @@ struct Flow_test : public beast::unit_test::suite auto const gw1 = Account("gw1"); auto const gw2 = Account("gw2"); auto const alice = Account("alice"); - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; Env env(*this, features); @@ -751,20 +751,20 @@ struct Flow_test : public beast::unit_test::suite env.fund(reserve(env, 3) + f * 4, alice); env.close(); - env(trust(alice, USD(2000))); - env(trust(alice, EUR(2000))); + env(trust(alice, usd(2000))); + env(trust(alice, eur(2000))); env.close(); - env(pay(gw1, alice, USD(1))); - env(pay(gw2, alice, EUR(1000))); + env(pay(gw1, alice, usd(1))); + env(pay(gw2, alice, eur(1000))); env.close(); - env(offer(alice, USD(500), EUR(600))); + env(offer(alice, usd(500), eur(600))); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(1))); - env.require(balance(alice, EUR(1000))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(1))); + env.require(Balance(alice, eur(1000))); auto aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); @@ -772,24 +772,24 @@ struct Flow_test : public beast::unit_test::suite { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } - env(pay(alice, alice, EUR(600)), sendmax(USD(500)), txflags(tfPartialPayment)); + env(pay(alice, alice, eur(600)), Sendmax(usd(500)), Txflags(tfPartialPayment)); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(1))); - env.require(balance(alice, EUR(1000))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(1))); + env.require(Balance(alice, eur(1000))); aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); for (auto const& offerPtr : aliceOffers) { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(598.8)); - BEAST_EXPECT(offer[sfTakerPays] == USD(499)); + BEAST_EXPECT(offer[sfTakerGets] == eur(598.8)); + BEAST_EXPECT(offer[sfTakerPays] == usd(499)); } } @@ -806,8 +806,8 @@ struct Flow_test : public beast::unit_test::suite auto const gw1 = Account("gw1"); auto const gw2 = Account("gw2"); auto const alice = Account("alice"); - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; Env env(*this, features); @@ -820,20 +820,20 @@ struct Flow_test : public beast::unit_test::suite env.fund(reserve(env, 3) + f * 4, alice); env.close(); - env(trust(alice, USD(506))); - env(trust(alice, EUR(606))); + env(trust(alice, usd(506))); + env(trust(alice, eur(606))); env.close(); - env(pay(gw1, alice, USD(500))); - env(pay(gw2, alice, EUR(600))); + env(pay(gw1, alice, usd(500))); + env(pay(gw2, alice, eur(600))); env.close(); - env(offer(alice, USD(500), EUR(600))); + env(offer(alice, usd(500), eur(600))); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(500))); - env.require(balance(alice, EUR(600))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(500))); + env.require(Balance(alice, eur(600))); auto aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); @@ -841,24 +841,24 @@ struct Flow_test : public beast::unit_test::suite { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } - env(pay(alice, alice, EUR(60)), sendmax(USD(50)), txflags(tfPartialPayment)); + env(pay(alice, alice, eur(60)), Sendmax(usd(50)), Txflags(tfPartialPayment)); env.close(); - env.require(owners(alice, 3)); - env.require(balance(alice, USD(500))); - env.require(balance(alice, EUR(600))); + env.require(Owners(alice, 3)); + env.require(Balance(alice, usd(500))); + env.require(Balance(alice, eur(600))); aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); for (auto const& offerPtr : aliceOffers) { auto const offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(594)); - BEAST_EXPECT(offer[sfTakerPays] == USD(495)); + BEAST_EXPECT(offer[sfTakerGets] == eur(594)); + BEAST_EXPECT(offer[sfTakerPays] == usd(495)); } } void @@ -877,21 +877,21 @@ struct Flow_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, gw); env.close(); - env(trust(alice, USD(20))); - env(pay(gw, alice, USD(10))); - env(offer(alice, XRP(50000), USD(10))); + env(trust(alice, usd(20))); + env(pay(gw, alice, usd(10))); + env(offer(alice, XRP(50000), usd(10))); // Consuming the offer changes the owner count, which could also cause // liquidity to decrease in the forward pass - auto const toSend = consumeOffer ? USD(10) : USD(9); + auto const toSend = consumeOffer ? usd(10) : usd(9); env(pay(alice, alice, toSend), - path(~USD), - sendmax(XRP(20000)), - txflags(tfPartialPayment | tfNoRippleDirect)); + Path(~usd), + Sendmax(XRP(20000)), + Txflags(tfPartialPayment | tfNoRippleDirect)); } void @@ -907,22 +907,22 @@ struct Flow_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000), alice, bob, gw); env.close(); - env(trust(bob, USD(20))); + env(trust(bob, usd(20))); - STAmount const tinyAmt1{USD, 9000000000000000ll, -17, false, STAmount::unchecked{}}; - STAmount const tinyAmt3{USD, 9000000000000003ll, -17, false, STAmount::unchecked{}}; + STAmount const tinyAmt1{usd, 9000000000000000ll, -17, false, STAmount::Unchecked{}}; + STAmount const tinyAmt3{usd, 9000000000000003ll, -17, false, STAmount::Unchecked{}}; env(offer(gw, drops(9000000000), tinyAmt3)); env(pay(alice, bob, tinyAmt1), - path(~USD), - sendmax(drops(9000000000)), - txflags(tfNoRippleDirect)); + Path(~usd), + Sendmax(drops(9000000000)), + Txflags(tfNoRippleDirect)); - BEAST_EXPECT(!isOffer(env, gw, XRP(0), USD(0))); + BEAST_EXPECT(!isOffer(env, gw, XRP(0), usd(0))); } { // Test forward @@ -931,24 +931,24 @@ struct Flow_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000), alice, bob, gw); env.close(); - env(trust(alice, USD(20))); + env(trust(alice, usd(20))); - STAmount const tinyAmt1{USD, 9000000000000000ll, -17, false, STAmount::unchecked{}}; - STAmount const tinyAmt3{USD, 9000000000000003ll, -17, false, STAmount::unchecked{}}; + STAmount const tinyAmt1{usd, 9000000000000000ll, -17, false, STAmount::Unchecked{}}; + STAmount const tinyAmt3{usd, 9000000000000003ll, -17, false, STAmount::Unchecked{}}; env(pay(gw, alice, tinyAmt1)); env(offer(gw, tinyAmt3, drops(9000000000))); env(pay(alice, bob, drops(9000000000)), - path(~XRP), - sendmax(USD(1)), - txflags(tfNoRippleDirect)); + Path(~XRP), + Sendmax(usd(1)), + Txflags(tfNoRippleDirect)); - BEAST_EXPECT(!isOffer(env, gw, USD(0), XRP(0))); + BEAST_EXPECT(!isOffer(env, gw, usd(0), XRP(0))); } } @@ -963,12 +963,12 @@ struct Flow_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; - auto const usdC = USD.currency; + auto const usd = gw["USD"]; + auto const usdC = usd.currency; env.fund(XRP(10000), alice, bob, gw); env.close(); - env(trust(alice, USD(100))); + env(trust(alice, usd(100))); env.close(); BEAST_EXPECT(!getNoRippleFlag(env, gw, alice, usdC)); @@ -977,36 +977,36 @@ struct Flow_test : public beast::unit_test::suite pay(gw, alice, // 12.55.... - STAmount{USD, std::uint64_t(1255555555555555ull), -14, false})); + STAmount{usd, std::uint64_t(1255555555555555ull), -14, false})); env(offer( gw, // 5.0... - STAmount{USD, std::uint64_t(5000000000000000ull), -15, false}, + STAmount{usd, std::uint64_t(5000000000000000ull), -15, false}, XRP(1000))); env(offer( gw, // .555... - STAmount{USD, std::uint64_t(5555555555555555ull), -16, false}, + STAmount{usd, std::uint64_t(5555555555555555ull), -16, false}, XRP(10))); env(offer( gw, // 4.44.... - STAmount{USD, std::uint64_t(4444444444444444ull), -15, false}, + STAmount{usd, std::uint64_t(4444444444444444ull), -15, false}, XRP(.1))); env(offer( alice, // 17 - STAmount{USD, std::uint64_t(1700000000000000ull), -14, false}, + STAmount{usd, std::uint64_t(1700000000000000ull), -14, false}, XRP(.001))); env(pay(alice, bob, XRP(10000)), - path(~XRP), - sendmax(USD(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + Path(~XRP), + Sendmax(usd(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); } void @@ -1037,10 +1037,10 @@ struct Flow_test : public beast::unit_test::suite env.close(); env(pay(alice, alice, XRP(1)), - path(gw, bob, ~XRP), - sendmax(gw["USD"](1000)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + Path(gw, bob, ~XRP), + Sendmax(gw["USD"](1000)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); env.trust(bob["USD"](10000), alice); @@ -1050,10 +1050,10 @@ struct Flow_test : public beast::unit_test::suite env.close(); env(pay(carol, carol, gw["USD"](1000)), - path(~bob["USD"], gw), - sendmax(XRP(100000)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + Path(~bob["USD"], gw), + Sendmax(XRP(100000)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); pass(); @@ -1075,28 +1075,28 @@ struct Flow_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000000), alice, bob, carol, gw); env.close(); - env.trust(USD(10000), alice, carol); - env(trust(bob, USD(10000), tfSetNoRipple)); - env.trust(USD(10000), bob); + env.trust(usd(10000), alice, carol); + env(trust(bob, usd(10000), tfSetNoRipple)); + env.trust(usd(10000), bob); env.trust(bob["USD"](10000), carol); env.close(); env(pay(bob, carol, bob["USD"](1000))); - env(pay(gw, bob, USD(1000))); + env(pay(gw, bob, usd(1000))); env.close(); env(offer(carol, XRP(1), bob["USD"](1000))); env.close(); - env(pay(alice, alice, USD(1000)), - path(~bob["USD"], bob, gw), - sendmax(XRP(1)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(alice, alice, usd(1000)), + Path(~bob["USD"], bob, gw), + Sendmax(XRP(1)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); } @@ -1114,7 +1114,7 @@ struct Flow_test : public beast::unit_test::suite auto const ann = Account("ann"); auto const gw = Account("gateway"); - auto const CTB = gw["CTB"]; + auto const ctb = gw["CTB"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 2) + drops(9999640) + fee, ann); @@ -1122,17 +1122,17 @@ struct Flow_test : public beast::unit_test::suite env.close(); env(rate(gw, 1.002)); - env(trust(ann, CTB(10))); + env(trust(ann, ctb(10))); env.close(); - env(pay(gw, ann, CTB(2.856))); + env(pay(gw, ann, ctb(2.856))); env.close(); - env(offer(ann, drops(365611702030), CTB(5.713))); + env(offer(ann, drops(365611702030), ctb(5.713))); env.close(); // This payment caused the assert. - env(pay(ann, ann, CTB(0.687)), sendmax(drops(20000000000)), txflags(tfPartialPayment)); + env(pay(ann, ann, ctb(0.687)), Sendmax(drops(20000000000)), Txflags(tfPartialPayment)); } void @@ -1148,7 +1148,7 @@ struct Flow_test : public beast::unit_test::suite env.fund(XRP(10000), alice); env.close(); - env(pay(alice, alice, alice["USD"](100)), path(~alice["USD"]), ter(temBAD_PATH)); + env(pay(alice, alice, alice["USD"](100)), Path(~alice["USD"]), Ter(temBAD_PATH)); } void @@ -1160,32 +1160,32 @@ struct Flow_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; { // Payment path starting with XRP - Env env(*this, testable_amendments()); + Env env(*this, testableAmendments()); env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); env.close(); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); - env(offer(alice, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(alice, USD(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), EUR(100)), txflags(tfPassive)); + env(offer(alice, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(alice, usd(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), eur(100)), Txflags(tfPassive)); env.close(); TER const expectedTer = TER{temBAD_PATH_LOOP}; - env(pay(alice, bob, EUR(1)), - path(~USD, ~XRP, ~EUR), - sendmax(XRP(1)), - txflags(tfNoRippleDirect), - ter(expectedTer)); + env(pay(alice, bob, eur(1)), + Path(~usd, ~XRP, ~eur), + Sendmax(XRP(1)), + Txflags(tfNoRippleDirect), + Ter(expectedTer)); pass(); } @@ -1194,49 +1194,49 @@ struct Flow_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); - env(offer(alice, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(alice, EUR(100), XRP(100)), txflags(tfPassive)); + env(offer(alice, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(alice, eur(100), XRP(100)), Txflags(tfPassive)); env.close(); // EUR -> //XRP -> //USD ->XRP env(pay(alice, bob, XRP(1)), - path(~XRP, ~USD, ~XRP), - sendmax(EUR(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + Path(~XRP, ~usd, ~XRP), + Sendmax(eur(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { // Payment where loop is formed in the middle of the path, not on an // endpoint - auto const JPY = gw["JPY"]; + auto const jpy = gw["JPY"]; Env env(*this); env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); - env.trust(JPY(1000), alice, bob); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); + env.trust(jpy(1000), alice, bob); env.close(); - env(pay(gw, alice, USD(100))); - env(pay(gw, alice, EUR(100))); - env(pay(gw, alice, JPY(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, alice, eur(100))); + env(pay(gw, alice, jpy(100))); env.close(); - env(offer(alice, USD(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), EUR(100)), txflags(tfPassive)); - env(offer(alice, EUR(100), XRP(100)), txflags(tfPassive)); - env(offer(alice, XRP(100), JPY(100)), txflags(tfPassive)); + env(offer(alice, usd(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), eur(100)), Txflags(tfPassive)); + env(offer(alice, eur(100), XRP(100)), Txflags(tfPassive)); + env(offer(alice, XRP(100), jpy(100)), Txflags(tfPassive)); env.close(); - env(pay(alice, bob, JPY(1)), - path(~XRP, ~EUR, ~XRP, ~JPY), - sendmax(USD(1)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, bob, jpy(1)), + Path(~XRP, ~eur, ~XRP, ~jpy), + Sendmax(usd(1)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } } @@ -1259,10 +1259,10 @@ struct Flow_test : public beast::unit_test::suite env(ticket::create(alice, 1)); // Make a payment using the ticket. - env(pay(alice, bob, XRP(1000)), ticket::use(ticketSeq)); + env(pay(alice, bob, XRP(1000)), ticket::Use(ticketSeq)); env.close(); - env.require(balance(bob, XRP(1000))); - env.require(balance(alice, XRP(9000) - (env.current()->fees().base * 2))); + env.require(Balance(bob, XRP(1000))); + env.require(Balance(alice, XRP(9000) - (env.current()->fees().base * 2))); } void @@ -1296,7 +1296,7 @@ struct Flow_test : public beast::unit_test::suite testRIPD1449(); using namespace jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeats(sa - featurePermissionedDEX); testWithFeats(sa); testEmptyStrand(sa); @@ -1309,7 +1309,7 @@ struct Flow_manual_test : public Flow_test run() override { using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); FeatureBitset const permDex{featurePermissionedDEX}; testWithFeats(all - permDex); diff --git a/src/test/app/Freeze_test.cpp b/src/test/app/Freeze_test.cpp index 29127ec8e1..26b7a1e70a 100644 --- a/src/test/app/Freeze_test.cpp +++ b/src/test/app/Freeze_test.cpp @@ -35,7 +35,7 @@ namespace xrpl { -class Freeze_test : public beast::unit_test::suite +class Freeze_test : public beast::unit_test::Suite { void testRippleState(FeatureBitset features) @@ -45,29 +45,29 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; + Account const g1{"G1"}; Account const alice{"alice"}; Account const bob{"bob"}; - env.fund(XRP(1000), G1, alice, bob); + env.fund(XRP(1000), g1, alice, bob); env.close(); - env.trust(G1["USD"](100), bob); - env.trust(G1["USD"](100), alice); + env.trust(g1["USD"](100), bob); + env.trust(g1["USD"](100), alice); env.close(); - env(pay(G1, bob, G1["USD"](10))); - env(pay(G1, alice, G1["USD"](100))); + env(pay(g1, bob, g1["USD"](10))); + env(pay(g1, alice, g1["USD"](100))); env.close(); - env(offer(alice, XRP(500), G1["USD"](100))); + env(offer(alice, XRP(500), g1["USD"](100))); env.close(); { auto lines = getAccountLines(env, bob); if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u))) return; - BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human()); + BEAST_EXPECT(lines[jss::lines][0u][jss::account] == g1.human()); BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "100"); BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "10"); } @@ -76,7 +76,7 @@ class Freeze_test : public beast::unit_test::suite auto lines = getAccountLines(env, alice); if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u))) return; - BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human()); + BEAST_EXPECT(lines[jss::lines][0u][jss::account] == g1.human()); BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "100"); BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "100"); } @@ -84,23 +84,23 @@ class Freeze_test : public beast::unit_test::suite { // Account with line unfrozen (proving operations normally work) // test: can make Payment on that line - env(pay(alice, bob, G1["USD"](1))); + env(pay(alice, bob, g1["USD"](1))); // test: can receive Payment on that line - env(pay(bob, alice, G1["USD"](1))); + env(pay(bob, alice, g1["USD"](1))); env.close(); } { // Is created via a TrustSet with SetFreeze flag // test: sets LowFreeze | HighFreeze flags - env(trust(G1, bob["USD"](0), tfSetFreeze)); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, bob["USD"](0), tfSetFreeze)); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 2u))) return; auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; BEAST_EXPECT( - ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none)); + ff[sfLowLimit.fieldName] == g1["USD"](0).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze)); env.close(); @@ -109,35 +109,35 @@ class Freeze_test : public beast::unit_test::suite { // Account with line frozen by issuer // test: can buy more assets on that line - env(offer(bob, G1["USD"](5), XRP(25))); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(offer(bob, g1["USD"](5), XRP(25))); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 5u))) return; auto ff = affected[3u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; BEAST_EXPECT( - ff[sfHighLimit.fieldName] == bob["USD"](100).value().getJson(JsonOptions::none)); - auto amt = STAmount{Issue{to_currency("USD"), noAccount()}, -15}.value().getJson( - JsonOptions::none); + ff[sfHighLimit.fieldName] == bob["USD"](100).value().getJson(JsonOptions::KNone)); + auto amt = STAmount{Issue{toCurrency("USD"), noAccount()}, -15}.value().getJson( + JsonOptions::KNone); BEAST_EXPECT(ff[sfBalance.fieldName] == amt); env.close(); } { // test: can not sell assets from that line - env(offer(bob, XRP(1), G1["USD"](5)), ter(tecUNFUNDED_OFFER)); + env(offer(bob, XRP(1), g1["USD"](5)), Ter(tecUNFUNDED_OFFER)); // test: can receive Payment on that line - env(pay(alice, bob, G1["USD"](1))); + env(pay(alice, bob, g1["USD"](1))); // test: can not make Payment from that line - env(pay(bob, alice, G1["USD"](1)), ter(tecPATH_DRY)); + env(pay(bob, alice, g1["USD"](1)), Ter(tecPATH_DRY)); } { // check G1 account lines // test: shows freeze - auto lines = getAccountLines(env, G1); - Json::Value bobLine; + auto lines = getAccountLines(env, g1); + json::Value bobLine; for (auto const& it : lines[jss::lines]) { if (it[jss::account] == bob.human()) @@ -155,10 +155,10 @@ class Freeze_test : public beast::unit_test::suite { // test: shows freeze peer auto lines = getAccountLines(env, bob); - Json::Value g1Line; + json::Value g1Line; for (auto const& it : lines[jss::lines]) { - if (it[jss::account] == G1.human()) + if (it[jss::account] == g1.human()) { g1Line = it; break; @@ -173,13 +173,13 @@ class Freeze_test : public beast::unit_test::suite { // Is cleared via a TrustSet with ClearFreeze flag // test: sets LowFreeze | HighFreeze flags - env(trust(G1, bob["USD"](0), tfClearFreeze)); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, bob["USD"](0), tfClearFreeze)); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 2u))) return; auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; BEAST_EXPECT( - ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none)); + ff[sfLowLimit.fieldName] == g1["USD"](0).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze)); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze)); env.close(); @@ -194,20 +194,20 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; + Account const g1{"G1"}; + Account const a1{"A1"}; - env.fund(XRP(10000), G1, A1); + env.fund(XRP(10000), g1, a1); env.close(); - env.trust(G1["USD"](1000), A1); + env.trust(g1["USD"](1000), a1); env.close(); if (features[featureDeepFreeze]) { // test: Issuer deep freezing the trust line in a single // transaction - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfLowFreeze); @@ -218,7 +218,7 @@ class Freeze_test : public beast::unit_test::suite // test: Issuer clearing deep freeze and normal freeze in a single // transaction - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(!(flags & (lsfLowFreeze | lsfLowDeepFreeze))); @@ -227,13 +227,13 @@ class Freeze_test : public beast::unit_test::suite } // test: Issuer deep freezing not already frozen line must fail - env(trust(G1, A1["USD"](0), tfSetDeepFreeze), ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze), Ter(tecNO_PERMISSION)); - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: Issuer deep freezing already frozen trust line - env(trust(G1, A1["USD"](0), tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfLowFreeze); @@ -244,7 +244,7 @@ class Freeze_test : public beast::unit_test::suite // test: Holder clearing freeze flags has no effect. Each sides' // flags are independent - env(trust(A1, G1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(a1, g1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfLowFreeze); @@ -254,11 +254,11 @@ class Freeze_test : public beast::unit_test::suite } // test: Issuer can't clear normal freeze when line is deep frozen - env(trust(G1, A1["USD"](0), tfClearFreeze), ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfClearFreeze), Ter(tecNO_PERMISSION)); // test: Issuer clearing deep freeze but normal freeze is still in // effect - env(trust(G1, A1["USD"](0), tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfLowFreeze); @@ -270,10 +270,10 @@ class Freeze_test : public beast::unit_test::suite else { // test: applying deep freeze before amendment fails - env(trust(G1, A1["USD"](0), tfSetDeepFreeze), ter(temINVALID_FLAG)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze), Ter(temINVALID_FLAG)); // test: clearing deep freeze before amendment fails - env(trust(G1, A1["USD"](0), tfClearDeepFreeze), ter(temINVALID_FLAG)); + env(trust(g1, a1["USD"](0), tfClearDeepFreeze), Ter(temINVALID_FLAG)); } } @@ -285,44 +285,44 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; + Account const g1{"G1"}; + Account const a1{"A1"}; - env.fund(XRP(10000), G1, A1); + env.fund(XRP(10000), g1, a1); env.close(); // test: can create frozen trustline { - env(trust(G1, A1["USD"](1000), tfSetFreeze)); + env(trust(g1, a1["USD"](1000), tfSetFreeze)); auto const flags = getTrustlineFlags(env, 5u, 3u, false); BEAST_EXPECT(flags & lsfLowFreeze); env.close(); - env.require(lines(A1, 1)); + env.require(lines(a1, 1)); } // Cleanup - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); - env.require(lines(G1, 0)); - env.require(lines(A1, 0)); + env.require(lines(g1, 0)); + env.require(lines(a1, 0)); // test: cannot create deep frozen trustline without normal freeze if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](1000), tfSetDeepFreeze), ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](1000), tfSetDeepFreeze), Ter(tecNO_PERMISSION)); env.close(); - env.require(lines(A1, 0)); + env.require(lines(a1, 0)); } // test: can create deep frozen trustline together with normal freeze if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); auto const flags = getTrustlineFlags(env, 5u, 3u, false); BEAST_EXPECT(flags & lsfLowFreeze); BEAST_EXPECT(flags & lsfLowDeepFreeze); env.close(); - env.require(lines(A1, 1)); + env.require(lines(a1, 1)); } } @@ -334,32 +334,32 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; + Account const g1{"G1"}; + Account const a1{"A1"}; - env.fund(XRP(10000), G1, A1); + env.fund(XRP(10000), g1, a1); env.close(); - env.trust(G1["USD"](1000), A1); + env.trust(g1["USD"](1000), a1); env.close(); if (features[featureDeepFreeze]) { // test: can't have both set and clear flag families in the same // transaction - env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearFreeze), ter(tecNO_PERMISSION)); - env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearDeepFreeze), ter(tecNO_PERMISSION)); - env(trust(G1, A1["USD"](0), tfSetDeepFreeze | tfClearFreeze), ter(tecNO_PERMISSION)); - env(trust(G1, A1["USD"](0), tfSetDeepFreeze | tfClearDeepFreeze), - ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfClearFreeze), Ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfClearDeepFreeze), Ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze | tfClearFreeze), Ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze | tfClearDeepFreeze), + Ter(tecNO_PERMISSION)); } else { // test: old behavior, transaction succeed with no effect on a // trust line - env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfClearFreeze)); { - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; BEAST_EXPECT(checkArraySize(affected, 1u)); // means no trustline changes } } @@ -373,54 +373,54 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; - env.fund(XRP(12000), G1); - env.fund(XRP(1000), A1); - env.fund(XRP(20000), A2, A3, A4); + env.fund(XRP(12000), g1); + env.fund(XRP(1000), a1); + env.fund(XRP(20000), a2, a3, a4); env.close(); - env.trust(G1["USD"](1200), A1); - env.trust(G1["USD"](200), A2); - env.trust(G1["BTC"](100), A3); - env.trust(G1["BTC"](100), A4); + env.trust(g1["USD"](1200), a1); + env.trust(g1["USD"](200), a2); + env.trust(g1["BTC"](100), a3); + env.trust(g1["BTC"](100), a4); env.close(); - env(pay(G1, A1, G1["USD"](1000))); - env(pay(G1, A2, G1["USD"](100))); - env(pay(G1, A3, G1["BTC"](100))); - env(pay(G1, A4, G1["BTC"](100))); + env(pay(g1, a1, g1["USD"](1000))); + env(pay(g1, a2, g1["USD"](100))); + env(pay(g1, a3, g1["BTC"](100))); + env(pay(g1, a4, g1["BTC"](100))); env.close(); - env(offer(G1, XRP(10000), G1["USD"](100)), txflags(tfPassive)); - env(offer(G1, G1["USD"](100), XRP(10000)), txflags(tfPassive)); - env(offer(A1, XRP(10000), G1["USD"](100)), txflags(tfPassive)); - env(offer(A2, G1["USD"](100), XRP(10000)), txflags(tfPassive)); + env(offer(g1, XRP(10000), g1["USD"](100)), Txflags(tfPassive)); + env(offer(g1, g1["USD"](100), XRP(10000)), Txflags(tfPassive)); + env(offer(a1, XRP(10000), g1["USD"](100)), Txflags(tfPassive)); + env(offer(a2, g1["USD"](100), XRP(10000)), Txflags(tfPassive)); env.close(); { // Is toggled via AccountSet using SetFlag and ClearFlag // test: SetFlag GlobalFreeze - env.require(nflags(G1, asfGlobalFreeze)); - env(fset(G1, asfGlobalFreeze)); - env.require(flags(G1, asfGlobalFreeze)); - env.require(nflags(G1, asfNoFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); + env(fset(g1, asfGlobalFreeze)); + env.require(Flags(g1, asfGlobalFreeze)); + env.require(Nflags(g1, asfNoFreeze)); // test: ClearFlag GlobalFreeze - env(fclear(G1, asfGlobalFreeze)); - env.require(nflags(G1, asfGlobalFreeze)); - env.require(nflags(G1, asfNoFreeze)); + env(fclear(g1, asfGlobalFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); + env.require(Nflags(g1, asfNoFreeze)); } { // Account without GlobalFreeze (proving operations normally work) // test: visible offers where taker_pays is unfrozen issuer auto offers = env.rpc( - "book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers]; + "book_offers", std::string("USD/") + g1.human(), "XRP")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; std::set accounts; @@ -428,12 +428,12 @@ class Freeze_test : public beast::unit_test::suite { accounts.insert(offer[jss::Account].asString()); } - BEAST_EXPECT(accounts.find(A2.human()) != std::end(accounts)); - BEAST_EXPECT(accounts.find(G1.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(a2.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(g1.human()) != std::end(accounts)); // test: visible offers where taker_gets is unfrozen issuer offers = env.rpc( - "book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers]; + "book_offers", "XRP", std::string("USD/") + g1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; accounts.clear(); @@ -441,63 +441,63 @@ class Freeze_test : public beast::unit_test::suite { accounts.insert(offer[jss::Account].asString()); } - BEAST_EXPECT(accounts.find(A1.human()) != std::end(accounts)); - BEAST_EXPECT(accounts.find(G1.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(a1.human()) != std::end(accounts)); + BEAST_EXPECT(accounts.find(g1.human()) != std::end(accounts)); } { // Offers/Payments // test: assets can be bought on the market - env(offer(A3, G1["BTC"](1), XRP(1))); + env(offer(a3, g1["BTC"](1), XRP(1))); // test: assets can be sold on the market - env(offer(A4, XRP(1), G1["BTC"](1))); + env(offer(a4, XRP(1), g1["BTC"](1))); // test: direct issues can be sent - env(pay(G1, A2, G1["USD"](1))); + env(pay(g1, a2, g1["USD"](1))); // test: direct redemptions can be sent - env(pay(A2, G1, G1["USD"](1))); + env(pay(a2, g1, g1["USD"](1))); // test: via rippling can be sent - env(pay(A2, A1, G1["USD"](1))); + env(pay(a2, a1, g1["USD"](1))); // test: via rippling can be sent back - env(pay(A1, A2, G1["USD"](1))); + env(pay(a1, a2, g1["USD"](1))); } { // Account with GlobalFreeze // set GlobalFreeze first // test: SetFlag GlobalFreeze will toggle back to freeze - env.require(nflags(G1, asfGlobalFreeze)); - env(fset(G1, asfGlobalFreeze)); - env.require(flags(G1, asfGlobalFreeze)); - env.require(nflags(G1, asfNoFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); + env(fset(g1, asfGlobalFreeze)); + env.require(Flags(g1, asfGlobalFreeze)); + env.require(Nflags(g1, asfNoFreeze)); // test: assets can't be bought on the market - env(offer(A3, G1["BTC"](1), XRP(1)), ter(tecFROZEN)); + env(offer(a3, g1["BTC"](1), XRP(1)), Ter(tecFROZEN)); // test: assets can't be sold on the market - env(offer(A4, XRP(1), G1["BTC"](1)), ter(tecFROZEN)); + env(offer(a4, XRP(1), g1["BTC"](1)), Ter(tecFROZEN)); } { // offers are filtered (seems to be broken?) // test: account_offers always shows own offers - auto offers = getAccountOffers(env, G1)[jss::offers]; + auto offers = getAccountOffers(env, g1)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; // test: book_offers shows offers // (should these actually be filtered?) offers = env.rpc( - "book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers]; + "book_offers", "XRP", std::string("USD/") + g1.human())[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; offers = env.rpc( - "book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers]; + "book_offers", std::string("USD/") + g1.human(), "XRP")[jss::result][jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 2u))) return; } @@ -505,13 +505,13 @@ class Freeze_test : public beast::unit_test::suite { // Payments // test: direct issues can be sent - env(pay(G1, A2, G1["USD"](1))); + env(pay(g1, a2, g1["USD"](1))); // test: direct redemptions can be sent - env(pay(A2, G1, G1["USD"](1))); + env(pay(a2, g1, g1["USD"](1))); // test: via rippling cant be sent - env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY)); + env(pay(a2, a1, g1["USD"](1)), Ter(tecPATH_DRY)); } } @@ -523,29 +523,29 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; + Account const g1{"G1"}; + Account const a1{"A1"}; Account const frozenAcc{"A2"}; Account const deepFrozenAcc{"A3"}; - env.fund(XRP(12000), G1); - env.fund(XRP(1000), A1); + env.fund(XRP(12000), g1); + env.fund(XRP(1000), a1); env.fund(XRP(1000), frozenAcc); env.fund(XRP(1000), deepFrozenAcc); env.close(); - env.trust(G1["USD"](1000), A1); - env.trust(G1["USD"](1000), frozenAcc); - env.trust(G1["USD"](1000), deepFrozenAcc); + env.trust(g1["USD"](1000), a1); + env.trust(g1["USD"](1000), frozenAcc); + env.trust(g1["USD"](1000), deepFrozenAcc); env.close(); - env(pay(G1, A1, G1["USD"](1000))); - env(pay(G1, frozenAcc, G1["USD"](1000))); - env(pay(G1, deepFrozenAcc, G1["USD"](1000))); + env(pay(g1, a1, g1["USD"](1000))); + env(pay(g1, frozenAcc, g1["USD"](1000))); + env(pay(g1, deepFrozenAcc, g1["USD"](1000))); // Freezing and deep freezing some of the trust lines to check deep // freeze and clearing of freeze separately - env(trust(G1, frozenAcc["USD"](0), tfSetFreeze)); + env(trust(g1, frozenAcc["USD"](0), tfSetFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfLowFreeze); @@ -553,7 +553,7 @@ class Freeze_test : public beast::unit_test::suite } if (features[featureDeepFreeze]) { - env(trust(G1, deepFrozenAcc["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, deepFrozenAcc["USD"](0), tfSetFreeze | tfSetDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(!(flags & (lsfLowFreeze | lsfLowDeepFreeze))); @@ -565,41 +565,41 @@ class Freeze_test : public beast::unit_test::suite // TrustSet NoFreeze // test: should set NoFreeze in Flags - env.require(nflags(G1, asfNoFreeze)); - env(fset(G1, asfNoFreeze)); - env.require(flags(G1, asfNoFreeze)); - env.require(nflags(G1, asfGlobalFreeze)); + env.require(Nflags(g1, asfNoFreeze)); + env(fset(g1, asfNoFreeze)); + env.require(Flags(g1, asfNoFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); // test: cannot be cleared - env(fclear(G1, asfNoFreeze)); - env.require(flags(G1, asfNoFreeze)); - env.require(nflags(G1, asfGlobalFreeze)); + env(fclear(g1, asfNoFreeze)); + env.require(Flags(g1, asfNoFreeze)); + env.require(Nflags(g1, asfGlobalFreeze)); // test: can set GlobalFreeze - env(fset(G1, asfGlobalFreeze)); - env.require(flags(G1, asfNoFreeze)); - env.require(flags(G1, asfGlobalFreeze)); + env(fset(g1, asfGlobalFreeze)); + env.require(Flags(g1, asfNoFreeze)); + env.require(Flags(g1, asfGlobalFreeze)); // test: cannot unset GlobalFreeze - env(fclear(G1, asfGlobalFreeze)); - env.require(flags(G1, asfNoFreeze)); - env.require(flags(G1, asfGlobalFreeze)); + env(fclear(g1, asfGlobalFreeze)); + env.require(Flags(g1, asfNoFreeze)); + env.require(Flags(g1, asfGlobalFreeze)); // test: trustlines can't be frozen when no freeze enacted if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](0), tfSetFreeze), ter(tecNO_PERMISSION)); + env(trust(g1, a1["USD"](0), tfSetFreeze), Ter(tecNO_PERMISSION)); // test: cannot deep freeze already frozen line when no freeze // enacted - env(trust(G1, frozenAcc["USD"](0), tfSetDeepFreeze), ter(tecNO_PERMISSION)); + env(trust(g1, frozenAcc["USD"](0), tfSetDeepFreeze), Ter(tecNO_PERMISSION)); } else { // test: previous functionality, checking there's no changes to a // trust line - env(trust(G1, A1["USD"](0), tfSetFreeze)); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, a1["USD"](0), tfSetFreeze)); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 1u))) return; @@ -608,7 +608,7 @@ class Freeze_test : public beast::unit_test::suite } // test: can clear freeze on account - env(trust(G1, frozenAcc["USD"](0), tfClearFreeze)); + env(trust(g1, frozenAcc["USD"](0), tfClearFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(!(flags & lsfLowFreeze)); @@ -617,7 +617,7 @@ class Freeze_test : public beast::unit_test::suite if (features[featureDeepFreeze]) { // test: can clear deep freeze on account - env(trust(G1, deepFrozenAcc["USD"](0), tfClearDeepFreeze)); + env(trust(g1, deepFrozenAcc["USD"](0), tfClearDeepFreeze)); { auto const flags = getTrustlineFlags(env, 2u, 1u); BEAST_EXPECT(flags & lsfHighFreeze); @@ -634,91 +634,91 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; + Account const g1{"G1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; - env.fund(XRP(1000), G1, A3, A4); - env.fund(XRP(2000), A2); + env.fund(XRP(1000), g1, a3, a4); + env.fund(XRP(2000), a2); env.close(); - env.trust(G1["USD"](1000), A2); - env.trust(G1["USD"](2000), A3); - env.trust(G1["USD"](2000), A4); + env.trust(g1["USD"](1000), a2); + env.trust(g1["USD"](2000), a3); + env.trust(g1["USD"](2000), a4); env.close(); - env(pay(G1, A3, G1["USD"](2000))); - env(pay(G1, A4, G1["USD"](2000))); + env(pay(g1, a3, g1["USD"](2000))); + env(pay(g1, a4, g1["USD"](2000))); env.close(); - env(offer(A3, XRP(1000), G1["USD"](1000)), txflags(tfPassive)); + env(offer(a3, XRP(1000), g1["USD"](1000)), Txflags(tfPassive)); env.close(); // removal after successful payment // test: make a payment with partially consuming offer - env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1))); + env(pay(a2, g1, g1["USD"](1)), Paths(g1["USD"]), Sendmax(XRP(1))); env.close(); // test: offer was only partially consumed - auto offers = getAccountOffers(env, A3)[jss::offers]; + auto offers = getAccountOffers(env, a3)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; BEAST_EXPECT( - offers[0u][jss::taker_gets] == G1["USD"](999).value().getJson(JsonOptions::none)); + offers[0u][jss::taker_gets] == g1["USD"](999).value().getJson(JsonOptions::KNone)); // test: someone else creates an offer providing liquidity - env(offer(A4, XRP(999), G1["USD"](999))); + env(offer(a4, XRP(999), g1["USD"](999))); env.close(); // test: owner of partially consumed offers line is frozen - env(trust(G1, A3["USD"](0), tfSetFreeze)); - auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, a3["USD"](0), tfSetFreeze)); + auto affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 2u))) return; auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; - BEAST_EXPECT(ff[sfHighLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none)); + BEAST_EXPECT(ff[sfHighLimit.fieldName] == g1["USD"](0).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze)); BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfHighFreeze); env.close(); // verify offer on the books - offers = getAccountOffers(env, A3)[jss::offers]; + offers = getAccountOffers(env, a3)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 1u))) return; // test: Can make a payment via the new offer - env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1))); + env(pay(a2, g1, g1["USD"](1)), Paths(g1["USD"]), Sendmax(XRP(1))); env.close(); // test: Partially consumed offer was removed by tes* payment - offers = getAccountOffers(env, A3)[jss::offers]; + offers = getAccountOffers(env, a3)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 0u))) return; // removal buy successful OfferCreate // test: freeze the new offer - env(trust(G1, A4["USD"](0), tfSetFreeze)); - affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(trust(g1, a4["USD"](0), tfSetFreeze)); + affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 2u))) return; ff = affected[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; - BEAST_EXPECT(ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none)); + BEAST_EXPECT(ff[sfLowLimit.fieldName] == g1["USD"](0).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze); BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze)); env.close(); // test: can no longer create a crossing offer - env(offer(A2, G1["USD"](999), XRP(999))); - affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + env(offer(a2, g1["USD"](999), XRP(999))); + affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, 8u))) return; auto created = affected[0u][sfCreatedNode.fieldName]; - BEAST_EXPECT(created[sfNewFields.fieldName][jss::Account] == A2.human()); + BEAST_EXPECT(created[sfNewFields.fieldName][jss::Account] == a2.human()); env.close(); // test: offer was removed by offer_create - offers = getAccountOffers(env, A4)[jss::offers]; + offers = getAccountOffers(env, a4)[jss::offers]; if (!BEAST_EXPECT(checkArraySize(offers, 0u))) return; } @@ -731,74 +731,74 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2, A3); + env.fund(XRP(10000), g1, a1, a2, a3); env.close(); - auto const limit = USD(10000); - env.trust(limit, A1, A2, A3); + auto const limit = usd(10000); + env.trust(limit, a1, a2, a3); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); // Making large passive sell offer // Wants to sell 50 USD for 100 XRP - env(offer(A2, XRP(100), USD(50)), txflags(tfPassive)); + env(offer(a2, XRP(100), usd(50)), Txflags(tfPassive)); env.close(); // Making large passive buy offer // Wants to buy 100 USD for 100 XRP - env(offer(A3, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(a3, usd(100), XRP(100)), Txflags(tfPassive)); env.close(); - env.require(offers(A2, 1), offers(A3, 1)); + env.require(offers(a2, 1), offers(a3, 1)); // Checking A1 can buy from A2 by crossing it's offer - env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill)); + env(offer(a1, usd(1), XRP(2)), Txflags(tfFillOrKill)); env.close(); - env.require(balance(A1, USD(1001)), balance(A2, USD(999))); + env.require(Balance(a1, usd(1001)), Balance(a2, usd(999))); // Checking A1 can sell to A3 by crossing it's offer - env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill)); + env(offer(a1, XRP(1), usd(1)), Txflags(tfFillOrKill)); env.close(); - env.require(balance(A1, USD(1000)), balance(A3, USD(1))); + env.require(Balance(a1, usd(1000)), Balance(a3, usd(1))); // Testing aggressive and passive offer placing, trustline frozen by // the issuer { - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: can still make passive buy offer - env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive)); + env(offer(a1, usd(1), XRP(0.5)), Txflags(tfPassive)); env.close(); - env.require(balance(A1, USD(1000)), offers(A1, 1)); + env.require(Balance(a1, usd(1000)), offers(a1, 1)); // Cleanup - env(offer_cancel(A1, env.seq(A1) - 1)); - env.require(offers(A1, 0)); + env(offerCancel(a1, env.seq(a1) - 1)); + env.require(offers(a1, 0)); env.close(); // test: can still buy from A2 - env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill)); + env(offer(a1, usd(1), XRP(2)), Txflags(tfFillOrKill)); env.close(); - env.require(balance(A1, USD(1001)), balance(A2, USD(998)), offers(A1, 0)); + env.require(Balance(a1, usd(1001)), Balance(a2, usd(998)), offers(a1, 0)); // test: cannot create passive sell offer - env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(2), usd(1)), Txflags(tfPassive), Ter(tecUNFUNDED_OFFER)); env.close(); - env.require(balance(A1, USD(1001)), offers(A1, 0)); + env.require(Balance(a1, usd(1001)), offers(a1, 0)); // test: cannot sell to A3 - env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(1), usd(1)), Txflags(tfFillOrKill), Ter(tecUNFUNDED_OFFER)); env.close(); - env.require(balance(A1, USD(1001)), offers(A1, 0)); + env.require(Balance(a1, usd(1001)), offers(a1, 0)); - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); } @@ -806,55 +806,55 @@ class Freeze_test : public beast::unit_test::suite // by the issuer if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: cannot create passive buy offer - env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive), ter(tecFROZEN)); + env(offer(a1, usd(1), XRP(0.5)), Txflags(tfPassive), Ter(tecFROZEN)); env.close(); // test: cannot buy from A2 - env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecFROZEN)); + env(offer(a1, usd(1), XRP(2)), Txflags(tfFillOrKill), Ter(tecFROZEN)); env.close(); // test: cannot create passive sell offer - env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(2), usd(1)), Txflags(tfPassive), Ter(tecUNFUNDED_OFFER)); env.close(); // test: cannot sell to A3 - env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(1), usd(1)), Txflags(tfFillOrKill), Ter(tecUNFUNDED_OFFER)); env.close(); - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); - env.require(balance(A1, USD(1001)), offers(A1, 0)); + env.require(Balance(a1, usd(1001)), offers(a1, 0)); } // Testing already existing offers behavior after trustline is frozen by // the issuer { - env.require(balance(A1, USD(1001))); - env(offer(A1, XRP(1.9), USD(1))); - env(offer(A1, USD(1), XRP(1.1))); + env.require(Balance(a1, usd(1001))); + env(offer(a1, XRP(1.9), usd(1))); + env(offer(a1, usd(1), XRP(1.1))); env.close(); - env.require(balance(A1, USD(1001)), offers(A1, 2)); + env.require(Balance(a1, usd(1001)), offers(a1, 2)); - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: A2 wants to sell to A1, must succeed - env.require(balance(A1, USD(1001)), balance(A2, USD(998))); - env(offer(A2, XRP(1.1), USD(1)), txflags(tfFillOrKill)); + env.require(Balance(a1, usd(1001)), Balance(a2, usd(998))); + env(offer(a2, XRP(1.1), usd(1)), Txflags(tfFillOrKill)); env.close(); - env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 1)); + env.require(Balance(a1, usd(1002)), Balance(a2, usd(997)), offers(a1, 1)); // test: A3 wants to buy from A1, must fail - env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 1)); - env(offer(A3, USD(1), XRP(1.9)), txflags(tfFillOrKill), ter(tecKILLED)); + env.require(Balance(a1, usd(1002)), Balance(a3, usd(1)), offers(a1, 1)); + env(offer(a3, usd(1), XRP(1.9)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 0)); + env.require(Balance(a1, usd(1002)), Balance(a3, usd(1)), offers(a1, 0)); - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); } @@ -862,66 +862,66 @@ class Freeze_test : public beast::unit_test::suite // the issuer if (features[featureDeepFreeze]) { - env.require(balance(A1, USD(1002))); - env(offer(A1, XRP(1.9), USD(1))); - env(offer(A1, USD(1), XRP(1.1))); + env.require(Balance(a1, usd(1002))); + env(offer(a1, XRP(1.9), usd(1))); + env(offer(a1, usd(1), XRP(1.1))); env.close(); - env.require(balance(A1, USD(1002)), offers(A1, 2)); + env.require(Balance(a1, usd(1002)), offers(a1, 2)); - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A2 wants to sell to A1, must fail - env.require(balance(A1, USD(1002)), balance(A2, USD(997))); - env(offer(A2, XRP(1.1), USD(1)), txflags(tfFillOrKill), ter(tecKILLED)); + env.require(Balance(a1, usd(1002)), Balance(a2, usd(997))); + env(offer(a2, XRP(1.1), usd(1)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 1)); + env.require(Balance(a1, usd(1002)), Balance(a2, usd(997)), offers(a1, 1)); // test: A3 wants to buy from A1, must fail - env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 1)); - env(offer(A3, USD(1), XRP(1.9)), txflags(tfFillOrKill), ter(tecKILLED)); + env.require(Balance(a1, usd(1002)), Balance(a3, usd(1)), offers(a1, 1)); + env(offer(a3, usd(1), XRP(1.9)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 0)); + env.require(Balance(a1, usd(1002)), Balance(a3, usd(1)), offers(a1, 0)); - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing aggressive and passive offer placing, trustline frozen by // the holder { - env(trust(A1, limit, tfSetFreeze)); + env(trust(a1, limit, tfSetFreeze)); env.close(); // test: A1 can make passive buy offer - env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive)); + env(offer(a1, usd(1), XRP(0.5)), Txflags(tfPassive)); env.close(); - env.require(balance(A1, USD(1002)), offers(A1, 1)); + env.require(Balance(a1, usd(1002)), offers(a1, 1)); // Cleanup - env(offer_cancel(A1, env.seq(A1) - 1)); - env.require(offers(A1, 0)); + env(offerCancel(a1, env.seq(a1) - 1)); + env.require(offers(a1, 0)); env.close(); // test: A1 wants to buy, must fail - env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecKILLED)); + env(offer(a1, usd(1), XRP(2)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 0)); + env.require(Balance(a1, usd(1002)), Balance(a2, usd(997)), offers(a1, 0)); // test: A1 can create passive sell offer - env(offer(A1, XRP(2), USD(1)), txflags(tfPassive)); + env(offer(a1, XRP(2), usd(1)), Txflags(tfPassive)); env.close(); - env.require(balance(A1, USD(1002)), offers(A1, 1)); + env.require(Balance(a1, usd(1002)), offers(a1, 1)); // Cleanup - env(offer_cancel(A1, env.seq(A1) - 1)); - env.require(offers(A1, 0)); + env(offerCancel(a1, env.seq(a1) - 1)); + env.require(offers(a1, 0)); env.close(); // test: A1 can sell to A3 - env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill)); + env(offer(a1, XRP(1), usd(1)), Txflags(tfFillOrKill)); env.close(); - env.require(balance(A1, USD(1001)), offers(A1, 0)); + env.require(Balance(a1, usd(1001)), offers(a1, 0)); - env(trust(A1, limit, tfClearFreeze)); + env(trust(a1, limit, tfClearFreeze)); env.close(); } @@ -929,26 +929,26 @@ class Freeze_test : public beast::unit_test::suite // by the holder if (features[featureDeepFreeze]) { - env(trust(A1, limit, tfSetFreeze | tfSetDeepFreeze)); + env(trust(a1, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A1 cannot create passive buy offer - env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive), ter(tecFROZEN)); + env(offer(a1, usd(1), XRP(0.5)), Txflags(tfPassive), Ter(tecFROZEN)); env.close(); // test: A1 cannot buy, must fail - env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecFROZEN)); + env(offer(a1, usd(1), XRP(2)), Txflags(tfFillOrKill), Ter(tecFROZEN)); env.close(); // test: A1 cannot create passive sell offer - env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(2), usd(1)), Txflags(tfPassive), Ter(tecUNFUNDED_OFFER)); env.close(); // test: A1 cannot sell to A3 - env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER)); + env(offer(a1, XRP(1), usd(1)), Txflags(tfFillOrKill), Ter(tecUNFUNDED_OFFER)); env.close(); - env(trust(A1, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a1, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } } @@ -958,94 +958,93 @@ class Freeze_test : public beast::unit_test::suite { testcase("Longer paths payment on frozen trust lines"); using namespace test::jtx; - using path = test::jtx::path; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); + env.fund(XRP(10000), g1, a1, a2); env.close(); - auto const limit = USD(10000); - env.trust(limit, A1, A2); + auto const limit = usd(10000); + env.trust(limit, a1, a2); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); - env(offer(A2, XRP(100), USD(100)), txflags(tfPassive)); + env(offer(a2, XRP(100), usd(100)), Txflags(tfPassive)); env.close(); // Testing payments A1 <-> G1 using offer from A2 frozen by issuer. { - env(trust(G1, A2["USD"](0), tfSetFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze)); env.close(); // test: A1 cannot send USD using XRP through A2 offer - env(pay(A1, G1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(a1, g1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); // test: G1 cannot send USD using XRP through A2 offer - env(pay(G1, A1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(g1, a1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze)); env.close(); } // Testing payments A1 <-> G1 using offer from A2 deep frozen by issuer. if (features[featureDeepFreeze]) { - env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A1 cannot send USD using XRP through A2 offer - env(pay(A1, G1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(a1, g1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); // test: G1 cannot send USD using XRP through A2 offer - env(pay(G1, A1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(g1, a1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing payments A1 <-> G1 using offer from A2 frozen by currency // holder. { - env(trust(A2, limit, tfSetFreeze)); + env(trust(a2, limit, tfSetFreeze)); env.close(); // test: A1 can send USD using XRP through A2 offer - env(pay(A1, G1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect)); + env(pay(a1, g1, usd(10)), Path(~usd), Sendmax(XRP(11)), Txflags(tfNoRippleDirect)); env.close(); // test: G1 can send USD using XRP through A2 offer - env(pay(G1, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect)); + env(pay(g1, a1, usd(10)), Path(~usd), Sendmax(XRP(11)), Txflags(tfNoRippleDirect)); env.close(); - env(trust(A2, limit, tfClearFreeze)); + env(trust(a2, limit, tfClearFreeze)); env.close(); } @@ -1053,51 +1052,51 @@ class Freeze_test : public beast::unit_test::suite // currency holder. if (features[featureDeepFreeze]) { - env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze)); + env(trust(a2, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A1 cannot send USD using XRP through A2 offer - env(pay(A1, G1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(a1, g1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); // test: G1 cannot send USD using XRP through A2 offer - env(pay(G1, A1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(g1, a1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); - env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a2, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Cleanup - env(offer_cancel(A1, env.seq(A1) - 1)); - env.require(offers(A1, 0)); + env(offerCancel(a1, env.seq(a1) - 1)); + env.require(offers(a1, 0)); env.close(); - env(offer(A2, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(a2, usd(100), XRP(100)), Txflags(tfPassive)); env.close(); // Testing payments A1 <-> G1 using offer from A2 frozen by issuer. { - env(trust(G1, A2["USD"](0), tfSetFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze)); env.close(); // test: A1 can send XRP using USD through A2 offer - env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(a1, g1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); // test: G1 can send XRP using USD through A2 offer - env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(g1, a1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze)); env.close(); } @@ -1105,44 +1104,44 @@ class Freeze_test : public beast::unit_test::suite // issuer. if (features[featureDeepFreeze]) { - env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A1 cannot send XRP using USD through A2 offer - env(pay(A1, G1, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(a1, g1, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); // test: G1 cannot send XRP using USD through A2 offer - env(pay(G1, A1, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(g1, a1, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing payments A1 <-> G1 using offer from A2 frozen by currency // holder. { - env(trust(A2, limit, tfSetFreeze)); + env(trust(a2, limit, tfSetFreeze)); env.close(); // test: A1 can send XRP using USD through A2 offer - env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(a1, g1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); // test: G1 can send XRP using USD through A2 offer - env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(g1, a1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); - env(trust(A2, limit, tfClearFreeze)); + env(trust(a2, limit, tfClearFreeze)); env.close(); } @@ -1150,32 +1149,32 @@ class Freeze_test : public beast::unit_test::suite // currency holder. if (features[featureDeepFreeze]) { - env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze)); + env(trust(a2, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A1 cannot send XRP using USD through A2 offer - env(pay(A1, G1, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(a1, g1, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); // test: G1 cannot send XRP using USD through A2 offer - env(pay(G1, A1, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_PARTIAL)); + env(pay(g1, a1, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_PARTIAL)); env.close(); - env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a2, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Cleanup - env(offer_cancel(A1, env.seq(A1) - 1)); - env.require(offers(A1, 0)); + env(offerCancel(a1, env.seq(a1) - 1)); + env.require(offers(a1, 0)); env.close(); } @@ -1187,117 +1186,117 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); + env.fund(XRP(10000), g1, a1, a2); env.close(); - auto const limit = USD(10000); - env.trust(limit, A1, A2); + auto const limit = usd(10000); + env.trust(limit, a1, a2); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); // Checking payments before freeze // To issuer: - env(pay(A1, G1, USD(1))); - env(pay(A2, G1, USD(1))); + env(pay(a1, g1, usd(1))); + env(pay(a2, g1, usd(1))); env.close(); // To each other: - env(pay(A1, A2, USD(1))); - env(pay(A2, A1, USD(1))); + env(pay(a1, a2, usd(1))); + env(pay(a2, a1, usd(1))); env.close(); // Freeze A1 - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // Issuer and A1 can send payments to each other - env(pay(A1, G1, USD(1))); - env(pay(G1, A1, USD(1))); + env(pay(a1, g1, usd(1))); + env(pay(g1, a1, usd(1))); env.close(); // A1 cannot send tokens to A2 - env(pay(A1, A2, USD(1)), ter(tecPATH_DRY)); + env(pay(a1, a2, usd(1)), Ter(tecPATH_DRY)); // A2 can still send to A1 - env(pay(A2, A1, USD(1))); + env(pay(a2, a1, usd(1))); env.close(); if (features[featureDeepFreeze]) { // Deep freeze A1 - env(trust(G1, A1["USD"](0), tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetDeepFreeze)); env.close(); // Issuer and A1 can send payments to each other - env(pay(A1, G1, USD(1))); - env(pay(G1, A1, USD(1))); + env(pay(a1, g1, usd(1))); + env(pay(g1, a1, usd(1))); env.close(); // A1 cannot send tokens to A2 - env(pay(A1, A2, USD(1)), ter(tecPATH_DRY)); + env(pay(a1, a2, usd(1)), Ter(tecPATH_DRY)); // A2 cannot send tokens to A1 - env(pay(A2, A1, USD(1)), ter(tecPATH_DRY)); + env(pay(a2, a1, usd(1)), Ter(tecPATH_DRY)); // Clear deep freeze on A1 - env(trust(G1, A1["USD"](0), tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearDeepFreeze)); env.close(); } // Clear freeze on A1 - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); // A1 freezes trust line - env(trust(A1, limit, tfSetFreeze)); + env(trust(a1, limit, tfSetFreeze)); env.close(); // Issuer and A2 must not be affected - env(pay(A2, G1, USD(1))); - env(pay(G1, A2, USD(1))); + env(pay(a2, g1, usd(1))); + env(pay(g1, a2, usd(1))); env.close(); // A1 can send tokens to the issuer - env(pay(A1, G1, USD(1))); + env(pay(a1, g1, usd(1))); env.close(); // A1 can send tokens to A2 - env(pay(A1, A2, USD(1))); + env(pay(a1, a2, usd(1))); env.close(); // Issuer can sent tokens to A1 - env(pay(G1, A1, USD(1))); + env(pay(g1, a1, usd(1))); // A2 cannot send tokens to A1 - env(pay(A2, A1, USD(1)), ter(tecPATH_DRY)); + env(pay(a2, a1, usd(1)), Ter(tecPATH_DRY)); if (features[featureDeepFreeze]) { // A1 deep freezes trust line - env(trust(A1, limit, tfSetDeepFreeze)); + env(trust(a1, limit, tfSetDeepFreeze)); env.close(); // Issuer and A2 must not be affected - env(pay(A2, G1, USD(1))); - env(pay(G1, A2, USD(1))); + env(pay(a2, g1, usd(1))); + env(pay(g1, a2, usd(1))); env.close(); // A1 can still send token to issuer - env(pay(A1, G1, USD(1))); + env(pay(a1, g1, usd(1))); env.close(); // Issuer can send tokens to A1 - env(pay(G1, A1, USD(1))); + env(pay(g1, a1, usd(1))); // A2 cannot send tokens to A1 - env(pay(A2, A1, USD(1)), ter(tecPATH_DRY)); + env(pay(a2, a1, usd(1)), Ter(tecPATH_DRY)); // A1 cannot send tokens to A2 - env(pay(A1, A2, USD(1)), ter(tecPATH_DRY)); + env(pay(a1, a2, usd(1)), Ter(tecPATH_DRY)); } } @@ -1309,137 +1308,137 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); + env.fund(XRP(10000), g1, a1, a2); env.close(); - auto const limit = USD(10000); - env.trust(limit, A1, A2); + auto const limit = usd(10000); + env.trust(limit, a1, a2); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); // Confirming we can write and cash checks { - uint256 const checkId{getCheckIndex(G1, env.seq(G1))}; - env(check::create(G1, A1, USD(10))); + uint256 const checkId{getCheckIndex(g1, env.seq(g1))}; + env(check::create(g1, a1, usd(10))); env.close(); - env(check::cash(A1, checkId, USD(10))); + env(check::cash(a1, checkId, usd(10))); env.close(); } { - uint256 const checkId{getCheckIndex(G1, env.seq(G1))}; - env(check::create(G1, A2, USD(10))); + uint256 const checkId{getCheckIndex(g1, env.seq(g1))}; + env(check::create(g1, a2, usd(10))); env.close(); - env(check::cash(A2, checkId, USD(10))); + env(check::cash(a2, checkId, usd(10))); env.close(); } { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, G1, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, g1, usd(10))); env.close(); - env(check::cash(G1, checkId, USD(10))); + env(check::cash(g1, checkId, usd(10))); env.close(); } { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, A2, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, a2, usd(10))); env.close(); - env(check::cash(A2, checkId, USD(10))); + env(check::cash(a2, checkId, usd(10))); env.close(); } { - uint256 const checkId{getCheckIndex(A2, env.seq(A2))}; - env(check::create(A2, G1, USD(10))); + uint256 const checkId{getCheckIndex(a2, env.seq(a2))}; + env(check::create(a2, g1, usd(10))); env.close(); - env(check::cash(G1, checkId, USD(10))); + env(check::cash(g1, checkId, usd(10))); env.close(); } { - uint256 const checkId{getCheckIndex(A2, env.seq(A2))}; - env(check::create(A2, A1, USD(10))); + uint256 const checkId{getCheckIndex(a2, env.seq(a2))}; + env(check::create(a2, a1, usd(10))); env.close(); - env(check::cash(A1, checkId, USD(10))); + env(check::cash(a1, checkId, usd(10))); env.close(); } // Testing creation and cashing of checks on a trustline frozen by // issuer { - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: issuer writes check to A1. { - uint256 const checkId{getCheckIndex(G1, env.seq(G1))}; - env(check::create(G1, A1, USD(10))); + uint256 const checkId{getCheckIndex(g1, env.seq(g1))}; + env(check::create(g1, a1, usd(10))); env.close(); - env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN)); + env(check::cash(a1, checkId, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A2 writes check to A1. { - uint256 const checkId{getCheckIndex(A2, env.seq(A2))}; - env(check::create(A2, A1, USD(10))); + uint256 const checkId{getCheckIndex(a2, env.seq(a2))}; + env(check::create(a2, a1, usd(10))); env.close(); // Same as previous test - env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN)); + env(check::cash(a1, checkId, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to issuer { - env(check::create(A1, G1, USD(10)), ter(tecFROZEN)); + env(check::create(a1, g1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to A2 { // Same as previous test - env(check::create(A1, A2, USD(10)), ter(tecFROZEN)); + env(check::create(a1, a2, usd(10)), Ter(tecFROZEN)); env.close(); } // Unfreeze the trustline to create a couple of checks so that we // could try to cash them later when the trustline is frozen again. - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); - uint256 const checkId1{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, G1, USD(10))); + uint256 const checkId1{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, g1, usd(10))); env.close(); - uint256 const checkId2{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, A2, USD(10))); + uint256 const checkId2{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, a2, usd(10))); env.close(); - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: issuer tries to cash the check from A1 { - env(check::cash(G1, checkId1, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(g1, checkId1, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } // test: A2 tries to cash the check from A1 { - env(check::cash(A2, checkId2, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(a2, checkId2, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); } @@ -1447,110 +1446,110 @@ class Freeze_test : public beast::unit_test::suite // issuer if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: issuer writes check to A1. { - uint256 const checkId{getCheckIndex(G1, env.seq(G1))}; - env(check::create(G1, A1, USD(10))); + uint256 const checkId{getCheckIndex(g1, env.seq(g1))}; + env(check::create(g1, a1, usd(10))); env.close(); - env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN)); + env(check::cash(a1, checkId, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A2 writes check to A1. { - uint256 const checkId{getCheckIndex(A2, env.seq(A2))}; - env(check::create(A2, A1, USD(10))); + uint256 const checkId{getCheckIndex(a2, env.seq(a2))}; + env(check::create(a2, a1, usd(10))); env.close(); // Same as previous test - env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN)); + env(check::cash(a1, checkId, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to issuer { - env(check::create(A1, G1, USD(10)), ter(tecFROZEN)); + env(check::create(a1, g1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to A2 { // Same as previous test - env(check::create(A1, A2, USD(10)), ter(tecFROZEN)); + env(check::create(a1, a2, usd(10)), Ter(tecFROZEN)); env.close(); } // Unfreeze the trustline to create a couple of checks so that we // could try to cash them later when the trustline is frozen again. - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); - uint256 const checkId1{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, G1, USD(10))); + uint256 const checkId1{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, g1, usd(10))); env.close(); - uint256 const checkId2{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, A2, USD(10))); + uint256 const checkId2{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, a2, usd(10))); env.close(); - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: issuer tries to cash the check from A1 { - env(check::cash(G1, checkId1, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(g1, checkId1, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } // test: A2 tries to cash the check from A1 { - env(check::cash(A2, checkId2, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(a2, checkId2, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing creation and cashing of checks on a trustline frozen by // a currency holder { - env(trust(A1, limit, tfSetFreeze)); + env(trust(a1, limit, tfSetFreeze)); env.close(); // test: issuer writes check to A1. { - env(check::create(G1, A1, USD(10)), ter(tecFROZEN)); + env(check::create(g1, a1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A2 writes check to A1. { - env(check::create(A2, A1, USD(10)), ter(tecFROZEN)); + env(check::create(a2, a1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to issuer { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, G1, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, g1, usd(10))); env.close(); - env(check::cash(G1, checkId, USD(10))); + env(check::cash(g1, checkId, usd(10))); env.close(); } // test: A1 writes check to A2 { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, A2, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, a2, usd(10))); env.close(); - env(check::cash(A2, checkId, USD(10))); + env(check::cash(a2, checkId, usd(10))); env.close(); } - env(trust(A1, limit, tfClearFreeze)); + env(trust(a1, limit, tfClearFreeze)); env.close(); } @@ -1558,40 +1557,40 @@ class Freeze_test : public beast::unit_test::suite // a currency holder if (features[featureDeepFreeze]) { - env(trust(A1, limit, tfSetFreeze | tfSetDeepFreeze)); + env(trust(a1, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: issuer writes check to A1. { - env(check::create(G1, A1, USD(10)), ter(tecFROZEN)); + env(check::create(g1, a1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A2 writes check to A1. { - env(check::create(A2, A1, USD(10)), ter(tecFROZEN)); + env(check::create(a2, a1, usd(10)), Ter(tecFROZEN)); env.close(); } // test: A1 writes check to issuer { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, G1, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, g1, usd(10))); env.close(); - env(check::cash(G1, checkId, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(g1, checkId, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } // test: A1 writes check to A2 { - uint256 const checkId{getCheckIndex(A1, env.seq(A1))}; - env(check::create(A1, A2, USD(10))); + uint256 const checkId{getCheckIndex(a1, env.seq(a1))}; + env(check::create(a1, a2, usd(10))); env.close(); - env(check::cash(A2, checkId, USD(10)), ter(tecPATH_PARTIAL)); + env(check::cash(a2, checkId, usd(10)), Ter(tecPATH_PARTIAL)); env.close(); } - env(trust(A1, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a1, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } } @@ -1601,53 +1600,52 @@ class Freeze_test : public beast::unit_test::suite { testcase("AMM payments on frozen trust lines"); using namespace test::jtx; - using path = test::jtx::path; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); + env.fund(XRP(10000), g1, a1, a2); env.close(); - env.trust(G1["USD"](10000), A1, A2); + env.trust(g1["USD"](10000), a1, a2); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); - AMM const ammG1(env, G1, XRP(1'000), USD(1'000)); + AMM const ammG1(env, g1, XRP(1'000), usd(1'000)); env.close(); // Testing basic payment using AMM when freezing one of the trust lines. { - env(trust(G1, A1["USD"](0), tfSetFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze)); env.close(); // test: can still use XRP to make payment - env(pay(A1, A2, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect)); + env(pay(a1, a2, usd(10)), Path(~usd), Sendmax(XRP(11)), Txflags(tfNoRippleDirect)); env.close(); // test: cannot use USD to make payment - env(pay(A1, A2, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(a1, a2, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); // test: can still receive USD payments. - env(pay(A2, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect)); + env(pay(a2, a1, usd(10)), Path(~usd), Sendmax(XRP(11)), Txflags(tfNoRippleDirect)); env.close(); // test: can still receive XRP payments. - env(pay(A2, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(a2, a1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); - env(trust(G1, A1["USD"](0), tfClearFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze)); env.close(); } @@ -1655,34 +1653,34 @@ class Freeze_test : public beast::unit_test::suite // lines. if (features[featureDeepFreeze]) { - env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a1["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: can still use XRP to make payment - env(pay(A1, A2, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect)); + env(pay(a1, a2, usd(10)), Path(~usd), Sendmax(XRP(11)), Txflags(tfNoRippleDirect)); env.close(); // test: cannot use USD to make payment - env(pay(A1, A2, XRP(10)), - path(~XRP), - sendmax(USD(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(a1, a2, XRP(10)), + Path(~XRP), + Sendmax(usd(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); // test: cannot receive USD payments. - env(pay(A2, A1, USD(10)), - path(~USD), - sendmax(XRP(11)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(a2, a1, usd(10)), + Path(~usd), + Sendmax(XRP(11)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); env.close(); // test: can still receive XRP payments. - env(pay(A2, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect)); + env(pay(a2, a1, XRP(10)), Path(~XRP), Sendmax(usd(11)), Txflags(tfNoRippleDirect)); env.close(); - env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a1["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } } @@ -1694,161 +1692,161 @@ class Freeze_test : public beast::unit_test::suite using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); + env.fund(XRP(10000), g1, a1, a2); env.close(); - auto const limit = USD(10000); - env.trust(limit, A1, A2); + auto const limit = usd(10000); + env.trust(limit, a1, a2); env.close(); - env(pay(G1, A1, USD(1000))); - env(pay(G1, A2, USD(1000))); + env(pay(g1, a1, usd(1000))); + env(pay(g1, a2, usd(1000))); env.close(); // Testing A2 nft offer sell when A2 frozen by issuer { - auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10)); - env(trust(G1, A2["USD"](0), tfSetFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a2, usd(10)); + env(trust(g1, a2["USD"](0), tfSetFreeze)); env.close(); // test: A2 can still receive USD for his NFT - env(token::acceptSellOffer(A1, sellOfferIndex)); + env(token::acceptSellOffer(a1, sellOfferIndex)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze)); env.close(); } // Testing A2 nft offer sell when A2 deep frozen by issuer if (features[featureDeepFreeze]) { - auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10)); + auto const sellOfferIndex = createNFTSellOffer(env, a2, usd(10)); - env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A2 cannot receive USD for his NFT - env(token::acceptSellOffer(A1, sellOfferIndex), ter(tecFROZEN)); + env(token::acceptSellOffer(a1, sellOfferIndex), Ter(tecFROZEN)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing A1 nft offer sell when A2 frozen by issuer { - auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10)); - env(trust(G1, A2["USD"](0), tfSetFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a1, usd(10)); + env(trust(g1, a2["USD"](0), tfSetFreeze)); env.close(); // test: A2 cannot send USD for NFT - env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(a2, sellOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze)); env.close(); } // Testing A1 nft offer sell when A2 deep frozen by issuer if (features[featureDeepFreeze]) { - auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10)); - env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a1, usd(10)); + env(trust(g1, a2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A2 cannot send USD for NFT - env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(a2, sellOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing A1 nft buy offer when A2 deep frozen by issuer if (features[featureDeepFreeze] && features[fixEnforceNFTokenTrustlineV2]) { - env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, a2["USD"](0), tfSetFreeze | tfSetDeepFreeze)); env.close(); - uint256 const nftID{token::getNextID(env, A2, 0u, tfTransferable)}; - env(token::mint(A2, 0), txflags(tfTransferable)); + uint256 const nftID{token::getNextID(env, a2, 0u, tfTransferable)}; + env(token::mint(a2, 0), Txflags(tfTransferable)); env.close(); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2)); env.close(); - env(token::acceptBuyOffer(A2, buyIdx), ter(tecFROZEN)); + env(token::acceptBuyOffer(a2, buyIdx), Ter(tecFROZEN)); env.close(); - env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); + env(trust(g1, a2["USD"](0), tfClearFreeze | tfClearDeepFreeze)); env.close(); - env(token::acceptBuyOffer(A2, buyIdx)); + env(token::acceptBuyOffer(a2, buyIdx)); env.close(); } // Testing A2 nft offer sell when A2 frozen by currency holder { - auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10)); - env(trust(A2, limit, tfSetFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a2, usd(10)); + env(trust(a2, limit, tfSetFreeze)); env.close(); // test: offer can still be accepted. - env(token::acceptSellOffer(A1, sellOfferIndex)); + env(token::acceptSellOffer(a1, sellOfferIndex)); env.close(); - env(trust(A2, limit, tfClearFreeze)); + env(trust(a2, limit, tfClearFreeze)); env.close(); } // Testing A2 nft offer sell when A2 deep frozen by currency holder if (features[featureDeepFreeze]) { - auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10)); + auto const sellOfferIndex = createNFTSellOffer(env, a2, usd(10)); - env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze)); + env(trust(a2, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A2 cannot receive USD for his NFT - env(token::acceptSellOffer(A1, sellOfferIndex), ter(tecFROZEN)); + env(token::acceptSellOffer(a1, sellOfferIndex), Ter(tecFROZEN)); env.close(); - env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a2, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } // Testing A1 nft offer sell when A2 frozen by currency holder { - auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10)); - env(trust(A2, limit, tfSetFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a1, usd(10)); + env(trust(a2, limit, tfSetFreeze)); env.close(); // test: A2 cannot send USD for NFT - env(token::acceptSellOffer(A2, sellOfferIndex)); + env(token::acceptSellOffer(a2, sellOfferIndex)); env.close(); - env(trust(A2, limit, tfClearFreeze)); + env(trust(a2, limit, tfClearFreeze)); env.close(); } // Testing A1 nft offer sell when A2 deep frozen by currency holder if (features[featureDeepFreeze]) { - auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10)); - env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze)); + auto const sellOfferIndex = createNFTSellOffer(env, a1, usd(10)); + env(trust(a2, limit, tfSetFreeze | tfSetDeepFreeze)); env.close(); // test: A2 cannot send USD for NFT - env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(a2, sellOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); - env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze)); + env(trust(a2, limit, tfClearFreeze | tfClearDeepFreeze)); env.close(); } @@ -1858,23 +1856,23 @@ class Freeze_test : public beast::unit_test::suite Account const broker{"broker"}; env.fund(XRP(10000), broker); env.close(); - env(trust(G1, broker["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, broker["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); env.close(); - uint256 const nftID{token::getNextID(env, A2, 0u, tfTransferable)}; - env(token::mint(A2, 0), txflags(tfTransferable)); + uint256 const nftID{token::getNextID(env, a2, 0u, tfTransferable)}; + env(token::mint(a2, 0), Txflags(tfTransferable)); env.close(); - uint256 const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key; - env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken)); + uint256 const sellIdx = keylet::nftoffer(a2, env.seq(a2)).key; + env(token::createOffer(a2, nftID, usd(10)), Txflags(tfSellNFToken)); env.close(); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(11)), token::owner(A2)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(11)), token::Owner(a2)); env.close(); env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecFROZEN)); + token::BrokerFee(usd(1)), + Ter(tecFROZEN)); env.close(); } @@ -1884,25 +1882,25 @@ class Freeze_test : public beast::unit_test::suite Account const minter{"minter"}; env.fund(XRP(10000), minter); env.close(); - env(trust(G1, minter["USD"](1000))); + env(trust(g1, minter["USD"](1000))); env.close(); uint256 const nftID{token::getNextID(env, minter, 0u, tfTransferable, 1u)}; - env(token::mint(minter, 0), token::xferFee(1u), txflags(tfTransferable)); + env(token::mint(minter, 0), token::XferFee(1u), Txflags(tfTransferable)); env.close(); uint256 const minterSellIdx = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, drops(1)), Txflags(tfSellNFToken)); env.close(); - env(token::acceptSellOffer(A2, minterSellIdx)); + env(token::acceptSellOffer(a2, minterSellIdx)); env.close(); - uint256 const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key; - env(token::createOffer(A2, nftID, USD(100)), txflags(tfSellNFToken)); + uint256 const sellIdx = keylet::nftoffer(a2, env.seq(a2)).key; + env(token::createOffer(a2, nftID, usd(100)), Txflags(tfSellNFToken)); env.close(); - env(trust(G1, minter["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); + env(trust(g1, minter["USD"](1000), tfSetFreeze | tfSetDeepFreeze)); env.close(); - env(token::acceptSellOffer(A1, sellIdx), ter(tecFROZEN)); + env(token::acceptSellOffer(a1, sellIdx), Ter(tecFROZEN)); env.close(); } } @@ -1916,7 +1914,7 @@ class Freeze_test : public beast::unit_test::suite bool modified = true) { using namespace test::jtx; - auto const affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + auto const affected = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; if (!BEAST_EXPECT(checkArraySize(affected, expectedArraySize))) return 0; @@ -1947,11 +1945,11 @@ class Freeze_test : public beast::unit_test::suite { using namespace test::jtx; uint256 const nftID{token::getNextID(env, account, 0u, tfTransferable)}; - env(token::mint(account, 0), txflags(tfTransferable)); + env(token::mint(account, 0), Txflags(tfTransferable)); env.close(); uint256 const sellOfferIndex = keylet::nftoffer(account, env.seq(account)).key; - env(token::createOffer(account, nftID, currency), txflags(tfSellNFToken)); + env(token::createOffer(account, nftID, currency), Txflags(tfSellNFToken)); env.close(); return sellOfferIndex; @@ -1977,7 +1975,7 @@ public: testNFTOffersWhenFreeze(features); }; using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testAll(sa - featureDeepFreeze - featurePermissionedDEX - fixEnforceNFTokenTrustlineV2); testAll(sa - featurePermissionedDEX - fixEnforceNFTokenTrustlineV2); testAll(sa - featureDeepFreeze - featurePermissionedDEX); diff --git a/src/test/app/GRPCServerTLS_test.cpp b/src/test/app/GRPCServerTLS_test.cpp index a3411682a2..6dbf335b6c 100644 --- a/src/test/app/GRPCServerTLS_test.cpp +++ b/src/test/app/GRPCServerTLS_test.cpp @@ -353,7 +353,7 @@ makeTestGRPCCall(std::unique_ptr return status.ok(); } -class GRPCServerTLS_test : public beast::unit_test::suite, public TemporaryTLSCertificates +class GRPCServerTLS_test : public beast::unit_test::Suite, public TemporaryTLSCertificates { public: void diff --git a/src/test/app/HashRouter_test.cpp b/src/test/app/HashRouter_test.cpp index 3ad317b157..8f9cae351e 100644 --- a/src/test/app/HashRouter_test.cpp +++ b/src/test/app/HashRouter_test.cpp @@ -14,7 +14,7 @@ namespace xrpl::test { -class HashRouter_test : public beast::unit_test::suite +class HashRouter_test : public beast::unit_test::Suite { static HashRouter::Setup getSetup(std::chrono::seconds hold, std::chrono::seconds relay) @@ -267,7 +267,7 @@ class HashRouter_test : public beast::unit_test::suite { Config const cfg; // default - auto const setup = setup_HashRouter(cfg); + auto const setup = setupHashRouter(cfg); BEAST_EXPECT(setup.holdTime == 300s); BEAST_EXPECT(setup.relayTime == 30s); } @@ -277,7 +277,7 @@ class HashRouter_test : public beast::unit_test::suite auto& h = cfg.section("hashrouter"); h.set("hold_time", "600"); h.set("relay_time", "15"); - auto const setup = setup_HashRouter(cfg); + auto const setup = setupHashRouter(cfg); BEAST_EXPECT(setup.holdTime == 600s); BEAST_EXPECT(setup.relayTime == 15s); } @@ -287,7 +287,7 @@ class HashRouter_test : public beast::unit_test::suite auto& h = cfg.section("hashrouter"); h.set("hold_time", "400"); h.set("relay_time", "400"); - auto const setup = setup_HashRouter(cfg); + auto const setup = setupHashRouter(cfg); BEAST_EXPECT(setup.holdTime == 400s); BEAST_EXPECT(setup.relayTime == 400s); } @@ -299,7 +299,7 @@ class HashRouter_test : public beast::unit_test::suite h.set("relay_time", "120"); try { - setup_HashRouter(cfg); + setupHashRouter(cfg); fail(); } catch (std::exception const& e) @@ -318,7 +318,7 @@ class HashRouter_test : public beast::unit_test::suite h.set("relay_time", "120"); try { - setup_HashRouter(cfg); + setupHashRouter(cfg); fail(); } catch (std::exception const& e) @@ -338,7 +338,7 @@ class HashRouter_test : public beast::unit_test::suite h.set("relay_time", "6"); try { - setup_HashRouter(cfg); + setupHashRouter(cfg); fail(); } catch (std::exception const& e) @@ -355,7 +355,7 @@ class HashRouter_test : public beast::unit_test::suite auto& h = cfg.section("hashrouter"); h.set("hold_time", "alice"); h.set("relay_time", "bob"); - auto const setup = setup_HashRouter(cfg); + auto const setup = setupHashRouter(cfg); // The set function ignores values that don't convert, so the // defaults are left unchanged BEAST_EXPECT(setup.holdTime == 300s); diff --git a/src/test/app/Invariants_test.cpp b/src/test/app/Invariants_test.cpp index 36ba3e98ec..965414553f 100644 --- a/src/test/app/Invariants_test.cpp +++ b/src/test/app/Invariants_test.cpp @@ -76,7 +76,7 @@ makeTransactor(ApplyContext& ctx); namespace xrpl::test { -class Invariants_test : public beast::unit_test::suite +class Invariants_test : public beast::unit_test::Suite { // The optional Preclose function is used to process additional transactions // on the ledger after creating two accounts, but before closing it, and @@ -94,7 +94,7 @@ class Invariants_test : public beast::unit_test::suite static FeatureBitset defaultAmendments() { - return xrpl::test::jtx::testable_amendments() | featureInvariantsV1_1 | fixSecurity3_1_3; + return xrpl::test::jtx::testableAmendments() | featureInvariantsV1_1 | fixSecurity3_1_3; } /** Run a specific test case to put the ledger into a state that will be @@ -116,7 +116,7 @@ class Invariants_test : public beast::unit_test::suite enum class TxAccount : int { None = 0, A1, A2 }; void doInvariantCheck( - std::vector const& expect_logs, + std::vector const& expectLogs, Precheck const& precheck, XRPAmount fee = XRPAmount{}, STTx tx = STTx{ttACCOUNT_SET, [](STObject&) {}}, @@ -126,7 +126,7 @@ class Invariants_test : public beast::unit_test::suite { doInvariantCheck( test::jtx::Env(*this, defaultAmendments()), - expect_logs, + expectLogs, precheck, fee, tx, @@ -138,7 +138,7 @@ class Invariants_test : public beast::unit_test::suite void doInvariantCheck( test::jtx::Env&& env, - std::vector const& expect_logs, + std::vector const& expectLogs, Precheck const& precheck, XRPAmount fee = XRPAmount{}, STTx tx = STTx{ttACCOUNT_SET, [](STObject&) {}}, @@ -148,26 +148,26 @@ class Invariants_test : public beast::unit_test::suite { using namespace test::jtx; - Account const A1{"A1"}; - Account const A2{"A2"}; - env.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env.fund(XRP(1000), a1, a2); if (preclose) - BEAST_EXPECT(preclose(A1, A2, env)); + BEAST_EXPECT(preclose(a1, a2, env)); env.close(); if (setTxAccount != TxAccount::None) - tx.setAccountID(sfAccount, setTxAccount == TxAccount::A1 ? A1.id() : A2.id()); + tx.setAccountID(sfAccount, setTxAccount == TxAccount::A1 ? a1.id() : a2.id()); - doInvariantCheck(std::move(env), A1, A2, expect_logs, precheck, fee, tx, ters); + doInvariantCheck(std::move(env), a1, a2, expectLogs, precheck, fee, tx, ters); } void doInvariantCheck( // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) test::jtx::Env&& env, - test::jtx::Account const& A1, - test::jtx::Account const& A2, - std::vector const& expect_logs, + test::jtx::Account const& a1, + test::jtx::Account const& a2, + std::vector const& expectLogs, Precheck const& precheck, XRPAmount fee = XRPAmount{}, STTx tx = STTx{ttACCOUNT_SET, [](STObject&) {}}, @@ -176,15 +176,15 @@ class Invariants_test : public beast::unit_test::suite using namespace test::jtx; OpenView ov{*env.current()}; - test::StreamSink sink{beast::severities::kWarning}; + test::StreamSink sink{beast::severities::KWarning}; beast::Journal const jlog{sink}; - ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, tapNONE, jlog}; + ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog}; // Invariants normally run in the Transaction's "apply" (operator()) context, and can always // access global Rules. CurrentTransactionRulesGuard const rg(ov.rules()); - BEAST_EXPECT(precheck(A1, A2, ac)); + BEAST_EXPECT(precheck(a1, a2, ac)); auto transactor = makeTransactor(ac); if (!BEAST_EXPECT(transactor)) @@ -212,7 +212,7 @@ class Invariants_test : public beast::unit_test::suite } // std::cerr << messages << '\n'; - for (auto const& m : expect_logs) + for (auto const& m : expectLogs) { BEAST_EXPECTS(messages.find(m) != std::string::npos, m); } @@ -226,9 +226,9 @@ class Invariants_test : public beast::unit_test::suite testcase << "XRP created"; doInvariantCheck( {{"XRP net change was positive: 500"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // put a single account in the view and "manufacture" some XRP - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; auto amt = sle->getFieldAmount(sfBalance); @@ -247,15 +247,15 @@ class Invariants_test : public beast::unit_test::suite // An account was deleted, but not by an AccountDelete transaction. doInvariantCheck( {{"an account root was deleted"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // remove an account from the view - auto sle = ac.view().peek(keylet::account(A1.id())); + auto sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sle->at(sfBalance) = beast::zero; + sle->at(sfBalance) = beast::kZERO; ac.view().erase(sle); return true; }); @@ -275,17 +275,17 @@ class Invariants_test : public beast::unit_test::suite // Successful AccountDelete that deleted more than one account. doInvariantCheck( {{"account deletion succeeded but deleted multiple accounts"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { + [](Account const& a1, Account const& a2, ApplyContext& ac) { // remove two accounts from the view - auto sleA1 = ac.view().peek(keylet::account(A1.id())); - auto sleA2 = ac.view().peek(keylet::account(A2.id())); + auto sleA1 = ac.view().peek(keylet::account(a1.id())); + auto sleA2 = ac.view().peek(keylet::account(a2.id())); if (!sleA1 || !sleA2) return false; // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sleA1->at(sfBalance) = beast::zero; - sleA2->at(sfBalance) = beast::zero; + sleA1->at(sfBalance) = beast::kZERO; + sleA2->at(sfBalance) = beast::kZERO; ac.view().erase(sleA1); ac.view().erase(sleA2); return true; @@ -302,13 +302,14 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"account deletion left behind a non-zero balance"}}, + // NOLINTNEXTLINE(readability-identifier-naming) [&](Account const& A1, Account const& A2, ApplyContext& ac) { // A1 has a balance. Delete A1 auto const a1 = A1.id(); auto const sleA1 = ac.view().peek(keylet::account(a1)); if (!sleA1) return false; - if (!BEAST_EXPECT(*sleA1->at(sfBalance) != beast::zero)) + if (!BEAST_EXPECT(*sleA1->at(sfBalance) != beast::kZERO)) return false; ac.view().erase(sleA1); @@ -320,6 +321,7 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"account deletion left behind a non-zero owner count"}}, + // NOLINTNEXTLINE(readability-identifier-naming) [&](Account const& A1, Account const& A2, ApplyContext& ac) { // Increment A1's owner count, then delete A1 auto const a1 = A1.id(); @@ -329,7 +331,7 @@ class Invariants_test : public beast::unit_test::suite // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sleA1->at(sfBalance) = beast::zero; + sleA1->at(sfBalance) = beast::kZERO; BEAST_EXPECT(sleA1->at(sfOwnerCount) == 0); adjustOwnerCount(ac.view(), sleA1, 1, ac.journal); @@ -340,7 +342,7 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttACCOUNT_DELETE, [](STObject& tx) {}}); - for (auto const& keyletInfo : directAccountKeylets) + for (auto const& keyletInfo : kDIRECT_ACCOUNT_KEYLETS) { // TODO: Use structured binding once LLVM 16 is the minimum // supported version. See also: @@ -354,7 +356,8 @@ class Invariants_test : public beast::unit_test::suite using namespace std::string_literals; doInvariantCheck( - {{"account deletion left behind a "s + type.c_str() + " object"}}, + {{"account deletion left behind a "s + type.cStr() + " object"}}, + // NOLINTNEXTLINE(readability-identifier-naming) [&](Account const& A1, Account const& A2, ApplyContext& ac) { // Add an object to the ledger for account A1, then delete // A1 @@ -369,7 +372,7 @@ class Invariants_test : public beast::unit_test::suite // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the // desired check. - sleA1->at(sfBalance) = beast::zero; + sleA1->at(sfBalance) = beast::kZERO; ac.view().erase(sleA1); return true; @@ -381,15 +384,15 @@ class Invariants_test : public beast::unit_test::suite // NFT special case doInvariantCheck( {{"account deletion left behind a NFTokenPage object"}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { + [&](Account const& a1, Account const&, ApplyContext& ac) { // remove an account from the view - auto sle = ac.view().peek(keylet::account(A1.id())); + auto sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sle->at(sfBalance) = beast::zero; + sle->at(sfBalance) = beast::kZERO; sle->at(sfOwnerCount) = 0; ac.view().erase(sle); return true; @@ -397,10 +400,10 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttACCOUNT_DELETE, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const&, Env& env) { + [&](Account const& a1, Account const&, Env& env) { // Preclose callback to mint the NFT which will be deleted in // the Precheck callback above. - env(token::mint(A1)); + env(token::mint(a1)); return true; }); @@ -411,7 +414,7 @@ class Invariants_test : public beast::unit_test::suite Issue ammIssue; doInvariantCheck( {{"account deletion left behind a DirectoryNode object"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // Delete the AMM account without cleaning up the directory or // deleting the AMM object auto sle = ac.view().peek(keylet::account(ammAcctID)); @@ -424,7 +427,7 @@ class Invariants_test : public beast::unit_test::suite // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sle->at(sfBalance) = beast::zero; + sle->at(sfBalance) = beast::kZERO; sle->at(sfOwnerCount) = 0; ac.view().erase(sle); @@ -433,10 +436,10 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttAMM_WITHDRAW, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { // Preclose callback to create the AMM which will be partially // deleted in the Precheck callback above. - AMM const amm(env, A1, XRP(100), A1["USD"](50)); + AMM const amm(env, a1, XRP(100), a1["USD"](50)); ammAcctID = amm.ammAccount(); ammKey = amm.ammID(); ammIssue = amm.lptIssue(); @@ -444,7 +447,7 @@ class Invariants_test : public beast::unit_test::suite }); doInvariantCheck( {{"account deletion left behind a AMM object"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // Delete all the AMM's trust lines, remove the AMM from the AMM // account's directory (this deletes the directory), and delete // the AMM account. Do not delete the AMM object. @@ -456,7 +459,7 @@ class Invariants_test : public beast::unit_test::suite BEAST_EXPECT(sle->at(~sfAMMID) == ammKey); for (auto const& trustKeylet : - {keylet::line(ammAcctID, A1["USD"]), keylet::line(A1, ammIssue)}) + {keylet::line(ammAcctID, a1["USD"]), keylet::line(a1, ammIssue)}) { auto const line = ac.view().peek(trustKeylet); if (!line) @@ -488,7 +491,7 @@ class Invariants_test : public beast::unit_test::suite // Clear the balance so the "account deletion left behind a // non-zero balance" check doesn't trip earlier than the desired // check. - sle->at(sfBalance) = beast::zero; + sle->at(sfBalance) = beast::kZERO; sle->at(sfOwnerCount) = 0; ac.view().erase(sle); @@ -497,10 +500,10 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttAMM_WITHDRAW, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { // Preclose callback to create the AMM which will be partially // deleted in the Precheck callback above. - AMM const amm(env, A1, XRP(100), A1["USD"](50)); + AMM const amm(env, a1, XRP(100), a1["USD"](50)); ammAcctID = amm.ammAccount(); ammKey = amm.ammID(); ammIssue = amm.lptIssue(); @@ -515,9 +518,9 @@ class Invariants_test : public beast::unit_test::suite testcase << "ledger entry types don't match"; doInvariantCheck( {{"ledger entry type mismatch"}, {"XRP net change of -1000000000 doesn't match fee 0"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // replace an entry in the table with an SLE of a different type - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; auto const sleNew = std::make_shared(ltTICKET, sle->key()); @@ -527,9 +530,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"invalid ledger entry type added"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // add an entry in the table with an SLE of an invalid type - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; @@ -537,7 +540,7 @@ class Invariants_test : public beast::unit_test::suite // unsupported value so that the valid type invariant check // will fail. auto const sleNew = - std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); // We don't use ltNICKNAME directly since it's marked deprecated // to prevent accidental use elsewhere. @@ -554,10 +557,10 @@ class Invariants_test : public beast::unit_test::suite testcase << "trust lines with XRP not allowed"; doInvariantCheck( {{"an XRP trust line was created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { + [](Account const& a1, Account const& a2, ApplyContext& ac) { // create simple trust SLE with xrp currency auto const sleNew = - std::make_shared(keylet::line(A1, A2, xrpIssue().currency)); + std::make_shared(keylet::line(a1, a2, xrpIssue().currency)); ac.view().insert(sleNew); return true; }); @@ -572,10 +575,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"a trust line with deep freeze flag without normal freeze was " "created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sleNew = std::make_shared(keylet::line(A1, A2, A1["USD"].currency)); - sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); - sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sleNew = std::make_shared(keylet::line(a1, a2, a1["USD"].currency)); + sleNew->setFieldAmount(sfLowLimit, a1["USD"](0)); + sleNew->setFieldAmount(sfHighLimit, a1["USD"](0)); std::uint32_t uFlags = 0u; uFlags |= lsfLowDeepFreeze; @@ -587,10 +590,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"a trust line with deep freeze flag without normal freeze was " "created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sleNew = std::make_shared(keylet::line(A1, A2, A1["USD"].currency)); - sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); - sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sleNew = std::make_shared(keylet::line(a1, a2, a1["USD"].currency)); + sleNew->setFieldAmount(sfLowLimit, a1["USD"](0)); + sleNew->setFieldAmount(sfHighLimit, a1["USD"](0)); std::uint32_t uFlags = 0u; uFlags |= lsfHighDeepFreeze; sleNew->setFieldU32(sfFlags, uFlags); @@ -601,10 +604,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"a trust line with deep freeze flag without normal freeze was " "created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sleNew = std::make_shared(keylet::line(A1, A2, A1["USD"].currency)); - sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); - sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sleNew = std::make_shared(keylet::line(a1, a2, a1["USD"].currency)); + sleNew->setFieldAmount(sfLowLimit, a1["USD"](0)); + sleNew->setFieldAmount(sfHighLimit, a1["USD"](0)); std::uint32_t uFlags = 0u; uFlags |= lsfLowDeepFreeze | lsfHighDeepFreeze; sleNew->setFieldU32(sfFlags, uFlags); @@ -615,10 +618,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"a trust line with deep freeze flag without normal freeze was " "created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sleNew = std::make_shared(keylet::line(A1, A2, A1["USD"].currency)); - sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); - sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sleNew = std::make_shared(keylet::line(a1, a2, a1["USD"].currency)); + sleNew->setFieldAmount(sfLowLimit, a1["USD"](0)); + sleNew->setFieldAmount(sfHighLimit, a1["USD"](0)); std::uint32_t uFlags = 0u; uFlags |= lsfLowDeepFreeze | lsfHighFreeze; sleNew->setFieldU32(sfFlags, uFlags); @@ -629,10 +632,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"a trust line with deep freeze flag without normal freeze was " "created"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sleNew = std::make_shared(keylet::line(A1, A2, A1["USD"].currency)); - sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); - sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sleNew = std::make_shared(keylet::line(a1, a2, a1["USD"].currency)); + sleNew->setFieldAmount(sfLowLimit, a1["USD"](0)); + sleNew->setFieldAmount(sfHighLimit, a1["USD"](0)); std::uint32_t uFlags = 0u; uFlags |= lsfLowFreeze | lsfHighDeepFreeze; sleNew->setFieldU32(sfFlags, uFlags); @@ -647,49 +650,49 @@ class Invariants_test : public beast::unit_test::suite using namespace test::jtx; testcase << "transfers when frozen"; - Account const G1{"G1"}; + Account const g1{"G1"}; // Helper function to establish the trustlines - auto const createTrustlines = [&](Account const& A1, Account const& A2, Env& env) { + auto const createTrustlines = [&](Account const& a1, Account const& a2, Env& env) { // Preclose callback to establish trust lines with gateway - env.fund(XRP(1000), G1); + env.fund(XRP(1000), g1); - env.trust(G1["USD"](10000), A1); - env.trust(G1["USD"](10000), A2); + env.trust(g1["USD"](10000), a1); + env.trust(g1["USD"](10000), a2); env.close(); - env(pay(G1, A1, G1["USD"](1000))); - env(pay(G1, A2, G1["USD"](1000))); + env(pay(g1, a1, g1["USD"](1000))); + env(pay(g1, a2, g1["USD"](1000))); env.close(); return true; }; - auto const A1FrozenByIssuer = [&](Account const& A1, Account const& A2, Env& env) { - createTrustlines(A1, A2, env); - env(trust(G1, A1["USD"](10000), tfSetFreeze)); + auto const a1FrozenByIssuer = [&](Account const& a1, Account const& a2, Env& env) { + createTrustlines(a1, a2, env); + env(trust(g1, a1["USD"](10000), tfSetFreeze)); env.close(); return true; }; - auto const A1DeepFrozenByIssuer = [&](Account const& A1, Account const& A2, Env& env) { - A1FrozenByIssuer(A1, A2, env); - env(trust(G1, A1["USD"](10000), tfSetDeepFreeze)); + auto const a1DeepFrozenByIssuer = [&](Account const& a1, Account const& a2, Env& env) { + a1FrozenByIssuer(a1, a2, env); + env(trust(g1, a1["USD"](10000), tfSetDeepFreeze)); env.close(); return true; }; - auto const changeBalances = [&](Account const& A1, - Account const& A2, + auto const changeBalances = [&](Account const& a1, + Account const& a2, ApplyContext& ac, - int A1Balance, - int A2Balance) { - auto const sleA1 = ac.view().peek(keylet::line(A1, G1["USD"])); - auto const sleA2 = ac.view().peek(keylet::line(A2, G1["USD"])); + int a1Balance, + int a2Balance) { + auto const sleA1 = ac.view().peek(keylet::line(a1, g1["USD"])); + auto const sleA2 = ac.view().peek(keylet::line(a2, g1["USD"])); - sleA1->setFieldAmount(sfBalance, G1["USD"](A1Balance)); - sleA2->setFieldAmount(sfBalance, G1["USD"](A2Balance)); + sleA1->setFieldAmount(sfBalance, g1["USD"](a1Balance)); + sleA2->setFieldAmount(sfBalance, g1["USD"](a2Balance)); ac.view().update(sleA1); ac.view().update(sleA2); @@ -698,38 +701,38 @@ class Invariants_test : public beast::unit_test::suite // test: imitating frozen A1 making a payment to A2. doInvariantCheck( {{"Attempting to move frozen funds"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - changeBalances(A1, A2, ac, -900, -1100); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + changeBalances(a1, a2, ac, -900, -1100); return true; }, XRPAmount{}, STTx{ttPAYMENT, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - A1FrozenByIssuer); + a1FrozenByIssuer); // test: imitating deep frozen A1 making a payment to A2. doInvariantCheck( {{"Attempting to move frozen funds"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - changeBalances(A1, A2, ac, -900, -1100); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + changeBalances(a1, a2, ac, -900, -1100); return true; }, XRPAmount{}, STTx{ttPAYMENT, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - A1DeepFrozenByIssuer); + a1DeepFrozenByIssuer); // test: imitating A2 making a payment to deep frozen A1. doInvariantCheck( {{"Attempting to move frozen funds"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - changeBalances(A1, A2, ac, -1100, -900); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + changeBalances(a1, a2, ac, -1100, -900); return true; }, XRPAmount{}, STTx{ttPAYMENT, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - A1DeepFrozenByIssuer); + a1DeepFrozenByIssuer); } void @@ -740,12 +743,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Cannot return non-native STAmount as XRPAmount"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { + [](Account const& a1, Account const& a2, ApplyContext& ac) { // non-native balance - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - STAmount const nonNative(A2["USD"](51)); + STAmount const nonNative(a2["USD"](51)); sle->setFieldAmount(sfBalance, nonNative); ac.view().update(sle); return true; @@ -753,14 +756,14 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"incorrect account XRP balance"}, {"XRP net change was positive: 99999999000000001"}}, - [this](Account const& A1, Account const&, ApplyContext& ac) { + [this](Account const& a1, Account const&, ApplyContext& ac) { // balance exceeds genesis amount - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; // Use `drops(1)` to bypass a call to STAmount::canonicalize // with an invalid value - sle->setFieldAmount(sfBalance, INITIAL_XRP + drops(1)); + sle->setFieldAmount(sfBalance, kINITIAL_XRP + drops(1)); BEAST_EXPECT(!sle->getFieldAmount(sfBalance).negative()); ac.view().update(sle); return true; @@ -769,9 +772,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"incorrect account XRP balance"}, {"XRP net change of -1000000001 doesn't match fee 0"}}, - [this](Account const& A1, Account const&, ApplyContext& ac) { + [this](Account const& a1, Account const&, ApplyContext& ac) { // balance is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; sle->setFieldAmount(sfBalance, STAmount{1, true}); @@ -794,10 +797,10 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{-1}); doInvariantCheck( - {{"fee paid exceeds system limit: "s + to_string(INITIAL_XRP)}, - {"XRP net change of 0 doesn't match fee "s + to_string(INITIAL_XRP)}}, + {{"fee paid exceeds system limit: "s + to_string(kINITIAL_XRP)}, + {"XRP net change of 0 doesn't match fee "s + to_string(kINITIAL_XRP)}}, [](Account const&, Account const&, ApplyContext&) { return true; }, - XRPAmount{INITIAL_XRP}); + XRPAmount{kINITIAL_XRP}); doInvariantCheck( {{"fee paid is 20 exceeds fee specified in transaction."}, @@ -814,13 +817,13 @@ class Invariants_test : public beast::unit_test::suite testcase << "no bad offers"; doInvariantCheck( - {{"offer with a bad amount"}}, [](Account const& A1, Account const&, ApplyContext& ac) { + {{"offer with a bad amount"}}, [](Account const& a1, Account const&, ApplyContext& ac) { // offer with negative takerpays - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::offer(A1.id(), (*sle)[sfSequence])); - sleNew->setAccountID(sfAccount, A1.id()); + auto sleNew = std::make_shared(keylet::offer(a1.id(), (*sle)[sfSequence])); + sleNew->setAccountID(sfAccount, a1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); sleNew->setFieldAmount(sfTakerPays, XRP(-1)); ac.view().insert(sleNew); @@ -828,28 +831,28 @@ class Invariants_test : public beast::unit_test::suite }); doInvariantCheck( - {{"offer with a bad amount"}}, [](Account const& A1, Account const&, ApplyContext& ac) { + {{"offer with a bad amount"}}, [](Account const& a1, Account const&, ApplyContext& ac) { // offer with negative takergets - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::offer(A1.id(), (*sle)[sfSequence])); - sleNew->setAccountID(sfAccount, A1.id()); + auto sleNew = std::make_shared(keylet::offer(a1.id(), (*sle)[sfSequence])); + sleNew->setAccountID(sfAccount, a1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); - sleNew->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleNew->setFieldAmount(sfTakerPays, a1["USD"](10)); sleNew->setFieldAmount(sfTakerGets, XRP(-1)); ac.view().insert(sleNew); return true; }); doInvariantCheck( - {{"offer with a bad amount"}}, [](Account const& A1, Account const&, ApplyContext& ac) { + {{"offer with a bad amount"}}, [](Account const& a1, Account const&, ApplyContext& ac) { // offer XRP to XRP - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::offer(A1.id(), (*sle)[sfSequence])); - sleNew->setAccountID(sfAccount, A1.id()); + auto sleNew = std::make_shared(keylet::offer(a1.id(), (*sle)[sfSequence])); + sleNew->setAccountID(sfAccount, a1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); sleNew->setFieldAmount(sfTakerPays, XRP(10)); sleNew->setFieldAmount(sfTakerGets, XRP(11)); @@ -867,12 +870,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"XRP net change of -1000000 doesn't match fee 0"}, {"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // escrow with negative amount - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); sleNew->setFieldAmount(sfAmount, XRP(-1)); ac.view().insert(sleNew); return true; @@ -881,15 +884,15 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"XRP net change was positive: 100000000000000001"}, {"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // escrow with too-large amount - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); // Use `drops(1)` to bypass a call to STAmount::canonicalize // with an invalid value - sleNew->setFieldAmount(sfAmount, INITIAL_XRP + drops(1)); + sleNew->setFieldAmount(sfAmount, kINITIAL_XRP + drops(1)); ac.view().insert(sleNew); return true; }); @@ -897,12 +900,12 @@ class Invariants_test : public beast::unit_test::suite // IOU < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // escrow with too-little iou - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); Issue const usd{Currency(0x5553440000000000), AccountID(0x4985601)}; STAmount const amt(usd, -1); @@ -914,12 +917,12 @@ class Invariants_test : public beast::unit_test::suite // IOU bad currency doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // escrow with bad iou currency - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); Issue const bad{badCurrency(), AccountID(0x4985601)}; STAmount const amt(bad, 1); @@ -931,12 +934,12 @@ class Invariants_test : public beast::unit_test::suite // MPT < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // escrow with too-little mpt - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - auto sleNew = std::make_shared(keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow(a1, (*sle)[sfSequence] + 2)); MPTIssue const mpt{makeMptID(1, AccountID(0x4985601))}; STAmount const amt(mpt, -1); @@ -948,9 +951,9 @@ class Invariants_test : public beast::unit_test::suite // MPT OutstandingAmount < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptissuance outstanding is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; @@ -964,9 +967,9 @@ class Invariants_test : public beast::unit_test::suite // MPT LockedAmount < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptissuance locked is less than locked - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; @@ -980,9 +983,9 @@ class Invariants_test : public beast::unit_test::suite // MPT OutstandingAmount < LockedAmount doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptissuance outstanding is less than locked - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; @@ -997,14 +1000,14 @@ class Invariants_test : public beast::unit_test::suite // MPT MPTAmount < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptoken amount is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; MPTIssue const mpt{makeMptID(1, AccountID(0x4985601))}; - auto sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), A1)); + auto sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), a1)); sleNew->setFieldU64(sfMPTAmount, -1); ac.view().insert(sleNew); return true; @@ -1013,14 +1016,14 @@ class Invariants_test : public beast::unit_test::suite // MPT LockedAmount < 0 doInvariantCheck( {{"escrow specifies invalid amount"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptoken locked amount is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; MPTIssue const mpt{makeMptID(1, AccountID(0x4985601))}; - auto sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), A1)); + auto sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), a1)); sleNew->setFieldU64(sfLockedAmount, -1); ac.view().insert(sleNew); return true; @@ -1038,8 +1041,8 @@ class Invariants_test : public beast::unit_test::suite [](Account const&, Account const&, ApplyContext& ac) { // Insert a new account root created by a non-payment into // the view. - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); ac.view().insert(sleNew); return true; @@ -1050,14 +1053,14 @@ class Invariants_test : public beast::unit_test::suite [](Account const&, Account const&, ApplyContext& ac) { // Insert two new account roots into the view. { - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleA3 = std::make_shared(acctKeylet); ac.view().insert(sleA3); } { - Account const A4{"A4"}; - Keylet const acctKeylet = keylet::account(A4); + Account const a4{"A4"}; + Keylet const acctKeylet = keylet::account(a4); auto const sleA4 = std::make_shared(acctKeylet); ac.view().insert(sleA4); } @@ -1068,8 +1071,8 @@ class Invariants_test : public beast::unit_test::suite {{"account created with wrong starting sequence number"}}, [](Account const&, Account const&, ApplyContext& ac) { // Insert a new account root with the wrong starting sequence. - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, ac.view().seq() + 1); ac.view().insert(sleNew); @@ -1081,8 +1084,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"pseudo-account created by a wrong transaction type"}}, [](Account const&, Account const&, ApplyContext& ac) { - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, 0); sleNew->setFieldH256(sfAMMID, uint256(1)); @@ -1096,8 +1099,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"account created with wrong starting sequence number"}}, [](Account const&, Account const&, ApplyContext& ac) { - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, ac.view().seq()); sleNew->setFieldH256(sfAMMID, uint256(1)); @@ -1111,8 +1114,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"pseudo-account created with wrong flags"}}, [](Account const&, Account const&, ApplyContext& ac) { - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, 0); sleNew->setFieldH256(sfAMMID, uint256(1)); @@ -1126,8 +1129,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"pseudo-account created with wrong flags"}}, [](Account const&, Account const&, ApplyContext& ac) { - Account const A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Account const a3{"A3"}; + Keylet const acctKeylet = keylet::account(a3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, 0); sleNew->setFieldH256(sfAMMID, uint256(1)); @@ -1161,7 +1164,7 @@ class Invariants_test : public beast::unit_test::suite STObject newNFToken(*nfTokenTemplate, sfNFToken, [&nftID](STObject& object) { object.setFieldH256(sfNFTokenID, nftID); }); - ret.push_back(std::move(newNFToken)); + ret.pushBack(std::move(newNFToken)); ++nftID; } return ret; @@ -1169,8 +1172,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page has invalid size"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, makeNFTokenIDs(0)); ac.view().insert(nftPage); @@ -1179,8 +1182,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page has invalid size"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, makeNFTokenIDs(33)); ac.view().insert(nftPage); @@ -1189,11 +1192,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFTs on page are not sorted"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { STArray nfTokens = makeNFTokenIDs(2); std::iter_swap(nfTokens.begin(), nfTokens.begin() + 1); - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, nfTokens); ac.view().insert(nftPage); @@ -1202,11 +1205,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT contains empty URI"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { STArray nfTokens = makeNFTokenIDs(1); nfTokens[0].setFieldVL(sfURI, Blob{}); - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, nfTokens); ac.view().insert(nftPage); @@ -1215,10 +1218,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page is improperly linked"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, makeNFTokenIDs(1)); - nftPage->setFieldH256(sfPreviousPageMin, keylet::nftpage_max(A1).key); + nftPage->setFieldH256(sfPreviousPageMin, keylet::nftpageMax(a1).key); ac.view().insert(nftPage); return true; @@ -1226,10 +1229,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page is improperly linked"}}, - [&makeNFTokenIDs](Account const& A1, Account const& A2, ApplyContext& ac) { - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + [&makeNFTokenIDs](Account const& a1, Account const& a2, ApplyContext& ac) { + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, makeNFTokenIDs(1)); - nftPage->setFieldH256(sfPreviousPageMin, keylet::nftpage_min(A2).key); + nftPage->setFieldH256(sfPreviousPageMin, keylet::nftpageMin(a2).key); ac.view().insert(nftPage); return true; @@ -1237,8 +1240,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page is improperly linked"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { - auto nftPage = std::make_shared(keylet::nftpage_max(A1)); + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { + auto nftPage = std::make_shared(keylet::nftpageMax(a1)); nftPage->setFieldArray(sfNFTokens, makeNFTokenIDs(1)); nftPage->setFieldH256(sfNextPageMin, nftPage->key()); @@ -1248,12 +1251,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT page is improperly linked"}}, - [&makeNFTokenIDs](Account const& A1, Account const& A2, ApplyContext& ac) { + [&makeNFTokenIDs](Account const& a1, Account const& a2, ApplyContext& ac) { STArray nfTokens = makeNFTokenIDs(1); auto nftPage = std::make_shared(keylet::nftpage( - keylet::nftpage_max(A1), ++(nfTokens[0].getFieldH256(sfNFTokenID)))); + keylet::nftpageMax(a1), ++(nfTokens[0].getFieldH256(sfNFTokenID)))); nftPage->setFieldArray(sfNFTokens, nfTokens); - nftPage->setFieldH256(sfNextPageMin, keylet::nftpage_max(A2).key); + nftPage->setFieldH256(sfNextPageMin, keylet::nftpageMax(a2).key); ac.view().insert(nftPage); return true; @@ -1261,10 +1264,10 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"NFT found in incorrect page"}}, - [&makeNFTokenIDs](Account const& A1, Account const&, ApplyContext& ac) { + [&makeNFTokenIDs](Account const& a1, Account const&, ApplyContext& ac) { STArray nfTokens = makeNFTokenIDs(2); auto nftPage = std::make_shared(keylet::nftpage( - keylet::nftpage_max(A1), (nfTokens[1].getFieldH256(sfNFTokenID)))); + keylet::nftpageMax(a1), (nfTokens[1].getFieldH256(sfNFTokenID)))); nftPage->setFieldArray(sfNFTokens, nfTokens); ac.view().insert(nftPage); @@ -1275,15 +1278,15 @@ class Invariants_test : public beast::unit_test::suite static std::shared_ptr createPermissionedDomain( ApplyContext& ac, - test::jtx::Account const& A1, - test::jtx::Account const& A2, + test::jtx::Account const& a1, + test::jtx::Account const& a2, std::uint32_t numCreds = 2, std::uint32_t seq = 10) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), seq); + Keylet const pdKeylet = keylet::permissionedDomain(a1.id(), seq); auto sle = std::make_shared(pdKeylet); - sle->setAccountID(sfOwner, A1); + sle->setAccountID(sfOwner, a1); sle->setFieldU32(sfSequence, seq); if (numCreds != 0u) @@ -1294,10 +1297,10 @@ class Invariants_test : public beast::unit_test::suite for (std::size_t n = 0; n < numCreds; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); auto credType = "cred_type" + std::to_string(n); cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } sle->setFieldArray(sfAcceptedCredentials, credentials); } @@ -1320,8 +1323,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain with no rules."}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - return createPermissionedDomain(ac, A1, A2, 0).get(); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + return createPermissionedDomain(ac, a1, a2, 0).get(); }, XRPAmount{}, STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, @@ -1329,12 +1332,12 @@ class Invariants_test : public beast::unit_test::suite testcase << "PermissionedDomain 2"; - auto constexpr tooBig = maxPermissionedDomainCredentialsArraySize + 1; + auto constexpr kTOO_BIG = kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE + 1; doInvariantCheck( Env(*this, features), - {{"permissioned domain bad credentials size " + std::to_string(tooBig)}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - return !!createPermissionedDomain(ac, A1, A2, tooBig); + {{"permissioned domain bad credentials size " + std::to_string(kTOO_BIG)}}, + [](Account const& a1, Account const& a2, ApplyContext& ac) { + return !!createPermissionedDomain(ac, a1, a2, kTOO_BIG); }, XRPAmount{}, STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, @@ -1344,17 +1347,17 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain credentials aren't sorted"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto slePd = createPermissionedDomain(ac, A1, A2, 0); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto slePd = createPermissionedDomain(ac, a1, a2, 0); STArray credentials(sfAcceptedCredentials, 2); for (std::size_t n = 0; n < 2; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); auto credType = std::string("cred_type") + std::to_string(9 - n); cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); ac.view().update(slePd); @@ -1368,16 +1371,16 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain credentials aren't unique"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - auto slePd = createPermissionedDomain(ac, A1, A2, 0); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + auto slePd = createPermissionedDomain(ac, a1, a2, 0); STArray credentials(sfAcceptedCredentials, 2); for (std::size_t n = 0; n < 2; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); cred.setFieldVL(sfCredentialType, Slice("cred_type", 9)); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); ac.view().update(slePd); @@ -1391,9 +1394,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain with no rules."}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // create PD - auto slePd = createPermissionedDomain(ac, A1, A2); + auto slePd = createPermissionedDomain(ac, a1, a2); // update PD with empty rules { @@ -1411,22 +1414,22 @@ class Invariants_test : public beast::unit_test::suite testcase << "PermissionedDomain Set 2"; doInvariantCheck( Env(*this, features), - {{"permissioned domain bad credentials size " + std::to_string(tooBig)}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + {{"permissioned domain bad credentials size " + std::to_string(kTOO_BIG)}}, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // create PD - auto slePd = createPermissionedDomain(ac, A1, A2); + auto slePd = createPermissionedDomain(ac, a1, a2); // update PD { - STArray credentials(sfAcceptedCredentials, tooBig); + STArray credentials(sfAcceptedCredentials, kTOO_BIG); - for (std::size_t n = 0; n < tooBig; ++n) + for (std::size_t n = 0; n < kTOO_BIG; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); auto credType = "cred_type2" + std::to_string(n); cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); @@ -1443,9 +1446,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain credentials aren't sorted"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // create PD - auto slePd = createPermissionedDomain(ac, A1, A2); + auto slePd = createPermissionedDomain(ac, a1, a2); // update PD { @@ -1453,10 +1456,10 @@ class Invariants_test : public beast::unit_test::suite for (std::size_t n = 0; n < 2; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); auto credType = std::string("cred_type2") + std::to_string(9 - n); cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); @@ -1473,9 +1476,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"permissioned domain credentials aren't unique"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // create PD - auto slePd = createPermissionedDomain(ac, A1, A2); + auto slePd = createPermissionedDomain(ac, a1, a2); // update PD { @@ -1483,9 +1486,9 @@ class Invariants_test : public beast::unit_test::suite for (std::size_t n = 0; n < 2; ++n) { auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); + cred.setAccountID(sfIssuer, a2); cred.setFieldVL(sfCredentialType, Slice("cred_type", 9)); - credentials.push_back(std::move(cred)); + credentials.pushBack(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); ac.view().update(slePd); @@ -1514,9 +1517,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), fixPDEnabled ? badMoreThan1 : emptyV, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - createPermissionedDomain(ac, A1, A2); - createPermissionedDomain(ac, A1, A2, 2, 11); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + createPermissionedDomain(ac, a1, a2); + createPermissionedDomain(ac, a1, a2, 2, 11); return true; }, XRPAmount{}, @@ -1529,19 +1532,19 @@ class Invariants_test : public beast::unit_test::suite Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); - [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, fixPDEnabled ? badMoreThan1 : emptyV, [&pd1, &pd2](Account const&, Account const&, ApplyContext& ac) { auto sle1 = ac.view().peek({ltPERMISSIONED_DOMAIN, pd1}); @@ -1571,19 +1574,19 @@ class Invariants_test : public beast::unit_test::suite Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); - [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( Env(*this, features), - A1, - A2, + a1, + a2, fixPDEnabled ? badNoDomains : emptyV, [](Account const&, Account const&, ApplyContext&) { return true; }, XRPAmount{}, @@ -1596,18 +1599,18 @@ class Invariants_test : public beast::unit_test::suite Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, fixPDEnabled ? badDeleted : emptyV, [&pd1](Account const&, Account const&, ApplyContext& ac) { auto sle1 = ac.view().peek({ltPERMISSIONED_DOMAIN, pd1}); @@ -1624,8 +1627,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), fixPDEnabled ? badNotDeleted : emptyV, - [](Account const& A1, Account const& A2, ApplyContext& ac) { - createPermissionedDomain(ac, A1, A2); + [](Account const& a1, Account const& a2, ApplyContext& ac) { + createPermissionedDomain(ac, a1, a2); return true; }, XRPAmount{}, @@ -1638,8 +1641,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( fixPDEnabled ? badTx : emptyV, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - createPermissionedDomain(ac, A1, A2); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + createPermissionedDomain(ac, a1, a2); return true; }, XRPAmount{}, @@ -1711,7 +1714,7 @@ class Invariants_test : public beast::unit_test::suite { doInvariantCheck( {{mod.expectedFailure}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { + [&](Account const& a1, Account const&, ApplyContext& ac) { auto sle = ac.view().peek(keylet::account(pseudoAccountID)); if (!sle) return false; @@ -1732,7 +1735,7 @@ class Invariants_test : public beast::unit_test::suite continue; doInvariantCheck( {{"pseudo-account has 2 pseudo-account fields set"}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { + [&](Account const& a1, Account const&, ApplyContext& ac) { auto sle = ac.view().peek(keylet::account(pseudoAccountID)); if (!sle) return false; @@ -1756,8 +1759,8 @@ class Invariants_test : public beast::unit_test::suite {{"pseudo-account has 0 pseudo-account fields set"}, {"pseudo-account sequence changed"}, {"pseudo-account flags are not set"}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { - auto sle = ac.view().peek(keylet::account(A1.id())); + [&](Account const& a1, Account const&, ApplyContext& ac) { + auto sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; sle->at(sfSequence) = 0; @@ -1769,8 +1772,8 @@ class Invariants_test : public beast::unit_test::suite static std::pair createPermissionedDomainEnv( test::jtx::Env& env, - test::jtx::Account const& A1, - test::jtx::Account const& A2, + test::jtx::Account const& a1, + test::jtx::Account const& a2, std::uint32_t numCreds = 2) { using namespace test::jtx; @@ -1780,11 +1783,11 @@ class Invariants_test : public beast::unit_test::suite for (std::size_t n = 0; n < numCreds; ++n) { auto credType = "cred_type" + std::to_string(n); - credentials.push_back({A2, credType}); + credentials.push_back({a2, credType}); } - std::uint32_t const seq = env.seq(A1); - env(pdomain::setTx(A1, credentials)); + std::uint32_t const seq = env.seq(a1); + env(pdomain::setTx(a1, credentials)); uint256 const key = pdomain::getNewDomain(env.meta()); // std::cout << "PD, acc: " << A1.id() << ", seq: " << seq << ", k: " << @@ -1806,11 +1809,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"domain doesn't exist"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A1.id(), 10); + [](Account const& a1, Account const&, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a1.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A1); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a1); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); ac.view().insert(sleOffer); return true; @@ -1823,8 +1826,8 @@ class Invariants_test : public beast::unit_test::suite sfDomainID, uint256{"F10D0CC9A0F9A3CBF585B80BE09A186483668FDBDD39AA7E33" "70F3649CE134E5"}); - Account const A1{"A1"}; - tx.setFieldAmount(sfTakerPays, A1["USD"](10)); + Account const a1{"A1"}; + tx.setFieldAmount(sfTakerPays, a1["USD"](10)); tx.setFieldAmount(sfTakerGets, XRP(1)); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); @@ -1833,16 +1836,16 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( Env(*this, features), {{"hybrid offer is malformed"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); sleOffer->setFlag(lsfHybrid); STArray bookArr; - bookArr.push_back(STObject::makeInnerObject(sfBook)); + bookArr.pushBack(STObject::makeInnerObject(sfBook)); sleOffer->setFieldArray(sfAdditionalBooks, bookArr); ac.view().insert(sleOffer); return true; @@ -1855,31 +1858,31 @@ class Invariants_test : public beast::unit_test::suite { Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, {{"hybrid offer is malformed"}}, - [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&pd1](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); sleOffer->setFlag(lsfHybrid); sleOffer->setFieldH256(sfDomainID, pd1); STArray bookArr; - bookArr.push_back(STObject::makeInnerObject(sfBook)); - bookArr.push_back(STObject::makeInnerObject(sfBook)); + bookArr.pushBack(STObject::makeInnerObject(sfBook)); + bookArr.pushBack(STObject::makeInnerObject(sfBook)); sleOffer->setFieldArray(sfAdditionalBooks, bookArr); ac.view().insert(sleOffer); return true; @@ -1893,25 +1896,25 @@ class Invariants_test : public beast::unit_test::suite { Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, fixS313Enabled ? std::vector{{"hybrid offer is malformed"}} : std::vector{}, - [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&pd1](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); sleOffer->setFlag(lsfHybrid); sleOffer->setFieldH256(sfDomainID, pd1); @@ -1932,24 +1935,24 @@ class Invariants_test : public beast::unit_test::suite { Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, {{"hybrid offer is malformed"}}, - [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&pd1](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); sleOffer->setFlag(lsfHybrid); sleOffer->setFieldH256(sfDomainID, pd1); @@ -1964,25 +1967,25 @@ class Invariants_test : public beast::unit_test::suite { Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); - [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, {{"transaction consumed wrong domains"}}, - [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&pd1](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); sleOffer->setFieldH256(sfDomainID, pd1); ac.view().insert(sleOffer); @@ -1991,9 +1994,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ ttOFFER_CREATE, - [&pd2, &A1](STObject& tx) { + [&pd2, &a1](STObject& tx) { tx.setFieldH256(sfDomainID, pd2); - tx.setFieldAmount(sfTakerPays, A1["USD"](10)); + tx.setFieldAmount(sfTakerPays, a1["USD"](10)); tx.setFieldAmount(sfTakerGets, XRP(1)); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); @@ -2002,24 +2005,24 @@ class Invariants_test : public beast::unit_test::suite { Env env1(*this, features); - Account const A1{"A1"}; - Account const A2{"A2"}; - env1.fund(XRP(1000), A1, A2); + Account const a1{"A1"}; + Account const a2{"A2"}; + env1.fund(XRP(1000), a1, a2); env1.close(); - [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, a1, a2); env1.close(); doInvariantCheck( std::move(env1), - A1, - A2, + a1, + a2, {{"domain transaction affected regular offers"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const offerKey = keylet::offer(A2.id(), 10); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(a2.id(), 10); auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setAccountID(sfAccount, a2); + sleOffer->setFieldAmount(sfTakerPays, a1["USD"](10)); sleOffer->setFieldAmount(sfTakerGets, XRP(1)); ac.view().insert(sleOffer); return true; @@ -2028,9 +2031,9 @@ class Invariants_test : public beast::unit_test::suite STTx{ ttOFFER_CREATE, [&](STObject& tx) { - Account const A1{"A1"}; + Account const a1{"A1"}; tx.setFieldH256(sfDomainID, pd1); - tx.setFieldAmount(sfTakerPays, A1["USD"](10)); + tx.setFieldAmount(sfTakerPays, a1["USD"](10)); tx.setFieldAmount(sfTakerGets, XRP(1)); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); @@ -2056,7 +2059,7 @@ class Invariants_test : public beast::unit_test::suite auto const loanBrokerKeylet = keylet::loanbroker(a.id(), env.seq(a)); // Create a Loan Broker with all default values. - env(set(a, vaultID), fee(increment)); + env(set(a, vaultID), Fee(kINCREMENT)); return loanBrokerKeylet; }; @@ -2095,7 +2098,7 @@ class Invariants_test : public beast::unit_test::suite { doInvariantCheck( {{"changed an unchangeable field"}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { + [&](Account const& a1, Account const&, ApplyContext& ac) { auto sle = ac.view().peek(loanBrokerKeylet); if (!sle) return false; @@ -2122,8 +2125,8 @@ class Invariants_test : public beast::unit_test::suite { doInvariantCheck( {{"changed an unchangeable field"}}, - [&](Account const& A1, Account const&, ApplyContext& ac) { - auto sle = ac.view().peek(keylet::account(A1.id())); + [&](Account const& a1, Account const&, ApplyContext& ac) { + auto sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; mod(sle); @@ -2160,7 +2163,7 @@ class Invariants_test : public beast::unit_test::suite return iouAsset; } case Asset::MPT: { - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); PrettyAsset const mptAsset = mptt.issuanceID(); mptt.authorize({.account = alice}); @@ -2185,7 +2188,7 @@ class Invariants_test : public beast::unit_test::suite // Ensure the test scenarios are set up completely. The test cases // will need to recompute any of these values it needs for itself // rather than trying to return a bunch of items - auto setupTest = [&, this](Account const& A1, Account const&, ApplyContext& ac) + auto setupTest = [&, this](Account const& a1, Account const&, ApplyContext& ac) -> std::optional> { if (loanBrokerKeylet.type != ltLOAN_BROKER) return {}; @@ -2226,8 +2229,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Loan Broker with zero OwnerCount has multiple directory " "pages"}}, - [&setupTest, this](Account const& A1, Account const& A2, ApplyContext& ac) { - auto test = setupTest(A1, A2, ac); + [&setupTest, this](Account const& a1, Account const& a2, ApplyContext& ac) { + auto test = setupTest(a1, a2, ac); if (!test || !test->first || !test->second) return false; @@ -2256,8 +2259,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Loan Broker with zero OwnerCount has multiple indexes in " "the Directory root"}}, - [&setupTest](Account const& A1, Account const& A2, ApplyContext& ac) { - auto test = setupTest(A1, A2, ac); + [&setupTest](Account const& a1, Account const& a2, ApplyContext& ac) { + auto test = setupTest(a1, a2, ac); if (!test || !test->first || !test->second) return false; @@ -2280,8 +2283,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Loan Broker directory corrupt"}}, - [&setupTest](Account const& A1, Account const& A2, ApplyContext& ac) { - auto test = setupTest(A1, A2, ac); + [&setupTest](Account const& a1, Account const& a2, ApplyContext& ac) { + auto test = setupTest(a1, a2, ac); if (!test || !test->first || !test->second) return false; @@ -2307,8 +2310,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Loan Broker with zero OwnerCount has an unexpected entry in " "the directory"}}, - [&setupTest](Account const& A1, Account const& A2, ApplyContext& ac) { - auto test = setupTest(A1, A2, ac); + [&setupTest](Account const& a1, Account const& a2, ApplyContext& ac) { + auto test = setupTest(a1, a2, ac); if (!test || !test->first || !test->second) return false; @@ -2331,7 +2334,7 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {{"Loan Broker sequence number decreased"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { if (loanBrokerKeylet.type != ltLOAN_BROKER) return false; auto sleBroker = ac.view().peek(loanBrokerKeylet); @@ -2427,7 +2430,7 @@ class Invariants_test : public beast::unit_test::suite std::optional accountShares = std::nullopt; // NOLINTEND(readability-redundant-member-init) }; - auto constexpr adjust = [&](ApplyView& ac, xrpl::Keylet keylet, Adjustments args) { + auto constexpr kADJUST = [&](ApplyView& ac, xrpl::Keylet keylet, Adjustments args) { auto sleVault = ac.peek(keylet); if (!sleVault) return false; @@ -2526,7 +2529,7 @@ class Invariants_test : public beast::unit_test::suite return true; }; - constexpr auto args = [](AccountID id, int adjustment, auto fn) -> Adjustments { + constexpr auto kARGS = [](AccountID id, int adjustment, auto fn) -> Adjustments { Adjustments sample = { .assetsTotal = adjustment, .assetsAvailable = adjustment, @@ -2541,24 +2544,24 @@ class Invariants_test : public beast::unit_test::suite return sample; }; - Account const A3{"A3"}; - Account const A4{"A4"}; - auto const precloseXrp = [&](Account const& A1, Account const& A2, Env& env) -> bool { - env.fund(XRP(1000), A3, A4); + Account const a3{"A3"}; + Account const a4{"A4"}; + auto const precloseXrp = [&](Account const& a1, Account const& a2, Env& env) -> bool { + env.fund(XRP(1000), a3, a4); Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); - env(vault.deposit({.depositor = A1, .id = keylet.key, .amount = XRP(10)})); - env(vault.deposit({.depositor = A2, .id = keylet.key, .amount = XRP(10)})); - env(vault.deposit({.depositor = A3, .id = keylet.key, .amount = XRP(10)})); + env(vault.deposit({.depositor = a1, .id = keylet.key, .amount = XRP(10)})); + env(vault.deposit({.depositor = a2, .id = keylet.key, .amount = XRP(10)})); + env(vault.deposit({.depositor = a3, .id = keylet.key, .amount = XRP(10)})); return true; }; testcase << "Vault general checks"; doInvariantCheck( {"vault deletion succeeded without deleting a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2568,17 +2571,17 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_DELETE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault updated by a wrong transaction type"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2588,17 +2591,17 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttPAYMENT, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault updated by a wrong transaction type"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2608,21 +2611,21 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttPAYMENT, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault updated by a wrong transaction type"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { auto const sequence = ac.view().seq(); - auto const vaultKeylet = keylet::vault(A1.id(), sequence); + auto const vaultKeylet = keylet::vault(a1.id(), sequence); auto sleVault = std::make_shared(vaultKeylet); auto const vaultPage = ac.view().dirInsert( - keylet::ownerDir(A1.id()), sleVault->key(), describeOwnerDir(A1.id())); + keylet::ownerDir(a1.id()), sleVault->key(), describeOwnerDir(a1.id())); sleVault->setFieldU64(sfOwnerNode, *vaultPage); ac.view().insert(sleVault); return true; @@ -2633,8 +2636,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"vault deleted by a wrong transaction type"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2644,25 +2647,25 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_SET, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault operation updated more than single vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; ac.view().erase(sleVault); } { - auto const keylet = keylet::vault(A2.id(), ac.view().seq()); + auto const keylet = keylet::vault(a2.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2673,14 +2676,14 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_DELETE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; { - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); } { - auto [tx, _] = vault.create({.owner = A2, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a2, .asset = xrpIssue()}); env(tx); } return true; @@ -2688,18 +2691,18 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"vault operation updated more than single vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { auto const sequence = ac.view().seq(); - auto const insertVault = [&](Account const A) { - auto const vaultKeylet = keylet::vault(A.id(), sequence); + auto const insertVault = [&](Account const a) { + auto const vaultKeylet = keylet::vault(a.id(), sequence); auto sleVault = std::make_shared(vaultKeylet); auto const vaultPage = ac.view().dirInsert( - keylet::ownerDir(A.id()), sleVault->key(), describeOwnerDir(A.id())); + keylet::ownerDir(a.id()), sleVault->key(), describeOwnerDir(a.id())); sleVault->setFieldU64(sfOwnerNode, *vaultPage); ac.view().insert(sleVault); }; - insertVault(A1); - insertVault(A2); + insertVault(a1); + insertVault(a2); return true; }, XRPAmount{}, @@ -2708,8 +2711,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deleted vault must also delete shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2719,9 +2722,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_DELETE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -2730,8 +2733,8 @@ class Invariants_test : public beast::unit_test::suite {"deleted vault must have no shares outstanding", "deleted vault must have no assets outstanding", "deleted vault must have no assets available"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2745,18 +2748,18 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_DELETE, [](STObject&) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); - env(vault.deposit({.depositor = A1, .id = keylet.key, .amount = XRP(10)})); + env(vault.deposit({.depositor = a1, .id = keylet.key, .amount = XRP(10)})); return true; }); doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2777,73 +2780,73 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { return true; }, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { return true; }, XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { return true; }, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { return true; }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { return true; }, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { return true; }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { return true; }, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { return true; }, XRPAmount{}, STTx{ttVAULT_CLAWBACK, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault operation succeeded without modifying a vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { return true; }, + [&](Account const& a1, Account const& a2, ApplyContext& ac) { return true; }, XRPAmount{}, STTx{ttVAULT_DELETE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"updated vault must have shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2859,9 +2862,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_SET, [](STObject&) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, _] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, _] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -2869,8 +2872,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"vault operation succeeded without updating shares", "assets available must not be greater than assets outstanding"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2881,11 +2884,11 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); - env(vault.deposit({.depositor = A1, .id = keylet.key, .amount = XRP(10)})); + env(vault.deposit({.depositor = a1, .id = keylet.key, .amount = XRP(10)})); return true; }); @@ -2897,8 +2900,8 @@ class Invariants_test : public beast::unit_test::suite "assets available must be positive", "assets available must not be greater than assets outstanding", "assets outstanding must be positive"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2909,17 +2912,17 @@ class Invariants_test : public beast::unit_test::suite ac.view().update(slePseudoAccount); // Move 10 drops to A4 to enforce total XRP balance - auto sleA4 = ac.view().peek(keylet::account(A4.id())); + auto sleA4 = ac.view().peek(keylet::account(a4.id())); if (!sleA4) return false; (*sleA4)[sfBalance] = *(*sleA4)[sfBalance] + 10; ac.view().update(sleA4); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) { - sample.assetsAvailable = (DROPS_PER_XRP * -100).value(); - sample.assetsTotal = (DROPS_PER_XRP * -200).value(); - sample.sharesTotal = -1; - })); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) { + sample.assetsAvailable = (kDROPS_PER_XRP * -100).value(); + sample.assetsTotal = (kDROPS_PER_XRP * -200).value(); + sample.sharesTotal = -1; + })); }, XRPAmount{}, STTx{ttVAULT_SET, [](STObject& tx) {}}, @@ -2929,8 +2932,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"violation of vault immutable data"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2945,12 +2948,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"violation of vault immutable data"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; - sleVault->setAccountID(sfAccount, A2.id()); + sleVault->setAccountID(sfAccount, a2.id()); ac.view().update(sleVault); return true; }, @@ -2961,8 +2964,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"violation of vault immutable data"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -2978,12 +2981,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"vault transaction must not change loss unrealized", "set must not change assets outstanding"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) { - sample.lossUnrealized = 13; - sample.assetsTotal = 20; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) { + sample.lossUnrealized = 13; + sample.assetsTotal = 20; + })); }, XRPAmount{}, STTx{ttVAULT_SET, [](STObject& tx) {}}, @@ -2995,11 +2998,11 @@ class Invariants_test : public beast::unit_test::suite {"loss unrealized must not exceed the difference " "between assets outstanding and available", "vault transaction must not change loss unrealized"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 100, [&](Adjustments& sample) { - sample.lossUnrealized = 13; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 100, [&](Adjustments& sample) { + sample.lossUnrealized = 13; + })); }, XRPAmount{}, STTx{ @@ -3010,11 +3013,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"set assets outstanding must not exceed assets maximum"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) { - sample.assetsMaximum = 1; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) { + sample.assetsMaximum = 1; + })); }, XRPAmount{}, STTx{ttVAULT_SET, [](STObject& tx) {}}, @@ -3024,11 +3027,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"assets maximum must be positive"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) { - sample.assetsMaximum = -1; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) { + sample.assetsMaximum = -1; + })); }, XRPAmount{}, STTx{ttVAULT_SET, [](STObject& tx) {}}, @@ -3040,8 +3043,8 @@ class Invariants_test : public beast::unit_test::suite {"set must not change shares outstanding", "updated zero sized vault must have no assets outstanding", "updated zero sized vault must have no assets available"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3061,8 +3064,8 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"updated shares must not exceed maximum"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3072,7 +3075,7 @@ class Invariants_test : public beast::unit_test::suite (*sleShares)[sfMaximumAmount] = 10; ac.view().update(sleShares); - return adjust(ac.view(), keylet, args(A2.id(), 10, [](Adjustments&) {})); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [](Adjustments&) {})); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject&) {}}, @@ -3082,9 +3085,9 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"updated shares must not exceed maximum"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - adjust(ac.view(), keylet, args(A2.id(), 10, [](Adjustments&) {})); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [](Adjustments&) {})); auto sleVault = ac.view().peek(keylet); if (!sleVault) @@ -3092,7 +3095,7 @@ class Invariants_test : public beast::unit_test::suite auto sleShares = ac.view().peek(keylet::mptIssuance((*sleVault)[sfShareMPTID])); if (!sleShares) return false; - (*sleShares)[sfOutstandingAmount] = maxMPTokenAmount + 1; + (*sleShares)[sfOutstandingAmount] = kMAX_MP_TOKEN_AMOUNT + 1; ac.view().update(sleShares); return true; }, @@ -3109,8 +3112,8 @@ class Invariants_test : public beast::unit_test::suite "updated zero sized vault must have no assets outstanding", "create operation must not have updated a vault", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3121,9 +3124,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -3135,8 +3138,8 @@ class Invariants_test : public beast::unit_test::suite "assets available must not be greater than assets outstanding", "create operation must not have updated a vault", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3147,9 +3150,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -3162,8 +3165,8 @@ class Invariants_test : public beast::unit_test::suite "vault transaction must not change loss unrealized", "create operation must not have updated a vault", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3174,9 +3177,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -3186,8 +3189,8 @@ class Invariants_test : public beast::unit_test::suite "created vault must be empty", "create operation must not have updated a vault", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3202,9 +3205,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -3214,8 +3217,8 @@ class Invariants_test : public beast::unit_test::suite "assets maximum must be positive", "create operation must not have updated a vault", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3226,9 +3229,9 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); @@ -3238,8 +3241,8 @@ class Invariants_test : public beast::unit_test::suite "shares issuer and vault pseudo-account must be the same", "shares issuer must be a pseudo-account", "shares issuer pseudo-account must point back to the vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); auto sleVault = ac.view().peek(keylet); if (!sleVault) return false; @@ -3247,31 +3250,31 @@ class Invariants_test : public beast::unit_test::suite if (!sleShares) return false; ac.view().update(sleVault); - (*sleShares)[sfIssuer] = A1.id(); + (*sleShares)[sfIssuer] = a1.id(); ac.view().update(sleShares); return true; }, XRPAmount{}, STTx{ttVAULT_CREATE, [](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = xrpIssue()}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = xrpIssue()}); env(tx); return true; }); doInvariantCheck( {"vault created by a wrong transaction type", "account root created illegally"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { // The code below will create a valid vault with (almost) all // the invariants holding. Except one: it is created by the // wrong transaction type. auto const sequence = ac.view().seq(); - auto const vaultKeylet = keylet::vault(A1.id(), sequence); + auto const vaultKeylet = keylet::vault(a1.id(), sequence); auto sleVault = std::make_shared(vaultKeylet); auto const vaultPage = ac.view().dirInsert( - keylet::ownerDir(A1.id()), sleVault->key(), describeOwnerDir(A1.id())); + keylet::ownerDir(a1.id()), sleVault->key(), describeOwnerDir(a1.id())); sleVault->setFieldU64(sfOwnerNode, *vaultPage); auto pseudoId = pseudoAccountAddress(ac.view(), vaultKeylet.key); @@ -3304,12 +3307,12 @@ class Invariants_test : public beast::unit_test::suite sleVault->at(sfAccount) = pseudoId; sleVault->at(sfFlags) = 0; sleVault->at(sfSequence) = sequence; - sleVault->at(sfOwner) = A1.id(); + sleVault->at(sfOwner) = a1.id(); sleVault->at(sfAssetsTotal) = Number(0); sleVault->at(sfAssetsAvailable) = Number(0); sleVault->at(sfLossUnrealized) = Number(0); sleVault->at(sfShareMPTID) = sharesMptId; - sleVault->at(sfWithdrawalPolicy) = vaultStrategyFirstComeFirstServe; + sleVault->at(sfWithdrawalPolicy) = kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE; ac.view().insert(sleVault); ac.view().insert(sleShares); @@ -3322,12 +3325,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"shares issuer and vault pseudo-account must be the same", "shares issuer pseudo-account must point back to the vault"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { auto const sequence = ac.view().seq(); - auto const vaultKeylet = keylet::vault(A1.id(), sequence); + auto const vaultKeylet = keylet::vault(a1.id(), sequence); auto sleVault = std::make_shared(vaultKeylet); auto const vaultPage = ac.view().dirInsert( - keylet::ownerDir(A1.id()), sleVault->key(), describeOwnerDir(A1.id())); + keylet::ownerDir(a1.id()), sleVault->key(), describeOwnerDir(a1.id())); sleVault->setFieldU64(sfOwnerNode, *vaultPage); auto pseudoId = pseudoAccountAddress(ac.view(), vaultKeylet.key); @@ -3361,15 +3364,15 @@ class Invariants_test : public beast::unit_test::suite // sleVault->at(sfAccount) = pseudoId; // Setting wrong pseudo account ID - sleVault->at(sfAccount) = A2.id(); + sleVault->at(sfAccount) = a2.id(); sleVault->at(sfFlags) = 0; sleVault->at(sfSequence) = sequence; - sleVault->at(sfOwner) = A1.id(); + sleVault->at(sfOwner) = a1.id(); sleVault->at(sfAssetsTotal) = Number(0); sleVault->at(sfAssetsAvailable) = Number(0); sleVault->at(sfLossUnrealized) = Number(0); sleVault->at(sfShareMPTID) = sharesMptId; - sleVault->at(sfWithdrawalPolicy) = vaultStrategyFirstComeFirstServe; + sleVault->at(sfWithdrawalPolicy) = kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE; ac.view().insert(sleVault); ac.view().insert(sleShares); @@ -3381,19 +3384,19 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"shares issuer and vault pseudo-account must be the same", "shares issuer must exist"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { + [&](Account const& a1, Account const& a2, ApplyContext& ac) { auto const sequence = ac.view().seq(); - auto const vaultKeylet = keylet::vault(A1.id(), sequence); + auto const vaultKeylet = keylet::vault(a1.id(), sequence); auto sleVault = std::make_shared(vaultKeylet); auto const vaultPage = ac.view().dirInsert( - keylet::ownerDir(A1.id()), sleVault->key(), describeOwnerDir(A1.id())); + keylet::ownerDir(a1.id()), sleVault->key(), describeOwnerDir(a1.id())); sleVault->setFieldU64(sfOwnerNode, *vaultPage); - auto const sharesMptId = makeMptID(sequence, A2.id()); + auto const sharesMptId = makeMptID(sequence, a2.id()); auto const sharesKeylet = keylet::mptIssuance(sharesMptId); auto sleShares = std::make_shared(sharesKeylet); auto const sharesPage = ac.view().dirInsert( - keylet::ownerDir(A2.id()), sharesKeylet, describeOwnerDir(A2.id())); + keylet::ownerDir(a2.id()), sharesKeylet, describeOwnerDir(a2.id())); sleShares->setFieldU64(sfOwnerNode, *sharesPage); sleShares->at(sfFlags) = 0; @@ -3402,15 +3405,15 @@ class Invariants_test : public beast::unit_test::suite sleShares->at(sfOutstandingAmount) = 0; sleShares->at(sfSequence) = sequence; - sleVault->at(sfAccount) = A2.id(); + sleVault->at(sfAccount) = a2.id(); sleVault->at(sfFlags) = 0; sleVault->at(sfSequence) = sequence; - sleVault->at(sfOwner) = A1.id(); + sleVault->at(sfOwner) = a1.id(); sleVault->at(sfAssetsTotal) = Number(0); sleVault->at(sfAssetsAvailable) = Number(0); sleVault->at(sfLossUnrealized) = Number(0); sleVault->at(sfShareMPTID) = sharesMptId; - sleVault->at(sfWithdrawalPolicy) = vaultStrategyFirstComeFirstServe; + sleVault->at(sfWithdrawalPolicy) = kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE; ac.view().insert(sleVault); ac.view().insert(sleShares); @@ -3423,11 +3426,11 @@ class Invariants_test : public beast::unit_test::suite testcase << "Vault deposit"; doInvariantCheck( {"deposit must change vault balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [](Adjustments& sample) { - sample.vaultAssets.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [](Adjustments& sample) { + sample.vaultAssets.reset(); + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject&) {}}, @@ -3436,11 +3439,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit assets outstanding must not exceed assets maximum"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 200, [&](Adjustments& sample) { - sample.assetsMaximum = 1; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 200, [&](Adjustments& sample) { + sample.assetsMaximum = 1; + })); }, XRPAmount{}, STTx{ @@ -3455,26 +3458,26 @@ class Invariants_test : public beast::unit_test::suite // ValidVault::finalize is otherwise impossible to trigger. doInvariantCheck( {"deposit must increase vault balance", "deposit must change depositor balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); // Move 10 drops to A4 to enforce total XRP balance - auto sleA4 = ac.view().peek(keylet::account(A4.id())); + auto sleA4 = ac.view().peek(keylet::account(a4.id())); if (!sleA4) return false; (*sleA4)[sfBalance] = *(*sleA4)[sfBalance] + 10; ac.view().update(sleA4); - return adjust(ac.view(), keylet, args(A3.id(), -10, [&](Adjustments& sample) { - sample.accountAssets->amount = -100; - })); + return kADJUST(ac.view(), keylet, kARGS(a3.id(), -10, [&](Adjustments& sample) { + sample.accountAssets->amount = -100; + })); }, XRPAmount{100}, STTx{ ttVAULT_DEPOSIT, [&](STObject& tx) { tx[sfFee] = XRPAmount(100); - tx[sfAccount] = A3.id(); + tx[sfAccount] = a3.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseXrp); @@ -3485,20 +3488,20 @@ class Invariants_test : public beast::unit_test::suite "deposit must change vault and depositor balance by equal amount", "deposit and assets outstanding must add up", "deposit and assets available must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); // Move 10 drops from A2 to A3 to enforce total XRP balance - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + auto sleA3 = ac.view().peek(keylet::account(a3.id())); if (!sleA3) return false; (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] + 10; ac.view().update(sleA3); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.vaultAssets = -20; - sample.accountAssets->amount = 10; - })); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.vaultAssets = -20; + sample.accountAssets->amount = 10; + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(10); }}, @@ -3508,19 +3511,19 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit must change depositor balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); // Move 10 drops from A3 to vault to enforce total XRP balance - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + auto sleA3 = ac.view().peek(keylet::account(a3.id())); if (!sleA3) return false; (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] - 10; ac.view().update(sleA3); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.accountAssets->amount = 0; - })); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.accountAssets->amount = 0; + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(10); }}, @@ -3530,11 +3533,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit must change depositor shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.accountShares.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.accountShares.reset(); + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(10); }}, @@ -3544,12 +3547,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit must change vault shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 10, [](Adjustments& sample) { - sample.sharesTotal = 0; - })); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [](Adjustments& sample) { + sample.sharesTotal = 0; + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(10); }}, @@ -3562,12 +3565,12 @@ class Invariants_test : public beast::unit_test::suite "deposit must change depositor and vault shares by equal amount", "deposit must not change vault balance by more than deposited " "amount"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.accountShares->amount = -5; - sample.sharesTotal = -10; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.accountShares->amount = -5; + sample.sharesTotal = -10; + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(5); }}, @@ -3577,22 +3580,22 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit and assets outstanding must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto sleA3 = ac.view().peek(keylet::account(a3.id())); (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] - 2000; ac.view().update(sleA3); - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.assetsTotal = 11; - })); + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.assetsTotal = 11; + })); }, XRPAmount{2000}, STTx{ ttVAULT_DEPOSIT, [&](STObject& tx) { tx[sfAmount] = XRPAmount(10); - tx[sfDelegate] = A3.id(); + tx[sfDelegate] = a3.id(); tx[sfFee] = XRPAmount(2000); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, @@ -3602,12 +3605,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"deposit and assets outstanding must add up", "deposit and assets available must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 10, [&](Adjustments& sample) { - sample.assetsTotal = 7; - sample.assetsAvailable = 7; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 10, [&](Adjustments& sample) { + sample.assetsTotal = 7; + sample.assetsAvailable = 7; + })); }, XRPAmount{}, STTx{ttVAULT_DEPOSIT, [](STObject& tx) { tx[sfAmount] = XRPAmount(10); }}, @@ -3618,11 +3621,11 @@ class Invariants_test : public beast::unit_test::suite testcase << "Vault withdrawal"; doInvariantCheck( {"withdrawal must change vault balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [](Adjustments& sample) { - sample.vaultAssets.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [](Adjustments& sample) { + sample.vaultAssets.reset(); + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3635,26 +3638,26 @@ class Invariants_test : public beast::unit_test::suite // sfDestination would have been A4, but has been omitted. doInvariantCheck( {"withdrawal must change one destination balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); // Move 10 drops to A4 to enforce total XRP balance - auto sleA4 = ac.view().peek(keylet::account(A4.id())); + auto sleA4 = ac.view().peek(keylet::account(a4.id())); if (!sleA4) return false; (*sleA4)[sfBalance] = *(*sleA4)[sfBalance] + 10; ac.view().update(sleA4); - return adjust(ac.view(), keylet, args(A3.id(), -10, [&](Adjustments& sample) { - sample.accountAssets->amount = -100; - })); + return kADJUST(ac.view(), keylet, kARGS(a3.id(), -10, [&](Adjustments& sample) { + sample.accountAssets->amount = -100; + })); }, XRPAmount{100}, STTx{ ttVAULT_WITHDRAW, [&](STObject& tx) { tx[sfFee] = XRPAmount(100); - tx[sfAccount] = A3.id(); + tx[sfAccount] = a3.id(); // This commented out line causes the invariant violation. // tx[sfDestination] = A4.id(); }}, @@ -3669,20 +3672,20 @@ class Invariants_test : public beast::unit_test::suite "withdrawal and assets outstanding must add up", "withdrawal and assets available must add up", }, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); // Move 10 drops from A2 to A3 to enforce total XRP balance - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + auto sleA3 = ac.view().peek(keylet::account(a3.id())); if (!sleA3) return false; (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] + 10; ac.view().update(sleA3); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.vaultAssets = 10; - sample.accountAssets->amount = -20; - })); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.vaultAssets = 10; + sample.accountAssets->amount = -20; + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3692,13 +3695,13 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"withdrawal must change one destination balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - if (!adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - *sample.vaultAssets -= 5; - }))) + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + if (!kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + *sample.vaultAssets -= 5; + }))) return false; - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + auto sleA3 = ac.view().peek(keylet::account(a3.id())); if (!sleA3) return false; (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] + 5; @@ -3706,18 +3709,18 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttVAULT_WITHDRAW, [&](STObject& tx) { tx.setAccountID(sfDestination, A3.id()); }}, + STTx{ttVAULT_WITHDRAW, [&](STObject& tx) { tx.setAccountID(sfDestination, a3.id()); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseXrp, TxAccount::A2); doInvariantCheck( {"withdrawal must change depositor shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.accountShares.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.accountShares.reset(); + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3727,11 +3730,11 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"withdrawal must change vault shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), -10, [](Adjustments& sample) { - sample.sharesTotal = 0; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [](Adjustments& sample) { + sample.sharesTotal = 0; + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3743,12 +3746,12 @@ class Invariants_test : public beast::unit_test::suite {"withdrawal must decrease depositor shares", "withdrawal must change depositor and vault shares by equal " "amount"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.accountShares->amount = 5; - sample.sharesTotal = 10; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.accountShares->amount = 5; + sample.sharesTotal = 10; + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3759,12 +3762,12 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"withdrawal and assets outstanding must add up", "withdrawal and assets available must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.assetsTotal = -15; - sample.assetsAvailable = -15; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.assetsTotal = -15; + sample.assetsAvailable = -15; + })); }, XRPAmount{}, STTx{ttVAULT_WITHDRAW, [](STObject&) {}}, @@ -3774,71 +3777,71 @@ class Invariants_test : public beast::unit_test::suite doInvariantCheck( {"withdrawal and assets outstanding must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto sleA3 = ac.view().peek(keylet::account(A3.id())); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto sleA3 = ac.view().peek(keylet::account(a3.id())); (*sleA3)[sfBalance] = *(*sleA3)[sfBalance] - 2000; ac.view().update(sleA3); - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.assetsTotal = -7; - })); + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.assetsTotal = -7; + })); }, XRPAmount{2000}, STTx{ ttVAULT_WITHDRAW, [&](STObject& tx) { tx[sfAmount] = XRPAmount(10); - tx[sfDelegate] = A3.id(); + tx[sfDelegate] = a3.id(); tx[sfFee] = XRPAmount(2000); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseXrp, TxAccount::A2); - auto const precloseMpt = [&](Account const& A1, Account const& A2, Env& env) -> bool { - env.fund(XRP(1000), A3, A4); + auto const precloseMpt = [&](Account const& a1, Account const& a2, Env& env) -> bool { + env.fund(XRP(1000), a3, a4); // Create MPT asset { - Json::Value jv; - jv[sfAccount] = A3.human(); + json::Value jv; + jv[sfAccount] = a3.human(); jv[sfTransactionType] = jss::MPTokenIssuanceCreate; jv[sfFlags] = tfMPTCanTransfer; env(jv); env.close(); } - auto const mptID = makeMptID(env.seq(A3) - 1, A3); + auto const mptID = makeMptID(env.seq(a3) - 1, a3); Asset const asset = MPTIssue(mptID); // Authorize A1 A2 A4 { - Json::Value jv; - jv[sfAccount] = A1.human(); + json::Value jv; + jv[sfAccount] = a1.human(); jv[sfTransactionType] = jss::MPTokenAuthorize; jv[sfMPTokenIssuanceID] = to_string(mptID); env(jv); - jv[sfAccount] = A2.human(); + jv[sfAccount] = a2.human(); env(jv); - jv[sfAccount] = A4.human(); + jv[sfAccount] = a4.human(); env(jv); env.close(); } // Send tokens to A1 A2 A4 { - env(pay(A3, A1, asset(1000))); - env(pay(A3, A2, asset(1000))); - env(pay(A3, A4, asset(1000))); + env(pay(a3, a1, asset(1000))); + env(pay(a3, a2, asset(1000))); + env(pay(a3, a4, asset(1000))); env.close(); } Vault const vault{env}; - auto [tx, keylet] = vault.create({.owner = A1, .asset = asset}); + auto [tx, keylet] = vault.create({.owner = a1, .asset = asset}); env(tx); - env(vault.deposit({.depositor = A1, .id = keylet.key, .amount = asset(10)})); - env(vault.deposit({.depositor = A2, .id = keylet.key, .amount = asset(10)})); - env(vault.deposit({.depositor = A4, .id = keylet.key, .amount = asset(10)})); + env(vault.deposit({.depositor = a1, .id = keylet.key, .amount = asset(10)})); + env(vault.deposit({.depositor = a2, .id = keylet.key, .amount = asset(10)})); + env(vault.deposit({.depositor = a4, .id = keylet.key, .amount = asset(10)})); return true; }; @@ -3846,14 +3849,14 @@ class Invariants_test : public beast::unit_test::suite {"withdrawal must decrease depositor shares", "withdrawal must change depositor and vault shares by equal " "amount"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A2.id(), -10, [&](Adjustments& sample) { - sample.accountShares->amount = 5; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -10, [&](Adjustments& sample) { + sample.accountShares->amount = 5; + })); }, XRPAmount{}, - STTx{ttVAULT_WITHDRAW, [&](STObject& tx) { tx[sfAccount] = A3.id(); }}, + STTx{ttVAULT_WITHDRAW, [&](STObject& tx) { tx[sfAccount] = a3.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt, TxAccount::A2); @@ -3861,23 +3864,23 @@ class Invariants_test : public beast::unit_test::suite testcase << "Vault clawback"; doInvariantCheck( {"clawback must change vault balance"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A2.id(), -1, [&](Adjustments& sample) { - sample.vaultAssets.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), -1, [&](Adjustments& sample) { + sample.vaultAssets.reset(); + })); }, XRPAmount{}, - STTx{ttVAULT_CLAWBACK, [&](STObject& tx) { tx[sfAccount] = A3.id(); }}, + STTx{ttVAULT_CLAWBACK, [&](STObject& tx) { tx[sfAccount] = a3.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt); // Not the same as below check: attempt to clawback XRP doInvariantCheck( {"clawback may only be performed by the asset issuer"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq()); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) {})); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq()); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) {})); }, XRPAmount{}, STTx{ttVAULT_CLAWBACK, [](STObject&) {}}, @@ -3887,12 +3890,12 @@ class Invariants_test : public beast::unit_test::suite // Not the same as above check: attempt to clawback MPT by bad account doInvariantCheck( {"clawback may only be performed by the asset issuer"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A2.id(), 0, [&](Adjustments& sample) {})); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a2.id(), 0, [&](Adjustments& sample) {})); }, XRPAmount{}, - STTx{ttVAULT_CLAWBACK, [&](STObject& tx) { tx[sfAccount] = A4.id(); }}, + STTx{ttVAULT_CLAWBACK, [&](STObject& tx) { tx[sfAccount] = a4.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt); @@ -3900,36 +3903,36 @@ class Invariants_test : public beast::unit_test::suite {"clawback must decrease vault balance", "clawback must decrease holder shares", "clawback must change vault shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A4.id(), 10, [&](Adjustments& sample) { - sample.sharesTotal = 0; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a4.id(), 10, [&](Adjustments& sample) { + sample.sharesTotal = 0; + })); }, XRPAmount{}, STTx{ ttVAULT_CLAWBACK, [&](STObject& tx) { - tx[sfAccount] = A3.id(); - tx[sfHolder] = A4.id(); + tx[sfAccount] = a3.id(); + tx[sfHolder] = a4.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt); doInvariantCheck( {"clawback must change holder shares"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A4.id(), -10, [&](Adjustments& sample) { - sample.accountShares.reset(); - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a4.id(), -10, [&](Adjustments& sample) { + sample.accountShares.reset(); + })); }, XRPAmount{}, STTx{ ttVAULT_CLAWBACK, [&](STObject& tx) { - tx[sfAccount] = A3.id(); - tx[sfHolder] = A4.id(); + tx[sfAccount] = a3.id(); + tx[sfHolder] = a4.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt); @@ -3938,20 +3941,20 @@ class Invariants_test : public beast::unit_test::suite {"clawback must change holder and vault shares by equal amount", "clawback and assets outstanding must add up", "clawback and assets available must add up"}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const keylet = keylet::vault(A1.id(), ac.view().seq() - 2); - return adjust(ac.view(), keylet, args(A4.id(), -10, [&](Adjustments& sample) { - sample.accountShares->amount = -8; - sample.assetsTotal = -7; - sample.assetsAvailable = -7; - })); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const keylet = keylet::vault(a1.id(), ac.view().seq() - 2); + return kADJUST(ac.view(), keylet, kARGS(a4.id(), -10, [&](Adjustments& sample) { + sample.accountShares->amount = -8; + sample.assetsTotal = -7; + sample.assetsAvailable = -7; + })); }, XRPAmount{}, STTx{ ttVAULT_CLAWBACK, [&](STObject& tx) { - tx[sfAccount] = A3.id(); - tx[sfHolder] = A4.id(); + tx[sfAccount] = a3.id(); + tx[sfHolder] = a4.id(); }}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, precloseMpt); @@ -3966,13 +3969,13 @@ class Invariants_test : public beast::unit_test::suite // MPT OutstandingAmount > MaximumAmount doInvariantCheck( {{"OutstandingAmount overflow"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { + [](Account const& a1, Account const&, ApplyContext& ac) { // mptissuance outstanding is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), A1)}; + MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), a1)}; auto sleNew = std::make_shared(keylet::mptIssuance(mpt.getMptID())); sleNew->setFieldU64(sfOutstandingAmount, 110); sleNew->setFieldU64(sfMaximumAmount, 100); @@ -3983,19 +3986,19 @@ class Invariants_test : public beast::unit_test::suite // MPTToken amount doesn't add up to OutstandingAmount doInvariantCheck( {{"invalid OutstandingAmount balance"}}, - [](Account const& A1, Account const& A2, ApplyContext& ac) { + [](Account const& a1, Account const& a2, ApplyContext& ac) { // mptissuance outstanding is negative - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; - MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), A1)}; + MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), a1)}; auto sleNew = std::make_shared(keylet::mptIssuance(mpt.getMptID())); sleNew->setFieldU64(sfOutstandingAmount, 100); sleNew->setFieldU64(sfMaximumAmount, 100); ac.view().insert(sleNew); - sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), A2)); + sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), a2)); sleNew->setFieldU64(sfMPTAmount, 90); ac.view().insert(sleNew); @@ -4007,25 +4010,25 @@ class Invariants_test : public beast::unit_test::suite MPTID id; doInvariantCheck( {{log}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - return update(id, ac, A1); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + return update(id, ac, a1); }, XRPAmount{}, STTx{ttPAYMENT, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Account const gw("gw"); env.fund(XRP(1'000), gw); MPTTester const mpt( - {.env = env, .issuer = gw, .holders = {A1}, .pay = 100, .maxAmt = 100}); + {.env = env, .issuer = gw, .holders = {a1}, .pay = 100, .maxAmt = 100}); id = mpt.issuanceID(); return true; }); }; testPayment( "invalid OutstandingAmount balance", - [&](MPTID const& id, ApplyContext& ac, Account const& A1) { - auto sle = ac.view().peek(keylet::mptoken(id, A1)); + [&](MPTID const& id, ApplyContext& ac, Account const& a1) { + auto sle = ac.view().peek(keylet::mptoken(id, a1)); if (!sle) return false; sle->setFieldU64(sfMPTAmount, 101); @@ -4052,19 +4055,19 @@ class Invariants_test : public beast::unit_test::suite { doInvariantCheck( {{std::string("MPToken created for the MPT issuer")}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - auto const sle = ac.view().peek(keylet::account(A1.id())); + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; auto seq = sle->getFieldU32(sfSequence); for (int i = 0; i < nTokens; ++i) { - MPTIssue const mpt{makeMptID(seq + i, A1)}; + MPTIssue const mpt{makeMptID(seq + i, a1)}; auto sleNew = std::make_shared(keylet::mptIssuance(mpt.getMptID())); ac.view().insert(sleNew); - sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), A2)); + sleNew = std::make_shared(keylet::mptoken(mpt.getMptID(), a2)); ac.view().insert(sleNew); } @@ -4079,11 +4082,11 @@ class Invariants_test : public beast::unit_test::suite for (auto const& tx : {ttAMM_WITHDRAW, ttAMM_CLAWBACK}) { MPTID id; - Account const A3("A3"); + Account const a3("A3"); doInvariantCheck( {{"MPT authorize succeeded but created/deleted bad number of mptokens"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - for (auto const& a : {A1, A2, A3}) + [&](Account const& a1, Account const& a2, ApplyContext& ac) { + for (auto const& a : {a1, a2, a3}) { auto sle = ac.view().peek(keylet::mptoken(id, a)); if (!sle) @@ -4095,10 +4098,10 @@ class Invariants_test : public beast::unit_test::suite XRPAmount{}, STTx{tx, [](STObject& tx) {}}, {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, - [&](Account const& A1, Account const& A2, Env& env) { + [&](Account const& a1, Account const& a2, Env& env) { Account const gw("gw"); - env.fund(XRP(1'000), gw, A3); - MPTTester const mpt({.env = env, .issuer = gw, .holders = {A1, A2, A3}}); + env.fund(XRP(1'000), gw, a3); + MPTTester const mpt({.env = env, .issuer = gw, .holders = {a1, a2, a3}}); id = mpt.issuanceID(); return true; }); @@ -4122,21 +4125,21 @@ class Invariants_test : public beast::unit_test::suite // ApplyStateTable::visit(). The configurer callables receive the // SLE and the Issue corresponding to that side's keylet currency. auto const insertOrderedTrustLinePair = [](ApplyContext& ac, - Account const& A1, - Account const& A2, - Account const& A3, + Account const& a1, + Account const& a2, + Account const& a3, auto const& badConfig, auto const& goodConfig) { char const* const c1 = "USD"; char const* const c2 = "EUR"; - auto const k1 = keylet::line(A1, A2, A1[c1].currency); - auto const k2 = keylet::line(A1, A3, A1[c2].currency); + auto const k1 = keylet::line(a1, a2, a1[c1].currency); + auto const k2 = keylet::line(a1, a3, a1[c2].currency); bool const k1First = k1.key < k2.key; auto const& badKey = k1First ? k1 : k2; auto const& goodKey = k1First ? k2 : k1; - Issue const badIss{k1First ? A1[c1].currency : A1[c2].currency, A1.id()}; - Issue const goodIss{k1First ? A1[c2].currency : A1[c1].currency, A1.id()}; + Issue const badIss{k1First ? a1[c1].currency : a1[c2].currency, a1.id()}; + Issue const goodIss{k1First ? a1[c2].currency : a1[c1].currency, a1.id()}; auto const sleBad = std::make_shared(badKey); badConfig(*sleBad, badIss); @@ -4157,13 +4160,13 @@ class Invariants_test : public beast::unit_test::suite Env(*this, features), fixEnabled ? std::vector{{"an XRP trust line was created"}} : std::vector{}, - [&insertOrderedTrustLinePair](Account const& A1, Account const& A2, ApplyContext& ac) { - Account const A3{"A3"}; + [&insertOrderedTrustLinePair](Account const& a1, Account const& a2, ApplyContext& ac) { + Account const a3{"A3"}; insertOrderedTrustLinePair( ac, - A1, - A2, - A3, + a1, + a2, + a3, [](SLE& sle, Issue const& iss) { // sfLowLimit has xrpIssue, making isXrp = true sle.setFieldAmount(sfLowLimit, STAmount{xrpIssue(), 0}); @@ -4186,13 +4189,13 @@ class Invariants_test : public beast::unit_test::suite fixEnabled ? std::vector{{"a trust line with deep freeze flag without " "normal freeze was created"}} : std::vector{}, - [&insertOrderedTrustLinePair](Account const& A1, Account const& A2, ApplyContext& ac) { - Account const A3{"A3"}; + [&insertOrderedTrustLinePair](Account const& a1, Account const& a2, ApplyContext& ac) { + Account const a3{"A3"}; insertOrderedTrustLinePair( ac, - A1, - A2, - A3, + a1, + a2, + a3, [](SLE& sle, Issue const& iss) { sle.setFieldAmount(sfLowLimit, STAmount{iss, 0}); sle.setFieldAmount(sfHighLimit, STAmount{iss, 0}); @@ -4219,15 +4222,15 @@ class Invariants_test : public beast::unit_test::suite Env(*this, features), fixEnabled ? std::vector{{"escrow specifies invalid amount"}} : std::vector{{"a MPT issuance was created"}}, - [](Account const& A1, Account const&, ApplyContext& ac) { - auto const sle = ac.view().peek(keylet::account(A1.id())); + [](Account const& a1, Account const&, ApplyContext& ac) { + auto const sle = ac.view().peek(keylet::account(a1.id())); if (!sle) return false; MPTIssue const mpt{makeMptID(1, AccountID(0x4985601))}; auto sleNew = std::make_shared(keylet::mptIssuance(mpt.getMptID())); - // outstanding exceeds maxMPTokenAmount -> checkAmount sets bad_ - sleNew->setFieldU64(sfOutstandingAmount, maxMPTokenAmount + 1); + // outstanding exceeds kMAX_MP_TOKEN_AMOUNT -> checkAmount sets bad_ + sleNew->setFieldU64(sfOutstandingAmount, kMAX_MP_TOKEN_AMOUNT + 1); // locked is valid and <= outstanding -> must NOT clear bad_ sleNew->setFieldU64(sfLockedAmount, 10); ac.view().insert(sleNew); @@ -4253,7 +4256,7 @@ class Invariants_test : public beast::unit_test::suite std::vector values; }; - NumberMantissaScaleGuard const g{MantissaRange::mantissa_scale::large}; + NumberMantissaScaleGuard const g{MantissaRange::MantissaScale::Large}; auto makeDelta = [&vaultAsset](Number const& n) -> ValidVault::DeltaInfo { return {.delta = n, .scale = scale(n, vaultAsset.raw())}; diff --git a/src/test/app/LPTokenTransfer_test.cpp b/src/test/app/LPTokenTransfer_test.cpp index 2b440c67d5..4bf2db9515 100644 --- a/src/test/app/LPTokenTransfer_test.cpp +++ b/src/test/app/LPTokenTransfer_test.cpp @@ -31,50 +31,50 @@ class LPTokenTransfer_test : public jtx::AMMTest using namespace jtx; Env env{*this, features}; - fund(env, gw, {alice}, {USD(20'000), BTC(0.5)}, Fund::All); + fund(env, gw_, {alice_}, {USD(20'000), BTC(0.5)}, Fund::All); env.close(); - AMM ammAlice(env, alice, USD(20'000), BTC(0.5)); + AMM ammAlice(env, alice_, USD(20'000), BTC(0.5)); BEAST_EXPECT(ammAlice.expectBalances(USD(20'000), BTC(0.5), IOUAmount{100, 0})); - fund(env, gw, {carol}, {USD(4'000), BTC(1)}, Fund::Acct); - ammAlice.deposit(carol, 10); + fund(env, gw_, {carol_}, {USD(4'000), BTC(1)}, Fund::Acct); + ammAlice.deposit(carol_, 10); BEAST_EXPECT(ammAlice.expectBalances(USD(22'000), BTC(0.55), IOUAmount{110, 0})); - fund(env, gw, {bob}, {USD(4'000), BTC(1)}, Fund::Acct); - ammAlice.deposit(bob, 10); + fund(env, gw_, {bob_}, {USD(4'000), BTC(1)}, Fund::Acct); + ammAlice.deposit(bob_, 10); BEAST_EXPECT(ammAlice.expectBalances(USD(24'000), BTC(0.60), IOUAmount{120, 0})); auto const lpIssue = ammAlice.lptIssue(); - env.trust(STAmount{lpIssue, 500}, alice); - env.trust(STAmount{lpIssue, 500}, bob); - env.trust(STAmount{lpIssue, 500}, carol); + env.trust(STAmount{lpIssue, 500}, alice_); + env.trust(STAmount{lpIssue, 500}, bob_); + env.trust(STAmount{lpIssue, 500}, carol_); env.close(); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // bob can still send lptoken to carol even tho carol's USD is + // bob_ can still send lptoken to carol_ even tho carol_'s USD is // frozen, regardless of whether fixFrozenLPTokenTransfer is enabled or // not // Note: Deep freeze is not considered for LPToken transfer - env(pay(bob, carol, STAmount{lpIssue, 5})); + env(pay(bob_, carol_, STAmount{lpIssue, 5})); env.close(); // cannot transfer to an amm account - env(pay(carol, lpIssue.getIssuer(), STAmount{lpIssue, 5}), ter(tecNO_PERMISSION)); + env(pay(carol_, lpIssue.getIssuer(), STAmount{lpIssue, 5}), Ter(tecNO_PERMISSION)); env.close(); if (features[fixFrozenLPTokenTransfer]) { - // carol is frozen on USD and therefore can't send lptoken to bob - env(pay(carol, bob, STAmount{lpIssue, 5}), ter(tecPATH_DRY)); + // carol_ is frozen on USD and therefore can't send lptoken to bob_ + env(pay(carol_, bob_, STAmount{lpIssue, 5}), Ter(tecPATH_DRY)); } else { - // carol can still send lptoken with frozen USD - env(pay(carol, bob, STAmount{lpIssue, 5})); + // carol_ can still send lptoken with frozen USD + env(pay(carol_, bob_, STAmount{lpIssue, 5})); } } @@ -86,85 +86,85 @@ class LPTokenTransfer_test : public jtx::AMMTest using namespace jtx; Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(10'000), EUR(10'000)}, Fund::All); - AMM ammAlice(env, alice, USD(10'000), EUR(10'000)); - ammAlice.deposit(carol, 1'000); - ammAlice.deposit(bob, 1'000); + fund(env, gw_, {alice_, bob_, carol_}, {USD(10'000), EUR(10'000)}, Fund::All); + AMM ammAlice(env, alice_, USD(10'000), EUR(10'000)); + ammAlice.deposit(carol_, 1'000); + ammAlice.deposit(bob_, 1'000); auto const lpIssue = ammAlice.lptIssue(); // carols creates an offer to sell lptoken - env(offer(carol, XRP(10), STAmount{lpIssue, 10}), txflags(tfPassive)); + env(offer(carol_, XRP(10), STAmount{lpIssue, 10}), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); - env.trust(STAmount{lpIssue, 1'000'000'000}, alice); - env.trust(STAmount{lpIssue, 1'000'000'000}, bob); - env.trust(STAmount{lpIssue, 1'000'000'000}, carol); + env.trust(STAmount{lpIssue, 1'000'000'000}, alice_); + env.trust(STAmount{lpIssue, 1'000'000'000}, bob_); + env.trust(STAmount{lpIssue, 1'000'000'000}, carol_); env.close(); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // exercises alice's ability to consume carol's offer to sell lptoken - // when carol's USD is frozen pre/post fixFrozenLPTokenTransfer + // exercises alice_'s ability to consume carol_'s offer to sell lptoken + // when carol_'s USD is frozen pre/post fixFrozenLPTokenTransfer // amendment if (features[fixFrozenLPTokenTransfer]) { - // with fixFrozenLPTokenTransfer, alice fails to consume carol's - // offer since carol's USD is frozen - env(pay(alice, bob, STAmount{lpIssue, 10}), - txflags(tfPartialPayment), - sendmax(XRP(10)), - ter(tecPATH_DRY)); + // with fixFrozenLPTokenTransfer, alice_ fails to consume carol_'s + // offer since carol_'s USD is frozen + env(pay(alice_, bob_, STAmount{lpIssue, 10}), + Txflags(tfPartialPayment), + Sendmax(XRP(10)), + Ter(tecPATH_DRY)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); - // gateway unfreezes carol's USD - env(trust(gw, carol["USD"](1'000'000'000), tfClearFreeze)); + // gateway unfreezes carol_'s USD + env(trust(gw_, carol_["USD"](1'000'000'000), tfClearFreeze)); env.close(); - // alice successfully consumes carol's offer - env(pay(alice, bob, STAmount{lpIssue, 10}), - txflags(tfPartialPayment), - sendmax(XRP(10))); + // alice_ successfully consumes carol_'s offer + env(pay(alice_, bob_, STAmount{lpIssue, 10}), + Txflags(tfPartialPayment), + Sendmax(XRP(10))); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } else { - // without fixFrozenLPTokenTransfer, alice can consume carol's offer - // even when carol's USD is frozen - env(pay(alice, bob, STAmount{lpIssue, 10}), - txflags(tfPartialPayment), - sendmax(XRP(10))); + // without fixFrozenLPTokenTransfer, alice_ can consume carol_'s offer + // even when carol_'s USD is frozen + env(pay(alice_, bob_, STAmount{lpIssue, 10}), + Txflags(tfPartialPayment), + Sendmax(XRP(10))); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } - // make sure carol's USD is not frozen - env(trust(gw, carol["USD"](1'000'000'000), tfClearFreeze)); + // make sure carol_'s USD is not frozen + env(trust(gw_, carol_["USD"](1'000'000'000), tfClearFreeze)); env.close(); - // ensure that carol's offer to buy lptoken can be consumed by alice - // even when carol's USD is frozen + // ensure that carol_'s offer to buy lptoken can be consumed by alice_ + // even when carol_'s USD is frozen { - // carol creates an offer to buy lptoken - env(offer(carol, STAmount{lpIssue, 10}, XRP(10)), txflags(tfPassive)); + // carol_ creates an offer to buy lptoken + env(offer(carol_, STAmount{lpIssue, 10}, XRP(10)), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // alice successfully consumes carol's offer - env(pay(alice, bob, XRP(10)), - txflags(tfPartialPayment), - sendmax(STAmount{lpIssue, 10})); + // alice_ successfully consumes carol_'s offer + env(pay(alice_, bob_, XRP(10)), + Txflags(tfPartialPayment), + Sendmax(STAmount{lpIssue, 10})); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); } } @@ -176,56 +176,56 @@ class LPTokenTransfer_test : public jtx::AMMTest using namespace jtx; Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(10'000), EUR(10'000)}, Fund::All); - AMM ammAlice(env, alice, USD(10'000), EUR(10'000)); - ammAlice.deposit(carol, 1'000); - ammAlice.deposit(bob, 1'000); + fund(env, gw_, {alice_, bob_, carol_}, {USD(10'000), EUR(10'000)}, Fund::All); + AMM ammAlice(env, alice_, USD(10'000), EUR(10'000)); + ammAlice.deposit(carol_, 1'000); + ammAlice.deposit(bob_, 1'000); auto const lpIssue = ammAlice.lptIssue(); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // exercises carol's ability to create a new offer to sell lptoken with + // exercises carol_'s ability to create a new offer to sell lptoken with // frozen USD, before and after fixFrozenLPTokenTransfer if (features[fixFrozenLPTokenTransfer]) { - // with fixFrozenLPTokenTransfer, carol can't create an offer to + // with fixFrozenLPTokenTransfer, carol_ can't create an offer to // sell lptoken when one of the assets is frozen - // carol can't create an offer to sell lptoken - env(offer(carol, XRP(10), STAmount{lpIssue, 10}), - txflags(tfPassive), - ter(tecUNFUNDED_OFFER)); + // carol_ can't create an offer to sell lptoken + env(offer(carol_, XRP(10), STAmount{lpIssue, 10}), + Txflags(tfPassive), + Ter(tecUNFUNDED_OFFER)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 0)); + BEAST_EXPECT(expectOffers(env, carol_, 0)); - // gateway unfreezes carol's USD - env(trust(gw, carol["USD"](1'000'000'000), tfClearFreeze)); + // gateway unfreezes carol_'s USD + env(trust(gw_, carol_["USD"](1'000'000'000), tfClearFreeze)); env.close(); - // carol can create an offer to sell lptoken after USD is unfrozen - env(offer(carol, XRP(10), STAmount{lpIssue, 10}), txflags(tfPassive)); + // carol_ can create an offer to sell lptoken after USD is unfrozen + env(offer(carol_, XRP(10), STAmount{lpIssue, 10}), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); } else { - // without fixFrozenLPTokenTransfer, carol can create an offer - env(offer(carol, XRP(10), STAmount{lpIssue, 10}), txflags(tfPassive)); + // without fixFrozenLPTokenTransfer, carol_ can create an offer + env(offer(carol_, XRP(10), STAmount{lpIssue, 10}), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); } - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // carol can create offer to buy lptoken even if USD is frozen - env(offer(carol, STAmount{lpIssue, 10}, XRP(5)), txflags(tfPassive)); + // carol_ can create offer to buy lptoken even if USD is frozen + env(offer(carol_, STAmount{lpIssue, 10}, XRP(5)), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 2)); + BEAST_EXPECT(expectOffers(env, carol_, 2)); } void @@ -237,55 +237,55 @@ class LPTokenTransfer_test : public jtx::AMMTest Env env{*this, features}; // Offer crossing with two AMM LPTokens. - fund(env, gw, {alice, carol}, {USD(10'000)}, Fund::All); - AMM ammAlice1(env, alice, XRP(10'000), USD(10'000)); - ammAlice1.deposit(carol, 10'000'000); + fund(env, gw_, {alice_, carol_}, {USD(10'000)}, Fund::All); + AMM ammAlice1(env, alice_, XRP(10'000), USD(10'000)); + ammAlice1.deposit(carol_, 10'000'000); - fund(env, gw, {alice, carol}, {EUR(10'000)}, Fund::TokenOnly); - AMM ammAlice2(env, alice, XRP(10'000), EUR(10'000)); - ammAlice2.deposit(carol, 10'000'000); + fund(env, gw_, {alice_, carol_}, {EUR(10'000)}, Fund::TokenOnly); + AMM ammAlice2(env, alice_, XRP(10'000), EUR(10'000)); + ammAlice2.deposit(carol_, 10'000'000); auto const token1 = ammAlice1.lptIssue(); auto const token2 = ammAlice2.lptIssue(); - // carol creates offer - env(offer(carol, STAmount{token2, 100}, STAmount{token1, 100})); + // carol_ creates offer + env(offer(carol_, STAmount{token2, 100}, STAmount{token1, 100})); env.close(); - BEAST_EXPECT(expectOffers(env, carol, 1)); + BEAST_EXPECT(expectOffers(env, carol_, 1)); - // gateway freezes carol's USD, carol's token1 should be frozen as well - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD, carol_'s token1 should be frozen as well + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // alice creates an offer which exhibits different behavior on offer + // alice_ creates an offer which exhibits different behavior on offer // crossing depending on if fixFrozenLPTokenTransfer is enabled - env(offer(alice, STAmount{token1, 100}, STAmount{token2, 100})); + env(offer(alice_, STAmount{token1, 100}, STAmount{token2, 100})); env.close(); - // exercises carol's offer's ability to cross with alice's offer when - // carol's USD is frozen, before and after fixFrozenLPTokenTransfer + // exercises carol_'s offer's ability to cross with alice_'s offer when + // carol_'s USD is frozen, before and after fixFrozenLPTokenTransfer if (features[fixFrozenLPTokenTransfer]) { - // with fixFrozenLPTokenTransfer enabled, alice's offer can no - // longer cross with carol's offer + // with fixFrozenLPTokenTransfer enabled, alice_'s offer can no + // longer cross with carol_'s offer BEAST_EXPECT( - expectHolding(env, alice, STAmount{token1, 10'000'000}) && - expectHolding(env, alice, STAmount{token2, 10'000'000})); + expectHolding(env, alice_, STAmount{token1, 10'000'000}) && + expectHolding(env, alice_, STAmount{token2, 10'000'000})); BEAST_EXPECT( - expectHolding(env, carol, STAmount{token2, 10'000'000}) && - expectHolding(env, carol, STAmount{token1, 10'000'000})); - BEAST_EXPECT(expectOffers(env, alice, 1) && expectOffers(env, carol, 0)); + expectHolding(env, carol_, STAmount{token2, 10'000'000}) && + expectHolding(env, carol_, STAmount{token1, 10'000'000})); + BEAST_EXPECT(expectOffers(env, alice_, 1) && expectOffers(env, carol_, 0)); } else { - // alice's offer still crosses with carol's offer despite carol's + // alice_'s offer still crosses with carol_'s offer despite carol_'s // token1 is frozen BEAST_EXPECT( - expectHolding(env, alice, STAmount{token1, 10'000'100}) && - expectHolding(env, alice, STAmount{token2, 9'999'900})); + expectHolding(env, alice_, STAmount{token1, 10'000'100}) && + expectHolding(env, alice_, STAmount{token2, 9'999'900})); BEAST_EXPECT( - expectHolding(env, carol, STAmount{token2, 10'000'100}) && - expectHolding(env, carol, STAmount{token1, 9'999'900})); - BEAST_EXPECT(expectOffers(env, alice, 0) && expectOffers(env, carol, 0)); + expectHolding(env, carol_, STAmount{token2, 10'000'100}) && + expectHolding(env, carol_, STAmount{token1, 9'999'900})); + BEAST_EXPECT(expectOffers(env, alice_, 0) && expectOffers(env, carol_, 0)); } } @@ -297,43 +297,43 @@ class LPTokenTransfer_test : public jtx::AMMTest using namespace jtx; Env env{*this, features}; - fund(env, gw, {alice, bob, carol}, {USD(10'000), EUR(10'000)}, Fund::All); - AMM ammAlice(env, alice, USD(10'000), EUR(10'000)); - ammAlice.deposit(carol, 1'000); - ammAlice.deposit(bob, 1'000); + fund(env, gw_, {alice_, bob_, carol_}, {USD(10'000), EUR(10'000)}, Fund::All); + AMM ammAlice(env, alice_, USD(10'000), EUR(10'000)); + ammAlice.deposit(carol_, 1'000); + ammAlice.deposit(bob_, 1'000); auto const lpIssue = ammAlice.lptIssue(); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); - // carol can always create a check with lptoken that has frozen + // carol_ can always create a check with lptoken that has frozen // token - uint256 const carolChkId{keylet::check(carol, env.seq(carol)).key}; - env(check::create(carol, bob, STAmount{lpIssue, 10})); + uint256 const carolChkId{keylet::check(carol_, env.seq(carol_)).key}; + env(check::create(carol_, bob_, STAmount{lpIssue, 10})); env.close(); - // with fixFrozenLPTokenTransfer enabled, bob fails to cash the check + // with fixFrozenLPTokenTransfer enabled, bob_ fails to cash the check if (features[fixFrozenLPTokenTransfer]) { - env(check::cash(bob, carolChkId, STAmount{lpIssue, 10}), ter(tecPATH_PARTIAL)); + env(check::cash(bob_, carolChkId, STAmount{lpIssue, 10}), Ter(tecPATH_PARTIAL)); } else { - env(check::cash(bob, carolChkId, STAmount{lpIssue, 10})); + env(check::cash(bob_, carolChkId, STAmount{lpIssue, 10})); } env.close(); - // bob creates a check - uint256 const bobChkId{keylet::check(bob, env.seq(bob)).key}; - env(check::create(bob, carol, STAmount{lpIssue, 10})); + // bob_ creates a check + uint256 const bobChkId{keylet::check(bob_, env.seq(bob_)).key}; + env(check::create(bob_, carol_, STAmount{lpIssue, 10})); env.close(); - // carol cashes the bob's check. Even though carol is frozen, she can + // carol_ cashes the bob_'s check. Even though carol_ is frozen, she can // still receive LPToken - env(check::cash(carol, bobChkId, STAmount{lpIssue, 10})); + env(check::cash(carol_, bobChkId, STAmount{lpIssue, 10})); env.close(); } @@ -346,25 +346,25 @@ class LPTokenTransfer_test : public jtx::AMMTest Env env{*this, features}; // Setup AMM - fund(env, gw, {alice, bob, carol}, {USD(10'000), EUR(10'000)}, Fund::All); - AMM ammAlice(env, alice, USD(10'000), EUR(10'000)); - ammAlice.deposit(carol, 1'000); - ammAlice.deposit(bob, 1'000); + fund(env, gw_, {alice_, bob_, carol_}, {USD(10'000), EUR(10'000)}, Fund::All); + AMM ammAlice(env, alice_, USD(10'000), EUR(10'000)); + ammAlice.deposit(carol_, 1'000); + ammAlice.deposit(bob_, 1'000); auto const lpIssue = ammAlice.lptIssue(); - // bob mints a nft - uint256 const nftID{token::getNextID(env, bob, 0u, tfTransferable)}; - env(token::mint(bob, 0), txflags(tfTransferable)); + // bob_ mints a nft + uint256 const nftID{token::getNextID(env, bob_, 0u, tfTransferable)}; + env(token::mint(bob_, 0), Txflags(tfTransferable)); env.close(); - // bob creates a sell offer for lptoken - uint256 const sellOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftID, STAmount{lpIssue, 10}), txflags(tfSellNFToken)); + // bob_ creates a sell offer for lptoken + uint256 const sellOfferIndex = keylet::nftoffer(bob_, env.seq(bob_)).key; + env(token::createOffer(bob_, nftID, STAmount{lpIssue, 10}), Txflags(tfSellNFToken)); env.close(); - // gateway freezes carol's USD - env(trust(gw, carol["USD"](0), tfSetFreeze)); + // gateway freezes carol_'s USD + env(trust(gw_, carol_["USD"](0), tfSetFreeze)); env.close(); // exercises one's ability to transfer NFT using lptoken when one of the @@ -374,36 +374,36 @@ class LPTokenTransfer_test : public jtx::AMMTest // with fixFrozenLPTokenTransfer, freezing USD will prevent buy/sell // offers with lptokens from being created/accepted - // carol fails to accept bob's offer with lptoken because carol's + // carol_ fails to accept bob_'s offer with lptoken because carol_'s // USD is frozen - env(token::acceptSellOffer(carol, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(carol_, sellOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); - // gateway unfreezes carol's USD - env(trust(gw, carol["USD"](1'000'000), tfClearFreeze)); + // gateway unfreezes carol_'s USD + env(trust(gw_, carol_["USD"](1'000'000), tfClearFreeze)); env.close(); - // carol can now accept the offer and own the nft - env(token::acceptSellOffer(carol, sellOfferIndex)); + // carol_ can now accept the offer and own the nft + env(token::acceptSellOffer(carol_, sellOfferIndex)); env.close(); - // gateway freezes bob's USD - env(trust(gw, bob["USD"](0), tfSetFreeze)); + // gateway freezes bob_'s USD + env(trust(gw_, bob_["USD"](0), tfSetFreeze)); env.close(); - // bob fails to create a buy offer with lptoken for carol's nft - // since bob's USD is frozen - env(token::createOffer(bob, nftID, STAmount{lpIssue, 10}), - token::owner(carol), - ter(tecUNFUNDED_OFFER)); + // bob_ fails to create a buy offer with lptoken for carol_'s nft + // since bob_'s USD is frozen + env(token::createOffer(bob_, nftID, STAmount{lpIssue, 10}), + token::Owner(carol_), + Ter(tecUNFUNDED_OFFER)); env.close(); - // gateway unfreezes bob's USD - env(trust(gw, bob["USD"](1'000'000), tfClearFreeze)); + // gateway unfreezes bob_'s USD + env(trust(gw_, bob_["USD"](1'000'000), tfClearFreeze)); env.close(); - // bob can now create a buy offer - env(token::createOffer(bob, nftID, STAmount{lpIssue, 10}), token::owner(carol)); + // bob_ can now create a buy offer + env(token::createOffer(bob_, nftID, STAmount{lpIssue, 10}), token::Owner(carol_)); env.close(); } else @@ -411,21 +411,21 @@ class LPTokenTransfer_test : public jtx::AMMTest // without fixFrozenLPTokenTransfer, freezing USD will still allow // buy/sell offers to be created/accepted with lptoken - // carol can still accept bob's offer despite carol's USD is frozen - env(token::acceptSellOffer(carol, sellOfferIndex)); + // carol_ can still accept bob_'s offer despite carol_'s USD is frozen + env(token::acceptSellOffer(carol_, sellOfferIndex)); env.close(); - // gateway freezes bob's USD - env(trust(gw, bob["USD"](0), tfSetFreeze)); + // gateway freezes bob_'s USD + env(trust(gw_, bob_["USD"](0), tfSetFreeze)); env.close(); - // bob creates a buy offer with lptoken despite bob's USD is frozen - uint256 const buyOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftID, STAmount{lpIssue, 10}), token::owner(carol)); + // bob_ creates a buy offer with lptoken despite bob_'s USD is frozen + uint256 const buyOfferIndex = keylet::nftoffer(bob_, env.seq(bob_)).key; + env(token::createOffer(bob_, nftID, STAmount{lpIssue, 10}), token::Owner(carol_)); env.close(); - // carol accepts bob's offer - env(token::acceptBuyOffer(carol, buyOfferIndex)); + // carol_ accepts bob_'s offer + env(token::acceptBuyOffer(carol_, buyOfferIndex)); env.close(); } } @@ -434,7 +434,7 @@ public: void run() override { - FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const all{jtx::testableAmendments()}; for (auto const features : {all, all - fixFrozenLPTokenTransfer}) { diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index 73944b617c..396ec8db2d 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -26,7 +26,7 @@ namespace xrpl::test { -class LedgerHistory_test : public beast::unit_test::suite +class LedgerHistory_test : public beast::unit_test::Suite { public: /** Generate a new ledger by hand, applying a specific close time offset @@ -48,7 +48,7 @@ public: { assert(!stx); return std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, @@ -59,14 +59,14 @@ public: if (stx) { OpenView accum(&*res); - applyTransaction(env.app(), accum, *stx, false, tapNONE, env.journal); + applyTransaction(env.app(), accum, *stx, false, TapNone, env.journal); accum.apply(*res); } res->updateSkipList(); { - res->stateMap().flushDirty(NodeObjectType::hotACCOUNT_NODE); - res->txMap().flushDirty(NodeObjectType::hotTRANSACTION_NODE); + res->stateMap().flushDirty(NodeObjectType::AccountNode); + res->txMap().flushDirty(NodeObjectType::TransactionNode); } res->unshare(); @@ -90,7 +90,7 @@ public: { bool found = false; Env env{*this, envconfig(), std::make_unique("MISMATCH ", &found)}; - LedgerHistory lh{beast::insight::NullCollector::New(), env.app()}; + LedgerHistory lh{beast::insight::NullCollector::make(), env.app()}; auto const genesis = makeLedger({}, env, lh, 0s); uint256 const dummyTxHash{1}; lh.builtLedger(genesis, dummyTxHash, {}); @@ -106,7 +106,7 @@ public: *this, envconfig(), std::make_unique("MISMATCH on close time", &found)}; - LedgerHistory lh{beast::insight::NullCollector::New(), env.app()}; + LedgerHistory lh{beast::insight::NullCollector::make(), env.app()}; auto const genesis = makeLedger({}, env, lh, 0s); auto const ledgerA = makeLedger(genesis, env, lh, 4s); auto const ledgerB = makeLedger(genesis, env, lh, 40s); @@ -125,7 +125,7 @@ public: *this, envconfig(), std::make_unique("MISMATCH on prior ledger", &found)}; - LedgerHistory lh{beast::insight::NullCollector::New(), env.app()}; + LedgerHistory lh{beast::insight::NullCollector::make(), env.app()}; auto const genesis = makeLedger({}, env, lh, 0s); auto const ledgerA = makeLedger(genesis, env, lh, 4s); auto const ledgerB = makeLedger(genesis, env, lh, 40s); @@ -147,7 +147,7 @@ public: : "MISMATCH on consensus transaction set"; bool found = false; Env env{*this, envconfig(), std::make_unique(msg, &found)}; - LedgerHistory lh{beast::insight::NullCollector::New(), env.app()}; + LedgerHistory lh{beast::insight::NullCollector::make(), env.app()}; Account const alice{"A1"}; Account const bob{"A2"}; diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index a97b492921..3345f45aa6 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -31,7 +31,7 @@ namespace xrpl { -class LedgerLoad_test : public beast::unit_test::suite +class LedgerLoad_test : public beast::unit_test::Suite { auto static ledgerConfig( std::unique_ptr cfg, @@ -54,14 +54,14 @@ class LedgerLoad_test : public beast::unit_test::suite std::string const dbPath; // NOLINTBEGIN(readability-redundant-member-init) std::string ledgerFile = {}; - Json::Value ledger = {}; - Json::Value hashes = {}; + json::Value ledger = {}; + json::Value hashes = {}; uint256 trapTxHash = {}; // NOLINTEND(readability-redundant-member-init) }; SetupData - setupLedger(beast::temp_dir const& td) + setupLedger(beast::TempDir const& td) { using namespace test::jtx; SetupData retval = {.dbPath = td.path()}; @@ -96,7 +96,7 @@ class LedgerLoad_test : public beast::unit_test::suite if (it[sfLedgerEntryType.fieldName] == jss::LedgerHashes) return it[sfHashes.fieldName]; } - return Json::Value{}; + return json::Value{}; }(); BEAST_EXPECT(retval.hashes.size() == 41); @@ -127,7 +127,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LoadFile, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT( sd.ledger[jss::ledger][jss::accountState].size() == @@ -147,7 +147,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LoadFile, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); }); // file does not exist @@ -157,7 +157,7 @@ class LedgerLoad_test : public beast::unit_test::suite envconfig( ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LoadFile, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); }); // make a corrupted version of the ledger file (last 10 bytes removed). @@ -183,7 +183,7 @@ class LedgerLoad_test : public beast::unit_test::suite StartUpType::LoadFile, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); }); } @@ -200,7 +200,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Load, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 98); BEAST_EXPECT( @@ -221,7 +221,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97); // in replace mode do not automatically accept the ledger being replayed @@ -247,7 +247,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, sd.trapTxHash), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97); // in replace mode do not automatically accept the ledger being replayed @@ -277,7 +277,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, ~sd.trapTxHash), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); BEAST_EXPECT(false); } catch (std::runtime_error const&) @@ -301,7 +301,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::Load, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT( sd.ledger[jss::ledger][jss::accountState].size() == @@ -319,7 +319,7 @@ class LedgerLoad_test : public beast::unit_test::suite *this, envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::Load, std::nullopt), nullptr, - beast::severities::kDisabled); + beast::severities::KDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; BEAST_EXPECT( sd.ledger[jss::ledger][jss::accountState].size() == @@ -330,7 +330,7 @@ public: void run() override { - beast::temp_dir const td; + beast::TempDir const td; auto sd = setupLedger(td); // test cases diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index 625eb22ac5..ee14a93d07 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -20,7 +20,7 @@ namespace xrpl::test { -class LedgerMaster_test : public beast::unit_test::suite +class LedgerMaster_test : public beast::unit_test::Suite { static std::unique_ptr makeNetworkConfig(uint32_t networkID) @@ -116,7 +116,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testWithFeats(all); } diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 7766be3545..a96fa2c499 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -65,7 +65,7 @@ namespace xrpl::test { -struct LedgerReplay_test : public beast::unit_test::suite +struct LedgerReplay_test : public beast::unit_test::Suite { void run() override @@ -87,7 +87,7 @@ struct LedgerReplay_test : public beast::unit_test::suite auto const lastClosedParent = ledgerMaster.getLedgerByHash(lastClosed->header().parentHash); auto const replayed = buildLedger( - LedgerReplay(lastClosedParent, lastClosed), tapNONE, env.app(), env.journal); + LedgerReplay(lastClosedParent, lastClosed), TapNone, env.app(), env.journal); BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash); } @@ -170,7 +170,7 @@ public: { } - Json::Value + json::Value getInfo() override { return {}; @@ -227,7 +227,7 @@ class TestPeer : public Peer public: TestPeer(bool enableLedgerReplay) : ledgerReplayEnabled_(enableLedgerReplay) - , nodePublicKey_(derivePublicKey(KeyType::ed25519, randomSecretKey())) + , nodePublicKey_(derivePublicKey(KeyType::Ed25519, randomSecretKey())) { } @@ -269,7 +269,7 @@ public: { return nodePublicKey_; } - Json::Value + json::Value json() override { return {}; @@ -291,8 +291,8 @@ public: [[nodiscard]] uint256 const& getClosedLedgerHash() const override { - static uint256 const hash{}; - return hash; + static uint256 const kHASH{}; + return kHASH; } [[nodiscard]] bool hasLedger(uint256 const& hash, std::uint32_t seq) const override @@ -346,9 +346,11 @@ public: return fingerprint_; } + // NOLINTBEGIN(readability-identifier-naming) std::string fingerprint_; bool ledgerReplayEnabled_; PublicKey nodePublicKey_; + // NOLINTEND(readability-identifier-naming) }; enum class PeerSetBehavior { @@ -443,8 +445,8 @@ struct TestPeerSet : public PeerSet [[nodiscard]] std::set const& getPeerIds() const override { - static std::set const emptyPeers; - return emptyPeers; + static std::set const kEMPTY_PEERS; + return kEMPTY_PEERS; } LedgerReplayMsgHandler& local; @@ -464,24 +466,24 @@ public: LedgerReplayMsgHandler& other, PeerSetBehavior bhvr, PeerFeature peerFeature) - : local(me) - , remote(other) - , behavior(bhvr) - , enableLedgerReplay(peerFeature == PeerFeature::LedgerReplayEnabled) + : local_(me) + , remote_(other) + , behavior_(bhvr) + , enableLedgerReplay_(peerFeature == PeerFeature::LedgerReplayEnabled) { } std::unique_ptr build() override { - return std::make_unique(local, remote, behavior, enableLedgerReplay); + return std::make_unique(local_, remote_, behavior_, enableLedgerReplay_); } private: - LedgerReplayMsgHandler& local; - LedgerReplayMsgHandler& remote; - PeerSetBehavior behavior; - bool enableLedgerReplay; + LedgerReplayMsgHandler& local_; + LedgerReplayMsgHandler& remote_; + PeerSetBehavior behavior_; + bool enableLedgerReplay_; }; /** @@ -499,7 +501,7 @@ struct LedgerServer int txAmount = 10; }; - LedgerServer(beast::unit_test::suite& suite, Parameter const& p) + LedgerServer(beast::unit_test::Suite& suite, Parameter const& p) : env(suite) , app(env.app()) , ledgerMaster(env.app().getLedgerMaster()) @@ -509,7 +511,7 @@ struct LedgerServer assert(param.initLedgers > 0); createAccounts(param.initAccounts); createLedgerHistory(); - app.getLogs().threshold(beast::severities::kWarning); + app.getLogs().threshold(beast::severities::KWarning); } /** @@ -559,9 +561,9 @@ struct LedgerServer accounts[toIdx], jtx::drops(ledgerMaster.getClosedLedger()->fees().base) + jtx::XRP(param.txAmount)), - jtx::seq(jtx::autofill), - jtx::fee(jtx::autofill), - jtx::sig(jtx::autofill)); + jtx::Seq(jtx::kAUTOFILL), + jtx::Fee(jtx::kAUTOFILL), + jtx::Sig(jtx::kAUTOFILL)); } env.close(); } @@ -604,12 +606,12 @@ class LedgerReplayClient { public: LedgerReplayClient( - beast::unit_test::suite& suite, + beast::unit_test::Suite& suite, LedgerServer& server, PeerSetBehavior behavior = PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr = InboundLedgersBehavior::Good, PeerFeature peerFeature = PeerFeature::LedgerReplayEnabled) - : env(suite, jtx::envconfig(), nullptr, beast::severities::kDisabled) + : env(suite, jtx::envconfig(), nullptr, beast::severities::KDisabled) , app(env.app()) , ledgerMaster(env.app().getLedgerMaster()) , inboundLedgers(server.app.getLedgerMaster(), ledgerMaster, inboundBhvr) @@ -699,7 +701,7 @@ public: { std::unique_lock const lock(replayer.mtx_); auto i = std::ranges::find_if(replayer.tasks_, [&](auto const& t) { - return t->parameter_.finishHash_ == hash && t->parameter_.totalLedgers_ == totalReplay; + return t->parameter_.finishHash == hash && t->parameter_.totalLedgers == totalReplay; }); if (i == replayer.tasks_.end()) return {}; @@ -846,7 +848,7 @@ void logAll( LedgerServer& server, LedgerReplayClient& client, - beast::severities::Severity level = Severity::kTrace) + beast::severities::Severity level = Severity::KTrace) { server.app.getLogs().threshold(level); client.app.getLogs().threshold(level); @@ -859,7 +861,7 @@ logAll( struct NetworkOfTwo { NetworkOfTwo( - beast::unit_test::suite& suite, + beast::unit_test::Suite& suite, LedgerServer::Parameter const& param, PeerSetBehavior behavior = PeerSetBehavior::Good, InboundLedgersBehavior inboundBhvr = InboundLedgersBehavior::Good, @@ -897,7 +899,7 @@ struct NetworkOfTwo * -- call replayer.replay() 4 times to replay 1000 ledgers */ -struct LedgerReplayer_test : public beast::unit_test::suite +struct LedgerReplayer_test : public beast::unit_test::Suite { void testProofPath() @@ -1033,19 +1035,19 @@ struct LedgerReplayer_test : public beast::unit_test::suite BEAST_EXPECT(tp9.canMergeInto(tp10)); BEAST_EXPECT(!tp10.canMergeInto(tp9)); - tp9.totalLedgers_++; + tp9.totalLedgers++; BEAST_EXPECT(!tp9.canMergeInto(tp10)); - tp9.totalLedgers_--; + tp9.totalLedgers--; BEAST_EXPECT(tp9.canMergeInto(tp10)); - tp9.reason_ = InboundLedger::Reason::CONSENSUS; + tp9.reason = InboundLedger::Reason::CONSENSUS; BEAST_EXPECT(!tp9.canMergeInto(tp10)); - tp9.reason_ = InboundLedger::Reason::GENERIC; + tp9.reason = InboundLedger::Reason::GENERIC; BEAST_EXPECT(tp9.canMergeInto(tp10)); - tp9.finishHash_ = uint256(1234); + tp9.finishHash = uint256(1234); BEAST_EXPECT(!tp9.canMergeInto(tp10)); - tp9.finishHash_ = uint256(9); + tp9.finishHash = uint256(9); BEAST_EXPECT(tp9.canMergeInto(tp10)); // larger task @@ -1093,20 +1095,20 @@ struct LedgerReplayer_test : public beast::unit_test::suite testcase("handshake test"); auto handshake = [&](bool client, bool server, bool expecting) -> bool { auto request = xrpl::makeRequest(true, false, client, false, false); - http_request_type http_request; - http_request.version(request.version()); - http_request.base() = request.base(); + http_request_type httpRequest; + httpRequest.version(request.version()); + httpRequest.base() = request.base(); bool const serverResult = - peerFeatureEnabled(http_request, FEATURE_LEDGER_REPLAY, server); + peerFeatureEnabled(httpRequest, kFEATURE_LEDGER_REPLAY, server); if (serverResult != expecting) return false; beast::IP::Address const addr = boost::asio::ip::make_address("172.1.1.100"); jtx::Env serverEnv(*this); serverEnv.app().config().LEDGER_REPLAY = server; - auto http_resp = xrpl::makeResponse( - true, http_request, addr, addr, uint256{1}, 1, {1, 0}, serverEnv.app()); - auto const clientResult = peerFeatureEnabled(http_resp, FEATURE_LEDGER_REPLAY, client); + auto httpResp = xrpl::makeResponse( + true, httpRequest, addr, addr, uint256{1}, 1, {1, 0}, serverEnv.app()); + auto const clientResult = peerFeatureEnabled(httpResp, kFEATURE_LEDGER_REPLAY, client); return clientResult == expecting; }; @@ -1285,7 +1287,7 @@ struct LedgerReplayer_test : public beast::unit_test::suite auto skipList = net.client.findSkipListAcquire(finalHash); std::uint8_t payload[55] = {0x6A, 0x09, 0xE6, 0x67, 0xF3, 0xBC, 0xC9, 0x08, 0xB2}; - auto item = make_shamapitem(uint256(12345), Slice(payload, sizeof(payload))); + auto item = makeShamapitem(uint256(12345), Slice(payload, sizeof(payload))); skipList->processData(l->seq(), item); std::vector const deltaStatuses; @@ -1363,29 +1365,28 @@ struct LedgerReplayer_test : public beast::unit_test::suite { l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash); } - auto finalHash_early = l->header().hash; - net.client.replayer.replay(InboundLedger::Reason::GENERIC, finalHash_early, totalReplay); + auto finalHashEarly = l->header().hash; + net.client.replayer.replay(InboundLedger::Reason::GENERIC, finalHashEarly, totalReplay); BEAST_EXPECT(net.client.waitAndCheckStatus( - finalHash_early, + finalHashEarly, totalReplay, TaskStatus::Completed, TaskStatus::Completed, deltaStatuses)); // deltaStatuses no change - BEAST_EXPECT(net.client.waitForLedgers(finalHash_early, totalReplay)); + BEAST_EXPECT(net.client.waitForLedgers(finalHashEarly, totalReplay)); BEAST_EXPECT(net.client.countsAsExpected(3, 2, 2 * (totalReplay - 1))); // partial overlap l = net.server.ledgerMaster.getLedgerByHash(l->header().parentHash); - auto finalHash_moreEarly = l->header().parentHash; - net.client.replayer.replay( - InboundLedger::Reason::GENERIC, finalHash_moreEarly, totalReplay); + auto finalHashMoreEarly = l->header().parentHash; + net.client.replayer.replay(InboundLedger::Reason::GENERIC, finalHashMoreEarly, totalReplay); BEAST_EXPECT(net.client.waitAndCheckStatus( - finalHash_moreEarly, + finalHashMoreEarly, totalReplay, TaskStatus::Completed, TaskStatus::Completed, deltaStatuses)); // deltaStatuses no change - BEAST_EXPECT(net.client.waitForLedgers(finalHash_moreEarly, totalReplay)); + BEAST_EXPECT(net.client.waitForLedgers(finalHashMoreEarly, totalReplay)); BEAST_EXPECT(net.client.countsAsExpected(4, 3, (2 * (totalReplay - 1)) + 2)); // cover @@ -1428,7 +1429,7 @@ struct LedgerReplayer_test : public beast::unit_test::suite } }; -struct LedgerReplayerTimeout_test : public beast::unit_test::suite +struct LedgerReplayerTimeout_test : public beast::unit_test::Suite { void testSkipListTimeout() @@ -1492,7 +1493,7 @@ struct LedgerReplayerTimeout_test : public beast::unit_test::suite } }; -struct LedgerReplayerLong_test : public beast::unit_test::suite +struct LedgerReplayerLong_test : public beast::unit_test::Suite { void run() override diff --git a/src/test/app/LendingHelpers_test.cpp b/src/test/app/LendingHelpers_test.cpp index 82c80f0158..cbfd9da884 100644 --- a/src/test/app/LendingHelpers_test.cpp +++ b/src/test/app/LendingHelpers_test.cpp @@ -15,7 +15,7 @@ namespace xrpl::test { -class LendingHelpers_test : public beast::unit_test::suite +class LendingHelpers_test : public beast::unit_test::Suite { void testComputeRaisedRate() @@ -249,7 +249,7 @@ class LendingHelpers_test : public beast::unit_test::suite using namespace xrpl::detail; Account const issuer{"issuer"}; - PrettyAsset const IOU = issuer["IOU"]; + PrettyAsset const iou = issuer["IOU"]; int32_t const loanScale = 1; auto const overpayment = Number{1'000}; auto const overpaymentInterestRate = TenthBips32{10'000}; // 10% @@ -263,7 +263,7 @@ class LendingHelpers_test : public beast::unit_test::suite auto const expectedPrincipalPortion = Number{400}; // 1,000 - 100 - 500 auto const components = xrpl::detail::computeOverpaymentComponents( - IOU, + iou, loanScale, overpayment, overpaymentInterestRate, @@ -304,7 +304,7 @@ class LendingHelpers_test : public beast::unit_test::suite }; Account const issuer{"issuer"}; - PrettyAsset const IOU = issuer["IOU"]; + PrettyAsset const iou = issuer["IOU"]; std::int32_t const loanScale = 1; auto const testCases = std::vector{ @@ -330,7 +330,7 @@ class LendingHelpers_test : public beast::unit_test::suite testcase("computeInterestAndFeeParts: " + tc.name); auto const [computedInterestPart, computedFeePart] = - computeInterestAndFeeParts(IOU, tc.interest, tc.managementFeeRate, loanScale); + computeInterestAndFeeParts(iou, tc.interest, tc.managementFeeRate, loanScale); BEAST_EXPECTS( computedInterestPart == tc.expectedInterestPart, "Interest part mismatch: expected " + to_string(tc.expectedInterestPart) + diff --git a/src/test/app/LoadFeeTrack_test.cpp b/src/test/app/LoadFeeTrack_test.cpp index f6d05bf0e6..1122ac4ad6 100644 --- a/src/test/app/LoadFeeTrack_test.cpp +++ b/src/test/app/LoadFeeTrack_test.cpp @@ -6,7 +6,7 @@ namespace xrpl { -class LoadFeeTrack_test : public beast::unit_test::suite +class LoadFeeTrack_test : public beast::unit_test::Suite { public: void @@ -18,8 +18,8 @@ public: Fees const fees = [&]() { Fees f; f.base = d.FEES.reference_fee; - f.reserve = 200 * DROPS_PER_XRP; - f.increment = 50 * DROPS_PER_XRP; + f.reserve = 200 * kDROPS_PER_XRP; + f.increment = 50 * kDROPS_PER_XRP; return f; }(); @@ -31,8 +31,8 @@ public: Fees const fees = [&]() { Fees f; f.base = d.FEES.reference_fee * 10; - f.reserve = 200 * DROPS_PER_XRP; - f.increment = 50 * DROPS_PER_XRP; + f.reserve = 200 * kDROPS_PER_XRP; + f.increment = 50 * kDROPS_PER_XRP; return f; }(); @@ -44,8 +44,8 @@ public: Fees const fees = [&]() { Fees f; f.base = d.FEES.reference_fee; - f.reserve = 200 * DROPS_PER_XRP; - f.increment = 50 * DROPS_PER_XRP; + f.reserve = 200 * kDROPS_PER_XRP; + f.increment = 50 * kDROPS_PER_XRP; return f; }(); diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index 3bdd346877..58c925c043 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -59,11 +59,11 @@ namespace xrpl::test { -class LoanBroker_test : public beast::unit_test::suite +class LoanBroker_test : public beast::unit_test::Suite { // Ensure that all the features needed for Lending Protocol are included, // even if they are set to unsupported. - FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const all_{jtx::testableAmendments()}; void testDisabled() @@ -84,34 +84,34 @@ class LoanBroker_test : public beast::unit_test::suite PrettyAsset const asset{xrpIssue(), 1'000'000}; Vault const vault{env}; auto const [tx, keylet] = vault.create({.owner = alice, .asset = asset}); - env(tx, ter(goodVault ? ter(tesSUCCESS) : ter(temDISABLED))); + env(tx, Ter(goodVault ? Ter(tesSUCCESS) : Ter(temDISABLED))); env.close(); BEAST_EXPECT(static_cast(env.le(keylet)) == goodVault); using namespace loanBroker; // Can't create a loan broker regardless of whether the vault exists - env(set(alice, keylet.key), ter(temDISABLED)); + env(set(alice, keylet.key), Ter(temDISABLED)); auto const brokerKeylet = keylet::loanbroker(alice.id(), env.seq(alice)); // Other LoanBroker transactions are disabled, too. // 1. LoanBrokerCoverDeposit - env(coverDeposit(alice, brokerKeylet.key, asset(1000)), ter(temDISABLED)); + env(coverDeposit(alice, brokerKeylet.key, asset(1000)), Ter(temDISABLED)); // 2. LoanBrokerCoverWithdraw - env(coverWithdraw(alice, brokerKeylet.key, asset(1000)), ter(temDISABLED)); + env(coverWithdraw(alice, brokerKeylet.key, asset(1000)), Ter(temDISABLED)); // 3. LoanBrokerCoverClawback - env(coverClawback(alice), ter(temDISABLED)); - env(coverClawback(alice), loanBrokerID(brokerKeylet.key), ter(temDISABLED)); - env(coverClawback(alice), amount(asset(0)), ter(temDISABLED)); + env(coverClawback(alice), Ter(temDISABLED)); + env(coverClawback(alice), kLOAN_BROKER_ID(brokerKeylet.key), Ter(temDISABLED)); + env(coverClawback(alice), kAMOUNT(asset(0)), Ter(temDISABLED)); env(coverClawback(alice), - loanBrokerID(brokerKeylet.key), - amount(asset(1000)), - ter(temDISABLED)); + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(asset(1000)), + Ter(temDISABLED)); // 4. LoanBrokerDelete - env(del(alice, brokerKeylet.key), ter(temDISABLED)); + env(del(alice, brokerKeylet.key), Ter(temDISABLED)); }; - failAll(all - featureMPTokensV1); - failAll(all - featureSingleAssetVault - featureLendingProtocol); - failAll(all - featureSingleAssetVault); - failAll(all - featureLendingProtocol, true); + failAll(all_ - featureMPTokensV1); + failAll(all_ - featureSingleAssetVault - featureLendingProtocol); + failAll(all_ - featureSingleAssetVault); + failAll(all_ - featureLendingProtocol, true); } struct VaultInfo @@ -119,8 +119,8 @@ class LoanBroker_test : public beast::unit_test::suite jtx::PrettyAsset asset; uint256 vaultID; jtx::Account pseudoAccount; - VaultInfo(jtx::PrettyAsset const& asset_, uint256 const& vaultID_, AccountID const& pseudo) - : asset(asset_), vaultID(vaultID_), pseudoAccount("vault", pseudo) + VaultInfo(jtx::PrettyAsset const& asset, uint256 const& vaultId, AccountID const& pseudo) + : asset(asset), vaultID(vaultId), pseudoAccount("vault", pseudo) { } }; @@ -166,15 +166,15 @@ class LoanBroker_test : public beast::unit_test::suite using namespace loanBroker; // Bogus assets to use in test cases - static PrettyAsset const badMptAsset = [&]() { - MPTTester badMptt{env, evan, mptInitNoFund}; + static PrettyAsset const kBAD_MPT_ASSET = [&]() { + MPTTester badMptt{env, evan, kMPT_INIT_NO_FUND}; badMptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); env.close(); return badMptt["BAD"]; }(); - static PrettyAsset const badIouAsset = evan["BAD"]; - static Account const nonExistent{"NonExistent"}; - static PrettyAsset const ghostIouAsset = nonExistent["GST"]; + static PrettyAsset const kBAD_IOU_ASSET = evan["BAD"]; + static Account const kNON_EXISTENT{"NonExistent"}; + static PrettyAsset const kGHOST_IOU_ASSET = kNON_EXISTENT["GST"]; PrettyAsset const vaultPseudoIouAsset = vault.pseudoAccount["PSD"]; auto const badKeylet = keylet::loanbroker(alice.id(), env.seq(alice)); @@ -235,7 +235,7 @@ class LoanBroker_test : public beast::unit_test::suite BEAST_EXPECT( pseudo->at(sfFlags) == (lsfDisableMaster | lsfDefaultRipple | lsfDepositAuth)); BEAST_EXPECT(pseudo->at(sfSequence) == 0); - BEAST_EXPECT(pseudo->at(sfBalance) == beast::zero); + BEAST_EXPECT(pseudo->at(sfBalance) == beast::kZERO); BEAST_EXPECT(pseudo->at(sfOwnerCount) == (vault.asset.raw().native() ? 0 : 1)); BEAST_EXPECT(!pseudo->isFieldPresent(sfAccountTxnID)); BEAST_EXPECT(!pseudo->isFieldPresent(sfRegularKey)); @@ -284,72 +284,72 @@ class LoanBroker_test : public beast::unit_test::suite { auto const amount = vault.asset(n); BEAST_EXPECT(broker->at(sfCoverAvailable) == amount.number()); - env.require(balance(pseudoAccount, amount)); + env.require(Balance(pseudoAccount, amount)); } }; // Test Cover funding before allowing alterations - env(coverDeposit(alice, uint256(0), vault.asset(10)), ter(temINVALID)); - env(coverDeposit(evan, keylet.key, vault.asset(10)), ter(tecNO_PERMISSION)); - env(coverDeposit(evan, keylet.key, vault.asset(0)), ter(temBAD_AMOUNT)); - env(coverDeposit(evan, keylet.key, vault.asset(-10)), ter(temBAD_AMOUNT)); - env(coverDeposit(alice, vault.vaultID, vault.asset(10)), ter(tecNO_ENTRY)); + env(coverDeposit(alice, uint256(0), vault.asset(10)), Ter(temINVALID)); + env(coverDeposit(evan, keylet.key, vault.asset(10)), Ter(tecNO_PERMISSION)); + env(coverDeposit(evan, keylet.key, vault.asset(0)), Ter(temBAD_AMOUNT)); + env(coverDeposit(evan, keylet.key, vault.asset(-10)), Ter(temBAD_AMOUNT)); + env(coverDeposit(alice, vault.vaultID, vault.asset(10)), Ter(tecNO_ENTRY)); verifyCoverAmount(0); // Test cover clawback failure cases BEFORE depositing any cover // Need one of brokerID or amount - env(coverClawback(alice), ter(temINVALID)); - env(coverClawback(alice), loanBrokerID(uint256(0)), ter(temINVALID)); - env(coverClawback(alice), amount(XRP(1000)), ter(temBAD_AMOUNT)); - env(coverClawback(alice), amount(vault.asset(-10)), ter(temBAD_AMOUNT)); + env(coverClawback(alice), Ter(temINVALID)); + env(coverClawback(alice), kLOAN_BROKER_ID(uint256(0)), Ter(temINVALID)); + env(coverClawback(alice), kAMOUNT(XRP(1000)), Ter(temBAD_AMOUNT)); + env(coverClawback(alice), kAMOUNT(vault.asset(-10)), Ter(temBAD_AMOUNT)); // Clawbacks with an MPT need to specify the broker ID - env(coverClawback(alice), amount(badMptAsset(1)), ter(temINVALID)); - env(coverClawback(evan), loanBrokerID(vault.vaultID), ter(tecNO_ENTRY)); + env(coverClawback(alice), kAMOUNT(kBAD_MPT_ASSET(1)), Ter(temINVALID)); + env(coverClawback(evan), kLOAN_BROKER_ID(vault.vaultID), Ter(tecNO_ENTRY)); // Only the issuer can clawback - env(coverClawback(alice), loanBrokerID(keylet.key), ter(tecNO_PERMISSION)); + env(coverClawback(alice), kLOAN_BROKER_ID(keylet.key), Ter(tecNO_PERMISSION)); if (vault.asset.raw().native()) { // Can not clawback XRP under any circumstances - env(coverClawback(issuer), loanBrokerID(keylet.key), ter(tecNO_PERMISSION)); + env(coverClawback(issuer), kLOAN_BROKER_ID(keylet.key), Ter(tecNO_PERMISSION)); } else { if (vault.asset.raw().holds()) { - // Clawbacks without a loanBrokerID need to specify an IOU + // Clawbacks without a kLOAN_BROKER_ID need to specify an IOU // with the broker's pseudo-account as the issuer - env(coverClawback(alice), amount(ghostIouAsset(1)), ter(tecNO_ENTRY)); - env(coverClawback(alice), amount(badIouAsset(1)), ter(tecOBJECT_NOT_FOUND)); + env(coverClawback(alice), kAMOUNT(kGHOST_IOU_ASSET(1)), Ter(tecNO_ENTRY)); + env(coverClawback(alice), kAMOUNT(kBAD_IOU_ASSET(1)), Ter(tecOBJECT_NOT_FOUND)); // Pseudo-account is not for a broker env(coverClawback(alice), - amount(vaultPseudoIouAsset(1)), - ter(tecOBJECT_NOT_FOUND)); + kAMOUNT(vaultPseudoIouAsset(1)), + Ter(tecOBJECT_NOT_FOUND)); // If we specify a pseudo-account as the IOU amount, it // needs to match the loan broker env(coverClawback(issuer), - loanBrokerID(keylet.key), - amount(badBrokerPseudoIouAsset(10)), - ter(tecWRONG_ASSET)); + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(badBrokerPseudoIouAsset(10)), + Ter(tecWRONG_ASSET)); PrettyAsset const brokerWrongCurrencyAsset = pseudoAccount["WAT"]; env(coverClawback(issuer), - loanBrokerID(keylet.key), - amount(brokerWrongCurrencyAsset(10)), - ter(tecWRONG_ASSET)); + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(brokerWrongCurrencyAsset(10)), + Ter(tecWRONG_ASSET)); } else { // Clawbacks with an MPT need to specify the broker ID, even // if the asset is valid BEAST_EXPECT(vault.asset.raw().holds()); - env(coverClawback(alice), amount(vault.asset(10)), ter(temINVALID)); + env(coverClawback(alice), kAMOUNT(vault.asset(10)), Ter(temINVALID)); } // Since no cover has been deposited, there's nothing to claw // back env(coverClawback(issuer), - loanBrokerID(keylet.key), - amount(vault.asset(10)), - ter(tecINSUFFICIENT_FUNDS)); + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(vault.asset(10)), + Ter(tecINSUFFICIENT_FUNDS)); } env.close(); @@ -359,26 +359,26 @@ class LoanBroker_test : public beast::unit_test::suite verifyCoverAmount(10); // Test withdrawal failure cases - env(coverWithdraw(alice, uint256(0), vault.asset(10)), ter(temINVALID)); - env(coverWithdraw(evan, keylet.key, vault.asset(10)), ter(tecNO_PERMISSION)); - env(coverWithdraw(evan, keylet.key, vault.asset(0)), ter(temBAD_AMOUNT)); - env(coverWithdraw(evan, keylet.key, vault.asset(-10)), ter(temBAD_AMOUNT)); - env(coverWithdraw(alice, vault.vaultID, vault.asset(10)), ter(tecNO_ENTRY)); - env(coverWithdraw(alice, keylet.key, vault.asset(900)), ter(tecINSUFFICIENT_FUNDS)); + env(coverWithdraw(alice, uint256(0), vault.asset(10)), Ter(temINVALID)); + env(coverWithdraw(evan, keylet.key, vault.asset(10)), Ter(tecNO_PERMISSION)); + env(coverWithdraw(evan, keylet.key, vault.asset(0)), Ter(temBAD_AMOUNT)); + env(coverWithdraw(evan, keylet.key, vault.asset(-10)), Ter(temBAD_AMOUNT)); + env(coverWithdraw(alice, vault.vaultID, vault.asset(10)), Ter(tecNO_ENTRY)); + env(coverWithdraw(alice, keylet.key, vault.asset(900)), Ter(tecINSUFFICIENT_FUNDS)); // Skip this test for XRP, because that can always be sent if (!vault.asset.raw().native()) { TER const expected = vault.asset.raw().holds() ? tecNO_AUTH : tecNO_LINE; env(coverWithdraw(alice, keylet.key, vault.asset(1)), - destination(bystander), - ter(expected)); + kDESTINATION(bystander), + Ter(expected)); } // Can not withdraw to the zero address env(coverWithdraw(alice, keylet.key, vault.asset(1)), - destination(AccountID{}), - ter(temMALFORMED)); + kDESTINATION(AccountID{}), + Ter(temMALFORMED)); // Withdraw some of the cover amount env(coverWithdraw(alice, keylet.key, vault.asset(7))); @@ -392,20 +392,20 @@ class LoanBroker_test : public beast::unit_test::suite // Withdraw some more. Send it to Evan. Very generous, considering // how much trouble he's been. - env(coverWithdraw(alice, keylet.key, vault.asset(1)), destination(evan)); + env(coverWithdraw(alice, keylet.key, vault.asset(1)), kDESTINATION(evan)); env.close(); verifyCoverAmount(7); // Withdraw some more. Send it to Evan. Very generous, considering // how much trouble he's been. - env(coverWithdraw(alice, keylet.key, vault.asset(1)), destination(evan), dtag(3)); + env(coverWithdraw(alice, keylet.key, vault.asset(1)), kDESTINATION(evan), Dtag(3)); env.close(); verifyCoverAmount(6); if (!vault.asset.raw().native()) { // Issuer claws back some of the cover - env(coverClawback(issuer), loanBrokerID(keylet.key), amount(vault.asset(2))); + env(coverClawback(issuer), kLOAN_BROKER_ID(keylet.key), kAMOUNT(vault.asset(2))); env.close(); verifyCoverAmount(4); @@ -419,32 +419,32 @@ class LoanBroker_test : public beast::unit_test::suite // defer autofills until submission time env.json( coverClawback(issuer), - loanBrokerID(keylet.key), - fee(none), - seq(none), - sig(none)), + kLOAN_BROKER_ID(keylet.key), + Fee(kNONE), + Seq(kNONE), + Sig(kNONE)), env.json( coverClawback(issuer), - loanBrokerID(keylet.key), - amount(vault.asset(0)), - fee(none), - seq(none), - sig(none)), + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(vault.asset(0)), + Fee(kNONE), + Seq(kNONE), + Sig(kNONE)), env.json( coverClawback(issuer), - loanBrokerID(keylet.key), - amount(vault.asset(6)), - fee(none), - seq(none), - sig(none)), + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(vault.asset(6)), + Fee(kNONE), + Seq(kNONE), + Sig(kNONE)), // amount will be truncated to what's available env.json( coverClawback(issuer), - loanBrokerID(keylet.key), - amount(vault.asset(100)), - fee(none), - seq(none), - sig(none)), + kLOAN_BROKER_ID(keylet.key), + kAMOUNT(vault.asset(100)), + Fee(kNONE), + Seq(kNONE), + Sig(kNONE)), }) { // Issuer claws it all back @@ -460,7 +460,7 @@ class LoanBroker_test : public beast::unit_test::suite } // no-op - env(set(alice, vault.vaultID), loanBrokerID(keylet.key)); + env(set(alice, vault.vaultID), kLOAN_BROKER_ID(keylet.key)); env.close(); // Make modifications to the broker @@ -477,9 +477,9 @@ class LoanBroker_test : public beast::unit_test::suite // Debt maximum: explicit 0 // Data: explicit empty env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - debtMaximum(Number(0)), - data("")); + kLOAN_BROKER_ID(broker->key()), + kDEBT_MAXIMUM(Number(0)), + kDATA("")); env.close(); // Check the updated fields @@ -491,9 +491,9 @@ class LoanBroker_test : public beast::unit_test::suite ///////////////////////////////////// // try to delete the wrong broker object - env(del(alice, vault.vaultID), ter(tecNO_ENTRY)); + env(del(alice, vault.vaultID), Ter(tecNO_ENTRY)); // evan tries to delete the broker - env(del(evan, keylet.key), ter(tecNO_PERMISSION)); + env(del(evan, keylet.key), Ter(tecNO_PERMISSION)); // Get the "bad" broker out of the way env(del(alice, badKeylet.key)); @@ -504,7 +504,7 @@ class LoanBroker_test : public beast::unit_test::suite auto const aliceBalance = env.balance(alice, vault.asset); auto const coverFunds = env.balance(pseudoAccount, vault.asset); BEAST_EXPECT(coverFunds.number() == broker->at(sfCoverAvailable)); - BEAST_EXPECT(coverFunds != beast::zero); + BEAST_EXPECT(coverFunds != beast::kZERO); verifyCoverAmount(6); // delete the broker @@ -529,8 +529,8 @@ class LoanBroker_test : public beast::unit_test::suite auto const expectedBalance = aliceBalance + coverFunds - (aliceBalance.value().native() ? STAmount(env.current()->fees().base.value()) : vault.asset(0)); - env.require(balance(alice, expectedBalance)); - env.require(balance(pseudoAccount, vault.asset(none))); + env.require(Balance(alice, expectedBalance)); + env.require(Balance(pseudoAccount, vault.asset(kNONE))); } } @@ -542,7 +542,7 @@ class LoanBroker_test : public beast::unit_test::suite // Create 3 loan brokers: one for XRP, one for an IOU, and one for an // MPT. That'll require three corresponding SAVs. - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; // For simplicity, alice will be the sole actor for the vault & brokers. @@ -572,7 +572,7 @@ class LoanBroker_test : public beast::unit_test::suite env(pay(issuer, alice, iouAsset(100'000))); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); env.close(); PrettyAsset const mptAsset = mptt["MPT"]; @@ -645,64 +645,66 @@ class LoanBroker_test : public beast::unit_test::suite auto badKeylet = keylet::vault(alice.id(), env.seq(alice)); // Try some failure cases // not the vault owner - env(set(evan, vault.vaultID), ter(tecNO_PERMISSION)); + env(set(evan, vault.vaultID), Ter(tecNO_PERMISSION)); // not a vault - env(set(alice, badKeylet.key), ter(tecNO_ENTRY)); + env(set(alice, badKeylet.key), Ter(tecNO_ENTRY)); // flags are checked first - env(set(evan, vault.vaultID, ~tfUniversal), ter(temINVALID_FLAG)); + env(set(evan, vault.vaultID, ~tfUniversal), Ter(temINVALID_FLAG)); // field length validation // sfData: good length, bad account env(set(evan, vault.vaultID), - data(std::string(maxDataPayloadLength, 'X')), - ter(tecNO_PERMISSION)); + kDATA(std::string(kMAX_DATA_PAYLOAD_LENGTH, 'X')), + Ter(tecNO_PERMISSION)); // sfData: too long env(set(evan, vault.vaultID), - data(std::string(maxDataPayloadLength + 1, 'Y')), - ter(temINVALID)); + kDATA(std::string(kMAX_DATA_PAYLOAD_LENGTH + 1, 'Y')), + Ter(temINVALID)); // sfManagementFeeRate: good value, bad account env(set(evan, vault.vaultID), - managementFeeRate(maxManagementFeeRate), - ter(tecNO_PERMISSION)); + kMANAGEMENT_FEE_RATE(kMAX_MANAGEMENT_FEE_RATE), + Ter(tecNO_PERMISSION)); // sfManagementFeeRate: too big env(set(evan, vault.vaultID), - managementFeeRate(maxManagementFeeRate + TenthBips16(10)), - ter(temINVALID)); + kMANAGEMENT_FEE_RATE(kMAX_MANAGEMENT_FEE_RATE + TenthBips16(10)), + Ter(temINVALID)); // sfCoverRateMinimum and sfCoverRateLiquidation are linked // Cover: good value, bad account env(set(evan, vault.vaultID), - coverRateMinimum(maxCoverRate), - coverRateLiquidation(maxCoverRate), - ter(tecNO_PERMISSION)); + kCOVER_RATE_MINIMUM(kMAX_COVER_RATE), + kCOVER_RATE_LIQUIDATION(kMAX_COVER_RATE), + Ter(tecNO_PERMISSION)); // CoverMinimum: too big env(set(evan, vault.vaultID), - coverRateMinimum(maxCoverRate + 1), - coverRateLiquidation(maxCoverRate + 1), - ter(temINVALID)); + kCOVER_RATE_MINIMUM(kMAX_COVER_RATE + 1), + kCOVER_RATE_LIQUIDATION(kMAX_COVER_RATE + 1), + Ter(temINVALID)); // CoverLiquidation: too big env(set(evan, vault.vaultID), - coverRateMinimum(maxCoverRate / 2), - coverRateLiquidation(maxCoverRate + 1), - ter(temINVALID)); + kCOVER_RATE_MINIMUM(kMAX_COVER_RATE / 2), + kCOVER_RATE_LIQUIDATION(kMAX_COVER_RATE + 1), + Ter(temINVALID)); // Cover: zero min, non-zero liquidation - implicit and // explicit zero values. - env(set(evan, vault.vaultID), coverRateLiquidation(maxCoverRate), ter(temINVALID)); env(set(evan, vault.vaultID), - coverRateMinimum(tenthBipsZero), - coverRateLiquidation(maxCoverRate), - ter(temINVALID)); + kCOVER_RATE_LIQUIDATION(kMAX_COVER_RATE), + Ter(temINVALID)); + env(set(evan, vault.vaultID), + kCOVER_RATE_MINIMUM(tenthBipsZero), + kCOVER_RATE_LIQUIDATION(kMAX_COVER_RATE), + Ter(temINVALID)); // Cover: non-zero min, zero liquidation - implicit and // explicit zero values. - env(set(evan, vault.vaultID), coverRateMinimum(maxCoverRate), ter(temINVALID)); + env(set(evan, vault.vaultID), kCOVER_RATE_MINIMUM(kMAX_COVER_RATE), Ter(temINVALID)); env(set(evan, vault.vaultID), - coverRateMinimum(maxCoverRate), - coverRateLiquidation(tenthBipsZero), - ter(temINVALID)); + kCOVER_RATE_MINIMUM(kMAX_COVER_RATE), + kCOVER_RATE_LIQUIDATION(tenthBipsZero), + Ter(temINVALID)); // sfDebtMaximum: good value, bad account - env(set(evan, vault.vaultID), debtMaximum(Number(0)), ter(tecNO_PERMISSION)); + env(set(evan, vault.vaultID), kDEBT_MAXIMUM(Number(0)), Ter(tecNO_PERMISSION)); // sfDebtMaximum: overflow - env(set(evan, vault.vaultID), debtMaximum(Number(1, 100)), ter(temINVALID)); + env(set(evan, vault.vaultID), kDEBT_MAXIMUM(Number(1, 100)), Ter(temINVALID)); // sfDebtMaximum: negative - env(set(evan, vault.vaultID), debtMaximum(Number(-1)), ter(temINVALID)); + env(set(evan, vault.vaultID), kDEBT_MAXIMUM(Number(-1)), Ter(temINVALID)); std::string testData; lifecycle( @@ -737,57 +739,61 @@ class LoanBroker_test : public beast::unit_test::suite // fields that can't be changed // LoanBrokerID - env(set(alice, vault.vaultID), loanBrokerID(nextKeylet.key), ter(tecNO_ENTRY)); + env(set(alice, vault.vaultID), + kLOAN_BROKER_ID(nextKeylet.key), + Ter(tecNO_ENTRY)); // VaultID - env(set(alice, nextKeylet.key), loanBrokerID(broker->key()), ter(tecNO_ENTRY)); + env(set(alice, nextKeylet.key), + kLOAN_BROKER_ID(broker->key()), + Ter(tecNO_ENTRY)); // Owner env(set(evan, vault.vaultID), - loanBrokerID(broker->key()), - ter(tecNO_PERMISSION)); + kLOAN_BROKER_ID(broker->key()), + Ter(tecNO_PERMISSION)); // ManagementFeeRate env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - managementFeeRate(maxManagementFeeRate), - ter(temINVALID)); + kLOAN_BROKER_ID(broker->key()), + kMANAGEMENT_FEE_RATE(kMAX_MANAGEMENT_FEE_RATE), + Ter(temINVALID)); // CoverRateMinimum env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - coverRateMinimum(maxManagementFeeRate), - ter(temINVALID)); + kLOAN_BROKER_ID(broker->key()), + kCOVER_RATE_MINIMUM(kMAX_MANAGEMENT_FEE_RATE), + Ter(temINVALID)); // CoverRateLiquidation env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - coverRateLiquidation(maxManagementFeeRate), - ter(temINVALID)); + kLOAN_BROKER_ID(broker->key()), + kCOVER_RATE_LIQUIDATION(kMAX_MANAGEMENT_FEE_RATE), + Ter(temINVALID)); // fields that can be changed testData = "Test Data 1234"; // Bad data: too long env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - data(std::string(maxDataPayloadLength + 1, 'W')), - ter(temINVALID)); + kLOAN_BROKER_ID(broker->key()), + kDATA(std::string(kMAX_DATA_PAYLOAD_LENGTH + 1, 'W')), + Ter(temINVALID)); // Bad debt maximum env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - debtMaximum(Number(-175, -1)), - ter(temINVALID)); + kLOAN_BROKER_ID(broker->key()), + kDEBT_MAXIMUM(Number(-175, -1)), + Ter(temINVALID)); Number debtMax{175, -1}; if (vault.asset.integral()) { env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - data(testData), - debtMaximum(debtMax), - ter(tecPRECISION_LOSS)); + kLOAN_BROKER_ID(broker->key()), + kDATA(testData), + kDEBT_MAXIMUM(debtMax), + Ter(tecPRECISION_LOSS)); roundToAsset(vault.asset, debtMax); } // Data & Debt maximum env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - data(testData), - debtMaximum(debtMax)); + kLOAN_BROKER_ID(broker->key()), + kDATA(testData), + kDEBT_MAXIMUM(debtMax)); }, [&](SLE::const_ref broker) { // Check the updated fields @@ -810,15 +816,15 @@ class LoanBroker_test : public beast::unit_test::suite badVault, [&](jtx::JTx const& jv) { testData = "spam spam spam spam"; - // Finally, create another Loan Broker with none of the + // Finally, create another Loan Broker with kNONE of the // values at default return env.jt( jv, - data(testData), - managementFeeRate(TenthBips16(123)), - debtMaximum(Number(9)), - coverRateMinimum(TenthBips32(100)), - coverRateLiquidation(TenthBips32(200))); + kDATA(testData), + kMANAGEMENT_FEE_RATE(TenthBips16(123)), + kDEBT_MAXIMUM(Number(9)), + kCOVER_RATE_MINIMUM(TenthBips32(100)), + kCOVER_RATE_LIQUIDATION(TenthBips32(200))); }, [&](SLE::const_ref broker) { // Extra checks @@ -831,9 +837,9 @@ class LoanBroker_test : public beast::unit_test::suite [&](SLE::const_ref broker) { // Reset Data & Debt maximum to default values env(set(alice, vault.vaultID), - loanBrokerID(broker->key()), - data(""), - debtMaximum(Number(0))); + kLOAN_BROKER_ID(broker->key()), + kDATA(""), + kDEBT_MAXIMUM(Number(0))); }, [&](SLE::const_ref broker) { // Check the updated fields @@ -901,23 +907,23 @@ class LoanBroker_test : public beast::unit_test::suite auto jv = getTxJv(); // empty broker ID jv[sfLoanBrokerID] = ""; - env(jv, ter(temINVALID)); + env(jv, Ter(temINVALID)); // zero broker ID jv[sfLoanBrokerID] = to_string(uint256{}); // needs a flag to distinguish the parsed STTx from the prior // test - env(jv, txflags(tfFullyCanonicalSig), ter(temINVALID)); + env(jv, Txflags(tfFullyCanonicalSig), Ter(temINVALID)); }; auto testZeroVaultID = [&](auto&& getTxJv) { auto jv = getTxJv(); // empty broker ID jv[sfVaultID] = ""; - env(jv, ter(temINVALID)); + env(jv, Ter(temINVALID)); // zero broker ID jv[sfVaultID] = to_string(uint256{}); // needs a flag to distinguish the parsed STTx from the prior // test - env(jv, txflags(tfFullyCanonicalSig), ter(temINVALID)); + env(jv, Txflags(tfFullyCanonicalSig), Ter(temINVALID)); }; if (brokerTest == LoanBrokerTest::CoverDeposit) @@ -926,18 +932,18 @@ class LoanBroker_test : public beast::unit_test::suite testZeroBrokerID([&]() { return coverDeposit(alice, brokerKeylet.key, asset(10)); }); // preclaim: tecWRONG_ASSET - env(coverDeposit(alice, brokerKeylet.key, issuer["BAD"](10)), ter(tecWRONG_ASSET)); + env(coverDeposit(alice, brokerKeylet.key, issuer["BAD"](10)), Ter(tecWRONG_ASSET)); // preclaim: tecINSUFFICIENT_FUNDS env(pay(alice, issuer, asset(100'000 - 50))); env.close(); env(coverDeposit(alice, brokerKeylet.key, vaultInfo.asset(10)), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); // preclaim: tecFROZEN env(fset(issuer, asfGlobalFreeze)); env.close(); - env(coverDeposit(alice, brokerKeylet.key, vaultInfo.asset(10)), ter(tecFROZEN)); + env(coverDeposit(alice, brokerKeylet.key, vaultInfo.asset(10)), Ter(tecFROZEN)); } else { @@ -952,13 +958,13 @@ class LoanBroker_test : public beast::unit_test::suite testZeroBrokerID([&]() { return coverWithdraw(alice, brokerKeylet.key, asset(10)); }); // preclaim: tecWRONG_ASSET - env(coverWithdraw(alice, brokerKeylet.key, issuer["BAD"](10)), ter(tecWRONG_ASSET)); + env(coverWithdraw(alice, brokerKeylet.key, issuer["BAD"](10)), Ter(tecWRONG_ASSET)); // preclaim: tecNO_DST Account const bogus{"bogus"}; env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(bogus), - ter(tecNO_DST)); + kDESTINATION(bogus), + Ter(tecNO_DST)); // preclaim: tecDST_TAG_NEEDED Account const dest{"dest"}; @@ -966,16 +972,16 @@ class LoanBroker_test : public beast::unit_test::suite env(fset(dest, asfRequireDest)); env.close(); env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(dest), - ter(tecDST_TAG_NEEDED)); + kDESTINATION(dest), + Ter(tecDST_TAG_NEEDED)); // preclaim: tecNO_PERMISSION env(fclear(dest, asfRequireDest)); env(fset(dest, asfDepositAuth)); env.close(); env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(dest), - ter(tecNO_PERMISSION)); + kDESTINATION(dest), + Ter(tecNO_PERMISSION)); // preclaim: tecFROZEN env(trust(dest, asset(1'000))); @@ -983,20 +989,20 @@ class LoanBroker_test : public beast::unit_test::suite env(fset(issuer, asfGlobalFreeze)); env.close(); env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(dest), - ter(tecFROZEN)); + kDESTINATION(dest), + Ter(tecFROZEN)); // preclaim:: tecFROZEN (deep frozen) env(fclear(issuer, asfGlobalFreeze)); env(trust(issuer, asset(1'000), dest, tfSetFreeze | tfSetDeepFreeze)); env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(dest), - ter(tecFROZEN)); + kDESTINATION(dest), + Ter(tecFROZEN)); // preclaim: tecPSEUDO_ACCOUNT env(coverWithdraw(alice, brokerKeylet.key, asset(10)), - destination(vaultInfo.pseudoAccount), - ter(tecPSEUDO_ACCOUNT)); + kDESTINATION(vaultInfo.pseudoAccount), + Ter(tecPSEUDO_ACCOUNT)); } if (brokerTest == LoanBrokerTest::CoverClawback) @@ -1005,33 +1011,33 @@ class LoanBroker_test : public beast::unit_test::suite testZeroBrokerID([&]() { return env.json( coverClawback(alice), - loanBrokerID(brokerKeylet.key), - amount(vaultInfo.asset(2))); + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(vaultInfo.asset(2))); }); if (asset.holds()) { // preclaim: AllowTrustLineClawback is not set env(coverClawback(issuer), - loanBrokerID(brokerKeylet.key), - amount(vaultInfo.asset(2)), - ter(tecNO_PERMISSION)); + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(vaultInfo.asset(2)), + Ter(tecNO_PERMISSION)); // preclaim: NoFreeze is set env(fset(issuer, asfAllowTrustLineClawback | asfNoFreeze)); env.close(); env(coverClawback(issuer), - loanBrokerID(brokerKeylet.key), - amount(vaultInfo.asset(2)), - ter(tecNO_PERMISSION)); + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(vaultInfo.asset(2)), + Ter(tecNO_PERMISSION)); } else { // preclaim: MPTCanClawback is not set or MPTCanLock is not set env(coverClawback(issuer), - loanBrokerID(brokerKeylet.key), - amount(vaultInfo.asset(2)), - ter(tecNO_PERMISSION)); + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(vaultInfo.asset(2)), + Ter(tecNO_PERMISSION)); } env.close(); } @@ -1041,14 +1047,14 @@ class LoanBroker_test : public beast::unit_test::suite Account const borrower{"borrower"}; env.fund(XRP(1'000), borrower); env(loan::set(borrower, brokerKeylet.key, asset(50).value()), - sig(sfCounterpartySignature, alice), - fee(env.current()->fees().base * 2)); + Sig(sfCounterpartySignature, alice), + Fee(env.current()->fees().base * 2)); // preflight: temINVALID (empty/zero broker id) testZeroBrokerID([&]() { return del(alice, brokerKeylet.key); }); // preclaim: tecHAS_OBLIGATIONS - env(del(alice, brokerKeylet.key), ter(tecHAS_OBLIGATIONS)); + env(del(alice, brokerKeylet.key), Ter(tecHAS_OBLIGATIONS)); // Repay and delete the loan auto const loanKeylet = keylet::loan(brokerKeylet.key, 1); @@ -1057,11 +1063,11 @@ class LoanBroker_test : public beast::unit_test::suite env(trust(issuer, asset(0), alice, tfSetFreeze | tfSetDeepFreeze)); // preclaim: tecFROZEN (deep frozen) - env(del(alice, brokerKeylet.key), ter(tecFROZEN)); + env(del(alice, brokerKeylet.key), Ter(tecFROZEN)); env(trust(issuer, asset(0), alice, tfClearFreeze | tfClearDeepFreeze)); // successful delete the loan broker object - env(del(alice, brokerKeylet.key), ter(tesSUCCESS)); + env(del(alice, brokerKeylet.key), Ter(tesSUCCESS)); } else { @@ -1072,11 +1078,11 @@ class LoanBroker_test : public beast::unit_test::suite { // preflight: temINVALID (empty/zero broker id) testZeroBrokerID([&]() { - return env.json(set(alice, vaultInfo.vaultID), loanBrokerID(brokerKeylet.key)); + return env.json(set(alice, vaultInfo.vaultID), kLOAN_BROKER_ID(brokerKeylet.key)); }); // preflight: temINVALID (empty/zero vault id) testZeroVaultID([&]() { - return env.json(set(alice, vaultInfo.vaultID), loanBrokerID(brokerKeylet.key)); + return env.json(set(alice, vaultInfo.vaultID), kLOAN_BROKER_ID(brokerKeylet.key)); }); if (asset.holds()) @@ -1084,7 +1090,7 @@ class LoanBroker_test : public beast::unit_test::suite env(fclear(issuer, asfDefaultRipple)); env.close(); // preclaim: DefaultRipple is not set - env(set(alice, vaultInfo.vaultID), ter(terNO_RIPPLE)); + env(set(alice, vaultInfo.vaultID), Ter(terNO_RIPPLE)); env(fset(issuer, asfDefaultRipple)); env.close(); @@ -1095,7 +1101,7 @@ class LoanBroker_test : public beast::unit_test::suite env(pay(alice, issuer, amt)); // preclaim:: tecINSUFFICIENT_RESERVE - env(set(alice, vaultInfo.vaultID), ter(tecINSUFFICIENT_RESERVE)); + env(set(alice, vaultInfo.vaultID), Ter(tecINSUFFICIENT_RESERVE)); } } @@ -1110,18 +1116,18 @@ class LoanBroker_test : public beast::unit_test::suite { Account const alice{"alice"}; Account const issuer{"issuer"}; - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; Env env(*this); env.fund(XRP(100'000), alice); env.close(); - auto jtx = env.jt(coverClawback(alice), amount(USD(100))); + auto jtx = env.jt(coverClawback(alice), kAMOUNT(usd(100))); // holder == account - env(jtx, ter(temINVALID)); + env(jtx, Ter(temINVALID)); // holder == beast::zero - STAmount const bad(Issue{USD.currency, beast::zero}, 100); + STAmount const bad(Issue{usd.currency, beast::kZERO}, 100); jtx.jv[sfAmount] = bad.getJson(); jtx.stx = env.ust(jtx); Serializer s; @@ -1243,9 +1249,9 @@ class LoanBroker_test : public beast::unit_test::suite // Create a writable view cloned from the current ledger and remove the // vault SLE OpenView ov{*env.current()}; - test::StreamSink sink{beast::severities::kWarning}; + test::StreamSink sink{beast::severities::KWarning}; beast::Journal const jlog{sink}; - ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, tapNONE, jlog}; + ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog}; if (auto sleBroker = ac.view().peek(keylet::loanbroker(brokerKeylet.key))) { @@ -1258,7 +1264,7 @@ class LoanBroker_test : public beast::unit_test::suite // Invoke preclaim against the mutated (ApplyView) view; triggers // nullptr deref - PreclaimContext const pctx{env.app(), ac.view(), tesSUCCESS, tx, tapNONE, jlog}; + PreclaimContext const pctx{env.app(), ac.view(), tesSUCCESS, tx, TapNone, jlog}; (void)LoanBrokerCoverDeposit::preclaim(pctx); } @@ -1281,7 +1287,7 @@ class LoanBroker_test : public beast::unit_test::suite .env = env, .issuer = issuer, .holders = {alice}, - .flags = MPTDEXFlags | tfMPTRequireAuth | tfMPTCanClawback | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth | tfMPTCanClawback | tfMPTCanLock, .authHolder = true, }); @@ -1322,14 +1328,14 @@ class LoanBroker_test : public beast::unit_test::suite // Can't deposit into Vault if the vault owner is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(vault.deposit({.depositor = alice, .id = vaultKeylet.key, .amount = asset(51)}), err); }); // Can't withdraw from Vault if the vault owner is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(vault.withdraw({.depositor = alice, .id = vaultKeylet.key, .amount = asset(1)}), err); }); @@ -1352,19 +1358,21 @@ class LoanBroker_test : public beast::unit_test::suite // Can't cover deposit into Vault if the vault owner is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(coverDeposit(alice, brokerKeylet.key, vaultInfo.asset(10)), err); }); // Can't cover withdraw from Vault if the vault owner is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(coverWithdraw(alice, brokerKeylet.key, vaultInfo.asset(5)), err); }); // Issuer can always cover clawback. The holder authorization is n/a. forUnauthAuth([&](bool) { - env(coverClawback(issuer), loanBrokerID(brokerKeylet.key), amount(vaultInfo.asset(1))); + env(coverClawback(issuer), + kLOAN_BROKER_ID(brokerKeylet.key), + kAMOUNT(vaultInfo.asset(1))); }); } @@ -1383,7 +1391,7 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); PrettyAsset const asset = [&]() { - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); env.close(); PrettyAsset const mptAsset = mptt["MPT"]; @@ -1417,8 +1425,8 @@ class LoanBroker_test : public beast::unit_test::suite Account const borrower{"borrower"}; env.fund(XRP(1'000), borrower); env(loan::set(borrower, brokerKeylet.key, asset(50).value()), - sig(sfCounterpartySignature, alice), - fee(env.current()->fees().base * 2)); + Sig(sfCounterpartySignature, alice), + Fee(env.current()->fees().base * 2)); auto const broker = env.le(brokerKeylet); if (!BEAST_EXPECT(broker)) return; @@ -1429,47 +1437,47 @@ class LoanBroker_test : public beast::unit_test::suite auto tx2 = set(alice, vaultInfo.vaultID); tx2[sfLoanBrokerID] = to_string(brokerKeylet.key); tx2[sfDebtMaximum] = debtTotal - 1; - env(tx2, ter(tecLIMIT_EXCEEDED)); + env(tx2, Ter(tecLIMIT_EXCEEDED)); tx2[sfDebtMaximum] = debtTotal + 1; - env(tx2, ter(tesSUCCESS)); + env(tx2, Ter(tesSUCCESS)); tx2[sfDebtMaximum] = 0; - env(tx2, ter(tesSUCCESS)); + env(tx2, Ter(tesSUCCESS)); - tx2[sfDebtMaximum] = Json::Value::maxInt; - env(tx2, ter(tesSUCCESS)); + tx2[sfDebtMaximum] = json::Value::kMAX_INT; + env(tx2, Ter(tesSUCCESS)); { auto const dm = power(2, 64) - 1; - BEAST_EXPECT(dm > maxMPTokenAmount); + BEAST_EXPECT(dm > kMAX_MP_TOKEN_AMOUNT); tx2[sfDebtMaximum] = dm; - env(tx2, ter(temINVALID)); + env(tx2, Ter(temINVALID)); } { auto const dm = power(2, 63) - 1; - BEAST_EXPECTS(dm > maxMPTokenAmount, to_string(dm)); + BEAST_EXPECTS(dm > kMAX_MP_TOKEN_AMOUNT, to_string(dm)); tx2[sfDebtMaximum] = dm; - env(tx2, ter(temINVALID)); + env(tx2, Ter(temINVALID)); } { auto const dm = power(2, 63) - 3; - BEAST_EXPECTS(dm == maxMPTokenAmount, to_string(dm)); + BEAST_EXPECTS(dm == kMAX_MP_TOKEN_AMOUNT, to_string(dm)); tx2[sfDebtMaximum] = dm; - env(tx2, ter(tesSUCCESS)); + env(tx2, Ter(tesSUCCESS)); } { auto const dm = 2 * (power(2, 62) - 1) + 1; - BEAST_EXPECTS(dm == maxMPTokenAmount, to_string(dm)); + BEAST_EXPECTS(dm == kMAX_MP_TOKEN_AMOUNT, to_string(dm)); tx2[sfDebtMaximum] = dm; - env(tx2, ter(tesSUCCESS)); + env(tx2, Ter(tesSUCCESS)); } tx2[sfDebtMaximum] = Number{9223372036854775807, 0}; - env(tx2, ter(tesSUCCESS)); + env(tx2, Ter(tesSUCCESS)); } void @@ -1495,7 +1503,7 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(vault.deposit({.depositor = broker, .id = keylet.key, .amount = deposit}), - ter(err)); + Ter(err)); env.close(); auto const brokerKeylet = keylet::loanbroker(broker, env.seq(broker)); @@ -1503,7 +1511,7 @@ class LoanBroker_test : public beast::unit_test::suite env(loanBroker::set(broker, keylet.key)); env.close(); - env(loanBroker::coverDeposit(broker, brokerKeylet.key, deposit), ter(err)); + env(loanBroker::coverDeposit(broker, brokerKeylet.key, deposit), Ter(err)); env.close(); }; @@ -1525,14 +1533,14 @@ class LoanBroker_test : public beast::unit_test::suite {2'000, 2'500, 250, tesSUCCESS}, // issuer can issue 500 tokens (250 VaultDeposit + // 250 LoanBrokerCoverDeposit). MaximumAmount is default. - {maxMPTokenAmount - 500, std::nullopt, 250, tesSUCCESS}, + {kMAX_MP_TOKEN_AMOUNT - 500, std::nullopt, 250, tesSUCCESS}, // issuer can issue 500, and fails on depositing 1'000 {2'000, 2'500, 1'000, tecINSUFFICIENT_FUNDS}, // issuer has already issued MaximumAmount {2'000, 2'000, 1'000, tecINSUFFICIENT_FUNDS}, // issuer has already issued MaximumAmount. MaximumAmount is // default. - {maxMPTokenAmount, std::nullopt, 250, tecINSUFFICIENT_FUNDS}, + {kMAX_MP_TOKEN_AMOUNT, std::nullopt, 250, tecINSUFFICIENT_FUNDS}, }; for (auto const& [pay, max, deposit, err] : mptTests) { @@ -1542,7 +1550,7 @@ class LoanBroker_test : public beast::unit_test::suite .issuer = issuer, .holders = {holder}, .pay = pay, - .flags = MPTDEXFlags, + .flags = kMPT_DEX_FLAGS, .maxAmt = max}); return std::make_tuple(token, token(deposit), err); }); @@ -1550,7 +1558,7 @@ class LoanBroker_test : public beast::unit_test::suite } void - testAMB06_VaultFreezeCheckMissing() + testAmB06VaultFreezeCheckMissing() { testcase << "RIPD-4466 - LoanBrokerSet disallows frozen vaults"; using namespace jtx; @@ -1558,10 +1566,10 @@ class LoanBroker_test : public beast::unit_test::suite Account const issuer{"issuer"}, lender{"lender"}, borrower{"borrower"}; env.fund(XRP(20'000), issuer, lender, borrower); - auto const IOU = issuer["IOU"]; + auto const iou = issuer["IOU"]; Vault const vault{env}; - auto [tx, vaultKeylet] = vault.create({.owner = lender, .asset = IOU.asset()}); + auto [tx, vaultKeylet] = vault.create({.owner = lender, .asset = iou.asset()}); env(tx); env.close(); @@ -1571,7 +1579,7 @@ class LoanBroker_test : public beast::unit_test::suite auto const vaultPseudoAcct = Account("VaultPseudo", vaultPseudo); env(trust(issuer, vaultPseudoAcct["IOU"](0), tfSetFreeze)); - env(loanBroker::set(lender, vaultKeylet.key), ter(tecFROZEN)); + env(loanBroker::set(lender, vaultKeylet.key), Ter(tecFROZEN)); } void @@ -1658,8 +1666,8 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(vault.withdraw({.depositor = broker, .id = keylet.key, .amount = token(1'000)}), - loanBroker::destination(dest), - ter(std::ignore)); + loanBroker::kDESTINATION(dest), + Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); @@ -1675,8 +1683,8 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::destination(dest), - ter(std::ignore)); + loanBroker::kDESTINATION(dest), + Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); @@ -1687,8 +1695,8 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::destination(dest), - ter(std::ignore)); + loanBroker::kDESTINATION(dest), + Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); } @@ -1732,7 +1740,7 @@ class LoanBroker_test : public beast::unit_test::suite .issuer = issuer, .holders = {broker, dest}, .pay = 2'000, - .flags = MPTDEXFlags | tfMPTRequireAuth, + .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth, .authHolder = true, .maxAmt = 5'000}); // unauthorize dest @@ -1746,7 +1754,7 @@ class LoanBroker_test : public beast::unit_test::suite .issuer = issuer, .holders = {broker, dest}, .pay = 2'000, - .flags = MPTDEXFlags, + .flags = kMPT_DEX_FLAGS, .maxAmt = 4'000}); BEAST_EXPECT(env.balance(issuer, tester) == tester(-4'000)); return tester; @@ -1757,7 +1765,7 @@ class LoanBroker_test : public beast::unit_test::suite .issuer = issuer, .holders = {broker}, .pay = 2'000, - .flags = MPTDEXFlags, + .flags = kMPT_DEX_FLAGS, .maxAmt = 4'000}); } default: @@ -1779,8 +1787,8 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(vault.withdraw({.depositor = broker, .id = keylet.key, .amount = token(1'000)}), - loanBroker::destination(dest), - ter(std::ignore)); + loanBroker::kDESTINATION(dest), + Ter(std::ignore)); // Shouldn't fail if at MaximumAmount since no new tokens are issued TER const err = mptState == MPTState::ReachedMAX ? TER(tesSUCCESS) : tecNO_AUTH; @@ -1803,8 +1811,8 @@ class LoanBroker_test : public beast::unit_test::suite env.close(); env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::destination(dest), - ter(std::ignore)); + loanBroker::kDESTINATION(dest), + Ter(std::ignore)); BEAST_EXPECT(env.ter() == err); env.close(); }; @@ -1838,7 +1846,7 @@ public: testRequireAuth(); testRIPD4323(); - testAMB06_VaultFreezeCheckMissing(); + testAmB06VaultFreezeCheckMissing(); testRIPD4274(); diff --git a/src/test/app/Loan_test.cpp b/src/test/app/Loan_test.cpp index ad87603661..f189196a82 100644 --- a/src/test/app/Loan_test.cpp +++ b/src/test/app/Loan_test.cpp @@ -82,14 +82,14 @@ namespace xrpl::test { -class Loan_test : public beast::unit_test::suite +class Loan_test : public beast::unit_test::Suite { protected: // Ensure that all the features needed for Lending Protocol are included, // even if they are set to unsupported. - FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const all_{jtx::testableAmendments()}; - std::string const iouCurrency{"IOU"}; + std::string const iouCurrency_{"IOU"}; void testDisabled() @@ -114,28 +114,28 @@ protected: // counter party signature is optional on LoanSet. Confirm that by // sending transaction without one. - auto setTx = env.jt(set(alice, keylet.key, Number(10000)), ter(temDISABLED)); + auto setTx = env.jt(set(alice, keylet.key, Number(10000)), Ter(temDISABLED)); env(setTx); // All loan transactions are disabled. // 1. LoanSet - setTx = env.jt(setTx, sig(sfCounterpartySignature, bob), ter(temDISABLED)); + setTx = env.jt(setTx, Sig(sfCounterpartySignature, bob), Ter(temDISABLED)); env(setTx); // Actual sequence will be based off the loan broker, but we // obviously don't have one of those if the amendment is disabled auto const loanKeylet = keylet::loan(keylet.key, env.seq(alice)); // Other Loan transactions are disabled, too. // 2. LoanDelete - env(del(alice, loanKeylet.key), ter(temDISABLED)); + env(del(alice, loanKeylet.key), Ter(temDISABLED)); // 3. LoanManage - env(manage(alice, loanKeylet.key, tfLoanImpair), ter(temDISABLED)); + env(manage(alice, loanKeylet.key, tfLoanImpair), Ter(temDISABLED)); // 4. LoanPay - env(pay(alice, loanKeylet.key, XRP(500)), ter(temDISABLED)); + env(pay(alice, loanKeylet.key, XRP(500)), Ter(temDISABLED)); }; - failAll(all - featureMPTokensV1); - failAll(all - featureSingleAssetVault - featureLendingProtocol); - failAll(all - featureSingleAssetVault); - failAll(all - featureLendingProtocol); + failAll(all_ - featureMPTokensV1); + failAll(all_ - featureSingleAssetVault - featureLendingProtocol); + failAll(all_ - featureSingleAssetVault); + failAll(all_ - featureLendingProtocol); } struct BrokerParameters @@ -152,8 +152,8 @@ protected: [[nodiscard]] Number maxCoveredLoanValue(Number const& currentDebt) const { - NumberRoundModeGuard const mg(Number::rounding_mode::downward); - auto debtLimit = coverDeposit * tenthBipsPerUnity.value() / coverRateMin.value(); + NumberRoundModeGuard const mg(Number::RoundingMode::Downward); + auto debtLimit = coverDeposit * kTENTH_BIPS_PER_UNITY.value() / coverRateMin.value(); return debtLimit - currentDebt; } @@ -161,8 +161,8 @@ protected: static BrokerParameters const& defaults() { - static BrokerParameters const result{}; - return result; + static BrokerParameters const kRESULT{}; + return kRESULT; } // TODO: create an operator() which returns a transaction similar to @@ -176,13 +176,13 @@ protected: uint256 vaultID; BrokerParameters params; BrokerInfo( - jtx::PrettyAsset const& asset_, - Keylet const& brokerKeylet_, - Keylet const& vaultKeylet_, + jtx::PrettyAsset const& asset, + Keylet const& brokerKeylet, + Keylet const& vaultKeylet, BrokerParameters p) - : asset(asset_) - , brokerID(brokerKeylet_.key) - , vaultID(vaultKeylet_.key) + : asset(asset) + , brokerID(brokerKeylet.key) + , vaultID(vaultKeylet.key) , params(std::move(p)) { } @@ -248,36 +248,36 @@ protected: broker.asset(principalRequest).number(), flags.value_or(0))}; - sig(sfCounterpartySignature, counter)(env, jt); + Sig(sfCounterpartySignature, counter)(env, jt); - fee{setFee.value_or(env.current()->fees().base * 2)}(env, jt); + Fee{setFee.value_or(env.current()->fees().base * 2)}(env, jt); if (counterpartyExplicit) - counterparty(counter)(env, jt); + kCOUNTERPARTY(counter)(env, jt); if (originationFee) - loanOriginationFee(broker.asset(*originationFee).number())(env, jt); + kLOAN_ORIGINATION_FEE(broker.asset(*originationFee).number())(env, jt); if (serviceFee) - loanServiceFee(broker.asset(*serviceFee).number())(env, jt); + kLOAN_SERVICE_FEE(broker.asset(*serviceFee).number())(env, jt); if (lateFee) - latePaymentFee(broker.asset(*lateFee).number())(env, jt); + kLATE_PAYMENT_FEE(broker.asset(*lateFee).number())(env, jt); if (closeFee) - closePaymentFee(broker.asset(*closeFee).number())(env, jt); + kCLOSE_PAYMENT_FEE(broker.asset(*closeFee).number())(env, jt); if (overFee) - overpaymentFee (*overFee)(env, jt); + kOVERPAYMENT_FEE (*overFee)(env, jt); if (interest) - interestRate (*interest)(env, jt); + kINTEREST_RATE (*interest)(env, jt); if (lateInterest) - lateInterestRate (*lateInterest)(env, jt); + kLATE_INTEREST_RATE (*lateInterest)(env, jt); if (closeInterest) - closeInterestRate (*closeInterest)(env, jt); + kCLOSE_INTEREST_RATE (*closeInterest)(env, jt); if (overpaymentInterest) - overpaymentInterestRate (*overpaymentInterest)(env, jt); + kOVERPAYMENT_INTEREST_RATE (*overpaymentInterest)(env, jt); if (payTotal) - paymentTotal (*payTotal)(env, jt); + kPAYMENT_TOTAL (*payTotal)(env, jt); if (payInterval) - paymentInterval (*payInterval)(env, jt); + kPAYMENT_INTERVAL (*payInterval)(env, jt); if (gracePd) - gracePeriod (*gracePd)(env, jt); + kGRACE_PERIOD (*gracePd)(env, jt); return env.jt(jt, fN...); } @@ -294,8 +294,8 @@ protected: static PaymentParameters const& defaults() { - static PaymentParameters const result{}; - return result; + static PaymentParameters const kRESULT{}; + return kRESULT; } }; @@ -327,11 +327,11 @@ protected: Keylet const& loanKeylet; VerifyLoanStatus( - jtx::Env const& env_, - BrokerInfo const& broker_, - jtx::Account const& pseudo_, - Keylet const& keylet_) - : env(env_), broker(broker_), pseudoAccount(pseudo_), loanKeylet(keylet_) + jtx::Env const& env, + BrokerInfo const& broker, + jtx::Account const& pseudo, + Keylet const& keylet) + : env(env), broker(broker), pseudoAccount(pseudo), loanKeylet(keylet) { } @@ -402,7 +402,7 @@ protected: env.balance(account, broker.asset) - (balanceBefore - balanceChangeAmount), borrowerScale); env.test.expect( - roundToScale(difference, loanScale) >= beast::zero, + roundToScale(difference, loanScale) >= beast::kZERO, "Balance before: " + to_string(balanceBefore.value()) + ", expected change: " + to_string(balanceChangeAmount) + ", difference (balance after - expected): " + to_string(difference), @@ -521,13 +521,13 @@ protected: using namespace loanBroker; env(set(lender, vaultKeylet.key, params.flags), - data(params.data), - managementFeeRate(params.managementFeeRate), - debtMaximum(debtMaximumValue), - coverRateMinimum(coverRateMinValue), - coverRateLiquidation(TenthBips32(params.coverRateLiquidation))); + kDATA(params.data), + kMANAGEMENT_FEE_RATE(params.managementFeeRate), + kDEBT_MAXIMUM(debtMaximumValue), + kCOVER_RATE_MINIMUM(coverRateMinValue), + kCOVER_RATE_LIQUIDATION(TenthBips32(params.coverRateLiquidation))); - if (coverDepositValue != beast::zero) + if (coverDepositValue != beast::kZERO) env(coverDeposit(lender, keylet.key, coverDepositValue)); env.close(); @@ -588,7 +588,7 @@ protected: : std::max(broker.vaultScale(env), state.principalOutstanding.exponent()))); BEAST_EXPECT(state.paymentInterval == 600); { - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); BEAST_EXPECT( state.totalValue == roundToAsset( @@ -652,7 +652,7 @@ protected: return PrettyAsset{xrpIssue(), 1'000'000}; case AssetType::IOU: { - PrettyAsset const asset{issuer[iouCurrency]}; + PrettyAsset const asset{issuer[iouCurrency_]}; auto const limit = asset(100 * (brokerParams.vaultDeposit + brokerParams.coverDeposit)); @@ -673,7 +673,7 @@ protected: if (!env.le(keylet::account(borrower))) env.fund(env.current()->fees().accountReserve(10) * 10, noripple(borrower)); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); // Scale the MPT asset so interest is interesting PrettyAsset const asset{mptt.issuanceID(), 10'000}; @@ -709,8 +709,8 @@ protected: auto const asset = createAsset(env, assetType, brokerParams, issuer, lender, borrower); auto const principal = asset(loanParams.principalRequest).number(); auto const interest = loanParams.interest.value_or(TenthBips32{}); - auto const interval = loanParams.payInterval.value_or(LoanSet::defaultPaymentInterval); - auto const total = loanParams.payTotal.value_or(LoanSet::defaultPaymentTotal); + auto const interval = loanParams.payInterval.value_or(LoanSet::kDEFAULT_PAYMENT_INTERVAL); + auto const total = loanParams.payTotal.value_or(LoanSet::kDEFAULT_PAYMENT_TOTAL); auto const feeRate = brokerParams.managementFeeRate; auto const props = computeLoanProperties( asset, @@ -736,8 +736,8 @@ protected: BEAST_EXPECT(!checkLoanGuards( asset, asset(loanParams.principalRequest).number(), - loanParams.interest.value_or(TenthBips32{}) != beast::zero, - loanParams.payTotal.value_or(LoanSet::defaultPaymentTotal), + loanParams.interest.value_or(TenthBips32{}) != beast::kZERO, + loanParams.payTotal.value_or(LoanSet::kDEFAULT_PAYMENT_TOTAL), props, env.journal)); } @@ -844,7 +844,7 @@ protected: auto const shortage = totalNeeded - borrowerBalance.number(); - if (shortage > beast::zero && (broker.asset.native() || issuer != borrower)) + if (shortage > beast::kZERO && (broker.asset.native() || issuer != borrower)) { env( pay((broker.asset.native() ? env.master : issuer), @@ -912,7 +912,7 @@ protected: // Include the service fee STAmount const totalDue = roundToScale( - roundedPeriodicPayment + serviceFee, state.loanScale, Number::rounding_mode::upward); + roundedPeriodicPayment + serviceFee, state.loanScale, Number::RoundingMode::Upward); auto currentRoundedState = constructLoanState( state.totalValue, state.principalOutstanding, state.managementFeeOutstanding); @@ -971,7 +971,7 @@ protected: return; auto const totalSpent = (totalPaid.trackedValueDelta + totalFeesPaid + - (broker.asset.native() ? Number(baseFee) * totalPaymentsMade : numZero)); + (broker.asset.native() ? Number(baseFee) * totalPaymentsMade : kNUM_ZERO)); BEAST_EXPECT( env.balance(borrower, broker.asset).number() == borrowerInitialBalance - totalSpent); @@ -1002,7 +1002,7 @@ protected: BEAST_EXPECT( paymentComponents.trackedValueDelta <= roundedPeriodicPayment || - (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final && + (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final && paymentComponents.trackedValueDelta >= roundedPeriodicPayment)); BEAST_EXPECT( paymentComponents.trackedValueDelta == @@ -1018,7 +1018,7 @@ protected: BEAST_EXPECT( deltas.total() == deltas.principal + deltas.interest + deltas.managementFee); BEAST_EXPECT( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || deltas.total() == state.periodicPayment || (state.loanScale - (deltas.total() - state.periodicPayment).exponent()) > 14); @@ -1031,9 +1031,9 @@ protected: << paymentComponents.trackedPrincipalDelta << ", " << paymentComponents.trackedInterestPart() << ", " << paymentComponents.trackedManagementFeeDelta << ", " << [&]() -> char const* { - if (paymentComponents.specialCase == ::xrpl::detail::PaymentSpecialCase::final) + if (paymentComponents.specialCase == ::xrpl::detail::PaymentSpecialCase::Final) return "final"; - if (paymentComponents.specialCase == ::xrpl::detail::PaymentSpecialCase::extra) + if (paymentComponents.specialCase == ::xrpl::detail::PaymentSpecialCase::Extra) return "extra"; return "none"; }() << std::endl; @@ -1052,17 +1052,17 @@ protected: // IOUs, the difference should be dust. Number const diff = totalDue - totalDueAmount; BEAST_EXPECT( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || - diff == beast::zero || - (diff > beast::zero && + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || + diff == beast::kZERO || + (diff > beast::kZERO && ((broker.asset.integral() && (static_cast(diff) < 3)) || (state.loanScale - diff.exponent() > 13)))); BEAST_EXPECT( - paymentComponents.trackedPrincipalDelta >= beast::zero && + paymentComponents.trackedPrincipalDelta >= beast::kZERO && paymentComponents.trackedPrincipalDelta <= state.principalOutstanding); BEAST_EXPECT( - paymentComponents.specialCase != xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase != xrpl::detail::PaymentSpecialCase::Final || paymentComponents.trackedPrincipalDelta == state.principalOutstanding); } @@ -1122,7 +1122,7 @@ protected: --state.paymentRemaining; state.previousPaymentDate = state.nextPaymentDate; - if (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final) + if (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final) { state.paymentRemaining = 0; state.nextPaymentDate = 0; @@ -1206,7 +1206,7 @@ protected: Account const lender("lender"); Account const borrower("borrower"); - Env env(*this, all); + Env env(*this, all_); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower); @@ -1436,31 +1436,31 @@ protected: env(jt); } // Only the lender can manage - env(manage(evan, keylet.key, 0), ter(tecNO_PERMISSION)); + env(manage(evan, keylet.key, 0), Ter(tecNO_PERMISSION)); // unknown flags - env(manage(lender, keylet.key, tfLoanManageMask), ter(temINVALID_FLAG)); + env(manage(lender, keylet.key, tfLoanManageMask), Ter(temINVALID_FLAG)); // combinations of flags are not allowed - env(manage(lender, keylet.key, tfLoanUnimpair | tfLoanImpair), ter(temINVALID_FLAG)); - env(manage(lender, keylet.key, tfLoanImpair | tfLoanDefault), ter(temINVALID_FLAG)); - env(manage(lender, keylet.key, tfLoanUnimpair | tfLoanDefault), ter(temINVALID_FLAG)); + env(manage(lender, keylet.key, tfLoanUnimpair | tfLoanImpair), Ter(temINVALID_FLAG)); + env(manage(lender, keylet.key, tfLoanImpair | tfLoanDefault), Ter(temINVALID_FLAG)); + env(manage(lender, keylet.key, tfLoanUnimpair | tfLoanDefault), Ter(temINVALID_FLAG)); env(manage(lender, keylet.key, tfLoanUnimpair | tfLoanImpair | tfLoanDefault), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); // invalid loan ID - env(manage(lender, broker.brokerID, tfLoanImpair), ter(tecNO_ENTRY)); + env(manage(lender, broker.brokerID, tfLoanImpair), Ter(tecNO_ENTRY)); // Loan is unimpaired, can't unimpair it again - env(manage(lender, keylet.key, tfLoanUnimpair), ter(tecNO_PERMISSION)); + env(manage(lender, keylet.key, tfLoanUnimpair), Ter(tecNO_PERMISSION)); // Loan is unimpaired, it can go into default, but only after it's past // due - env(manage(lender, keylet.key, tfLoanDefault), ter(tecTOO_SOON)); + env(manage(lender, keylet.key, tfLoanDefault), Ter(tecTOO_SOON)); // Check the vault bool const canImpair = canImpairLoan(env, broker, state); // Impair the loan, if possible env(manage(lender, keylet.key, tfLoanImpair), - canImpair ? ter(tesSUCCESS) : ter(tecLIMIT_EXCEEDED)); + canImpair ? Ter(tesSUCCESS) : Ter(tecLIMIT_EXCEEDED)); // Unimpair the loan env(manage(lender, keylet.key, tfLoanUnimpair), - canImpair ? ter(tesSUCCESS) : ter(tecNO_PERMISSION)); + canImpair ? Ter(tesSUCCESS) : Ter(tecNO_PERMISSION)); auto const nextDueDate = startDate + *loanParams.payInterval; @@ -1478,7 +1478,7 @@ protected: loanFlags | 0); // Can't delete the loan yet. It has payments remaining. - env(del(lender, keylet.key), ter(tecHAS_OBLIGATIONS)); + env(del(lender, keylet.key), Ter(tecHAS_OBLIGATIONS)); if (BEAST_EXPECT(toEndOfLife)) toEndOfLife(keylet, verifyLoanStatus); @@ -1493,21 +1493,21 @@ protected: auto const borrowerStartingBalance = env.balance(borrower, broker.asset); // Try to delete the loan broker with an active loan - env(loanBroker::del(lender, broker.brokerID), ter(tecHAS_OBLIGATIONS)); + env(loanBroker::del(lender, broker.brokerID), Ter(tecHAS_OBLIGATIONS)); // Ensure the above tx doesn't get ordered after the LoanDelete and // delete our broker! env.close(); // Test failure cases - env(del(lender, keylet.key, tfLoanOverpayment), ter(temINVALID_FLAG)); - env(del(evan, keylet.key), ter(tecNO_PERMISSION)); - env(del(lender, broker.brokerID), ter(tecNO_ENTRY)); + env(del(lender, keylet.key, tfLoanOverpayment), Ter(temINVALID_FLAG)); + env(del(evan, keylet.key), Ter(tecNO_PERMISSION)); + env(del(lender, broker.brokerID), Ter(tecNO_ENTRY)); // Delete the loan // Either the borrower or the lender can delete the loan. Alternate // between who does it across tests. - static unsigned deleteCounter = 0; - auto const deleter = ((++deleteCounter % 2) != 0u) ? lender : borrower; + static unsigned kDELETE_COUNTER = 0; + auto const deleter = ((++kDELETE_COUNTER % 2) != 0u) ? lender : borrower; env(del(deleter, keylet.key)); env.close(); @@ -1602,7 +1602,7 @@ protected: Number const totalVaultRequest = broker.asset(broker.params.vaultDeposit).value(); Number const debtMaximumRequest = broker.asset(broker.params.debtMax).value(); - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); auto const pseudoAcct = [&]() { auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID)); @@ -1618,251 +1618,251 @@ protected: // Try some failure cases // flags are checked first env(set(evan, broker.brokerID, principalRequest, tfLoanSetMask), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); // field length validation // sfData: good length, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - data(std::string(maxDataPayloadLength, 'X')), + Sig(sfCounterpartySignature, borrower), + kDATA(std::string(kMAX_DATA_PAYLOAD_LENGTH, 'X')), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfData: too long env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - data(std::string(maxDataPayloadLength + 1, 'Y')), + Sig(sfCounterpartySignature, lender), + kDATA(std::string(kMAX_DATA_PAYLOAD_LENGTH + 1, 'Y')), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // field range validation // sfOverpaymentFee: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - overpaymentFee(maxOverpaymentFee), + Sig(sfCounterpartySignature, borrower), + kOVERPAYMENT_FEE(kMAX_OVERPAYMENT_FEE), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfOverpaymentFee: too big env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - overpaymentFee(maxOverpaymentFee + 1), + Sig(sfCounterpartySignature, lender), + kOVERPAYMENT_FEE(kMAX_OVERPAYMENT_FEE + 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfInterestRate: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - interestRate(maxInterestRate), + Sig(sfCounterpartySignature, borrower), + kINTEREST_RATE(kMAX_INTEREST_RATE), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - interestRate(TenthBips32(0)), + Sig(sfCounterpartySignature, borrower), + kINTEREST_RATE(TenthBips32(0)), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfInterestRate: too big env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - interestRate(maxInterestRate + 1), + Sig(sfCounterpartySignature, lender), + kINTEREST_RATE(kMAX_INTEREST_RATE + 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfInterestRate: too small env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - interestRate(TenthBips32(-1)), + Sig(sfCounterpartySignature, lender), + kINTEREST_RATE(TenthBips32(-1)), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfLateInterestRate: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - lateInterestRate(maxLateInterestRate), + Sig(sfCounterpartySignature, borrower), + kLATE_INTEREST_RATE(kMAX_LATE_INTEREST_RATE), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - lateInterestRate(TenthBips32(0)), + Sig(sfCounterpartySignature, borrower), + kLATE_INTEREST_RATE(TenthBips32(0)), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfLateInterestRate: too big env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - lateInterestRate(maxLateInterestRate + 1), + Sig(sfCounterpartySignature, lender), + kLATE_INTEREST_RATE(kMAX_LATE_INTEREST_RATE + 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfLateInterestRate: too small env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - lateInterestRate(TenthBips32(-1)), + Sig(sfCounterpartySignature, lender), + kLATE_INTEREST_RATE(TenthBips32(-1)), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfCloseInterestRate: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - closeInterestRate(maxCloseInterestRate), + Sig(sfCounterpartySignature, borrower), + kCLOSE_INTEREST_RATE(kMAX_CLOSE_INTEREST_RATE), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - closeInterestRate(TenthBips32(0)), + Sig(sfCounterpartySignature, borrower), + kCLOSE_INTEREST_RATE(TenthBips32(0)), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfCloseInterestRate: too big env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - closeInterestRate(maxCloseInterestRate + 1), + Sig(sfCounterpartySignature, lender), + kCLOSE_INTEREST_RATE(kMAX_CLOSE_INTEREST_RATE + 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - closeInterestRate(TenthBips32(-1)), + Sig(sfCounterpartySignature, lender), + kCLOSE_INTEREST_RATE(TenthBips32(-1)), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfOverpaymentInterestRate: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - overpaymentInterestRate(maxOverpaymentInterestRate), + Sig(sfCounterpartySignature, borrower), + kOVERPAYMENT_INTEREST_RATE(kMAX_OVERPAYMENT_INTEREST_RATE), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - overpaymentInterestRate(TenthBips32(0)), + Sig(sfCounterpartySignature, borrower), + kOVERPAYMENT_INTEREST_RATE(TenthBips32(0)), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfOverpaymentInterestRate: too big env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - overpaymentInterestRate(maxOverpaymentInterestRate + 1), + Sig(sfCounterpartySignature, lender), + kOVERPAYMENT_INTEREST_RATE(kMAX_OVERPAYMENT_INTEREST_RATE + 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - overpaymentInterestRate(TenthBips32(-1)), + Sig(sfCounterpartySignature, lender), + kOVERPAYMENT_INTEREST_RATE(TenthBips32(-1)), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfPaymentTotal: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - paymentTotal(LoanSet::minPaymentTotal), + Sig(sfCounterpartySignature, borrower), + kPAYMENT_TOTAL(LoanSet::kMIN_PAYMENT_TOTAL), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfPaymentTotal: too small (there is no max) env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - paymentTotal(LoanSet::minPaymentTotal - 1), + Sig(sfCounterpartySignature, lender), + kPAYMENT_TOTAL(LoanSet::kMIN_PAYMENT_TOTAL - 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfPaymentInterval: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - paymentInterval(LoanSet::minPaymentInterval), + Sig(sfCounterpartySignature, borrower), + kPAYMENT_INTERVAL(LoanSet::kMIN_PAYMENT_INTERVAL), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfPaymentInterval: too small (there is no max) env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - paymentInterval(LoanSet::minPaymentInterval - 1), + Sig(sfCounterpartySignature, lender), + kPAYMENT_INTERVAL(LoanSet::kMIN_PAYMENT_INTERVAL - 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // sfGracePeriod: good value, bad account env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, borrower), - paymentInterval(LoanSet::minPaymentInterval * 2), - gracePeriod(LoanSet::minPaymentInterval * 2), + Sig(sfCounterpartySignature, borrower), + kPAYMENT_INTERVAL(LoanSet::kMIN_PAYMENT_INTERVAL * 2), + kGRACE_PERIOD(LoanSet::kMIN_PAYMENT_INTERVAL * 2), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // sfGracePeriod: larger than paymentInterval env(set(evan, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - paymentInterval(LoanSet::minPaymentInterval * 2), - gracePeriod(LoanSet::minPaymentInterval * 3), + Sig(sfCounterpartySignature, lender), + kPAYMENT_INTERVAL(LoanSet::kMIN_PAYMENT_INTERVAL * 2), + kGRACE_PERIOD(LoanSet::kMIN_PAYMENT_INTERVAL * 3), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // insufficient fee - single sign env(set(borrower, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), - ter(telINSUF_FEE_P)); + Sig(sfCounterpartySignature, lender), + Ter(telINSUF_FEE_P)); // insufficient fee - multisign env(signers(lender, 2, {{evan, 1}, {borrower, 1}})); env(signers(borrower, 2, {{evan, 1}, {lender, 1}})); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(evan, lender), - msig(sfCounterpartySignature, evan, borrower), - fee(env.current()->fees().base * 5 - 1), - ter(telINSUF_FEE_P)); + kCOUNTERPARTY(lender), + Msig(evan, lender), + Msig(sfCounterpartySignature, evan, borrower), + Fee(env.current()->fees().base * 5 - 1), + Ter(telINSUF_FEE_P)); // Bad multisign signatures for borrower (Account) env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(alice, issuer), - msig(sfCounterpartySignature, evan, borrower), - fee(env.current()->fees().base * 5), - ter(tefBAD_SIGNATURE)); + kCOUNTERPARTY(lender), + Msig(alice, issuer), + Msig(sfCounterpartySignature, evan, borrower), + Fee(env.current()->fees().base * 5), + Ter(tefBAD_SIGNATURE)); // Bad multisign signatures for issuer (Counterparty) env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(evan, lender), - msig(sfCounterpartySignature, alice, issuer), - fee(env.current()->fees().base * 5 - 1), - ter(tefBAD_SIGNATURE)); - env(signers(lender, none)); - env(signers(borrower, none)); + kCOUNTERPARTY(lender), + Msig(evan, lender), + Msig(sfCounterpartySignature, alice, issuer), + Fee(env.current()->fees().base * 5 - 1), + Ter(tefBAD_SIGNATURE)); + env(signers(lender, kNONE)); + env(signers(borrower, kNONE)); // multisign sufficient fee, but no signers set up env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(evan, lender), - msig(sfCounterpartySignature, evan, borrower), - fee(env.current()->fees().base * 5), - ter(tefNOT_MULTI_SIGNING)); + kCOUNTERPARTY(lender), + Msig(evan, lender), + Msig(sfCounterpartySignature, evan, borrower), + Fee(env.current()->fees().base * 5), + Ter(tefNOT_MULTI_SIGNING)); // not the broker owner, no counterparty, not signed by broker // owner env(set(borrower, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, evan), + Sig(sfCounterpartySignature, evan), loanSetFee, - ter(tefBAD_AUTH)); + Ter(tefBAD_AUTH)); // not the broker owner, counterparty is borrower env(set(evan, broker.brokerID, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), loanSetFee, - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); // not a LoanBroker object, no counterparty env(set(lender, badKeylet.key, principalRequest), - sig(sfCounterpartySignature, evan), + Sig(sfCounterpartySignature, evan), loanSetFee, - ter(temBAD_SIGNER)); + Ter(temBAD_SIGNER)); // not a LoanBroker object, counterparty is valid env(set(lender, badKeylet.key, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), loanSetFee, - ter(tecNO_ENTRY)); + Ter(tecNO_ENTRY)); // borrower doesn't exist env(set(lender, broker.brokerID, principalRequest), - counterparty(alice), - sig(sfCounterpartySignature, alice), + kCOUNTERPARTY(alice), + Sig(sfCounterpartySignature, alice), loanSetFee, - ter(terNO_ACCOUNT)); + Ter(terNO_ACCOUNT)); // Request more funds than the vault has available env(set(evan, broker.brokerID, totalVaultRequest + 1), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); // Request more funds than the broker's first-loss capital can // cover. env(set(evan, broker.brokerID, maxCoveredLoanRequest + 1), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); // Frozen trust line / locked MPT issuance // XRP can not be frozen, but run through the loop anyway to test @@ -1899,14 +1899,14 @@ protected: if (broker.asset.holds()) { auto freeze = [&](Account const& holder) { - env(trust(issuer, holder[iouCurrency](0), tfSetFreeze)); + env(trust(issuer, holder[iouCurrency_](0), tfSetFreeze)); }; auto deepfreeze = [&](Account const& holder) { - env(trust(issuer, holder[iouCurrency](0), tfSetFreeze | tfSetDeepFreeze)); + env(trust(issuer, holder[iouCurrency_](0), tfSetFreeze | tfSetDeepFreeze)); }; auto unfreeze = [&](Account const& holder) { env(trust( - issuer, holder[iouCurrency](0), tfClearFreeze | tfClearDeepFreeze)); + issuer, holder[iouCurrency_](0), tfClearFreeze | tfClearDeepFreeze)); }; return std::make_tuple(freeze, deepfreeze, unfreeze, tecFROZEN); } @@ -1930,9 +1930,9 @@ protected: // Try to create a loan with a frozen line env(set(evan, broker.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(expectedResult)); + Ter(expectedResult)); // Unfreeze the account BEAST_EXPECT(unfreeze); @@ -1942,9 +1942,9 @@ protected: // except too it requests more principal than the broker can // carry env(set(evan, broker.brokerID, debtMaximumRequest + 1), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecLIMIT_EXCEEDED)); + Ter(tecLIMIT_EXCEEDED)); } } @@ -1956,7 +1956,7 @@ protected: // freeze it. (Don't need to do this for the borrower, // because LoanSet will create a line to the borrower // automatically.) - env(trust(evan, issuer[iouCurrency](100'000))); + env(trust(evan, issuer[iouCurrency_](100'000))); for (auto const& account : {// these accounts can't be frozen, which deep freeze // implies @@ -1970,9 +1970,9 @@ protected: // Try to create a loan with a deep frozen line env(set(evan, broker.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(expectedResult)); + Ter(expectedResult)); // Unfreeze evan BEAST_EXPECT(unfreeze); @@ -1982,9 +1982,9 @@ protected: // except too it requests more principal than the broker can // carry env(set(evan, broker.brokerID, debtMaximumRequest + 1), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecLIMIT_EXCEEDED)); + Ter(tecLIMIT_EXCEEDED)); } } } @@ -2011,7 +2011,7 @@ protected: ? 0 : std::max( broker.vaultScale(env), state.principalOutstanding.exponent()))); - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); auto const defaultAmount = roundToAsset( broker.asset, std::min( @@ -2058,7 +2058,7 @@ protected: bool const canImpair = canImpairLoan(env, broker, state); // Impair the loan, if possible env(manage(lender, loanKeylet.key, tfLoanImpair), - canImpair ? ter(tesSUCCESS) : ter(tecLIMIT_EXCEEDED)); + canImpair ? Ter(tesSUCCESS) : Ter(tecLIMIT_EXCEEDED)); if (canImpair) { @@ -2066,7 +2066,7 @@ protected: state.nextPaymentDate = env.now().time_since_epoch().count(); // Once the loan is impaired, it can't be impaired again - env(manage(lender, loanKeylet.key, tfLoanImpair), ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanImpair), Ter(tecNO_PERMISSION)); } verifyLoanStatus(state); } @@ -2075,7 +2075,7 @@ protected: // Can't default the loan yet. The grace period hasn't // expired - env(manage(lender, loanKeylet.key, tfLoanDefault), ter(tecTOO_SOON)); + env(manage(lender, loanKeylet.key, tfLoanDefault), Ter(tecTOO_SOON)); // Let some time pass so that the loan can be // defaulted @@ -2100,10 +2100,10 @@ protected: verifyLoanStatus(state); // Once a loan is defaulted, it can't be managed - env(manage(lender, loanKeylet.key, tfLoanUnimpair), ter(tecNO_PERMISSION)); - env(manage(lender, loanKeylet.key, tfLoanImpair), ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanUnimpair), Ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanImpair), Ter(tecNO_PERMISSION)); // Can't make a payment on it either - env(pay(borrower, loanKeylet.key, broker.asset(300)), ter(tecKILLED)); + env(pay(borrower, loanKeylet.key, broker.asset(300)), Ter(tecKILLED)); }; }; @@ -2120,12 +2120,12 @@ protected: // Send some bogus pay transactions env(pay(borrower, keylet::loan(uint256(0)).key, broker.asset(10), txFlags), - ter(temINVALID)); + Ter(temINVALID)); // broker.asset(80) is less than a single payment, but all these // checks fail before that matters - env(pay(borrower, loanKeylet.key, broker.asset(-80), txFlags), ter(temBAD_AMOUNT)); - env(pay(borrower, broker.brokerID, broker.asset(80), txFlags), ter(tecNO_ENTRY)); - env(pay(evan, loanKeylet.key, broker.asset(80), txFlags), ter(tecNO_PERMISSION)); + env(pay(borrower, loanKeylet.key, broker.asset(-80), txFlags), Ter(temBAD_AMOUNT)); + env(pay(borrower, broker.brokerID, broker.asset(80), txFlags), Ter(tecNO_ENTRY)); + env(pay(evan, loanKeylet.key, broker.asset(80), txFlags), Ter(tecNO_PERMISSION)); // TODO: Write a general "isFlag" function? See STObject::isFlag. // Maybe add a static overloaded member? @@ -2138,8 +2138,9 @@ protected: loanKeylet.key, STAmount{broker.asset, state.periodicPayment * Number{15, -1}}, tfLoanOverpayment), - fee(XRPAmount{baseFee * (Number{15, -1} / loanPaymentsPerFeeIncrement + 1)}), - ter(tecNO_PERMISSION)); + Fee(XRPAmount{ + baseFee * (Number{15, -1} / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}), + Ter(tecNO_PERMISSION)); { env.disableFeature(fixSecurity3_1_3); @@ -2147,9 +2148,9 @@ protected: loanKeylet.key, STAmount{broker.asset, state.periodicPayment * Number{15, -1}}, tfLoanOverpayment), - fee(XRPAmount{ - baseFee * (Number{15, -1} / loanPaymentsPerFeeIncrement + 1)}), - ter(temINVALID_FLAG)); + Fee(XRPAmount{ + baseFee * (Number{15, -1} / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}), + Ter(temINVALID_FLAG)); env.enableFeature(fixSecurity3_1_3); } } @@ -2160,32 +2161,32 @@ protected: loanKeylet.key, broker.asset(state.periodicPayment * 2), tfLoanLatePayment | tfLoanFullPayment), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); env(pay(borrower, loanKeylet.key, broker.asset(state.periodicPayment * 2), tfLoanLatePayment | tfLoanOverpayment), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); env(pay(borrower, loanKeylet.key, broker.asset(state.periodicPayment * 2), tfLoanOverpayment | tfLoanFullPayment), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); env(pay(borrower, loanKeylet.key, broker.asset(state.periodicPayment * 2), tfLoanLatePayment | tfLoanOverpayment | tfLoanFullPayment), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); { auto const otherAsset = broker.asset.raw() == assets[0].raw() ? assets[1] : assets[0]; - env(pay(borrower, loanKeylet.key, otherAsset(100), txFlags), ter(tecWRONG_ASSET)); + env(pay(borrower, loanKeylet.key, otherAsset(100), txFlags), Ter(tecWRONG_ASSET)); } // Amount doesn't cover a single payment env(pay(borrower, loanKeylet.key, STAmount{broker.asset, 1}, txFlags), - ter(tecINSUFFICIENT_PAYMENT)); + Ter(tecINSUFFICIENT_PAYMENT)); // Get the balance after these failed transactions take // fees @@ -2201,17 +2202,17 @@ protected: XRPAmount const badFee{ baseFee * (borrowerBalanceBeforePayment.number() * 2 / state.periodicPayment / - loanPaymentsPerFeeIncrement + + kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; env(pay(borrower, loanKeylet.key, STAmount{broker.asset, borrowerBalanceBeforePayment.number() * 2}, txFlags), - fee(badFee), - ter(tecINSUFFICIENT_FUNDS)); + Fee(badFee), + Ter(tecINSUFFICIENT_FUNDS)); - XRPAmount const goodFee{baseFee * (numPayments / loanPaymentsPerFeeIncrement + 1)}; - env(pay(borrower, loanKeylet.key, transactionAmount, txFlags), fee(goodFee)); + XRPAmount const goodFee{baseFee * (numPayments / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; + env(pay(borrower, loanKeylet.key, transactionAmount, txFlags), Fee(goodFee)); env.close(); @@ -2237,8 +2238,8 @@ protected: state.loanScale, borrower, borrowerBalanceBeforePayment, payoffAmount, adjustment); // Can't impair or default a paid off loan - env(manage(lender, loanKeylet.key, tfLoanImpair), ter(tecNO_PERMISSION)); - env(manage(lender, loanKeylet.key, tfLoanDefault), ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanImpair), Ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanDefault), Ter(tecNO_PERMISSION)); }; auto fullPayment = [&](std::uint32_t baseFlag) { @@ -2260,9 +2261,9 @@ protected: // to verify they're working correctly The numbers in // the below BEAST_EXPECTs may not hold across assets. Number const interval = state.paymentInterval; - auto const periodicRate = interval * Number(12, -2) / secondsInYear; + auto const periodicRate = interval * Number(12, -2) / kSECONDS_IN_YEAR; BEAST_EXPECT( - periodicRate == Number(2283105022831050228ULL, -24, Number::normalized{})); + periodicRate == Number(2283105022831050228ULL, -24, Number::Normalized{})); STAmount const principalOutstanding{broker.asset, state.principalOutstanding}; STAmount const accruedInterest{ broker.asset, state.principalOutstanding * periodicRate * loanAge / interval}; @@ -2315,7 +2316,7 @@ protected: // service fee is 2 auto const startingPayments = state.paymentRemaining; STAmount const payoffAmount = [&]() { - NumberRoundModeGuard const mg(Number::rounding_mode::upward); + NumberRoundModeGuard const mg(Number::RoundingMode::Upward); auto const rawPayoff = startingPayments * (state.periodicPayment + broker.asset(2).value()); STAmount payoffAmount{broker.asset, rawPayoff}; @@ -2500,9 +2501,9 @@ protected: // to verify they're working correctly The numbers in // the below BEAST_EXPECTs may not hold across assets. Number const interval = state.paymentInterval; - auto const periodicRate = interval * Number(12, -2) / secondsInYear; + auto const periodicRate = interval * Number(12, -2) / kSECONDS_IN_YEAR; BEAST_EXPECT( - periodicRate == Number(2283105022831050228, -24, Number::normalized{})); + periodicRate == Number(2283105022831050228, -24, Number::Normalized{})); STAmount const roundedPeriodicPayment{ broker.asset, roundPeriodicPayment(broker.asset, state.periodicPayment, state.loanScale)}; @@ -2518,24 +2519,24 @@ protected: roundedPeriodicPayment == roundToScale( broker.asset( - Number(8333457002039338267, -17), Number::rounding_mode::upward), + Number(8333457002039338267, -17), Number::RoundingMode::Upward), state.loanScale, - Number::rounding_mode::upward)); + Number::RoundingMode::Upward)); // 83334570.01162141 // Include the service fee STAmount const totalDue = roundToScale( roundedPeriodicPayment + serviceFee, state.loanScale, - Number::rounding_mode::upward); + Number::RoundingMode::Upward); // Only check the first payment since the rounding // may drift as payments are made BEAST_EXPECT( totalDue == roundToScale( broker.asset( - Number(8533457002039338267, -17), Number::rounding_mode::upward), + Number(8533457002039338267, -17), Number::RoundingMode::Upward), state.loanScale, - Number::rounding_mode::upward)); + Number::RoundingMode::Upward)); { auto const raw = computeTheoreticalLoanState( @@ -2563,9 +2564,9 @@ protected: BEAST_EXPECT( transactionAmount == roundToScale( - broker.asset(Number(9533457002039400, -14), Number::rounding_mode::upward), + broker.asset(Number(9533457002039400, -14), Number::RoundingMode::Upward), state.loanScale, - Number::rounding_mode::upward)); + Number::RoundingMode::Upward)); auto const initialState = state; xrpl::detail::PaymentComponents totalPaid{ @@ -2596,7 +2597,7 @@ protected: broker.params.managementFeeRate); BEAST_EXPECTS( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || paymentComponents.trackedValueDelta <= roundedPeriodicPayment, "Delta: " + to_string(paymentComponents.trackedValueDelta) + ", periodic payment: " + to_string(roundedPeriodicPayment)); @@ -2616,10 +2617,10 @@ protected: << paymentComponents.trackedManagementFeeDelta << ", " << [&]() -> char const* { if (paymentComponents.specialCase == - ::xrpl::detail::PaymentSpecialCase::final) + ::xrpl::detail::PaymentSpecialCase::Final) return "final"; if (paymentComponents.specialCase == - ::xrpl::detail::PaymentSpecialCase::extra) + ::xrpl::detail::PaymentSpecialCase::Extra) return "extra"; return "none"; }(); @@ -2635,9 +2636,9 @@ protected: // IOUs, the difference should be after the 8th digit. Number const diff = totalDue - totalDueAmount; BEAST_EXPECT( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || - diff == beast::zero || - (diff > beast::zero && + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || + diff == beast::kZERO || + (diff > beast::kZERO && ((broker.asset.integral() && (static_cast(diff) < 3)) || (state.loanScale - diff.exponent() > 13)))); @@ -2647,7 +2648,7 @@ protected: paymentComponents.trackedInterestPart() + paymentComponents.trackedManagementFeeDelta); BEAST_EXPECT( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || paymentComponents.trackedValueDelta <= roundedPeriodicPayment); BEAST_EXPECT( @@ -2656,21 +2657,20 @@ protected: broker.asset, deltas.principal, state.loanScale, - Number::rounding_mode::upward) == + Number::RoundingMode::Upward) == roundToScale( broker.asset( - Number(8333228691531218890, -17), - Number::rounding_mode::upward), + Number(8333228691531218890, -17), Number::RoundingMode::Upward), state.loanScale, - Number::rounding_mode::upward)); + Number::RoundingMode::Upward)); BEAST_EXPECT( - paymentComponents.trackedPrincipalDelta >= beast::zero && + paymentComponents.trackedPrincipalDelta >= beast::kZERO && paymentComponents.trackedPrincipalDelta <= state.principalOutstanding); BEAST_EXPECT( - paymentComponents.specialCase != xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase != xrpl::detail::PaymentSpecialCase::Final || paymentComponents.trackedPrincipalDelta == state.principalOutstanding); BEAST_EXPECT( - paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final || + paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final || (state.periodicPayment.exponent() - (deltas.principal + deltas.interest + deltas.managementFee - state.periodicPayment) @@ -2708,7 +2708,7 @@ protected: --state.paymentRemaining; state.previousPaymentDate = state.nextPaymentDate; - if (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::final) + if (paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final) { state.paymentRemaining = 0; state.nextPaymentDate = 0; @@ -2752,8 +2752,8 @@ protected: BEAST_EXPECT(totalPaymentsMade == initialState.paymentRemaining); // Can't impair or default a paid off loan - env(manage(lender, loanKeylet.key, tfLoanImpair), ter(tecNO_PERMISSION)); - env(manage(lender, loanKeylet.key, tfLoanDefault), ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanImpair), Ter(tecNO_PERMISSION)); + env(manage(lender, loanKeylet.key, tfLoanDefault), Ter(tecNO_PERMISSION)); }); #if LOAN_TODO @@ -2818,7 +2818,7 @@ protected: STAmount const bigPayment{broker.asset, totalDue * numPayments}; XRPAmount const bigFee{baseFee * (numPayments / loanPaymentsPerFeeIncrement + 1)}; time("ten payments", [&]() { - env(pay(borrower, loanKeylet.key, bigPayment), fee(bigFee)); + env(pay(borrower, loanKeylet.key, bigPayment), Fee(bigFee)); }); env.close(); @@ -2908,7 +2908,7 @@ protected: std::function mptTest, std::function iouTest, CaseArgs args = {}) { - Env env(*this, all); + Env env(*this, all_); env.fund(XRP(args.initialXRP), issuer, lender, borrower); env.close(); if (args.requireAuth) @@ -2919,12 +2919,12 @@ protected: // We need two different asset types, MPT and IOU. Prepare MPT // first - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; - auto const none = LedgerSpecificFlags(0); + auto const kNONE = LedgerSpecificFlags(0); mptt.create( {.flags = tfMPTCanTransfer | tfMPTCanLock | - (args.requireAuth ? tfMPTRequireAuth : none)}); + (args.requireAuth ? tfMPTRequireAuth : kNONE)}); env.close(); PrettyAsset const mptAsset = mptt.issuanceID(); mptt.authorize({.account = lender}); @@ -2942,7 +2942,7 @@ protected: env.close(); // Prepare IOU - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; env(trust(lender, iouAsset(10'000'000))); env(trust(borrower, iouAsset(10'000'000))); env.close(); @@ -2985,15 +2985,15 @@ protected: testcase("MPT issuer is borrower, issuer submits"); env(set(issuer, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); testcase("MPT issuer is borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(issuer), - sig(sfCounterpartySignature, issuer), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(issuer), + Sig(sfCounterpartySignature, issuer), + Fee(env.current()->fees().base * 5)); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3001,15 +3001,15 @@ protected: testcase("IOU issuer is borrower, issuer submits"); env(set(issuer, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); testcase("IOU issuer is borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(issuer), - sig(sfCounterpartySignature, issuer), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(issuer), + Sig(sfCounterpartySignature, issuer), + Fee(env.current()->fees().base * 5)); }, CaseArgs{.requireAuth = true}); @@ -3020,17 +3020,17 @@ protected: testcase("MPT unauthorized borrower, borrower submits"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); testcase("MPT unauthorized borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3038,25 +3038,25 @@ protected: testcase("IOU unauthorized borrower, borrower submits"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); testcase("IOU unauthorized borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); }, CaseArgs{.requireAuth = true}); auto const [acctReserve, incReserve] = [this]() -> std::pair { - Env const env{*this, testable_amendments()}; + Env const env{*this, testableAmendments()}; return { - env.current()->fees().accountReserve(0).drops() / DROPS_PER_XRP.drops(), - env.current()->fees().increment.drops() / DROPS_PER_XRP.drops()}; + env.current()->fees().accountReserve(0).drops() / kDROPS_PER_XRP.drops(), + env.current()->fees().increment.drops() / kDROPS_PER_XRP.drops()}; }(); testCase( @@ -3075,24 +3075,24 @@ protected: BEAST_EXPECT(sleMPT1 == nullptr); // Burn some XRP - env(noop(borrower), fee(XRP((acctReserve * 2) + (incReserve * 2)))); + env(noop(borrower), Fee(XRP((acctReserve * 2) + (incReserve * 2)))); env.close(); // Cannot create loan, not enough reserve to create MPToken env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecINSUFFICIENT_RESERVE}); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecINSUFFICIENT_RESERVE}); env.close(); // Can create loan now, will implicitly create MPToken env(pay(issuer, borrower, XRP(incReserve))); env.close(); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); env.close(); auto const sleMPT2 = env.le(mptoken); @@ -3121,24 +3121,24 @@ protected: BEAST_EXPECT(sleLine1 == nullptr); // Burn some XRP - env(noop(borrower), fee(XRP((acctReserve * 2) + (incReserve * 2)))); + env(noop(borrower), Fee(XRP((acctReserve * 2) + (incReserve * 2)))); env.close(); // Cannot create loan, not enough reserve to create trust line env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_LINE_INSUF_RESERVE}); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_LINE_INSUF_RESERVE}); env.close(); // Can create loan now, will implicitly create trust line env(pay(issuer, borrower, XRP(incReserve))); env.close(); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); env.close(); auto const sleLine2 = env.le(trustline); @@ -3168,26 +3168,26 @@ protected: BEAST_EXPECT(sleMPT2 == nullptr); // Burn some XRP - env(noop(lender), fee(XRP(incReserve))); + env(noop(lender), Fee(XRP(incReserve))); env.close(); // Cannot create loan, not enough reserve to create MPToken env(set(borrower, broker.brokerID, principalRequest), - loanOriginationFee(broker.asset(1).value()), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecINSUFFICIENT_RESERVE}); + kLOAN_ORIGINATION_FEE(broker.asset(1).value()), + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecINSUFFICIENT_RESERVE}); env.close(); // Can create loan now, will implicitly create MPToken env(pay(issuer, lender, XRP(incReserve))); env.close(); env(set(borrower, broker.brokerID, principalRequest), - loanOriginationFee(broker.asset(1).value()), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kLOAN_ORIGINATION_FEE(broker.asset(1).value()), + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); env.close(); auto const sleMPT3 = env.le(mptoken); @@ -3219,26 +3219,26 @@ protected: BEAST_EXPECT(sleLine2 == nullptr); // Burn some XRP - env(noop(lender), fee(XRP(incReserve))); + env(noop(lender), Fee(XRP(incReserve))); env.close(); // Cannot create loan, not enough reserve to create trust line env(set(borrower, broker.brokerID, principalRequest), - loanOriginationFee(broker.asset(1).value()), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_LINE_INSUF_RESERVE}); + kLOAN_ORIGINATION_FEE(broker.asset(1).value()), + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_LINE_INSUF_RESERVE}); env.close(); // Can create loan now, will implicitly create trust line env(pay(issuer, lender, XRP(incReserve))); env.close(); env(set(borrower, broker.brokerID, principalRequest), - loanOriginationFee(broker.asset(1).value()), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kLOAN_ORIGINATION_FEE(broker.asset(1).value()), + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); env.close(); auto const sleLine3 = env.le(trustline); @@ -3267,19 +3267,19 @@ protected: // Cannot create loan, lender not authorized to receive fee env(set(borrower, broker.brokerID, principalRequest), - loanOriginationFee(broker.asset(1).value()), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kLOAN_ORIGINATION_FEE(broker.asset(1).value()), + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); env.close(); // Cannot create loan, even without an origination fee env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter{tecNO_AUTH}); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter{tecNO_AUTH}); env.close(); // No MPToken for lender - no authorization and no payment @@ -3296,9 +3296,9 @@ protected: testcase("MPT authorized borrower, borrower submits"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3306,9 +3306,9 @@ protected: testcase("IOU authorized borrower, borrower submits"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5)); }, CaseArgs{.requireAuth = true, .authorizeBorrower = true}); @@ -3319,9 +3319,9 @@ protected: testcase("MPT authorized borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), + Fee(env.current()->fees().base * 5)); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3329,16 +3329,16 @@ protected: testcase("IOU authorized borrower, lender submits"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), + Fee(env.current()->fees().base * 5)); }, CaseArgs{.requireAuth = true, .authorizeBorrower = true}); jtx::Account const alice{"alice"}; jtx::Account const bella{"bella"}; auto const msigSetup = [&](Env& env, Account const& account) { - Json::Value const tx1 = signers(account, 2, {{alice, 1}, {bella, 1}}); + json::Value const tx1 = signers(account, 2, {{alice, 1}, {bella, 1}}); env(tx1); env.close(); }; @@ -3353,9 +3353,9 @@ protected: "MPT authorized borrower, borrower submits, lender " "multisign"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(sfCounterpartySignature, alice, bella), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Msig(sfCounterpartySignature, alice, bella), + Fee(env.current()->fees().base * 5)); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3366,9 +3366,9 @@ protected: "IOU authorized borrower, borrower submits, lender " "multisign"); env(set(borrower, broker.brokerID, principalRequest), - counterparty(lender), - msig(sfCounterpartySignature, alice, bella), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(lender), + Msig(sfCounterpartySignature, alice, bella), + Fee(env.current()->fees().base * 5)); }, CaseArgs{.requireAuth = true, .authorizeBorrower = true}); @@ -3382,9 +3382,9 @@ protected: "MPT authorized borrower, lender submits, borrower " "multisign"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - msig(sfCounterpartySignature, alice, bella), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(borrower), + Msig(sfCounterpartySignature, alice, bella), + Fee(env.current()->fees().base * 5)); }, [&, this](Env& env, BrokerInfo const& broker) { using namespace loan; @@ -3395,9 +3395,9 @@ protected: "IOU authorized borrower, lender submits, borrower " "multisign"); env(set(lender, broker.brokerID, principalRequest), - counterparty(borrower), - msig(sfCounterpartySignature, alice, bella), - fee(env.current()->fees().base * 5)); + kCOUNTERPARTY(borrower), + Msig(sfCounterpartySignature, alice, bella), + Fee(env.current()->fees().base * 5)); }, CaseArgs{.requireAuth = true, .authorizeBorrower = true}); @@ -3413,11 +3413,11 @@ protected: testcase("Vault at maximum value"); env(set(issuer, broker.brokerID, principalRequest), - counterparty(lender), - interestRate(TenthBips32(10'000)), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - ter(tecLIMIT_EXCEEDED)); + kCOUNTERPARTY(lender), + kINTEREST_RATE(TenthBips32(10'000)), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + Ter(tecLIMIT_EXCEEDED)); }, nullptr); @@ -3434,13 +3434,13 @@ protected: testcase("Vault maximum value exceeded"); env(set(issuer, broker.brokerID, principalRequest), - counterparty(lender), - interestRate(TenthBips32(100'000)), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 5), - paymentTotal(2), - paymentInterval(3600 * 24), - ter(tecLIMIT_EXCEEDED)); + kCOUNTERPARTY(lender), + kINTEREST_RATE(TenthBips32(100'000)), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 5), + kPAYMENT_TOTAL(2), + kPAYMENT_INTERVAL(3600 * 24), + Ter(tecLIMIT_EXCEEDED)); }, nullptr); } @@ -3453,7 +3453,7 @@ protected: // Create 3 loan brokers: one for XRP, one for an IOU, and one for // an MPT. That'll require three corresponding SAVs. - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; // For simplicity, lender will be the sole actor for the vault & @@ -3473,7 +3473,7 @@ protected: // Create assets PrettyAsset const xrpAsset{xrpIssue(), 1'000'000}; - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; env(trust(lender, iouAsset(10'000'000))); env(trust(borrower, iouAsset(10'000'000))); env(trust(evan, iouAsset(10'000'000))); @@ -3483,7 +3483,7 @@ protected: env(pay(issuer, borrower, iouAsset(10'000))); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); // Scale the MPT asset a little bit so we can get some interest PrettyAsset const mptAsset{mptt.issuanceID(), 100}; @@ -3548,7 +3548,7 @@ protected: using namespace std::chrono_literals; // Create 3 loan brokers: one for XRP, one for an IOU, and one for // an MPT. That'll require three corresponding SAVs. - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; // For simplicity, lender will be the sole actor for the vault & @@ -3568,19 +3568,19 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; // The LoanSet json can be created without a counterparty signature, // but it will not pass preflight auto createJson = env.json( - set(lender, broker.brokerID, broker.asset(principalRequest).value()), fee(loanSetFee)); - env(createJson, ter(temBAD_SIGNER)); + set(lender, broker.brokerID, broker.asset(principalRequest).value()), Fee(loanSetFee)); + env(createJson, Ter(temBAD_SIGNER)); // Adding an empty counterparty signature object also fails, but // at the RPC level. - createJson = env.json(createJson, json(sfCounterpartySignature, Json::objectValue)); - env(createJson, ter(telENV_RPC_FAILED)); + createJson = env.json(createJson, Json(sfCounterpartySignature, json::ObjectValue)); + env(createJson, Ter(telENV_RPC_FAILED)); if (auto const jt = env.jt(createJson); BEAST_EXPECT(jt.stx)) { @@ -3597,14 +3597,14 @@ protected: } // Copy the transaction signature into the counterparty signature. - Json::Value counterpartyJson{Json::objectValue}; + json::Value counterpartyJson{json::ObjectValue}; counterpartyJson[sfTxnSignature] = createJson[sfTxnSignature]; counterpartyJson[sfSigningPubKey] = createJson[sfSigningPubKey]; if (!BEAST_EXPECT(!createJson.isMember(jss::Signers))) counterpartyJson[sfSigners] = createJson[sfSigners]; // The duplicated signature works - createJson = env.json(createJson, json(sfCounterpartySignature, counterpartyJson)); + createJson = env.json(createJson, Json(sfCounterpartySignature, counterpartyJson)); env(createJson); env.close(); @@ -3629,7 +3629,7 @@ protected: } } auto const loanID = [&]() { - Json::Value params(Json::objectValue); + json::Value params(json::ObjectValue); params[jss::account] = lender.human(); params[jss::type] = "Loan"; auto const res = env.rpc("json", "account_objects", to_string(params)); @@ -3681,12 +3681,12 @@ protected: testcase << "Batch Bypass Counterparty"; bool const lendingBatchEnabled = !std::ranges::any_of( - Batch::disabledTxTypes, + Batch::kDISABLED_TX_TYPES, [](auto const& disabled) { return disabled == ttLOAN_BROKER_SET; }); using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const lender{"lender"}; Account const borrower{"borrower"}; @@ -3701,38 +3701,38 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto forgedLoanSet = set(borrower, broker.brokerID, principalRequest, 0); - Json::Value randomData{Json::objectValue}; - randomData[jss::SigningPubKey] = Json::StaticString{"2600"}; - Json::Value sigObject{Json::objectValue}; + json::Value randomData{json::ObjectValue}; + randomData[jss::SigningPubKey] = json::StaticString{"2600"}; + json::Value sigObject{json::ObjectValue}; sigObject[jss::SigningPubKey] = strHex(lender.pk().slice()); Serializer ss; - ss.add32(HashPrefix::txSign); + ss.add32(HashPrefix::TxSign); parse(randomData).addWithoutSigningFields(ss); auto const sig = xrpl::sign(borrower.pk(), borrower.sk(), ss.slice()); sigObject[jss::TxnSignature] = strHex(Slice{sig.data(), sig.size()}); - forgedLoanSet[Json::StaticString{"CounterpartySignature"}] = sigObject; + forgedLoanSet[json::StaticString{"CounterpartySignature"}] = sigObject; // ? Fails because the lender hasn't signed the tx - env(env.json(forgedLoanSet, fee(loanSetFee)), ter(telENV_RPC_FAILED)); + env(env.json(forgedLoanSet, Fee(loanSetFee)), Ter(telENV_RPC_FAILED)); auto const seq = env.seq(borrower); auto const batchFee = batch::calcBatchFee(env, 1, 2); // ! Should fail because the lender hasn't signed the tx env(batch::outer(borrower, seq, batchFee, tfAllOrNothing), - batch::inner(forgedLoanSet, seq + 1), - batch::inner(pay(borrower, lender, XRP(1)), seq + 2), - ter(lendingBatchEnabled ? temBAD_SIGNATURE : temINVALID_INNER_BATCH)); + batch::Inner(forgedLoanSet, seq + 1), + batch::Inner(pay(borrower, lender, XRP(1)), seq + 2), + Ter(lendingBatchEnabled ? temBAD_SIGNATURE : temINVALID_INNER_BATCH)); env.close(); // ? Check that the loan was NOT created { - Json::Value params(Json::objectValue); + json::Value params(json::ObjectValue); params[jss::account] = borrower.human(); params[jss::type] = "Loan"; auto const res = env.rpc("json", "account_objects", to_string(params)); @@ -3749,7 +3749,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -3770,18 +3770,18 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; - auto createJson = env.json(set(lender, broker.brokerID, principalRequest), fee(loanSetFee)); + auto createJson = env.json(set(lender, broker.brokerID, principalRequest), Fee(loanSetFee)); - Json::Value counterpartyJson{Json::objectValue}; + json::Value counterpartyJson{json::ObjectValue}; counterpartyJson[sfTxnSignature] = createJson[sfTxnSignature]; counterpartyJson[sfSigningPubKey] = createJson[sfSigningPubKey]; if (!BEAST_EXPECT(!createJson.isMember(jss::Signers))) counterpartyJson[sfSigners] = createJson[sfSigners]; - createJson = env.json(createJson, json(sfCounterpartySignature, counterpartyJson)); + createJson = env.json(createJson, Json(sfCounterpartySignature, counterpartyJson)); env(createJson); env.close(); @@ -3796,7 +3796,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -3811,7 +3811,7 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{640562, -5}; Number const serviceFee{2462611968}; @@ -3819,10 +3819,10 @@ protected: auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - loanServiceFee(serviceFee), - paymentTotal(numPayments), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + kLOAN_SERVICE_FEE(serviceFee), + kPAYMENT_TOTAL(numPayments), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["CloseInterestRate"] = 55374; createJson["ClosePaymentFee"] = "3825205248"; @@ -3836,10 +3836,10 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); // Fails in preclaim because principal requested can't be // represented as XRP - env(createJson, ter(tecPRECISION_LOSS)); + env(createJson, Ter(tecPRECISION_LOSS)); env.close(); BEAST_EXPECT(!env.le(keylet)); @@ -3848,10 +3848,10 @@ protected: createJson[sfPrincipalRequested] = actualPrincipal; createJson.removeMember(sfSequence.jsonName); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); // Fails in doApply because the payment is too small to be // represented as XRP. - env(createJson, ter(tecPRECISION_LOSS)); + env(createJson, Ter(tecPRECISION_LOSS)); env.close(); } @@ -3864,7 +3864,7 @@ protected: using namespace jtx; - Env env(*this, all); + Env env(*this, all_); auto lowerFee = [&]() { // Run the local fee back down. @@ -3876,9 +3876,9 @@ protected: Account const alice{"alice"}; std::string const borrowerPass = "borrower"; - Account const borrower{borrowerPass, KeyType::ed25519}; + Account const borrower{borrowerPass, KeyType::Ed25519}; auto const lenderPass = "lender"; - Account const lender{lenderPass, KeyType::ed25519}; + Account const lender{lenderPass, KeyType::Ed25519}; env.fund(XRP(1'000'000), alice, lender, borrower); env.close(); @@ -3891,12 +3891,12 @@ protected: { testcase("RPC AccountSet"); - Json::Value txJson{Json::objectValue}; + json::Value txJson{json::ObjectValue}; txJson[sfTransactionType] = "AccountSet"; txJson[sfAccount] = borrower.human(); auto const signParams = [&]() { - Json::Value signParams{Json::objectValue}; + json::Value signParams{json::ObjectValue}; signParams[jss::passphrase] = borrowerPass; signParams[jss::key_type] = "ed25519"; signParams[jss::tx_json] = txJson; @@ -3908,7 +3908,7 @@ protected: auto txSignBlob = jSign[jss::result][jss::tx_blob].asString(); txSignResult.removeMember(jss::hash); - auto const jtx = env.jt(txJson, sig(borrower)); + auto const jtx = env.jt(txJson, Sig(borrower)); BEAST_EXPECT(txSignResult == jtx.jv); lowerFee(); @@ -3919,18 +3919,18 @@ protected: jSubmit[jss::result][jss::engine_result].asString() == "tesSUCCESS"); lowerFee(); - env(jtx.jv, sig(none), seq(none), fee(none), ter(tefPAST_SEQ)); + env(jtx.jv, Sig(kNONE), Seq(kNONE), Fee(kNONE), Ter(tefPAST_SEQ)); } { testcase("RPC LoanSet - illegal signature_target"); - Json::Value txJson{Json::objectValue}; + json::Value txJson{json::ObjectValue}; txJson[sfTransactionType] = "AccountSet"; txJson[sfAccount] = borrower.human(); auto const borrowerSignParams = [&]() { - Json::Value params{Json::objectValue}; + json::Value params{json::ObjectValue}; params[jss::passphrase] = borrowerPass; params[jss::key_type] = "ed25519"; params[jss::signature_target] = "Destination"; @@ -3948,7 +3948,7 @@ protected: { testcase("RPC LoanSet - sign and submit borrower initiated"); // 1. Borrower creates the transaction - Json::Value txJson{Json::objectValue}; + json::Value txJson{json::ObjectValue}; txJson[sfTransactionType] = "LoanSet"; txJson[sfAccount] = borrower.human(); txJson[sfCounterparty] = lender.human(); @@ -3965,7 +3965,7 @@ protected: // 2. Borrower signs the transaction auto const borrowerSignParams = [&]() { - Json::Value params{Json::objectValue}; + json::Value params{json::ObjectValue}; params[jss::passphrase] = borrowerPass; params[jss::key_type] = "ed25519"; params[jss::tx_json] = txJson; @@ -3997,7 +3997,7 @@ protected: // 3. Borrower sends the signed transaction to the lender // 4. Lender signs the transaction auto const lenderSignParams = [&]() { - Json::Value params{Json::objectValue}; + json::Value params{json::ObjectValue}; params[jss::passphrase] = lenderPass; params[jss::key_type] = "ed25519"; params[jss::signature_target] = "CounterpartySignature"; @@ -4055,7 +4055,7 @@ protected: { testcase("RPC LoanSet - sign and submit lender initiated"); // 1. Lender creates the transaction - Json::Value txJson{Json::objectValue}; + json::Value txJson{json::ObjectValue}; txJson[sfTransactionType] = "LoanSet"; txJson[sfAccount] = lender.human(); txJson[sfCounterparty] = borrower.human(); @@ -4072,7 +4072,7 @@ protected: // 2. Lender signs the transaction auto const lenderSignParams = [&]() { - Json::Value params{Json::objectValue}; + json::Value params{json::ObjectValue}; params[jss::passphrase] = lenderPass; params[jss::key_type] = "ed25519"; params[jss::tx_json] = txJson; @@ -4103,7 +4103,7 @@ protected: // 3. Lender sends the signed transaction to the Borrower // 4. Borrower signs the transaction auto const borrowerSignParams = [&]() { - Json::Value params{Json::objectValue}; + json::Value params{json::ObjectValue}; params[jss::passphrase] = borrowerPass; params[jss::key_type] = "ed25519"; params[jss::signature_target] = "CounterpartySignature"; @@ -4168,7 +4168,7 @@ protected: Account const issuer("issuer"); Account const borrower("borrower"); Account const broker("broker"); - auto const IOU = issuer["IOU"]; + auto const iou = issuer["IOU"]; for (bool const deepFreeze : {true, false}) { @@ -4179,7 +4179,7 @@ protected: BEAST_EXPECT(le)) { auto const account = le->at(accountField); - if (auto const sleLine = env.le(keylet::line(account, IOU)); + if (auto const sleLine = env.le(keylet::line(account, iou)); BEAST_EXPECT(sleLine)) { STAmount balance = sleLine->at(sfBalance); @@ -4188,33 +4188,33 @@ protected: return balance; } } - return STAmount{IOU}; + return STAmount{iou}; }; env.fund(XRP(20'000), issuer, broker, borrower); env.close(); - env(trust(broker, IOU(20'000'000))); - env(pay(issuer, broker, IOU(10'000'000))); + env(trust(broker, iou(20'000'000))); + env(pay(issuer, broker, iou(10'000'000))); env.close(); - auto const brokerInfo = createVaultAndBroker(env, IOU, broker); + auto const brokerInfo = createVaultAndBroker(env, iou, broker); - BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == IOU(1'000)); + BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == iou(1'000)); auto const keylet = keylet::loan(brokerInfo.brokerID, 1); env(set(borrower, brokerInfo.brokerID, 10'000), - sig(sfCounterpartySignature, broker), - loanServiceFee(IOU(100).value()), - paymentInterval(100), - fee(XRP(100))); + Sig(sfCounterpartySignature, broker), + kLOAN_SERVICE_FEE(iou(100).value()), + kPAYMENT_INTERVAL(100), + Fee(XRP(100))); env.close(); - env(trust(borrower, IOU(20'000'000))); + env(trust(borrower, iou(20'000'000))); // The borrower increases their limit and acquires some IOU so // they can pay interest - env(pay(issuer, borrower, IOU(500))); + env(pay(issuer, borrower, iou(500))); env.close(); if (auto const le = env.le(keylet::loan(keylet.key)); BEAST_EXPECT(le)) @@ -4225,20 +4225,20 @@ protected: env.close(); } - env(pay(borrower, keylet.key, IOU(10'100)), fee(XRP(100))); + env(pay(borrower, keylet.key, iou(10'100)), Fee(XRP(100))); env.close(); if (deepFreeze) { // The fee goes to the broker pseudo-account - BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == IOU(1'100)); - BEAST_EXPECT(getCoverBalance(brokerInfo, sfOwner) == IOU(8'999'000)); + BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == iou(1'100)); + BEAST_EXPECT(getCoverBalance(brokerInfo, sfOwner) == iou(8'999'000)); } else { // The fee goes to the broker account - BEAST_EXPECT(getCoverBalance(brokerInfo, sfOwner) == IOU(8'999'100)); - BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == IOU(1'000)); + BEAST_EXPECT(getCoverBalance(brokerInfo, sfOwner) == iou(8'999'100)); + BEAST_EXPECT(getCoverBalance(brokerInfo, sfAccount) == iou(1'000)); } } }; @@ -4258,28 +4258,28 @@ protected: env.fund(XRP(1'000), issuer, lender); - std::int64_t constexpr issuerBalance = 10'000'000; + std::int64_t constexpr kISSUER_BALANCE = 10'000'000; MPTTester const asset( - {.env = env, .issuer = issuer, .holders = {lender}, .pay = issuerBalance}); + {.env = env, .issuer = issuer, .holders = {lender}, .pay = kISSUER_BALANCE}); BrokerParameters const brokerParams{ .debtMax = 200, }; auto const broker = createVaultAndBroker(env, asset, lender, brokerParams); - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); // Create Loan - env(set(borrower, broker.brokerID, 200), sig(sfCounterpartySignature, lender), loanSetFee); + env(set(borrower, broker.brokerID, 200), Sig(sfCounterpartySignature, lender), loanSetFee); env.close(); // Issuer should not create MPToken BEAST_EXPECT(!env.le(keylet::mptoken(asset.issuanceID(), issuer))); // Issuer "borrowed" 200, OutstandingAmount decreased by 200 - BEAST_EXPECT(env.balance(issuer, asset) == asset(-issuerBalance + 200)); + BEAST_EXPECT(env.balance(issuer, asset) == asset(-kISSUER_BALANCE + 200)); // Pay Loan auto const loanKeylet = keylet::loan(broker.brokerID, 1); env(pay(borrower, loanKeylet.key, asset(200))); env.close(); // Issuer "re-payed" 200, OutstandingAmount increased by 200 - BEAST_EXPECT(env.balance(issuer, asset) == asset(-issuerBalance)); + BEAST_EXPECT(env.balance(issuer, asset) == asset(-kISSUER_BALANCE)); } void @@ -4295,7 +4295,7 @@ protected: Env env(*this); env.fund(XRP(1'000), alice); env.close(); - env(del(alice, beast::zero), ter(temINVALID)); + env(del(alice, beast::kZERO), Ter(temINVALID)); } } @@ -4312,7 +4312,7 @@ protected: Env env(*this); env.fund(XRP(1'000), alice); env.close(); - env(manage(alice, beast::zero, tfLoanDefault), ter(temINVALID)); + env(manage(alice, beast::kZERO, tfLoanDefault), Ter(temINVALID)); } } @@ -4325,20 +4325,20 @@ protected: Account const lender{"lender"}; Account const issuer{"issuer"}; Account const borrower{"borrower"}; - auto const IOU = issuer["IOU"]; + auto const iou = issuer["IOU"]; // preclaim Env env(*this); env.fund(XRP(1'000), lender, issuer, borrower); - env(trust(lender, IOU(10'000'000))); - env(pay(issuer, lender, IOU(5'000'000))); + env(trust(lender, iou(10'000'000))); + env(pay(issuer, lender, iou(5'000'000))); BrokerInfo brokerInfo{createVaultAndBroker(env, issuer["IOU"], lender)}; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); STAmount const debtMaximumRequest = brokerInfo.asset(1'000).value(); env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee); env.close(); @@ -4350,7 +4350,7 @@ protected: env.close(); // preclaim: tecFROZEN - env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecFROZEN)); + env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecFROZEN)); env.close(); env(fclear(issuer, asfGlobalFreeze)); @@ -4375,7 +4375,7 @@ protected: env.close(); // preclaim: tecFROZEN due to deep frozen - env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecFROZEN)); + env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecFROZEN)); env.close(); // Only one needs to be unfrozen @@ -4383,7 +4383,7 @@ protected: env.close(); // The payment is late by this point - env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecEXPIRED)); + env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecEXPIRED)); env.close(); env(pay(borrower, loanKeylet.key, debtMaximumRequest, tfLoanLatePayment)); env.close(); @@ -4391,7 +4391,7 @@ protected: // preclaim: tecKILLED // note that tecKILLED in loanMakePayment() // doesn't happen because of the preclaim check. - env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecKILLED)); + env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecKILLED)); } void @@ -4403,16 +4403,16 @@ protected: Account const lender{"lender"}; Account const issuer{"issuer"}; Account const borrower{"borrower"}; - auto const IOU = issuer["IOU"]; + auto const iou = issuer["IOU"]; auto testWrapper = [&](auto&& test) { Env env(*this); env.fund(XRP(1'000), lender, issuer, borrower); - env(trust(lender, IOU(10'000'000))); - env(pay(issuer, lender, IOU(5'000'000))); + env(trust(lender, iou(10'000'000))); + env(pay(issuer, lender, iou(5'000'000))); BrokerInfo const brokerInfo{createVaultAndBroker(env, issuer["IOU"], lender)}; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const debtMaximumRequest = brokerInfo.asset(1'000).value(); test(env, brokerInfo, loanSetFee, debtMaximumRequest); }; @@ -4420,32 +4420,32 @@ protected: // preflight: testWrapper([&](Env& env, BrokerInfo const& brokerInfo, - jtx::fee const& loanSetFee, + jtx::Fee const& loanSetFee, Number const& debtMaximumRequest) { // first temBAD_SIGNER: TODO // invalid grace period { // zero grace period env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), - gracePeriod(0), + Sig(sfCounterpartySignature, lender), + kGRACE_PERIOD(0), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // grace period less than default minimum env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), - gracePeriod(LoanSet::defaultGracePeriod - 1), + Sig(sfCounterpartySignature, lender), + kGRACE_PERIOD(LoanSet::kDEFAULT_GRACE_PERIOD - 1), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); // grace period greater than payment interval env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), - paymentInterval(120), - gracePeriod(121), + Sig(sfCounterpartySignature, lender), + kPAYMENT_INTERVAL(120), + kGRACE_PERIOD(121), loanSetFee, - ter(temINVALID)); + Ter(temINVALID)); } // empty/zero broker ID { @@ -4455,10 +4455,10 @@ protected: // empty broker ID jv[sfLoanBrokerID] = id; env(jv, - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - txflags(flags), - ter(temINVALID)); + Txflags(flags), + Ter(temINVALID)); }; // empty broker ID testZeroBrokerID(std::string("")); @@ -4474,7 +4474,7 @@ protected: JTx const tx = env.jt( set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee); STTx local = *(tx.stx); auto counterpartySig = local.getFieldObject(sfCounterpartySignature); @@ -4482,7 +4482,7 @@ protected: badPubKey[20] ^= 0xAA; counterpartySig.setFieldVL(sfSigningPubKey, badPubKey); local.setFieldObject(sfCounterpartySignature, counterpartySig); - Json::Value jvResult; + json::Value jvResult; jvResult[jss::tx_blob] = strHex(local.getSerializer().slice()); auto res = env.rpc("json", "submit", to_string(jvResult))["result"]; BEAST_EXPECT( @@ -4494,7 +4494,7 @@ protected: // preclaim: testWrapper([&](Env& env, BrokerInfo const& brokerInfo, - jtx::fee const& loanSetFee, + jtx::Fee const& loanSetFee, Number const& debtMaximumRequest) { // canAddHoldingFailure (IOU only, if MPT doesn't have // MPTCanTransfer set, then can't create Vault/LoanBroker, @@ -4502,15 +4502,15 @@ protected: env(fclear(issuer, asfDefaultRipple)); env.close(); env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(terNO_RIPPLE)); + Ter(terNO_RIPPLE)); }); // doApply: testWrapper([&](Env& env, BrokerInfo const& brokerInfo, - jtx::fee const& loanSetFee, + jtx::Fee const& loanSetFee, Number const& debtMaximumRequest) { auto const amt = env.balance(borrower) - env.current()->fees().accountReserve(env.ownerCount(borrower)); @@ -4518,9 +4518,9 @@ protected: // tecINSUFFICIENT_RESERVE env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecINSUFFICIENT_RESERVE)); + Ter(tecINSUFFICIENT_RESERVE)); // addEmptyHolding failure env(pay(issuer, borrower, amt)); @@ -4528,9 +4528,9 @@ protected: env.close(); env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - ter(tecFROZEN)); + Ter(tecFROZEN)); }); } @@ -4543,7 +4543,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4552,7 +4552,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); PrettyAsset const mptAsset = mptt.issuanceID(); mptt.authorize({.account = lender}); @@ -4565,13 +4565,13 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["CloseInterestRate"] = 76671; createJson["ClosePaymentFee"] = "2061925410"; @@ -4589,8 +4589,8 @@ protected: auto const brokerStateBefore = env.le(keylet::loanbroker(broker.brokerID)); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); - env(createJson, ter(temINVALID)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); + env(createJson, Ter(temINVALID)); env.close(); } @@ -4604,7 +4604,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; using namespace Lending; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4613,7 +4613,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; auto trustLenderTx = env.json(trust(lender, iouAsset(1'000'000'000))); env(trustLenderTx); auto trustBorrowerTx = env.json(trust(borrower, iouAsset(1'000'000'000))); @@ -4629,13 +4629,13 @@ protected: using namespace loan; auto const baseFee = env.current()->fees().base; - auto const loanSetFee = fee(baseFee * 2); + auto const loanSetFee = Fee(baseFee * 2); Number const principalRequest{1, 3}; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["ClosePaymentFee"] = "0"; createJson["GracePeriod"] = 60; @@ -4652,8 +4652,8 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); - env(createJson, ter(tesSUCCESS)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); + env(createJson, Ter(tesSUCCESS)); env.close(); auto const pseudoAcct = [&]() { @@ -4671,11 +4671,11 @@ protected: Number const payment{3'269'349'176'470'588, -12}; XRPAmount const payFee{ baseFee * - ((payment / originalState.periodicPayment) / loanPaymentsPerFeeIncrement + 1)}; + ((payment / originalState.periodicPayment) / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; auto loanPayTx = - env.json(pay(borrower, keylet.key, STAmount{broker.asset, payment}), fee(payFee)); + env.json(pay(borrower, keylet.key, STAmount{broker.asset, payment}), Fee(payFee)); BEAST_EXPECT(to_string(payment) == "3269.349176470588"); - env(loanPayTx, ter(tesSUCCESS)); + env(loanPayTx, Ter(tesSUCCESS)); env.close(); auto const newState = getCurrentState(env, broker, keylet); @@ -4695,7 +4695,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4704,7 +4704,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; auto trustLenderTx = env.json(trust(lender, iouAsset(1'000'000'000))); env(trustLenderTx); auto trustBorrowerTx = env.json(trust(borrower, iouAsset(1'000'000'000))); @@ -4719,13 +4719,13 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["CloseInterestRate"] = 47299; createJson["ClosePaymentFee"] = "3985819770"; @@ -4742,13 +4742,13 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); env(createJson); env.close(); auto loanPayTx = env.json(pay(borrower, keylet.key, STAmount{broker.asset, Number{}})); loanPayTx["Amount"]["value"] = "0.000281284125490196"; - env(loanPayTx, ter(tecINSUFFICIENT_PAYMENT)); + env(loanPayTx, Ter(tecINSUFFICIENT_PAYMENT)); env.close(); } @@ -4761,7 +4761,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; using namespace Lending; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4770,7 +4770,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; env(trust(lender, iouAsset(100'000'000))); env(trust(borrower, iouAsset(100'000'000))); env(pay(issuer, lender, iouAsset(10'000'000))); @@ -4781,14 +4781,14 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto const baseFee = env.current()->fees().base; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["ClosePaymentFee"] = "0"; createJson["GracePeriod"] = 60; @@ -4806,27 +4806,28 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); - env(createJson, ter(tesSUCCESS)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); + env(createJson, Ter(tesSUCCESS)); env.close(); auto const stateBefore = getCurrentState(env, broker, keylet); BEAST_EXPECT(stateBefore.paymentRemaining == 3239184); - BEAST_EXPECT(stateBefore.paymentRemaining > loanMaximumPaymentsPerTransaction); + BEAST_EXPECT(stateBefore.paymentRemaining > kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION); auto loanPayTx = env.json(pay(borrower, keylet.key, STAmount{broker.asset, Number{}})); Number const amount{395937, -2}; loanPayTx["Amount"]["value"] = to_string(amount); XRPAmount const payFee{ baseFee * - std::int64_t(amount / stateBefore.periodicPayment / loanPaymentsPerFeeIncrement + 1)}; - env(loanPayTx, ter(tesSUCCESS), fee(payFee)); + std::int64_t( + amount / stateBefore.periodicPayment / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; + env(loanPayTx, Ter(tesSUCCESS), Fee(payFee)); env.close(); auto const stateAfter = getCurrentState(env, broker, keylet); BEAST_EXPECT( stateAfter.paymentRemaining == - stateBefore.paymentRemaining - loanMaximumPaymentsPerTransaction); + stateBefore.paymentRemaining - kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION); } void @@ -4839,7 +4840,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; using namespace Lending; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4848,7 +4849,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; auto trustLenderTx = env.json(trust(lender, iouAsset(1'000'000'000))); env(trustLenderTx); auto trustBorrowerTx = env.json(trust(borrower, iouAsset(1'000'000'000))); @@ -4863,13 +4864,13 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["ClosePaymentFee"] = "0"; createJson["InterestRate"] = 24346; @@ -4885,8 +4886,8 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); - env(createJson, ter(tesSUCCESS)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); + env(createJson, Ter(tesSUCCESS)); env.close(); auto const baseFee = env.current()->fees().base; @@ -4898,9 +4899,10 @@ protected: Number const amount{3074'745'058'823'529, -12}; BEAST_EXPECT(to_string(amount) == "3074.745058823529"); XRPAmount const payFee{ - baseFee * (amount / stateBefore.periodicPayment / loanPaymentsPerFeeIncrement + 1)}; + baseFee * + (amount / stateBefore.periodicPayment / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; loanPayTx["Amount"]["value"] = to_string(amount); - env(loanPayTx, fee(payFee), ter(tesSUCCESS)); + env(loanPayTx, Fee(payFee), Ter(tesSUCCESS)); env.close(); } @@ -4909,9 +4911,10 @@ protected: Number const amount{6732'118'170'944'051, -12}; BEAST_EXPECT(to_string(amount) == "6732.118170944051"); XRPAmount const payFee{ - baseFee * (amount / stateBefore.periodicPayment / loanPaymentsPerFeeIncrement + 1)}; + baseFee * + (amount / stateBefore.periodicPayment / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; loanPayTx["Amount"]["value"] = to_string(amount); - env(loanPayTx, fee(payFee), ter(tesSUCCESS)); + env(loanPayTx, Fee(payFee), Ter(tesSUCCESS)); env.close(); } @@ -4938,7 +4941,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; using namespace Lending; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -4947,7 +4950,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; auto trustLenderTx = env.json(trust(lender, iouAsset(1'000'000'000))); env(trustLenderTx); auto trustBorrowerTx = env.json(trust(borrower, iouAsset(1'000'000'000))); @@ -4967,13 +4970,13 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest{1, 3}; auto createJson = env.json( set(borrower, broker.brokerID, principalRequest), - fee(loanSetFee), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + Json(sfCounterpartySignature, json::ObjectValue)); createJson["ClosePaymentFee"] = "0"; createJson["InterestRate"] = 12833; @@ -4989,29 +4992,30 @@ protected: auto const loanSequence = brokerStateBefore->at(sfLoanSequence); auto const keylet = keylet::loan(broker.brokerID, loanSequence); - createJson = env.json(createJson, sig(sfCounterpartySignature, lender)); - env(createJson, ter(tesSUCCESS)); + createJson = env.json(createJson, Sig(sfCounterpartySignature, lender)); + env(createJson, Ter(tesSUCCESS)); env.close(); auto const baseFee = env.current()->fees().base; auto const stateBefore = getCurrentState(env, broker, keylet); BEAST_EXPECT(stateBefore.paymentRemaining == 5678); - BEAST_EXPECT(stateBefore.paymentRemaining > loanMaximumPaymentsPerTransaction); + BEAST_EXPECT(stateBefore.paymentRemaining > kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION); auto loanPayTx = env.json(pay(borrower, keylet.key, STAmount{broker.asset, Number{}})); Number const amount{9924'81, -2}; BEAST_EXPECT(to_string(amount) == "9924.81"); XRPAmount const payFee{ - baseFee * (amount / stateBefore.periodicPayment / loanPaymentsPerFeeIncrement + 1)}; + baseFee * + (amount / stateBefore.periodicPayment / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; loanPayTx["Amount"]["value"] = to_string(amount); - env(loanPayTx, fee(payFee), ter(tesSUCCESS)); + env(loanPayTx, Fee(payFee), Ter(tesSUCCESS)); env.close(); auto const stateAfter = getCurrentState(env, broker, keylet); BEAST_EXPECT( stateAfter.paymentRemaining == - stateBefore.paymentRemaining - loanMaximumPaymentsPerTransaction); + stateBefore.paymentRemaining - kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION); } void @@ -5023,7 +5027,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; using namespace Lending; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -5032,7 +5036,7 @@ protected: env.fund(XRP(1'000'000), issuer, lender, borrower); env.close(); - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; auto trustLenderTx = env.json(trust(lender, iouAsset(1'000'000'000))); env(trustLenderTx); auto trustBorrowerTx = env.json(trust(borrower, iouAsset(1'000'000'000))); @@ -5048,24 +5052,24 @@ protected: using namespace loan; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); using timeType = decltype(sfNextPaymentDueDate)::type::value_type; static_assert(std::is_same_v); - timeType constexpr maxTime = std::numeric_limits::max(); - static_assert(maxTime == 4'294'967'295); + timeType constexpr kMAX_TIME = std::numeric_limits::max(); + static_assert(kMAX_TIME == 4'294'967'295); auto const baseJson = [&]() { auto createJson = env.json( set(borrower, broker.brokerID, Number{55524'81, -2}), - fee(loanSetFee), - closePaymentFee(0), - gracePeriod(LoanSet::defaultGracePeriod), - interestRate(TenthBips32(12833)), - lateInterestRate(TenthBips32(77048)), - latePaymentFee(0), - loanOriginationFee(218), - json(sfCounterpartySignature, Json::objectValue)); + Fee(loanSetFee), + kCLOSE_PAYMENT_FEE(0), + kGRACE_PERIOD(LoanSet::kDEFAULT_GRACE_PERIOD), + kINTEREST_RATE(TenthBips32(12833)), + kLATE_INTEREST_RATE(TenthBips32(77048)), + kLATE_PAYMENT_FEE(0), + kLOAN_ORIGINATION_FEE(218), + Json(sfCounterpartySignature, json::ObjectValue)); createJson.removeMember(sfSequence.getJsonName()); @@ -5082,16 +5086,17 @@ protected: BEAST_EXPECT(startDate >= 50); - return maxTime - startDate; + return kMAX_TIME - startDate; }; { // straight-up overflow: interval auto const interval = maxLoanTime() + 1; auto const total = 1; - auto createJson = env.json(baseJson, paymentInterval(interval), paymentTotal(total)); + auto createJson = + env.json(baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { @@ -5099,9 +5104,10 @@ protected: // min interval is 60 auto const interval = 60; auto const total = maxLoanTime() + 1; - auto createJson = env.json(baseJson, paymentInterval(interval), paymentTotal(total)); + auto createJson = + env.json(baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { @@ -5111,19 +5117,20 @@ protected: auto const total = 1; auto const grace = interval; auto createJson = env.json( - baseJson, paymentInterval(interval), paymentTotal(total), gracePeriod(grace)); + baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total), kGRACE_PERIOD(grace)); // The grace period can't be larger than the interval. - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { // Overflow with multiplication of a few large intervals auto const interval = 1'000'000'000; auto const total = 10; - auto createJson = env.json(baseJson, paymentInterval(interval), paymentTotal(total)); + auto createJson = + env.json(baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { @@ -5131,9 +5138,10 @@ protected: // min interval is 60 auto const interval = 60; auto const total = 1'000'000'000; - auto createJson = env.json(baseJson, paymentInterval(interval), paymentTotal(total)); + auto createJson = + env.json(baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { @@ -5143,9 +5151,9 @@ protected: auto const interval = (maxLoanTime() - total) / total; auto const grace = interval; auto createJson = env.json( - baseJson, paymentInterval(interval), paymentTotal(total), gracePeriod(grace)); + baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total), kGRACE_PERIOD(grace)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tecKILLED)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tecKILLED)); env.close(); } { @@ -5158,9 +5166,9 @@ protected: auto const interval = maxLoanTime() - grace; auto const total = 1; auto createJson = env.json( - baseJson, paymentInterval(interval), paymentTotal(total), gracePeriod(grace)); + baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total), kGRACE_PERIOD(grace)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tesSUCCESS)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tesSUCCESS)); env.close(); // The transaction is killed in the closed ledger @@ -5183,12 +5191,12 @@ protected: auto const closeStartDate = (parentCloseTime() / 10 + 1) * 10; auto const grace = 5'000; - auto const interval = maxTime - closeStartDate - grace; + auto const interval = kMAX_TIME - closeStartDate - grace; auto const total = 1; auto createJson = env.json( - baseJson, paymentInterval(interval), paymentTotal(total), gracePeriod(grace)); + baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total), kGRACE_PERIOD(grace)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tesSUCCESS)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tesSUCCESS)); env.close(); // The transaction succeeds in the closed ledger @@ -5200,7 +5208,7 @@ protected: // This loan exists auto const afterState = getCurrentState(env, broker, keylet); - BEAST_EXPECT(afterState.nextPaymentDate == maxTime - grace); + BEAST_EXPECT(afterState.nextPaymentDate == kMAX_TIME - grace); BEAST_EXPECT(afterState.previousPaymentDate == 0); BEAST_EXPECT(afterState.paymentRemaining == 1); } @@ -5212,7 +5220,7 @@ protected: // Start date when the ledger is closed will be larger auto const closeStartDate = (parentCloseTime() / 10 + 1) * 10; auto const grace = 5'000; - auto const maxLoanTime = maxTime - closeStartDate - grace; + auto const maxLoanTime = kMAX_TIME - closeStartDate - grace; auto const total = [&]() { if (maxLoanTime % 5 == 0) return 5; @@ -5232,9 +5240,9 @@ protected: auto const interval = maxLoanTime / total; auto createJson = env.json( - baseJson, paymentInterval(interval), paymentTotal(total), gracePeriod(grace)); + baseJson, kPAYMENT_INTERVAL(interval), kPAYMENT_TOTAL(total), kGRACE_PERIOD(grace)); - env(createJson, sig(sfCounterpartySignature, lender), ter(tesSUCCESS)); + env(createJson, Sig(sfCounterpartySignature, lender), Ter(tesSUCCESS)); env.close(); // This loan exists @@ -5246,21 +5254,22 @@ protected: // pay all but the last payment { - NumberRoundModeGuard const mg{Number::rounding_mode::upward}; + NumberRoundModeGuard const mg{Number::RoundingMode::Upward}; Number const payment = beforeState.periodicPayment * (total - 1); - XRPAmount const payFee{baseFee * ((total - 1) / loanPaymentsPerFeeIncrement + 1)}; + XRPAmount const payFee{ + baseFee * ((total - 1) / kLOAN_PAYMENTS_PER_FEE_INCREMENT + 1)}; STAmount const paymentAmount = roundToScale(STAmount{broker.asset, payment}, beforeState.loanScale); - auto loanPayTx = env.json(pay(borrower, keylet.key, paymentAmount), fee(payFee)); - env(loanPayTx, ter(tesSUCCESS)); + auto loanPayTx = env.json(pay(borrower, keylet.key, paymentAmount), Fee(payFee)); + env(loanPayTx, Ter(tesSUCCESS)); env.close(); } // The loan is on the last payment auto const afterState = getCurrentState(env, broker, keylet); BEAST_EXPECT(afterState.paymentRemaining == 1); - BEAST_EXPECT(afterState.nextPaymentDate == maxTime - grace); - BEAST_EXPECT(afterState.previousPaymentDate == maxTime - grace - interval); + BEAST_EXPECT(afterState.nextPaymentDate == kMAX_TIME - grace); + BEAST_EXPECT(afterState.previousPaymentDate == kMAX_TIME - grace - interval); } } @@ -5282,14 +5291,14 @@ protected: .env = env, .issuer = issuer, .holders = {lender, borrower}, - .flags = MPTDEXFlags | tfMPTRequireAuth | tfMPTCanClawback | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth | tfMPTCanClawback | tfMPTCanLock, .authHolder = true, }); env(pay(issuer, lender, asset(5'000'000))); BrokerInfo brokerInfo{createVaultAndBroker(env, asset, lender)}; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); STAmount const debtMaximumRequest = brokerInfo.asset(1'000).value(); auto forUnauthAuth = [&](auto&& doTx) { @@ -5304,19 +5313,19 @@ protected: // Can't create a loan if the borrower is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(set(borrower, brokerInfo.brokerID, debtMaximumRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, err); }); - std::uint32_t constexpr loanSequence = 1; - auto const loanKeylet = keylet::loan(brokerInfo.brokerID, loanSequence); + std::uint32_t constexpr kLOAN_SEQUENCE = 1; + auto const loanKeylet = keylet::loan(brokerInfo.brokerID, kLOAN_SEQUENCE); // Can't loan pay if the borrower is not authorized forUnauthAuth([&](bool authorized) { - auto const err = !authorized ? ter(tecNO_AUTH) : ter(tesSUCCESS); + auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS); env(pay(borrower, loanKeylet.key, debtMaximumRequest), err); }); } @@ -5336,7 +5345,7 @@ protected: env.fund(XRP(100'000), issuer, alice); env.close(); - MPTTester mpt{env, issuer, mptInitNoFund}; + MPTTester mpt{env, issuer, kMPT_INIT_NO_FUND}; mpt.create({.flags = tfMPTCanTransfer, .mutableFlags = tmfMPTCanMutateCanTransfer}); @@ -5371,18 +5380,18 @@ protected: // Standard Payment path should forbid third-party transfers. auto const err = feature[featureMPTokensV2] ? tecNO_PERMISSION : tecNO_AUTH; - env(pay(alice, pseudoAccount, asset(1)), ter(err)); + env(pay(alice, pseudoAccount, asset(1)), Ter(err)); env.close(); // Cover cannot be transferred to broker account auto const depositAmount = asset(1); - env(coverDeposit(alice, brokerKeylet.key, depositAmount), ter{tecNO_AUTH}); + env(coverDeposit(alice, brokerKeylet.key, depositAmount), Ter{tecNO_AUTH}); env.close(); if (auto const refreshed = env.le(brokerKeylet); BEAST_EXPECT(refreshed)) { BEAST_EXPECT(refreshed->at(sfCoverAvailable) == 0); - env.require(balance(pseudoAccount, asset(0))); + env.require(Balance(pseudoAccount, asset(0))); } // Set CanTransfer again and transfer some deposit @@ -5395,7 +5404,7 @@ protected: if (auto const refreshed = env.le(brokerKeylet); BEAST_EXPECT(refreshed)) { BEAST_EXPECT(refreshed->at(sfCoverAvailable) == 1); - env.require(balance(pseudoAccount, depositAmount)); + env.require(Balance(pseudoAccount, depositAmount)); } // Remove CanTransfer after the deposit @@ -5403,7 +5412,7 @@ protected: env.close(); // Cover cannot be transferred from broker account - env(coverWithdraw(alice, brokerKeylet.key, depositAmount), ter{tecNO_AUTH}); + env(coverWithdraw(alice, brokerKeylet.key, depositAmount), Ter{tecNO_AUTH}); env.close(); // Set CanTransfer again and withdraw @@ -5416,7 +5425,7 @@ protected: if (auto const refreshed = env.le(brokerKeylet); BEAST_EXPECT(refreshed)) { BEAST_EXPECT(refreshed->at(sfCoverAvailable) == 0); - env.require(balance(pseudoAccount, asset(0))); + env.require(Balance(pseudoAccount, asset(0))); } } @@ -5447,7 +5456,7 @@ protected: BrokerInfo broker{createVaultAndBroker(env, asset, lender)}; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); auto const brokerPreLoan = env.le(keylet::loanbroker(broker.brokerID)); if (BEAST_EXPECT(brokerPreLoan); !brokerPreLoan.has_value()) @@ -5462,17 +5471,17 @@ protected: Number const closeFee = asset(4).value(); env(set(borrower, broker.brokerID, principal), - sig(sfCounterpartySignature, lender), - loanServiceFee(serviceFee), - latePaymentFee(lateFee), - closePaymentFee(closeFee), - interestRate(percentageToTenthBips(12)), - lateInterestRate(percentageToTenthBips(24) / 10), - closeInterestRate(percentageToTenthBips(5)), - paymentTotal(12), - paymentInterval(600), - gracePeriod(0), - fee(loanSetFee)); + Sig(sfCounterpartySignature, lender), + kLOAN_SERVICE_FEE(serviceFee), + kLATE_PAYMENT_FEE(lateFee), + kCLOSE_PAYMENT_FEE(closeFee), + kINTEREST_RATE(percentageToTenthBips(12)), + kLATE_INTEREST_RATE(percentageToTenthBips(24) / 10), + kCLOSE_INTEREST_RATE(percentageToTenthBips(5)), + kPAYMENT_TOTAL(12), + kPAYMENT_INTERVAL(600), + kGRACE_PERIOD(0), + Fee(loanSetFee)); env.close(); auto state1 = getCurrentState(env, broker, loanKeylet); @@ -5604,14 +5613,14 @@ protected: BrokerParameters brokerParams{.debtMax = 0, .coverRateMin = TenthBips32{10'000}}; BrokerInfo broker{createVaultAndBroker(env, asset, lender, brokerParams)}; - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); auto createTx = env.jt( set(borrower, broker.brokerID, principalRequest), - sig(sfCounterpartySignature, lender), + Sig(sfCounterpartySignature, lender), loanSetFee, - paymentInterval(600), - paymentTotal(1), - gracePeriod(60)); + kPAYMENT_INTERVAL(600), + kPAYMENT_TOTAL(1), + kGRACE_PERIOD(60)); env(createTx); env.close(); @@ -5657,7 +5666,7 @@ protected: #endif void - testPoC_UnsignedUnderflowOnFullPayAfterEarlyPeriodic() + testPoCUnsignedUnderflowOnFullPayAfterEarlyPeriodic() { // --- PoC Summary ---------------------------------------------------- // Scenario: Borrower makes one periodic payment early (before next due) @@ -5679,7 +5688,7 @@ protected: using namespace loan; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); Account const lender{"poc_lender4"}; Account const borrower{"poc_borrower4"}; @@ -5692,7 +5701,7 @@ protected: // Create a 3-payment loan so full-payment path is enabled after 1 // periodic payment. - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); Number const principalRequest = asset(1000).value(); auto const originationFee = asset(0).value(); auto const serviceFee = asset(1).value(); @@ -5709,20 +5718,20 @@ protected: auto createJtx = env.jt( set(borrower, broker.brokerID, principalRequest, 0), - sig(sfCounterpartySignature, lender), - loanOriginationFee(originationFee), - loanServiceFee(serviceFee), - latePaymentFee(lateFee), - closePaymentFee(closeFee), - overpaymentFee(percentageToTenthBips(5) / 10), - interestRate(interest), - lateInterestRate(lateInterest), - closeInterestRate(closeInterest), - overpaymentInterestRate(overpaymentInterest), - paymentTotal(total), - paymentInterval(interval), - gracePeriod(grace), - fee(loanSetFee)); + Sig(sfCounterpartySignature, lender), + kLOAN_ORIGINATION_FEE(originationFee), + kLOAN_SERVICE_FEE(serviceFee), + kLATE_PAYMENT_FEE(lateFee), + kCLOSE_PAYMENT_FEE(closeFee), + kOVERPAYMENT_FEE(percentageToTenthBips(5) / 10), + kINTEREST_RATE(interest), + kLATE_INTEREST_RATE(lateInterest), + kCLOSE_INTEREST_RATE(closeInterest), + kOVERPAYMENT_INTEREST_RATE(overpaymentInterest), + kPAYMENT_TOTAL(total), + kPAYMENT_INTERVAL(interval), + kGRACE_PERIOD(grace), + Fee(loanSetFee)); auto const brokerSle = env.le(keylet::loanbroker(broker.brokerID)); BEAST_EXPECT(brokerSle); @@ -5840,7 +5849,7 @@ protected: << " roundedFullMgmtFeeClamped=" << roundedFullMgmtFeeClamped << " fullDueClamped=" << to_string(fullDueClamped.getJson()) << std::endl; - env(pay(borrower, loanKeylet.key, fullDue), txflags(tfLoanFullPayment)); + env(pay(borrower, loanKeylet.key, fullDue), Txflags(tfLoanFullPayment)); env.close(); // Sanity: underflow present (unsigned delta very large relative to @@ -5881,7 +5890,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - Env env(*this, all); + Env env(*this, all_); // Setup: Create accounts Account const issuer{"issuer"}; @@ -6042,7 +6051,7 @@ protected: auto const assetType = AssetType::XRP; - Env env(*this, all); + Env env(*this, all_); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower); @@ -6113,7 +6122,7 @@ protected: auto const assetType = AssetType::MPT; - Env env(*this, all); + Env env(*this, all_); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower); @@ -6151,7 +6160,7 @@ protected: if (auto const loanSle = env.le(loanKeylet); BEAST_EXPECT(loanSle)) { BEAST_EXPECT(brokerSle->at(sfDebtTotal) == loanSle->at(sfTotalValueOutstanding)); - BEAST_EXPECT(brokerSle->at(sfDebtTotal) == beast::zero); + BEAST_EXPECT(brokerSle->at(sfDebtTotal) == beast::kZERO); } } } @@ -6166,7 +6175,7 @@ protected: Account const issuer{"issuer"}; Account const borrower{"borrower"}; Account const depositor{"depositor"}; - auto const txfee = fee(XRP(100)); + auto const txFee = Fee(XRP(100)); Env env(*this); Vault const vault(env); @@ -6175,16 +6184,16 @@ protected: env.close(); auto [tx, vaultKeyLet] = vault.create({.owner = lender, .asset = xrpIssue()}); - env(tx, txfee); + env(tx, txFee); env.close(); env(vault.deposit({.depositor = depositor, .id = vaultKeyLet.key, .amount = XRP(1'000)}), - txfee); + txFee); env.close(); auto const brokerKeyLet = keylet::loanbroker(lender.id(), env.seq(lender)); - env(loanBroker::set(lender, vaultKeyLet.key), txfee); + env(loanBroker::set(lender, vaultKeyLet.key), txFee); env.close(); // BrokerInfo brokerInfo{xrpIssue(), keylet, vaultKeyLet, {}}; @@ -6192,12 +6201,12 @@ protected: STAmount const debtMaximumRequest = XRPAmount(200'000); env(set(borrower, brokerKeyLet.key, debtMaximumRequest), - sig(sfCounterpartySignature, lender), - interestRate(TenthBips32(50'000)), - paymentTotal(2), - paymentInterval(150), - txflags(tfLoanOverpayment), - txfee); + Sig(sfCounterpartySignature, lender), + kINTEREST_RATE(TenthBips32(50'000)), + kPAYMENT_TOTAL(2), + kPAYMENT_INTERVAL(150), + Txflags(tfLoanOverpayment), + txFee); env.close(); std::uint32_t const loanSequence = 1; @@ -6206,8 +6215,8 @@ protected: if (auto loan = env.le(loanKeylet); env.test.BEAST_EXPECT(loan)) { env(loan::pay(borrower, loanKeylet.key, XRPAmount(150'001)), - txflags(tfLoanOverpayment), - txfee); + Txflags(tfLoanOverpayment), + txFee); env.close(); } } @@ -6220,7 +6229,7 @@ protected: using namespace jtx; using namespace loanBroker; - Env env(*this, all); + Env env(*this, all_); Account const lender{"lender"}; Account const borrower{"borrower"}; @@ -6249,9 +6258,9 @@ protected: // Create a loan with principal 804 XRP and 0% interest (so // DebtTotal increases by exactly 804) env(loan::set(borrower, brokerInfo.brokerID, xrpAsset(804).value()), - loan::interestRate(TenthBips32(0)), - sig(sfCounterpartySignature, lender), - fee(env.current()->fees().base * 2)); + loan::kINTEREST_RATE(TenthBips32(0)), + Sig(sfCounterpartySignature, lender), + Fee(env.current()->fees().base * 2)); BEAST_EXPECT(env.ter() == tesSUCCESS); env.close(); @@ -6266,7 +6275,7 @@ protected: // Attempt to withdraw 2 XRP to self, leaving 80 XRP CoverAvailable. // The minimum is 80.4 XRP, which rounds up to 81 XRP, so this fails. env(coverWithdraw(lender, brokerInfo.brokerID, xrpAsset(2).value()), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); BEAST_EXPECT(env.ter() == tecINSUFFICIENT_FUNDS); env.close(); @@ -6319,7 +6328,7 @@ protected: auto const assetType = AssetType::IOU; - Env env(*this, all); + Env env(*this, all_); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower); @@ -6353,7 +6362,7 @@ protected: using namespace loan; Account const broker{"broker"}; Account const issuer{"issuer"}; - Account const borrower_{"borrower"}; + Account const borrower{"borrower"}; Account const depositor{"depositor"}; auto testLoanAsset = [&](auto&& getMaxDebt, auto const& borrower) { @@ -6371,7 +6380,7 @@ protected: env.close(); auto const xrpFee = XRP(100); - auto const txFee = fee(xrpFee); + auto const txFee = Fee(xrpFee); STAmount const debtMaximumRequest = getMaxDebt(env); @@ -6395,10 +6404,10 @@ protected: auto const serviceFee = 101; env(set(broker, brokerKeylet.key, debtMaximumRequest), - counterparty(borrower), - sig(sfCounterpartySignature, borrower), - loanServiceFee(serviceFee), - paymentTotal(10), + kCOUNTERPARTY(borrower), + Sig(sfCounterpartySignature, borrower), + kLOAN_SERVICE_FEE(serviceFee), + kPAYMENT_TOTAL(10), txFee); env.close(); @@ -6423,7 +6432,7 @@ protected: // Since a borrower is the broker, the payment is // transferred to the Vault from the broker but not // the service fee. - // If the asset is XRP then the broker pays the txfee. + // If the asset is XRP then the broker pays the txFee. if (asset.native()) return brokerBalanceBefore.number() - payment - xrpFee.number(); return brokerBalanceBefore.number() - payment; @@ -6434,19 +6443,19 @@ protected: }; // Test when a borrower is the broker and is not to verify correct // service fee transfer in both cases. - for (auto const& borrowerAcct : {broker, borrower_}) + for (auto const& borrowerAcct : {broker, borrower}) { testLoanAsset( [&](Env&) -> STAmount { return STAmount{XRPAmount{200'000}}; }, borrowerAcct); testLoanAsset( [&](Env& env) -> STAmount { - auto const IOU = issuer["USD"]; - env(trust(broker, IOU(1'000'000'000))); - env(trust(depositor, IOU(1'000'000'000))); - env(pay(issuer, broker, IOU(100'000'000))); - env(pay(issuer, depositor, IOU(100'000'000))); + auto const iou = issuer["USD"]; + env(trust(broker, iou(1'000'000'000))); + env(trust(depositor, iou(1'000'000'000))); + env(pay(issuer, broker, iou(100'000'000))); + env(pay(issuer, depositor, iou(100'000'000))); env.close(); - return IOU(200'000); + return iou(200'000); }, borrowerAcct); testLoanAsset( @@ -6483,7 +6492,7 @@ protected: auto const assetType = AssetType::IOU; - Env env(*this, all); + Env env(*this, all_); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, issuer); @@ -6539,7 +6548,7 @@ protected: auto const assetType = AssetType::XRP; - Env env(*this, makeConfig(), all, nullptr, beast::severities::Severity::kWarning); + Env env(*this, makeConfig(), all_, nullptr, beast::severities::Severity::KWarning); auto loanResult = createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower); @@ -6587,7 +6596,7 @@ protected: using namespace jtx; using namespace loan; - Env env(*this, all); + Env env(*this, all_); Account const lender{"lender"}, borrower{"borrower"}; @@ -6605,23 +6614,23 @@ protected: .managementFeeRate = TenthBips16(10'000), }); - auto const loanSetFee = fee(env.current()->fees().base * 2); + auto const loanSetFee = Fee(env.current()->fees().base * 2); auto const loanKeylet = keylet::loan( result.brokerKeylet().key, (env.le(result.brokerKeylet()))->at(sfLoanSequence)); env(loan::set( borrower, result.brokerKeylet().key, asset(10'000).value(), tfLoanOverpayment), - sig(sfCounterpartySignature, lender), - loan::paymentInterval(86400 * 30), - loan::paymentTotal(3), - loan::overpaymentInterestRate(TenthBips32(percentageToTenthBips(20))), + Sig(sfCounterpartySignature, lender), + loan::kPAYMENT_INTERVAL(86400 * 30), + loan::kPAYMENT_TOTAL(3), + loan::kOVERPAYMENT_INTEREST_RATE(TenthBips32(percentageToTenthBips(20))), loanSetFee); // From calculator auto const expectedOverpaymentManagementFee = Number{33333, 0}; auto const loanBrokerBalanceBefore = env.balance(lender); - auto const loanPayFee = fee(env.current()->fees().base * 2); + auto const loanPayFee = Fee(env.current()->fees().base * 2); env(pay(borrower, loanKeylet.key, asset(5'000).value(), tfLoanOverpayment), loanPayFee); env.close(); @@ -6641,25 +6650,25 @@ protected: Account const issuer("issuer"); Account const borrower("borrower"); Account const broker("broker"); - auto const IOU = issuer["IOU"]; - Env env(*this, all); + auto const iou = issuer["IOU"]; + Env env(*this, all_); env.fund(XRP(20'000), issuer, broker, borrower); env.close(); // Set up trustlines and fund accounts - env(trust(broker, IOU(20'000'000))); - env(trust(borrower, IOU(20'000'000))); - env(pay(issuer, broker, IOU(10'000'000))); - env(pay(issuer, borrower, IOU(1'000))); + env(trust(broker, iou(20'000'000))); + env(trust(borrower, iou(20'000'000))); + env(pay(issuer, broker, iou(10'000'000))); + env(pay(issuer, borrower, iou(1'000))); env.close(); // Create vault and broker - auto const brokerInfo = createVaultAndBroker(env, IOU, broker); + auto const brokerInfo = createVaultAndBroker(env, iou, broker); // Create a loan first (this creates debt) auto const keylet = keylet::loan(brokerInfo.brokerID, 1); env(set(borrower, brokerInfo.brokerID, 10'000), - sig(sfCounterpartySignature, broker), - loanServiceFee(IOU(100).value()), - paymentInterval(100), - fee(XRP(100))); + Sig(sfCounterpartySignature, broker), + kLOAN_SERVICE_FEE(iou(100).value()), + kPAYMENT_INTERVAL(100), + Fee(XRP(100))); env.close(); // Ensure broker has sufficient cover so brokerPayee == brokerOwner // We need coverAvailable >= (debtTotal * coverRateMinimum) @@ -6667,25 +6676,25 @@ protected: // The default coverRateMinimum is 10%, so for a 10,000 loan we need // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. - auto const additionalCover = IOU(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{IOU, additionalCover})); + auto const additionalCover = iou(50'000).value(); + env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{iou, additionalCover})); env.close(); // Verify broker owner has a trustline - auto const brokerTrustline = keylet::line(broker, IOU); + auto const brokerTrustline = keylet::line(broker, iou); BEAST_EXPECT(env.le(brokerTrustline) != nullptr); // Broker owner deletes their trustline // First, pay any positive balance to issuer to zero it out - auto const brokerBalance = env.balance(broker, IOU); + auto const brokerBalance = env.balance(broker, iou); env(pay(broker, issuer, brokerBalance)); env.close(); // Remove the trustline by setting limit to 0 - env(trust(broker, IOU(0))); + env(trust(broker, iou(0))); env.close(); // Verify trustline is deleted BEAST_EXPECT(env.le(brokerTrustline) == nullptr); // Now borrower tries to make a payment // We should get a tesSUCCESS instead of a tecNO_LINE. - env(pay(borrower, keylet.key, IOU(10'100)), fee(XRP(100)), ter(tesSUCCESS)); + env(pay(borrower, keylet.key, iou(10'100)), Fee(XRP(100)), Ter(tesSUCCESS)); env.close(); // Verify trustline is still deleted BEAST_EXPECT(env.le(brokerTrustline) == nullptr); @@ -6694,9 +6703,9 @@ protected: BEAST_EXPECT(brokerSle)) { Account const pseudo("pseudo-account", brokerSle->at(sfAccount)); - auto const balance = env.balance(pseudo, IOU); + auto const balance = env.balance(pseudo, iou); // 1,000 default + 50,000 extra + 100 service fee from LoanPay - BEAST_EXPECTS(balance == IOU(51'100), to_string(Json::Value(balance))); + BEAST_EXPECTS(balance == iou(51'100), to_string(json::Value(balance))); } } @@ -6711,14 +6720,14 @@ protected: Account const borrower("borrower"); Account const broker("broker"); - Env env(*this, all); + Env env(*this, all_); env.fund(XRP(20'000), issuer, broker, borrower); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); - PrettyAsset const MPT{mptt.issuanceID()}; + PrettyAsset const mpt{mptt.issuanceID()}; // Authorize broker and borrower mptt.authorize({.account = broker}); @@ -6727,19 +6736,19 @@ protected: env.close(); // Fund accounts - env(pay(issuer, broker, MPT(10'000'000))); - env(pay(issuer, borrower, MPT(1'000))); + env(pay(issuer, broker, mpt(10'000'000))); + env(pay(issuer, borrower, mpt(1'000))); env.close(); // Create vault and broker - auto const brokerInfo = createVaultAndBroker(env, MPT, broker); + auto const brokerInfo = createVaultAndBroker(env, mpt, broker); // Create a loan first (this creates debt) auto const keylet = keylet::loan(brokerInfo.brokerID, 1); env(set(borrower, brokerInfo.brokerID, 10'000), - sig(sfCounterpartySignature, broker), - loanServiceFee(MPT(100).value()), - paymentInterval(100), - fee(XRP(100))); + Sig(sfCounterpartySignature, broker), + kLOAN_SERVICE_FEE(mpt(100).value()), + kPAYMENT_INTERVAL(100), + Fee(XRP(100))); env.close(); // Ensure broker has sufficient cover so brokerPayee == brokerOwner // We need coverAvailable >= (debtTotal * coverRateMinimum) @@ -6747,15 +6756,15 @@ protected: // The default coverRateMinimum is 10%, so for a 10,000 loan we need // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. - auto const additionalCover = MPT(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{MPT, additionalCover})); + auto const additionalCover = mpt(50'000).value(); + env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); env.close(); // Verify broker owner is authorized auto const brokerMpt = keylet::mptoken(mptt.issuanceID(), broker); BEAST_EXPECT(env.le(brokerMpt) != nullptr); // Broker owner unauthorizes. // First, pay any positive balance to issuer to zero it out - auto const brokerBalance = env.balance(broker, MPT); + auto const brokerBalance = env.balance(broker, mpt); env(pay(broker, issuer, brokerBalance)); env.close(); // Then, unauthorize the MPT. @@ -6765,8 +6774,8 @@ protected: BEAST_EXPECT(env.le(brokerMpt) == nullptr); // Now borrower tries to make a payment // We should get a tesSUCCESS instead of a tecNO_AUTH. - auto const borrowerBalance = env.balance(borrower, MPT); - env(pay(borrower, keylet.key, MPT(10'100)), fee(XRP(100)), ter(tesSUCCESS)); + auto const borrowerBalance = env.balance(borrower, mpt); + env(pay(borrower, keylet.key, mpt(10'100)), Fee(XRP(100)), Ter(tesSUCCESS)); env.close(); // Verify the MPT is still unauthorized. BEAST_EXPECT(env.le(brokerMpt) == nullptr); @@ -6775,9 +6784,9 @@ protected: BEAST_EXPECT(brokerSle)) { Account const pseudo("pseudo-account", brokerSle->at(sfAccount)); - auto const balance = env.balance(pseudo, MPT); + auto const balance = env.balance(pseudo, mpt); // 1,000 default + 50,000 extra + 100 service fee from LoanPay - BEAST_EXPECTS(balance == MPT(51'100), to_string(Json::Value(balance))); + BEAST_EXPECTS(balance == mpt(51'100), to_string(json::Value(balance))); } } @@ -6792,7 +6801,7 @@ protected: Account const borrower("borrower"); Account const broker("broker"); - Env env(*this, all); + Env env(*this, all_); env.fund(XRP(20'000), issuer, broker, borrower); env.close(); @@ -6812,13 +6821,13 @@ protected: env(credentials::accept(borrower, issuer, credType)); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({ .flags = tfMPTCanClawback | tfMPTRequireAuth | tfMPTCanTransfer | tfMPTCanLock, .domainID = domainID, }); - PrettyAsset const MPT{mptt.issuanceID()}; + PrettyAsset const mpt{mptt.issuanceID()}; // Authorize broker and borrower mptt.authorize({.account = broker}); @@ -6827,19 +6836,19 @@ protected: env.close(); // Fund accounts - env(pay(issuer, broker, MPT(10'000'000))); - env(pay(issuer, borrower, MPT(1'000))); + env(pay(issuer, broker, mpt(10'000'000))); + env(pay(issuer, borrower, mpt(1'000))); env.close(); // Create vault and broker - auto const brokerInfo = createVaultAndBroker(env, MPT, broker); + auto const brokerInfo = createVaultAndBroker(env, mpt, broker); // Create a loan first (this creates debt) auto const keylet = keylet::loan(brokerInfo.brokerID, 1); env(set(borrower, brokerInfo.brokerID, 10'000), - sig(sfCounterpartySignature, broker), - loanServiceFee(MPT(100).value()), - paymentInterval(100), - fee(XRP(100))); + Sig(sfCounterpartySignature, broker), + kLOAN_SERVICE_FEE(mpt(100).value()), + kPAYMENT_INTERVAL(100), + Fee(XRP(100))); env.close(); // Ensure broker has sufficient cover so brokerPayee == brokerOwner // We need coverAvailable >= (debtTotal * coverRateMinimum) @@ -6847,15 +6856,15 @@ protected: // The default coverRateMinimum is 10%, so for a 10,000 loan we need // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. - auto const additionalCover = MPT(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{MPT, additionalCover})); + auto const additionalCover = mpt(50'000).value(); + env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); env.close(); // Verify broker owner is authorized auto const brokerMpt = keylet::mptoken(mptt.issuanceID(), broker); BEAST_EXPECT(env.le(brokerMpt) != nullptr); // Remove the credentials for the Broker owner. // First, pay any positive balance to issuer to zero it out - auto const brokerBalance = env.balance(broker, MPT); + auto const brokerBalance = env.balance(broker, mpt); env(pay(broker, issuer, brokerBalance)); env.close(); @@ -6864,23 +6873,23 @@ protected: // Make sure the broker is not authorized to hold the MPT after we // deleted the credentials - env(pay(issuer, broker, MPT(1'000)), ter(tecNO_AUTH)); + env(pay(issuer, broker, mpt(1'000)), Ter(tecNO_AUTH)); // Now borrower tries to make a payment // We should get a tesSUCCESS instead of a tecNO_AUTH. - auto const borrowerBalance = env.balance(borrower, MPT); - env(pay(borrower, keylet.key, MPT(10'100)), fee(XRP(100)), ter(tesSUCCESS)); + auto const borrowerBalance = env.balance(borrower, mpt); + env(pay(borrower, keylet.key, mpt(10'100)), Fee(XRP(100)), Ter(tesSUCCESS)); env.close(); // Verify broker is still not authorized - env(pay(issuer, broker, MPT(1'000)), ter(tecNO_AUTH)); + env(pay(issuer, broker, mpt(1'000)), Ter(tecNO_AUTH)); // Verify the service fee went to the broker pseudo-account if (auto const brokerSle = env.le(keylet::loanbroker(brokerInfo.brokerID)); BEAST_EXPECT(brokerSle)) { Account const pseudo("pseudo-account", brokerSle->at(sfAccount)); - auto const balance = env.balance(pseudo, MPT); + auto const balance = env.balance(pseudo, mpt); // 1,000 default + 50,000 extra + 100 service fee from LoanPay - BEAST_EXPECTS(balance == MPT(51'100), to_string(Json::Value(balance))); + BEAST_EXPECTS(balance == mpt(51'100), to_string(json::Value(balance))); } } @@ -6895,7 +6904,7 @@ protected: Account const borrower("borrower"); Account const broker("broker"); - Env env(*this, all); + Env env(*this, all_); env.fund(XRP(20'000), issuer, broker, borrower); env.close(); @@ -6916,13 +6925,13 @@ protected: env(credentials::accept(borrower, issuer, credType)); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({ .flags = tfMPTCanClawback | tfMPTRequireAuth | tfMPTCanTransfer | tfMPTCanLock, .domainID = domainID, }); - PrettyAsset const MPT{mptt.issuanceID()}; + PrettyAsset const mpt{mptt.issuanceID()}; // Authorize broker and borrower mptt.authorize({.account = broker}); @@ -6930,16 +6939,16 @@ protected: env.close(); // Fund accounts - env(pay(issuer, broker, MPT(10'000'000))); - env(pay(issuer, borrower, MPT(1'000))); + env(pay(issuer, broker, mpt(10'000'000))); + env(pay(issuer, borrower, mpt(1'000))); env.close(); // Create vault and broker - auto const brokerInfo = createVaultAndBroker(env, MPT, broker); + auto const brokerInfo = createVaultAndBroker(env, mpt, broker); // Remove the credentials for the Broker owner. // Clear the balance first. - auto const brokerBalance = env.balance(broker, MPT); + auto const brokerBalance = env.balance(broker, mpt); env(pay(broker, issuer, brokerBalance)); env.close(); // Delete the credentials @@ -6948,11 +6957,11 @@ protected: // Create a loan, this should fail for tecNO_AUTH env(set(borrower, brokerInfo.brokerID, 10'000), - sig(sfCounterpartySignature, broker), - loanServiceFee(MPT(100).value()), - paymentInterval(100), - fee(XRP(100)), - ter(tecNO_AUTH)); + Sig(sfCounterpartySignature, broker), + kLOAN_SERVICE_FEE(mpt(100).value()), + kPAYMENT_INTERVAL(100), + Fee(XRP(100)), + Ter(tecNO_AUTH)); env.close(); } @@ -6965,7 +6974,7 @@ protected: using namespace loan; using namespace loanBroker; - Env env(*this, all); + Env env(*this, all_); Account const issuer{"issuer"}; Account const lender{"lender"}; @@ -7005,12 +7014,12 @@ protected: // Create Loan A auto loanATx = env.jt( set(borrowerA, brokerKeylet.key, principalAmount), - sig(sfCounterpartySignature, lender), - interestRate(TenthBips32(500)), // 5% - paymentTotal(12), - loan::paymentInterval(loanPaymentInterval), - loan::gracePeriod(loanGracePeriod), - fee(XRP(10))); // Sufficient fee for multi-sig transaction + Sig(sfCounterpartySignature, lender), + kINTEREST_RATE(TenthBips32(500)), // 5% + kPAYMENT_TOTAL(12), + loan::kPAYMENT_INTERVAL(loanPaymentInterval), + loan::kGRACE_PERIOD(loanGracePeriod), + Fee(XRP(10))); // Sufficient fee for multi-sig transaction env(loanATx); env.close(); @@ -7019,12 +7028,12 @@ protected: // Create Loan B auto loanBTx = env.jt( set(borrowerB, brokerKeylet.key, principalAmount), - sig(sfCounterpartySignature, lender), - interestRate(TenthBips32(500)), // 5% - paymentTotal(12), - loan::paymentInterval(loanPaymentInterval), - loan::gracePeriod(loanGracePeriod), - fee(XRP(10))); // Sufficient fee for multi-sig transaction + Sig(sfCounterpartySignature, lender), + kINTEREST_RATE(TenthBips32(500)), // 5% + kPAYMENT_TOTAL(12), + loan::kPAYMENT_INTERVAL(loanPaymentInterval), + loan::kGRACE_PERIOD(loanGracePeriod), + Fee(XRP(10))); // Sufficient fee for multi-sig transaction env(loanBTx); env.close(); @@ -7039,7 +7048,7 @@ protected: auto const loanAGrace = loanASle->at(sfGracePeriod); env.close(std::chrono::seconds{loanANextDue + loanAGrace + 60}); - env(manage(lender, loanAKeylet.key, tfLoanDefault), ter(tesSUCCESS)); + env(manage(lender, loanAKeylet.key, tfLoanDefault), Ter(tesSUCCESS)); env.close(); // Verify Loan A is defaulted @@ -7062,7 +7071,7 @@ protected: // CoverAvailable should have decreased significantly BEAST_EXPECT(afterFirstCoverAvailable == 946); - env(manage(lender, loanBKeylet.key, tfLoanDefault), ter(tesSUCCESS)); + env(manage(lender, loanBKeylet.key, tfLoanDefault), Ter(tesSUCCESS)); brokerSle = env.le(brokerKeylet); if (!BEAST_EXPECT(brokerSle)) @@ -7088,17 +7097,17 @@ protected: testcase("Vault withdraw reflects sfLossUnrealized"); // Test constants - static constexpr std::int64_t INITIAL_FUNDING = 1'000'000; - static constexpr std::int64_t LENDER_INITIAL_IOU = 5'000'000; - static constexpr std::int64_t DEPOSITOR_INITIAL_IOU = 1'000'000; - static constexpr std::int64_t BORROWER_INITIAL_IOU = 100'000; - static constexpr std::int64_t DEPOSIT_AMOUNT = 5'000; - static constexpr std::int64_t PRINCIPAL_AMOUNT = 99; - static constexpr std::uint64_t EXPECTED_SHARES_PER_DEPOSITOR = 5'000'000'000; - static constexpr std::uint32_t PAYMENT_INTERVAL = 600; - static constexpr std::uint32_t PAYMENT_TOTAL = 2; + static constexpr std::int64_t kINITIAL_FUNDING = 1'000'000; + static constexpr std::int64_t kLENDER_INITIAL_IOU = 5'000'000; + static constexpr std::int64_t kDEPOSITOR_INITIAL_IOU = 1'000'000; + static constexpr std::int64_t kBORROWER_INITIAL_IOU = 100'000; + static constexpr std::int64_t kDEPOSIT_AMOUNT = 5'000; + static constexpr std::int64_t kPRINCIPAL_AMOUNT = 99; + static constexpr std::uint64_t kEXPECTED_SHARES_PER_DEPOSITOR = 5'000'000'000; + static constexpr std::uint32_t kLOCAL_PAYMENT_INTERVAL = 600; + static constexpr std::uint32_t kLOCAL_PAYMENT_TOTAL = 2; - Env env(*this, all); + Env env(*this, all_); // Setup accounts Account const issuer{"issuer"}; @@ -7107,11 +7116,11 @@ protected: Account const depositorB{"lpB"}; Account const borrower{"borrowerA"}; - env.fund(XRP(INITIAL_FUNDING), issuer, lender, depositorA, depositorB, borrower); + env.fund(XRP(kINITIAL_FUNDING), issuer, lender, depositorA, depositorB, borrower); env.close(); // Setup trust lines - PrettyAsset const iouAsset = issuer[iouCurrency]; + PrettyAsset const iouAsset = issuer[iouCurrency_]; env(trust(lender, iouAsset(10'000'000))); env(trust(depositorA, iouAsset(10'000'000))); env(trust(depositorB, iouAsset(10'000'000))); @@ -7119,10 +7128,10 @@ protected: env.close(); // Fund accounts with IOUs - env(pay(issuer, lender, iouAsset(LENDER_INITIAL_IOU))); - env(pay(issuer, depositorA, iouAsset(DEPOSITOR_INITIAL_IOU))); - env(pay(issuer, depositorB, iouAsset(DEPOSITOR_INITIAL_IOU))); - env(pay(issuer, borrower, iouAsset(BORROWER_INITIAL_IOU))); + env(pay(issuer, lender, iouAsset(kLENDER_INITIAL_IOU))); + env(pay(issuer, depositorA, iouAsset(kDEPOSITOR_INITIAL_IOU))); + env(pay(issuer, depositorB, iouAsset(kDEPOSITOR_INITIAL_IOU))); + env(pay(issuer, borrower, iouAsset(kBORROWER_INITIAL_IOU))); env.close(); // Create vault and broker, then add deposits from two depositors @@ -7132,15 +7141,15 @@ protected: env(v.deposit({ .depositor = depositorA, .id = broker.vaultKeylet().key, - .amount = iouAsset(DEPOSIT_AMOUNT), + .amount = iouAsset(kDEPOSIT_AMOUNT), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env(v.deposit({ .depositor = depositorB, .id = broker.vaultKeylet().key, - .amount = iouAsset(DEPOSIT_AMOUNT), + .amount = iouAsset(kDEPOSIT_AMOUNT), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); // Create a loan @@ -7150,16 +7159,16 @@ protected: auto const loanKeylet = keylet::loan(broker.brokerID, sleBroker->at(sfLoanSequence)); - env(set(borrower, broker.brokerID, PRINCIPAL_AMOUNT), - sig(sfCounterpartySignature, lender), - paymentTotal(PAYMENT_TOTAL), - paymentInterval(PAYMENT_INTERVAL), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + env(set(borrower, broker.brokerID, kPRINCIPAL_AMOUNT), + Sig(sfCounterpartySignature, lender), + kPAYMENT_TOTAL(kLOCAL_PAYMENT_TOTAL), + kPAYMENT_INTERVAL(kLOCAL_PAYMENT_INTERVAL), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); // Impair the loan to create unrealized loss - env(manage(lender, loanKeylet.key, tfLoanImpair), ter(tesSUCCESS)); + env(manage(lender, loanKeylet.key, tfLoanImpair), Ter(tesSUCCESS)); env.close(); // Verify unrealized loss is recorded in the vault @@ -7168,7 +7177,7 @@ protected: return; BEAST_EXPECT( - vaultAfterImpair->at(sfLossUnrealized) == broker.asset(PRINCIPAL_AMOUNT).value()); + vaultAfterImpair->at(sfLossUnrealized) == broker.asset(kPRINCIPAL_AMOUNT).value()); // Helper to get share balance for a depositor auto const shareAsset = vaultAfterImpair->at(sfShareMPTID); @@ -7180,8 +7189,8 @@ protected: // Verify both depositors have equal shares auto const sharesLpA = getShareBalance(depositorA); auto const sharesLpB = getShareBalance(depositorB); - BEAST_EXPECT(sharesLpA == EXPECTED_SHARES_PER_DEPOSITOR); - BEAST_EXPECT(sharesLpB == EXPECTED_SHARES_PER_DEPOSITOR); + BEAST_EXPECT(sharesLpA == kEXPECTED_SHARES_PER_DEPOSITOR); + BEAST_EXPECT(sharesLpB == kEXPECTED_SHARES_PER_DEPOSITOR); BEAST_EXPECT(sharesLpA == sharesLpB); // Helper to attempt withdrawal @@ -7191,7 +7200,7 @@ protected: STAmount const shareAmt{MPTIssue{shareAsset}, Number(shareAmount)}; env(v.withdraw( {.depositor = depositor, .id = broker.vaultKeylet().key, .amount = shareAmt}), - ter(expected)); + Ter(expected)); env.close(); }; @@ -7216,10 +7225,10 @@ public: testWithdrawReflectsUnrealizedLoss(); testInvalidLoanSet(); - auto const all = jtx::testable_amendments(); + auto const all = jtx::testableAmendments(); testCoverDepositWithdrawNonTransferableMPT(all); testCoverDepositWithdrawNonTransferableMPT(all - featureMPTokensV2); - testPoC_UnsignedUnderflowOnFullPayAfterEarlyPeriodic(); + testPoCUnsignedUnderflowOnFullPayAfterEarlyPeriodic(); testDisabled(); testSelfLoan(); @@ -7269,13 +7278,13 @@ class LoanBatch_test : public Loan_test protected: beast::xor_shift_engine engine_; - std::uniform_int_distribution<> assetDist{0, 2}; - std::uniform_int_distribution principalDist{100'000, 1'000'000'000}; - std::uniform_int_distribution interestRateDist{0, 10000}; - std::uniform_int_distribution<> paymentTotalDist{12, 10000}; - std::uniform_int_distribution<> paymentIntervalDist{60, 3600 * 24 * 30}; - std::uniform_int_distribution managementFeeRateDist{0, 10'000}; - std::uniform_int_distribution<> serviceFeeDist{0, 20}; + std::uniform_int_distribution<> assetDist_{0, 2}; + std::uniform_int_distribution principalDist_{100'000, 1'000'000'000}; + std::uniform_int_distribution interestRateDist_{0, 10000}; + std::uniform_int_distribution<> paymentTotalDist_{12, 10000}; + std::uniform_int_distribution<> paymentIntervalDist_{60, 3600 * 24 * 30}; + std::uniform_int_distribution managementFeeRateDist_{0, 10'000}; + std::uniform_int_distribution<> serviceFeeDist_{0, 20}; /* # Generate parameters that are more likely to be valid principal = Decimal(str(rand.randint(100000, @@ -7302,13 +7311,13 @@ protected: Account const borrower("borrower"); // Determine all the random parameters at once - AssetType const assetType = static_cast(assetDist(engine_)); - auto const principalRequest = principalDist(engine_); - TenthBips16 const managementFeeRate{managementFeeRateDist(engine_)}; - auto const serviceFee = serviceFeeDist(engine_); - TenthBips32 interest{interestRateDist(engine_)}; - auto const payTotal = paymentTotalDist(engine_); - auto const payInterval = paymentIntervalDist(engine_); + AssetType const assetType = static_cast(assetDist_(engine_)); + auto const principalRequest = principalDist_(engine_); + TenthBips16 const managementFeeRate{managementFeeRateDist_(engine_)}; + auto const serviceFee = serviceFeeDist_(engine_); + TenthBips32 interest{interestRateDist_(engine_)}; + auto const payTotal = paymentTotalDist_(engine_); + auto const payInterval = paymentIntervalDist_(engine_); BrokerParameters const brokerParams{ .vaultDeposit = principalRequest * 10, diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 681d2f2577..a9c36d93d2 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +68,7 @@ namespace xrpl::test { -class MPToken_test : public beast::unit_test::suite +class MPToken_test : public beast::unit_test::Suite { void testCreateValidation(FeatureBitset features) @@ -94,7 +94,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.create({.flags = 0x00000001, .err = temINVALID_FLAG}); - // tries to set a txfee while not enabling in the flag + // tries to set a txFee while not enabling in the flag mptAlice.create( {.maxAmt = 100, .assetScale = 0, @@ -140,24 +140,24 @@ class MPToken_test : public beast::unit_test::suite .assetScale = 0, .metadata = "test", .flags = tfMPTRequireAuth, - .domainID = beast::zero, + .domainID = uint256{}, .err = temMALFORMED}); } - // tries to set a txfee greater than max + // tries to set a txFee greater than max mptAlice.create( {.maxAmt = 100, .assetScale = 0, - .transferFee = maxTransferFee + 1, + .transferFee = kMAX_TRANSFER_FEE + 1, .metadata = "test", .flags = tfMPTCanTransfer, .err = temBAD_TRANSFER_FEE}); - // tries to set a txfee while not enabling transfer + // tries to set a txFee while not enabling transfer mptAlice.create( {.maxAmt = 100, .assetScale = 0, - .transferFee = maxTransferFee, + .transferFee = kMAX_TRANSFER_FEE, .metadata = "test", .err = temMALFORMED}); @@ -185,7 +185,7 @@ class MPToken_test : public beast::unit_test::suite .metadata = "test", .err = temMALFORMED}); mptAlice.create( - {.maxAmt = maxMPTokenAmount + 1, // 9'223'372'036'854'775'808 + {.maxAmt = kMAX_MP_TOKEN_AMOUNT + 1, // 9'223'372'036'854'775'808 .assetScale = 0, .transferFee = 0, .metadata = "test", @@ -207,7 +207,7 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; MPTTester mptAlice(env, alice); mptAlice.create( - {.maxAmt = maxMPTokenAmount, // 9'223'372'036'854'775'807 + {.maxAmt = kMAX_MP_TOKEN_AMOUNT, // 9'223'372'036'854'775'807 .assetScale = 1, .transferFee = 10, .metadata = "123", @@ -216,9 +216,9 @@ class MPToken_test : public beast::unit_test::suite tfMPTCanTransfer | tfMPTCanClawback}); // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; - Json::Value const result = env.rpc("tx", txHash)[jss::result]; + json::Value const result = env.rpc("tx", txHash)[jss::result]; BEAST_EXPECT(result[sfMaximumAmount.getJsonName()] == "9223372036854775807"); } @@ -236,13 +236,13 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer1, credentials1)); auto const domainId1 = [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); MPTTester mptAlice(env, alice); mptAlice.create({ - .maxAmt = maxMPTokenAmount, // 9'223'372'036'854'775'807 + .maxAmt = kMAX_MP_TOKEN_AMOUNT, // 9'223'372'036'854'775'807 .assetScale = 1, .transferFee = 10, .metadata = "123", @@ -254,9 +254,9 @@ class MPToken_test : public beast::unit_test::suite // Get the hash for the most recent transaction. std::string const txHash{ - env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; - Json::Value const result = env.rpc("tx", txHash)[jss::result]; + json::Value const result = env.rpc("tx", txHash)[jss::result]; BEAST_EXPECT(result[sfMaximumAmount.getJsonName()] == "9223372036854775807"); } } @@ -708,7 +708,7 @@ class MPToken_test : public beast::unit_test::suite // Trying to set DomainID on a public MPTokenIssuance mptAlice.set({.domainID = uint256(42), .err = tecNO_PERMISSION}); - mptAlice.set({.domainID = beast::zero, .err = tecNO_PERMISSION}); + mptAlice.set({.domainID = uint256{}, .err = tecNO_PERMISSION}); } { @@ -725,7 +725,7 @@ class MPToken_test : public beast::unit_test::suite {.flags = tfMPTUnlock, .domainID = uint256(42), .err = tecNO_PERMISSION}); mptAlice.set( - {.flags = tfMPTUnlock, .domainID = beast::zero, .err = tecNO_PERMISSION}); + {.flags = tfMPTUnlock, .domainID = uint256{}, .err = tecNO_PERMISSION}); } } } @@ -818,7 +818,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer1, credentials1)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -832,7 +832,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer2, credentials2)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -844,7 +844,7 @@ class MPToken_test : public beast::unit_test::suite BEAST_EXPECT(mptAlice.checkDomainID(std::nullopt)); // reset "domain not set" to "domain not set", i.e. no change - mptAlice.set({.domainID = beast::zero}); + mptAlice.set({.domainID = uint256{}}); BEAST_EXPECT(mptAlice.checkDomainID(std::nullopt)); // reset "domain not set" to domain1 @@ -856,7 +856,7 @@ class MPToken_test : public beast::unit_test::suite BEAST_EXPECT(mptAlice.checkDomainID(domainId2)); // reset domain to "domain not set" - mptAlice.set({.domainID = beast::zero}); + mptAlice.set({.domainID = uint256{}}); BEAST_EXPECT(mptAlice.checkDomainID(std::nullopt)); } } @@ -870,13 +870,13 @@ class MPToken_test : public beast::unit_test::suite Account const alice("alice"); // issuer Account const bob("bob"); // holder Account const carol("carol"); // holder - auto const MPTokensV2 = features[featureMPTokensV2]; + auto const mpTokensV2 = features[featureMPTokensV2]; // preflight validation // MPT is disabled { - Env env{*this, features - featureMPTokensV1}; + Env env{*this, features - featureMPTokensV1}; // NOLINT TODO Account const alice("alice"); Account const bob("bob"); @@ -884,7 +884,7 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), bob); STAmount const mpt{MPTIssue{makeMptID(1, alice)}, UINT64_C(100)}; - env(pay(alice, bob, mpt), ter(temDISABLED)); + env(pay(alice, bob, mpt), Ter(temDISABLED)); } // MPT is disabled, unsigned request @@ -892,13 +892,13 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features - featureMPTokensV1}; Account const alice("alice"); // issuer Account const carol("carol"); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; env.fund(XRP(1'000), alice); env.fund(XRP(1'000), carol); STAmount const mpt{MPTIssue{makeMptID(1, alice)}, UINT64_C(100)}; - Json::Value jv; + json::Value jv; jv[jss::secret] = alice.name(); jv[jss::tx_json] = pay(alice, carol, mpt); jv[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); @@ -913,14 +913,14 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {bob}}); mptAlice.create({.ownerCount = 1, .holderCount = 0}); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; mptAlice.authorize({.account = bob}); - auto err = !features[featureMPTokensV2] ? ter(temINVALID_FLAG) : ter(temRIPPLE_EMPTY); - env(pay(alice, bob, MPT(10)), txflags(tfNoRippleDirect), err); - err = !features[featureMPTokensV2] ? ter(temINVALID_FLAG) : ter(tesSUCCESS); - env(pay(alice, bob, MPT(10)), txflags(tfLimitQuality), err); + auto err = !features[featureMPTokensV2] ? Ter(temINVALID_FLAG) : Ter(temRIPPLE_EMPTY); + env(pay(alice, bob, mpt(10)), Txflags(tfNoRippleDirect), err); + err = !features[featureMPTokensV2] ? Ter(temINVALID_FLAG) : Ter(tesSUCCESS); + env(pay(alice, bob, mpt(10)), Txflags(tfLimitQuality), err); } // Invalid combination of send, sendMax, deliverMin, paths @@ -938,25 +938,25 @@ class MPToken_test : public beast::unit_test::suite // sendMax and DeliverMin are valid XRP amount, // but is invalid combination with MPT amount - auto const MPT = mptAlice["MPT"]; - auto err = !MPTokensV2 ? ter(temMALFORMED) : ter(tecPATH_PARTIAL); - env(pay(alice, carol, MPT(100)), sendmax(XRP(100)), err); - env(pay(alice, carol, MPT(100)), deliver_min(XRP(100)), ter(temBAD_AMOUNT)); + auto const mpt = mptAlice["MPT"]; + auto err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tecPATH_PARTIAL); + env(pay(alice, carol, mpt(100)), Sendmax(XRP(100)), err); + env(pay(alice, carol, mpt(100)), DeliverMin(XRP(100)), Ter(temBAD_AMOUNT)); // sendMax MPT is invalid with IOU or XRP - auto const USD = alice["USD"]; - err = !MPTokensV2 ? ter(temMALFORMED) : ter(tecPATH_DRY); - env(pay(alice, carol, USD(100)), sendmax(MPT(100)), err); - err = !MPTokensV2 ? ter(temMALFORMED) : ter(tecPATH_PARTIAL); - env(pay(alice, carol, XRP(100)), sendmax(MPT(100)), err); - env(pay(alice, carol, USD(100)), deliver_min(MPT(100)), ter(temBAD_AMOUNT)); - env(pay(alice, carol, XRP(100)), deliver_min(MPT(100)), ter(temBAD_AMOUNT)); + auto const usd = alice["USD"]; + err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tecPATH_DRY); + env(pay(alice, carol, usd(100)), Sendmax(mpt(100)), err); + err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tecPATH_PARTIAL); + env(pay(alice, carol, XRP(100)), Sendmax(mpt(100)), err); + env(pay(alice, carol, usd(100)), DeliverMin(mpt(100)), Ter(temBAD_AMOUNT)); + env(pay(alice, carol, XRP(100)), DeliverMin(mpt(100)), Ter(temBAD_AMOUNT)); // sendmax and amount are different MPT issue - test::jtx::MPT const MPT1("MPT", makeMptID(env.seq(alice) + 10, alice)); - err = !MPTokensV2 ? ter(temMALFORMED) : ter(tecOBJECT_NOT_FOUND); - env(pay(alice, carol, MPT1(100)), sendmax(MPT(100)), err); + test::jtx::MPT const mpT1("MPT", makeMptID(env.seq(alice) + 10, alice)); + err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tecOBJECT_NOT_FOUND); + env(pay(alice, carol, mpT1(100)), Sendmax(mpt(100)), err); // "paths" is invalid in V1 - err = !MPTokensV2 ? ter(temMALFORMED) : ter(tesSUCCESS); - env(pay(alice, carol, MPT(100)), path(~USD), err); + err = !mpTokensV2 ? Ter(temMALFORMED) : Ter(tesSUCCESS); + env(pay(alice, carol, mpt(100)), Path(~usd), err); } // build_path is invalid if MPT @@ -968,13 +968,13 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {bob, carol}}); mptAlice.create({.ownerCount = 1, .holderCount = 0}); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; mptAlice.authorize({.account = carol}); - Json::Value payment; + json::Value payment; payment[jss::secret] = alice.name(); - payment[jss::tx_json] = pay(alice, carol, MPT(100)); + payment[jss::tx_json] = pay(alice, carol, mpt(100)); payment[jss::build_path] = true; auto jrr = env.rpc("json", "submit", to_string(payment)); @@ -991,7 +991,7 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {bob, carol}}); mptAlice.create({.ownerCount = 1, .holderCount = 0}); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; mptAlice.authorize({.account = bob}); mptAlice.authorize({.account = carol}); @@ -1002,7 +1002,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.pay(bob, alice, -1, temBAD_AMOUNT); - env(pay(alice, bob, MPT(10)), sendmax(MPT(-1)), ter(temBAD_AMOUNT)); + env(pay(alice, bob, mpt(10)), Sendmax(mpt(-1)), Ter(temBAD_AMOUNT)); } // Pay to self @@ -1095,7 +1095,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer1, credentials1)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -1119,7 +1119,7 @@ class MPToken_test : public beast::unit_test::suite // bob is authorized via domain mptAlice.pay(alice, bob, 100); - mptAlice.set({.domainID = beast::zero}); + mptAlice.set({.domainID = uint256{}}); // bob is no longer authorized mptAlice.pay(alice, bob, 100, tecNO_AUTH); @@ -1137,7 +1137,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer1, credentials1)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -1171,7 +1171,7 @@ class MPToken_test : public beast::unit_test::suite // bob is still authorized, via domain mptAlice.pay(bob, alice, 10); - mptAlice.set({.domainID = beast::zero}); + mptAlice.set({.domainID = uint256{}}); // bob fails to send back to alice because he is no longer // authorize to move his funds! @@ -1194,7 +1194,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer1, credentials)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -1206,7 +1206,7 @@ class MPToken_test : public beast::unit_test::suite env(pdomain::setTx(credIssuer2, credentials)); return [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); }(); @@ -1408,22 +1408,22 @@ class MPToken_test : public beast::unit_test::suite // but SendMax is not included. mptAlice.pay(bob, carol, 100, tecPATH_PARTIAL); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; // SendMax doesn't cover the fee - env(pay(bob, carol, MPT(100)), sendmax(MPT(109)), ter(tecPATH_PARTIAL)); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(109)), Ter(tecPATH_PARTIAL)); // Payment succeeds if sufficient SendMax is included. // 100 to carol, 10 to issuer - env(pay(bob, carol, MPT(100)), sendmax(MPT(110))); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(110))); // 100 to carol, 10 to issuer - env(pay(bob, carol, MPT(100)), sendmax(MPT(115))); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(115))); BEAST_EXPECT(mptAlice.checkMPTokenAmount(bob, 780)); BEAST_EXPECT(mptAlice.checkMPTokenAmount(carol, 200)); // Payment succeeds if partial payment even if // SendMax is less than deliver amount - env(pay(bob, carol, MPT(100)), sendmax(MPT(90)), txflags(tfPartialPayment)); - // 82 to carol, 8 to issuer (90 / 1.1 ~ 81.81 (rounded to nearest in - // v1) = 82) + env(pay(bob, carol, mpt(100)), Sendmax(mpt(90)), Txflags(tfPartialPayment)); + // 82 to carol, 8 to issuer (90 / 1.1 ~ 81.81 (rounded to nearest) = + // 82) BEAST_EXPECT(mptAlice.checkMPTokenAmount(bob, 690)); // In V2 the payments are executed via the payment engine and // the rounding results in a higher quality trade @@ -1444,16 +1444,16 @@ class MPToken_test : public beast::unit_test::suite mptAlice.authorize({.account = carol}); mptAlice.pay(alice, bob, 1'000); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; // SendMax is less than the amount - env(pay(bob, carol, MPT(100)), sendmax(MPT(99)), ter(tecPATH_PARTIAL)); - env(pay(bob, alice, MPT(100)), sendmax(MPT(99)), ter(tecPATH_PARTIAL)); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(99)), Ter(tecPATH_PARTIAL)); + env(pay(bob, alice, mpt(100)), Sendmax(mpt(99)), Ter(tecPATH_PARTIAL)); // Payment succeeds if sufficient SendMax is included. - env(pay(bob, carol, MPT(100)), sendmax(MPT(100))); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(100))); BEAST_EXPECT(mptAlice.checkMPTokenAmount(carol, 100)); // Payment succeeds if partial payment - env(pay(bob, carol, MPT(100)), sendmax(MPT(99)), txflags(tfPartialPayment)); + env(pay(bob, carol, mpt(100)), Sendmax(mpt(99)), Txflags(tfPartialPayment)); BEAST_EXPECT(mptAlice.checkMPTokenAmount(carol, 199)); } @@ -1470,19 +1470,19 @@ class MPToken_test : public beast::unit_test::suite mptAlice.authorize({.account = carol}); mptAlice.pay(alice, bob, 1'000); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; // Fails even with the partial payment because // deliver amount < deliverMin - env(pay(bob, alice, MPT(100)), - sendmax(MPT(99)), - deliver_min(MPT(100)), - txflags(tfPartialPayment), - ter(tecPATH_PARTIAL)); + env(pay(bob, alice, mpt(100)), + Sendmax(mpt(99)), + DeliverMin(mpt(100)), + Txflags(tfPartialPayment), + Ter(tecPATH_PARTIAL)); // Payment succeeds if deliver amount >= deliverMin - env(pay(bob, alice, MPT(100)), - sendmax(MPT(99)), - deliver_min(MPT(99)), - txflags(tfPartialPayment)); + env(pay(bob, alice, mpt(100)), + Sendmax(mpt(99)), + DeliverMin(mpt(99)), + Txflags(tfPartialPayment)); } // Issuer fails trying to send more than the maximum amount allowed @@ -1500,7 +1500,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.pay(alice, bob, 100); // issuer tries to exceed max amount - auto const err = MPTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; + auto const err = mpTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; mptAlice.pay(alice, bob, 1, err); } @@ -1516,10 +1516,10 @@ class MPToken_test : public beast::unit_test::suite mptAlice.authorize({.account = bob}); // issuer sends holder the default max amount allowed - mptAlice.pay(alice, bob, maxMPTokenAmount); + mptAlice.pay(alice, bob, kMAX_MP_TOKEN_AMOUNT); // issuer tries to exceed max amount - auto const err = MPTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; + auto const err = mpTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; mptAlice.pay(alice, bob, 1, err); } @@ -1529,10 +1529,10 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), alice, bob); STAmount const mpt{MPTIssue{makeMptID(1, alice)}, UINT64_C(100)}; - Json::Value jv; + json::Value jv; jv[jss::secret] = alice.name(); jv[jss::tx_json] = pay(alice, bob, mpt); - jv[jss::tx_json][jss::Amount][jss::value] = std::to_string(maxMPTokenAmount + 1); + jv[jss::tx_json][jss::Amount][jss::value] = std::to_string(kMAX_MP_TOKEN_AMOUNT + 1); auto const jrr = env.rpc("json", "submit", to_string(jv)); BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams"); } @@ -1550,7 +1550,7 @@ class MPToken_test : public beast::unit_test::suite .ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; mptAlice.authorize({.account = bob}); mptAlice.authorize({.account = carol}); @@ -1559,10 +1559,9 @@ class MPToken_test : public beast::unit_test::suite mptAlice.pay(alice, bob, 10'000); // payment between the holders - env(pay(bob, carol, MPT(10'000)), sendmax(MPT(10'000)), txflags(tfPartialPayment)); - + env(pay(bob, carol, mpt(10'000)), Sendmax(mpt(10'000)), Txflags(tfPartialPayment)); // Verify the metadata - auto const meta = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; + auto const meta = env.meta()->getJson(JsonOptions::KNone)[sfAffectedNodes.fieldName]; // Issuer got 10 in the transfer fees BEAST_EXPECT( meta[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName] @@ -1580,8 +1579,8 @@ class MPToken_test : public beast::unit_test::suite // payment between the holders fails without // partial payment - auto const err = MPTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; - env(pay(bob, carol, MPT(10'000)), sendmax(MPT(10'000)), ter(err)); + auto const err = mpTokensV2 ? tecPATH_DRY : tecPATH_PARTIAL; + env(pay(bob, carol, mpt(10'000)), Sendmax(mpt(10'000)), Ter(err)); } // Pay maximum allowed amount @@ -1591,24 +1590,24 @@ class MPToken_test : public beast::unit_test::suite MPTTester mptAlice(env, alice, {.holders = {bob, carol}}); mptAlice.create( - {.maxAmt = maxMPTokenAmount, + {.maxAmt = kMAX_MP_TOKEN_AMOUNT, .ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); - auto const MPT = mptAlice["MPT"]; + auto const mpt = mptAlice["MPT"]; mptAlice.authorize({.account = bob}); mptAlice.authorize({.account = carol}); // issuer sends holder the max amount allowed - mptAlice.pay(alice, bob, maxMPTokenAmount); - BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(maxMPTokenAmount)); + mptAlice.pay(alice, bob, kMAX_MP_TOKEN_AMOUNT); + BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(kMAX_MP_TOKEN_AMOUNT)); // payment between the holders - mptAlice.pay(bob, carol, maxMPTokenAmount); - BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(maxMPTokenAmount)); + mptAlice.pay(bob, carol, kMAX_MP_TOKEN_AMOUNT); + BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(kMAX_MP_TOKEN_AMOUNT)); // holder pays back to the issuer - mptAlice.pay(carol, alice, maxMPTokenAmount); + mptAlice.pay(carol, alice, kMAX_MP_TOKEN_AMOUNT); BEAST_EXPECT(mptAlice.checkMPTokenOutstandingAmount(0)); } @@ -1632,13 +1631,13 @@ class MPToken_test : public beast::unit_test::suite // Non-existent issuance { - Env env{*this, features}; + Env env{*this, features}; // NOLINT TODO env.fund(XRP(1'000), alice, bob); STAmount const mpt{MPTID{0}, 100}; auto const err = - !features[featureMPTokensV2] ? ter(tecOBJECT_NOT_FOUND) : ter(temBAD_CURRENCY); + !features[featureMPTokensV2] ? Ter(tecOBJECT_NOT_FOUND) : Ter(temBAD_CURRENCY); env(pay(alice, bob, mpt), err); } @@ -1790,7 +1789,7 @@ class MPToken_test : public beast::unit_test::suite testcase("DepositPreauth disabled featureCredentials"); { - Env env(*this, testable_amendments() - featureCredentials); + Env env(*this, testableAmendments() - featureCredentials); std::string const credIdx = "D007AE4B6E1274B4AF872588267B810C2F82716726351D1C7D38D3E5499FC6" @@ -1868,8 +1867,8 @@ class MPToken_test : public beast::unit_test::suite // Transaction has amount/issue fields. // Exclude pseudo-transaction SetFee. Don't consider // the Fee field since it's included in every transaction. - if (e.supportMPT() == soeMPTNotSupported && e.sField().getName() != jss::Fee && - format.getName() != jss::SetFee) + if (e.supportMPT() == SoeMptNotSupported && e.sField().getName() != jss::Fee && + format.getName() != std::string("SetFee")) { txWithAmounts.insert(format.getName() + e.sField().fieldName); break; @@ -1878,17 +1877,17 @@ class MPToken_test : public beast::unit_test::suite } Account const alice("alice"); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; Account const carol("carol"); MPTIssue const issue(makeMptID(1, alice)); STAmount mpt{issue, UINT64_C(100)}; - auto const jvb = bridge(alice, USD, alice, USD); + auto const jvb = bridge(alice, usd, alice, usd); for (auto const& feature : {features, features - featureMPTokensV1}) { Env env{*this, feature}; env.fund(XRP(1'000), alice); env.fund(XRP(1'000), carol); - auto test = [&](Json::Value const& jv, std::string const& mptField) { + auto test = [&](json::Value const& jv, std::string const& mptField) { txWithAmounts.erase(jv[jss::TransactionType].asString() + mptField); // tx is signed @@ -1899,7 +1898,7 @@ class MPToken_test : public beast::unit_test::suite BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidTransaction"); // tx is unsigned - Json::Value jv1; + json::Value jv1; jv1[jss::secret] = alice.name(); jv1[jss::tx_json] = jv; jrr = env.rpc("json", "submit", to_string(jv1)); @@ -1908,22 +1907,22 @@ class MPToken_test : public beast::unit_test::suite jrr = env.rpc("json", "sign", to_string(jv1)); BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams"); }; - auto setMPTFields = [&](SField const& field, Json::Value& jv, bool withAmount = true) { - jv[jss::Asset] = to_json(xrpIssue()); - jv[jss::Asset2] = to_json(USD.issue()); + auto setMPTFields = [&](SField const& field, json::Value& jv, bool withAmount = true) { + jv[jss::Asset] = toJson(xrpIssue()); + jv[jss::Asset2] = toJson(usd.issue()); if (withAmount) - jv[field.fieldName] = USD(10).value().getJson(JsonOptions::none); + jv[field.fieldName] = usd(10).value().getJson(JsonOptions::KNone); if (field == sfAsset) { - jv[jss::Asset] = to_json(mpt.get()); + jv[jss::Asset] = toJson(mpt.get()); } else if (field == sfAsset2) { - jv[jss::Asset2] = to_json(mpt.get()); + jv[jss::Asset2] = toJson(mpt.get()); } else { - jv[field.fieldName] = mpt.getJson(JsonOptions::none); + jv[field.fieldName] = mpt.getJson(JsonOptions::KNone); } }; // All transactions with sfAmount, which don't support MPT. @@ -1932,7 +1931,7 @@ class MPToken_test : public beast::unit_test::suite // AMMDeposit auto ammDeposit = [&](SField const& field) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::AMMDeposit; jv[jss::Account] = alice.human(); jv[jss::Flags] = tfSingleAsset; @@ -1943,7 +1942,7 @@ class MPToken_test : public beast::unit_test::suite ammDeposit(field); // AMMWithdraw auto ammWithdraw = [&](SField const& field) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::AMMWithdraw; jv[jss::Account] = alice.human(); jv[jss::Flags] = tfSingleAsset; @@ -1954,7 +1953,7 @@ class MPToken_test : public beast::unit_test::suite ammWithdraw(field); // AMMBid auto ammBid = [&](SField const& field) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::AMMBid; jv[jss::Account] = alice.human(); setMPTFields(field, jv); @@ -1964,132 +1963,132 @@ class MPToken_test : public beast::unit_test::suite ammBid(sfBidMax); // PaymentChannelCreate { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::PaymentChannelCreate; jv[jss::Account] = alice.human(); jv[jss::Destination] = carol.human(); jv[jss::SettleDelay] = 1; jv[sfPublicKey.fieldName] = strHex(alice.pk().slice()); - jv[jss::Amount] = mpt.getJson(JsonOptions::none); - test(jv, jss::Amount.c_str()); + jv[jss::Amount] = mpt.getJson(JsonOptions::KNone); + test(jv, jss::Amount.cStr()); } // PaymentChannelFund { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::PaymentChannelFund; jv[jss::Account] = alice.human(); jv[sfChannel.fieldName] = to_string(uint256{1}); - jv[jss::Amount] = mpt.getJson(JsonOptions::none); - test(jv, jss::Amount.c_str()); + jv[jss::Amount] = mpt.getJson(JsonOptions::KNone); + test(jv, jss::Amount.cStr()); } // PaymentChannelClaim { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::PaymentChannelClaim; jv[jss::Account] = alice.human(); jv[sfChannel.fieldName] = to_string(uint256{1}); - jv[jss::Amount] = mpt.getJson(JsonOptions::none); - test(jv, jss::Amount.c_str()); + jv[jss::Amount] = mpt.getJson(JsonOptions::KNone); + test(jv, jss::Amount.cStr()); } // NFTokenCreateOffer { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::NFTokenCreateOffer; jv[jss::Account] = alice.human(); jv[sfNFTokenID.fieldName] = to_string(uint256{1}); - jv[jss::Amount] = mpt.getJson(JsonOptions::none); - test(jv, jss::Amount.c_str()); + jv[jss::Amount] = mpt.getJson(JsonOptions::KNone); + test(jv, jss::Amount.cStr()); } // NFTokenAcceptOffer { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::NFTokenAcceptOffer; jv[jss::Account] = alice.human(); - jv[sfNFTokenBrokerFee.fieldName] = mpt.getJson(JsonOptions::none); + jv[sfNFTokenBrokerFee.fieldName] = mpt.getJson(JsonOptions::KNone); test(jv, sfNFTokenBrokerFee.fieldName); } // NFTokenMint { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::NFTokenMint; jv[jss::Account] = alice.human(); jv[sfNFTokenTaxon.fieldName] = 1; - jv[jss::Amount] = mpt.getJson(JsonOptions::none); - test(jv, jss::Amount.c_str()); + jv[jss::Amount] = mpt.getJson(JsonOptions::KNone); + test(jv, jss::Amount.cStr()); } // TrustSet auto trustSet = [&](SField const& field) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = jss::TrustSet; jv[jss::Account] = alice.human(); jv[jss::Flags] = 0; - jv[field.fieldName] = mpt.getJson(JsonOptions::none); + jv[field.fieldName] = mpt.getJson(JsonOptions::KNone); test(jv, field.fieldName); }; trustSet(sfLimitAmount); trustSet(sfFee); // XChainCommit { - Json::Value const jv = xchain_commit(alice, jvb, 1, mpt); - test(jv, jss::Amount.c_str()); + json::Value const jv = xchainCommit(alice, jvb, 1, mpt); + test(jv, jss::Amount.cStr()); } // XChainClaim { - Json::Value const jv = xchain_claim(alice, jvb, 1, mpt, alice); - test(jv, jss::Amount.c_str()); + json::Value const jv = xchainClaim(alice, jvb, 1, mpt, alice); + test(jv, jss::Amount.cStr()); } // XChainCreateClaimID { - Json::Value const jv = xchain_create_claim_id(alice, jvb, mpt, alice); + json::Value const jv = xchainCreateClaimId(alice, jvb, mpt, alice); test(jv, sfSignatureReward.fieldName); } // XChainAddClaimAttestation { - Json::Value const jv = - claim_attestation(alice, jvb, alice, mpt, alice, true, 1, alice, signer(alice)); - test(jv, jss::Amount.c_str()); + json::Value const jv = + claimAttestation(alice, jvb, alice, mpt, alice, true, 1, alice, Signer(alice)); + test(jv, jss::Amount.cStr()); } // XChainAddAccountCreateAttestation { - Json::Value jv = create_account_attestation( - alice, jvb, alice, mpt, XRP(10), alice, false, 1, alice, signer(alice)); + json::Value jv = createAccountAttestation( + alice, jvb, alice, mpt, XRP(10), alice, false, 1, alice, Signer(alice)); for (auto const& field : {sfAmount.fieldName, sfSignatureReward.fieldName}) { - jv[field] = mpt.getJson(JsonOptions::none); + jv[field] = mpt.getJson(JsonOptions::KNone); test(jv, field); } } // XChainAccountCreateCommit { - Json::Value jv = sidechain_xchain_account_create(alice, jvb, alice, mpt, XRP(10)); + json::Value jv = sidechainXchainAccountCreate(alice, jvb, alice, mpt, XRP(10)); for (auto const& field : {sfAmount.fieldName, sfSignatureReward.fieldName}) { - jv[field] = mpt.getJson(JsonOptions::none); + jv[field] = mpt.getJson(JsonOptions::KNone); test(jv, field); } } // XChain[Create|Modify]Bridge - auto bridgeTx = [&](Json::StaticString const& tt, + auto bridgeTx = [&](json::StaticString const& tt, STAmount const& rewardAmount, STAmount const& minAccountAmount, std::string const& field) { - Json::Value jv; + json::Value jv; jv[jss::TransactionType] = tt; jv[jss::Account] = alice.human(); jv[sfXChainBridge.fieldName] = jvb; - jv[sfSignatureReward.fieldName] = rewardAmount.getJson(JsonOptions::none); + jv[sfSignatureReward.fieldName] = rewardAmount.getJson(JsonOptions::KNone); jv[sfMinAccountCreateAmount.fieldName] = - minAccountAmount.getJson(JsonOptions::none); + minAccountAmount.getJson(JsonOptions::KNone); test(jv, field); }; auto reward = STAmount{sfSignatureReward, mpt}; - auto minAmount = STAmount{sfMinAccountCreateAmount, USD(10)}; + auto minAmount = STAmount{sfMinAccountCreateAmount, usd(10)}; for (SField const& field : {std::ref(sfSignatureReward), std::ref(sfMinAccountCreateAmount)}) { bridgeTx(jss::XChainCreateBridge, reward, minAmount, field.fieldName); bridgeTx(jss::XChainModifyBridge, reward, minAmount, field.fieldName); - reward = STAmount{sfSignatureReward, USD(10)}; + reward = STAmount{sfSignatureReward, usd(10)}; minAmount = STAmount{sfMinAccountCreateAmount, mpt}; } } @@ -2113,13 +2112,13 @@ class MPToken_test : public beast::unit_test::suite mptAlice.create(); - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; BEAST_EXPECTS( txHash == "E11F0E0CA14219922B7881F060B9CEE67CFBC87E4049A441ED2AE348FF8FAC" "0E", txHash); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; auto const id = meta[jss::mpt_issuance_id].asString(); // Expect mpt_issuance_id field BEAST_EXPECT(meta.isMember(jss::mpt_issuance_id)); @@ -2142,16 +2141,16 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; auto const mpt = xrpl::test::jtx::MPT(alice.name(), makeMptID(env.seq(alice), alice)); - env(claw(alice, bob["USD"](5), bob), ter(temMALFORMED)); + env(claw(alice, bob["USD"](5), bob), Ter(temMALFORMED)); env.close(); - env(claw(alice, mpt(5)), ter(temDISABLED)); + env(claw(alice, mpt(5)), Ter(temDISABLED)); env.close(); - env(claw(alice, mpt(5), bob), ter(temDISABLED)); + env(claw(alice, mpt(5), bob), Ter(temDISABLED)); env.close(); } @@ -2164,27 +2163,27 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; auto const mpt = xrpl::test::jtx::MPT(alice.name(), makeMptID(env.seq(alice), alice)); // clawing back IOU from a MPT holder fails - env(claw(alice, bob["USD"](5), bob), ter(temMALFORMED)); + env(claw(alice, bob["USD"](5), bob), Ter(temMALFORMED)); env.close(); // clawing back MPT without specifying a holder fails - env(claw(alice, mpt(5)), ter(temMALFORMED)); + env(claw(alice, mpt(5)), Ter(temMALFORMED)); env.close(); // clawing back zero amount fails - env(claw(alice, mpt(0), bob), ter(temBAD_AMOUNT)); + env(claw(alice, mpt(0), bob), Ter(temBAD_AMOUNT)); env.close(); // alice can't claw back from herself - env(claw(alice, mpt(5), alice), ter(temMALFORMED)); + env(claw(alice, mpt(5), alice), Ter(temMALFORMED)); env.close(); // can't clawback negative amount - env(claw(alice, mpt(-1), bob), ter(temBAD_AMOUNT)); + env(claw(alice, mpt(-1), bob), Ter(temBAD_AMOUNT)); env.close(); } @@ -2199,7 +2198,7 @@ class MPToken_test : public beast::unit_test::suite // enable asfAllowTrustLineClawback for alice env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowTrustLineClawback)); + env.require(Flags(alice, asfAllowTrustLineClawback)); // Create issuance without enabling clawback mptAlice.create({.ownerCount = 1, .holderCount = 0}); @@ -2227,7 +2226,7 @@ class MPToken_test : public beast::unit_test::suite xrpl::test::jtx::MPT(alice.name(), makeMptID(env.seq(alice), alice)); // issuer tries to clawback MPT where issuance doesn't exist - env(claw(alice, fakeMpt(5), bob), ter(tecOBJECT_NOT_FOUND)); + env(claw(alice, fakeMpt(5), bob), Ter(tecOBJECT_NOT_FOUND)); env.close(); // alice creates issuance @@ -2263,9 +2262,9 @@ class MPToken_test : public beast::unit_test::suite auto const mpt = xrpl::test::jtx::MPT(alice.name(), makeMptID(env.seq(alice), alice)); - Json::Value jv = claw(alice, mpt(1), bob); - jv[jss::Amount][jss::value] = std::to_string(maxMPTokenAmount + 1); - Json::Value jv1; + json::Value jv = claw(alice, mpt(1), bob); + jv[jss::Amount][jss::value] = std::to_string(kMAX_MP_TOKEN_AMOUNT + 1); + json::Value jv1; jv1[jss::secret] = alice.name(); jv1[jss::tx_json] = jv; auto const jrr = env.rpc("json", "submit", to_string(jv1)); @@ -2382,8 +2381,8 @@ class MPToken_test : public beast::unit_test::suite { using namespace test::jtx; testcase("Tokens Equality"); - Currency const cur1{to_currency("CU1")}; - Currency const cur2{to_currency("CU2")}; + Currency const cur1{toCurrency("CU1")}; + Currency const cur2{toCurrency("CU2")}; Account const gw1{"gw1"}; Account const gw2{"gw2"}; MPTID const mpt1 = makeMptID(1, gw1); @@ -2484,14 +2483,14 @@ class MPToken_test : public beast::unit_test::suite { testcase("Test MPTIssue from/to Json"); MPTIssue const issue1{asset1.get()}; - Json::Value const jv = to_json(issue1); + json::Value const jv = toJson(issue1); BEAST_EXPECT(jv[jss::mpt_issuance_id] == to_string(asset1.get())); BEAST_EXPECT(issue1 == mptIssueFromJson(jv)); } { testcase("Test Asset from/to Json"); - Json::Value const jv = to_json(asset1); + json::Value const jv = toJson(asset1); BEAST_EXPECT(jv[jss::mpt_issuance_id] == to_string(asset1.get())); BEAST_EXPECT( to_string(jv) == @@ -2710,7 +2709,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.create({.ownerCount = 1, .mutableFlags = tmfMPTCanMutateMetadata}); - std::string metadata(maxMPTokenMetadataLength + 1, 'a'); + std::string const metadata(kMAX_MP_TOKEN_METADATA_LENGTH + 1, 'a'); mptAlice.set({.account = alice, .metadata = metadata, .err = temMALFORMED}); } @@ -2734,7 +2733,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.set( {.account = alice, .id = mptID, - .transferFee = maxTransferFee + 1, + .transferFee = kMAX_TRANSFER_FEE + 1, .err = temBAD_TRANSFER_FEE}); } @@ -2888,8 +2887,8 @@ class MPToken_test : public beast::unit_test::suite .flags = tfMPTCanTransfer, .mutableFlags = tmfMPTCanMutateTransferFee}); - for (std::uint16_t const fee : - std::initializer_list{1, 10, 100, 200, 500, 1000, maxTransferFee}) + for (std::uint16_t const fee : std::initializer_list{ + 1, 10, 100, 200, 500, 1000, kMAX_TRANSFER_FEE}) { mptAlice.set({.account = alice, .transferFee = fee}); BEAST_EXPECT(mptAlice.checkTransferFee(fee)); @@ -3142,32 +3141,32 @@ class MPToken_test : public beast::unit_test::suite mptAlice.authorize({.account = carol}); mptAlice.authorize({.account = bob}); - auto const MPT = mptAlice["MPT"]; - env(pay(alice, carol, MPT(10'000))); - env(pay(alice, bob, MPT(10'000))); + auto const mpt = mptAlice["MPT"]; + env(pay(alice, carol, mpt(10'000))); + env(pay(alice, bob, mpt(10'000))); env.close(); // MPTCanEscrow is not enabled - env(escrow::create(carol, bob, MPT(3)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(carol, bob, mpt(3)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); // MPTCanEscrow is enabled now mptAlice.set({.account = alice, .mutableFlags = tmfMPTSetCanEscrow}); - env(escrow::create(carol, bob, MPT(3)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150)); + env(escrow::create(carol, bob, mpt(3)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150)); // Clear MPTCanEscrow mptAlice.set({.account = alice, .mutableFlags = tmfMPTClearCanEscrow}); - env(escrow::create(carol, bob, MPT(3)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tecNO_PERMISSION)); + env(escrow::create(carol, bob, mpt(3)), + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tecNO_PERMISSION)); } void @@ -3217,18 +3216,18 @@ class MPToken_test : public beast::unit_test::suite BEAST_EXPECT(mptAlice.isTransferFeePresent()); // Bob can pay carol - MPT const MPTC = mptAlice; + MPT const mptc = mptAlice; if (!features[featureMPTokensV2]) { mptAlice.pay(bob, carol, 50); - BEAST_EXPECT(env.balance(carol, MPTC) == MPTC(50)); + BEAST_EXPECT(env.balance(carol, mptc) == mptc(50)); } else { // The difference is due to the rounding in MPT/DEX. // 1 MPTC is the transfer fee paid by bob to the issuer. - env(pay(bob, carol, mptAlice(50)), txflags(tfPartialPayment)); - BEAST_EXPECT(env.balance(carol, MPTC) == MPTC(49)); + env(pay(bob, carol, mptAlice(50)), Txflags(tfPartialPayment)); + BEAST_EXPECT(env.balance(carol, mptc) == mptc(49)); } // Alice clears MPTCanTransfer @@ -3319,15 +3318,15 @@ class MPToken_test : public beast::unit_test::suite Account const alice("alice"); Account const bob("bob"); - std::uint64_t constexpr maxAmt = 150; + std::uint64_t constexpr kMAX_AMT = 150; Env env{*this, features}; - MPTTester mptt(env, issuer, {.holders = {alice, bob}}); - mptt.create({.maxAmt = maxAmt, .ownerCount = 1, .flags = tfMPTCanTransfer}); - mptt.authorize({.account = alice}); - mptt.authorize({.account = bob}); + MPTTester mptTester(env, issuer, {.holders = {alice, bob}}); + mptTester.create({.maxAmt = kMAX_AMT, .ownerCount = 1, .flags = tfMPTCanTransfer}); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = bob}); - Asset const asset{MPTIssue{mptt.issuanceID()}}; + Asset const asset{MPTIssue{mptTester.issuanceID()}}; // Each test case creates a fresh ApplyView and calls // accountSendMulti from the issuer to the given receivers. @@ -3335,7 +3334,7 @@ class MPToken_test : public beast::unit_test::suite TER expectedTer, std::optional expectedOutstanding, std::string const& label) { - ApplyViewImpl av(&*env.current(), tapNONE); + ApplyViewImpl av(&*env.current(), TapNone); auto const ter = accountSendMulti(av, issuer.id(), asset, receivers, env.app().getJournal("View")); BEAST_EXPECTS(ter == expectedTer, label); @@ -3344,7 +3343,7 @@ class MPToken_test : public beast::unit_test::suite // view may contain partial state and must be discarded. if (expectedOutstanding) { - auto const sle = av.peek(keylet::mptIssuance(mptt.issuanceID())); + auto const sle = av.peek(keylet::mptIssuance(mptTester.issuanceID())); if (!BEAST_EXPECT(sle)) return; BEAST_EXPECTS(sle->getFieldU64(sfOutstandingAmount) == *expectedOutstanding, label); @@ -3360,14 +3359,14 @@ class MPToken_test : public beast::unit_test::suite std::nullopt, "aggregate exceeds max"); - runTest(R{{alice.id(), 75}, {bob.id(), 75}}, tesSUCCESS, maxAmt, "aggregate at boundary"); + runTest(R{{alice.id(), 75}, {bob.id(), 75}}, tesSUCCESS, kMAX_AMT, "aggregate at boundary"); runTest(R{{alice.id(), 50}, {bob.id(), 50}}, tesSUCCESS, 100, "aggregate within limit"); runTest( R{{alice.id(), 150}, {bob.id(), 0}}, tesSUCCESS, - maxAmt, + kMAX_AMT, "one receiver at max, other zero"); runTest( @@ -3378,14 +3377,14 @@ class MPToken_test : public beast::unit_test::suite // Issue 50 tokens so outstandingAmount is nonzero, then verify // the third condition: outstandingAmount > maximumAmount - sendAmount - totalSendAmount - mptt.pay(issuer, alice, 50); + mptTester.pay(issuer, alice, 50); env.close(); // maxAmt=150, outstanding=50, so 100 more available runTest( R{{alice.id(), 50}, {bob.id(), 50}}, tesSUCCESS, - maxAmt, + kMAX_AMT, "nonzero outstanding, aggregate at boundary"); runTest( @@ -3397,7 +3396,7 @@ class MPToken_test : public beast::unit_test::suite runTest( R{{alice.id(), 100}, {bob.id(), 0}}, tesSUCCESS, - maxAmt, + kMAX_AMT, "nonzero outstanding, single send at remaining capacity"); runTest( @@ -3429,7 +3428,7 @@ class MPToken_test : public beast::unit_test::suite Account const gw = Account("gw"); Account const alice = Account("alice"); Account const carol = Account("carol"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Blocking flags for (auto flags : @@ -3449,24 +3448,24 @@ class MPToken_test : public beast::unit_test::suite (flags & (tfMPTCanLock | tfMPTCanClawback)) == (tfMPTCanLock | tfMPTCanClawback); bool const requireAuth = (flags & tfMPTRequireAuth) != 0u; - auto mpt = MPTTester( + auto mptTester = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000, .flags = flags, .authHolder = true}); - MPT const BTC = mpt; + MPT const btc = mptTester; if (requireAuth) - mpt.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); + mptTester.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); if (lockMPToken) { - mpt.set({.holder = alice, .flags = tfMPTLock}); + mptTester.set({.holder = alice, .flags = tfMPTLock}); } else if (lockMPTIssue) { - mpt.set({.flags = tfMPTLock}); + mptTester.set({.flags = tfMPTLock}); } auto testOffer = @@ -3494,14 +3493,14 @@ class MPToken_test : public beast::unit_test::suite auto const err = buyUSD ? errBuy : errSell; auto seq(env.seq(account)); - env(offer(account, buy(10), sell(10)), ter(err)); - env(offer_cancel(account, seq)); + env(offer(account, buy(10), sell(10)), Ter(err)); + env(offerCancel(account, seq)); env.close(); }; auto testOffers = [&](Account const& account) { - testOffer(account, XRP, BTC, false); - testOffer(account, BTC, XRP, true); + testOffer(account, XRP, btc, false); + testOffer(account, btc, XRP, true); }; testOffers(alice); testOffers(gw); @@ -3511,14 +3510,14 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features - featureMPTokensV2}; - MPTTester mpt(env, gw, {.holders = {alice}}); + MPTTester mptTester(env, gw, {.holders = {alice}}); - mpt.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); + mptTester.create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer}); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 200); - env(offer(alice, XRP(100), mpt.mpt(101)), ter(temDISABLED)); + env(offer(alice, XRP(100), mptTester.mpt(101)), Ter(temDISABLED)); env.close(); } @@ -3527,22 +3526,22 @@ class MPToken_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(1'000), gw, alice); env.close(); - MPT const BTC = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 100}); - MPT const ETH = MPT(gw, 1); + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 100}); + MPT const eth = MPT(gw, 1); - env(offer(alice, ETH(10), BTC(10)), ter(tecOBJECT_NOT_FOUND)); - env(offer(alice, BTC(10), ETH(10)), ter(tecUNFUNDED_OFFER)); + env(offer(alice, eth(10), btc(10)), Ter(tecOBJECT_NOT_FOUND)); + env(offer(alice, btc(10), eth(10)), Ter(tecUNFUNDED_OFFER)); } // MPToken object doesn't exist and the account is not the issuer of MPT { Env env(*this); env.fund(XRP(1'000), gw, alice); - MPTTester const BTC({.env = env, .issuer = gw, .holders = {alice}, .pay = 100}); - MPTTester const ETH({.env = env, .issuer = gw}); + MPTTester const btc({.env = env, .issuer = gw, .holders = {alice}, .pay = 100}); + MPTTester const eth({.env = env, .issuer = gw}); - env(offer(alice, ETH(10), BTC(10))); - env(offer(alice, BTC(10), ETH(10)), ter(tecUNFUNDED_OFFER)); + env(offer(alice, eth(10), btc(10))); + env(offer(alice, btc(10), eth(10)), Ter(tecUNFUNDED_OFFER)); } // MPTLock flag is set and the account is not the issuer of MPT @@ -3551,39 +3550,39 @@ class MPToken_test : public beast::unit_test::suite Account const dan = Account("dan"); Env env(*this); env.fund(XRP(1'000), gw, alice, carol, bob, dan); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob, dan}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester ETH( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob, dan}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - env(offer(bob, ETH(10), BTC(10)), txflags(tfPassive)); - env(offer(dan, BTC(10), ETH(10)), txflags(tfPassive)); + env(offer(bob, eth(10), btc(10)), Txflags(tfPassive)); + env(offer(dan, btc(10), eth(10)), Txflags(tfPassive)); auto test = [&](auto const& flag, bool gwOwner = false) { - BTC.set({.holder = carol, .flags = flag}); - BTC.set({.holder = alice, .flags = flag}); + btc.set({.holder = carol, .flags = flag}); + btc.set({.holder = alice, .flags = flag}); if (gwOwner) { // Succeeds if the account is the issuer - env(offer(gw, ETH(1), BTC(1))); - env(offer(gw, BTC(1), ETH(1))); + env(offer(gw, eth(1), btc(1))); + env(offer(gw, btc(1), eth(1))); } else { - auto const err = flag == tfMPTLock ? ter(tecUNFUNDED_OFFER) : ter(tesSUCCESS); - env(offer(alice, ETH(1), BTC(1)), err); + auto const err = flag == tfMPTLock ? Ter(tecUNFUNDED_OFFER) : Ter(tesSUCCESS); + env(offer(alice, eth(1), btc(1)), err); // Offer created by not crossed - env(offer(carol, BTC(1), ETH(1))); - BEAST_EXPECT(expectOffers(env, carol, 1, {{BTC(1), ETH(1)}})); + env(offer(carol, btc(1), eth(1))); + BEAST_EXPECT(expectOffers(env, carol, 1, {{btc(1), eth(1)}})); } }; @@ -3596,28 +3595,28 @@ class MPToken_test : public beast::unit_test::suite { Env env(*this); env.fund(XRP(1'000), gw, alice); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice}, .pay = 100, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - MPTTester const ETH( + MPTTester const eth( {.env = env, .issuer = gw, .holders = {alice}, .pay = 100, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); - BTC.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); + btc.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); - env(offer(alice, ETH(10), BTC(10)), ter(tecUNFUNDED_OFFER)); + env(offer(alice, eth(10), btc(10)), Ter(tecUNFUNDED_OFFER)); // issuer can create - env(offer(gw, ETH(10), BTC(10))); + env(offer(gw, eth(10), btc(10))); env.close(); } @@ -3625,14 +3624,14 @@ class MPToken_test : public beast::unit_test::suite { Env env(*this); env.fund(XRP(1'000), gw, alice, carol); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol}, .pay = 100, .flags = tfMPTCanTrade, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester ETH( + MPTTester eth( {.env = env, .issuer = gw, .holders = {alice, carol}, @@ -3641,24 +3640,24 @@ class MPToken_test : public beast::unit_test::suite .mutableFlags = tmfMPTCanMutateCanTransfer}); // Can create - env(offer(alice, ETH(10), BTC(10)), txflags(tfPassive)); - BTC.set({.mutableFlags = tmfMPTSetCanTransfer}); - ETH.set({.mutableFlags = tmfMPTClearCanTransfer}); - env(offer(alice, ETH(10), BTC(10)), txflags(tfPassive)); + env(offer(alice, eth(10), btc(10)), Txflags(tfPassive)); + btc.set({.mutableFlags = tmfMPTSetCanTransfer}); + eth.set({.mutableFlags = tmfMPTClearCanTransfer}); + env(offer(alice, eth(10), btc(10)), Txflags(tfPassive)); BEAST_EXPECT(getAccountOffers(env, alice)[jss::offers].size() == 2); // issuer can create - env(offer(gw, ETH(10), BTC(10)), txflags(tfPassive)); + env(offer(gw, eth(10), btc(10)), Txflags(tfPassive)); env.close(); // can cross issuer's offer, other offers are removed - env(offer(carol, BTC(10), ETH(10))); + env(offer(carol, btc(10), eth(10))); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, gw, 0)); BEAST_EXPECT(expectOffers(env, carol, 0)); // can't cross holder's offer, holder's offer is removed - env(offer(alice, ETH(10), BTC(10)), txflags(tfPassive)); - env(offer(carol, BTC(10), ETH(10))); + env(offer(alice, eth(10), btc(10)), Txflags(tfPassive)); + env(offer(carol, btc(10), eth(10))); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, carol, 1)); } @@ -3667,14 +3666,14 @@ class MPToken_test : public beast::unit_test::suite { Env env(*this); env.fund(XRP(1'000), gw, alice, carol); - MPTTester const BTC( + MPTTester const btc( {.env = env, .issuer = gw, .holders = {alice, carol}, .pay = 100, .flags = tfMPTCanTransfer, .mutableFlags = tmfMPTCanMutateCanTrade}); - MPTTester const ETH( + MPTTester const eth( {.env = env, .issuer = gw, .holders = {alice, carol}, @@ -3683,7 +3682,7 @@ class MPToken_test : public beast::unit_test::suite .mutableFlags = tmfMPTCanMutateCanTrade}); // Can't create - env(offer(gw, ETH(10), BTC(10)), ter(tecNO_PERMISSION)); + env(offer(gw, eth(10), btc(10)), Ter(tecNO_PERMISSION)); env.close(); } @@ -3691,110 +3690,110 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice, carol}}); + MPTTester mptTester(env, gw, {.holders = {alice, carol}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 200); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - env(offer(alice, XRP(100), MPT(101))); + env(offer(alice, XRP(100), mpt(101))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(100), MPT(101)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(100), mpt(101)}}})); - env(offer(carol, MPT(101), XRP(100))); + env(offer(carol, mpt(101), XRP(100))); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 99)); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 301)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 99)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 301)); } // IOU/MPT { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice, carol}}); + MPTTester mptTester(env, gw, {.holders = {alice, carol}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - env(trust(alice, USD(2'000))); - env(pay(gw, alice, USD(1'000))); + env(trust(alice, usd(2'000))); + env(pay(gw, alice, usd(1'000))); env.close(); - env(trust(carol, USD(2'000))); - env(pay(gw, carol, USD(1'000))); + env(trust(carol, usd(2'000))); + env(pay(gw, carol, usd(1'000))); env.close(); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 200); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - env(offer(alice, USD(100), MPT(101))); + env(offer(alice, usd(100), mpt(101))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{USD(100), MPT(101)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{usd(100), mpt(101)}}})); - env(offer(carol, MPT(101), USD(100))); + env(offer(carol, mpt(101), usd(100))); env.close(); - BEAST_EXPECT(env.balance(alice, USD) == USD(1'100)); - BEAST_EXPECT(env.balance(carol, USD) == USD(900)); + BEAST_EXPECT(env.balance(alice, usd) == usd(1'100)); + BEAST_EXPECT(env.balance(carol, usd) == usd(900)); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 99)); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 301)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 99)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 301)); } // MPT/MPT { Env env{*this, features}; - MPTTester mpt1(env, gw, {.holders = {alice, carol}}); - mpt1.create( + MPTTester mptTester1(env, gw, {.holders = {alice, carol}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; + auto const mpt1 = mptTester1["MPT1"]; - MPTTester mpt2(env, gw, {.holders = {alice, carol}, .fund = false}); - mpt2.create( + MPTTester mptTester2(env, gw, {.holders = {alice, carol}, .fund = false}); + mptTester2.create( {.ownerCount = 2, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT2"]; + auto const mpt2 = mptTester2["MPT2"]; - mpt1.authorize({.account = alice}); - mpt1.authorize({.account = carol}); - mpt1.pay(gw, alice, 200); - mpt1.pay(gw, carol, 200); + mptTester1.authorize({.account = alice}); + mptTester1.authorize({.account = carol}); + mptTester1.pay(gw, alice, 200); + mptTester1.pay(gw, carol, 200); - mpt2.authorize({.account = alice}); - mpt2.authorize({.account = carol}); - mpt2.pay(gw, alice, 200); - mpt2.pay(gw, carol, 200); + mptTester2.authorize({.account = alice}); + mptTester2.authorize({.account = carol}); + mptTester2.pay(gw, alice, 200); + mptTester2.pay(gw, carol, 200); - env(offer(alice, MPT2(100), MPT1(101))); + env(offer(alice, mpt2(100), mpt1(101))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{MPT2(100), MPT1(101)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{mpt2(100), mpt1(101)}}})); - env(offer(carol, MPT1(101), MPT2(100))); + env(offer(carol, mpt1(101), mpt2(100))); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, carol, 0)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 99)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(carol, 301)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 300)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 100)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 99)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(carol, 301)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 300)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 100)); } } @@ -3807,83 +3806,83 @@ class MPToken_test : public beast::unit_test::suite Account const alice = Account("alice"); Account const carol = Account("carol"); Account const bob = Account("bob"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Loop { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {carol, bob}}); + MPTTester mptTester(env, gw, {.holders = {carol, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - mpt.authorize({.account = bob}); + mptTester.authorize({.account = bob}); // holder to holder - env(pay(carol, bob, MPT(1)), - test::jtx::path(~MPT, ~USD, ~MPT), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH_LOOP)); + env(pay(carol, bob, mpt(1)), + test::jtx::Path(~mpt, ~usd, ~mpt), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH_LOOP)); env.close(); // issuer to holder - env(pay(gw, bob, MPT(1)), - test::jtx::path(~MPT, ~USD, ~MPT), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH_LOOP)); + env(pay(gw, bob, mpt(1)), + test::jtx::Path(~mpt, ~usd, ~mpt), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH_LOOP)); env.close(); // holder to issuer - env(pay(bob, gw, MPT(1)), - test::jtx::path(~MPT, ~USD, ~MPT), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH_LOOP)); + env(pay(bob, gw, mpt(1)), + test::jtx::Path(~mpt, ~usd, ~mpt), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH_LOOP)); env.close(); } // Rippling { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {carol, bob}}); + MPTTester mptTester(env, gw, {.holders = {carol, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - mpt.authorize({.account = bob}); + mptTester.authorize({.account = bob}); // holder to holder - env(pay(carol, bob, MPT(1)), - test::jtx::path(~MPT, gw), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH)); + env(pay(carol, bob, mpt(1)), + test::jtx::Path(~mpt, gw), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH)); env.close(); // issuer to holder - env(pay(gw, bob, MPT(1)), - test::jtx::path(~MPT, carol), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH)); + env(pay(gw, bob, mpt(1)), + test::jtx::Path(~mpt, carol), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH)); env.close(); // holder to issuer - env(pay(bob, gw, MPT(1)), - test::jtx::path(~MPT, carol), - sendmax(XRP(1)), - txflags(tfPartialPayment), - ter(temBAD_PATH)); + env(pay(bob, gw, mpt(1)), + test::jtx::Path(~mpt, carol), + Sendmax(XRP(1)), + Txflags(tfPartialPayment), + Ter(temBAD_PATH)); env.close(); } @@ -3891,128 +3890,128 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features - featureMPTokensV2}; - MPTTester mpt(env, gw, {.holders = {alice}}); + MPTTester mptTester(env, gw, {.holders = {alice}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); + mptTester.authorize({.account = alice}); - env(pay(gw, alice, MPT(101)), - test::jtx::path(~MPT), - sendmax(XRP(100)), - txflags(tfPartialPayment), - ter(temMALFORMED)); + env(pay(gw, alice, mpt(101)), + test::jtx::Path(~mpt), + Sendmax(XRP(100)), + Txflags(tfPartialPayment), + Ter(temMALFORMED)); } { auto const ed = Account{"ed"}; Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol, bob, ed); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .mutableFlags = tmfMPTCanMutateRequireAuth | tmfMPTCanMutateCanTrade | tmfMPTCanMutateCanTransfer}); - MPTTester ETH( + MPTTester eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester const USD( + MPTTester const usd( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester const CAD( + MPTTester const cad( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .mutableFlags = tmfMPTCanMutateCanTransfer}); - env(offer(bob, ETH(1'000), BTC(1'000)), txflags(tfPassive)); + env(offer(bob, eth(1'000), btc(1'000)), Txflags(tfPassive)); env.close(); - env(offer(bob, BTC(1'000), ETH(1'000)), txflags(tfPassive)); + env(offer(bob, btc(1'000), eth(1'000)), Txflags(tfPassive)); env.close(); // MPTokenIssuance doesn't exist - env(pay(alice, carol, MPT(gw, 1'000)(10)), sendmax(ETH(10)), ter(tecOBJECT_NOT_FOUND)); + env(pay(alice, carol, MPT(gw, 1'000)(10)), Sendmax(eth(10)), Ter(tecOBJECT_NOT_FOUND)); env.close(); - env(pay(alice, carol, ETH(10)), sendmax(MPT(gw)(10)), ter(tecOBJECT_NOT_FOUND)); + env(pay(alice, carol, eth(10)), Sendmax(MPT(gw)(10)), Ter(tecOBJECT_NOT_FOUND)); env.close(); // MPToken object doesn't exist // holder and issuer fail - env(pay(ed, carol, BTC(10)), sendmax(ETH(10)), ter(tecNO_AUTH)); - env(pay(carol, ed, BTC(10)), sendmax(ETH(10)), ter(tecNO_AUTH)); - env(pay(ed, gw, BTC(10)), sendmax(ETH(10)), ter(tecNO_AUTH)); - env(pay(gw, ed, BTC(10)), sendmax(ETH(10)), ter(tecNO_AUTH)); + env(pay(ed, carol, btc(10)), Sendmax(eth(10)), Ter(tecNO_AUTH)); + env(pay(carol, ed, btc(10)), Sendmax(eth(10)), Ter(tecNO_AUTH)); + env(pay(ed, gw, btc(10)), Sendmax(eth(10)), Ter(tecNO_AUTH)); + env(pay(gw, ed, btc(10)), Sendmax(eth(10)), Ter(tecNO_AUTH)); env.close(); // MPTRequireAuth is set - BTC.authorize({.account = ed}); - ETH.authorize({.account = ed}); - env(pay(gw, ed, ETH(100))); - env(pay(gw, ed, BTC(100))); + btc.authorize({.account = ed}); + eth.authorize({.account = ed}); + env(pay(gw, ed, eth(100))); + env(pay(gw, ed, btc(100))); env.close(); - BTC.set({.mutableFlags = tmfMPTSetRequireAuth}); + btc.set({.mutableFlags = tmfMPTSetRequireAuth}); // authorize bob to enable the offers trading - BTC.authorize({.account = gw, .holder = bob}); + btc.authorize({.account = gw, .holder = bob}); env.close(); - env(pay(ed, carol, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecNO_AUTH)); - env(pay(carol, ed, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecNO_AUTH)); + env(pay(ed, carol, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecNO_AUTH)); + env(pay(carol, ed, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecNO_AUTH)); // BTC is transferred from bob to ed, ed is not authorized - env(pay(gw, ed, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecNO_AUTH)); + env(pay(gw, ed, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecNO_AUTH)); // BTC is transferred from bob to issuer - env(pay(ed, gw, BTC(10)), path(~BTC), sendmax(ETH(10))); + env(pay(ed, gw, btc(10)), Path(~btc), Sendmax(eth(10))); // BTC is transferred from issuer to bob - env(pay(gw, ed, ETH(10)), path(~ETH), sendmax(BTC(10))); + env(pay(gw, ed, eth(10)), Path(~eth), Sendmax(btc(10))); // BTC is transferred from ed to bob, ed is not authorized - env(pay(ed, gw, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tecNO_AUTH)); + env(pay(ed, gw, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tecNO_AUTH)); env.close(); - BTC.set({.mutableFlags = tmfMPTClearRequireAuth}); + btc.set({.mutableFlags = tmfMPTClearRequireAuth}); // MPTCanTransfer is not set // Fail regardless if source/destination is the issuer or // not since the offer is owned by a holder. - BTC.set({.mutableFlags = tmfMPTClearCanTransfer}); - env(pay(ed, carol, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecPATH_PARTIAL)); - env(pay(carol, ed, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecPATH_PARTIAL)); - env(pay(ed, carol, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tecPATH_PARTIAL)); - env(pay(carol, ed, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tecPATH_PARTIAL)); + btc.set({.mutableFlags = tmfMPTClearCanTransfer}); + env(pay(ed, carol, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecPATH_PARTIAL)); + env(pay(carol, ed, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecPATH_PARTIAL)); + env(pay(ed, carol, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tecPATH_PARTIAL)); + env(pay(carol, ed, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tecPATH_PARTIAL)); // Fail because BTC, which has CanTransfer disabled, is sent to // bob - env(pay(ed, gw, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tecPATH_PARTIAL)); - env(pay(ed, gw, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tesSUCCESS)); - env(pay(gw, ed, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tesSUCCESS)); + env(pay(ed, gw, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tecPATH_PARTIAL)); + env(pay(ed, gw, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tesSUCCESS)); + env(pay(gw, ed, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tesSUCCESS)); // Fail because BTC, which has CanTransfer disabled, is sent to // ed - env(pay(gw, ed, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tecPATH_PARTIAL)); + env(pay(gw, ed, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tecPATH_PARTIAL)); env.close(); - env(offer(gw, ETH(100), BTC(100)), txflags(tfPassive)); + env(offer(gw, eth(100), btc(100)), Txflags(tfPassive)); env.close(); - env(offer(gw, BTC(100), ETH(100)), txflags(tfPassive)); + env(offer(gw, btc(100), eth(100)), Txflags(tfPassive)); env.close(); BEAST_EXPECT(expectOffers(env, bob, 2)); - env(pay(ed, carol, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tesSUCCESS)); - env(pay(ed, carol, ETH(10)), path(~ETH), sendmax(BTC(10)), ter(tesSUCCESS)); - env(pay(gw, carol, BTC(10)), path(~BTC), sendmax(ETH(10)), ter(tesSUCCESS)); + env(pay(ed, carol, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tesSUCCESS)); + env(pay(ed, carol, eth(10)), Path(~eth), Sendmax(btc(10)), Ter(tesSUCCESS)); + env(pay(gw, carol, btc(10)), Path(~btc), Sendmax(eth(10)), Ter(tesSUCCESS)); env.close(); - env(pay(ed, gw, BTC(10)), path(~BTC), sendmax(ETH(10))); + env(pay(ed, gw, btc(10)), Path(~btc), Sendmax(eth(10))); env.close(); } // Multiple steps: CAD/USD, USD/BTC, BTC/ETH @@ -4021,33 +4020,33 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol, bob, ed); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester ETH( + MPTTester eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester USD( + MPTTester usd( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .mutableFlags = tmfMPTCanMutateCanTransfer}); - MPTTester CAD( + MPTTester cad( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .mutableFlags = tmfMPTCanMutateCanTransfer}); // takerGets can transfer if: // - CanTransfer is set @@ -4060,77 +4059,77 @@ class MPToken_test : public beast::unit_test::suite // - The offer's owner is the issuer // - Previous step is BookStep, which transfers per above // - CanTransfer is set - env(offer(bob, CAD(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), BTC(100)), txflags(tfPassive)); - env(offer(bob, BTC(100), ETH(100)), txflags(tfPassive)); + env(offer(bob, cad(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), btc(100)), Txflags(tfPassive)); + env(offer(bob, btc(100), eth(100)), Txflags(tfPassive)); env.close(); BEAST_EXPECT(expectOffers(env, bob, 3)); - BTC.set({.mutableFlags = tmfMPTSetCanTransfer}); - USD.set({.mutableFlags = tmfMPTClearCanTransfer}); + btc.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearCanTransfer}); // TakerGets // fail - CAD/USD is owned by bob - env(pay(alice, carol, ETH(1)), - path(~USD, ~BTC, ~ETH), - sendmax(CAD(1)), - ter(tecPATH_PARTIAL)); + env(pay(alice, carol, eth(1)), + Path(~usd, ~btc, ~eth), + Sendmax(cad(1)), + Ter(tecPATH_PARTIAL)); auto seq(env.seq(gw)); - env(offer(gw, USD(1), BTC(1)), txflags(tfPassive)); + env(offer(gw, usd(1), btc(1)), Txflags(tfPassive)); env.close(); // fail - CAD/USD is owned by bob - env(pay(alice, carol, ETH(1)), - path(~USD, ~BTC, ~ETH), - sendmax(CAD(1)), - ter(tecPATH_PARTIAL)); + env(pay(alice, carol, eth(1)), + Path(~usd, ~btc, ~eth), + Sendmax(cad(1)), + Ter(tecPATH_PARTIAL)); env.close(); - env(offer_cancel(gw, seq)); - env(offer(gw, CAD(1), USD(1)), txflags(tfPassive)); + env(offerCancel(gw, seq)); + env(offer(gw, cad(1), usd(1)), Txflags(tfPassive)); env.close(); BEAST_EXPECT(expectOffers(env, bob, 3)); // succeed - CAD/USD is owned by issuer - env(pay(alice, carol, ETH(1)), path(~USD, ~BTC, ~ETH), sendmax(CAD(1))); + env(pay(alice, carol, eth(1)), Path(~usd, ~btc, ~eth), Sendmax(cad(1))); env.close(); // bob's CAD/USD is deleted BEAST_EXPECT(expectOffers(env, bob, 2)); - env(offer(bob, CAD(100), USD(100)), txflags(tfPassive)); + env(offer(bob, cad(100), usd(100)), Txflags(tfPassive)); BEAST_EXPECT(expectOffers(env, gw, 0)); - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); - ETH.set({.mutableFlags = tmfMPTClearCanTransfer}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); + eth.set({.mutableFlags = tmfMPTClearCanTransfer}); // fail - BTC/ETH is owned by bob, destination is carol - env(pay(alice, carol, ETH(1)), - path(~USD, ~BTC, ~ETH), - sendmax(CAD(1)), - ter(tecPATH_PARTIAL)); + env(pay(alice, carol, eth(1)), + Path(~usd, ~btc, ~eth), + Sendmax(cad(1)), + Ter(tecPATH_PARTIAL)); env.close(); BEAST_EXPECT(expectOffers(env, bob, 3)); // succeed - destination is an issuer - env(pay(alice, gw, ETH(1)), path(~USD, ~BTC, ~ETH), sendmax(CAD(1))); + env(pay(alice, gw, eth(1)), Path(~usd, ~btc, ~eth), Sendmax(cad(1))); env.close(); BEAST_EXPECT(expectOffers(env, bob, 3)); // TakerPays - ETH.set({.mutableFlags = tmfMPTSetCanTransfer}); - CAD.set({.mutableFlags = tmfMPTClearCanTransfer}); + eth.set({.mutableFlags = tmfMPTSetCanTransfer}); + cad.set({.mutableFlags = tmfMPTClearCanTransfer}); // fail - CAD/USD is owned by bob, source is alice - env(pay(alice, carol, ETH(1)), - path(~USD, ~BTC, ~ETH), - sendmax(CAD(1)), - ter(tecPATH_PARTIAL)); + env(pay(alice, carol, eth(1)), + Path(~usd, ~btc, ~eth), + Sendmax(cad(1)), + Ter(tecPATH_PARTIAL)); // succeed - source is the issuer - env(pay(gw, carol, ETH(1)), path(~USD, ~BTC, ~ETH), sendmax(CAD(1))); + env(pay(gw, carol, eth(1)), Path(~usd, ~btc, ~eth), Sendmax(cad(1))); env.close(); - env(offer(gw, CAD(1), USD(1)), txflags(tfPassive)); + env(offer(gw, cad(1), usd(1)), Txflags(tfPassive)); env.close(); // succeed - CAD/USD is owned by issuer - env(pay(alice, carol, ETH(1)), path(~USD, ~BTC, ~ETH), sendmax(CAD(1))); + env(pay(alice, carol, eth(1)), Path(~usd, ~btc, ~eth), Sendmax(cad(1))); env.close(); BEAST_EXPECT(expectOffers(env, gw, 0)); BEAST_EXPECT(expectOffers(env, bob, 2)); - CAD.set({.mutableFlags = tmfMPTSetCanTransfer}); - BTC.set({.mutableFlags = tmfMPTClearCanTransfer}); - env(offer(bob, CAD(1), USD(1)), txflags(tfPassive)); - env(offer(gw, USD(1), BTC(1)), txflags(tfPassive)); + cad.set({.mutableFlags = tmfMPTSetCanTransfer}); + btc.set({.mutableFlags = tmfMPTClearCanTransfer}); + env(offer(bob, cad(1), usd(1)), Txflags(tfPassive)); + env(offer(gw, usd(1), btc(1)), Txflags(tfPassive)); env.close(); // succeed - USD/BTC is owned by issuer - env(pay(alice, carol, ETH(1)), path(~USD, ~BTC, ~ETH), sendmax(CAD(1))); + env(pay(alice, carol, eth(1)), Path(~usd, ~btc, ~eth), Sendmax(cad(1))); env.close(); BEAST_EXPECT(expectOffers(env, gw, 0)); } @@ -4140,21 +4139,21 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol, bob); env.close(); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, .flags = tfMPTCanTransfer, .mutableFlags = tmfMPTCanMutateCanTrade}); - MPTTester const ETH( + MPTTester const eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 1'000, .flags = tfMPTCanTransfer | tfMPTCanTrade, .mutableFlags = tmfMPTCanMutateCanTrade}); - MPTTester const USD( + MPTTester const usd( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, @@ -4162,20 +4161,20 @@ class MPToken_test : public beast::unit_test::suite .flags = tfMPTCanTransfer | tfMPTCanTrade, .mutableFlags = tmfMPTCanMutateCanTrade}); - env(pay(alice, carol, ETH(1)), path(~ETH), sendmax(BTC(1)), ter(tecNO_PERMISSION)); - env(pay(alice, carol, BTC(1)), path(~BTC), sendmax(ETH(1)), ter(tecNO_PERMISSION)); + env(pay(alice, carol, eth(1)), Path(~eth), Sendmax(btc(1)), Ter(tecNO_PERMISSION)); + env(pay(alice, carol, btc(1)), Path(~btc), Sendmax(eth(1)), Ter(tecNO_PERMISSION)); env.close(); - BTC.set({.mutableFlags = tmfMPTSetCanTrade}); - env(offer(bob, XRP(1), BTC(1))); - env(offer(bob, BTC(1), ETH(1))); - env(offer(bob, ETH(1), USD(1))); + btc.set({.mutableFlags = tmfMPTSetCanTrade}); + env(offer(bob, XRP(1), btc(1))); + env(offer(bob, btc(1), eth(1))); + env(offer(bob, eth(1), usd(1))); env.close(); - BTC.set({.mutableFlags = tmfMPTClearCanTrade}); - env(pay(gw, carol, USD(1)), - path(~BTC, ~ETH, ~USD), - sendmax(XRP(1)), - ter(tecPATH_PARTIAL)); + btc.set({.mutableFlags = tmfMPTClearCanTrade}); + env(pay(gw, carol, usd(1)), + Path(~btc, ~eth, ~usd), + Sendmax(XRP(1)), + Ter(tecPATH_PARTIAL)); env.close(); BEAST_EXPECT(expectOffers(env, bob, 3)); } @@ -4208,19 +4207,19 @@ class MPToken_test : public beast::unit_test::suite } }; auto getMPT = [&](Env& env) { - MPTTester const BTC( + MPTTester const btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester const ETH( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester const eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); - return std::make_pair(BTC, ETH); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + return std::make_pair(btc, eth); }; auto getIOU = [&](Env& env) { for (auto const& iou : {gw["BTC"], gw["ETH"]}) @@ -4268,36 +4267,36 @@ class MPToken_test : public beast::unit_test::suite Env env(*this); env.fund(XRP(1'000), gw, alice, carol, bob); - auto [BTC, ETH] = getTokens(env); + auto [btc, eth] = getTokens(env); - env(offer(arg.offerOwner, ETH(10), BTC(10)), txflags(tfPassive)); + env(offer(arg.offerOwner, eth(10), btc(10)), Txflags(tfPassive)); env.close(); if (arg.globalFlagBuy != LockType::None) { - lock(env, gw, ETH, LockType::Global); + lock(env, gw, eth, LockType::Global); } else { - lock(env, arg.offerOwner, ETH, arg.offerFlagBuy); - lock(env, arg.src, ETH, arg.srcFlag); + lock(env, arg.offerOwner, eth, arg.offerFlagBuy); + lock(env, arg.src, eth, arg.srcFlag); } if (arg.globalFlagSell != LockType::None) { - lock(env, gw, BTC, LockType::Global); + lock(env, gw, btc, LockType::Global); } else { - lock(env, arg.offerOwner, BTC, arg.offerFlagSell); - lock(env, arg.dst, BTC, arg.dstFlag); + lock(env, arg.offerOwner, btc, arg.offerFlagSell); + lock(env, arg.dst, btc, arg.dstFlag); } - auto const err = getErr(ETH, arg); - env(pay(arg.src, arg.dst, BTC(1)), - path(~BTC), - txflags(tfNoRippleDirect), - sendmax(ETH(1)), - ter(err)); + auto const err = getErr(eth, arg); + env(pay(arg.src, arg.dst, btc(1)), + Path(~btc), + Txflags(tfNoRippleDirect), + Sendmax(eth(1)), + Ter(err)); env.close(); }; // clang-format off @@ -4341,48 +4340,48 @@ class MPToken_test : public beast::unit_test::suite } { Env env(*this); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(1'000), gw, alice, carol, bob); - MPTTester BTC( + MPTTester btc( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); - MPTTester ETH( + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); + MPTTester eth( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100, - .flags = tfMPTCanLock | MPTDEXFlags}); + .flags = tfMPTCanLock | kMPT_DEX_FLAGS}); - env(trust(alice, USD(100))); - env(pay(gw, alice, USD(100))); - env(trust(carol, USD(100))); + env(trust(alice, usd(100))); + env(pay(gw, alice, usd(100))); + env(trust(carol, usd(100))); - env(offer(alice, XRP(10), ETH(10))); - env(offer(bob, ETH(10), BTC(10))); - env(offer(alice, BTC(10), USD(10))); + env(offer(alice, XRP(10), eth(10))); + env(offer(bob, eth(10), btc(10))); + env(offer(alice, btc(10), usd(10))); env.close(); - BTC.set({.holder = bob, .flags = tfMPTLock}); + btc.set({.holder = bob, .flags = tfMPTLock}); // Bob's offer is unfunded - env(pay(alice, carol, USD(1)), - path(~(MPT)ETH, ~(MPT)BTC, ~USD), - txflags(tfNoRippleDirect | tfPartialPayment), - sendmax(XRP(1)), - ter(tecPATH_DRY)); + env(pay(alice, carol, usd(1)), + Path(~(MPT)eth, ~(MPT)btc, ~usd), + Txflags(tfNoRippleDirect | tfPartialPayment), + Sendmax(XRP(1)), + Ter(tecPATH_DRY)); env.close(); - BTC.set({.holder = bob, .flags = tfMPTUnlock}); - ETH.set({.holder = bob, .flags = tfMPTLock}); + btc.set({.holder = bob, .flags = tfMPTUnlock}); + eth.set({.holder = bob, .flags = tfMPTLock}); - env(pay(alice, carol, USD(1)), - path(~(MPT)ETH, ~(MPT)BTC, ~USD), - txflags(tfNoRippleDirect | tfPartialPayment), - sendmax(XRP(1)), - ter(tecPATH_DRY)); + env(pay(alice, carol, usd(1)), + Path(~(MPT)eth, ~(MPT)btc, ~usd), + Txflags(tfNoRippleDirect | tfPartialPayment), + Sendmax(XRP(1)), + Ter(tecPATH_DRY)); } // A domain payment should only consume a USD/MPT offer with a domain. @@ -4394,25 +4393,25 @@ class MPToken_test : public beast::unit_test::suite auto const domainID = setupDomain(env, {alice, bob, carol, gw}, domainOwner, "permdex-cred"); - MPTTester BTC({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); - MPTTester ETH({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); + MPTTester btc({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); + MPTTester eth({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); auto test = [&](bool withDomain) { if (withDomain) { - env(offer(bob, ETH(1), BTC(1)), domain(domainID)); + env(offer(bob, eth(1), btc(1)), Domain(domainID)); } else { - env(offer(bob, ETH(1), BTC(1))); + env(offer(bob, eth(1), btc(1))); } - auto const err = withDomain ? ter(tesSUCCESS) : ter(tecPATH_DRY); - env(pay(alice, carol, BTC(1)), - path(~(MPT)BTC), - txflags(tfPartialPayment), - sendmax(ETH(1)), - domain(domainID), + auto const err = withDomain ? Ter(tesSUCCESS) : Ter(tecPATH_DRY); + env(pay(alice, carol, btc(1)), + Path(~(MPT)btc), + Txflags(tfPartialPayment), + Sendmax(eth(1)), + Domain(domainID), err); }; test(true); @@ -4428,18 +4427,18 @@ class MPToken_test : public beast::unit_test::suite auto const domainID = setupDomain(env, {alice, bob, carol, gw}, domainOwner, "permdex-cred"); - MPTTester BTC({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); - MPTTester ETH({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); + MPTTester btc({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); + MPTTester eth({.env = env, .issuer = gw, .holders = {alice, carol, bob}, .pay = 100}); auto test = [&](bool isHybrid) { auto const flags = isHybrid ? tfHybrid : 0; - env(offer(bob, ETH(1), BTC(1)), txflags(flags), domain(domainID)); + env(offer(bob, eth(1), btc(1)), Txflags(flags), Domain(domainID)); - auto const err = isHybrid ? ter(tesSUCCESS) : ter(tecPATH_DRY); - env(pay(alice, carol, BTC(1)), - path(~(MPT)BTC), - txflags(tfPartialPayment), - sendmax(ETH(1)), + auto const err = isHybrid ? Ter(tesSUCCESS) : Ter(tecPATH_DRY); + env(pay(alice, carol, btc(1)), + Path(~(MPT)btc), + Txflags(tfPartialPayment), + Sendmax(eth(1)), err); }; test(true); @@ -4449,258 +4448,259 @@ class MPToken_test : public beast::unit_test::suite // MPT/XRP { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice, carol, bob}}); + MPTTester mptTester(env, gw, {.holders = {alice, carol, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 200); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - mpt.authorize({.account = bob}); + mptTester.authorize({.account = bob}); - env(offer(alice, XRP(100), MPT(101))); + env(offer(alice, XRP(100), mpt(101))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(100), MPT(101)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{XRP(100), mpt(101)}}})); - env(pay(carol, bob, MPT(101)), - test::jtx::path(~MPT), - sendmax(XRP(100)), - txflags(tfPartialPayment)); + env(pay(carol, bob, mpt(101)), + test::jtx::Path(~mpt), + Sendmax(XRP(100)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 99)); - BEAST_EXPECT(mpt.checkMPTokenAmount(bob, 101)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 99)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(bob, 101)); } // MPT/IOU { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice, carol, bob}}); + MPTTester mptTester(env, gw, {.holders = {alice, carol, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - env(trust(alice, USD(2'000))); - env(pay(gw, alice, USD(1'000))); - env(trust(bob, USD(2'000))); - env(pay(gw, bob, USD(1'000))); - env(trust(carol, USD(2'000))); - env(pay(gw, carol, USD(1'000))); + env(trust(alice, usd(2'000))); + env(pay(gw, alice, usd(1'000))); + env(trust(bob, usd(2'000))); + env(pay(gw, bob, usd(1'000))); + env(trust(carol, usd(2'000))); + env(pay(gw, carol, usd(1'000))); env.close(); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 200); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - mpt.authorize({.account = bob}); + mptTester.authorize({.account = bob}); - env(offer(alice, USD(100), MPT(101))); + env(offer(alice, usd(100), mpt(101))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{USD(100), MPT(101)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{usd(100), mpt(101)}}})); - env(pay(carol, bob, MPT(101)), - test::jtx::path(~MPT), - sendmax(USD(100)), - txflags(tfPartialPayment)); + env(pay(carol, bob, mpt(101)), + test::jtx::Path(~mpt), + Sendmax(usd(100)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(env.balance(carol, USD) == USD(900)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 99)); - BEAST_EXPECT(mpt.checkMPTokenAmount(bob, 101)); + BEAST_EXPECT(env.balance(carol, usd) == usd(900)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 99)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(bob, 101)); } // IOU/MPT { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice, carol, bob}}); + MPTTester mptTester(env, gw, {.holders = {alice, carol, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - env(trust(alice, USD(2'000)), txflags(tfClearNoRipple)); - env(pay(gw, alice, USD(1'000))); - env(trust(bob, USD(2'000)), txflags(tfClearNoRipple)); + env(trust(alice, usd(2'000)), Txflags(tfClearNoRipple)); + env(pay(gw, alice, usd(1'000))); + env(trust(bob, usd(2'000)), Txflags(tfClearNoRipple)); env.close(); - mpt.authorize({.account = alice}); - env(pay(gw, alice, MPT(200))); + mptTester.authorize({.account = alice}); + env(pay(gw, alice, mpt(200))); - mpt.authorize({.account = carol}); - env(pay(gw, carol, MPT(200))); + mptTester.authorize({.account = carol}); + env(pay(gw, carol, mpt(200))); - env(offer(alice, MPT(101), USD(100))); + env(offer(alice, mpt(101), usd(100))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{MPT(101), USD(100)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{mpt(101), usd(100)}}})); - env(pay(carol, bob, USD(100)), - test::jtx::path(~USD), - sendmax(MPT(101)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, usd(100)), + test::jtx::Path(~usd), + Sendmax(mpt(101)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(env.balance(alice, USD) == USD(900)); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 301)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 99)); - BEAST_EXPECT(env.balance(bob, USD) == USD(100)); + BEAST_EXPECT(env.balance(alice, usd) == usd(900)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 301)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 99)); + BEAST_EXPECT(env.balance(bob, usd) == usd(100)); } // MPT/MPT { Env env{*this, features}; - MPTTester mpt1(env, gw, {.holders = {alice, carol, bob}}); - mpt1.create( + MPTTester mptTester1(env, gw, {.holders = {alice, carol, bob}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; + auto const mpt1 = mptTester1["MPT1"]; - MPTTester mpt2(env, gw, {.holders = {alice, carol, bob}, .fund = false}); - mpt2.create( + MPTTester mptTester2(env, gw, {.holders = {alice, carol, bob}, .fund = false}); + mptTester2.create( {.ownerCount = 2, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT2"]; + auto const mpt2 = mptTester2["MPT2"]; - mpt1.authorize({.account = alice}); - mpt1.pay(gw, alice, 200); - mpt2.authorize({.account = alice}); + mptTester1.authorize({.account = alice}); + mptTester1.pay(gw, alice, 200); + mptTester2.authorize({.account = alice}); - mpt2.authorize({.account = carol}); - mpt2.pay(gw, carol, 200); + mptTester2.authorize({.account = carol}); + mptTester2.pay(gw, carol, 200); - mpt1.authorize({.account = bob}); - mpt2.authorize({.account = bob}); - mpt2.pay(gw, bob, 200); + mptTester1.authorize({.account = bob}); + mptTester2.authorize({.account = bob}); + mptTester2.pay(gw, bob, 200); - env(offer(alice, MPT2(100), MPT1(100))); + env(offer(alice, mpt2(100), mpt1(100))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{MPT2(100), MPT1(100)}}})); + BEAST_EXPECT( + expectOffers(env, alice, 1, {{Amounts{mptTester2(100), mptTester1(100)}}})); // holder to holder - env(pay(carol, bob, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(carol, bob, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 190)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 10)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(200)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(400)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 10)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 190)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 10)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(200)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(400)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 10)); // issuer to holder - env(pay(gw, bob, MPT1(20)), - test::jtx::path(~MPT1), - sendmax(MPT2(20)), - txflags(tfPartialPayment)); + env(pay(gw, bob, mpt1(20)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(20)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 170)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 30)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(200)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(420)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 30)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 170)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 30)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(200)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(420)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 30)); // holder to issuer - env(pay(bob, gw, MPT1(70)), - test::jtx::path(~MPT1), - sendmax(MPT2(70)), - txflags(tfPartialPayment)); + env(pay(bob, gw, mpt1(70)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(70)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 100)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 100)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(130)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(420)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 30)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 130)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(130)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(420)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 30)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 130)); } // MPT/MPT, issuer owns the offer { Env env{*this, features}; - MPTTester mpt1(env, gw, {.holders = {carol, bob}}); - mpt1.create( + MPTTester mptTester1(env, gw, {.holders = {carol, bob}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; + auto const mpt1 = mptTester1["MPT1"]; - MPTTester mpt2(env, gw, {.holders = {carol, bob}, .fund = false}); - mpt2.create( + MPTTester mptTester2(env, gw, {.holders = {carol, bob}, .fund = false}); + mptTester2.create( {.ownerCount = 2, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT2"]; + auto const mpt2 = mptTester2["MPT2"]; - mpt2.authorize({.account = carol}); - mpt2.pay(gw, carol, 200); + mptTester2.authorize({.account = carol}); + mptTester2.pay(gw, carol, 200); - mpt1.authorize({.account = bob}); - mpt2.authorize({.account = bob}); - mpt2.pay(gw, bob, 200); + mptTester1.authorize({.account = bob}); + mptTester2.authorize({.account = bob}); + mptTester2.pay(gw, bob, 200); - env(offer(gw, MPT2(100), MPT1(100))); + env(offer(gw, mpt2(100), mpt1(100))); env.close(); - BEAST_EXPECT(expectOffers(env, gw, 1, {{Amounts{MPT2(100), MPT1(100)}}})); + BEAST_EXPECT(expectOffers(env, gw, 1, {{Amounts{mpt2(100), mpt1(100)}}})); // holder to holder - env(pay(carol, bob, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(carol, bob, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, gw, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(10)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(390)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 10)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(10)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(390)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 10)); // issuer to holder - env(pay(gw, bob, MPT1(20)), - test::jtx::path(~MPT1), - sendmax(MPT2(20)), - txflags(tfPartialPayment)); + env(pay(gw, bob, mpt1(20)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(20)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, gw, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(30)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(390)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 30)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(30)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(390)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 30)); // holder to issuer - env(pay(bob, gw, MPT1(70)), - test::jtx::path(~MPT1), - sendmax(MPT2(70)), - txflags(tfPartialPayment)); + env(pay(bob, gw, mpt1(70)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(70)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, gw, 0)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(30)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(320)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 30)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 130)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(30)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(320)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 30)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 130)); } // MPT/MPT, different issuer @@ -4708,240 +4708,240 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; Account const gw1{"gw1"}; - MPTTester mpt1(env, gw, {.holders = {alice, carol, bob}}); - mpt1.create( + MPTTester mptTester1(env, gw, {.holders = {alice, carol, bob}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; + auto const mpt1 = mptTester1["MPT1"]; env.fund(XRP(1'000), gw1); - MPTTester mpt2(env, gw1, {.holders = {alice, carol, bob}, .fund = false}); - mpt2.create( + MPTTester mptTester2(env, gw1, {.holders = {alice, carol, bob}, .fund = false}); + mptTester2.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT2"]; + auto const mpt2 = mptTester2["MPT2"]; - mpt1.authorize({.account = alice}); - mpt1.pay(gw, alice, 200); - mpt2.authorize({.account = alice}); + mptTester1.authorize({.account = alice}); + mptTester1.pay(gw, alice, 200); + mptTester2.authorize({.account = alice}); - mpt2.authorize({.account = carol}); - mpt2.pay(gw1, carol, 200); + mptTester2.authorize({.account = carol}); + mptTester2.pay(gw1, carol, 200); - mpt1.authorize({.account = bob}); - mpt1.pay(gw, bob, 200); - mpt2.authorize({.account = bob}); - mpt2.pay(gw1, bob, 200); + mptTester1.authorize({.account = bob}); + mptTester1.pay(gw, bob, 200); + mptTester2.authorize({.account = bob}); + mptTester2.pay(gw1, bob, 200); - mpt1.authorize({.account = gw1}); - mpt1.pay(gw, gw1, 200); + mptTester1.authorize({.account = gw1}); + mptTester1.pay(gw, gw1, 200); - mpt2.authorize({.account = gw}); - mpt2.pay(gw1, gw, 200); + mptTester2.authorize({.account = gw}); + mptTester2.pay(gw1, gw, 200); - env(offer(alice, MPT2(100), MPT1(100))); + env(offer(alice, mpt2(100), mpt1(100))); env.close(); - BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{MPT2(100), MPT1(100)}}})); + BEAST_EXPECT(expectOffers(env, alice, 1, {{Amounts{mpt2(100), mpt1(100)}}})); - env(pay(carol, bob, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(carol, bob, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(600)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(600)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 200)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 200)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(carol, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 210)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 200)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 190)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 10)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(600)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(600)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 200)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 200)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(carol, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 210)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 200)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 190)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 10)); - env(pay(bob, gw, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(bob, gw, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(590)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(600)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 200)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 200)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 210)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 180)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 20)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(590)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(600)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 200)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 200)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 210)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 180)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 20)); - env(pay(gw, bob, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(gw, bob, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(590)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(600)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 200)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 220)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 170)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 30)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(590)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(600)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 200)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 220)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 170)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 30)); - env(pay(bob, gw1, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(bob, gw1, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(590)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(600)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 210)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 220)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 180)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 160)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 40)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(590)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(600)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 210)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 220)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 180)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 160)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 40)); - env(pay(gw1, bob, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(gw1, bob, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(590)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(610)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 210)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 190)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 230)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(bob, 180)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 150)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 50)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(590)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(610)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 210)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 190)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 230)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(bob, 180)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 150)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 50)); - env(pay(gw, gw1, MPT1(10)), - test::jtx::path(~MPT1), - sendmax(MPT2(10)), - txflags(tfPartialPayment)); + env(pay(gw, gw1, mpt1(10)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(10)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 1)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(590)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(610)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 220)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 180)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 140)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 60)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(590)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(610)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 220)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 180)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 140)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 60)); - env(pay(gw1, gw, MPT1(40)), - test::jtx::path(~MPT1), - sendmax(MPT2(40)), - txflags(tfPartialPayment)); + env(pay(gw1, gw, mpt1(40)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(40)), + Txflags(tfPartialPayment)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); - BEAST_EXPECT(mpt1.checkMPTokenOutstandingAmount(550)); - BEAST_EXPECT(mpt2.checkMPTokenOutstandingAmount(650)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(gw1, 220)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(gw, 180)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(alice, 100)); - BEAST_EXPECT(mpt2.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester1.checkMPTokenOutstandingAmount(550)); + BEAST_EXPECT(mptTester2.checkMPTokenOutstandingAmount(650)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(gw1, 220)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(gw, 180)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester2.checkMPTokenAmount(alice, 100)); } - // MPT/IOU IOU/MPT1 + // MPT/IOU IOU/mpt1 { Env env = pathTestEnv(*this); Account const gw1{"gw1"}; Account const gw2{"gw2"}; Account const dan{"dan"}; env.fund(XRP(1'000), gw2); - auto const USD = gw2["USD"]; + auto const usd = gw2["USD"]; - MPTTester mpt(env, gw, {.holders = {alice, carol}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice, carol}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - MPTTester mpt1(env, gw1, {.holders = {bob, dan}}); - mpt1.create( + MPTTester mptTester1(env, gw1, {.holders = {bob, dan}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; - mpt1.authorize({.account = bob}); - mpt1.pay(gw1, bob, 200); - mpt1.authorize({.account = dan}); + auto const mpt1 = mptTester1["MPT1"]; + mptTester1.authorize({.account = bob}); + mptTester1.pay(gw1, bob, 200); + mptTester1.authorize({.account = dan}); - env(trust(alice, USD(400))); - env(pay(gw2, alice, USD(200))); - env(trust(bob, USD(400))); + env(trust(alice, usd(400))); + env(pay(gw2, alice, usd(200))); + env(trust(bob, usd(400))); - env(offer(alice, MPT(100), USD(100))); - env(offer(bob, USD(100), MPT1(100))); + env(offer(alice, mpt(100), usd(100))); + env(offer(bob, usd(100), mpt1(100))); env.close(); - env(pay(carol, dan, MPT1(100)), - sendmax(MPT(100)), - path(~USD, ~MPT1), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, dan, mpt1(100)), + Sendmax(mpt(100)), + Path(~usd, ~mpt1), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); BEAST_EXPECT(expectOffers(env, alice, 0)); BEAST_EXPECT(expectOffers(env, bob, 0)); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 100)); - BEAST_EXPECT(mpt1.checkMPTokenAmount(dan, 100)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 100)); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(dan, 100)); } // XRP/MPT AMM { Env env{*this, features}; - fund(env, gw, {alice, carol, bob}, XRP(11'000), {USD(20'000)}); + fund(env, gw, {alice, carol, bob}, XRP(11'000), {usd(20'000)}); - MPTTester mpt(env, gw, {.fund = false}); + MPTTester mptTester(env, gw, {.fund = false}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = bob}); - mpt.pay(gw, alice, 10'100); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = bob}); + mptTester.pay(gw, alice, 10'100); - AMM const amm(env, alice, XRP(10'000), MPT(10'100)); + AMM const amm(env, alice, XRP(10'000), mpt(10'100)); - env(pay(carol, bob, MPT(100)), - test::jtx::path(~MPT), - sendmax(XRP(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, mpt(100)), + test::jtx::Path(~mpt), + Sendmax(XRP(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); - BEAST_EXPECT(amm.expectBalances(XRP(10'100), MPT(10'000), amm.tokens())); - BEAST_EXPECT(mpt.checkMPTokenAmount(bob, 100)); + BEAST_EXPECT(amm.expectBalances(XRP(10'100), mpt(10'000), amm.tokens())); + BEAST_EXPECT(mptTester.checkMPTokenAmount(bob, 100)); } // IOU/MPT AMM { Env env{*this, features}; - fund(env, gw, {alice, carol, bob}, XRP(11'000), {USD(20'000)}); + fund(env, gw, {alice, carol, bob}, XRP(11'000), {usd(20'000)}); - MPTTester mpt(env, gw, {.fund = false}); + MPTTester mptTester(env, gw, {.fund = false}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = bob}); - mpt.pay(gw, alice, 10'100); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = bob}); + mptTester.pay(gw, alice, 10'100); - AMM const amm(env, alice, USD(10'000), MPT(10'100)); + AMM const amm(env, alice, usd(10'000), mpt(10'100)); - env(pay(carol, bob, MPT(100)), - test::jtx::path(~MPT), - sendmax(USD(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, mpt(100)), + test::jtx::Path(~mpt), + Sendmax(usd(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); - BEAST_EXPECT(amm.expectBalances(USD(10'100), MPT(10'000), amm.tokens())); - BEAST_EXPECT(mpt.checkMPTokenAmount(bob, 100)); + BEAST_EXPECT(amm.expectBalances(usd(10'100), mpt(10'000), amm.tokens())); + BEAST_EXPECT(mptTester.checkMPTokenAmount(bob, 100)); } // MPT/MPT AMM cross-asset payment @@ -4950,123 +4950,123 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(20'000), gw, alice, carol, bob); env.close(); - MPTTester mpt1(env, gw, {.fund = false}); - mpt1.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; - mpt1.authorize({.account = alice}); - mpt1.authorize({.account = bob}); - mpt1.pay(gw, alice, 10'100); + MPTTester mptTester1(env, gw, {.fund = false}); + mptTester1.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt1 = mptTester1["MPT1"]; + mptTester1.authorize({.account = alice}); + mptTester1.authorize({.account = bob}); + mptTester1.pay(gw, alice, 10'100); - MPTTester mpt2(env, gw, {.fund = false}); - mpt2.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT1"]; - mpt2.authorize({.account = alice}); - mpt2.authorize({.account = bob}); - mpt2.authorize({.account = carol}); - mpt2.pay(gw, alice, 10'100); - mpt2.pay(gw, carol, 100); + MPTTester mptTester2(env, gw, {.fund = false}); + mptTester2.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt2 = mptTester2["MPT1"]; + mptTester2.authorize({.account = alice}); + mptTester2.authorize({.account = bob}); + mptTester2.authorize({.account = carol}); + mptTester2.pay(gw, alice, 10'100); + mptTester2.pay(gw, carol, 100); - AMM const amm(env, alice, MPT2(10'000), MPT1(10'100)); + AMM const amm(env, alice, mpt2(10'000), mpt1(10'100)); - env(pay(carol, bob, MPT1(100)), - test::jtx::path(~MPT1), - sendmax(MPT2(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, mpt1(100)), + test::jtx::Path(~mpt1), + Sendmax(mpt2(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); - BEAST_EXPECT(amm.expectBalances(MPT2(10'100), MPT1(10'000), amm.tokens())); - BEAST_EXPECT(mpt1.checkMPTokenAmount(bob, 100)); + BEAST_EXPECT(amm.expectBalances(mpt2(10'100), mpt1(10'000), amm.tokens())); + BEAST_EXPECT(mptTester1.checkMPTokenAmount(bob, 100)); } // Multi-steps with AMM // EUR/MPT1 MPT1/MPT2 MPT2/USD USD/CRN AMM:CRN/MPT MPT/YAN { Env env{*this, features}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; - auto const CRN = gw["CRN"]; - auto const YAN = gw["YAN"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; + auto const crn = gw["CRN"]; + auto const yan = gw["YAN"]; fund( env, gw, {alice, carol, bob}, XRP(1'000), - {USD(1'000), EUR(1'000), CRN(2'000), YAN(1'000)}); + {usd(1'000), eur(1'000), crn(2'000), yan(1'000)}); auto createMPT = [&]() -> std::pair { - MPTTester mpt(env, gw, {.fund = false}); - mpt.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 2'000); - return {mpt, mpt["MPT"]}; + MPTTester mptTester(env, gw, {.fund = false}); + mptTester.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 2'000); + return {mptTester, mptTester["MPT"]}; }; - auto const [mpt1, MPT1] = createMPT(); - auto const [mpt2, MPT2] = createMPT(); - auto const [mpt3, MPT3] = createMPT(); + auto const [mptTester1, mpt1] = createMPT(); + auto const [mptTester2, mpt2] = createMPT(); + auto const [mptTester3, mpt3] = createMPT(); - env(offer(alice, EUR(100), MPT1(101))); - env(offer(alice, MPT1(101), MPT2(102))); - env(offer(alice, MPT2(102), USD(103))); - env(offer(alice, USD(103), CRN(104))); + env(offer(alice, eur(100), mpt1(101))); + env(offer(alice, mpt1(101), mpt2(102))); + env(offer(alice, mpt2(102), usd(103))); + env(offer(alice, usd(103), crn(104))); env.close(); - AMM const amm(env, alice, CRN(1'000), MPT3(1'104)); - env(offer(alice, MPT3(104), YAN(100))); + AMM const amm(env, alice, crn(1'000), mpt3(1'104)); + env(offer(alice, mpt3(104), yan(100))); - env(pay(carol, bob, YAN(100)), - test::jtx::path(~MPT1, ~MPT2, ~USD, ~CRN, ~MPT3, ~YAN), - sendmax(EUR(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, yan(100)), + test::jtx::Path(~mpt1, ~mpt2, ~usd, ~crn, ~mpt3, ~yan), + Sendmax(eur(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); - BEAST_EXPECT(env.balance(carol, EUR) == EUR(900)); - BEAST_EXPECT(env.balance(bob, YAN) == YAN(1'100)); - BEAST_EXPECT(amm.expectBalances(CRN(1'104), MPT3(1'000), amm.tokens())); + BEAST_EXPECT(env.balance(carol, eur) == eur(900)); + BEAST_EXPECT(env.balance(bob, yan) == yan(1'100)); + BEAST_EXPECT(amm.expectBalances(crn(1'104), mpt3(1'000), amm.tokens())); BEAST_EXPECT(expectOffers(env, alice, 0)); } // Multi-steps with AMM and MPT endpoints - // MPT1/EUR EUR/MPT2 MPT2/USD USD/CRN AMM:CRN/MPT3 MPT3/MPT4 + // mpt1/EUR EUR/mpt2 mpt2/USD USD/CRN AMM:CRN/MPT3 MPT3/MPT4 { Env env{*this, features}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; - auto const CRN = gw["CRN"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; + auto const crn = gw["CRN"]; - fund(env, gw, {alice, carol, bob}, XRP(1'000), {USD(1'000), EUR(1'000), CRN(2'000)}); + fund(env, gw, {alice, carol, bob}, XRP(1'000), {usd(1'000), eur(1'000), crn(2'000)}); auto createMPT = [&]() -> std::pair { - MPTTester mpt(env, gw, {.fund = false}); - mpt.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 2'000); - return {mpt, mpt["MPT"]}; + MPTTester mptTester(env, gw, {.fund = false}); + mptTester.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 2'000); + return {mptTester, mptTester["MPT"]}; }; - auto const [mpt1, MPT1] = createMPT(); - auto const [mpt2, MPT2] = createMPT(); - auto const [mpt3, MPT3] = createMPT(); - auto [mpt4, MPT4] = createMPT(); - mpt4.authorize({.account = bob}); + auto const [mptTester1, mpt1] = createMPT(); + auto const [mptTester2, mpt2] = createMPT(); + auto const [mptTester3, mpt3] = createMPT(); + auto [mptTester4, mpt4] = createMPT(); + mptTester4.authorize({.account = bob}); - env(offer(alice, EUR(100), MPT1(101))); - env(offer(alice, MPT1(101), MPT2(102))); - env(offer(alice, MPT2(102), USD(103))); - env(offer(alice, USD(103), CRN(104))); + env(offer(alice, eur(100), mpt1(101))); + env(offer(alice, mpt1(101), mpt2(102))); + env(offer(alice, mpt2(102), usd(103))); + env(offer(alice, usd(103), crn(104))); env.close(); - AMM const amm(env, alice, CRN(1'000), MPT3(1'104)); - env(offer(alice, MPT3(104), MPT4(100))); + AMM const amm(env, alice, crn(1'000), mpt3(1'104)); + env(offer(alice, mpt3(104), mpt4(100))); - env(pay(carol, bob, MPT4(100)), - test::jtx::path(~MPT1, ~MPT2, ~USD, ~CRN, ~MPT3, ~MPT4), - sendmax(EUR(100)), - txflags(tfPartialPayment | tfNoRippleDirect)); + env(pay(carol, bob, mpt4(100)), + test::jtx::Path(~mpt1, ~mpt2, ~usd, ~crn, ~mpt3, ~mpt4), + Sendmax(eur(100)), + Txflags(tfPartialPayment | tfNoRippleDirect)); env.close(); - BEAST_EXPECT(env.balance(carol, EUR) == EUR(900)); - BEAST_EXPECT(mpt4.checkMPTokenAmount(bob, 100)); - BEAST_EXPECT(amm.expectBalances(CRN(1'104), MPT3(1'000), amm.tokens())); + BEAST_EXPECT(env.balance(carol, eur) == eur(900)); + BEAST_EXPECT(mptTester4.checkMPTokenAmount(bob, 100)); + BEAST_EXPECT(amm.expectBalances(crn(1'104), mpt3(1'000), amm.tokens())); BEAST_EXPECT(expectOffers(env, alice, 0)); } @@ -5077,73 +5077,73 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol, bob); - MPTTester usd(env, gw, {.holders = {alice, carol, bob}, .fund = false}); - usd.create( + MPTTester usdTester(env, gw, {.holders = {alice, carol, bob}, .fund = false}); + usdTester.create( {.maxAmt = 1'000, - .authorize = MPTCreate::AllHolders, + .authorize = MPTCreate::allHolders, .pay = {{{alice}, 1'000}}, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const USD = usd["USD"]; + auto const usd = usdTester["USD"]; - MPTTester eur(env, gw, {.holders = {alice, carol, bob}, .fund = false}); - eur.create( + MPTTester eurTester(env, gw, {.holders = {alice, carol, bob}, .fund = false}); + eurTester.create( {.maxAmt = 1'000, .authorize = {{alice, carol}}, .pay = {{{carol}, 100}}, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const EUR = eur["EUR"]; + auto const eur = eurTester["EUR"]; - env(offer(alice, EUR(10), USD(10))); + env(offer(alice, eur(10), usd(10))); - env(pay(carol, bob, USD(10)), - sendmax(EUR(10)), - path(~USD), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, bob, usd(10)), + Sendmax(eur(10)), + Path(~usd), + Txflags(tfNoRippleDirect | tfPartialPayment)); } { - Env env(*this, features); + Env env(*this, features); // NOLINT TODO env.fund(XRP(1'000), gw, alice, carol, bob); - auto MUSD = MPTTester( + auto musd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .maxAmt = 1'000}); - MPT const USD = MUSD; - env(pay(gw, alice, USD(800))); - env(offer(gw, XRP(300), USD(300))); - env(pay(carol, bob, USD(300)), - sendmax(XRP(300)), - path(~USD), - txflags(tfPartialPayment)); - BEAST_EXPECT(MUSD.checkMPTokenAmount(bob, 200)); - BEAST_EXPECT(MUSD.checkMPTokenOutstandingAmount(1'000)); + MPT const usd = musd; + env(pay(gw, alice, usd(800))); + env(offer(gw, XRP(300), usd(300))); + env(pay(carol, bob, usd(300)), + Sendmax(XRP(300)), + Path(~usd), + Txflags(tfPartialPayment)); + BEAST_EXPECT(musd.checkMPTokenAmount(bob, 200)); + BEAST_EXPECT(musd.checkMPTokenOutstandingAmount(1'000)); // initial + offer - fees - BEAST_EXPECT(env.balance(gw) == (XRP(1'000) + XRP(200) - txfee(env, 3))); + BEAST_EXPECT(env.balance(gw) == (XRP(1'000) + XRP(200) - txFee(env, 3))); } { Env env(*this, features); - auto const EUR = gw["EUR"]; + auto const eur = gw["EUR"]; env.fund(XRP(1'000), gw, alice, carol, bob); env.close(); - env(trust(alice, EUR(1'000))); - env(pay(gw, alice, EUR(300))); - env(trust(bob, EUR(1'000))); + env(trust(alice, eur(1'000))); + env(pay(gw, alice, eur(300))); + env(trust(bob, eur(1'000))); - auto MUSD = MPTTester( + auto musd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol, bob}, .maxAmt = 1'000}); - MPT const USD = MUSD; + MPT const usd = musd; - env(pay(gw, alice, USD(800))); - env(offer(gw, XRP(300), USD(300))); - env(offer(alice, USD(300), EUR(300))); - env(pay(carol, bob, EUR(300)), - sendmax(XRP(300)), - path(~USD, ~EUR), - txflags(tfPartialPayment)); - BEAST_EXPECT(MUSD.checkMPTokenAmount(alice, 1'000)); - BEAST_EXPECT(MUSD.checkMPTokenOutstandingAmount(1'000)); + env(pay(gw, alice, usd(800))); + env(offer(gw, XRP(300), usd(300))); + env(offer(alice, usd(300), eur(300))); + env(pay(carol, bob, eur(300)), + Sendmax(XRP(300)), + Path(~usd, ~eur), + Txflags(tfPartialPayment)); + BEAST_EXPECT(musd.checkMPTokenAmount(alice, 1'000)); + BEAST_EXPECT(musd.checkMPTokenOutstandingAmount(1'000)); // initial + offer - fees - BEAST_EXPECT(env.balance(gw) == (XRP(1'000) + XRP(200) - txfee(env, 4))); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(200)); + BEAST_EXPECT(env.balance(gw) == (XRP(1'000) + XRP(200) - txFee(env, 4))); + BEAST_EXPECT(env.balance(bob, eur) == eur(200)); } } @@ -5158,8 +5158,8 @@ class MPToken_test : public beast::unit_test::suite Account const carol{"carol"}; Account const bob{"bob"}; Account const dan{"dan"}; - auto const USD = gw["USD"]; - auto const EUR = gw1["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw1["EUR"]; // MPT can be a mpt end point step or a book-step @@ -5167,17 +5167,17 @@ class MPToken_test : public beast::unit_test::suite { Env env = pathTestEnv(*this); - MPTTester mpt(env, gw, {.holders = {dan, carol}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {dan, carol}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = dan}); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = dan}); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - auto const [pathSet, srcAmt, dstAmt] = find_paths(env, carol, dan, MPT(-1)); - BEAST_EXPECT(srcAmt == MPT(200)); - BEAST_EXPECT(dstAmt == MPT(200)); + auto const [pathSet, srcAmt, dstAmt] = findPaths(env, carol, dan, mpt(-1)); + BEAST_EXPECT(srcAmt == mpt(200)); + BEAST_EXPECT(dstAmt == mpt(200)); // Direct payment, no path BEAST_EXPECT(pathSet.empty()); } @@ -5188,29 +5188,29 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), carol); - MPTTester mpt(env, gw, {.holders = {alice, dan}}); + MPTTester mptTester(env, gw, {.holders = {alice, dan}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = dan}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = dan}); + mptTester.pay(gw, alice, 200); - env(offer(alice, XRP(100), MPT(100))); + env(offer(alice, XRP(100), mpt(100))); env.close(); - auto const [pathSet, srcAmt, dstAmt] = find_paths(env, carol, dan, MPT(-1)); + auto const [pathSet, srcAmt, dstAmt] = findPaths(env, carol, dan, mpt(-1)); BEAST_EXPECT(srcAmt == XRP(100)); - BEAST_EXPECT(dstAmt == MPT(100)); - if (BEAST_EXPECT(same(pathSet, stpath(IPE(mpt.issuanceID()))))) + BEAST_EXPECT(dstAmt == mpt(100)); + if (BEAST_EXPECT(same(pathSet, stpath(ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(~MPT), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(~mpt), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5221,66 +5221,67 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), carol); env.fund(XRP(1'000), gw); - MPTTester mpt(env, gw1, {.holders = {alice, dan}}); + MPTTester mptTester(env, gw1, {.holders = {alice, dan}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = dan}); - mpt.pay(gw1, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = dan}); + mptTester.pay(gw1, alice, 200); - env(trust(alice, USD(400))); - env(trust(carol, USD(400))); - env(pay(gw, carol, USD(200))); + env(trust(alice, usd(400))); + env(trust(carol, usd(400))); + env(pay(gw, carol, usd(200))); - env(offer(alice, USD(100), MPT(100))); + env(offer(alice, usd(100), mpt(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT(-1)); - BEAST_EXPECT(srcAmt == USD(100)); - BEAST_EXPECT(dstAmt == MPT(100)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt(-1)); + BEAST_EXPECT(srcAmt == usd(100)); + BEAST_EXPECT(dstAmt == mpt(100)); if (BEAST_EXPECT( - pathSet.size() == 1 && same(pathSet, stpath(gw, IPE(mpt.issuanceID()))))) + pathSet.size() == 1 && same(pathSet, stpath(gw, ipe(mptTester.issuanceID()))))) { // Validate the payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(USD(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(usd(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT(-1), USD(-1)); - BEAST_EXPECT(srcAmt == USD(90)); - BEAST_EXPECT(dstAmt == MPT(90)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()))))) + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt(-1), usd(-1)); + BEAST_EXPECT(srcAmt == usd(90)); + BEAST_EXPECT(dstAmt == mpt(90)); + if (BEAST_EXPECT( + pathSet.size() == 1 && same(pathSet, stpath(ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(USD(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(usd(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include source token std::tie(pathSet, srcAmt, dstAmt) = - find_paths(env, carol, dan, MPT(-1), std::nullopt, USD.currency); - BEAST_EXPECT(srcAmt == USD(80)); - BEAST_EXPECT(dstAmt == MPT(80)); + findPaths(env, carol, dan, mpt(-1), std::nullopt, usd.currency); + BEAST_EXPECT(srcAmt == usd(80)); + BEAST_EXPECT(dstAmt == mpt(80)); if (BEAST_EXPECT( - pathSet.size() == 1 && same(pathSet, stpath(gw, IPE(mpt.issuanceID()))))) + pathSet.size() == 1 && same(pathSet, stpath(gw, ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(USD(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(usd(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5291,133 +5292,136 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), dan); env.fund(XRP(1'000), gw); - MPTTester mpt(env, gw1, {.holders = {carol, alice}}); + MPTTester mptTester(env, gw1, {.holders = {carol, alice}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = carol}); - mpt.authorize({.account = alice}); - mpt.pay(gw1, carol, 200); + mptTester.authorize({.account = carol}); + mptTester.authorize({.account = alice}); + mptTester.pay(gw1, carol, 200); - env(trust(dan, USD(400))); - env(trust(alice, USD(400))); - env(pay(gw, alice, USD(200))); + env(trust(dan, usd(400))); + env(trust(alice, usd(400))); + env(pay(gw, alice, usd(200))); - env(offer(alice, MPT(100), USD(100))); + env(offer(alice, mpt(100), usd(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, USD(-1)); - BEAST_EXPECT(srcAmt == MPT(100)); - BEAST_EXPECT(dstAmt == USD(100)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(USD))))) + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, usd(-1)); + BEAST_EXPECT(srcAmt == mpt(100)); + BEAST_EXPECT(dstAmt == usd(100)); + if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(ipe(usd))))) { // Validate the payment works with the path - env(pay(carol, dan, USD(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, usd(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, USD(-1), MPT(-1)); - BEAST_EXPECT(srcAmt == MPT(90)); - BEAST_EXPECT(dstAmt == USD(90)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(USD))))) + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, usd(-1), mpt(-1)); + BEAST_EXPECT(srcAmt == mpt(90)); + BEAST_EXPECT(dstAmt == usd(90)); + if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(ipe(usd))))) { // validate a payment works with the path - env(pay(carol, dan, USD(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, usd(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include source token std::tie(pathSet, srcAmt, dstAmt) = - find_paths(env, carol, dan, USD(-1), std::nullopt, MPT.mpt()); - BEAST_EXPECT(srcAmt == MPT(80)); - BEAST_EXPECT(dstAmt == USD(80)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(USD))))) + findPaths(env, carol, dan, usd(-1), std::nullopt, mpt.mpt()); + BEAST_EXPECT(srcAmt == mpt(80)); + BEAST_EXPECT(dstAmt == usd(80)); + if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(ipe(usd))))) { // validate a payment works with the path - env(pay(carol, dan, USD(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, usd(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } - // Cross-asset payment via MPT1/MPT offer (one step) + // Cross-asset payment via mpt1/MPT offer (one step) { Env env = pathTestEnv(*this); - MPTTester mpt(env, gw, {.holders = {alice, dan}}); - MPTTester mpt1(env, gw1, {.holders = {carol}}); + MPTTester mptTester(env, gw, {.holders = {alice, dan}}); + MPTTester mptTester1(env, gw1, {.holders = {carol}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt1.create( + auto const mpt = mptTester["MPT"]; + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; + auto const mpt1 = mptTester1["MPT1"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = dan}); - mpt.pay(gw, alice, 200); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = dan}); + mptTester.pay(gw, alice, 200); - mpt1.authorize({.account = carol}); - mpt1.authorize({.account = alice}); - mpt1.pay(gw1, carol, 200); + mptTester1.authorize({.account = carol}); + mptTester1.authorize({.account = alice}); + mptTester1.pay(gw1, carol, 200); - env(offer(alice, MPT1(100), MPT(100))); + env(offer(alice, mpt1(100), mpt(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT(-1)); - BEAST_EXPECT(srcAmt == MPT1(100)); - BEAST_EXPECT(dstAmt == MPT(100)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()))))) + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt(-1)); + BEAST_EXPECT(srcAmt == mpt1(100)); + BEAST_EXPECT(dstAmt == mpt(100)); + if (BEAST_EXPECT( + pathSet.size() == 1 && same(pathSet, stpath(ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(MPT1(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(mpt1(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT(-1), MPT1(-1)); - BEAST_EXPECT(srcAmt == MPT1(90)); - BEAST_EXPECT(dstAmt == MPT(90)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()))))) + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt(-1), mpt1(-1)); + BEAST_EXPECT(srcAmt == mpt1(90)); + BEAST_EXPECT(dstAmt == mpt(90)); + if (BEAST_EXPECT( + pathSet.size() == 1 && same(pathSet, stpath(ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(MPT1(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(mpt1(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include source token std::tie(pathSet, srcAmt, dstAmt) = - find_paths(env, carol, dan, MPT(-1), std::nullopt, MPT1.mpt()); - BEAST_EXPECT(srcAmt == MPT1(80)); - BEAST_EXPECT(dstAmt == MPT(80)); - if (BEAST_EXPECT(pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()))))) + findPaths(env, carol, dan, mpt(-1), std::nullopt, mpt1.mpt()); + BEAST_EXPECT(srcAmt == mpt1(80)); + BEAST_EXPECT(dstAmt == mpt(80)); + if (BEAST_EXPECT( + pathSet.size() == 1 && same(pathSet, stpath(ipe(mptTester.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT(10)), - path(pathSet[0]), - sendmax(MPT1(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt(10)), + Path(pathSet[0]), + Sendmax(mpt1(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5428,55 +5432,57 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), carol); env.fund(XRP(1'000), dan); - MPTTester mpt(env, gw, {.holders = {alice, bob}}); + MPTTester mptTester(env, gw, {.holders = {alice, bob}}); - mpt.create( + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = bob}); - mpt.pay(gw, alice, 200); - mpt.pay(gw, bob, 200); + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = bob}); + mptTester.pay(gw, alice, 200); + mptTester.pay(gw, bob, 200); - env(trust(bob, USD(200))); - env(pay(gw, bob, USD(100))); - env(trust(dan, USD(200))); - env(trust(alice, USD(200))); + env(trust(bob, usd(200))); + env(pay(gw, bob, usd(100))); + env(trust(dan, usd(200))); + env(trust(alice, usd(200))); - env(offer(alice, XRP(100), MPT(100))); - env(offer(bob, MPT(100), USD(100))); + env(offer(alice, XRP(100), mpt(100))); + env(offer(bob, mpt(100), usd(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, USD(-1)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, usd(-1)); BEAST_EXPECT(srcAmt == XRP(100)); - BEAST_EXPECT(dstAmt == USD(100)); + BEAST_EXPECT(dstAmt == usd(100)); if (BEAST_EXPECT( - pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()), IPE(USD))))) + pathSet.size() == 1 && + same(pathSet, stpath(ipe(mptTester.issuanceID()), ipe(usd))))) { // validate a payment works with the path - env(pay(carol, dan, USD(10)), - path(pathSet[0]), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, usd(10)), + Path(pathSet[0]), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, USD(-1), XRP(100)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, usd(-1), XRP(100)); BEAST_EXPECT(srcAmt == XRP(90)); - BEAST_EXPECT(dstAmt == USD(90)); + BEAST_EXPECT(dstAmt == usd(90)); if (BEAST_EXPECT( - pathSet.size() == 1 && same(pathSet, stpath(IPE(mpt.issuanceID()), IPE(USD))))) + pathSet.size() == 1 && + same(pathSet, stpath(ipe(mptTester.issuanceID()), ipe(usd))))) { // validate a payment works with the path - env(pay(carol, dan, USD(10)), - path(pathSet[0]), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, usd(10)), + Path(pathSet[0]), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5486,79 +5492,79 @@ class MPToken_test : public beast::unit_test::suite Env env = pathTestEnv(*this); Account const gw2{"gw2"}; env.fund(XRP(1'000), gw2); - auto const USD2 = gw2["USD"]; + auto const usd2 = gw2["USD"]; - MPTTester mpt(env, gw, {.holders = {alice, carol}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice, carol}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - MPTTester mpt1(env, gw1, {.holders = {bob, dan}}); - mpt1.create( + MPTTester mptTester1(env, gw1, {.holders = {bob, dan}}); + mptTester1.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; - mpt1.authorize({.account = bob}); - mpt1.pay(gw1, bob, 200); - mpt1.authorize({.account = dan}); + auto const mpt1 = mptTester1["MPT1"]; + mptTester1.authorize({.account = bob}); + mptTester1.pay(gw1, bob, 200); + mptTester1.authorize({.account = dan}); - env(trust(alice, USD2(400))); - env(pay(gw2, alice, USD2(200))); - env(trust(bob, USD2(400))); + env(trust(alice, usd2(400))); + env(pay(gw2, alice, usd2(200))); + env(trust(bob, usd2(400))); - env(offer(alice, MPT(100), USD2(100))); - env(offer(bob, USD2(100), MPT1(100))); + env(offer(alice, mpt(100), usd2(100))); + env(offer(bob, usd2(100), mpt1(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT1(-1)); - BEAST_EXPECT(srcAmt == MPT(100)); - BEAST_EXPECT(dstAmt == MPT1(100)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt1(-1)); + BEAST_EXPECT(srcAmt == mpt(100)); + BEAST_EXPECT(dstAmt == mpt1(100)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(USD2), IPE(mpt1.issuanceID()))))) + same(pathSet, stpath(ipe(usd2), ipe(mptTester1.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT1(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt1(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT1(-1), MPT(-1)); - BEAST_EXPECT(srcAmt == MPT(90)); - BEAST_EXPECT(dstAmt == MPT1(90)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt1(-1), mpt(-1)); + BEAST_EXPECT(srcAmt == mpt(90)); + BEAST_EXPECT(dstAmt == mpt1(90)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(USD2), IPE(mpt1.issuanceID()))))) + same(pathSet, stpath(ipe(usd2), ipe(mptTester1.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT1(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt1(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include source token std::tie(pathSet, srcAmt, dstAmt) = - find_paths(env, carol, dan, MPT1(-1), std::nullopt, MPT.mpt()); - BEAST_EXPECT(srcAmt == MPT(80)); - BEAST_EXPECT(dstAmt == MPT1(80)); + findPaths(env, carol, dan, mpt1(-1), std::nullopt, mpt.mpt()); + BEAST_EXPECT(srcAmt == mpt(80)); + BEAST_EXPECT(dstAmt == mpt1(80)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(USD2), IPE(mpt1.issuanceID()))))) + same(pathSet, stpath(ipe(usd2), ipe(mptTester1.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT1(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt1(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5570,79 +5576,85 @@ class MPToken_test : public beast::unit_test::suite Account const gw2{"gw2"}; env.fund(XRP(1'000), gw, gw1, gw2, alice, bob, carol, dan); - MPTTester mpt(env, gw, {.holders = {alice, carol}, .fund = false}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice, carol}, .fund = false}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = carol}); - mpt.pay(gw, carol, 200); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, carol, 200); - MPTTester mpt1(env, gw1, {.holders = {bob, alice}, .fund = false}); - mpt1.create({.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; - mpt1.authorize({.account = alice}); - mpt1.pay(gw1, alice, 200); - mpt1.authorize({.account = bob}); + MPTTester mptTester1(env, gw1, {.holders = {bob, alice}, .fund = false}); + mptTester1.create({.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt1 = mptTester1["MPT1"]; + mptTester1.authorize({.account = alice}); + mptTester1.pay(gw1, alice, 200); + mptTester1.authorize({.account = bob}); - MPTTester mpt2(env, gw2, {.holders = {bob, dan}, .fund = false}); - mpt2.create({.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT2 = mpt2["MPT2"]; - mpt2.authorize({.account = bob}); - mpt2.pay(gw2, bob, 200); - mpt2.authorize({.account = dan}); + MPTTester mptTester2(env, gw2, {.holders = {bob, dan}, .fund = false}); + mptTester2.create({.ownerCount = 1, .flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt2 = mptTester2["MPT2"]; + mptTester2.authorize({.account = bob}); + mptTester2.pay(gw2, bob, 200); + mptTester2.authorize({.account = dan}); - env(offer(alice, MPT(100), MPT1(100))); - env(offer(bob, MPT1(100), MPT2(100))); + env(offer(alice, mpt(100), mpt1(100))); + env(offer(bob, mpt1(100), mpt2(100))); env.close(); // No sendMax STPathSet pathSet; STAmount srcAmt; STAmount dstAmt; - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT2(-1)); - BEAST_EXPECT(srcAmt == MPT(100)); - BEAST_EXPECT(dstAmt == MPT2(100)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt2(-1)); + BEAST_EXPECT(srcAmt == mpt(100)); + BEAST_EXPECT(dstAmt == mpt2(100)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(mpt1.issuanceID()), IPE(mpt2.issuanceID()))))) + same( + pathSet, + stpath(ipe(mptTester1.issuanceID()), ipe(mptTester2.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT2(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt2(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include sendMax - std::tie(pathSet, srcAmt, dstAmt) = find_paths(env, carol, dan, MPT2(-1), MPT(-1)); - BEAST_EXPECT(srcAmt == MPT(90)); - BEAST_EXPECT(dstAmt == MPT2(90)); + std::tie(pathSet, srcAmt, dstAmt) = findPaths(env, carol, dan, mpt2(-1), mpt(-1)); + BEAST_EXPECT(srcAmt == mpt(90)); + BEAST_EXPECT(dstAmt == mpt2(90)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(mpt1.issuanceID()), IPE(mpt2.issuanceID()))))) + same( + pathSet, + stpath(ipe(mptTester1.issuanceID()), ipe(mptTester2.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT2(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt2(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } // Include source token std::tie(pathSet, srcAmt, dstAmt) = - find_paths(env, carol, dan, MPT2(-1), std::nullopt, MPT.mpt()); - BEAST_EXPECT(srcAmt == MPT(80)); - BEAST_EXPECT(dstAmt == MPT2(80)); + findPaths(env, carol, dan, mpt2(-1), std::nullopt, mpt.mpt()); + BEAST_EXPECT(srcAmt == mpt(80)); + BEAST_EXPECT(dstAmt == mpt2(80)); if (BEAST_EXPECT( pathSet.size() == 1 && - same(pathSet, stpath(IPE(mpt1.issuanceID()), IPE(mpt2.issuanceID()))))) + same( + pathSet, + stpath(ipe(mptTester1.issuanceID()), ipe(mptTester2.issuanceID()))))) { // validate a payment works with the path - env(pay(carol, dan, MPT2(10)), - path(pathSet[0]), - sendmax(MPT(10)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(carol, dan, mpt2(10)), + Path(pathSet[0]), + Sendmax(mpt(10)), + Txflags(tfNoRippleDirect | tfPartialPayment)); } } @@ -5666,39 +5678,39 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000'000), sean); env.close(); - MPTTester usd(env, gw, {.holders = {carol, dan}, .fund = false}); - usd.create( - {.authorize = MPTCreate::AllHolders, - .pay = {{MPTCreate::AllHolders, 100}}, + MPTTester usdTester(env, gw, {.holders = {carol, dan}, .fund = false}); + usdTester.create( + {.authorize = MPTCreate::allHolders, + .pay = {{MPTCreate::allHolders, 100}}, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const USD = usd["USD"]; - env(offer(carol, XRP(100), USD(100))); + auto const usd = usdTester["USD"]; + env(offer(carol, XRP(100), usd(100))); - MPTTester gbp(env, gw, {.holders = {bob, sean}, .fund = false}); - gbp.create( - {.authorize = MPTCreate::AllHolders, + MPTTester gbpTester(env, gw, {.holders = {bob, sean}, .fund = false}); + gbpTester.create( + {.authorize = MPTCreate::allHolders, .pay = {{{bob}, 100}}, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const GBP = gbp["GBP"]; + auto const gbp = gbpTester["GBP"]; MPTTester usd1(env, gw1, {.holders = {bob, dan}, .fund = false}); usd1.create( - {.authorize = MPTCreate::AllHolders, + {.authorize = MPTCreate::allHolders, .pay = {{{dan}, 100}}, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const USD1 = usd1["USD1"]; - env(offer(bob, USD1(100), GBP(100))); + auto const usD1 = usd1["USD1"]; + env(offer(bob, usd1(100), gbp(100))); // dan has USD/gw and USD1/gw. Had USD been IOU, it would have // been able to ripple through dan's account. - auto const [pathSet, srcAmt, dstAmt] = find_paths(env, john, sean, GBP(-1), XRP(-1)); + auto const [pathSet, srcAmt, dstAmt] = findPaths(env, john, sean, gbp(-1), XRP(-1)); BEAST_EXPECT(pathSet.empty()); - env(pay(john, sean, GBP(10)), - sendmax(XRP(20)), - path(~USD, dan, gw1, ~GBP), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(temBAD_PATH)); + env(pay(john, sean, gbp(10)), + Sendmax(XRP(20)), + Path(~usd, dan, gw1, ~gbp), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(temBAD_PATH)); } } @@ -5716,18 +5728,18 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features - featureMPTokensV2}; - MPTTester mpt(env, gw, {.holders = {alice}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); uint256 const checkId{keylet::check(gw, env.seq(gw)).key}; - env(check::create(gw, alice, MPT(100)), ter(temDISABLED)); + env(check::create(gw, alice, mpt(100)), Ter(temDISABLED)); env.close(); - env(check::cash(alice, checkId, MPT(100)), ter(temDISABLED)); + env(check::cash(alice, checkId, mpt(100)), Ter(temDISABLED)); env.close(); } @@ -5736,69 +5748,69 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; Account const carol{"carol"}; - MPTTester mpt(env, gw, {.holders = {alice, carol}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice, carol}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 50); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 50); uint256 const checkId{keylet::check(alice, env.seq(alice)).key}; // can create - env(check::create(alice, carol, MPT(100))); + env(check::create(alice, carol, mpt(100))); env.close(); // can't cash since alice only has 50 of MPT - env(check::cash(carol, checkId, MPT(100)), ter(tecPATH_PARTIAL)); + env(check::cash(carol, checkId, mpt(100)), Ter(tecPATH_PARTIAL)); env.close(); // can cash if DeliverMin is set // carol is not authorized, MPToken is authorized by CheckCash - env(check::cash(carol, checkId, check::DeliverMin(MPT(50)))); + env(check::cash(carol, checkId, check::DeliverMin(mpt(50)))); env.close(); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 50)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(50)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 50)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(50)); } // Exceed max amount { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice}}); + mptTester.create( {.maxAmt = 100, .ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; uint256 const checkId{keylet::check(gw, env.seq(gw)).key}; // can create - env(check::create(gw, alice, MPT(200))); + env(check::create(gw, alice, mpt(200))); env.close(); // can't cash since the outstanding amount exceeds max amount - env(check::cash(alice, checkId, MPT(200)), ter(tecPATH_PARTIAL)); + env(check::cash(alice, checkId, mpt(200)), Ter(tecPATH_PARTIAL)); env.close(); // can cash if DeliverMin is set - env(check::cash(alice, checkId, check::DeliverMin(MPT(100)))); + env(check::cash(alice, checkId, check::DeliverMin(mpt(100)))); env.close(); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 100)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(100)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(100)); } // MPTokenIssuance object doesn't exist { Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - env(check::create(alice, carol, MPT(gw)(50)), ter(tecOBJECT_NOT_FOUND)); + env(check::create(alice, carol, MPT(gw)(50)), Ter(tecOBJECT_NOT_FOUND)); env.close(); - auto BTC = MPTTester({.env = env, .issuer = gw}); + auto btc = MPTTester({.env = env, .issuer = gw}); uint256 const chkId{getCheckIndex(gw, env.seq(gw))}; - env(check::cash(carol, chkId, MPT(gw)(1)), ter(tecNO_ENTRY)); + env(check::cash(carol, chkId, MPT(gw)(1)), Ter(tecNO_ENTRY)); env.close(); } @@ -5807,13 +5819,13 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto BTC = MPTTester({.env = env, .issuer = gw}); + auto btc = MPTTester({.env = env, .issuer = gw}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, carol, BTC(50))); + env(check::create(alice, carol, btc(50))); env.close(); // But cashing fails if alice doesn't have MPToken - env(check::cash(carol, chkId, BTC(1)), ter(tecPATH_PARTIAL)); + env(check::cash(carol, chkId, btc(1)), Ter(tecPATH_PARTIAL)); env.close(); } @@ -5827,14 +5839,14 @@ class MPToken_test : public beast::unit_test::suite .issuer = gw, .holders = {alice, carol}, .pay = 100, - .flags = MPTDEXFlags | tfMPTCanLock}); + .flags = kMPT_DEX_FLAGS | tfMPTCanLock}); mpt.set({.flags = tfMPTLock}); // Create Check fails, holder or issuer as destination - env(check::create(alice, carol, mpt(10)), ter(tecLOCKED)); + env(check::create(alice, carol, mpt(10)), Ter(tecLOCKED)); env.close(); - env(check::create(gw, carol, mpt(10)), ter(tecLOCKED)); + env(check::create(gw, carol, mpt(10)), Ter(tecLOCKED)); env.close(); mpt.set({.flags = tfMPTUnlock}); @@ -5852,7 +5864,7 @@ class MPToken_test : public beast::unit_test::suite // Cash Check fails, holder and issuer env(check::cash(carol, // chkIdAlice, mpt(1)), ter(tecPATH_PARTIAL)); // tec is different // if the source is the issuer (this is consistent with IOU) - env(check::cash(carol, chkIdGw, mpt(2)), ter(tecLOCKED)); + env(check::cash(carol, chkIdGw, mpt(2)), Ter(tecLOCKED)); env.close(); mpt.set({.flags = tfMPTUnlock}); @@ -5863,9 +5875,9 @@ class MPToken_test : public beast::unit_test::suite // Individual lock mpt.set({.holder = alice, .flags = tfMPTLock}); - env(check::create(alice, carol, mpt(10)), ter(tecLOCKED)); + env(check::create(alice, carol, mpt(10)), Ter(tecLOCKED)); env.close(); - env(check::create(carol, alice, mpt(10)), ter(tecLOCKED)); + env(check::create(carol, alice, mpt(10)), Ter(tecLOCKED)); env.close(); mpt.set({.holder = alice, .flags = tfMPTUnlock}); @@ -5882,10 +5894,10 @@ class MPToken_test : public beast::unit_test::suite env(check::create(gw, alice, mpt(10))); env.close(); mpt.set({.holder = alice, .flags = tfMPTLock}); - env(check::cash(carol, chkId1, mpt(1)), ter(tecPATH_PARTIAL)); - env(check::cash(alice, chkId2, mpt(1)), ter(tecLOCKED)); - env(check::cash(gw, chkId3, mpt(1)), ter(tecPATH_PARTIAL)); - env(check::cash(alice, chkId4, mpt(1)), ter(tecLOCKED)); + env(check::cash(carol, chkId1, mpt(1)), Ter(tecPATH_PARTIAL)); + env(check::cash(alice, chkId2, mpt(1)), Ter(tecLOCKED)); + env(check::cash(gw, chkId3, mpt(1)), Ter(tecPATH_PARTIAL)); + env(check::cash(alice, chkId4, mpt(1)), Ter(tecLOCKED)); } // MPTRequireAuth flag is set and the account is not authorized. @@ -5894,26 +5906,26 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto BTC = MPTTester( + auto btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol}, - .flags = tfMPTRequireAuth | MPTDEXFlags}); + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, carol, BTC(50))); + env(check::create(alice, carol, btc(50))); env.close(); // Authorize alice - BTC.authorize({.account = gw, .holder = alice}); - env(pay(gw, alice, BTC(100))); + btc.authorize({.account = gw, .holder = alice}); + env(pay(gw, alice, btc(100))); // carol is still not authorized - env(check::cash(carol, chkId, BTC(10)), ter(tecNO_AUTH)); + env(check::cash(carol, chkId, btc(10)), Ter(tecNO_AUTH)); env.close(); // authorize carol, can cash now - BTC.authorize({.account = gw, .holder = carol}); - env(check::cash(carol, chkId, BTC(10))); + btc.authorize({.account = gw, .holder = carol}); + env(check::cash(carol, chkId, btc(10))); env.close(); } @@ -5964,7 +5976,7 @@ class MPToken_test : public beast::unit_test::suite env.close(); // can't cash - env(check::cash(carol, checkId, mpt(10)), ter(tecPATH_PARTIAL)); + env(check::cash(carol, checkId, mpt(10)), Ter(tecPATH_PARTIAL)); env.close(); // can cash now @@ -5991,7 +6003,7 @@ class MPToken_test : public beast::unit_test::suite uint256 checkId{keylet::check(gw, env.seq(gw)).key}; // can't create - env(check::create(gw, alice, mpt(100)), ter(tecNO_PERMISSION)); + env(check::create(gw, alice, mpt(100)), Ter(tecNO_PERMISSION)); env.close(); mpt.set({.account = gw, .mutableFlags = tmfMPTSetCanTrade}); @@ -6000,7 +6012,7 @@ class MPToken_test : public beast::unit_test::suite env(check::create(gw, carol, mpt(100))); env.close(); mpt.set({.account = gw, .mutableFlags = tmfMPTClearCanTrade}); - env(check::cash(carol, checkId, mpt(10)), ter(tecNO_PERMISSION)); + env(check::cash(carol, checkId, mpt(10)), Ter(tecNO_PERMISSION)); env.close(); } @@ -6008,14 +6020,14 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + auto usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, carol, USD(1))); + env(check::create(alice, carol, usd(1))); env.close(); // temMALFORMED because MPT is not USD. It doesn't matter if it // exists or not - env(check::cash(carol, chkId, MPT(alice)(1)), ter(temMALFORMED)); + env(check::cash(carol, chkId, MPT(alice)(1)), Ter(temMALFORMED)); env.close(); } @@ -6024,15 +6036,15 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto BTC = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000}); + auto btc = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, carol, BTC(1))); + env(check::create(alice, carol, btc(1))); env.close(); // MPToken is automatically created - env(check::cash(carol, chkId, BTC(1))); + env(check::cash(carol, chkId, btc(1))); env.close(); } @@ -6041,17 +6053,17 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto BTC = MPTTester( + auto btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, - .flags = tfMPTRequireAuth | MPTDEXFlags, + .flags = tfMPTRequireAuth | kMPT_DEX_FLAGS, .authHolder = true}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; - env(check::create(alice, carol, BTC(1))); + env(check::create(alice, carol, btc(1))); env.close(); - env(check::cash(carol, chkId, BTC(1)), ter(tecPATH_PARTIAL)); + env(check::cash(carol, chkId, btc(1)), Ter(tecPATH_PARTIAL)); env.close(); } @@ -6060,25 +6072,25 @@ class MPToken_test : public beast::unit_test::suite Env env{*this, features}; env.fund(XRP(1'000), gw, alice, carol); - auto EUR = MPTTester( + auto eur = MPTTester( {.env = env, .issuer = gw, .holders = {alice, carol}, .flags = tfMPTCanTrade}); uint256 const chkId{getCheckIndex(alice, env.seq(alice))}; // alice can create - env(check::create(alice, carol, EUR(1))); + env(check::create(alice, carol, eur(1))); env.close(); // carol can't cash - env(check::cash(carol, chkId, EUR(1)), ter(tecPATH_PARTIAL)); + env(check::cash(carol, chkId, eur(1)), Ter(tecPATH_PARTIAL)); env.close(); // if issuer creates a check then carol can cash since // it's a transfer from the issuer uint256 const chkId1{getCheckIndex(gw, env.seq(gw))}; // alice can't create since CanTransfer is not set - env(check::create(gw, carol, EUR(1))); + env(check::create(gw, carol, eur(1))); env.close(); - env(check::cash(carol, chkId1, EUR(1))); + env(check::cash(carol, chkId1, eur(1))); env.close(); } @@ -6086,10 +6098,10 @@ class MPToken_test : public beast::unit_test::suite { Env env{*this, features}; - MPTTester mpt(env, gw); - mpt.create( + MPTTester mptTester(env, gw); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; + auto const mpt = mptTester["MPT"]; env.fund(XRP(1'000), alice, carol); @@ -6097,41 +6109,41 @@ class MPToken_test : public beast::unit_test::suite uint256 const checkId{keylet::check(alice, env.seq(alice)).key}; // can create - env(check::create(alice, carol, MPT(100))); + env(check::create(alice, carol, mpt(100))); env.close(); // authorize/fund alice - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 100); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 100); // carol can cash the check. MPToken is created automatically - env(check::cash(carol, checkId, MPT(100))); + env(check::cash(carol, checkId, mpt(100))); env.close(); - BEAST_EXPECT(mpt.checkMPTokenAmount(carol, 100)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(100)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(carol, 100)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(100)); } // Normal create/cash { Env env{*this, features}; - MPTTester mpt(env, gw, {.holders = {alice}}); - mpt.create( + MPTTester mptTester(env, gw, {.holders = {alice}}); + mptTester.create( {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); uint256 const checkId{keylet::check(gw, env.seq(gw)).key}; - env(check::create(gw, alice, MPT(100))); + env(check::create(gw, alice, mpt(100))); env.close(); - env(check::cash(alice, checkId, MPT(100))); + env(check::cash(alice, checkId, mpt(100))); env.close(); - BEAST_EXPECT(mpt.checkMPTokenAmount(alice, 100)); - BEAST_EXPECT(mpt.checkMPTokenOutstandingAmount(100)); + BEAST_EXPECT(mptTester.checkMPTokenAmount(alice, 100)); + BEAST_EXPECT(mptTester.checkMPTokenOutstandingAmount(100)); } } @@ -6142,16 +6154,16 @@ class MPToken_test : public beast::unit_test::suite testcase("AMMClawback"); Account const gw{"gw"}; Account const alice{"alice"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // MPTokenIssuance object doesn't exist { Env env(*this, features); env.fund(XRP(1'000), gw, alice); - MPTTester const BTC({.env = env, .issuer = gw}); - AMM const amm(env, gw, BTC(100), USD(100)); - env(amm::ammClawback(gw, alice, USD, MPT(alice), std::nullopt), ter(terNO_AMM)); - env(amm::ammClawback(gw, alice, USD, BTC, MPT(alice)(100)), ter(temBAD_AMOUNT)); + MPTTester const btc({.env = env, .issuer = gw}); + AMM const amm(env, gw, btc(100), usd(100)); + env(amm::ammClawback(gw, alice, usd, MPT(alice), std::nullopt), Ter(terNO_AMM)); + env(amm::ammClawback(gw, alice, usd, btc, MPT(alice)(100)), Ter(temBAD_AMOUNT)); } // MPTLock flag is set and the account is not the issuer of MPT - @@ -6164,25 +6176,25 @@ class MPToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto BTC = MPTTester( + auto btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000, - .flags = tfMPTCanLock | tfMPTCanClawback | MPTDEXFlags}); + .flags = tfMPTCanLock | tfMPTCanClawback | kMPT_DEX_FLAGS}); - env.trust(USD(10'000), alice); - env(pay(gw, alice, USD(10'000))); + env.trust(usd(10'000), alice); + env(pay(gw, alice, usd(10'000))); env.close(); - AMM amm(env, gw, BTC(100), USD(100)); + AMM amm(env, gw, btc(100), usd(100)); env.close(); amm.deposit(alice, 1'000); env.close(); - BTC.set({.flags = tfMPTLock}); + btc.set({.flags = tfMPTLock}); - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt)); } // MPTRequireAuth flag is set and the account is not authorized - @@ -6195,26 +6207,26 @@ class MPToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto BTC = MPTTester( + auto btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 40'000, - .flags = tfMPTRequireAuth | tfMPTCanClawback | MPTDEXFlags, + .flags = tfMPTRequireAuth | tfMPTCanClawback | kMPT_DEX_FLAGS, .authHolder = true}); - env.trust(USD(10'000), alice); - env(pay(gw, alice, USD(10'000))); + env.trust(usd(10'000), alice); + env(pay(gw, alice, usd(10'000))); env.close(); - AMM amm(env, gw, BTC(100), USD(100)); + AMM amm(env, gw, btc(100), usd(100)); env.close(); amm.deposit(alice, 1'000); env.close(); - BTC.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); + btc.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize}); - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt)); } // MPTCanTransfer is not set and the account is not the issuer of MPT - @@ -6227,7 +6239,7 @@ class MPToken_test : public beast::unit_test::suite env(fset(gw, asfAllowTrustLineClawback)); env.close(); - auto BTC = MPTTester( + auto btc = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, @@ -6235,43 +6247,43 @@ class MPToken_test : public beast::unit_test::suite .flags = tfMPTCanClawback | tfMPTCanTrade, .authHolder = true}); - env.trust(USD(10'000), alice); - env(pay(gw, alice, USD(10'000))); + env.trust(usd(10'000), alice); + env(pay(gw, alice, usd(10'000))); env.close(); - AMM amm(env, gw, BTC(100), USD(100)); + AMM amm(env, gw, btc(100), usd(100)); env.close(); // alice can't deposit since MPTCanTransfer is not set amm.deposit( - DepositArg{.account = alice, .tokens = 1'000, .err = ter(tecNO_PERMISSION)}); + DepositArg{.account = alice, .tokens = 1'000, .err = Ter(tecNO_PERMISSION)}); env.close(); // can't clawback since alice is not an LP - env(amm::ammClawback(gw, alice, BTC, USD, std::nullopt), ter(tecAMM_BALANCE)); + env(amm::ammClawback(gw, alice, btc, usd, std::nullopt), Ter(tecAMM_BALANCE)); } { Env env(*this, features); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}); - MPTTester mpt(env, gw, {.fund = false}); - mpt.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - AMM amm(env, gw, MPT(100), XRP(100)); + fund(env, gw, {alice}, XRP(1'000), {usd(1'000)}); + MPTTester mptTester(env, gw, {.fund = false}); + mptTester.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt = mptTester["MPT"]; + AMM amm(env, gw, mpt(100), XRP(100)); amm.deposit(DepositArg{.account = alice, .asset1In = XRP(10)}); - amm::ammClawback(gw, alice, MPTIssue(mpt.issuanceID()), xrpIssue(), MPT(10)); + amm::ammClawback(gw, alice, MPTIssue(mptTester.issuanceID()), xrpIssue(), mpt(10)); } { Env env(*this, features); - fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}); - MPTTester mpt(env, gw, {.fund = false}); - mpt.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - mpt.authorize({.account = alice}); - mpt.pay(gw, alice, 1'000); - auto const MPT = mpt["MPT"]; - AMM amm(env, gw, MPT(100), XRP(100)); + fund(env, gw, {alice}, XRP(1'000), {usd(1'000)}); + MPTTester mptTester(env, gw, {.fund = false}); + mptTester.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + mptTester.authorize({.account = alice}); + mptTester.pay(gw, alice, 1'000); + auto const mpt = mptTester["MPT"]; + AMM amm(env, gw, mpt(100), XRP(100)); amm.deposit(DepositArg{.account = alice, .tokens = 10'000}); - amm::ammClawback(gw, alice, MPTIssue(mpt.issuanceID()), xrpIssue(), MPT(10)); + amm::ammClawback(gw, alice, MPTIssue(mptTester.issuanceID()), xrpIssue(), mpt(10)); } // clawback one asset from MPT/MPT AMM. MPToken for another asset @@ -6279,21 +6291,21 @@ class MPToken_test : public beast::unit_test::suite { Env env(*this, features); env.fund(XRP(1'000), gw, alice); - auto USD = MPTTester( + auto usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice}, .pay = 10'000, - .flags = tfMPTCanClawback | MPTDEXFlags}); - auto EUR = - MPTTester({.env = env, .issuer = gw, .flags = tfMPTCanClawback | MPTDEXFlags}); - AMM amm(env, gw, USD(1'000), EUR(1'000)); - amm.deposit({.account = alice, .asset1In = USD(1'000)}); + .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); + auto eur = + MPTTester({.env = env, .issuer = gw, .flags = tfMPTCanClawback | kMPT_DEX_FLAGS}); + AMM amm(env, gw, usd(1'000), eur(1'000)); + amm.deposit({.account = alice, .asset1In = usd(1'000)}); // MPToken doesn't exist - BEAST_EXPECT(env.le(keylet::mptoken(EUR.issuanceID(), alice)) == nullptr); - env(amm::ammClawback(gw, alice, USD, EUR, USD(100))); + BEAST_EXPECT(env.le(keylet::mptoken(eur.issuanceID(), alice)) == nullptr); + env(amm::ammClawback(gw, alice, usd, eur, usd(100))); // MPToken is created - BEAST_EXPECT(env.le(keylet::mptoken(EUR.issuanceID(), alice))); + BEAST_EXPECT(env.le(keylet::mptoken(eur.issuanceID(), alice))); } } @@ -6306,34 +6318,34 @@ class MPToken_test : public beast::unit_test::suite Account const alice{"alice"}; Account const carol{"carol"}; Account const bob{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Create/deposit/withdraw { Env env{*this}; - fund(env, gw, {alice, carol, bob}, XRP(1'000), {USD(1'000)}); + fund(env, gw, {alice, carol, bob}, XRP(1'000), {usd(1'000)}); - MPTTester mpt(env, gw, {.fund = false}); - mpt.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT = mpt["MPT"]; - mpt.authorize({.account = alice}); - mpt.authorize({.account = carol}); - mpt.pay(gw, alice, 1'000); - mpt.pay(gw, carol, 1'000); + MPTTester mptTester(env, gw, {.fund = false}); + mptTester.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt = mptTester["MPT"]; + mptTester.authorize({.account = alice}); + mptTester.authorize({.account = carol}); + mptTester.pay(gw, alice, 1'000); + mptTester.pay(gw, carol, 1'000); - MPTTester mpt1(env, gw, {.fund = false}); - mpt1.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); - auto const MPT1 = mpt1["MPT1"]; - mpt1.authorize({.account = alice}); - mpt1.authorize({.account = carol}); - mpt1.pay(gw, alice, 1'000); - mpt1.pay(gw, carol, 1'000); + MPTTester mptTester1(env, gw, {.fund = false}); + mptTester1.create({.flags = tfMPTCanTransfer | tfMPTCanTrade}); + auto const mpt1 = mptTester1["MPT1"]; + mptTester1.authorize({.account = alice}); + mptTester1.authorize({.account = carol}); + mptTester1.pay(gw, alice, 1'000); + mptTester1.pay(gw, carol, 1'000); std::vector> pools = { - {XRP(100), MPT(100), IOUAmount{100'000}}, - {USD(100), MPT(100), IOUAmount{100}}, - {MPT(100), MPT1(100), IOUAmount{100}}}; + {XRP(100), mpt(100), IOUAmount{100'000}}, + {usd(100), mpt(100), IOUAmount{100}}, + {mpt(100), mpt1(100), IOUAmount{100}}}; for (auto& pool : pools) { AMM amm(env, gw, std::get<0>(pool), std::get<1>(pool)); @@ -6342,7 +6354,7 @@ class MPToken_test : public beast::unit_test::suite // bob doesn't own MPT amm.deposit( DepositArg{ - .account = bob, .tokens = std::get<2>(pool), .err = ter(tecNO_AUTH)}); + .account = bob, .tokens = std::get<2>(pool), .err = Ter(tecNO_AUTH)}); amm.withdrawAll(alice); amm.withdrawAll(carol); amm.withdrawAll(gw); @@ -6357,18 +6369,18 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - MPT const EUR = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + MPT const eur = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, eur(100))); - AMM const amm(env, gw, USD(1'100), EUR(1'000)); + AMM const amm(env, gw, usd(1'100), eur(1'000)); - env(pay(alice, carol, USD(100)), sendmax(EUR(100))); + env(pay(alice, carol, usd(100)), Sendmax(eur(100))); - BEAST_EXPECT(amm.expectBalances(USD(1'000), EUR(1'100), amm.tokens())); - BEAST_EXPECT(env.balance(carol, USD) == USD(100)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); + BEAST_EXPECT(amm.expectBalances(usd(1'000), eur(1'100), amm.tokens())); + BEAST_EXPECT(env.balance(carol, usd) == usd(100)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); } // Payment, two steps @@ -6378,23 +6390,23 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice, carol); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - MPT const EUR = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - MPT const BTC = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - env(pay(gw, alice, EUR(100))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + MPT const eur = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + MPT const btc = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + env(pay(gw, alice, eur(100))); - AMM const ammEUR_USD(env, gw, EUR(1'000), USD(1'100)); - AMM const ammUSD_BTC(env, gw, USD(1'000), BTC(1'100)); + AMM const ammEurUsd(env, gw, eur(1'000), usd(1'100)); + AMM const ammUsdBtc(env, gw, usd(1'000), btc(1'100)); - env(pay(alice, carol, BTC(100)), - sendmax(EUR(100)), - path(~USD, ~BTC), - txflags(tfNoRippleDirect)); + env(pay(alice, carol, btc(100)), + Sendmax(eur(100)), + Path(~usd, ~btc), + Txflags(tfNoRippleDirect)); - BEAST_EXPECT(ammEUR_USD.expectBalances(USD(1'000), EUR(1'100), ammEUR_USD.tokens())); - BEAST_EXPECT(ammUSD_BTC.expectBalances(USD(1'100), BTC(1'000), ammUSD_BTC.tokens())); - BEAST_EXPECT(env.balance(carol, BTC) == BTC(100)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); + BEAST_EXPECT(ammEurUsd.expectBalances(usd(1'000), eur(1'100), ammEurUsd.tokens())); + BEAST_EXPECT(ammUsdBtc.expectBalances(usd(1'100), btc(1'000), ammUsdBtc.tokens())); + BEAST_EXPECT(env.balance(carol, btc) == btc(100)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); } // Offer crossing @@ -6404,42 +6416,42 @@ class MPToken_test : public beast::unit_test::suite env.fund(XRP(1'000), gw, alice); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - MPT const EUR = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const eur = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - env(pay(gw, alice, EUR(1'000))); + env(pay(gw, alice, eur(1'000))); - AMM const amm(env, gw, EUR(1'000'000), USD(1'001'000)); + AMM const amm(env, gw, eur(1'000'000), usd(1'001'000)); - env(offer(alice, USD(1'000), EUR(1'000))); + env(offer(alice, usd(1'000), eur(1'000))); - BEAST_EXPECT(amm.expectBalances(USD(1'000'000), EUR(1'001'000), amm.tokens())); - BEAST_EXPECT(env.balance(alice, USD) == USD(1'000)); - BEAST_EXPECT(env.balance(alice, EUR) == EUR(0)); + BEAST_EXPECT(amm.expectBalances(usd(1'000'000), eur(1'001'000), amm.tokens())); + BEAST_EXPECT(env.balance(alice, usd) == usd(1'000)); + BEAST_EXPECT(env.balance(alice, eur) == eur(0)); } { Env env(*this); env.fund(XRP(1'000'000), gw, alice, carol); - auto USD = MPTTester( + auto usd = MPTTester( {.env = env, .issuer = gw, - .flags = tfMPTCanLock | MPTDEXFlags, + .flags = tfMPTCanLock | kMPT_DEX_FLAGS, .mutableFlags = tmfMPTCanMutateRequireAuth | tmfMPTCanMutateCanTransfer | tmfMPTCanMutateCanClawback | tmfMPTCanMutateCanTrade}); - auto EUR = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000'000}); + auto eur = MPTTester({.env = env, .issuer = gw, .holders = {alice}, .pay = 1'000'000}); auto const increment = env.current()->fees().increment; - auto const txfee = fee(drops(increment)); + auto const txfee = Fee(drops(increment)); auto const badMPT = MPT(gw, 1'000); auto createDeleteAMM = [&](Account const& lp) { AMM amm( env, lp, - USD(1'000), - EUR(1'000), + usd(1'000), + eur(1'000), CreateArg{.fee = static_cast(increment.value())}); amm.withdrawAll(lp); BEAST_EXPECT(!amm.ammExists()); @@ -6449,11 +6461,11 @@ class MPToken_test : public beast::unit_test::suite // AMMCreate // - auto createJv = AMM::createJv(alice, badMPT(1'000), EUR(1'000), 0); + auto createJv = AMM::createJv(alice, badMPT(1'000), eur(1'000), 0); auto createFail = [&](Account const& account, auto const& err) { createJv[sfAccount] = account.human(); - env(createJv, txfee, ter(err)); + env(createJv, txfee, Ter(err)); env.close(); }; @@ -6463,148 +6475,148 @@ class MPToken_test : public beast::unit_test::suite // MPToken doesn't exist - createJv[sfAmount] = STAmount{USD(1'000)}.getJson(); + createJv[sfAmount] = STAmount{usd(1'000)}.getJson(); createFail(alice, tecNO_AUTH); // alice authorizes MPToken, can create - USD.authorize({.account = alice}); - env(pay(gw, alice, USD(1'000'000)), txfee); + usd.authorize({.account = alice}); + env(pay(gw, alice, usd(1'000'000)), txfee); env.close(); createDeleteAMM(alice); // MPTLock is set // alice and issuer can't create - USD.set({.flags = tfMPTLock}); + usd.set({.flags = tfMPTLock}); createFail(alice, tecFROZEN); createFail(gw, tecFROZEN); // MPTRequireAuth is set // alice is not authorized - USD.set({.flags = tfMPTUnlock}); - USD.set({.mutableFlags = tmfMPTSetRequireAuth}); + usd.set({.flags = tfMPTUnlock}); + usd.set({.mutableFlags = tmfMPTSetRequireAuth}); createFail(alice, tecNO_AUTH); // issuer can create createDeleteAMM(gw); // alice is authorized, can create - USD.authorize({.account = gw, .holder = alice}); + usd.authorize({.account = gw, .holder = alice}); createDeleteAMM(alice); // MPTCanTransfer is not set - USD.set({.mutableFlags = tmfMPTClearRequireAuth}); - USD.set({.mutableFlags = tmfMPTClearCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearRequireAuth}); + usd.set({.mutableFlags = tmfMPTClearCanTransfer}); // alice can't create createFail(alice, tecNO_PERMISSION); // issuer can create createDeleteAMM(gw); - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); // alice can create createDeleteAMM(alice); // MPTCanTrade is not set - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); - USD.set({.mutableFlags = tmfMPTClearCanTrade}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearCanTrade}); // alice and issuer can't create createFail(alice, tecNO_PERMISSION); createFail(gw, tecNO_PERMISSION); - USD.set({.mutableFlags = tmfMPTSetCanTrade}); + usd.set({.mutableFlags = tmfMPTSetCanTrade}); // // AMMDeposit // - AMM amm(env, gw, USD(1'000), EUR(1'000)); + AMM amm(env, gw, usd(1'000), eur(1'000)); // MPTokenIssuance doesn't exist amm.deposit( {.account = alice, .asset1In = badMPT(1), - .asset2In = EUR(1), - .assets = std::make_pair(badMPT, EUR), - .err = ter(terNO_AMM)}); + .asset2In = eur(1), + .assets = std::make_pair(badMPT, eur), + .err = Ter(terNO_AMM)}); // MPToken doesn't exist amm.deposit( - {.account = carol, .asset1In = USD(1), .asset2In = EUR(1), .err = ter(tecNO_AUTH)}); + {.account = carol, .asset1In = usd(1), .asset2In = eur(1), .err = Ter(tecNO_AUTH)}); // MPTLock is set - USD.set({.flags = tfMPTLock}); + usd.set({.flags = tfMPTLock}); // alice and issuer can't deposit for (auto const& account : {carol, gw}) { amm.deposit( {.account = account, - .asset1In = USD(1), - .asset2In = EUR(1), - .err = ter(tecFROZEN)}); + .asset1In = usd(1), + .asset2In = eur(1), + .err = Ter(tecFROZEN)}); amm.deposit( {.account = account, - .asset1In = EUR(1), - .assets = std::make_pair(EUR, USD), - .err = ter(tecFROZEN)}); + .asset1In = eur(1), + .assets = std::make_pair(eur, usd), + .err = Ter(tecFROZEN)}); } - USD.set({.flags = tfMPTUnlock}); + usd.set({.flags = tfMPTUnlock}); // MPTRequireAuth is set // carol authorizes MPToken but is not authorized by the issuer - USD.authorize({.account = carol}); - env(pay(gw, carol, USD(1'000'000))); + usd.authorize({.account = carol}); + env(pay(gw, carol, usd(1'000'000))); // carol authorizes EUR - EUR.authorize({.account = carol}); - env(pay(gw, carol, EUR(1'000'000))); - USD.set({.mutableFlags = tmfMPTSetRequireAuth}); + eur.authorize({.account = carol}); + env(pay(gw, carol, eur(1'000'000))); + usd.set({.mutableFlags = tmfMPTSetRequireAuth}); // have to authorize amm account - USD.authorize({.account = gw, .holder = Account{"amm", amm.ammAccount()}}); + usd.authorize({.account = gw, .holder = Account{"amm", amm.ammAccount()}}); env.close(); amm.deposit( - {.account = carol, .asset1In = USD(1), .asset2In = EUR(1), .err = ter(tecNO_AUTH)}); + {.account = carol, .asset1In = usd(1), .asset2In = eur(1), .err = Ter(tecNO_AUTH)}); amm.deposit( {.account = carol, - .asset1In = EUR(1), - .assets = std::make_pair(EUR, USD), - .err = ter(tecNO_AUTH)}); + .asset1In = eur(1), + .assets = std::make_pair(eur, usd), + .err = Ter(tecNO_AUTH)}); // issuer can deposit amm.deposit({.account = gw, .tokens = 1'000}); // carol is authorized, can deposit - USD.authorize({.account = gw, .holder = carol}); + usd.authorize({.account = gw, .holder = carol}); amm.deposit({.account = carol, .tokens = 1'000}); // MPTCanTransfer is not set - USD.set({.mutableFlags = tmfMPTClearRequireAuth}); - USD.set({.mutableFlags = tmfMPTClearCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearRequireAuth}); + usd.set({.mutableFlags = tmfMPTClearCanTransfer}); // carol can't deposit amm.deposit( {.account = carol, - .asset1In = USD(1), - .asset2In = EUR(1), - .err = ter(tecNO_PERMISSION)}); + .asset1In = usd(1), + .asset2In = eur(1), + .err = Ter(tecNO_PERMISSION)}); amm.deposit( {.account = carol, - .asset1In = EUR(1), - .assets = std::make_pair(EUR, USD), - .err = ter(tecNO_PERMISSION)}); + .asset1In = eur(1), + .assets = std::make_pair(eur, usd), + .err = Ter(tecNO_PERMISSION)}); // issuer can deposit amm.deposit({.account = gw, .tokens = 1'000}); // carol can deposit - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); amm.deposit({.account = carol, .tokens = 1'000}); // MPTCanTrade is not set - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); - USD.set({.mutableFlags = tmfMPTClearCanTrade}); - amm.deposit({.account = gw, .tokens = 1'000, .err = ter(tecNO_PERMISSION)}); - amm.deposit({.account = carol, .tokens = 1'000, .err = ter(tecNO_PERMISSION)}); - USD.set({.mutableFlags = tmfMPTSetCanTrade}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearCanTrade}); + amm.deposit({.account = gw, .tokens = 1'000, .err = Ter(tecNO_PERMISSION)}); + amm.deposit({.account = carol, .tokens = 1'000, .err = Ter(tecNO_PERMISSION)}); + usd.set({.mutableFlags = tmfMPTSetCanTrade}); // // AMMWithdraw @@ -6616,88 +6628,88 @@ class MPToken_test : public beast::unit_test::suite WithdrawArg{ .account = carol, .asset1Out = badMPT(1), - .asset2Out = EUR(1), - .assets = std::make_pair(badMPT, EUR), - .err = ter(terNO_AMM)}); + .asset2Out = eur(1), + .assets = std::make_pair(badMPT, eur), + .err = Ter(terNO_AMM)}); // MPToken doesn't exist - doesn't apply since MPToken is created // on withdraw in this case // MPTLock is set - USD.set({.flags = tfMPTLock}); + usd.set({.flags = tfMPTLock}); // carol and issuer can't withdraw for (auto const& account : {carol, gw}) { amm.withdraw( {.account = account, - .asset1Out = USD(1), - .asset2Out = EUR(1), - .err = ter(tecFROZEN)}); - amm.withdraw({.account = account, .tokens = 1'000, .err = ter(tecFROZEN)}); + .asset1Out = usd(1), + .asset2Out = eur(1), + .err = Ter(tecFROZEN)}); + amm.withdraw({.account = account, .tokens = 1'000, .err = Ter(tecFROZEN)}); // can single withdraw another asset amm.withdraw( - {.account = account, .asset1Out = EUR(1), .assets = std::make_pair(EUR, USD)}); + {.account = account, .asset1Out = eur(1), .assets = std::make_pair(eur, usd)}); } - USD.set({.flags = tfMPTUnlock}); + usd.set({.flags = tfMPTUnlock}); // MPTRequireAuth is set - USD.set({.mutableFlags = tmfMPTSetRequireAuth}); - USD.authorize({.account = gw, .holder = carol, .flags = tfMPTUnauthorize}); + usd.set({.mutableFlags = tmfMPTSetRequireAuth}); + usd.authorize({.account = gw, .holder = carol, .flags = tfMPTUnauthorize}); // carol can't withdraw amm.withdraw( {.account = carol, - .asset1Out = USD(1), - .asset2Out = EUR(1), - .err = ter(tecNO_AUTH)}); + .asset1Out = usd(1), + .asset2Out = eur(1), + .err = Ter(tecNO_AUTH)}); // can withdraw another asset amm.withdraw( - {.account = carol, .asset1Out = EUR(1), .assets = std::make_pair(EUR, USD)}); + {.account = carol, .asset1Out = eur(1), .assets = std::make_pair(eur, usd)}); // issuer can withdraw - amm.withdraw({.account = gw, .asset1Out = USD(1), .asset2Out = EUR(1)}); + amm.withdraw({.account = gw, .asset1Out = usd(1), .asset2Out = eur(1)}); // carol is authorized, can withdraw - USD.authorize({.account = gw, .holder = carol}); - amm.withdraw({.account = carol, .asset1Out = USD(1), .asset2Out = EUR(1)}); + usd.authorize({.account = gw, .holder = carol}); + amm.withdraw({.account = carol, .asset1Out = usd(1), .asset2Out = eur(1)}); // MPTCanTransfer is set - USD.set({.mutableFlags = tmfMPTClearRequireAuth}); - USD.set({.mutableFlags = tmfMPTClearCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearRequireAuth}); + usd.set({.mutableFlags = tmfMPTClearCanTransfer}); // carol can't withdraw amm.withdraw( {.account = carol, - .asset1Out = USD(1), - .asset2Out = EUR(1), - .err = ter(tecNO_PERMISSION)}); + .asset1Out = usd(1), + .asset2Out = eur(1), + .err = Ter(tecNO_PERMISSION)}); // can withdraw another asset amm.withdraw( - {.account = carol, .asset1Out = EUR(1), .assets = std::make_pair(EUR, USD)}); + {.account = carol, .asset1Out = eur(1), .assets = std::make_pair(eur, usd)}); // issuer can withdraw - amm.withdraw({.account = gw, .asset1Out = USD(1), .asset2Out = EUR(1)}); + amm.withdraw({.account = gw, .asset1Out = usd(1), .asset2Out = eur(1)}); // carol can withdraw - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); - amm.withdraw({.account = carol, .asset1Out = USD(1), .asset2Out = EUR(1)}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); + amm.withdraw({.account = carol, .asset1Out = usd(1), .asset2Out = eur(1)}); - USD.set({.mutableFlags = tmfMPTSetCanTransfer}); - USD.set({.mutableFlags = tmfMPTClearCanTrade}); - amm.withdraw({.account = gw, .tokens = 1'000, .err = ter(tecNO_PERMISSION)}); - amm.withdraw({.account = carol, .tokens = 1'000, .err = ter(tecNO_PERMISSION)}); - USD.set({.mutableFlags = tmfMPTSetCanTrade}); + usd.set({.mutableFlags = tmfMPTSetCanTransfer}); + usd.set({.mutableFlags = tmfMPTClearCanTrade}); + amm.withdraw({.account = gw, .tokens = 1'000, .err = Ter(tecNO_PERMISSION)}); + amm.withdraw({.account = carol, .tokens = 1'000, .err = Ter(tecNO_PERMISSION)}); + usd.set({.mutableFlags = tmfMPTSetCanTrade}); // MPToken created on withdraw // redeem all carol's USD and unauthorize USD amm.withdrawAll(carol); - env(pay(carol, gw, env.balance(carol, USD))); - USD.authorize({.account = carol, .flags = tfMPTUnauthorize}); - BEAST_EXPECT(env.le(keylet::mptoken(USD.issuanceID(), carol)) == nullptr); + env(pay(carol, gw, env.balance(carol, usd))); + usd.authorize({.account = carol, .flags = tfMPTUnauthorize}); + BEAST_EXPECT(env.le(keylet::mptoken(usd.issuanceID(), carol)) == nullptr); // single-deposit EUR amm.deposit( - {.account = carol, .asset1In = EUR(1'000), .assets = std::make_pair(EUR, USD)}); + {.account = carol, .asset1In = eur(1'000), .assets = std::make_pair(eur, usd)}); // withdraw in USD to create MPToken - amm.withdraw({.account = carol, .asset1Out = USD(100)}); - BEAST_EXPECT(env.le(keylet::mptoken(USD.issuanceID(), carol))); + amm.withdraw({.account = carol, .asset1Out = usd(100)}); + BEAST_EXPECT(env.le(keylet::mptoken(usd.issuanceID(), carol))); } } @@ -6706,7 +6718,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testMultiSendMaximumAmount(all); // MPTokenIssuanceCreate diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index 1025b73fe8..f20847ae5c 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -39,19 +39,19 @@ namespace xrpl::test { -class Manifest_test : public beast::unit_test::suite +class Manifest_test : public beast::unit_test::Suite { private: static PublicKey randomNode() { - return derivePublicKey(KeyType::secp256k1, randomSecretKey()); + return derivePublicKey(KeyType::Secp256k1, randomSecretKey()); } static PublicKey randomMasterKey() { - return derivePublicKey(KeyType::ed25519, randomSecretKey()); + return derivePublicKey(KeyType::Ed25519, randomSecretKey()); } static void @@ -115,21 +115,21 @@ public: SecretKey const& ssk, int seq) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = seq; st[sfPublicKey] = pk; st[sfSigningPubKey] = spk; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - sign(st, HashPrefix::manifest, *publicKeyType(spk), ssk); + sign(st, HashPrefix::Manifest, *publicKeyType(spk), ssk); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - sign(st, HashPrefix::manifest, *publicKeyType(pk), sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, *publicKeyType(pk), sk, sfMasterSignature); Serializer s; st.add(s); - return base64_encode(std::string(static_cast(s.data()), s.size())); + return base64Encode(std::string(static_cast(s.data()), s.size())); } std::string @@ -137,18 +137,18 @@ public: { auto const pk = derivePublicKey(type, sk); - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = std::numeric_limits::max(); st[sfPublicKey] = pk; sign( - st, HashPrefix::manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); - BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::manifest, pk, sfMasterSignature)); + st, HashPrefix::Manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); + BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::Manifest, pk, sfMasterSignature)); Serializer s; st.add(s); - return base64_encode(std::string(static_cast(s.data()), s.size())); + return base64Encode(std::string(static_cast(s.data()), s.size())); } Manifest @@ -156,13 +156,13 @@ public: { auto const pk = derivePublicKey(type, sk); - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = std::numeric_limits::max(); st[sfPublicKey] = pk; sign( - st, HashPrefix::manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); - BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::manifest, pk, sfMasterSignature)); + st, HashPrefix::Manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); + BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::Manifest, pk, sfMasterSignature)); Serializer s; st.add(s); @@ -186,17 +186,17 @@ public: auto const pk = derivePublicKey(type, sk); auto const spk = derivePublicKey(stype, ssk); - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = seq; st[sfPublicKey] = pk; st[sfSigningPubKey] = spk; - sign(st, HashPrefix::manifest, stype, ssk); - BEAST_EXPECT(verify(st, HashPrefix::manifest, spk)); + sign(st, HashPrefix::Manifest, stype, ssk); + BEAST_EXPECT(verify(st, HashPrefix::Manifest, spk)); sign( - st, HashPrefix::manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); - BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::manifest, pk, sfMasterSignature)); + st, HashPrefix::Manifest, type, invalidSig ? randomSecretKey() : sk, sfMasterSignature); + BEAST_EXPECT(invalidSig ^ verify(st, HashPrefix::Manifest, pk, sfMasterSignature)); Serializer s; st.add(s); @@ -233,7 +233,7 @@ public: [](ManifestCache const& cache) -> std::vector { std::vector result; result.reserve(32); - cache.for_each_manifest([&result](Manifest const& man) { result.push_back(&man); }); + cache.forEachManifest([&result](Manifest const& man) { result.push_back(&man); }); return result; }; auto sort = [](std::vector mv) -> std::vector { @@ -310,8 +310,8 @@ public: !loaded.load(*dbCon, "ValidatorManifests", badManifest, emptyRevocation)); auto const sk = randomSecretKey(); - auto const pk = derivePublicKey(KeyType::ed25519, sk); - auto const kp = randomKeyPair(KeyType::secp256k1); + auto const pk = derivePublicKey(KeyType::Ed25519, sk); + auto const kp = randomKeyPair(KeyType::Secp256k1); std::string const cfgManifest = makeManifestString(pk, sk, kp.first, kp.second, 0); @@ -328,9 +328,9 @@ public: !loaded.load(*dbCon, "ValidatorManifests", emptyManifest, badRevocation)); auto const sk = randomSecretKey(); - auto const keyType = KeyType::ed25519; + auto const keyType = KeyType::Ed25519; auto const pk = derivePublicKey(keyType, sk); - auto const kp = randomKeyPair(KeyType::secp256k1); + auto const kp = randomKeyPair(KeyType::Secp256k1); std::vector const nonRevocation = { makeManifestString(pk, sk, kp.first, kp.second, 0)}; @@ -359,23 +359,23 @@ public: { testcase("getSignature"); auto const sk = randomSecretKey(); - auto const pk = derivePublicKey(KeyType::ed25519, sk); - auto const kp = randomKeyPair(KeyType::secp256k1); - auto const m = makeManifest(sk, KeyType::ed25519, kp.second, KeyType::secp256k1, 0); + auto const pk = derivePublicKey(KeyType::Ed25519, sk); + auto const kp = randomKeyPair(KeyType::Secp256k1); + auto const m = makeManifest(sk, KeyType::Ed25519, kp.second, KeyType::Secp256k1, 0); - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = 0; st[sfPublicKey] = pk; st[sfSigningPubKey] = kp.first; Serializer ss; - ss.add32(HashPrefix::manifest); + ss.add32(HashPrefix::Manifest); st.addWithoutSigningFields(ss); - auto const sig = sign(KeyType::secp256k1, kp.second, ss.slice()); + auto const sig = sign(KeyType::Secp256k1, kp.second, ss.slice()); BEAST_EXPECT( strHex(sig) == strHex(*m.getSignature())); // NOLINT(bugprone-unchecked-optional-access) - auto const masterSig = sign(KeyType::ed25519, sk, ss.slice()); + auto const masterSig = sign(KeyType::Ed25519, sk, ss.slice()); BEAST_EXPECT(strHex(masterSig) == strHex(m.getMasterSignature())); } @@ -386,7 +386,7 @@ public: ManifestCache cache; auto const sk = randomSecretKey(); - auto const pk = derivePublicKey(KeyType::ed25519, sk); + auto const pk = derivePublicKey(KeyType::Ed25519, sk); // getSigningKey should return same key if there is no manifest BEAST_EXPECT(cache.getSigningKey(pk) == pk); @@ -395,11 +395,11 @@ public: // for the listed validator master public key // getMasterKey should return the listed validator master key // for that ephemeral public key - auto const kp0 = randomKeyPair(KeyType::secp256k1); + auto const kp0 = randomKeyPair(KeyType::Secp256k1); BEAST_EXPECT( - ManifestDisposition::accepted == + ManifestDisposition::Accepted == cache.applyManifest( - makeManifest(sk, KeyType::ed25519, kp0.second, KeyType::secp256k1, 0))); + makeManifest(sk, KeyType::Ed25519, kp0.second, KeyType::Secp256k1, 0))); BEAST_EXPECT(cache.getSigningKey(pk) == kp0.first); BEAST_EXPECT(cache.getMasterKey(kp0.first) == pk); @@ -407,11 +407,11 @@ public: // for the listed validator master public key // getMasterKey should only return a master key for the latest // ephemeral public key - auto const kp1 = randomKeyPair(KeyType::secp256k1); + auto const kp1 = randomKeyPair(KeyType::Secp256k1); BEAST_EXPECT( - ManifestDisposition::accepted == + ManifestDisposition::Accepted == cache.applyManifest( - makeManifest(sk, KeyType::ed25519, kp1.second, KeyType::secp256k1, 1))); + makeManifest(sk, KeyType::Ed25519, kp1.second, KeyType::Secp256k1, 1))); BEAST_EXPECT(cache.getSigningKey(pk) == kp1.first); BEAST_EXPECT(cache.getMasterKey(kp1.first) == pk); BEAST_EXPECT(cache.getMasterKey(kp0.first) == kp0.first); @@ -419,9 +419,9 @@ public: // getSigningKey and getMasterKey should fail if a new manifest is // applied with the same signing key but a higher sequence BEAST_EXPECT( - ManifestDisposition::badEphemeralKey == + ManifestDisposition::BadEphemeralKey == cache.applyManifest( - makeManifest(sk, KeyType::ed25519, kp1.second, KeyType::secp256k1, 2))); + makeManifest(sk, KeyType::Ed25519, kp1.second, KeyType::Secp256k1, 2))); BEAST_EXPECT(cache.getSigningKey(pk) == kp1.first); BEAST_EXPECT(cache.getMasterKey(kp1.first) == pk); BEAST_EXPECT(cache.getMasterKey(kp0.first) == kp0.first); @@ -430,8 +430,8 @@ public: // key getMasterKey should return std::nullopt for an ephemeral public // key from a revoked master public key BEAST_EXPECT( - ManifestDisposition::accepted == - cache.applyManifest(makeRevocation(sk, KeyType::ed25519))); + ManifestDisposition::Accepted == + cache.applyManifest(makeRevocation(sk, KeyType::Ed25519))); BEAST_EXPECT(cache.revoked(pk)); BEAST_EXPECT(cache.getSigningKey(pk) == pk); BEAST_EXPECT(cache.getMasterKey(kp0.first) == kp0.first); @@ -488,14 +488,14 @@ public: { testcase("Versioning"); - auto const sk = generateSecretKey(KeyType::ed25519, randomSeed()); - auto const pk = derivePublicKey(KeyType::ed25519, sk); + auto const sk = generateSecretKey(KeyType::Ed25519, randomSeed()); + auto const pk = derivePublicKey(KeyType::Ed25519, sk); - auto const ssk = generateSecretKey(KeyType::secp256k1, randomSeed()); - auto const spk = derivePublicKey(KeyType::secp256k1, ssk); + auto const ssk = generateSecretKey(KeyType::Secp256k1, randomSeed()); + auto const spk = derivePublicKey(KeyType::Secp256k1, ssk); auto buildManifestObject = [&](std::uint16_t version) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = 3; st[sfPublicKey] = pk; st[sfSigningPubKey] = spk; @@ -503,8 +503,8 @@ public: if (version != 0) st[sfVersion] = version; - sign(st, HashPrefix::manifest, KeyType::ed25519, sk, sfMasterSignature); - sign(st, HashPrefix::manifest, KeyType::secp256k1, ssk); + sign(st, HashPrefix::Manifest, KeyType::Ed25519, sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, KeyType::Secp256k1, ssk); Serializer s; st.add(s); @@ -523,7 +523,7 @@ public: void testManifestDeserialization() { - std::array const keyTypes{{KeyType::ed25519, KeyType::secp256k1}}; + std::array const keyTypes{{KeyType::Ed25519, KeyType::Secp256k1}}; std::uint32_t sequence = 0; @@ -573,7 +573,7 @@ public: std::optional domain, bool noSigningPublic = false, bool noSignature = false) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = seq; st[sfPublicKey] = pk; @@ -583,10 +583,10 @@ public: if (!noSigningPublic) st[sfSigningPubKey] = spk; - sign(st, HashPrefix::manifest, keyType, sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, keyType, sk, sfMasterSignature); if (!noSignature) - sign(st, HashPrefix::manifest, sKeyType, ssk); + sign(st, HashPrefix::Manifest, sKeyType, ssk); return st; }; @@ -724,14 +724,14 @@ public: } { // reject matching master & ephemeral keys - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = 314159; st[sfPublicKey] = pk; st[sfSigningPubKey] = pk; - sign(st, HashPrefix::manifest, keyType, sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, keyType, sk, sfMasterSignature); - sign(st, HashPrefix::manifest, sKeyType, sk); + sign(st, HashPrefix::Manifest, sKeyType, sk); BEAST_EXPECT(!deserializeManifest(toString(st))); } @@ -790,21 +790,21 @@ public: { testcase("Manifest Domain Names"); - auto const sk1 = generateSecretKey(KeyType::secp256k1, randomSeed()); - auto const pk1 = derivePublicKey(KeyType::secp256k1, sk1); + auto const sk1 = generateSecretKey(KeyType::Secp256k1, randomSeed()); + auto const pk1 = derivePublicKey(KeyType::Secp256k1, sk1); - auto const sk2 = generateSecretKey(KeyType::secp256k1, randomSeed()); - auto const pk2 = derivePublicKey(KeyType::secp256k1, sk2); + auto const sk2 = generateSecretKey(KeyType::Secp256k1, randomSeed()); + auto const pk2 = derivePublicKey(KeyType::Secp256k1, sk2); auto test = [&](std::string domain) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = 7; st[sfPublicKey] = pk1; st[sfDomain] = makeSlice(domain); st[sfSigningPubKey] = pk2; - sign(st, HashPrefix::manifest, KeyType::secp256k1, sk1, sfMasterSignature); - sign(st, HashPrefix::manifest, KeyType::secp256k1, sk2); + sign(st, HashPrefix::Manifest, KeyType::Secp256k1, sk1, sfMasterSignature); + sign(st, HashPrefix::Manifest, KeyType::Secp256k1, sk2); Serializer s; st.add(s); @@ -870,72 +870,71 @@ public: { testcase("apply"); - auto const sk_a = randomSecretKey(); - auto const pk_a = derivePublicKey(KeyType::ed25519, sk_a); - auto const kp_a0 = randomKeyPair(KeyType::secp256k1); - auto const kp_a1 = randomKeyPair(KeyType::secp256k1); - auto const s_a0 = - makeManifest(sk_a, KeyType::ed25519, kp_a0.second, KeyType::secp256k1, 0); - auto const s_a1 = - makeManifest(sk_a, KeyType::ed25519, kp_a1.second, KeyType::secp256k1, 1); - auto const s_a2 = - makeManifest(sk_a, KeyType::ed25519, kp_a1.second, KeyType::secp256k1, 2); - auto const s_aMax = makeRevocation(sk_a, KeyType::ed25519); + auto const skA = randomSecretKey(); + auto const pkA = derivePublicKey(KeyType::Ed25519, skA); + auto const kpA0 = randomKeyPair(KeyType::Secp256k1); + auto const kpA1 = randomKeyPair(KeyType::Secp256k1); + auto const sA0 = + makeManifest(skA, KeyType::Ed25519, kpA0.second, KeyType::Secp256k1, 0); + auto const sA1 = + makeManifest(skA, KeyType::Ed25519, kpA1.second, KeyType::Secp256k1, 1); + auto const sA2 = + makeManifest(skA, KeyType::Ed25519, kpA1.second, KeyType::Secp256k1, 2); + auto const sAMax = makeRevocation(skA, KeyType::Ed25519); - auto const sk_b = randomSecretKey(); - auto const kp_b0 = randomKeyPair(KeyType::secp256k1); - auto const kp_b1 = randomKeyPair(KeyType::secp256k1); - auto const kp_b2 = randomKeyPair(KeyType::secp256k1); - auto const s_b0 = - makeManifest(sk_b, KeyType::ed25519, kp_b0.second, KeyType::secp256k1, 0); - auto const s_b1 = makeManifest( - sk_b, - KeyType::ed25519, - kp_b1.second, - KeyType::secp256k1, + auto const skB = randomSecretKey(); + auto const kpB0 = randomKeyPair(KeyType::Secp256k1); + auto const kpB1 = randomKeyPair(KeyType::Secp256k1); + auto const kpB2 = randomKeyPair(KeyType::Secp256k1); + auto const sB0 = + makeManifest(skB, KeyType::Ed25519, kpB0.second, KeyType::Secp256k1, 0); + auto const sB1 = makeManifest( + skB, + KeyType::Ed25519, + kpB1.second, + KeyType::Secp256k1, 1, true); // invalidSig - auto const s_b2 = - makeManifest(sk_b, KeyType::ed25519, kp_b2.second, KeyType::ed25519, 2); + auto const sB2 = makeManifest(skB, KeyType::Ed25519, kpB2.second, KeyType::Ed25519, 2); - auto const fake = s_b2.serialized + '\0'; + auto const fake = sB2.serialized + '\0'; // applyManifest should accept new manifests with // higher sequence numbers auto const seq0 = cache.sequence(); - BEAST_EXPECT(cache.applyManifest(clone(s_a0)) == ManifestDisposition::accepted); + BEAST_EXPECT(cache.applyManifest(clone(sA0)) == ManifestDisposition::Accepted); BEAST_EXPECT(cache.sequence() > seq0); auto const seq1 = cache.sequence(); - BEAST_EXPECT(cache.applyManifest(clone(s_a0)) == ManifestDisposition::stale); + BEAST_EXPECT(cache.applyManifest(clone(sA0)) == ManifestDisposition::Stale); BEAST_EXPECT(cache.sequence() == seq1); - BEAST_EXPECT(cache.applyManifest(clone(s_a1)) == ManifestDisposition::accepted); - BEAST_EXPECT(cache.applyManifest(clone(s_a1)) == ManifestDisposition::stale); - BEAST_EXPECT(cache.applyManifest(clone(s_a0)) == ManifestDisposition::stale); + BEAST_EXPECT(cache.applyManifest(clone(sA1)) == ManifestDisposition::Accepted); + BEAST_EXPECT(cache.applyManifest(clone(sA1)) == ManifestDisposition::Stale); + BEAST_EXPECT(cache.applyManifest(clone(sA0)) == ManifestDisposition::Stale); - BEAST_EXPECT(cache.applyManifest(clone(s_a2)) == ManifestDisposition::badEphemeralKey); + BEAST_EXPECT(cache.applyManifest(clone(sA2)) == ManifestDisposition::BadEphemeralKey); // applyManifest should accept manifests with max sequence numbers // that revoke the master public key - BEAST_EXPECT(!cache.revoked(pk_a)); - BEAST_EXPECT(s_aMax.revoked()); - BEAST_EXPECT(cache.applyManifest(clone(s_aMax)) == ManifestDisposition::accepted); - BEAST_EXPECT(cache.applyManifest(clone(s_aMax)) == ManifestDisposition::stale); - BEAST_EXPECT(cache.applyManifest(clone(s_a1)) == ManifestDisposition::stale); - BEAST_EXPECT(cache.applyManifest(clone(s_a0)) == ManifestDisposition::stale); - BEAST_EXPECT(cache.revoked(pk_a)); + BEAST_EXPECT(!cache.revoked(pkA)); + BEAST_EXPECT(sAMax.revoked()); + BEAST_EXPECT(cache.applyManifest(clone(sAMax)) == ManifestDisposition::Accepted); + BEAST_EXPECT(cache.applyManifest(clone(sAMax)) == ManifestDisposition::Stale); + BEAST_EXPECT(cache.applyManifest(clone(sA1)) == ManifestDisposition::Stale); + BEAST_EXPECT(cache.applyManifest(clone(sA0)) == ManifestDisposition::Stale); + BEAST_EXPECT(cache.revoked(pkA)); // applyManifest should reject manifests with invalid signatures - BEAST_EXPECT(cache.applyManifest(clone(s_b0)) == ManifestDisposition::accepted); - BEAST_EXPECT(cache.applyManifest(clone(s_b0)) == ManifestDisposition::stale); + BEAST_EXPECT(cache.applyManifest(clone(sB0)) == ManifestDisposition::Accepted); + BEAST_EXPECT(cache.applyManifest(clone(sB0)) == ManifestDisposition::Stale); BEAST_EXPECT(!deserializeManifest(fake)); - BEAST_EXPECT(cache.applyManifest(clone(s_b1)) == ManifestDisposition::invalid); - BEAST_EXPECT(cache.applyManifest(clone(s_b2)) == ManifestDisposition::accepted); + BEAST_EXPECT(cache.applyManifest(clone(sB1)) == ManifestDisposition::Invalid); + BEAST_EXPECT(cache.applyManifest(clone(sB2)) == ManifestDisposition::Accepted); - auto const s_c0 = makeManifest( - kp_b2.second, KeyType::ed25519, randomSecretKey(), KeyType::ed25519, 47); - BEAST_EXPECT(cache.applyManifest(clone(s_c0)) == ManifestDisposition::badMasterKey); + auto const sC0 = makeManifest( + kpB2.second, KeyType::Ed25519, randomSecretKey(), KeyType::Ed25519, 47); + BEAST_EXPECT(cache.applyManifest(clone(sC0)) == ManifestDisposition::BadMasterKey); } testLoadStore(cache); diff --git a/src/test/app/MultiSign_test.cpp b/src/test/app/MultiSign_test.cpp index f41042644f..55e1b73158 100644 --- a/src/test/app/MultiSign_test.cpp +++ b/src/test/app/MultiSign_test.cpp @@ -47,41 +47,41 @@ namespace xrpl::test { -class MultiSign_test : public beast::unit_test::suite +class MultiSign_test : public beast::unit_test::Suite { // Unfunded accounts to use for phantom signing. - jtx::Account const bogie{"bogie", KeyType::secp256k1}; - jtx::Account const demon{"demon", KeyType::ed25519}; - jtx::Account const ghost{"ghost", KeyType::secp256k1}; - jtx::Account const haunt{"haunt", KeyType::ed25519}; - jtx::Account const jinni{"jinni", KeyType::secp256k1}; - jtx::Account const phase{"phase", KeyType::ed25519}; - jtx::Account const shade{"shade", KeyType::secp256k1}; - jtx::Account const spook{"spook", KeyType::ed25519}; - jtx::Account const acc10{"acc10", KeyType::ed25519}; - jtx::Account const acc11{"acc11", KeyType::ed25519}; - jtx::Account const acc12{"acc12", KeyType::ed25519}; - jtx::Account const acc13{"acc13", KeyType::ed25519}; - jtx::Account const acc14{"acc14", KeyType::ed25519}; - jtx::Account const acc15{"acc15", KeyType::ed25519}; - jtx::Account const acc16{"acc16", KeyType::ed25519}; - jtx::Account const acc17{"acc17", KeyType::ed25519}; - jtx::Account const acc18{"acc18", KeyType::ed25519}; - jtx::Account const acc19{"acc19", KeyType::ed25519}; - jtx::Account const acc20{"acc20", KeyType::ed25519}; - jtx::Account const acc21{"acc21", KeyType::ed25519}; - jtx::Account const acc22{"acc22", KeyType::ed25519}; - jtx::Account const acc23{"acc23", KeyType::ed25519}; - jtx::Account const acc24{"acc24", KeyType::ed25519}; - jtx::Account const acc25{"acc25", KeyType::ed25519}; - jtx::Account const acc26{"acc26", KeyType::ed25519}; - jtx::Account const acc27{"acc27", KeyType::ed25519}; - jtx::Account const acc28{"acc28", KeyType::ed25519}; - jtx::Account const acc29{"acc29", KeyType::ed25519}; - jtx::Account const acc30{"acc30", KeyType::ed25519}; - jtx::Account const acc31{"acc31", KeyType::ed25519}; - jtx::Account const acc32{"acc32", KeyType::ed25519}; - jtx::Account const acc33{"acc33", KeyType::ed25519}; + jtx::Account const bogie_{"bogie", KeyType::Secp256k1}; + jtx::Account const demon_{"demon", KeyType::Ed25519}; + jtx::Account const ghost_{"ghost", KeyType::Secp256k1}; + jtx::Account const haunt_{"haunt", KeyType::Ed25519}; + jtx::Account const jinni_{"jinni", KeyType::Secp256k1}; + jtx::Account const phase_{"phase", KeyType::Ed25519}; + jtx::Account const shade_{"shade", KeyType::Secp256k1}; + jtx::Account const spook_{"spook", KeyType::Ed25519}; + jtx::Account const acc10_{"acc10", KeyType::Ed25519}; + jtx::Account const acc11_{"acc11", KeyType::Ed25519}; + jtx::Account const acc12_{"acc12", KeyType::Ed25519}; + jtx::Account const acc13_{"acc13", KeyType::Ed25519}; + jtx::Account const acc14_{"acc14", KeyType::Ed25519}; + jtx::Account const acc15_{"acc15", KeyType::Ed25519}; + jtx::Account const acc16_{"acc16", KeyType::Ed25519}; + jtx::Account const acc17_{"acc17", KeyType::Ed25519}; + jtx::Account const acc18_{"acc18", KeyType::Ed25519}; + jtx::Account const acc19_{"acc19", KeyType::Ed25519}; + jtx::Account const acc20_{"acc20", KeyType::Ed25519}; + jtx::Account const acc21_{"acc21", KeyType::Ed25519}; + jtx::Account const acc22_{"acc22", KeyType::Ed25519}; + jtx::Account const acc23_{"acc23", KeyType::Ed25519}; + jtx::Account const acc24_{"acc24", KeyType::Ed25519}; + jtx::Account const acc25_{"acc25", KeyType::Ed25519}; + jtx::Account const acc26_{"acc26", KeyType::Ed25519}; + jtx::Account const acc27_{"acc27", KeyType::Ed25519}; + jtx::Account const acc28_{"acc28", KeyType::Ed25519}; + jtx::Account const acc29_{"acc29", KeyType::Ed25519}; + jtx::Account const acc30_{"acc30", KeyType::Ed25519}; + jtx::Account const acc31_{"acc31", KeyType::Ed25519}; + jtx::Account const acc32_{"acc32", KeyType::Ed25519}; + jtx::Account const acc33_{"acc33", KeyType::Ed25519}; public: void @@ -91,28 +91,28 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; // Pay alice enough to meet the initial reserve, but not enough to // meet the reserve for a SignerListSet. auto const fee = env.current()->fees().base; env.fund(XRP(250) - drops(1), alice); env.close(); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); { // Attach a signer list to alice. Should fail. - Json::Value const signersList = signers(alice, 1, {{bogie, 1}}); - env(signersList, ter(tecINSUFFICIENT_RESERVE)); + json::Value const signersList = signers(alice, 1, {{bogie_, 1}}); + env(signersList, Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); // Fund alice enough to set the signer list, then attach signers. env(pay(env.master, alice, fee + drops(1))); env.close(); env(signersList); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); } { // Pay alice enough to almost make the reserve for the biggest @@ -120,32 +120,32 @@ public: env(pay(env.master, alice, fee - drops(1))); // Replace with the biggest possible signer list. Should fail. - Json::Value const bigSigners = signers( + json::Value const bigSigners = signers( alice, 1, - {{bogie, 1}, - {demon, 1}, - {ghost, 1}, - {haunt, 1}, - {jinni, 1}, - {phase, 1}, - {shade, 1}, - {spook, 1}}); - env(bigSigners, ter(tecINSUFFICIENT_RESERVE)); + {{bogie_, 1}, + {demon_, 1}, + {ghost_, 1}, + {haunt_, 1}, + {jinni_, 1}, + {phase_, 1}, + {shade_, 1}, + {spook_, 1}}); + env(bigSigners, Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // Fund alice one more drop (plus the fee) and succeed. env(pay(env.master, alice, fee + drops(1))); env.close(); env(bigSigners); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); } // Remove alice's signer list and get the owner count back. - env(signers(alice, jtx::none)); + env(signers(alice, jtx::kNONE)); env.close(); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); } void @@ -155,15 +155,15 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); // Add alice as a multisigner for herself. Should fail. - env(signers(alice, 1, {{alice, 1}}), ter(temBAD_SIGNER)); + env(signers(alice, 1, {{alice, 1}}), Ter(temBAD_SIGNER)); // Add a signer with a weight of zero. Should fail. - env(signers(alice, 1, {{bogie, 0}}), ter(temBAD_WEIGHT)); + env(signers(alice, 1, {{bogie_, 0}}), Ter(temBAD_WEIGHT)); // Add a signer where the weight is too big. Should fail since // the weight field is only 16 bits. The jtx framework can't do @@ -175,49 +175,50 @@ public: env(signers( alice, 1, - {{bogie, 1}, - {demon, 1}, - {ghost, 1}, - {haunt, 1}, - {jinni, 1}, - {phase, 1}, - {demon, 1}, - {spook, 1}}), - ter(temBAD_SIGNER)); + {{bogie_, 1}, + {demon_, 1}, + {ghost_, 1}, + {haunt_, 1}, + {jinni_, 1}, + {phase_, 1}, + {demon_, 1}, + {spook_, 1}}), + Ter(temBAD_SIGNER)); // Set a quorum of zero. Should fail. - env(signers(alice, 0, {{bogie, 1}}), ter(temMALFORMED)); + env(signers(alice, 0, {{bogie_, 1}}), Ter(temMALFORMED)); // Make a signer list where the quorum can't be met. Should fail. env(signers( alice, 9, - {{bogie, 1}, - {demon, 1}, - {ghost, 1}, - {haunt, 1}, - {jinni, 1}, - {phase, 1}, - {shade, 1}, - {spook, 1}}), - ter(temBAD_QUORUM)); + {{bogie_, 1}, + {demon_, 1}, + {ghost_, 1}, + {haunt_, 1}, + {jinni_, 1}, + {phase_, 1}, + {shade_, 1}, + {spook_, 1}}), + Ter(temBAD_QUORUM)); // Make a signer list that's too big. Should fail. - Account const spare("spare", KeyType::secp256k1); + Account const spare("spare", KeyType::Secp256k1); env(signers( alice, 1, - std::vector{ - {bogie, 1}, {demon, 1}, {ghost, 1}, {haunt, 1}, {jinni, 1}, {phase, 1}, - {shade, 1}, {spook, 1}, {spare, 1}, {acc10, 1}, {acc11, 1}, {acc12, 1}, - {acc13, 1}, {acc14, 1}, {acc15, 1}, {acc16, 1}, {acc17, 1}, {acc18, 1}, - {acc19, 1}, {acc20, 1}, {acc21, 1}, {acc22, 1}, {acc23, 1}, {acc24, 1}, - {acc25, 1}, {acc26, 1}, {acc27, 1}, {acc28, 1}, {acc29, 1}, {acc30, 1}, - {acc31, 1}, {acc32, 1}, {acc33, 1}, + std::vector{ + {bogie_, 1}, {demon_, 1}, {ghost_, 1}, {haunt_, 1}, {jinni_, 1}, {phase_, 1}, + {shade_, 1}, {spook_, 1}, {spare, 1}, {acc10_, 1}, {acc11_, 1}, {acc12_, 1}, + {acc13_, 1}, {acc14_, 1}, {acc15_, 1}, {acc16_, 1}, {acc17_, 1}, {acc18_, 1}, + {acc19_, 1}, {acc20_, 1}, {acc21_, 1}, {acc22_, 1}, {acc23_, 1}, {acc24_, 1}, + {acc25_, 1}, {acc26_, 1}, {acc27_, 1}, {acc28_, 1}, {acc29_, 1}, {acc30_, 1}, + {acc31_, 1}, {acc32_, 1}, {acc33_, 1}, }), - ter(temMALFORMED)); + Ter(temMALFORMED)); + // clang-format on env.close(); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); } void @@ -227,58 +228,58 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); // Attach phantom signers to alice and use them for a transaction. - env(signers(alice, 1, {{bogie, 1}, {demon, 1}})); + env(signers(alice, 1, {{bogie_, 1}, {demon_, 1}})); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // This should work. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, demon), fee(3 * baseFee)); + env(noop(alice), Msig(bogie_, demon_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Either signer alone should work. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee(2 * baseFee)); + env(noop(alice), Msig(bogie_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(demon), fee(2 * baseFee)); + env(noop(alice), Msig(demon_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Duplicate signers should fail. aliceSeq = env.seq(alice); env(noop(alice), - msig(demon, demon), - fee(3 * baseFee), - rpc("invalidTransaction", "fails local checks: Duplicate Signers not allowed.")); + Msig(demon_, demon_), + Fee(3 * baseFee), + Rpc("invalidTransaction", "fails local checks: Duplicate Signers not allowed.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // A non-signer should fail. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, spook), fee(3 * baseFee), ter(tefBAD_SIGNATURE)); + env(noop(alice), Msig(bogie_, spook_), Fee(3 * baseFee), Ter(tefBAD_SIGNATURE)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Don't meet the quorum. Should fail. - env(signers(alice, 2, {{bogie, 1}, {demon, 1}})); + env(signers(alice, 2, {{bogie_, 1}, {demon_, 1}})); aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee(2 * baseFee), ter(tefBAD_QUORUM)); + env(noop(alice), Msig(bogie_), Fee(2 * baseFee), Ter(tefBAD_QUORUM)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Meet the quorum. Should succeed. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, demon), fee(3 * baseFee)); + env(noop(alice), Msig(bogie_, demon_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); } @@ -290,7 +291,7 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); @@ -298,28 +299,28 @@ public: env(signers( alice, 1, - {{bogie, 1}, - {demon, 1}, - {ghost, 1}, - {haunt, 1}, - {jinni, 1}, - {phase, 1}, - {shade, 1}, - {spook, 1}})); + {{bogie_, 1}, + {demon_, 1}, + {ghost_, 1}, + {haunt_, 1}, + {jinni_, 1}, + {phase_, 1}, + {shade_, 1}, + {spook_, 1}})); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // This should work. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee(2 * baseFee)); + env(noop(alice), Msig(bogie_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // This should fail because the fee is too small. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee((2 * baseFee) - 1), ter(telINSUF_FEE_P)); + env(noop(alice), Msig(bogie_), Fee((2 * baseFee) - 1), Ter(telINSUF_FEE_P)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -327,8 +328,8 @@ public: // This should work. aliceSeq = env.seq(alice); env(noop(alice), - msig(bogie, demon, ghost, haunt, jinni, phase, shade, spook), - fee(9 * baseFee)); + Msig(bogie_, demon_, ghost_, haunt_, jinni_, phase_, shade_, spook_), + Fee(9 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); @@ -336,9 +337,9 @@ public: // This should fail because the fee is too small. aliceSeq = env.seq(alice); env(noop(alice), - msig(bogie, demon, ghost, haunt, jinni, phase, shade, spook), - fee((9 * baseFee) - 1), - ter(telINSUF_FEE_P)); + Msig(bogie_, demon_, ghost_, haunt_, jinni_, phase_, shade_, spook_), + Fee((9 * baseFee) - 1), + Ter(telINSUF_FEE_P)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -351,22 +352,22 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); // The signatures in a transaction must be submitted in sorted order. // Make sure the transaction fails if they are not. - env(signers(alice, 1, {{bogie, 1}, {demon, 1}})); + env(signers(alice, 1, {{bogie_, 1}, {demon_, 1}})); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); - msig phantoms{bogie, demon}; + Msig phantoms{bogie_, demon_}; std::ranges::reverse(phantoms.signers); std::uint32_t const aliceSeq = env.seq(alice); env(noop(alice), phantoms, - rpc("invalidTransaction", "fails local checks: Unsorted Signers array.")); + Rpc("invalidTransaction", "fails local checks: Unsorted Signers array.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); } @@ -378,50 +379,50 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; - Account const becky{"becky", KeyType::secp256k1}; - Account const cheri{"cheri", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; + Account const becky{"becky", KeyType::Secp256k1}; + Account const cheri{"cheri", KeyType::Ed25519}; env.fund(XRP(1000), alice, becky, cheri); env.close(); // For a different situation, give alice a regular key but don't use it. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); env.close(); std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), sig(alice)); - env(noop(alice), sig(alie)); + env(noop(alice), Sig(alice)); + env(noop(alice), Sig(alie)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 2); // Attach signers to alice - env(signers(alice, 4, {{becky, 3}, {cheri, 4}}), sig(alice)); + env(signers(alice, 4, {{becky, 3}, {cheri, 4}}), Sig(alice)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // Attempt a multisigned transaction that meets the quorum. auto const baseFee = env.current()->fees().base; aliceSeq = env.seq(alice); - env(noop(alice), msig(cheri), fee(2 * baseFee)); + env(noop(alice), Msig(cheri), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // If we don't meet the quorum the transaction should fail. aliceSeq = env.seq(alice); - env(noop(alice), msig(becky), fee(2 * baseFee), ter(tefBAD_QUORUM)); + env(noop(alice), Msig(becky), Fee(2 * baseFee), Ter(tefBAD_QUORUM)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Give becky and cheri regular keys. - Account const beck{"beck", KeyType::ed25519}; + Account const beck{"beck", KeyType::Ed25519}; env(regkey(becky, beck)); - Account const cher{"cher", KeyType::ed25519}; + Account const cher{"cher", KeyType::Ed25519}; env(regkey(cheri, cher)); env.close(); // becky's and cheri's master keys should still work. aliceSeq = env.seq(alice); - env(noop(alice), msig(becky, cheri), fee(3 * baseFee)); + env(noop(alice), Msig(becky, cheri), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); } @@ -433,55 +434,55 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const cheri{"cheri", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const cheri{"cheri", KeyType::Secp256k1}; env.fund(XRP(1000), alice, becky, cheri); env.close(); // Attach signers to alice. - env(signers(alice, 1, {{becky, 1}, {cheri, 1}}), sig(alice)); + env(signers(alice, 1, {{becky, 1}, {cheri, 1}}), Sig(alice)); // Give everyone regular keys. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); - Account const beck{"beck", KeyType::secp256k1}; + Account const beck{"beck", KeyType::Secp256k1}; env(regkey(becky, beck)); - Account const cher{"cher", KeyType::ed25519}; + Account const cher{"cher", KeyType::Ed25519}; env(regkey(cheri, cher)); env.close(); // Disable cheri's master key to mix things up. - env(fset(cheri, asfDisableMaster), sig(cheri)); + env(fset(cheri, asfDisableMaster), Sig(cheri)); env.close(); // Attempt a multisigned transaction that meets the quorum. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), msig(Reg{cheri, cher}), fee(2 * baseFee)); + env(noop(alice), Msig(Reg{cheri, cher}), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // cheri should not be able to multisign using her master key. aliceSeq = env.seq(alice); - env(noop(alice), msig(cheri), fee(2 * baseFee), ter(tefMASTER_DISABLED)); + env(noop(alice), Msig(cheri), Fee(2 * baseFee), Ter(tefMASTER_DISABLED)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // becky should be able to multisign using either of her keys. aliceSeq = env.seq(alice); - env(noop(alice), msig(becky), fee(2 * baseFee)); + env(noop(alice), Msig(becky), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(Reg{becky, beck}), fee(2 * baseFee)); + env(noop(alice), Msig(Reg{becky, beck}), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Both becky and cheri should be able to sign using regular keys. aliceSeq = env.seq(alice); - env(noop(alice), fee(3 * baseFee), msig(Reg{becky, beck}, Reg{cheri, cher})); + env(noop(alice), Fee(3 * baseFee), Msig(Reg{becky, beck}, Reg{cheri, cher})); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); } @@ -499,32 +500,32 @@ public: return cfg; }), features); - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const cheri{"cheri", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const cheri{"cheri", KeyType::Secp256k1}; env.fund(XRP(1000), alice, becky, cheri); env.close(); // Attach signers to alice. - env(signers(alice, 2, {{becky, 1}, {cheri, 1}}), sig(alice)); + env(signers(alice, 2, {{becky, 1}, {cheri, 1}}), Sig(alice)); // Give everyone regular keys. - Account const beck{"beck", KeyType::secp256k1}; + Account const beck{"beck", KeyType::Secp256k1}; env(regkey(becky, beck)); - Account const cher{"cher", KeyType::ed25519}; + Account const cher{"cher", KeyType::Ed25519}; env(regkey(cheri, cher)); env.close(); // Disable cheri's master key to mix things up. - env(fset(cheri, asfDisableMaster), sig(cheri)); + env(fset(cheri, asfDisableMaster), Sig(cheri)); env.close(); auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = 0; // these represent oft-repeated setup for input json below - auto setup_tx = [&]() -> Json::Value { - Json::Value jv; + auto setupTx = [&]() -> json::Value { + json::Value jv; jv[jss::tx_json][jss::Account] = alice.human(); jv[jss::tx_json][jss::TransactionType] = jss::AccountSet; jv[jss::tx_json][jss::Fee] = (8 * baseFee).jsonClipped(); @@ -532,12 +533,12 @@ public: jv[jss::tx_json][jss::SigningPubKey] = ""; return jv; }; - auto cheri_sign = [&](Json::Value& jv) { + auto cheriSign = [&](json::Value& jv) { jv[jss::account] = cheri.human(); jv[jss::key_type] = "ed25519"; jv[jss::passphrase] = cher.name(); }; - auto becky_sign = [&](Json::Value& jv) { + auto beckySign = [&](json::Value& jv) { jv[jss::account] = becky.human(); jv[jss::secret] = beck.name(); }; @@ -546,22 +547,22 @@ public: // Attempt a multisigned transaction that meets the quorum. // using sign_for and submit_multisigned aliceSeq = env.seq(alice); - Json::Value jv_one = setup_tx(); - cheri_sign(jv_one); - auto jrr = env.rpc("json", "sign_for", to_string(jv_one))[jss::result]; + json::Value jvOne = setupTx(); + cheriSign(jvOne); + auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); // for the second sign_for, use the returned tx_json with // first signer info - Json::Value jv_two; - jv_two[jss::tx_json] = jrr[jss::tx_json]; - becky_sign(jv_two); - jrr = env.rpc("json", "sign_for", to_string(jv_two))[jss::result]; + json::Value jvTwo; + jvTwo[jss::tx_json] = jrr[jss::tx_json]; + beckySign(jvTwo); + jrr = env.rpc("json", "sign_for", to_string(jvTwo))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); - Json::Value jv_submit; - jv_submit[jss::tx_json] = jrr[jss::tx_json]; - jrr = env.rpc("json", "submit_multisigned", to_string(jv_submit))[jss::result]; + json::Value jvSubmit; + jvSubmit[jss::tx_json] = jrr[jss::tx_json]; + jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); @@ -570,10 +571,10 @@ public: { // failure case -- SigningPubKey not empty aliceSeq = env.seq(alice); - Json::Value jv_one = setup_tx(); - jv_one[jss::tx_json][jss::SigningPubKey] = strHex(alice.pk().slice()); - cheri_sign(jv_one); - auto jrr = env.rpc("json", "sign_for", to_string(jv_one))[jss::result]; + json::Value jvOne = setupTx(); + jvOne[jss::tx_json][jss::SigningPubKey] = strHex(alice.pk().slice()); + cheriSign(jvOne); + auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "error"); BEAST_EXPECT(jrr[jss::error] == "invalidParams"); BEAST_EXPECT( @@ -584,23 +585,23 @@ public: { // failure case - bad fee aliceSeq = env.seq(alice); - Json::Value jv_one = setup_tx(); - jv_one[jss::tx_json][jss::Fee] = -1; - cheri_sign(jv_one); - auto jrr = env.rpc("json", "sign_for", to_string(jv_one))[jss::result]; + json::Value jvOne = setupTx(); + jvOne[jss::tx_json][jss::Fee] = -1; + cheriSign(jvOne); + auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); // for the second sign_for, use the returned tx_json with // first signer info - Json::Value jv_two; - jv_two[jss::tx_json] = jrr[jss::tx_json]; - becky_sign(jv_two); - jrr = env.rpc("json", "sign_for", to_string(jv_two))[jss::result]; + json::Value jvTwo; + jvTwo[jss::tx_json] = jrr[jss::tx_json]; + beckySign(jvTwo); + jrr = env.rpc("json", "sign_for", to_string(jvTwo))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); - Json::Value jv_submit; - jv_submit[jss::tx_json] = jrr[jss::tx_json]; - jrr = env.rpc("json", "submit_multisigned", to_string(jv_submit))[jss::result]; + json::Value jvSubmit; + jvSubmit[jss::tx_json] = jrr[jss::tx_json]; + jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "error"); BEAST_EXPECT(jrr[jss::error] == "invalidParams"); BEAST_EXPECT( @@ -610,23 +611,23 @@ public: { // failure case - bad fee v2 aliceSeq = env.seq(alice); - Json::Value jv_one = setup_tx(); - jv_one[jss::tx_json][jss::Fee] = alice["USD"](10).value().getFullText(); - cheri_sign(jv_one); - auto jrr = env.rpc("json", "sign_for", to_string(jv_one))[jss::result]; + json::Value jvOne = setupTx(); + jvOne[jss::tx_json][jss::Fee] = alice["USD"](10).value().getFullText(); + cheriSign(jvOne); + auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); // for the second sign_for, use the returned tx_json with // first signer info - Json::Value jv_two; - jv_two[jss::tx_json] = jrr[jss::tx_json]; - becky_sign(jv_two); - jrr = env.rpc("json", "sign_for", to_string(jv_two))[jss::result]; + json::Value jvTwo; + jvTwo[jss::tx_json] = jrr[jss::tx_json]; + beckySign(jvTwo); + jrr = env.rpc("json", "sign_for", to_string(jvTwo))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); - Json::Value jv_submit; - jv_submit[jss::tx_json] = jrr[jss::tx_json]; - jrr = env.rpc("json", "submit_multisigned", to_string(jv_submit))[jss::result]; + json::Value jvSubmit; + jvSubmit[jss::tx_json] = jrr[jss::tx_json]; + jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "error"); BEAST_EXPECT(jrr[jss::error] == "internal"); BEAST_EXPECT(jrr[jss::error_message] == "Internal error."); @@ -635,7 +636,7 @@ public: { // cheri should not be able to multisign using her master key. aliceSeq = env.seq(alice); - Json::Value jv = setup_tx(); + json::Value jv = setupTx(); jv[jss::account] = cheri.human(); jv[jss::secret] = cheri.name(); auto jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result]; @@ -649,24 +650,24 @@ public: // Unlike cheri, becky should also be able to sign using her master // key aliceSeq = env.seq(alice); - Json::Value jv_one = setup_tx(); - cheri_sign(jv_one); - auto jrr = env.rpc("json", "sign_for", to_string(jv_one))[jss::result]; + json::Value jvOne = setupTx(); + cheriSign(jvOne); + auto jrr = env.rpc("json", "sign_for", to_string(jvOne))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); // for the second sign_for, use the returned tx_json with // first signer info - Json::Value jv_two; - jv_two[jss::tx_json] = jrr[jss::tx_json]; - jv_two[jss::account] = becky.human(); - jv_two[jss::key_type] = "ed25519"; - jv_two[jss::passphrase] = becky.name(); - jrr = env.rpc("json", "sign_for", to_string(jv_two))[jss::result]; + json::Value jvTwo; + jvTwo[jss::tx_json] = jrr[jss::tx_json]; + jvTwo[jss::account] = becky.human(); + jvTwo[jss::key_type] = "ed25519"; + jvTwo[jss::passphrase] = becky.name(); + jrr = env.rpc("json", "sign_for", to_string(jvTwo))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); - Json::Value jv_submit; - jv_submit[jss::tx_json] = jrr[jss::tx_json]; - jrr = env.rpc("json", "submit_multisigned", to_string(jv_submit))[jss::result]; + json::Value jvSubmit; + jvSubmit[jss::tx_json] = jrr[jss::tx_json]; + jrr = env.rpc("json", "submit_multisigned", to_string(jvSubmit))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); @@ -674,9 +675,9 @@ public: { // check for bad or bogus accounts in the tx - Json::Value jv = setup_tx(); + json::Value jv = setupTx(); jv[jss::tx_json][jss::Account] = "DEADBEEF"; - cheri_sign(jv); + cheriSign(jv); auto jrr = env.rpc("json", "sign_for", to_string(jv))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "error"); BEAST_EXPECT(jrr[jss::error] == "srcActMalformed"); @@ -690,9 +691,9 @@ public: { aliceSeq = env.seq(alice); - Json::Value jv = setup_tx(); - jv[jss::tx_json][sfSigners.fieldName] = Json::Value{Json::arrayValue}; - becky_sign(jv); + json::Value jv = setupTx(); + jv[jss::tx_json][sfSigners.fieldName] = json::Value{json::ArrayValue}; + beckySign(jv); auto jrr = env.rpc("json", "submit_multisigned", to_string(jv))[jss::result]; BEAST_EXPECT(jrr[jss::status] == "error"); BEAST_EXPECT(jrr[jss::error] == "invalidParams"); @@ -709,65 +710,65 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const cheri{"cheri", KeyType::secp256k1}; - Account const daria{"daria", KeyType::ed25519}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const cheri{"cheri", KeyType::Secp256k1}; + Account const daria{"daria", KeyType::Ed25519}; env.fund(XRP(1000), alice, becky, cheri, daria); env.close(); // alice uses a regular key with the master disabled. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // becky is master only without a regular key. // cheri has a regular key, but leaves the master key enabled. - Account const cher{"cher", KeyType::secp256k1}; + Account const cher{"cher", KeyType::Secp256k1}; env(regkey(cheri, cher)); // daria has a regular key and disables her master key. - Account const dari{"dari", KeyType::ed25519}; + Account const dari{"dari", KeyType::Ed25519}; env(regkey(daria, dari)); - env(fset(daria, asfDisableMaster), sig(daria)); + env(fset(daria, asfDisableMaster), Sig(daria)); env.close(); // Attach signers to alice. - env(signers(alice, 1, {{becky, 1}, {cheri, 1}, {daria, 1}, {jinni, 1}}), sig(alie)); + env(signers(alice, 1, {{becky, 1}, {cheri, 1}, {daria, 1}, {jinni_, 1}}), Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // Each type of signer should succeed individually. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), msig(becky), fee(2 * baseFee)); + env(noop(alice), Msig(becky), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(cheri), fee(2 * baseFee)); + env(noop(alice), Msig(cheri), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(Reg{cheri, cher}), fee(2 * baseFee)); + env(noop(alice), Msig(Reg{cheri, cher}), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(Reg{daria, dari}), fee(2 * baseFee)); + env(noop(alice), Msig(Reg{daria, dari}), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(jinni), fee(2 * baseFee)); + env(noop(alice), Msig(jinni_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Should also work if all signers sign. aliceSeq = env.seq(alice); - env(noop(alice), fee(5 * baseFee), msig(becky, Reg{cheri, cher}, Reg{daria, dari}, jinni)); + env(noop(alice), Fee(5 * baseFee), Msig(becky, Reg{cheri, cher}, Reg{daria, dari}, jinni_)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); @@ -775,19 +776,19 @@ public: env(signers( alice, 0x3FFFC, - {{becky, 0xFFFF}, {cheri, 0xFFFF}, {daria, 0xFFFF}, {jinni, 0xFFFF}}), - sig(alie)); + {{becky, 0xFFFF}, {cheri, 0xFFFF}, {daria, 0xFFFF}, {jinni_, 0xFFFF}}), + Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); aliceSeq = env.seq(alice); - env(noop(alice), fee(9 * baseFee), msig(becky, Reg{cheri, cher}, Reg{daria, dari}, jinni)); + env(noop(alice), Fee(9 * baseFee), Msig(becky, Reg{cheri, cher}, Reg{daria, dari}, jinni_)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Try cheri with both key types. aliceSeq = env.seq(alice); - env(noop(alice), fee(5 * baseFee), msig(becky, cheri, Reg{daria, dari}, jinni)); + env(noop(alice), Fee(5 * baseFee), Msig(becky, cheri, Reg{daria, dari}, jinni_)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); @@ -798,35 +799,36 @@ public: {{becky, 0xFFFF}, {cheri, 0xFFFF}, {daria, 0xFFFF}, - {haunt, 0xFFFF}, - {jinni, 0xFFFF}, - {phase, 0xFFFF}, - {shade, 0xFFFF}, - {spook, 0xFFFF}}), - sig(alie)); + {haunt_, 0xFFFF}, + {jinni_, 0xFFFF}, + {phase_, 0xFFFF}, + {shade_, 0xFFFF}, + {spook_, 0xFFFF}}), + Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); aliceSeq = env.seq(alice); env(noop(alice), - fee(9 * baseFee), - msig(becky, Reg{cheri, cher}, Reg{daria, dari}, haunt, jinni, phase, shade, spook)); + Fee(9 * baseFee), + Msig( + becky, Reg{cheri, cher}, Reg{daria, dari}, haunt_, jinni_, phase_, shade_, spook_)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // One signer short should fail. aliceSeq = env.seq(alice); env(noop(alice), - msig(becky, cheri, haunt, jinni, phase, shade, spook), - fee(8 * baseFee), - ter(tefBAD_QUORUM)); + Msig(becky, cheri, haunt_, jinni_, phase_, shade_, spook_), + Fee(8 * baseFee), + Ter(tefBAD_QUORUM)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Remove alice's signer list and get the owner count back. - env(signers(alice, jtx::none), sig(alie)); + env(signers(alice, jtx::kNONE), Sig(alie)); env.close(); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); } // We want to always leave an account signable. Make sure the that we @@ -838,7 +840,7 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); @@ -859,51 +861,51 @@ public: // Master key tests. // M0: A lone master key cannot be disabled. - env(fset(alice, asfDisableMaster), sig(alice), ter(tecNO_ALTERNATIVE_KEY)); + env(fset(alice, asfDisableMaster), Sig(alice), Ter(tecNO_ALTERNATIVE_KEY)); // Add a regular key. - Account const alie{"alie", KeyType::ed25519}; + Account const alie{"alie", KeyType::Ed25519}; env(regkey(alice, alie)); // M1: The master key can be disabled if there's a regular key. - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // R0: A lone regular key cannot be removed. - env(regkey(alice, disabled), sig(alie), ter(tecNO_ALTERNATIVE_KEY)); + env(regkey(alice, kDISABLED), Sig(alie), Ter(tecNO_ALTERNATIVE_KEY)); // Add a signer list. - env(signers(alice, 1, {{bogie, 1}}), sig(alie)); + env(signers(alice, 1, {{bogie_, 1}}), Sig(alie)); // R1: The regular key can be removed if there's a signer list. - env(regkey(alice, disabled), sig(alie)); + env(regkey(alice, kDISABLED), Sig(alie)); // L0: A lone signer list cannot be removed. auto const baseFee = env.current()->fees().base; - env(signers(alice, jtx::none), msig(bogie), fee(2 * baseFee), ter(tecNO_ALTERNATIVE_KEY)); + env(signers(alice, jtx::kNONE), Msig(bogie_), Fee(2 * baseFee), Ter(tecNO_ALTERNATIVE_KEY)); // Enable the master key. - env(fclear(alice, asfDisableMaster), msig(bogie), fee(2 * baseFee)); + env(fclear(alice, asfDisableMaster), Msig(bogie_), Fee(2 * baseFee)); // L1: The signer list can be removed if the master key is enabled. - env(signers(alice, jtx::none), msig(bogie), fee(2 * baseFee)); + env(signers(alice, jtx::kNONE), Msig(bogie_), Fee(2 * baseFee)); // Add a signer list. - env(signers(alice, 1, {{bogie, 1}}), sig(alice)); + env(signers(alice, 1, {{bogie_, 1}}), Sig(alice)); // M2: The master key can be disabled if there's a signer list. - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // Add a regular key. - env(regkey(alice, alie), msig(bogie), fee(2 * baseFee)); + env(regkey(alice, alie), Msig(bogie_), Fee(2 * baseFee)); // L2: The signer list can be removed if there's a regular key. - env(signers(alice, jtx::none), sig(alie)); + env(signers(alice, jtx::kNONE), Sig(alie)); // Enable the master key. - env(fclear(alice, asfDisableMaster), sig(alie)); + env(fclear(alice, asfDisableMaster), Sig(alie)); // R2: The regular key can be removed if the master key is enabled. - env(regkey(alice, disabled), sig(alie)); + env(regkey(alice, kDISABLED), Sig(alie)); } // Verify that the first regular key can be made for free using the @@ -915,33 +917,33 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; env.fund(XRP(1000), alice); env.close(); // Give alice a regular key with a zero fee. Should succeed. Once. - Account const alie{"alie", KeyType::ed25519}; - env(regkey(alice, alie), sig(alice), fee(0)); + Account const alie{"alie", KeyType::Ed25519}; + env(regkey(alice, alie), Sig(alice), Fee(0)); // Try it again and creating the regular key for free should fail. - Account const liss{"liss", KeyType::secp256k1}; - env(regkey(alice, liss), sig(alice), fee(0), ter(telINSUF_FEE_P)); + Account const liss{"liss", KeyType::Secp256k1}; + env(regkey(alice, liss), Sig(alice), Fee(0), Ter(telINSUF_FEE_P)); // But paying to create a regular key should succeed. - env(regkey(alice, liss), sig(alice)); + env(regkey(alice, liss), Sig(alice)); // In contrast, trying to multisign for a regular key with a zero // fee should always fail. Even the first time. - Account const becky{"becky", KeyType::ed25519}; + Account const becky{"becky", KeyType::Ed25519}; env.fund(XRP(1000), becky); env.close(); - env(signers(becky, 1, {{alice, 1}}), sig(becky)); - env(regkey(becky, alie), msig(alice), fee(0), ter(telINSUF_FEE_P)); + env(signers(becky, 1, {{alice, 1}}), Sig(becky)); + env(regkey(becky, alie), Msig(alice), Fee(0), Ter(telINSUF_FEE_P)); // Using the master key to sign for a regular key for free should // still work. - env(regkey(becky, alie), sig(becky), fee(0)); + env(regkey(becky, alie), Sig(becky), Fee(0)); } // See if every kind of transaction can be successfully multi-signed. @@ -952,78 +954,78 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const zelda{"zelda", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const zelda{"zelda", KeyType::Secp256k1}; Account const gw{"gw"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(1000), alice, becky, zelda, gw); env.close(); // alice uses a regular key with the master disabled. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // Attach signers to alice. - env(signers(alice, 2, {{becky, 1}, {bogie, 1}}), sig(alie)); + env(signers(alice, 2, {{becky, 1}, {bogie_, 1}}), Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // Multisign a ttPAYMENT. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(pay(alice, env.master, XRP(1)), msig(becky, bogie), fee(3 * baseFee)); + env(pay(alice, env.master, XRP(1)), Msig(becky, bogie_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Multisign a ttACCOUNT_SET. aliceSeq = env.seq(alice); - env(noop(alice), msig(becky, bogie), fee(3 * baseFee)); + env(noop(alice), Msig(becky, bogie_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Multisign a ttREGULAR_KEY_SET. aliceSeq = env.seq(alice); - Account const ace{"ace", KeyType::secp256k1}; - env(regkey(alice, ace), msig(becky, bogie), fee(3 * baseFee)); + Account const ace{"ace", KeyType::Secp256k1}; + env(regkey(alice, ace), Msig(becky, bogie_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Multisign a ttTRUST_SET - env(trust("alice", USD(100)), - msig(becky, bogie), - fee(3 * baseFee), - require(lines("alice", 1))); + env(trust("alice", usd(100)), + Msig(becky, bogie_), + Fee(3 * baseFee), + Require(lines("alice", 1))); env.close(); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); // Multisign a ttOFFER_CREATE transaction. - env(pay(gw, alice, USD(50))); + env(pay(gw, alice, usd(50))); env.close(); - env.require(balance(alice, USD(50))); - env.require(balance(gw, alice["USD"](-50))); + env.require(Balance(alice, usd(50))); + env.require(Balance(gw, alice["USD"](-50))); std::uint32_t const offerSeq = env.seq(alice); - env(offer(alice, XRP(50), USD(50)), msig(becky, bogie), fee(3 * baseFee)); + env(offer(alice, XRP(50), usd(50)), Msig(becky, bogie_), Fee(3 * baseFee)); env.close(); - env.require(owners(alice, 3)); + env.require(Owners(alice, 3)); // Now multisign a ttOFFER_CANCEL canceling the offer we just created. { aliceSeq = env.seq(alice); - env(offer_cancel(alice, offerSeq), seq(aliceSeq), msig(becky, bogie), fee(3 * baseFee)); + env(offerCancel(alice, offerSeq), Seq(aliceSeq), Msig(becky, bogie_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); } // Multisign a ttSIGNER_LIST_SET. - env(signers(alice, 3, {{becky, 1}, {bogie, 1}, {demon, 1}}), - msig(becky, bogie), - fee(3 * baseFee)); + env(signers(alice, 3, {{becky, 1}, {bogie_, 1}, {demon_, 1}}), + Msig(becky, bogie_), + Fee(3 * baseFee)); env.close(); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); } void @@ -1038,7 +1040,7 @@ public: // lambda that submits an STTx and returns the resulting JSON. auto submitSTTx = [&env](STTx const& stx) { - Json::Value jvResult; + json::Value jvResult; jvResult[jss::tx_blob] = strHex(stx.getSerializer().slice()); return env.rpc("json", "submit", to_string(jvResult)); }; @@ -1046,12 +1048,12 @@ public: Account const alice{"alice"}; env.fund(XRP(1000), alice); env.close(); - env(signers(alice, 1, {{bogie, 1}, {demon, 1}}), sig(alice)); + env(signers(alice, 1, {{bogie_, 1}, {demon_, 1}}), Sig(alice)); auto const baseFee = env.current()->fees().base; { // Single-sign, but leave an empty SigningPubKey. - JTx const tx = env.jt(noop(alice), sig(alice)); + JTx const tx = env.jt(noop(alice), Sig(alice)); STTx local = *(tx.stx); local.setFieldVL(sfSigningPubKey, Blob()); // Empty SigningPubKey auto const info = submitSTTx(local); @@ -1061,7 +1063,7 @@ public: } { // Single-sign, but invalidate the signature. - JTx const tx = env.jt(noop(alice), sig(alice)); + JTx const tx = env.jt(noop(alice), Sig(alice)); STTx local = *(tx.stx); // Flip some bits in the signature. auto badSig = local.getFieldVL(sfTxnSignature); @@ -1075,7 +1077,7 @@ public: } { // Single-sign, but invalidate the sequence number. - JTx const tx = env.jt(noop(alice), sig(alice)); + JTx const tx = env.jt(noop(alice), Sig(alice)); STTx local = *(tx.stx); // Flip some bits in the signature. auto seq = local.getFieldU32(sfSequence); @@ -1088,7 +1090,7 @@ public: } { // Multisign, but leave a nonempty sfSigningPubKey. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_)); STTx local = *(tx.stx); local[sfSigningPubKey] = alice.pk(); // Insert sfSigningPubKey auto const info = submitSTTx(local); @@ -1098,7 +1100,7 @@ public: } { // Both multi- and single-sign with an empty SigningPubKey. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_)); STTx local = *(tx.stx); local.sign(alice.pk(), alice.sk()); local.setFieldVL(sfSigningPubKey, Blob()); // Empty SigningPubKey @@ -1109,7 +1111,7 @@ public: } { // Multisign but invalidate one of the signatures. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_)); STTx local = *(tx.stx); // Flip some bits in the signature. auto& signer = local.peekFieldArray(sfSigners).back(); @@ -1124,7 +1126,7 @@ public: } { // Multisign with an empty signers array should fail. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_)); STTx local = *(tx.stx); local.peekFieldArray(sfSigners).clear(); // Empty Signers array. auto const info = submitSTTx(local); @@ -1135,42 +1137,42 @@ public: { JTx const tx = env.jt( noop(alice), - fee(2 * baseFee), + Fee(2 * baseFee), - msig( - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie, - bogie)); + Msig( + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_, + bogie_)); STTx const local = *(tx.stx); auto const info = submitSTTx(local); BEAST_EXPECT( @@ -1179,7 +1181,7 @@ public: } { // The account owner may not multisign for themselves. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(alice)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(alice)); STTx const local = *(tx.stx); auto const info = submitSTTx(local); BEAST_EXPECT( @@ -1188,7 +1190,7 @@ public: } { // No duplicate multisignatures allowed. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie, bogie)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_, bogie_)); STTx const local = *(tx.stx); auto const info = submitSTTx(local); BEAST_EXPECT( @@ -1197,7 +1199,7 @@ public: } { // Multisignatures must be submitted in sorted order. - JTx const tx = env.jt(noop(alice), fee(2 * baseFee), msig(bogie, demon)); + JTx const tx = env.jt(noop(alice), Fee(2 * baseFee), Msig(bogie_, demon_)); STTx local = *(tx.stx); // Unsort the Signers array. auto& signers = local.peekFieldArray(sfSigners); @@ -1217,13 +1219,13 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; - Account const becky{"becky", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Ed25519}; + Account const becky{"becky", KeyType::Secp256k1}; env.fund(XRP(1000), alice, becky); env.close(); auto const baseFee = env.current()->fees().base; - env(noop(alice), msig(becky, demon), fee(3 * baseFee), ter(tefNOT_MULTI_SIGNING)); + env(noop(alice), Msig(becky, demon_), Fee(3 * baseFee), Ter(tefNOT_MULTI_SIGNING)); } void @@ -1238,8 +1240,8 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; - Account const becky{"becky", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Ed25519}; + Account const becky{"becky", KeyType::Secp256k1}; env.fund(XRP(1000), alice, becky); env.close(); @@ -1248,13 +1250,13 @@ public: env.close(); // becky sets up her signer list. - env(signers(becky, 1, {{bogie, 1}, {demon, 1}})); + env(signers(becky, 1, {{bogie_, 1}, {demon_, 1}})); env.close(); // Because becky has not (yet) disabled her master key, she can // multisign a transaction for alice. auto const baseFee = env.current()->fees().base; - env(noop(alice), msig(becky), fee(2 * baseFee)); + env(noop(alice), Msig(becky), Fee(2 * baseFee)); env.close(); // Now becky disables her master key. @@ -1263,31 +1265,31 @@ public: // Since becky's master key is disabled she can no longer // multisign for alice. - env(noop(alice), msig(becky), fee(2 * baseFee), ter(tefMASTER_DISABLED)); + env(noop(alice), Msig(becky), Fee(2 * baseFee), Ter(tefMASTER_DISABLED)); env.close(); // Becky cannot 2-level multisign for alice. 2-level multisigning // is not supported. - env(noop(alice), msig(Reg{becky, bogie}), fee(2 * baseFee), ter(tefBAD_SIGNATURE)); + env(noop(alice), Msig(Reg{becky, bogie_}), Fee(2 * baseFee), Ter(tefBAD_SIGNATURE)); env.close(); // Verify that becky cannot sign with a regular key that she has // not yet enabled. - Account const beck{"beck", KeyType::ed25519}; - env(noop(alice), msig(Reg{becky, beck}), fee(2 * baseFee), ter(tefBAD_SIGNATURE)); + Account const beck{"beck", KeyType::Ed25519}; + env(noop(alice), Msig(Reg{becky, beck}), Fee(2 * baseFee), Ter(tefBAD_SIGNATURE)); env.close(); // Once becky gives herself the regular key, she can sign for alice // using that regular key. - env(regkey(becky, beck), msig(demon), fee(2 * baseFee)); + env(regkey(becky, beck), Msig(demon_), Fee(2 * baseFee)); env.close(); - env(noop(alice), msig(Reg{becky, beck}), fee(2 * baseFee)); + env(noop(alice), Msig(Reg{becky, beck}), Fee(2 * baseFee)); env.close(); // The presence of becky's regular key does not influence whether she // can 2-level multisign; it still won't work. - env(noop(alice), msig(Reg{becky, demon}), fee(2 * baseFee), ter(tefBAD_SIGNATURE)); + env(noop(alice), Msig(Reg{becky, demon_}), Fee(2 * baseFee), Ter(tefBAD_SIGNATURE)); env.close(); } @@ -1301,7 +1303,7 @@ public: // through "submit_multisigned". Make sure that hash also locates // the transaction in the ledger. using namespace jtx; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; Env env( *this, @@ -1313,15 +1315,15 @@ public: env.fund(XRP(1000), alice); env.close(); - env(signers(alice, 2, {{bogie, 1}, {ghost, 1}})); + env(signers(alice, 2, {{bogie_, 1}, {ghost_, 1}})); env.close(); // Use sign_for to sign a transaction where alice pays 10 XRP to // masterpassphrase. auto const baseFee = env.current()->fees().base; - Json::Value jvSig1; - jvSig1[jss::account] = bogie.human(); - jvSig1[jss::secret] = bogie.name(); + json::Value jvSig1; + jvSig1[jss::account] = bogie_.human(); + jvSig1[jss::secret] = bogie_.name(); jvSig1[jss::tx_json][jss::Account] = alice.human(); jvSig1[jss::tx_json][jss::Amount] = 10000000; jvSig1[jss::tx_json][jss::Destination] = env.master.human(); @@ -1329,16 +1331,16 @@ public: jvSig1[jss::tx_json][jss::Sequence] = env.seq(alice); jvSig1[jss::tx_json][jss::TransactionType] = jss::Payment; - Json::Value jvSig2 = env.rpc("json", "sign_for", to_string(jvSig1)); + json::Value jvSig2 = env.rpc("json", "sign_for", to_string(jvSig1)); BEAST_EXPECT(jvSig2[jss::result][jss::status].asString() == "success"); // Save the hash with one signature for use later. std::string const hash1 = jvSig2[jss::result][jss::tx_json][jss::hash].asString(); // Add the next signature and sign again. - jvSig2[jss::result][jss::account] = ghost.human(); - jvSig2[jss::result][jss::secret] = ghost.name(); - Json::Value jvSubmit = env.rpc("json", "sign_for", to_string(jvSig2[jss::result])); + jvSig2[jss::result][jss::account] = ghost_.human(); + jvSig2[jss::result][jss::secret] = ghost_.name(); + json::Value jvSubmit = env.rpc("json", "sign_for", to_string(jvSig2[jss::result])); BEAST_EXPECT(jvSubmit[jss::result][jss::status].asString() == "success"); // Save the hash with two signatures for use later. @@ -1346,7 +1348,7 @@ public: BEAST_EXPECT(hash1 != hash2); // Submit the result of the two signatures. - Json::Value jvResult = + json::Value jvResult = env.rpc("json", "submit_multisigned", to_string(jvSubmit[jss::result])); BEAST_EXPECT(jvResult[jss::result][jss::status].asString() == "success"); BEAST_EXPECT(jvResult[jss::result][jss::engine_result].asString() == "tesSUCCESS"); @@ -1358,7 +1360,7 @@ public: // The transaction we just submitted should now be available and // validated. - Json::Value jvTx = env.rpc("tx", hash2); + json::Value jvTx = env.rpc("tx", hash2); BEAST_EXPECT(jvTx[jss::result][jss::status].asString() == "success"); BEAST_EXPECT(jvTx[jss::result][jss::validated].asString() == "true"); BEAST_EXPECT( @@ -1372,7 +1374,7 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(2000), alice); env.close(); @@ -1383,20 +1385,20 @@ public: std::uint32_t const aliceSeq = env.seq(alice); // Attach phantom signers to alice using a ticket. - env(signers(alice, 1, {{bogie, 1}, {demon, 1}}), ticket::use(aliceTicketSeq++)); + env(signers(alice, 1, {{bogie_, 1}, {demon_, 1}}), ticket::Use(aliceTicketSeq++)); env.close(); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); // This should work. auto const baseFee = env.current()->fees().base; - env(noop(alice), msig(bogie, demon), fee(3 * baseFee), ticket::use(aliceTicketSeq++)); + env(noop(alice), Msig(bogie_, demon_), Fee(3 * baseFee), ticket::Use(aliceTicketSeq++)); env.close(); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Should also be able to remove the signer list using a ticket. - env(signers(alice, jtx::none), ticket::use(aliceTicketSeq++)); + env(signers(alice, jtx::kNONE), ticket::Use(aliceTicketSeq++)); env.close(); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1409,7 +1411,7 @@ public: using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); uint8_t tag1[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, @@ -1418,57 +1420,57 @@ public: uint8_t tag2[] = "hello world some ascii 32b long"; // including 1 byte for NUL - uint256 bogie_tag = xrpl::base_uint<256>::fromVoid(tag1); - uint256 demon_tag = xrpl::base_uint<256>::fromVoid(tag2); + uint256 bogieTag = xrpl::BaseUint<256>::fromVoid(tag1); + uint256 demonTag = xrpl::BaseUint<256>::fromVoid(tag2); // Attach phantom signers to alice and use them for a transaction. - env(signers(alice, 1, {{bogie, 1, bogie_tag}, {demon, 1, demon_tag}})); + env(signers(alice, 1, {{bogie_, 1, bogieTag}, {demon_, 1, demonTag}})); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // This should work. auto const baseFee = env.current()->fees().base; std::uint32_t aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, demon), fee(3 * baseFee)); + env(noop(alice), Msig(bogie_, demon_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Either signer alone should work. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee(2 * baseFee)); + env(noop(alice), Msig(bogie_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); aliceSeq = env.seq(alice); - env(noop(alice), msig(demon), fee(2 * baseFee)); + env(noop(alice), Msig(demon_), Fee(2 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Duplicate signers should fail. aliceSeq = env.seq(alice); env(noop(alice), - msig(demon, demon), - fee(3 * baseFee), - rpc("invalidTransaction", "fails local checks: Duplicate Signers not allowed.")); + Msig(demon_, demon_), + Fee(3 * baseFee), + Rpc("invalidTransaction", "fails local checks: Duplicate Signers not allowed.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // A non-signer should fail. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, spook), fee(3 * baseFee), ter(tefBAD_SIGNATURE)); + env(noop(alice), Msig(bogie_, spook_), Fee(3 * baseFee), Ter(tefBAD_SIGNATURE)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Don't meet the quorum. Should fail. - env(signers(alice, 2, {{bogie, 1}, {demon, 1}})); + env(signers(alice, 2, {{bogie_, 1}, {demon_, 1}})); aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie), fee(2 * baseFee), ter(tefBAD_QUORUM)); + env(noop(alice), Msig(bogie_), Fee(2 * baseFee), Ter(tefBAD_QUORUM)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); // Meet the quorum. Should succeed. aliceSeq = env.seq(alice); - env(noop(alice), msig(bogie, demon), fee(3 * baseFee)); + env(noop(alice), Msig(bogie_, demon_), Fee(3 * baseFee)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); } @@ -1487,8 +1489,8 @@ public: bool const enabled = features[fixInvalidTxFlags]; testcase(std::string("SignerListSet flag, fix ") + (enabled ? "enabled" : "disabled")); - ter const expected(enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS)); - env(signers(alice, 2, {{bogie, 1}, {ghost, 1}}), expected, txflags(tfPassive)); + Ter const expected(enabled ? TER(temINVALID_FLAG) : TER(tesSUCCESS)); + env(signers(alice, 2, {{bogie_, 1}, {ghost_, 1}}), expected, Txflags(tfPassive)); env.close(); } @@ -1500,12 +1502,12 @@ public: // Verify that the SignerList object is created correctly. using namespace jtx; Env env{*this, features}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); // Attach phantom signers to alice. - env(signers(alice, 1, {{bogie, 1}, {demon, 1}})); + env(signers(alice, 1, {{bogie_, 1}, {demon_, 1}})); env.close(); // Verify that the SignerList object was created correctly. @@ -1549,7 +1551,7 @@ public: run() override { using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); testAll(all); diff --git a/src/test/app/NFTokenAuth_test.cpp b/src/test/app/NFTokenAuth_test.cpp index 2542f2eb36..da5760f387 100644 --- a/src/test/app/NFTokenAuth_test.cpp +++ b/src/test/app/NFTokenAuth_test.cpp @@ -29,7 +29,7 @@ namespace xrpl { -class NFTokenAuth_test : public beast::unit_test::suite +class NFTokenAuth_test : public beast::unit_test::Suite { static auto mintAndOfferNFT( @@ -40,11 +40,11 @@ class NFTokenAuth_test : public beast::unit_test::suite { using namespace test::jtx; auto const nftID{token::getNextID(env, account, 0u, tfTransferable, xfee)}; - env(token::mint(account, 0), token::xferFee(xfee), txflags(tfTransferable)); + env(token::mint(account, 0), token::XferFee(xfee), Txflags(tfTransferable)); env.close(); auto const sellIdx = keylet::nftoffer(account, env.seq(account)).key; - env(token::createOffer(account, nftID, currency), txflags(tfSellNFToken)); + env(token::createOffer(account, nftID, currency), Txflags(tfSellNFToken)); env.close(); return std::make_tuple(nftID, sellIdx); @@ -52,86 +52,86 @@ class NFTokenAuth_test : public beast::unit_test::suite public: void - testBuyOffer_UnauthorizedSeller(FeatureBitset features) + testBuyOfferUnauthorizedSeller(FeatureBitset features) { testcase("Unauthorized seller tries to accept buy offer"); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); - auto const [nftID, _] = mintAndOfferNFT(env, A2, drops(1)); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; + auto const [nftID, _] = mintAndOfferNFT(env, a2, drops(1)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; // It should be possible to create a buy offer even if NFT owner is not // authorized - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2)); + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2)); if (features[fixEnforceNFTokenTrustlineV2]) { // test: G1 requires authorization of A2, no trust line exists - env(token::acceptBuyOffer(A2, buyIdx), ter(tecNO_LINE)); + env(token::acceptBuyOffer(a2, buyIdx), Ter(tecNO_LINE)); env.close(); // trust line created, but not authorized - env(trust(A2, limit)); + env(trust(a2, limit)); // test: G1 requires authorization of A2 - env(token::acceptBuyOffer(A2, buyIdx), ter(tecNO_AUTH)); + env(token::acceptBuyOffer(a2, buyIdx), Ter(tecNO_AUTH)); env.close(); } else { // Old behavior: it is possible to sell tokens and receive IOUs // without the authorization - env(token::acceptBuyOffer(A2, buyIdx)); + env(token::acceptBuyOffer(a2, buyIdx)); env.close(); - BEAST_EXPECT(env.balance(A2, USD) == USD(10)); + BEAST_EXPECT(env.balance(a2, usd) == usd(10)); } } void - testCreateBuyOffer_UnauthorizedBuyer(FeatureBitset features) + testCreateBuyOfferUnauthorizedBuyer(FeatureBitset features) { testcase("Unauthorized buyer tries to create buy offer"); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const [nftID, _] = mintAndOfferNFT(env, A2, drops(1)); + auto const [nftID, _] = mintAndOfferNFT(env, a2, drops(1)); // test: check that buyer can't make an offer if they're not authorized. - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2), ter(tecUNFUNDED_OFFER)); + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2), Ter(tecUNFUNDED_OFFER)); env.close(); // Artificially create an unauthorized trustline with balance. Don't // close ledger before running the actual tests against this trustline. // After ledger is closed, the trustline will not exist. auto const unauthTrustline = [&](OpenView& view, beast::Journal) -> bool { - auto const sleA1 = std::make_shared(keylet::line(A1, G1, G1["USD"].currency)); - sleA1->setFieldAmount(sfBalance, A1["USD"](-1000)); + auto const sleA1 = std::make_shared(keylet::line(a1, g1, g1["USD"].currency)); + sleA1->setFieldAmount(sfBalance, a1["USD"](-1000)); view.rawInsert(sleA1); return true; }; @@ -140,52 +140,52 @@ public: if (features[fixEnforceNFTokenTrustlineV2]) { // test: check that buyer can't make an offer even with balance - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2), ter(tecNO_AUTH)); + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2), Ter(tecNO_AUTH)); } else { // old behavior: can create an offer if balance allows, regardless // ot authorization - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2)); + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2)); } } void - testAcceptBuyOffer_UnauthorizedBuyer(FeatureBitset features) + testAcceptBuyOfferUnauthorizedBuyer(FeatureBitset features) { testcase("Seller tries to accept buy offer from unauth buyer"); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - auto const [nftID, _] = mintAndOfferNFT(env, A2, drops(1)); + auto const [nftID, _] = mintAndOfferNFT(env, a2, drops(1)); // First we authorize buyer and seller so that he can create buy offer - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(10))); - env(trust(A2, limit)); - env(trust(G1, limit, A2, tfSetfAuth)); - env(pay(G1, A2, USD(10))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(10))); + env(trust(a2, limit)); + env(trust(g1, limit, a2, tfSetfAuth)); + env(pay(g1, a2, usd(10))); env.close(); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(10)), token::owner(A2)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(10)), token::Owner(a2)); env.close(); - env(pay(A1, G1, USD(10))); - env(trust(A1, USD(0))); - env(trust(G1, A1["USD"](0))); + env(pay(a1, g1, usd(10))); + env(trust(a1, usd(0))); + env(trust(g1, a1["USD"](0))); env.close(); // Replace an existing authorized trustline with artificial unauthorized @@ -193,8 +193,8 @@ public: // tests against this trustline. After ledger is closed, the trustline // will not exist. auto const unauthTrustline = [&](OpenView& view, beast::Journal) -> bool { - auto const sleA1 = std::make_shared(keylet::line(A1, G1, G1["USD"].currency)); - sleA1->setFieldAmount(sfBalance, A1["USD"](-1000)); + auto const sleA1 = std::make_shared(keylet::line(a1, g1, g1["USD"].currency)); + sleA1->setFieldAmount(sfBalance, a1["USD"](-1000)); view.rawInsert(sleA1); return true; }; @@ -202,12 +202,12 @@ public: if (features[fixEnforceNFTokenTrustlineV2]) { // test: check that offer can't be accepted even with balance - env(token::acceptBuyOffer(A2, buyIdx), ter(tecNO_AUTH)); + env(token::acceptBuyOffer(a2, buyIdx), Ter(tecNO_AUTH)); } } void - testSellOffer_UnauthorizedSeller(FeatureBitset features) + testSellOfferUnauthorizedSeller(FeatureBitset features) { testcase( "Authorized buyer tries to accept sell offer from unauthorized " @@ -215,154 +215,154 @@ public: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); - auto const [nftID, _] = mintAndOfferNFT(env, A2, drops(1)); + auto const [nftID, _] = mintAndOfferNFT(env, a2, drops(1)); if (features[fixEnforceNFTokenTrustlineV2]) { // test: can't create sell offer if there is no trustline but auth // required - env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken), ter(tecNO_LINE)); + env(token::createOffer(a2, nftID, usd(10)), Txflags(tfSellNFToken), Ter(tecNO_LINE)); - env(trust(A2, limit)); + env(trust(a2, limit)); // test: can't create sell offer if not authorized to hold token - env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken), ter(tecNO_AUTH)); + env(token::createOffer(a2, nftID, usd(10)), Txflags(tfSellNFToken), Ter(tecNO_AUTH)); // Authorizing trustline to make an offer creation possible - env(trust(G1, USD(0), A2, tfSetfAuth)); + env(trust(g1, usd(0), a2, tfSetfAuth)); env.close(); - auto const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key; - env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken)); + auto const sellIdx = keylet::nftoffer(a2, env.seq(a2)).key; + env(token::createOffer(a2, nftID, usd(10)), Txflags(tfSellNFToken)); env.close(); // // Reseting trustline to delete it. This allows to check if // already existing offers handled correctly - env(trust(A2, USD(0))); + env(trust(a2, usd(0))); env.close(); // test: G1 requires authorization of A1, no trust line exists - env(token::acceptSellOffer(A1, sellIdx), ter(tecNO_LINE)); + env(token::acceptSellOffer(a1, sellIdx), Ter(tecNO_LINE)); env.close(); // trust line created, but not authorized - env(trust(A2, limit)); + env(trust(a2, limit)); env.close(); // test: G1 requires authorization of A1 - env(token::acceptSellOffer(A1, sellIdx), ter(tecNO_AUTH)); + env(token::acceptSellOffer(a1, sellIdx), Ter(tecNO_AUTH)); env.close(); } else { - auto const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key; + auto const sellIdx = keylet::nftoffer(a2, env.seq(a2)).key; // Old behavior: sell offer can be created without authorization - env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken)); + env(token::createOffer(a2, nftID, usd(10)), Txflags(tfSellNFToken)); env.close(); // Old behavior: it is possible to sell NFT and receive IOUs // without the authorization - env(token::acceptSellOffer(A1, sellIdx)); + env(token::acceptSellOffer(a1, sellIdx)); env.close(); - BEAST_EXPECT(env.balance(A2, USD) == USD(10)); + BEAST_EXPECT(env.balance(a2, usd) == usd(10)); } } void - testSellOffer_UnauthorizedBuyer(FeatureBitset features) + testSellOfferUnauthorizedBuyer(FeatureBitset features) { testcase("Unauthorized buyer tries to accept sell offer"); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A2, limit)); - env(trust(G1, limit, A2, tfSetfAuth)); + env(trust(a2, limit)); + env(trust(g1, limit, a2, tfSetfAuth)); - auto const [_, sellIdx] = mintAndOfferNFT(env, A2, USD(10)); + auto const [_, sellIdx] = mintAndOfferNFT(env, a2, usd(10)); // test: check that buyer can't accept an offer if they're not // authorized. - env(token::acceptSellOffer(A1, sellIdx), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(a1, sellIdx), Ter(tecINSUFFICIENT_FUNDS)); env.close(); // Creating an artificial unauth trustline auto const unauthTrustline = [&](OpenView& view, beast::Journal) -> bool { - auto const sleA1 = std::make_shared(keylet::line(A1, G1, G1["USD"].currency)); - sleA1->setFieldAmount(sfBalance, A1["USD"](-1000)); + auto const sleA1 = std::make_shared(keylet::line(a1, g1, g1["USD"].currency)); + sleA1->setFieldAmount(sfBalance, a1["USD"](-1000)); view.rawInsert(sleA1); return true; }; env.app().getOpenLedger().modify(unauthTrustline); if (features[fixEnforceNFTokenTrustlineV2]) { - env(token::acceptSellOffer(A1, sellIdx), ter(tecNO_AUTH)); + env(token::acceptSellOffer(a1, sellIdx), Ter(tecNO_AUTH)); } } void - testBrokeredAcceptOffer_UnauthorizedBroker(FeatureBitset features) + testBrokeredAcceptOfferUnauthorizedBroker(FeatureBitset features) { testcase("Unauthorized broker bridges authorized buyer and seller."); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; Account const broker{"broker"}; - auto const USD{G1["USD"]}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2, broker); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2, broker); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); - env(trust(A2, limit)); - env(trust(G1, limit, A2, tfSetfAuth)); - env(pay(G1, A2, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); + env(trust(a2, limit)); + env(trust(g1, limit, a2, tfSetfAuth)); + env(pay(g1, a2, usd(1000))); env.close(); - auto const [nftID, sellIdx] = mintAndOfferNFT(env, A2, USD(10)); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(11)), token::owner(A2)); + auto const [nftID, sellIdx] = mintAndOfferNFT(env, a2, usd(10)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(11)), token::Owner(a2)); env.close(); if (features[fixEnforceNFTokenTrustlineV2]) { // test: G1 requires authorization of broker, no trust line exists env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecNO_LINE)); + token::BrokerFee(usd(1)), + Ter(tecNO_LINE)); env.close(); // trust line created, but not authorized @@ -371,8 +371,8 @@ public: // test: G1 requires authorization of broker env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecNO_AUTH)); + token::BrokerFee(usd(1)), + Ter(tecNO_AUTH)); env.close(); // test: can still be brokered without broker fee. @@ -382,15 +382,15 @@ public: else { // Old behavior: broker can receive IOUs without the authorization - env(token::brokerOffers(broker, buyIdx, sellIdx), token::brokerFee(USD(1))); + env(token::brokerOffers(broker, buyIdx, sellIdx), token::BrokerFee(usd(1))); env.close(); - BEAST_EXPECT(env.balance(broker, USD) == USD(1)); + BEAST_EXPECT(env.balance(broker, usd) == usd(1)); } } void - testBrokeredAcceptOffer_UnauthorizedBuyer(FeatureBitset features) + testBrokeredAcceptOfferUnauthorizedBuyer(FeatureBitset features) { testcase( "Authorized broker tries to bridge offers from unauthorized " @@ -398,42 +398,42 @@ public: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; Account const broker{"broker"}; - auto const USD{G1["USD"]}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2, broker); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2, broker); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, USD(0), A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); - env(trust(A2, limit)); - env(trust(G1, USD(0), A2, tfSetfAuth)); - env(pay(G1, A2, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, usd(0), a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); + env(trust(a2, limit)); + env(trust(g1, usd(0), a2, tfSetfAuth)); + env(pay(g1, a2, usd(1000))); env(trust(broker, limit)); - env(trust(G1, USD(0), broker, tfSetfAuth)); - env(pay(G1, broker, USD(1000))); + env(trust(g1, usd(0), broker, tfSetfAuth)); + env(pay(g1, broker, usd(1000))); env.close(); - auto const [nftID, sellIdx] = mintAndOfferNFT(env, A2, USD(10)); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(11)), token::owner(A2)); + auto const [nftID, sellIdx] = mintAndOfferNFT(env, a2, usd(10)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(11)), token::Owner(a2)); env.close(); // Resetting buyer's trust line to delete it - env(pay(A1, G1, USD(1000))); - env(trust(A1, USD(0))); + env(pay(a1, g1, usd(1000))); + env(trust(a1, usd(0))); env.close(); auto const unauthTrustline = [&](OpenView& view, beast::Journal) -> bool { - auto const sleA1 = std::make_shared(keylet::line(A1, G1, G1["USD"].currency)); - sleA1->setFieldAmount(sfBalance, A1["USD"](-1000)); + auto const sleA1 = std::make_shared(keylet::line(a1, g1, g1["USD"].currency)); + sleA1->setFieldAmount(sfBalance, a1["USD"](-1000)); view.rawInsert(sleA1); return true; }; @@ -443,14 +443,14 @@ public: { // test: G1 requires authorization of A2 env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecNO_AUTH)); + token::BrokerFee(usd(1)), + Ter(tecNO_AUTH)); env.close(); } } void - testBrokeredAcceptOffer_UnauthorizedSeller(FeatureBitset features) + testBrokeredAcceptOfferUnauthorizedSeller(FeatureBitset features) { testcase( "Authorized broker tries to bridge offers from unauthorized " @@ -458,98 +458,98 @@ public: using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; - Account const A1{"A1"}; - Account const A2{"A2"}; + Account const g1{"G1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; Account const broker{"broker"}; - auto const USD{G1["USD"]}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, A1, A2, broker); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, a1, a2, broker); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); env(trust(broker, limit)); - env(trust(G1, limit, broker, tfSetfAuth)); - env(pay(G1, broker, USD(1000))); + env(trust(g1, limit, broker, tfSetfAuth)); + env(pay(g1, broker, usd(1000))); env.close(); // Authorizing trustline to make an offer creation possible - env(trust(G1, USD(0), A2, tfSetfAuth)); + env(trust(g1, usd(0), a2, tfSetfAuth)); env.close(); - auto const [nftID, sellIdx] = mintAndOfferNFT(env, A2, USD(10)); - auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(11)), token::owner(A2)); + auto const [nftID, sellIdx] = mintAndOfferNFT(env, a2, usd(10)); + auto const buyIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(11)), token::Owner(a2)); env.close(); // Reseting trustline to delete it. This allows to check if // already existing offers handled correctly - env(trust(A2, USD(0))); + env(trust(a2, usd(0))); env.close(); if (features[fixEnforceNFTokenTrustlineV2]) { // test: G1 requires authorization of broker, no trust line exists env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecNO_LINE)); + token::BrokerFee(usd(1)), + Ter(tecNO_LINE)); env.close(); // trust line created, but not authorized - env(trust(A2, limit)); + env(trust(a2, limit)); env.close(); // test: G1 requires authorization of A2 env(token::brokerOffers(broker, buyIdx, sellIdx), - token::brokerFee(USD(1)), - ter(tecNO_AUTH)); + token::BrokerFee(usd(1)), + Ter(tecNO_AUTH)); env.close(); // test: cannot be brokered even without broker fee. - env(token::brokerOffers(broker, buyIdx, sellIdx), ter(tecNO_AUTH)); + env(token::brokerOffers(broker, buyIdx, sellIdx), Ter(tecNO_AUTH)); env.close(); } else { // Old behavior: broker can receive IOUs without the authorization - env(token::brokerOffers(broker, buyIdx, sellIdx), token::brokerFee(USD(1))); + env(token::brokerOffers(broker, buyIdx, sellIdx), token::BrokerFee(usd(1))); env.close(); - BEAST_EXPECT(env.balance(A2, USD) == USD(10)); + BEAST_EXPECT(env.balance(a2, usd) == usd(10)); return; } } void - testTransferFee_UnauthorizedMinter(FeatureBitset features) + testTransferFeeUnauthorizedMinter(FeatureBitset features) { testcase("Unauthorized minter receives transfer fee."); using namespace test::jtx; Env env(*this, features); - Account const G1{"G1"}; + Account const g1{"G1"}; Account const minter{"minter"}; - Account const A1{"A1"}; - Account const A2{"A2"}; - auto const USD{G1["USD"]}; + Account const a1{"A1"}; + Account const a2{"A2"}; + auto const usd{g1["USD"]}; - env.fund(XRP(10000), G1, minter, A1, A2); - env(fset(G1, asfRequireAuth)); + env.fund(XRP(10000), g1, minter, a1, a2); + env(fset(g1, asfRequireAuth)); env.close(); - auto const limit = USD(10000); + auto const limit = usd(10000); - env(trust(A1, limit)); - env(trust(G1, limit, A1, tfSetfAuth)); - env(pay(G1, A1, USD(1000))); - env(trust(A2, limit)); - env(trust(G1, limit, A2, tfSetfAuth)); - env(pay(G1, A2, USD(1000))); + env(trust(a1, limit)); + env(trust(g1, limit, a1, tfSetfAuth)); + env(pay(g1, a1, usd(1000))); + env(trust(a2, limit)); + env(trust(g1, limit, a2, tfSetfAuth)); + env(pay(g1, a2, usd(1000))); env(trust(minter, limit)); env.close(); @@ -557,24 +557,24 @@ public: // We authorized A1 and A2, but not the minter. // Now mint NFT auto const [nftID, minterSellIdx] = mintAndOfferNFT(env, minter, drops(1), 1); - env(token::acceptSellOffer(A1, minterSellIdx)); + env(token::acceptSellOffer(a1, minterSellIdx)); - uint256 const sellIdx = keylet::nftoffer(A1, env.seq(A1)).key; - env(token::createOffer(A1, nftID, USD(100)), txflags(tfSellNFToken)); + uint256 const sellIdx = keylet::nftoffer(a1, env.seq(a1)).key; + env(token::createOffer(a1, nftID, usd(100)), Txflags(tfSellNFToken)); if (features[fixEnforceNFTokenTrustlineV2]) { // test: G1 requires authorization - env(token::acceptSellOffer(A2, sellIdx), ter(tecNO_AUTH)); + env(token::acceptSellOffer(a2, sellIdx), Ter(tecNO_AUTH)); env.close(); } else { // Old behavior: can sell for USD. Minter can receive tokens - env(token::acceptSellOffer(A2, sellIdx)); + env(token::acceptSellOffer(a2, sellIdx)); env.close(); - BEAST_EXPECT(env.balance(minter, USD) == USD(0.001)); + BEAST_EXPECT(env.balance(minter, usd) == usd(0.001)); } } @@ -582,21 +582,21 @@ public: run() override { using namespace test::jtx; - static FeatureBitset const all{testable_amendments()}; + static FeatureBitset const kALL{testableAmendments()}; - static std::array const features = {all - fixEnforceNFTokenTrustlineV2, all}; + static std::array const kFEATURES = {kALL - fixEnforceNFTokenTrustlineV2, kALL}; - for (auto const feature : features) + for (auto const feature : kFEATURES) { - testBuyOffer_UnauthorizedSeller(feature); - testCreateBuyOffer_UnauthorizedBuyer(feature); - testAcceptBuyOffer_UnauthorizedBuyer(feature); - testSellOffer_UnauthorizedSeller(feature); - testSellOffer_UnauthorizedBuyer(feature); - testBrokeredAcceptOffer_UnauthorizedBroker(feature); - testBrokeredAcceptOffer_UnauthorizedBuyer(feature); - testBrokeredAcceptOffer_UnauthorizedSeller(feature); - testTransferFee_UnauthorizedMinter(feature); + testBuyOfferUnauthorizedSeller(feature); + testCreateBuyOfferUnauthorizedBuyer(feature); + testAcceptBuyOfferUnauthorizedBuyer(feature); + testSellOfferUnauthorizedSeller(feature); + testSellOfferUnauthorizedBuyer(feature); + testBrokeredAcceptOfferUnauthorizedBroker(feature); + testBrokeredAcceptOfferUnauthorizedBuyer(feature); + testBrokeredAcceptOfferUnauthorizedSeller(feature); + testTransferFeeUnauthorizedMinter(feature); } } }; diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index efb255ea2d..56bb6b75d7 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -42,16 +42,16 @@ namespace xrpl { -class NFTokenBurn_test : public beast::unit_test::suite +class NFTokenBurn_test : public beast::unit_test::Suite { // Helper function that returns the number of nfts owned by an account. static std::uint32_t nftCount(test::jtx::Env& env, test::jtx::Account const& acct) { - Json::Value params; + json::Value params; params[jss::account] = acct.human(); params[jss::type] = "state"; - Json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); + json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); return nfts[jss::result][jss::account_nfts].size(); }; @@ -67,8 +67,8 @@ class NFTokenBurn_test : public beast::unit_test::suite using namespace test::jtx; uint256 const nftokenID = token::getNextID(env, owner, 0, tfTransferable); env(token::mint(owner, 0), - token::uri(std::string(maxTokenURILength, 'u')), - txflags(tfTransferable)); + token::Uri(std::string(kMAX_TOKEN_URI_LENGTH, 'u')), + Txflags(tfTransferable)); env.close(); offerIndexes.reserve(tokenCancelCount); @@ -77,7 +77,7 @@ class NFTokenBurn_test : public beast::unit_test::suite { // Create sell offer offerIndexes.push_back(keylet::nftoffer(owner, env.seq(owner)).key); - env(token::createOffer(owner, nftokenID, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(owner, nftokenID, drops(1)), Txflags(tfSellNFToken)); env.close(); } @@ -89,18 +89,18 @@ class NFTokenBurn_test : public beast::unit_test::suite // It uses the ledger RPC command to show the NFT pages in the ledger. // This parameter controls how noisy the output is. enum class Volume : bool { - quiet = false, - noisy = true, + Quiet = false, + Noisy = true, }; static void printNFTPages(test::jtx::Env& env, Volume vol) { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = "current"; jvParams[jss::binary] = false; { - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); // Iterate the state and print all NFTokenPages. if (!jrr.isMember(jss::result) || !jrr[jss::result].isMember(jss::state)) @@ -108,13 +108,13 @@ class NFTokenBurn_test : public beast::unit_test::suite std::cout << "No ledger state found!" << std::endl; return; } - Json::Value& state = jrr[jss::result][jss::state]; + json::Value& state = jrr[jss::result][jss::state]; if (!state.isArray()) { std::cout << "Ledger state is not array!" << std::endl; return; } - for (Json::UInt i = 0; i < state.size(); ++i) + for (json::UInt i = 0; i < state.size(); ++i) { if (state[i].isMember(sfNFTokens.jsonName) && state[i][sfNFTokens.jsonName].isArray()) @@ -123,7 +123,7 @@ class NFTokenBurn_test : public beast::unit_test::suite std::cout << tokenCount << " NFtokens in page " << state[i][jss::index].asString() << std::endl; - if (vol == Volume::noisy) + if (vol == Volume::Noisy) { std::cout << state[i].toStyledString() << std::endl; } @@ -200,7 +200,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // way each time. std::mt19937 engine; std::uniform_int_distribution feeDist( - decltype(maxTransferFee){}, maxTransferFee); + decltype(kMAX_TRANSFER_FEE){}, kMAX_TRANSFER_FEE); alice.nfts.reserve(105); while (alice.nfts.size() < 105) @@ -208,7 +208,7 @@ class NFTokenBurn_test : public beast::unit_test::suite std::uint16_t const xferFee = feeDist(engine); alice.nfts.push_back( token::getNextID(env, alice, 0u, tfTransferable | tfBurnable, xferFee)); - env(token::mint(alice), txflags(tfTransferable | tfBurnable), token::xferFee(xferFee)); + env(token::mint(alice), Txflags(tfTransferable | tfBurnable), token::XferFee(xferFee)); env.close(); } @@ -219,9 +219,9 @@ class NFTokenBurn_test : public beast::unit_test::suite minter.nfts.push_back( token::getNextID(env, alice, 0u, tfTransferable | tfBurnable, xferFee)); env(token::mint(minter), - txflags(tfTransferable | tfBurnable), - token::xferFee(xferFee), - token::issuer(alice)); + Txflags(tfTransferable | tfBurnable), + token::XferFee(xferFee), + token::Issuer(alice)); env.close(); } @@ -236,7 +236,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // We do the same work on alice and minter, so make a lambda. auto xferNFT = [&env, &becky](AcctStat& acct, auto& iter) { uint256 const offerIndex = keylet::nftoffer(acct.acct, env.seq(acct.acct)).key; - env(token::createOffer(acct, *iter, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(acct, *iter, XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(becky, offerIndex)); env.close(); @@ -263,20 +263,20 @@ class NFTokenBurn_test : public beast::unit_test::suite { // Create sell offers for owner. env(token::createOffer(owner, nft, drops(1)), - txflags(tfSellNFToken), - token::destination(other1)); + Txflags(tfSellNFToken), + token::Destination(other1)); env(token::createOffer(owner, nft, drops(1)), - txflags(tfSellNFToken), - token::destination(other2)); + Txflags(tfSellNFToken), + token::Destination(other2)); env.close(); // Create buy offers for other1 and other2. - env(token::createOffer(other1, nft, drops(1)), token::owner(owner)); - env(token::createOffer(other2, nft, drops(1)), token::owner(owner)); + env(token::createOffer(other1, nft, drops(1)), token::Owner(owner)); + env(token::createOffer(other2, nft, drops(1)), token::Owner(owner)); env.close(); - env(token::createOffer(other2, nft, drops(2)), token::owner(owner)); - env(token::createOffer(other1, nft, drops(2)), token::owner(owner)); + env(token::createOffer(other2, nft, drops(2)), token::Owner(owner)); + env(token::createOffer(other1, nft, drops(2)), token::Owner(owner)); env.close(); } }; @@ -323,7 +323,7 @@ class NFTokenBurn_test : public beast::unit_test::suite } else { - env(token::burn(burner, nft), token::owner(owner)); + env(token::burn(burner, nft), token::Owner(owner)); } env.close(); @@ -337,7 +337,7 @@ class NFTokenBurn_test : public beast::unit_test::suite BEAST_EXPECT(nftCount(env, becky.acct) == 0); BEAST_EXPECT(nftCount(env, minter.acct) == 0); - // When all nfts are burned none of the accounts should have + // When all nfts are burned kNONE of the accounts should have // an ownerCount. BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, becky) == 0); @@ -404,16 +404,16 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that the ledger does indeed contain exactly three pages // of NFTs with 32 entries in each page. - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = "current"; jvParams[jss::binary] = false; { - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); - Json::Value& state = jrr[jss::result][jss::state]; + json::Value& state = jrr[jss::result][jss::state]; int pageCount = 0; - for (Json::UInt i = 0; i < state.size(); ++i) + for (json::UInt i = 0; i < state.size(); ++i) { if (state[i].isMember(sfNFTokens.jsonName) && state[i][sfNFTokens.jsonName].isArray()) @@ -447,15 +447,15 @@ class NFTokenBurn_test : public beast::unit_test::suite // A lambda verifies that the ledger no longer contains any NFT pages. auto checkNoTokenPages = [this, &env]() { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = "current"; jvParams[jss::binary] = false; { - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); - Json::Value& state = jrr[jss::result][jss::state]; + json::Value& state = jrr[jss::result][jss::state]; - for (Json::UInt i = 0; i < state.size(); ++i) + for (json::UInt i = 0; i < state.size(); ++i) { BEAST_EXPECT(!state[i].isMember(sfNFTokens.jsonName)); } @@ -472,19 +472,19 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that that all three pages are present and remember the // indexes. - auto lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; uint256 const middleNFTokenPageIndex = lastNFTokenPage->at(sfPreviousPageMin); auto middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; uint256 const firstNFTokenPageIndex = middleNFTokenPage->at(sfPreviousPageMin); auto firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); if (!BEAST_EXPECT(firstNFTokenPage)) return; @@ -498,7 +498,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that the last page is still present and contains just one // NFT. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; @@ -517,7 +517,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // _previous_ page because we need to preserve that last // page an an anchor. The contents of the next-to-last page // are moved into the last page. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(lastNFTokenPage); BEAST_EXPECT(lastNFTokenPage->at(~sfPreviousPageMin) == firstNFTokenPageIndex); BEAST_EXPECT(!lastNFTokenPage->isFieldPresent(sfNextPageMin)); @@ -525,13 +525,13 @@ class NFTokenBurn_test : public beast::unit_test::suite // The "middle" page should be gone. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); BEAST_EXPECT(!middleNFTokenPage); // The "first" page should still be present and linked to // the last page. firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); BEAST_EXPECT(firstNFTokenPage); BEAST_EXPECT(!firstNFTokenPage->isFieldPresent(sfPreviousPageMin)); BEAST_EXPECT(firstNFTokenPage->at(~sfNextPageMin) == lastNFTokenPage->key()); @@ -542,13 +542,13 @@ class NFTokenBurn_test : public beast::unit_test::suite // Removing the last token from the last page deletes the last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(!lastNFTokenPage); // The "middle" page is still present, but has lost the // NextPageMin field. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; BEAST_EXPECT(middleNFTokenPage->isFieldPresent(sfPreviousPageMin)); @@ -576,19 +576,19 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that that all three pages are present and remember the // indexes. - auto lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; uint256 const middleNFTokenPageIndex = lastNFTokenPage->at(sfPreviousPageMin); auto middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; uint256 const firstNFTokenPageIndex = middleNFTokenPage->at(sfPreviousPageMin); auto firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); if (!BEAST_EXPECT(firstNFTokenPage)) return; @@ -604,17 +604,17 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that middle page is gone and the links in the two // remaining pages are correct. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); BEAST_EXPECT(!middleNFTokenPage); - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(!lastNFTokenPage->isFieldPresent(sfNextPageMin)); BEAST_EXPECT(lastNFTokenPage->getFieldH256(sfPreviousPageMin) == firstNFTokenPageIndex); firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); BEAST_EXPECT( - firstNFTokenPage->getFieldH256(sfNextPageMin) == keylet::nftpage_max(alice).key); + firstNFTokenPage->getFieldH256(sfNextPageMin) == keylet::nftpageMax(alice).key); BEAST_EXPECT(!firstNFTokenPage->isFieldPresent(sfPreviousPageMin)); // Burn the remaining nfts. @@ -637,19 +637,19 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that that all three pages are present and remember the // indexes. - auto lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; uint256 const middleNFTokenPageIndex = lastNFTokenPage->at(sfPreviousPageMin); auto middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; uint256 const firstNFTokenPageIndex = middleNFTokenPage->at(sfPreviousPageMin); auto firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); if (!BEAST_EXPECT(firstNFTokenPage)) return; @@ -664,18 +664,18 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify the first page is gone. firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); BEAST_EXPECT(!firstNFTokenPage); // Check the links in the other two pages. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; BEAST_EXPECT(!middleNFTokenPage->isFieldPresent(sfPreviousPageMin)); BEAST_EXPECT(middleNFTokenPage->isFieldPresent(sfNextPageMin)); - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; BEAST_EXPECT(lastNFTokenPage->isFieldPresent(sfPreviousPageMin)); @@ -696,7 +696,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // _previous_ page because we need to preserve that last // page an an anchor. The contents of the next-to-last page // are moved into the last page. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(lastNFTokenPage); BEAST_EXPECT(!lastNFTokenPage->isFieldPresent(sfPreviousPageMin)); BEAST_EXPECT(!lastNFTokenPage->isFieldPresent(sfNextPageMin)); @@ -704,12 +704,12 @@ class NFTokenBurn_test : public beast::unit_test::suite // The "middle" page should be gone. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); BEAST_EXPECT(!middleNFTokenPage); // The "first" page should still be gone. firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); BEAST_EXPECT(!firstNFTokenPage); } else @@ -717,13 +717,13 @@ class NFTokenBurn_test : public beast::unit_test::suite // Removing the last token from the last page deletes the last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(!lastNFTokenPage); // The "middle" page is still present, but has lost the // NextPageMin field. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; BEAST_EXPECT(!middleNFTokenPage->isFieldPresent(sfPreviousPageMin)); @@ -771,13 +771,13 @@ class NFTokenBurn_test : public beast::unit_test::suite // checks. These variables must outlive the ApplyContext. OpenView ov{*env.current()}; STTx const tx{ttACCOUNT_SET, [](STObject&) {}}; - test::StreamSink sink{beast::severities::kWarning}; + test::StreamSink sink{beast::severities::KWarning}; beast::Journal const jlog{sink}; ApplyContext ac{ - env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, tapNONE, jlog}; + env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog}; // Verify that the last page is present and contains one NFT. - auto lastNFTokenPage = ac.view().peek(keylet::nftpage_max(alice)); + auto lastNFTokenPage = ac.view().peek(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; BEAST_EXPECT(lastNFTokenPage->getFieldArray(sfNFTokens).size() == 1); @@ -804,16 +804,16 @@ class NFTokenBurn_test : public beast::unit_test::suite // checks. These variables must outlive the ApplyContext. OpenView ov{*env.current()}; STTx const tx{ttACCOUNT_SET, [](STObject&) {}}; - test::StreamSink sink{beast::severities::kWarning}; + test::StreamSink sink{beast::severities::KWarning}; beast::Journal const jlog{sink}; ApplyContext ac{ - env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, tapNONE, jlog}; + env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog}; // Verify that the middle page is present. - auto lastNFTokenPage = ac.view().peek(keylet::nftpage_max(alice)); + auto lastNFTokenPage = ac.view().peek(keylet::nftpageMax(alice)); auto middleNFTokenPage = ac.view().peek( keylet::nftpage( - keylet::nftpage_min(alice), + keylet::nftpageMin(alice), lastNFTokenPage->getFieldH256(sfPreviousPageMin))); BEAST_EXPECT(middleNFTokenPage); @@ -861,8 +861,8 @@ class NFTokenBurn_test : public beast::unit_test::suite // When the token is burned, 498 sell offers and 1 buy offer are // removed. In total, 499 offers are removed std::vector offerIndexes; - auto const nftokenID = - createNftAndOffers(env, alice, offerIndexes, maxDeletableTokenOfferEntries - 2); + auto const nftokenID = createNftAndOffers( + env, alice, offerIndexes, kMAX_DELETABLE_TOKEN_OFFER_ENTRIES - 2); // Verify all sell offers are present in the ledger. for (uint256 const& offerIndex : offerIndexes) @@ -872,7 +872,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // Becky creates a buy offer uint256 const beckyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftokenID, drops(1)), token::owner(alice)); + env(token::createOffer(becky, nftokenID, drops(1)), token::Owner(alice)); env.close(); // Burn the token @@ -908,8 +908,8 @@ class NFTokenBurn_test : public beast::unit_test::suite // After we burn the token, 500 of the sell offers should be // removed, and one is left over std::vector offerIndexes; - auto const nftokenID = - createNftAndOffers(env, alice, offerIndexes, maxDeletableTokenOfferEntries + 1); + auto const nftokenID = createNftAndOffers( + env, alice, offerIndexes, kMAX_DELETABLE_TOKEN_OFFER_ENTRIES + 1); // Verify all sell offers are present in the ledger. for (uint256 const& offerIndex : offerIndexes) @@ -929,10 +929,10 @@ class NFTokenBurn_test : public beast::unit_test::suite offerDeletedCount++; } - BEAST_EXPECT(offerIndexes.size() == maxTokenOfferCancelCount + 1); + BEAST_EXPECT(offerIndexes.size() == kMAX_TOKEN_OFFER_CANCEL_COUNT + 1); // 500 sell offers should be removed - BEAST_EXPECT(offerDeletedCount == maxTokenOfferCancelCount); + BEAST_EXPECT(offerDeletedCount == kMAX_TOKEN_OFFER_CANCEL_COUNT); // alice should have ownerCounts of one for the orphaned sell offer BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -952,8 +952,8 @@ class NFTokenBurn_test : public beast::unit_test::suite // are removed. // In total, 500 offers are removed std::vector offerIndexes; - auto const nftokenID = - createNftAndOffers(env, alice, offerIndexes, maxDeletableTokenOfferEntries - 1); + auto const nftokenID = createNftAndOffers( + env, alice, offerIndexes, kMAX_DELETABLE_TOKEN_OFFER_ENTRIES - 1); // Verify all sell offers are present in the ledger. for (uint256 const& offerIndex : offerIndexes) @@ -962,9 +962,9 @@ class NFTokenBurn_test : public beast::unit_test::suite } // becky creates 2 buy offers - env(token::createOffer(becky, nftokenID, drops(1)), token::owner(alice)); + env(token::createOffer(becky, nftokenID, drops(1)), token::Owner(alice)); env.close(); - env(token::createOffer(becky, nftokenID, drops(1)), token::owner(alice)); + env(token::createOffer(becky, nftokenID, drops(1)), token::Owner(alice)); env.close(); // Burn the token @@ -1042,12 +1042,12 @@ class NFTokenBurn_test : public beast::unit_test::suite std::uint32_t const intTaxon = (i / 16) + (i & 0b10000 ? 2 : 0); uint32_t const extTaxon = internalTaxon(minter, intTaxon); nfts.push_back(token::getNextID(env, minter, extTaxon, tfTransferable)); - env(token::mint(minter, extTaxon), txflags(tfTransferable)); + env(token::mint(minter, extTaxon), Txflags(tfTransferable)); env.close(); // Minter creates an offer for the NFToken. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nfts.back(), XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nfts.back(), XRP(0)), Txflags(tfSellNFToken)); env.close(); // alice accepts the offer. @@ -1061,16 +1061,16 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that the ledger does indeed contain exactly three pages // of NFTs with 32 entries in each page. - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = "current"; jvParams[jss::binary] = false; { - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); - Json::Value& state = jrr[jss::result][jss::state]; + json::Value& state = jrr[jss::result][jss::state]; int pageCount = 0; - for (Json::UInt i = 0; i < state.size(); ++i) + for (json::UInt i = 0; i < state.size(); ++i) { if (state[i].isMember(sfNFTokens.jsonName) && state[i][sfNFTokens.jsonName].isArray()) @@ -1093,19 +1093,19 @@ class NFTokenBurn_test : public beast::unit_test::suite // Verify that that all three pages are present and remember the // indexes. - auto lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + auto lastNFTokenPage = env.le(keylet::nftpageMax(alice)); if (!BEAST_EXPECT(lastNFTokenPage)) return; uint256 const middleNFTokenPageIndex = lastNFTokenPage->at(sfPreviousPageMin); auto middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; uint256 const firstNFTokenPageIndex = middleNFTokenPage->at(sfPreviousPageMin); auto firstNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), firstNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), firstNFTokenPageIndex)); if (!BEAST_EXPECT(firstNFTokenPage)) return; @@ -1118,7 +1118,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // alice creates an offer for the NFToken. uint256 const aliceOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, last32NFTs.back(), XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(alice, last32NFTs.back(), XRP(0)), Txflags(tfSellNFToken)); env.close(); // minter accepts the offer. @@ -1129,14 +1129,14 @@ class NFTokenBurn_test : public beast::unit_test::suite // Removing the last token from the last page deletes alice's last // page. This is a bug. The contents of the next-to-last page // should have been moved into the last page. - lastNFTokenPage = env.le(keylet::nftpage_max(alice)); + lastNFTokenPage = env.le(keylet::nftpageMax(alice)); BEAST_EXPECT(!lastNFTokenPage); BEAST_EXPECT(ownerCount(env, alice) == 2); // The "middle" page is still present, but has lost the // NextPageMin field. middleNFTokenPage = - env.le(keylet::nftpage(keylet::nftpage_min(alice), middleNFTokenPageIndex)); + env.le(keylet::nftpage(keylet::nftpageMin(alice), middleNFTokenPageIndex)); if (!BEAST_EXPECT(middleNFTokenPage)) return; BEAST_EXPECT(middleNFTokenPage->isFieldPresent(sfPreviousPageMin)); @@ -1144,7 +1144,7 @@ class NFTokenBurn_test : public beast::unit_test::suite // Attempt to delete alice's account, but fail because she owns NFTs. auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, minter), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice, minter), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); env.close(); // minter sells the last 32 NFTs back to alice. @@ -1152,7 +1152,7 @@ class NFTokenBurn_test : public beast::unit_test::suite { // minter creates an offer for the NFToken. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); // alice accepts the offer. @@ -1165,8 +1165,8 @@ class NFTokenBurn_test : public beast::unit_test::suite { // Try the account_objects RPC command. Alice's account only shows // two NFT pages even though she owns more. - Json::Value acctObjs = [&env, &alice]() { - Json::Value params; + json::Value acctObjs = [&env, &alice]() { + json::Value params; params[jss::account] = alice.human(); return env.rpc("json", "account_objects", to_string(params)); }(); @@ -1176,8 +1176,8 @@ class NFTokenBurn_test : public beast::unit_test::suite { // Try the account_nfts RPC command. It only returns 64 NFTs // although alice owns 96. - Json::Value aliceNFTs = [&env, &alice]() { - Json::Value params; + json::Value aliceNFTs = [&env, &alice]() { + json::Value params; params[jss::account] = alice.human(); params[jss::type] = "state"; return env.rpc("json", "account_nfts", to_string(params)); @@ -1188,7 +1188,7 @@ class NFTokenBurn_test : public beast::unit_test::suite } protected: - FeatureBitset const allFeatures{test::jtx::testable_amendments()}; + FeatureBitset const allFeatures_{test::jtx::testableAmendments()}; void testWithFeats(FeatureBitset features) @@ -1203,8 +1203,8 @@ public: void run() override { - testWithFeats(allFeatures - fixNFTokenPageLinks); - testWithFeats(allFeatures); + testWithFeats(allFeatures_ - fixNFTokenPageLinks); + testWithFeats(allFeatures_); } }; diff --git a/src/test/app/NFTokenDir_test.cpp b/src/test/app/NFTokenDir_test.cpp index a1527e8601..fbae51406b 100644 --- a/src/test/app/NFTokenDir_test.cpp +++ b/src/test/app/NFTokenDir_test.cpp @@ -36,25 +36,25 @@ namespace xrpl { -class NFTokenDir_test : public beast::unit_test::suite +class NFTokenDir_test : public beast::unit_test::Suite { // printNFTPages is a helper function that may be used for debugging. // // It uses the ledger RPC command to show the NFT pages in the ledger. // This parameter controls how noisy the output is. enum class Volume : bool { - quiet = false, - noisy = true, + Quiet = false, + Noisy = true, }; static void printNFTPages(test::jtx::Env& env, Volume vol) { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = "current"; jvParams[jss::binary] = false; { - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); // Iterate the state and print all NFTokenPages. if (!jrr.isMember(jss::result) || !jrr[jss::result].isMember(jss::state)) @@ -62,13 +62,13 @@ class NFTokenDir_test : public beast::unit_test::suite std::cout << "No ledger state found!" << std::endl; return; } - Json::Value& state = jrr[jss::result][jss::state]; + json::Value& state = jrr[jss::result][jss::state]; if (!state.isArray()) { std::cout << "Ledger state is not array!" << std::endl; return; } - for (Json::UInt i = 0; i < state.size(); ++i) + for (json::UInt i = 0; i < state.size(); ++i) { if (state[i].isMember(sfNFTokens.jsonName) && state[i][sfNFTokens.jsonName].isArray()) @@ -77,7 +77,7 @@ class NFTokenDir_test : public beast::unit_test::suite std::cout << tokenCount << " NFtokens in page " << state[i][jss::index].asString() << std::endl; - if (vol == Volume::noisy) + if (vol == Volume::Noisy) { std::cout << state[i].toStyledString() << std::endl; } @@ -126,14 +126,14 @@ class NFTokenDir_test : public beast::unit_test::suite // Mint 100 sequential NFTs. Tweak the taxon so zero is always stored. // That's what makes them sequential. - constexpr std::size_t nftCount = 100; + constexpr std::size_t kNFT_COUNT = 100; std::vector nftIDs; - nftIDs.reserve(nftCount); - for (int i = 0; i < nftCount; ++i) + nftIDs.reserve(kNFT_COUNT); + for (int i = 0; i < kNFT_COUNT; ++i) { std::uint32_t const taxon = toUInt32(nft::cipheredTaxon(i, nft::toTaxon(0))); nftIDs.emplace_back(token::getNextID(env, issuer, taxon, tfTransferable)); - env(token::mint(issuer, taxon), txflags(tfTransferable)); + env(token::mint(issuer, taxon), Txflags(tfTransferable)); env.close(); } @@ -143,7 +143,7 @@ class NFTokenDir_test : public beast::unit_test::suite for (uint256 const& nftID : nftIDs) { offers.emplace_back(keylet::nftoffer(issuer, env.seq(issuer)).key); - env(token::createOffer(issuer, nftID, XRP(0)), txflags((tfSellNFToken))); + env(token::createOffer(issuer, nftID, XRP(0)), Txflags((tfSellNFToken))); env.close(); } @@ -190,7 +190,7 @@ class NFTokenDir_test : public beast::unit_test::suite for (std::string_view const seed : seeds) { Account const& account = - accounts.emplace_back(Account::AcctStringType::base58Seed, std::string(seed)); + accounts.emplace_back(Account::AcctStringType::Base58Seed, std::string(seed)); env.fund(XRP(10000), account); // Do not close the ledger inside the loop. If accounts are @@ -210,14 +210,14 @@ class NFTokenDir_test : public beast::unit_test::suite // Mint the NFT. uint256 const& nftID = nftIDs.emplace_back(token::getNextID(env, account, 0, tfTransferable)); - env(token::mint(account, 0), txflags(tfTransferable)); + env(token::mint(account, 0), Txflags(tfTransferable)); env.close(); // Create an offer to give the NFT to buyer for free. offers.emplace_back(keylet::nftoffer(account, env.seq(account)).key); env(token::createOffer(account, nftID, XRP(0)), - token::destination(buyer), - txflags((tfSellNFToken))); + token::Destination(buyer), + Txflags((tfSellNFToken))); } env.close(); @@ -238,22 +238,22 @@ class NFTokenDir_test : public beast::unit_test::suite for (uint256 const& nftID : nftIDs) { uint256 const offerID = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(100)), txflags(tfSellNFToken)); + env(token::createOffer(buyer, nftID, XRP(100)), Txflags(tfSellNFToken)); env.close(); env(token::cancelOffer(buyer, {offerID})); } // Verify that all the NFTs are owned by buyer. - Json::Value buyerNFTs = [&env, &buyer]() { - Json::Value params; + json::Value buyerNFTs = [&env, &buyer]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = "state"; return env.rpc("json", "account_nfts", to_string(params)); }(); BEAST_EXPECT(buyerNFTs[jss::result][jss::account_nfts].size() == nftIDs.size()); - for (Json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) + for (json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) { uint256 ownedID; BEAST_EXPECT(ownedID.parseHex(ownedNFT[sfNFTokenID.jsonName].asString())); @@ -272,7 +272,7 @@ class NFTokenDir_test : public beast::unit_test::suite // These seeds cause a lopsided split where the new NFT is added // to the upper page. - static std::initializer_list const splitAndAddToHi{ + static std::initializer_list const kSPLIT_AND_ADD_TO_HI{ "sp6JS7f14BuwFY8Mw5p3b8jjQBBTK", // 0. 0x1d2932ea "sp6JS7f14BuwFY8Mw6F7X3EiGKazu", // 1. 0x1d2932ea "sp6JS7f14BuwFY8Mw6FxjntJJfKXq", // 2. 0x1d2932ea @@ -318,7 +318,7 @@ class NFTokenDir_test : public beast::unit_test::suite // These seeds cause a lopsided split where the new NFT is added // to the lower page. - static std::initializer_list const splitAndAddToLo{ + static std::initializer_list const kSPLIT_AND_ADD_TO_LO{ "sp6JS7f14BuwFY8Mw5p3b8jjQBBTK", // 0. 0x1d2932ea "sp6JS7f14BuwFY8Mw6F7X3EiGKazu", // 1. 0x1d2932ea "sp6JS7f14BuwFY8Mw6FxjntJJfKXq", // 2. 0x1d2932ea @@ -363,8 +363,8 @@ class NFTokenDir_test : public beast::unit_test::suite }; // Run the test cases. - exerciseLopsided(splitAndAddToHi); - exerciseLopsided(splitAndAddToLo); + exerciseLopsided(kSPLIT_AND_ADD_TO_HI); + exerciseLopsided(kSPLIT_AND_ADD_TO_LO); } void @@ -381,7 +381,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Lambda that exercises the split. auto exercise = [this, &features](std::initializer_list seeds) { - Env env{*this, envconfig(), features, nullptr, beast::severities::kDisabled}; + Env env{*this, envconfig(), features, nullptr, beast::severities::KDisabled}; // Eventually all of the NFTokens will be owned by buyer. Account const buyer{"buyer"}; @@ -394,7 +394,7 @@ class NFTokenDir_test : public beast::unit_test::suite for (std::string_view const seed : seeds) { Account const& account = - accounts.emplace_back(Account::AcctStringType::base58Seed, std::string(seed)); + accounts.emplace_back(Account::AcctStringType::Base58Seed, std::string(seed)); env.fund(XRP(10000), account); // Do not close the ledger inside the loop. If accounts are @@ -414,14 +414,14 @@ class NFTokenDir_test : public beast::unit_test::suite // Mint the NFT. uint256 const& nftID = nftIDs.emplace_back(token::getNextID(env, account, 0, tfTransferable)); - env(token::mint(account, 0), txflags(tfTransferable)); + env(token::mint(account, 0), Txflags(tfTransferable)); env.close(); // Create an offer to give the NFT to buyer for free. offers.emplace_back(keylet::nftoffer(account, env.seq(account)).key); env(token::createOffer(account, nftID, XRP(0)), - token::destination(buyer), - txflags((tfSellNFToken))); + token::Destination(buyer), + Txflags((tfSellNFToken))); } env.close(); @@ -446,22 +446,22 @@ class NFTokenDir_test : public beast::unit_test::suite for (uint256 const& nftID : nftIDs) { uint256 const offerID = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(100)), txflags(tfSellNFToken)); + env(token::createOffer(buyer, nftID, XRP(100)), Txflags(tfSellNFToken)); env.close(); env(token::cancelOffer(buyer, {offerID})); } // Verify that all the NFTs are owned by buyer. - Json::Value buyerNFTs = [&env, &buyer]() { - Json::Value params; + json::Value buyerNFTs = [&env, &buyer]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = "state"; return env.rpc("json", "account_nfts", to_string(params)); }(); BEAST_EXPECT(buyerNFTs[jss::result][jss::account_nfts].size() == nftIDs.size()); - for (Json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) + for (json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) { uint256 ownedID; BEAST_EXPECT(ownedID.parseHex(ownedNFT[sfNFTokenID.jsonName].asString())); @@ -480,7 +480,7 @@ class NFTokenDir_test : public beast::unit_test::suite // These seeds fill the last 17 entries of the initial page with // equivalent NFTs. The split should keep these together. - static std::initializer_list const seventeenHi{ + static std::initializer_list const kSEVENTEEN_HI{ // These 16 need to be kept together by the implementation. "sp6JS7f14BuwFY8Mw5EYu5z86hKDL", // 0. 0x399187e9 "sp6JS7f14BuwFY8Mw5PUAMwc5ygd7", // 1. 0x399187e9 @@ -521,7 +521,7 @@ class NFTokenDir_test : public beast::unit_test::suite // These seeds fill the first entries of the initial page with // equivalent NFTs. The split should keep these together. - static std::initializer_list const seventeenLo{ + static std::initializer_list const kSEVENTEEN_LO{ // These 17 need to be kept together by the implementation. "sp6JS7f14BuwFY8Mw5EYu5z86hKDL", // 0. 0x399187e9 "sp6JS7f14BuwFY8Mw5PUAMwc5ygd7", // 1. 0x399187e9 @@ -561,8 +561,8 @@ class NFTokenDir_test : public beast::unit_test::suite }; // Run the test cases. - exercise(seventeenHi); - exercise(seventeenLo); + exercise(kSEVENTEEN_HI); + exercise(kSEVENTEEN_LO); } void @@ -583,7 +583,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Here are 33 seeds that produce identical low 32-bits in their // corresponding AccountIDs. - static std::initializer_list const seeds{ + static std::initializer_list const kSEEDS{ "sp6JS7f14BuwFY8Mw5FnqmbciPvH6", // 0. 0x9a8ebed3 "sp6JS7f14BuwFY8Mw5MBGbyMSsXLp", // 1. 0x9a8ebed3 "sp6JS7f14BuwFY8Mw5S4PnDyBdKKm", // 2. 0x9a8ebed3 @@ -621,11 +621,11 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; - accounts.reserve(seeds.size()); - for (std::string_view const seed : seeds) + accounts.reserve(kSEEDS.size()); + for (std::string_view const seed : kSEEDS) { Account const& account = - accounts.emplace_back(Account::AcctStringType::base58Seed, std::string(seed)); + accounts.emplace_back(Account::AcctStringType::Base58Seed, std::string(seed)); env.fund(XRP(10000), account); // Do not close the ledger inside the loop. If accounts are @@ -644,22 +644,22 @@ class NFTokenDir_test : public beast::unit_test::suite // Mint the NFT. uint256 const& nftID = nftIDs.emplace_back(token::getNextID(env, account, 0, tfTransferable)); - env(token::mint(account, 0), txflags(tfTransferable)); + env(token::mint(account, 0), Txflags(tfTransferable)); env.close(); // Create an offer to give the NFT to buyer for free. offers.emplace_back(keylet::nftoffer(account, env.seq(account)).key); env(token::createOffer(account, nftID, XRP(0)), - token::destination(buyer), - txflags((tfSellNFToken))); + token::Destination(buyer), + Txflags((tfSellNFToken))); } env.close(); // Verify that the low 96 bits of all generated NFTs is identical. - uint256 const expectLowBits = nftIDs.front() & nft::pageMask; + uint256 const expectLowBits = nftIDs.front() & nft::kPAGE_MASK; for (uint256 const& nftID : nftIDs) { - BEAST_EXPECT(expectLowBits == (nftID & nft::pageMask)); + BEAST_EXPECT(expectLowBits == (nftID & nft::kPAGE_MASK)); } // Remove one NFT and offer from the vectors. This offer is the one @@ -676,7 +676,7 @@ class NFTokenDir_test : public beast::unit_test::suite } // buyer accepts the last offer which causes a page overflow. - env(token::acceptSellOffer(buyer, offerForPageOverflow), ter(tecNO_SUITABLE_NFTOKEN_PAGE)); + env(token::acceptSellOffer(buyer, offerForPageOverflow), Ter(tecNO_SUITABLE_NFTOKEN_PAGE)); // Verify that all expected NFTs are owned by buyer and findable in // the ledger by having buyer create sell offers for all of their NFTs. @@ -685,22 +685,22 @@ class NFTokenDir_test : public beast::unit_test::suite for (uint256 const& nftID : nftIDs) { uint256 const offerID = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(100)), txflags(tfSellNFToken)); + env(token::createOffer(buyer, nftID, XRP(100)), Txflags(tfSellNFToken)); env.close(); env(token::cancelOffer(buyer, {offerID})); } // Verify that all the NFTs are owned by buyer. - Json::Value buyerNFTs = [&env, &buyer]() { - Json::Value params; + json::Value buyerNFTs = [&env, &buyer]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = "state"; return env.rpc("json", "account_nfts", to_string(params)); }(); BEAST_EXPECT(buyerNFTs[jss::result][jss::account_nfts].size() == nftIDs.size()); - for (Json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) + for (json::Value const& ownedNFT : buyerNFTs[jss::result][jss::account_nfts]) { uint256 ownedID; BEAST_EXPECT(ownedID.parseHex(ownedNFT[sfNFTokenID.jsonName].asString())); @@ -716,7 +716,7 @@ class NFTokenDir_test : public beast::unit_test::suite BEAST_EXPECT(nftIDs.empty()); TER const expect = tesSUCCESS; - env(token::mint(buyer, 0), txflags(tfTransferable), ter(expect)); + env(token::mint(buyer, 0), Txflags(tfTransferable), Ter(expect)); env.close(); } @@ -731,7 +731,7 @@ class NFTokenDir_test : public beast::unit_test::suite // // All of the NFTs should be acquired by the buyer. // - // Lastly, none of the remaining NFTs should be acquirable by the + // Lastly, kNONE of the remaining NFTs should be acquirable by the // buyer. They would cause page overflow. testcase("NFToken consecutive packing"); @@ -747,7 +747,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Here are 33 seeds that produce identical low 32-bits in their // corresponding AccountIDs. - static std::initializer_list const seeds{ + static std::initializer_list const kSEEDS{ "sp6JS7f14BuwFY8Mw56vZeiBuhePx", // 0. 0x115d0525 "sp6JS7f14BuwFY8Mw5BodF9tGuTUe", // 1. 0x115d0525 "sp6JS7f14BuwFY8Mw5EnhC1cg84J7", // 2. 0x115d0525 @@ -785,11 +785,11 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; - accounts.reserve(seeds.size()); - for (std::string_view const seed : seeds) + accounts.reserve(kSEEDS.size()); + for (std::string_view const seed : kSEEDS) { Account const& account = - accounts.emplace_back(Account::AcctStringType::base58Seed, std::string(seed)); + accounts.emplace_back(Account::AcctStringType::Base58Seed, std::string(seed)); env.fund(XRP(10000), account); // Do not close the ledger inside the loop. If accounts are @@ -816,14 +816,14 @@ class NFTokenDir_test : public beast::unit_test::suite uint256 const& nftID = nftIDsByPage[i].emplace_back( token::getNextID(env, account, taxon, tfTransferable)); - env(token::mint(account, taxon), txflags(tfTransferable)); + env(token::mint(account, taxon), Txflags(tfTransferable)); env.close(); // Create an offer to give the NFT to buyer for free. offers[i].emplace_back(keylet::nftoffer(account, env.seq(account)).key); env(token::createOffer(account, nftID, XRP(0)), - token::destination(buyer), - txflags((tfSellNFToken))); + token::Destination(buyer), + Txflags((tfSellNFToken))); } } env.close(); @@ -832,10 +832,10 @@ class NFTokenDir_test : public beast::unit_test::suite // sequence is identical. for (auto const& vec : nftIDsByPage) { - uint256 const expectLowBits = vec.front() & nft::pageMask; + uint256 const expectLowBits = vec.front() & nft::kPAGE_MASK; for (uint256 const& nftID : vec) { - BEAST_EXPECT(expectLowBits == (nftID & nft::pageMask)); + BEAST_EXPECT(expectLowBits == (nftID & nft::kPAGE_MASK)); } } @@ -850,11 +850,11 @@ class NFTokenDir_test : public beast::unit_test::suite { overflowNFTs.push_back(nftIDsByPage[i].back()); nftIDsByPage[i].pop_back(); - BEAST_EXPECT(nftIDsByPage[i].size() == seeds.size() - 1); + BEAST_EXPECT(nftIDsByPage[i].size() == kSEEDS.size() - 1); overflowOffers.push_back(offers[i].back()); offers[i].pop_back(); - BEAST_EXPECT(offers[i].size() == seeds.size() - 1); + BEAST_EXPECT(offers[i].size() == kSEEDS.size() - 1); } // buyer accepts all of the offers that won't cause an overflow. @@ -873,7 +873,7 @@ class NFTokenDir_test : public beast::unit_test::suite // the transaction succeeded. for (uint256 const& offer : overflowOffers) { - env(token::acceptSellOffer(buyer, offer), ter(tecNO_SUITABLE_NFTOKEN_PAGE)); + env(token::acceptSellOffer(buyer, offer), Ter(tecNO_SUITABLE_NFTOKEN_PAGE)); env.close(); } @@ -885,19 +885,19 @@ class NFTokenDir_test : public beast::unit_test::suite { for (uint256 const& nftID : vec) { - env(token::createOffer(buyer, nftID, XRP(100)), txflags(tfSellNFToken)); + env(token::createOffer(buyer, nftID, XRP(100)), Txflags(tfSellNFToken)); env.close(); } } // See what the account_objects command does with "nft_offer". { - Json::Value ownedNftOffers(Json::arrayValue); + json::Value ownedNftOffers(json::ArrayValue); std::string marker; do { - Json::Value buyerOffers = [&env, &buyer, &marker]() { - Json::Value params; + json::Value buyerOffers = [&env, &buyer, &marker]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = jss::nft_offer; @@ -909,14 +909,14 @@ class NFTokenDir_test : public beast::unit_test::suite marker.clear(); if (buyerOffers.isMember(jss::result)) { - Json::Value& result = buyerOffers[jss::result]; + json::Value& result = buyerOffers[jss::result]; if (result.isMember(jss::marker)) marker = result[jss::marker].asString(); if (result.isMember(jss::account_objects)) { - Json::Value& someOffers = result[jss::account_objects]; + json::Value& someOffers = result[jss::account_objects]; for (std::size_t i = 0; i < someOffers.size(); ++i) ownedNftOffers.append(someOffers[i]); } @@ -950,8 +950,8 @@ class NFTokenDir_test : public beast::unit_test::suite } // account_objects should no longer return any "nft_offer"s. - Json::Value remainingOffers = [&env, &buyer]() { - Json::Value params; + json::Value remainingOffers = [&env, &buyer]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = jss::nft_offer; @@ -965,12 +965,12 @@ class NFTokenDir_test : public beast::unit_test::suite // Verify that the ledger reports all of the NFTs owned by buyer. // Use the account_nfts rpc call to get the values. - Json::Value ownedNFTs(Json::arrayValue); + json::Value ownedNFTs(json::ArrayValue); std::string marker; do { - Json::Value buyerNFTs = [&env, &buyer, &marker]() { - Json::Value params; + json::Value buyerNFTs = [&env, &buyer, &marker]() { + json::Value params; params[jss::account] = buyer.human(); params[jss::type] = "state"; @@ -982,14 +982,14 @@ class NFTokenDir_test : public beast::unit_test::suite marker.clear(); if (buyerNFTs.isMember(jss::result)) { - Json::Value& result = buyerNFTs[jss::result]; + json::Value& result = buyerNFTs[jss::result]; if (result.isMember(jss::marker)) marker = result[jss::marker].asString(); if (result.isMember(jss::account_nfts)) { - Json::Value& someNFTs = result[jss::account_nfts]; + json::Value& someNFTs = result[jss::account_nfts]; for (std::size_t i = 0; i < someNFTs.size(); ++i) ownedNFTs.append(someNFTs[i]); } @@ -1003,7 +1003,7 @@ class NFTokenDir_test : public beast::unit_test::suite BEAST_EXPECT(ownedNFTs.size() == allNftIDs.size()); - for (Json::Value const& ownedNFT : ownedNFTs) + for (json::Value const& ownedNFT : ownedNFTs) { if (ownedNFT.isMember(sfNFTokenID.jsonName)) { @@ -1037,7 +1037,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testWithFeats(all); } diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index a9252d2b5e..3f4260e1b1 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -54,7 +54,7 @@ namespace xrpl { -class NFTokenBaseUtil_test : public beast::unit_test::suite +class NFTokenBaseUtil_test : public beast::unit_test::Suite { // Helper function that returns the number of NFTs minted by an issuer. static std::uint32_t @@ -80,10 +80,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite static std::uint32_t nftCount(test::jtx::Env& env, test::jtx::Account const& acct) { - Json::Value params; + json::Value params; params[jss::account] = acct.human(); params[jss::type] = "state"; - Json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); + json::Value nfts = env.rpc("json", "account_nfts", to_string(params)); return nfts[jss::result][jss::account_nfts].size(); }; @@ -134,7 +134,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(burnedCount(env, master) == 1); uint256 const nftId1{token::getNextID(env, env.master, 0u, tfTransferable)}; - env(token::mint(env.master, 0u), txflags(tfTransferable)); + env(token::mint(env.master, 0u), Txflags(tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, master) == 1); BEAST_EXPECT(mintedCount(env, master) == 2); @@ -144,7 +144,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.fund(XRP(10000), alice); env.close(); uint256 const aliceOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftId1, XRP(1000)), token::owner(master)); + env(token::createOffer(alice, nftId1, XRP(1000)), token::Owner(master)); env.close(); BEAST_EXPECT(ownerCount(env, master) == 1); @@ -196,7 +196,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice does not have enough XRP to cover the reserve for an NFT // page. - env(token::mint(alice, 0u), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(alice, 0u), Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -233,7 +233,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice still does not have enough XRP for the reserve of an NFT // page. - env(token::mint(alice, 0u), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(alice, 0u), Ter(tecINSUFFICIENT_RESERVE)); env.close(); checkAliceOwnerMintedBurned(0, 0, 0, __LINE__); @@ -258,7 +258,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // That NFT page is full. Creating an additional NFT page requires // additional reserve. - env(token::mint(alice), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(alice), Ter(tecINSUFFICIENT_RESERVE)); env.close(); checkAliceOwnerMintedBurned(1, 32, 0, __LINE__); @@ -268,7 +268,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice still does not have enough XRP for the reserve of an NFT // page. - env(token::mint(alice), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(alice), Ter(tecINSUFFICIENT_RESERVE)); env.close(); checkAliceOwnerMintedBurned(1, 32, 0, __LINE__); @@ -292,7 +292,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } // alice burns a non-existent NFT. - env(token::burn(alice, token::getID(env, alice, 197, 5)), ter(tecNO_ENTRY)); + env(token::burn(alice, token::getID(env, alice, 197, 5)), Ter(tecNO_ENTRY)); env.close(); checkAliceOwnerMintedBurned(0, 33, 33, __LINE__); @@ -346,9 +346,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // page. Just for grins (and code coverage), minter mints NFTs that // include a URI. env(token::mint(minter), - token::issuer(alice), - token::uri("uri"), - ter(tecINSUFFICIENT_RESERVE)); + token::Issuer(alice), + token::Uri("uri"), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); checkMintersOwnerMintedBurned(0, 33, nftSeq, 0, 0, 0, __LINE__); @@ -357,7 +357,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // Now minter can mint an NFT for alice. - env(token::mint(minter), token::issuer(alice), token::uri("uri")); + env(token::mint(minter), token::Issuer(alice), token::Uri("uri")); env.close(); checkMintersOwnerMintedBurned(0, 34, nftSeq, 1, 0, 0, __LINE__); @@ -365,7 +365,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // without any additional reserve requirements. for (int i = 1; i < 32; ++i) { - env(token::mint(minter), token::issuer(alice), token::uri("uri")); + env(token::mint(minter), token::Issuer(alice), token::Uri("uri")); checkMintersOwnerMintedBurned(0, i + 34, nftSeq, 1, 0, 0, __LINE__); } @@ -377,9 +377,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // That NFT page is full. Creating an additional NFT page requires // additional reserve. env(token::mint(minter), - token::issuer(alice), - token::uri("uri"), - ter(tecINSUFFICIENT_RESERVE)); + token::Issuer(alice), + token::Uri("uri"), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); checkMintersOwnerMintedBurned(0, 65, nftSeq, 1, 0, 0, __LINE__); @@ -388,7 +388,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // Now minter can mint an NFT. - env(token::mint(minter), token::issuer(alice), token::uri("uri")); + env(token::mint(minter), token::Issuer(alice), token::Uri("uri")); env.close(); checkMintersOwnerMintedBurned(0, 66, nftSeq, 2, 0, 0, __LINE__); @@ -408,7 +408,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkMintersOwnerMintedBurned(0, 66, nftSeq, 0, 0, 0, __LINE__); // minter burns a non-existent NFT. - env(token::burn(minter, token::getID(env, alice, 2009, 3)), ter(tecNO_ENTRY)); + env(token::burn(minter, token::getID(env, alice, 2009, 3)), Ter(tecNO_ENTRY)); env.close(); checkMintersOwnerMintedBurned(0, 66, nftSeq, 0, 0, 0, __LINE__); } @@ -468,8 +468,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite }); // See whether alice is at the boundary that causes an error. - env(token::mint(alice, 0u), ter(tesSUCCESS)); - env(token::mint(alice, 0u), ter(tecMAX_SEQUENCE_REACHED)); + env(token::mint(alice, 0u), Ter(tesSUCCESS)); + env(token::mint(alice, 0u), Ter(tecMAX_SEQUENCE_REACHED)); } void @@ -490,7 +490,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.fund(XRP(200), alice, minter); env.close(); - env(token::mint(alice, 0u), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(alice, 0u), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // Fund alice enough to start minting NFTs. @@ -501,43 +501,43 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // preflight // Set a negative fee. - env(token::mint(alice, 0u), fee(STAmount(10ull, true)), ter(temBAD_FEE)); + env(token::mint(alice, 0u), Fee(STAmount(10ull, true)), Ter(temBAD_FEE)); // Set an invalid flag. - env(token::mint(alice, 0u), txflags(0x00008000), ter(temINVALID_FLAG)); + env(token::mint(alice, 0u), Txflags(0x00008000), Ter(temINVALID_FLAG)); // Can't set a transfer fee if the NFT does not have the tfTRANSFERABLE // flag set. - env(token::mint(alice, 0u), token::xferFee(maxTransferFee), ter(temMALFORMED)); + env(token::mint(alice, 0u), token::XferFee(kMAX_TRANSFER_FEE), Ter(temMALFORMED)); // Set a bad transfer fee. env(token::mint(alice, 0u), - token::xferFee(maxTransferFee + 1), - txflags(tfTransferable), - ter(temBAD_NFTOKEN_TRANSFER_FEE)); + token::XferFee(kMAX_TRANSFER_FEE + 1), + Txflags(tfTransferable), + Ter(temBAD_NFTOKEN_TRANSFER_FEE)); // Account can't also be issuer. - env(token::mint(alice, 0u), token::issuer(alice), ter(temMALFORMED)); + env(token::mint(alice, 0u), token::Issuer(alice), Ter(temMALFORMED)); // Invalid URI: zero length. - env(token::mint(alice, 0u), token::uri(""), ter(temMALFORMED)); + env(token::mint(alice, 0u), token::Uri(""), Ter(temMALFORMED)); // Invalid URI: too long. env(token::mint(alice, 0u), - token::uri(std::string(maxTokenURILength + 1, 'q')), - ter(temMALFORMED)); + token::Uri(std::string(kMAX_TOKEN_URI_LENGTH + 1, 'q')), + Ter(temMALFORMED)); //---------------------------------------------------------------------- // preclaim // Non-existent issuer. - env(token::mint(alice, 0u), token::issuer(Account("demon")), ter(tecNO_ISSUER)); + env(token::mint(alice, 0u), token::Issuer(Account("demon")), Ter(tecNO_ISSUER)); //---------------------------------------------------------------------- // doApply // Existent issuer, but not given minting permission - env(token::mint(minter, 0u), token::issuer(alice), ter(tecNO_PERMISSION)); + env(token::mint(minter, 0u), token::Issuer(alice), Ter(tecNO_PERMISSION)); } void @@ -563,7 +563,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const nftAlice0ID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -571,12 +571,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // preflight // Set a negative fee. - env(token::burn(alice, nftAlice0ID), fee(STAmount(10ull, true)), ter(temBAD_FEE)); + env(token::burn(alice, nftAlice0ID), Fee(STAmount(10ull, true)), Ter(temBAD_FEE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // Set an invalid flag. - env(token::burn(alice, nftAlice0ID), txflags(0x00008000), ter(temINVALID_FLAG)); + env(token::burn(alice, nftAlice0ID), Txflags(0x00008000), Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); @@ -584,7 +584,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // preclaim // Try to burn a token that doesn't exist. - env(token::burn(alice, token::getID(env, alice, 0, 1)), ter(tecNO_ENTRY)); + env(token::burn(alice, token::getID(env, alice, 0, 1)), Ter(tecNO_ENTRY)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); @@ -616,12 +616,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const nftAlice0ID = token::getNextID(env, alice, 0, tfTransferable, 10); - env(token::mint(alice, 0u), txflags(tfTransferable), token::xferFee(10)); + env(token::mint(alice, 0u), Txflags(tfTransferable), token::XferFee(10)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); uint256 const nftXrpOnlyID = token::getNextID(env, alice, 0, tfOnlyXRP | tfTransferable); - env(token::mint(alice, 0), txflags(tfOnlyXRP | tfTransferable)); + env(token::mint(alice, 0), Txflags(tfOnlyXRP | tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -640,73 +640,73 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // buyer tries to create an NFTokenOffer, but doesn't have the reserve. env(token::createOffer(buyer, nftAlice0ID, XRP(1000)), - token::owner(alice), - ter(tecINSUFFICIENT_RESERVE)); + token::Owner(alice), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // Set a negative fee. env(token::createOffer(buyer, nftAlice0ID, XRP(1000)), - fee(STAmount(10ull, true)), - ter(temBAD_FEE)); + Fee(STAmount(10ull, true)), + Ter(temBAD_FEE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // Set an invalid flag. env(token::createOffer(buyer, nftAlice0ID, XRP(1000)), - txflags(0x00008000), - ter(temINVALID_FLAG)); + Txflags(0x00008000), + Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // Set an invalid amount. - env(token::createOffer(buyer, nftXrpOnlyID, buyer["USD"](1)), ter(temBAD_AMOUNT)); - env(token::createOffer(buyer, nftAlice0ID, buyer["USD"](0)), ter(temBAD_AMOUNT)); - env(token::createOffer(buyer, nftXrpOnlyID, drops(0)), ter(temBAD_AMOUNT)); + env(token::createOffer(buyer, nftXrpOnlyID, buyer["USD"](1)), Ter(temBAD_AMOUNT)); + env(token::createOffer(buyer, nftAlice0ID, buyer["USD"](0)), Ter(temBAD_AMOUNT)); + env(token::createOffer(buyer, nftXrpOnlyID, drops(0)), Ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // Set a bad expiration. env(token::createOffer(buyer, nftAlice0ID, buyer["USD"](1)), - token::expiration(0), - ter(temBAD_EXPIRATION)); + token::Expiration(0), + Ter(temBAD_EXPIRATION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // Invalid Owner field and tfSellToken flag relationships. // A buy offer must specify the owner. - env(token::createOffer(buyer, nftXrpOnlyID, XRP(1000)), ter(temMALFORMED)); + env(token::createOffer(buyer, nftXrpOnlyID, XRP(1000)), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // A sell offer must not specify the owner; the owner is implicit. env(token::createOffer(alice, nftXrpOnlyID, XRP(1000)), - token::owner(alice), - txflags(tfSellNFToken), - ter(temMALFORMED)); + token::Owner(alice), + Txflags(tfSellNFToken), + Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // An owner may not offer to buy their own token. env(token::createOffer(alice, nftXrpOnlyID, XRP(1000)), - token::owner(alice), - ter(temMALFORMED)); + token::Owner(alice), + Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // The destination may not be the account submitting the transaction. env(token::createOffer(alice, nftXrpOnlyID, XRP(1000)), - token::destination(alice), - txflags(tfSellNFToken), - ter(temMALFORMED)); + token::Destination(alice), + Txflags(tfSellNFToken), + Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // The destination must be an account already established in the ledger. env(token::createOffer(alice, nftXrpOnlyID, XRP(1000)), - token::destination(Account("demon")), - txflags(tfSellNFToken), - ter(tecNO_DST)); + token::Destination(Account("demon")), + Txflags(tfSellNFToken), + Ter(tecNO_DST)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -715,30 +715,30 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The new NFTokenOffer may not have passed its expiration time. env(token::createOffer(buyer, nftXrpOnlyID, XRP(1000)), - token::owner(alice), - token::expiration(lastClose(env)), - ter(tecEXPIRED)); + token::Owner(alice), + token::Expiration(lastClose(env)), + Ter(tecEXPIRED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // The nftID must be present in the ledger. env(token::createOffer(buyer, token::getID(env, alice, 0, 1), XRP(1000)), - token::owner(alice), - ter(tecNO_ENTRY)); + token::Owner(alice), + Ter(tecNO_ENTRY)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // The nftID must be present in the ledger of a sell offer too. env(token::createOffer(alice, token::getID(env, alice, 0, 1), XRP(1000)), - txflags(tfSellNFToken), - ter(tecNO_ENTRY)); + Txflags(tfSellNFToken), + Ter(tecNO_ENTRY)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); // buyer must have the funds to pay for their offer. env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecNO_LINE)); + token::Owner(alice), + Ter(tecNO_LINE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); @@ -749,8 +749,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Issuer (alice) must have a trust line for the offered funds. env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecNO_LINE)); + token::Owner(alice), + Ter(tecNO_LINE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -761,8 +761,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Issuer (alice) must have a trust line for the offered funds and // the trust line may not be frozen. env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecFROZEN)); + token::Owner(alice), + Ter(tecFROZEN)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -772,8 +772,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Can't transfer the NFT if the transferable flag is not set. env(token::createOffer(buyer, nftNoXferID, gwAUD(1000)), - token::owner(alice), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + token::Owner(alice), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -782,8 +782,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecFROZEN)); + token::Owner(alice), + Ter(tecFROZEN)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -794,8 +794,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecUNFUNDED_OFFER)); + token::Owner(alice), + Ter(tecUNFUNDED_OFFER)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // the trust line. @@ -809,8 +809,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // However buyer doesn't have enough XRP to cover the reserve for // an NFT offer. env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecINSUFFICIENT_RESERVE)); + token::Owner(alice), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -820,8 +820,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tecINSUFFICIENT_RESERVE)); + token::Owner(alice), + Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -832,8 +832,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // We don't care whether the offer is fully funded until the offer is // accepted. Success at last! env(token::createOffer(buyer, nftAlice0ID, gwAUD(1000)), - token::owner(alice), - ter(tesSUCCESS)); + token::Owner(alice), + Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 2); } @@ -856,13 +856,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const nftAlice0ID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // This is the offer we'll try to cancel. uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftAlice0ID, XRP(1)), token::owner(alice), ter(tesSUCCESS)); + env(token::createOffer(buyer, nftAlice0ID, XRP(1)), token::Owner(alice), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -871,43 +871,43 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Set a negative fee. env(token::cancelOffer(buyer, {buyerOfferIndex}), - fee(STAmount(10ull, true)), - ter(temBAD_FEE)); + Fee(STAmount(10ull, true)), + Ter(temBAD_FEE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // Set an invalid flag. env(token::cancelOffer(buyer, {buyerOfferIndex}), - txflags(0x00008000), - ter(temINVALID_FLAG)); + Txflags(0x00008000), + Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // Empty list of tokens to delete. { - Json::Value jv = token::cancelOffer(buyer); - jv[sfNFTokenOffers.jsonName] = Json::arrayValue; - env(jv, ter(temMALFORMED)); + json::Value jv = token::cancelOffer(buyer); + jv[sfNFTokenOffers.jsonName] = json::ArrayValue; + env(jv, Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); } // List of tokens to delete is too long. { - std::vector const offers(maxTokenOfferCancelCount + 1, buyerOfferIndex); + std::vector const offers(kMAX_TOKEN_OFFER_CANCEL_COUNT + 1, buyerOfferIndex); - env(token::cancelOffer(buyer, offers), ter(temMALFORMED)); + env(token::cancelOffer(buyer, offers), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); } // Duplicate entries are not allowed in the list of offers to cancel. - env(token::cancelOffer(buyer, {buyerOfferIndex, buyerOfferIndex}), ter(temMALFORMED)); + env(token::cancelOffer(buyer, {buyerOfferIndex, buyerOfferIndex}), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // Provide neither offers to cancel nor a root index. - env(token::cancelOffer(buyer), ter(temMALFORMED)); + env(token::cancelOffer(buyer), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -929,7 +929,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(check::create(gw, env.master, XRP(300))); env.close(); - env(token::cancelOffer(gw, {gwCheckId}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(gw, {gwCheckId}), Ter(tecNO_PERMISSION)); env.close(); // Cancel the check so it doesn't mess up later tests. @@ -938,7 +938,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } // gw attempts to cancel an offer they don't have permission to cancel. - env(token::cancelOffer(gw, {buyerOfferIndex}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(gw, {buyerOfferIndex}), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); @@ -971,13 +971,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 0); uint256 const nftAlice0ID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); uint8_t aliceCount = 1; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); uint256 const nftXrpOnlyID = token::getNextID(env, alice, 0, tfOnlyXRP | tfTransferable); - env(token::mint(alice, 0), txflags(tfOnlyXRP | tfTransferable)); + env(token::mint(alice, 0), Txflags(tfOnlyXRP | tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == aliceCount); @@ -988,25 +988,25 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice creates sell offers for her nfts. uint256 const plainOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAlice0ID, XRP(10)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftAlice0ID, XRP(10)), Txflags(tfSellNFToken)); env.close(); aliceCount++; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); uint256 const audOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAlice0ID, gwAUD(30)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftAlice0ID, gwAUD(30)), Txflags(tfSellNFToken)); env.close(); aliceCount++; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); uint256 const xrpOnlyOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftXrpOnlyID, XRP(20)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftXrpOnlyID, XRP(20)), Txflags(tfSellNFToken)); env.close(); aliceCount++; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); uint256 const noXferOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftNoXferID, XRP(30)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftNoXferID, XRP(30)), Txflags(tfSellNFToken)); env.close(); aliceCount++; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); @@ -1014,8 +1014,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice creates a sell offer that will expire soon. uint256 const aliceExpOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftNoXferID, XRP(40)), - txflags(tfSellNFToken), - token::expiration(lastClose(env) + 5)); + Txflags(tfSellNFToken), + token::Expiration(lastClose(env) + 5)); env.close(); aliceCount++; BEAST_EXPECT(ownerCount(env, alice) == aliceCount); @@ -1023,8 +1023,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // buyer creates a Buy offer that will expire soon. uint256 const buyerExpOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftAlice0ID, XRP(40)), - token::owner(alice), - token::expiration(lastClose(env) + 5)); + token::Owner(alice), + token::Expiration(lastClose(env) + 5)); env.close(); uint8_t buyerCount = 1; BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1034,49 +1034,49 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Set a negative fee. env(token::acceptSellOffer(buyer, noXferOfferIndex), - fee(STAmount(10ull, true)), - ter(temBAD_FEE)); + Fee(STAmount(10ull, true)), + Ter(temBAD_FEE)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Set an invalid flag. env(token::acceptSellOffer(buyer, noXferOfferIndex), - txflags(0x00008000), - ter(temINVALID_FLAG)); + Txflags(0x00008000), + Ter(temINVALID_FLAG)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Supply nether an sfNFTokenBuyOffer nor an sfNFTokenSellOffer field. { - Json::Value jv = token::acceptSellOffer(buyer, noXferOfferIndex); + json::Value jv = token::acceptSellOffer(buyer, noXferOfferIndex); jv.removeMember(sfNFTokenSellOffer.jsonName); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); } // A buy offer may not contain a sfNFTokenBrokerFee field. { - Json::Value jv = token::acceptBuyOffer(buyer, noXferOfferIndex); - jv[sfNFTokenBrokerFee.jsonName] = STAmount(500000).getJson(JsonOptions::none); - env(jv, ter(temMALFORMED)); + json::Value jv = token::acceptBuyOffer(buyer, noXferOfferIndex); + jv[sfNFTokenBrokerFee.jsonName] = STAmount(500000).getJson(JsonOptions::KNone); + env(jv, Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); } // A sell offer may not contain a sfNFTokenBrokerFee field. { - Json::Value jv = token::acceptSellOffer(buyer, noXferOfferIndex); - jv[sfNFTokenBrokerFee.jsonName] = STAmount(500000).getJson(JsonOptions::none); - env(jv, ter(temMALFORMED)); + json::Value jv = token::acceptSellOffer(buyer, noXferOfferIndex); + jv[sfNFTokenBrokerFee.jsonName] = STAmount(500000).getJson(JsonOptions::KNone); + env(jv, Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); } // A brokered offer may not contain a negative or zero brokerFee. env(token::brokerOffers(buyer, noXferOfferIndex, xrpOnlyOfferIndex), - token::brokerFee(gwAUD(0)), - ter(temMALFORMED)); + token::BrokerFee(gwAUD(0)), + Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1084,20 +1084,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // preclaim // The buy offer must be non-zero. - env(token::acceptBuyOffer(buyer, beast::zero), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptBuyOffer(buyer, beast::kZERO), Ter(tecOBJECT_NOT_FOUND)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The buy offer must be present in the ledger. uint256 const missingOfferIndex = keylet::nftoffer(alice, 1).key; - env(token::acceptBuyOffer(buyer, missingOfferIndex), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptBuyOffer(buyer, missingOfferIndex), Ter(tecOBJECT_NOT_FOUND)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The buy offer must not have expired. - // NOTE: this is only a preclaim check with the - // fixSecurity3_1_3 amendment disabled. - env(token::acceptBuyOffer(alice, buyerExpOfferIndex), ter(tecEXPIRED)); + // NOTE: this is only a preclaim check with the fixSecurity3_1_3 amendment disabled. + env(token::acceptBuyOffer(alice, buyerExpOfferIndex), Ter(tecEXPIRED)); env.close(); if (features[fixSecurity3_1_3]) { @@ -1106,19 +1105,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The sell offer must be non-zero. - env(token::acceptSellOffer(buyer, beast::zero), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptSellOffer(buyer, beast::kZERO), Ter(tecOBJECT_NOT_FOUND)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The sell offer must be present in the ledger. - env(token::acceptSellOffer(buyer, missingOfferIndex), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptSellOffer(buyer, missingOfferIndex), Ter(tecOBJECT_NOT_FOUND)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The sell offer must not have expired. - // NOTE: this is only a preclaim check with the - // fixSecurity3_1_3 amendment disabled. - env(token::acceptSellOffer(buyer, aliceExpOfferIndex), ter(tecEXPIRED)); + // NOTE: this is only a preclaim check with the fixSecurity3_1_3 amendment disabled. + env(token::acceptSellOffer(buyer, aliceExpOfferIndex), Ter(tecEXPIRED)); + env.close(); // Alice's count is decremented by one when the expired offer is // removed. @@ -1152,27 +1151,27 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftAlice0ID, gwAUD(29)), token::owner(alice)); + env(token::createOffer(buyer, nftAlice0ID, gwAUD(29)), token::Owner(alice)); env.close(); buyerCount++; BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // gw attempts to broker offers that are not for the same token. env(token::brokerOffers(gw, buyerOfferIndex, xrpOnlyOfferIndex), - ter(tecNFTOKEN_BUY_SELL_MISMATCH)); + Ter(tecNFTOKEN_BUY_SELL_MISMATCH)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // gw attempts to broker offers that are not for the same currency. env(token::brokerOffers(gw, buyerOfferIndex, plainOfferIndex), - ter(tecNFTOKEN_BUY_SELL_MISMATCH)); + Ter(tecNFTOKEN_BUY_SELL_MISMATCH)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // In a brokered offer, the buyer must offer greater than or // equal to the selling price. env(token::brokerOffers(gw, buyerOfferIndex, audOfferIndex), - ter(tecINSUFFICIENT_PAYMENT)); + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1185,7 +1184,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftAlice0ID, gwAUD(31)), token::owner(alice)); + env(token::createOffer(buyer, nftAlice0ID, gwAUD(31)), token::Owner(alice)); env.close(); buyerCount++; BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1193,23 +1192,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Broker sets their fee in a denomination other than the one // used by the offers env(token::brokerOffers(gw, buyerOfferIndex, audOfferIndex), - token::brokerFee(XRP(40)), - ter(tecNFTOKEN_BUY_SELL_MISMATCH)); + token::BrokerFee(XRP(40)), + Ter(tecNFTOKEN_BUY_SELL_MISMATCH)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Broker fee way too big. env(token::brokerOffers(gw, buyerOfferIndex, audOfferIndex), - token::brokerFee(gwAUD(31)), - ter(tecINSUFFICIENT_PAYMENT)); + token::BrokerFee(gwAUD(31)), + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Broker fee is smaller, but still too big once the offer // seller's minimum is taken into account. env(token::brokerOffers(gw, buyerOfferIndex, audOfferIndex), - token::brokerFee(gwAUD(1.5)), - ter(tecINSUFFICIENT_PAYMENT)); + token::BrokerFee(gwAUD(1.5)), + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1224,19 +1223,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftAlice0ID, gwAUD(30)), token::owner(alice)); + env(token::createOffer(buyer, nftAlice0ID, gwAUD(30)), token::Owner(alice)); env.close(); buyerCount++; BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Don't accept a buy offer if the sell flag is set. - env(token::acceptBuyOffer(buyer, plainOfferIndex), ter(tecNFTOKEN_OFFER_TYPE_MISMATCH)); + env(token::acceptBuyOffer(buyer, plainOfferIndex), Ter(tecNFTOKEN_OFFER_TYPE_MISMATCH)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == aliceCount); // An account can't accept its own offer. env(token::acceptBuyOffer(buyer, buyerOfferIndex), - ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); + Ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1244,14 +1243,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(pay(buyer, gw, gwAUD(30))); env.close(); BEAST_EXPECT(env.balance(buyer, gwAUD) == gwAUD(0)); - env(token::acceptBuyOffer(alice, buyerOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptBuyOffer(alice, buyerOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // alice gives her NFT to gw, so alice no longer owns nftAlice0. { uint256 const offerIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAlice0ID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftAlice0ID, XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(gw, offerIndex)); env.close(); @@ -1261,7 +1260,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // alice can't accept a buy offer for an NFT she no longer owns. - env(token::acceptBuyOffer(alice, buyerOfferIndex), ter(tecNO_PERMISSION)); + env(token::acceptBuyOffer(alice, buyerOfferIndex), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1276,26 +1275,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftXrpOnlyID, XRP(30)), token::owner(alice)); + env(token::createOffer(buyer, nftXrpOnlyID, XRP(30)), token::Owner(alice)); env.close(); buyerCount++; BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // Don't accept a sell offer without the sell flag set. env(token::acceptSellOffer(alice, buyerOfferIndex), - ter(tecNFTOKEN_OFFER_TYPE_MISMATCH)); + Ter(tecNFTOKEN_OFFER_TYPE_MISMATCH)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == aliceCount); // An account can't accept its own offer. env(token::acceptSellOffer(alice, plainOfferIndex), - ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); + Ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // The seller must currently be in possession of the token they // are selling. alice gave nftAlice0ID to gw. - env(token::acceptSellOffer(buyer, plainOfferIndex), ter(tecNO_PERMISSION)); + env(token::acceptSellOffer(buyer, plainOfferIndex), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); @@ -1304,7 +1303,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // insufficient funds. { uint256 const offerIndex = keylet::nftoffer(gw, env.seq(gw)).key; - env(token::createOffer(gw, nftAlice0ID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(gw, nftAlice0ID, XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(alice, offerIndex)); env.close(); @@ -1313,7 +1312,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(pay(buyer, gw, gwAUD(30))); env.close(); BEAST_EXPECT(env.balance(buyer, gwAUD) == gwAUD(0)); - env(token::acceptSellOffer(buyer, audOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptSellOffer(buyer, audOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); } @@ -1321,7 +1320,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite //---------------------------------------------------------------------- // doApply // - // As far as I can see none of the failure modes are accessible as + // As far as I can see kNONE of the failure modes are accessible as // long as the preflight and preclaim conditions are met. } @@ -1353,11 +1352,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // 3. transfers that nft to buyer. auto nftToBuyer = [&env, &alice, &minter1, &buyer](std::uint32_t flags) { uint256 const nftID{token::getNextID(env, alice, 0u, flags)}; - env(token::mint(minter1, 0u), token::issuer(alice), txflags(flags)); + env(token::mint(minter1, 0u), token::Issuer(alice), Txflags(flags)); env.close(); uint256 const offerIndex = keylet::nftoffer(minter1, env.seq(minter1)).key; - env(token::createOffer(minter1, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter1, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(buyer, offerIndex)); @@ -1369,26 +1368,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // An NFT without flagBurnable can only be burned by its owner. { uint256 const noBurnID = nftToBuyer(0); - env(token::burn(alice, noBurnID), token::owner(buyer), ter(tecNO_PERMISSION)); + env(token::burn(alice, noBurnID), token::Owner(buyer), Ter(tecNO_PERMISSION)); env.close(); - env(token::burn(minter1, noBurnID), token::owner(buyer), ter(tecNO_PERMISSION)); + env(token::burn(minter1, noBurnID), token::Owner(buyer), Ter(tecNO_PERMISSION)); env.close(); - env(token::burn(minter2, noBurnID), token::owner(buyer), ter(tecNO_PERMISSION)); + env(token::burn(minter2, noBurnID), token::Owner(buyer), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::burn(buyer, noBurnID), token::owner(buyer)); + env(token::burn(buyer, noBurnID), token::Owner(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); } // An NFT with flagBurnable can be burned by the issuer. { uint256 const burnableID = nftToBuyer(tfBurnable); - env(token::burn(minter2, burnableID), token::owner(buyer), ter(tecNO_PERMISSION)); + env(token::burn(minter2, burnableID), token::Owner(buyer), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::burn(alice, burnableID), token::owner(buyer)); + env(token::burn(alice, burnableID), token::Owner(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); } @@ -1404,7 +1403,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const burnableID = nftToBuyer(tfBurnable); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::burn(buyer, burnableID), token::owner(buyer)); + env(token::burn(buyer, burnableID), token::Owner(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); } @@ -1419,12 +1418,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter1 is no longer alice's minter, so no longer has // permission to burn alice's nfts. - env(token::burn(minter1, burnableID), token::owner(buyer), ter(tecNO_PERMISSION)); + env(token::burn(minter1, burnableID), token::Owner(buyer), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // minter2, however, can burn alice's nfts. - env(token::burn(minter2, burnableID), token::owner(buyer)); + env(token::burn(minter2, burnableID), token::Owner(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); } @@ -1455,18 +1454,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Don't set flagOnlyXRP and offers can be made with IOUs. { uint256 const nftIOUsOkayID{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); uint256 const aliceOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftIOUsOkayID, gwAUD(50)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftIOUsOkayID, gwAUD(50)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 3); BEAST_EXPECT(ownerCount(env, buyer) == 1); uint256 const buyerOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftIOUsOkayID, gwAUD(50)), token::owner(alice)); + env(token::createOffer(buyer, nftIOUsOkayID, gwAUD(50)), token::Owner(alice)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 2); @@ -1487,31 +1486,31 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const nftOnlyXrpID{ token::getNextID(env, alice, 0u, tfOnlyXRP | tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfOnlyXRP | tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfOnlyXRP | tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); env(token::createOffer(alice, nftOnlyXrpID, gwAUD(50)), - txflags(tfSellNFToken), - ter(temBAD_AMOUNT)); + Txflags(tfSellNFToken), + Ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); BEAST_EXPECT(ownerCount(env, buyer) == 1); env(token::createOffer(buyer, nftOnlyXrpID, gwAUD(50)), - token::owner(alice), - ter(temBAD_AMOUNT)); + token::Owner(alice), + Ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // However offers for XRP are okay. BEAST_EXPECT(ownerCount(env, alice) == 2); - env(token::createOffer(alice, nftOnlyXrpID, XRP(60)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftOnlyXrpID, XRP(60)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 3); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::createOffer(buyer, nftOnlyXrpID, XRP(60)), token::owner(alice)); + env(token::createOffer(buyer, nftOnlyXrpID, XRP(60)), token::Owner(alice)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 2); } @@ -1564,12 +1563,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const nftNoAutoTrustID{ token::getNextID(env, alice, 0u, tfTransferable, xferFee)}; - env(token::mint(alice, 0u), token::xferFee(xferFee), txflags(tfTransferable)); + env(token::mint(alice, 0u), token::XferFee(xferFee), Txflags(tfTransferable)); env.close(); // becky buys the nft for 1 drop. uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::owner(alice)); + env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::Owner(alice)); env.close(); env(token::acceptBuyOffer(alice, beckyBuyOfferIndex)); env.close(); @@ -1578,15 +1577,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite TER const createOfferTER = (xferFee != 0u) ? TER(tecNO_LINE) : TER(tesSUCCESS); uint256 const beckyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), - txflags(tfSellNFToken), - ter(createOfferTER)); + Txflags(tfSellNFToken), + Ter(createOfferTER)); env.close(); // cheri offers to buy the nft for CAD. uint256 const cheriOfferIndex = keylet::nftoffer(cheri, env.seq(cheri)).key; env(token::createOffer(cheri, nftNoAutoTrustID, gwCAD(100)), - token::owner(becky), - ter(createOfferTER)); + token::Owner(becky), + Ter(createOfferTER)); env.close(); // To keep things tidy, cancel the offers. @@ -1610,9 +1609,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite : static_cast(tesSUCCESS); env(token::mint(alice, 0u), - token::xferFee(transferFee), - txflags(tfTransferable | tfTrustLine), - ter(mintTER)); + token::XferFee(transferFee), + Txflags(tfTransferable | tfTrustLine), + Ter(mintTER)); env.close(); // If fixRemoveNFTokenAutoTrustLine is active the rest @@ -1622,14 +1621,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } // becky buys the nft for 1 drop. uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::owner(alice)); + env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::Owner(alice)); env.close(); env(token::acceptBuyOffer(alice, beckyBuyOfferIndex)); env.close(); // becky sells the nft for AUD. uint256 const beckySellOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, gwAUD(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftAutoTrustID, gwAUD(100)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(cheri, beckySellOfferIndex)); env.close(); @@ -1639,7 +1638,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky buys the nft back for CAD. uint256 const beckyBuyBackOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, gwCAD(50)), token::owner(cheri)); + env(token::createOffer(becky, nftAutoTrustID, gwCAD(50)), token::Owner(cheri)); env.close(); env(token::acceptBuyOffer(cheri, beckyBuyBackOfferIndex)); env.close(); @@ -1654,13 +1653,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::uint16_t const transferFee = 5000; // 5% uint256 const nftNoAutoTrustID{ token::getNextID(env, alice, 0u, tfTransferable, transferFee)}; - env(token::mint(alice, 0u), token::xferFee(transferFee), txflags(tfTransferable)); + env(token::mint(alice, 0u), token::XferFee(transferFee), Txflags(tfTransferable)); env.close(); // alice sells the nft using AUD. uint256 const aliceSellOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftNoAutoTrustID, gwAUD(200)), - txflags(tfSellNFToken)); + Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(cheri, aliceSellOfferIndex)); env.close(); @@ -1672,12 +1671,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // cheri can't sell the NFT for EUR, but can for CAD. env(token::createOffer(cheri, nftNoAutoTrustID, gwEUR(50)), - txflags(tfSellNFToken), - ter(tecNO_LINE)); + Txflags(tfSellNFToken), + Ter(tecNO_LINE)); env.close(); uint256 const cheriSellOfferIndex = keylet::nftoffer(cheri, env.seq(cheri)).key; env(token::createOffer(cheri, nftNoAutoTrustID, gwCAD(100)), - txflags(tfSellNFToken)); + Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(becky, cheriSellOfferIndex)); env.close(); @@ -1711,19 +1710,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const nftAliceNoTransferID{token::getNextID(env, alice, 0u)}; - env(token::mint(alice, 0u), token::xferFee(0)); + env(token::mint(alice, 0u), token::XferFee(0)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // becky tries to offer to buy alice's nft. BEAST_EXPECT(ownerCount(env, becky) == 0); env(token::createOffer(becky, nftAliceNoTransferID, XRP(20)), - token::owner(alice), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + token::Owner(alice), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); // alice offers to sell the nft and becky accepts the offer. uint256 const aliceSellOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAliceNoTransferID, XRP(20)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftAliceNoTransferID, XRP(20)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(becky, aliceSellOfferIndex)); env.close(); @@ -1732,8 +1731,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky tries to offer the nft for sale. env(token::createOffer(becky, nftAliceNoTransferID, XRP(21)), - txflags(tfSellNFToken), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + Txflags(tfSellNFToken), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, becky) == 1); @@ -1741,9 +1740,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky tries to offer the nft for sale with alice as the // destination. That also doesn't work. env(token::createOffer(becky, nftAliceNoTransferID, XRP(21)), - txflags(tfSellNFToken), - token::destination(alice), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + Txflags(tfSellNFToken), + token::Destination(alice), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, becky) == 1); @@ -1751,7 +1750,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice offers to buy the nft back from becky. becky accepts // the offer. uint256 const aliceBuyOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAliceNoTransferID, XRP(22)), token::owner(becky)); + env(token::createOffer(alice, nftAliceNoTransferID, XRP(22)), token::Owner(becky)); env.close(); env(token::acceptBuyOffer(becky, aliceBuyOfferIndex)); env.close(); @@ -1771,15 +1770,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 0); uint256 const nftMinterNoTransferID{token::getNextID(env, alice, 0u)}; - env(token::mint(minter), token::issuer(alice)); + env(token::mint(minter), token::Issuer(alice)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 1); // becky tries to offer to buy minter's nft. BEAST_EXPECT(ownerCount(env, becky) == 0); env(token::createOffer(becky, nftMinterNoTransferID, XRP(20)), - token::owner(minter), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + token::Owner(minter), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, becky) == 0); @@ -1790,8 +1789,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter tries to offer their nft for sale. BEAST_EXPECT(ownerCount(env, minter) == 1); env(token::createOffer(minter, nftMinterNoTransferID, XRP(21)), - txflags(tfSellNFToken), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + Txflags(tfSellNFToken), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -1807,7 +1806,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter successfully offers their nft for sale. BEAST_EXPECT(ownerCount(env, minter) == 1); uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftMinterNoTransferID, XRP(22)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftMinterNoTransferID, XRP(22)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -1826,23 +1825,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky attempts to sell the nft. env(token::createOffer(becky, nftMinterNoTransferID, XRP(23)), - txflags(tfSellNFToken), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + Txflags(tfSellNFToken), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); // Since minter is not, at the moment, alice's official minter // they cannot create an offer to buy the nft they minted. BEAST_EXPECT(ownerCount(env, minter) == 0); env(token::createOffer(minter, nftMinterNoTransferID, XRP(24)), - token::owner(becky), - ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); + token::Owner(becky), + Ter(tefNFTOKEN_IS_NOT_TRANSFERABLE)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 0); // alice can create an offer to buy the nft. BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const aliceBuyOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftMinterNoTransferID, XRP(25)), token::owner(becky)); + env(token::createOffer(alice, nftMinterNoTransferID, XRP(25)), token::Owner(becky)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); @@ -1857,7 +1856,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Now minter can create an offer to buy the nft. BEAST_EXPECT(ownerCount(env, minter) == 0); uint256 const minterBuyOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftMinterNoTransferID, XRP(26)), token::owner(becky)); + env(token::createOffer(minter, nftMinterNoTransferID, XRP(26)), token::Owner(becky)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -1877,7 +1876,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter burns their nft and alice cancels her offer so the // next tests can start with a clean slate. - env(token::burn(minter, nftMinterNoTransferID), ter(tesSUCCESS)); + env(token::burn(minter, nftMinterNoTransferID), Ter(tesSUCCESS)); env.close(); env(token::cancelOffer(alice, {aliceBuyOfferIndex})); env.close(); @@ -1890,18 +1889,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const nftAliceID{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 1); // Both alice and becky can make offers for alice's nft. uint256 const aliceSellOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftAliceID, XRP(20)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftAliceID, XRP(20)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAliceID, XRP(21)), token::owner(alice)); + env(token::createOffer(becky, nftAliceID, XRP(21)), token::Owner(alice)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -1913,7 +1912,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky offers to sell the nft. uint256 const beckySellOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAliceID, XRP(22)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftAliceID, XRP(22)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, becky) == 3); @@ -1928,7 +1927,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter offers to sell the nft. uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftAliceID, XRP(23)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftAliceID, XRP(23)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, becky) == 1); @@ -2005,12 +2004,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 1); uint256 const nftID = token::getNextID(env, alice, 0u, tfTransferable); - env(token::mint(alice), txflags(tfTransferable)); + env(token::mint(alice), Txflags(tfTransferable)); env.close(); // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); + env(token::createOffer(becky, nftID, gwXAU(10)), token::Owner(alice)); env.close(); BEAST_EXPECT(env.balance(alice, gwXAU) == gwXAU(1000)); BEAST_EXPECT(env.balance(becky, gwXAU) == gwXAU(1000)); @@ -2022,7 +2021,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky sells nft to carol. alice's balance should not change. uint256 const beckySellOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(10)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftID, gwXAU(10)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(carol, beckySellOfferIndex)); env.close(); @@ -2032,7 +2031,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter buys nft from carol. alice's balance should not change. uint256 const minterBuyOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(10)), token::owner(carol)); + env(token::createOffer(minter, nftID, gwXAU(10)), token::Owner(carol)); env.close(); env(token::acceptBuyOffer(carol, minterBuyOfferIndex)); env.close(); @@ -2044,7 +2043,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter sells the nft to alice. gwXAU balances should finish // where they started. uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(10)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(10)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(alice, minterSellOfferIndex)); env.close(); @@ -2066,12 +2065,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // An nft with a transfer fee of 1 basis point. uint256 const nftID = token::getNextID(env, alice, 0u, tfTransferable, 1); - env(token::mint(alice), txflags(tfTransferable), token::xferFee(1)); + env(token::mint(alice), Txflags(tfTransferable), token::XferFee(1)); env.close(); // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); + env(token::createOffer(becky, nftID, gwXAU(10)), token::Owner(alice)); env.close(); BEAST_EXPECT(env.balance(alice, gwXAU) == gwXAU(1000)); BEAST_EXPECT(env.balance(becky, gwXAU) == gwXAU(1000)); @@ -2083,7 +2082,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky sells nft to carol. alice's balance goes up. uint256 const beckySellOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(10)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftID, gwXAU(10)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(carol, beckySellOfferIndex)); env.close(); @@ -2094,7 +2093,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter buys nft from carol. alice's balance goes up. uint256 const minterBuyOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(10)), token::owner(carol)); + env(token::createOffer(minter, nftID, gwXAU(10)), token::Owner(carol)); env.close(); env(token::acceptBuyOffer(carol, minterBuyOfferIndex)); env.close(); @@ -2107,7 +2106,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter sells the nft to alice. Because alice is part of the // transaction no transfer fee is removed. uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(10)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(10)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(alice, minterSellOfferIndex)); env.close(); @@ -2140,19 +2139,20 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // A transfer fee greater than 50% is not allowed. env(token::mint(alice), - txflags(tfTransferable), - token::xferFee(maxTransferFee + 1), - ter(temBAD_NFTOKEN_TRANSFER_FEE)); + Txflags(tfTransferable), + token::XferFee(kMAX_TRANSFER_FEE + 1), + Ter(temBAD_NFTOKEN_TRANSFER_FEE)); env.close(); // Make an nft with a transfer fee of 50%. - uint256 const nftID = token::getNextID(env, alice, 0u, tfTransferable, maxTransferFee); - env(token::mint(alice), txflags(tfTransferable), token::xferFee(maxTransferFee)); + uint256 const nftID = + token::getNextID(env, alice, 0u, tfTransferable, kMAX_TRANSFER_FEE); + env(token::mint(alice), Txflags(tfTransferable), token::XferFee(kMAX_TRANSFER_FEE)); env.close(); // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); + env(token::createOffer(becky, nftID, gwXAU(10)), token::Owner(alice)); env.close(); BEAST_EXPECT(env.balance(alice, gwXAU) == gwXAU(1000)); BEAST_EXPECT(env.balance(becky, gwXAU) == gwXAU(1000)); @@ -2164,7 +2164,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky sells nft to minter. alice's balance goes up. uint256 const beckySellOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, gwXAU(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftID, gwXAU(100)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(minter, beckySellOfferIndex)); env.close(); @@ -2175,7 +2175,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // carol buys nft from minter. alice's balance goes up. uint256 const carolBuyOfferIndex = keylet::nftoffer(carol, env.seq(carol)).key; - env(token::createOffer(carol, nftID, gwXAU(10)), token::owner(minter)); + env(token::createOffer(carol, nftID, gwXAU(10)), token::Owner(minter)); env.close(); env(token::acceptBuyOffer(minter, carolBuyOfferIndex)); env.close(); @@ -2188,7 +2188,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // carol sells the nft to alice. Because alice is part of the // transaction no transfer fee is removed. uint256 const carolSellOfferIndex = keylet::nftoffer(carol, env.seq(carol)).key; - env(token::createOffer(carol, nftID, gwXAU(10)), txflags(tfSellNFToken)); + env(token::createOffer(carol, nftID, gwXAU(10)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(alice, carolSellOfferIndex)); env.close(); @@ -2218,9 +2218,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // See the impact of rounding when the nft is sold for small amounts // of drops. - for (auto NumberSwitchOver : {true}) + for (auto numberSwitchOver : {true}) { - if (NumberSwitchOver) + if (numberSwitchOver) { env.enableFeature(fixUniversalNumber); } @@ -2231,7 +2231,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // An nft with a transfer fee of 1 basis point. uint256 const nftID = token::getNextID(env, alice, 0u, tfTransferable, 1); - env(token::mint(alice), txflags(tfTransferable), token::xferFee(1)); + env(token::mint(alice), Txflags(tfTransferable), token::XferFee(1)); env.close(); // minter buys the nft for XRP(1). Since the transfer involves @@ -2239,7 +2239,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite STAmount aliceBalance = env.balance(alice); STAmount minterBalance = env.balance(minter); uint256 const minterBuyOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(1)), token::owner(alice)); + env(token::createOffer(minter, nftID, XRP(1)), token::Owner(alice)); env.close(); env(token::acceptBuyOffer(alice, minterBuyOfferIndex)); env.close(); @@ -2250,10 +2250,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter sells to carol. The payment is just small enough that // alice does not get any transfer fee. - auto pmt = NumberSwitchOver ? drops(50000) : drops(99999); + auto pmt = numberSwitchOver ? drops(50000) : drops(99999); STAmount carolBalance = env.balance(carol); uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, pmt), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, pmt), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(carol, minterSellOfferIndex)); env.close(); @@ -2267,8 +2267,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // transfer that enables a transfer fee of 1 basis point. STAmount beckyBalance = env.balance(becky); uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - pmt = NumberSwitchOver ? drops(50001) : drops(100000); - env(token::createOffer(becky, nftID, pmt), token::owner(carol)); + pmt = numberSwitchOver ? drops(50001) : drops(100000); + env(token::createOffer(becky, nftID, pmt), token::Owner(carol)); env.close(); env(token::acceptBuyOffer(carol, beckyBuyOfferIndex)); env.close(); @@ -2287,7 +2287,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // An nft with a transfer fee of 1 basis point. uint256 const nftID = token::getNextID(env, alice, 0u, tfTransferable, 1); - env(token::mint(alice), txflags(tfTransferable), token::xferFee(1)); + env(token::mint(alice), Txflags(tfTransferable), token::XferFee(1)); env.close(); // Due to the floating point nature of IOUs we need to @@ -2298,21 +2298,21 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(pay(becky, gw, env.balance(becky, gwXAU))); env.close(); - STAmount const startXAUBalance(gwXAU, STAmount::cMinValue, STAmount::cMinOffset + 5); + STAmount const startXAUBalance(gwXAU, STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET + 5); env(pay(gw, alice, startXAUBalance)); env(pay(gw, minter, startXAUBalance)); env(pay(gw, becky, startXAUBalance)); env.close(); // Here is the smallest expressible gwXAU amount. - STAmount const tinyXAU(gwXAU, STAmount::cMinValue, STAmount::cMinOffset); + STAmount const tinyXAU(gwXAU, STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET); // minter buys the nft for tinyXAU. Since the transfer involves // alice there should be no transfer fee. STAmount aliceBalance = env.balance(alice, gwXAU); STAmount minterBalance = env.balance(minter, gwXAU); uint256 const minterBuyOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, tinyXAU), token::owner(alice)); + env(token::createOffer(minter, nftID, tinyXAU), token::Owner(alice)); env.close(); env(token::acceptBuyOffer(alice, minterBuyOfferIndex)); env.close(); @@ -2324,7 +2324,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter sells to carol. STAmount carolBalance = env.balance(carol, gwXAU); uint256 const minterSellOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, tinyXAU), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, tinyXAU), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(carol, minterSellOfferIndex)); env.close(); @@ -2338,11 +2338,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // carol sells to becky. This is the smallest gwXAU amount // to pay for a transfer that enables a transfer fee of 1. - STAmount const cheapNFT(gwXAU, STAmount::cMinValue, STAmount::cMinOffset + 5); + STAmount const cheapNFT(gwXAU, STAmount::kMIN_VALUE, STAmount::kMIN_OFFSET + 5); STAmount beckyBalance = env.balance(becky, gwXAU); uint256 const beckyBuyOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftID, cheapNFT), token::owner(carol)); + env(token::createOffer(becky, nftID, cheapNFT), token::Owner(carol)); env.close(); env(token::acceptBuyOffer(carol, beckyBuyOfferIndex)); env.close(); @@ -2393,7 +2393,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Do some touch testing to show that the taxon is recoverable no // matter what else changes around it in the nft ID. { - std::uint32_t const taxon = rand_int(); + std::uint32_t const taxon = randInt(); for (int i = 0; i < 10; ++i) { // lambda to produce a useful message on error. @@ -2416,18 +2416,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env, alice, taxon, - rand_int(), - rand_int(), - rand_int()); + randInt(), + randInt(), + randInt()); check(taxon, nftAliceID); uint256 const nftBeckyID = token::getID( env, becky, taxon, - rand_int(), - rand_int(), - rand_int()); + randInt(), + randInt(), + randInt()); check(taxon, nftBeckyID); } } @@ -2459,13 +2459,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::string ret; // About 20% of the returned strings should be empty - if (rand_int(4) == 0) + if (randInt(4) == 0) return ret; - std::size_t const strLen = rand_int(256); + std::size_t const strLen = randInt(256); ret.reserve(strLen); for (std::size_t i = 0; i < strLen; ++i) - ret.push_back(rand_byte()); + ret.push_back(randByte()); return ret; }; @@ -2476,7 +2476,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::string uri; std::uint32_t taxon; - Entry(std::string uri_, std::uint32_t taxon_) : uri(std::move(uri_)), taxon(taxon_) + Entry(std::string uri, std::uint32_t taxon) : uri(std::move(uri)), taxon(taxon) { } }; @@ -2484,7 +2484,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::vector entries; entries.reserve(100); for (std::size_t i = 0; i < 100; ++i) - entries.emplace_back(randURI(), rand_int()); + entries.emplace_back(randURI(), randInt()); // alice creates nfts using entries. for (Entry const& entry : entries) @@ -2495,41 +2495,41 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } else { - env(token::mint(alice, entry.taxon), token::uri(entry.uri)); + env(token::mint(alice, entry.taxon), token::Uri(entry.uri)); } env.close(); } // Recover alice's nfts from the ledger. - Json::Value aliceNFTs = [&env, &alice]() { - Json::Value params; + json::Value aliceNFTs = [&env, &alice]() { + json::Value params; params[jss::account] = alice.human(); params[jss::type] = "state"; return env.rpc("json", "account_nfts", to_string(params)); }(); // Verify that the returned NFTs match what we sent. - Json::Value& nfts = aliceNFTs[jss::result][jss::account_nfts]; + json::Value& nfts = aliceNFTs[jss::result][jss::account_nfts]; if (!BEAST_EXPECT(nfts.size() == entries.size())) return; // Sort the returned NFTs by nft_serial so the are in the same order // as entries. - std::vector sortedNFTs; + std::vector sortedNFTs; sortedNFTs.reserve(nfts.size()); for (std::size_t i = 0; i < nfts.size(); ++i) sortedNFTs.push_back(nfts[i]); std::ranges::sort( sortedNFTs, - [](Json::Value const& lhs, Json::Value const& rhs) { + [](json::Value const& lhs, json::Value const& rhs) { return lhs[jss::nft_serial] < rhs[jss::nft_serial]; }); for (std::size_t i = 0; i < entries.size(); ++i) { Entry const& entry = entries[i]; - Json::Value const& ret = sortedNFTs[i]; + json::Value const& ret = sortedNFTs[i]; BEAST_EXPECT(entry.taxon == ret[sfNFTokenTaxon.jsonName]); if (entry.uri.empty()) { @@ -2565,7 +2565,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftokenID = token::getNextID(env, issuer, 0, tfTransferable); - env(token::mint(minter, 0), token::issuer(issuer), txflags(tfTransferable)); + env(token::mint(minter, 0), token::Issuer(issuer), Txflags(tfTransferable)); env.close(); // Test how adding a Destination field to an offer affects permissions @@ -2573,23 +2573,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerMinterToIssuer = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(issuer), - txflags(tfSellNFToken)); + token::Destination(issuer), + Txflags(tfSellNFToken)); uint256 const offerMinterToBuyer = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken)); + token::Destination(buyer), + Txflags(tfSellNFToken)); uint256 const offerIssuerToMinter = keylet::nftoffer(issuer, env.seq(issuer)).key; env(token::createOffer(issuer, nftokenID, drops(1)), - token::owner(minter), - token::destination(minter)); + token::Owner(minter), + token::Destination(minter)); uint256 const offerIssuerToBuyer = keylet::nftoffer(issuer, env.seq(issuer)).key; env(token::createOffer(issuer, nftokenID, drops(1)), - token::owner(minter), - token::destination(buyer)); + token::Owner(minter), + token::Destination(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 2); @@ -2603,10 +2603,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Note that issuer does not have any special permissions regarding // offer cancellation. issuer cannot cancel an offer for an // NFToken they issued. - env(token::cancelOffer(issuer, {offerMinterToBuyer}), ter(tecNO_PERMISSION)); - env(token::cancelOffer(buyer, {offerMinterToIssuer}), ter(tecNO_PERMISSION)); - env(token::cancelOffer(buyer, {offerIssuerToMinter}), ter(tecNO_PERMISSION)); - env(token::cancelOffer(minter, {offerIssuerToBuyer}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(issuer, {offerMinterToBuyer}), Ter(tecNO_PERMISSION)); + env(token::cancelOffer(buyer, {offerMinterToIssuer}), Ter(tecNO_PERMISSION)); + env(token::cancelOffer(buyer, {offerIssuerToMinter}), Ter(tecNO_PERMISSION)); + env(token::cancelOffer(minter, {offerIssuerToBuyer}), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 2); BEAST_EXPECT(ownerCount(env, minter) == 3); @@ -2629,8 +2629,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerMinterSellsToBuyer = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken)); + token::Destination(buyer), + Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -2638,7 +2638,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // issuer cannot accept a sell offer where they are not the // destination. - env(token::acceptSellOffer(issuer, offerMinterSellsToBuyer), ter(tecNO_PERMISSION)); + env(token::acceptSellOffer(issuer, offerMinterSellsToBuyer), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -2657,8 +2657,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerMinterBuysFromBuyer = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::owner(buyer), - token::destination(buyer)); + token::Owner(buyer), + token::Destination(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -2666,7 +2666,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // issuer cannot accept a buy offer where they are the // destination. - env(token::acceptBuyOffer(issuer, offerMinterBuysFromBuyer), ter(tecNO_PERMISSION)); + env(token::acceptBuyOffer(issuer, offerMinterBuysFromBuyer), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -2684,14 +2684,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // simply accept the offer. uint256 const offerBuyerBuysFromMinter = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID, drops(1)), - token::owner(minter), - token::destination(broker)); + token::Owner(minter), + token::Destination(broker)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 1); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::acceptBuyOffer(minter, offerBuyerBuysFromMinter), ter(tecNO_PERMISSION)); + env(token::acceptBuyOffer(minter, offerBuyerBuysFromMinter), Ter(tecNO_PERMISSION)); env.close(); // Clean up the unused offer. @@ -2707,11 +2707,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerMinterToBroker = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(broker), - txflags(tfSellNFToken)); + token::Destination(broker), + Txflags(tfSellNFToken)); uint256 const offerBuyerToMinter = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftokenID, drops(1)), token::owner(minter)); + env(token::createOffer(buyer, nftokenID, drops(1)), token::Owner(minter)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); @@ -2722,7 +2722,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // issuer cannot broker the offers, because they are not the // Destination. env(token::brokerOffers(issuer, offerBuyerToMinter, offerMinterToBroker), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -2744,14 +2744,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerBuyerToMinter = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID, drops(1)), - token::destination(minter), - txflags(tfSellNFToken)); + token::Destination(minter), + Txflags(tfSellNFToken)); uint256 const offerMinterToBuyer = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftokenID, drops(1)), token::owner(buyer)); + env(token::createOffer(minter, nftokenID, drops(1)), token::Owner(buyer)); uint256 const offerIssuerToBuyer = keylet::nftoffer(issuer, env.seq(issuer)).key; - env(token::createOffer(issuer, nftokenID, drops(1)), token::owner(buyer)); + env(token::createOffer(issuer, nftokenID, drops(1)), token::Owner(buyer)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); @@ -2762,7 +2762,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Cannot broker offers when the sell destination is not the // buyer. env(token::brokerOffers(broker, offerIssuerToBuyer, offerBuyerToMinter), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); @@ -2770,7 +2770,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 2); env(token::brokerOffers(broker, offerMinterToBuyer, offerBuyerToMinter), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); // Buyer is successful with acceptOffer. @@ -2800,19 +2800,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const offerMinterToBroker = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(broker), - txflags(tfSellNFToken)); + token::Destination(broker), + Txflags(tfSellNFToken)); uint256 const offerBuyerToBroker = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID, drops(1)), - token::owner(minter), - token::destination(broker)); + token::Owner(minter), + token::Destination(broker)); { // Cannot broker offers when the sell destination is not the // buyer or the broker. env(token::brokerOffers(issuer, offerBuyerToBroker, offerMinterToBroker), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -2848,7 +2848,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftokenID = token::getNextID(env, issuer, 0, tfTransferable); - env(token::mint(minter, 0), token::issuer(issuer), txflags(tfTransferable)); + env(token::mint(minter, 0), token::Issuer(issuer), Txflags(tfTransferable)); env.close(); // enable flag @@ -2858,9 +2858,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a sell offer from the minter to the buyer should be rejected { env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken), - ter(tecNO_PERMISSION)); + token::Destination(buyer), + Txflags(tfSellNFToken), + Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -2876,8 +2876,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offerIndex = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken)); + token::Destination(buyer), + Txflags(tfSellNFToken)); env.close(); env(token::cancelOffer(minter, {offerIndex})); @@ -2889,8 +2889,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offerIndex = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken)); + token::Destination(buyer), + Txflags(tfSellNFToken)); env.close(); env(fset(buyer, asfDisallowIncomingNFTokenOffer)); @@ -2908,8 +2908,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offerIndex = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID, drops(1)), - token::destination(buyer), - txflags(tfSellNFToken)); + token::Destination(buyer), + Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(buyer, offerIndex)); @@ -2925,16 +2925,16 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a random offer to buy the token { env(token::createOffer(alice, nftokenID, drops(1)), - token::owner(buyer), - ter(tecNO_PERMISSION)); + token::Owner(buyer), + Ter(tecNO_PERMISSION)); env.close(); } // minter offer to buy the token { env(token::createOffer(minter, nftokenID, drops(1)), - token::owner(buyer), - ter(tecNO_PERMISSION)); + token::Owner(buyer), + Ter(tecNO_PERMISSION)); env.close(); } @@ -2945,14 +2945,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(fset(buyer, asfDisallowIncomingNFTokenOffer)); // a sell offer from the minter to the buyer should be rejected env(token::mint(minter), - token::amount(drops(1)), - token::destination(buyer), - ter(tecNO_PERMISSION)); + token::Amount(drops(1)), + token::Destination(buyer), + Ter(tecNO_PERMISSION)); env.close(); // disable flag env(fclear(buyer, asfDisallowIncomingNFTokenOffer)); - env(token::mint(minter), token::amount(drops(1)), token::destination(buyer)); + env(token::mint(minter), token::Amount(drops(1)), token::Destination(buyer)); env.close(); } } @@ -2979,11 +2979,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftokenID0 = token::getNextID(env, issuer, 0, tfTransferable); - env(token::mint(minter, 0), token::issuer(issuer), txflags(tfTransferable)); + env(token::mint(minter, 0), token::Issuer(issuer), Txflags(tfTransferable)); env.close(); uint256 const nftokenID1 = token::getNextID(env, issuer, 0, tfTransferable); - env(token::mint(minter, 0), token::issuer(issuer), txflags(tfTransferable)); + env(token::mint(minter, 0), token::Issuer(issuer), Txflags(tfTransferable)); env.close(); uint8_t issuerCount = 0, minterCount = 0, buyerCount = 0; @@ -2994,24 +2994,24 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offerMinterToIssuer = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID0, drops(1)), - token::destination(issuer), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Destination(issuer), + token::Expiration(expiration), + Txflags(tfSellNFToken)); uint256 const offerMinterToAnyone = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID0, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); uint256 const offerIssuerToMinter = keylet::nftoffer(issuer, env.seq(issuer)).key; env(token::createOffer(issuer, nftokenID0, drops(1)), - token::owner(minter), - token::expiration(expiration)); + token::Owner(minter), + token::Expiration(expiration)); uint256 const offerBuyerToMinter = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, drops(1)), - token::owner(minter), - token::expiration(expiration)); + token::Owner(minter), + token::Expiration(expiration)); env.close(); issuerCount = 1; minterCount = 3; @@ -3026,8 +3026,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // // Note that these are tec responses, so these transactions will // not be retried by the ledger. - env(token::cancelOffer(issuer, {offerMinterToAnyone}), ter(tecNO_PERMISSION)); - env(token::cancelOffer(buyer, {offerIssuerToMinter}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(issuer, {offerMinterToAnyone}), Ter(tecNO_PERMISSION)); + env(token::cancelOffer(buyer, {offerIssuerToMinter}), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(lastClose(env) < expiration); BEAST_EXPECT(ownerCount(env, issuer) == issuerCount); @@ -3070,14 +3070,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offer0 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID0, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); minterCount++; uint256 const offer1 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID1, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); minterCount++; env.close(); BEAST_EXPECT(lastClose(env) < expiration); @@ -3099,7 +3099,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // No one can accept an expired sell offer. - env(token::acceptSellOffer(buyer, offer1), ter(tecEXPIRED)); + env(token::acceptSellOffer(buyer, offer1), Ter(tecEXPIRED)); // With fixSecurity3_1_3 amendment, the first accept // attempt deletes the expired offer. Without the amendment, @@ -3108,13 +3108,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // After amendment: offer was deleted by first accept attempt minterCount--; - env(token::acceptSellOffer(issuer, offer1), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptSellOffer(issuer, offer1), Ter(tecOBJECT_NOT_FOUND)); } else { // Before amendment: offer still exists, second accept also // fails - env(token::acceptSellOffer(issuer, offer1), ter(tecEXPIRED)); + env(token::acceptSellOffer(issuer, offer1), Ter(tecEXPIRED)); } env.close(); @@ -3141,8 +3141,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, XRP(0)), - txflags(tfSellNFToken), - token::destination(minter)); + Txflags(tfSellNFToken), + token::Destination(minter)); env.close(); env(token::acceptSellOffer(minter, offerSellBack)); buyerCount--; @@ -3160,14 +3160,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const offer0 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, drops(1)), - token::owner(minter), - token::expiration(expiration)); + token::Owner(minter), + token::Expiration(expiration)); buyerCount++; uint256 const offer1 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID1, drops(1)), - token::owner(minter), - token::expiration(expiration)); + token::Owner(minter), + token::Expiration(expiration)); buyerCount++; env.close(); BEAST_EXPECT(lastClose(env) < expiration); @@ -3187,7 +3187,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // An expired buy offer cannot be accepted. - env(token::acceptBuyOffer(minter, offer1), ter(tecEXPIRED)); + env(token::acceptBuyOffer(minter, offer1), Ter(tecEXPIRED)); // With fixSecurity3_1_3 amendment, the first accept // attempt deletes the expired offer. Without the amendment, @@ -3196,13 +3196,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // After amendment: offer was deleted by first accept attempt buyerCount--; - env(token::acceptBuyOffer(issuer, offer1), ter(tecOBJECT_NOT_FOUND)); + env(token::acceptBuyOffer(issuer, offer1), Ter(tecOBJECT_NOT_FOUND)); } else { // Before amendment: offer still exists, second accept also // fails - env(token::acceptBuyOffer(issuer, offer1), ter(tecEXPIRED)); + env(token::acceptBuyOffer(issuer, offer1), Ter(tecEXPIRED)); } env.close(); @@ -3229,8 +3229,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, XRP(0)), - txflags(tfSellNFToken), - token::destination(minter)); + Txflags(tfSellNFToken), + token::Destination(minter)); env.close(); env(token::acceptSellOffer(minter, offerSellBack)); env.close(); @@ -3248,22 +3248,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const sellOffer0 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID0, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); minterCount++; uint256 const sellOffer1 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID1, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); minterCount++; uint256 const buyOffer0 = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftokenID0, drops(1)), token::owner(minter)); + env(token::createOffer(buyer, nftokenID0, drops(1)), token::Owner(minter)); buyerCount++; uint256 const buyOffer1 = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftokenID1, drops(1)), token::owner(minter)); + env(token::createOffer(buyer, nftokenID1, drops(1)), token::Owner(minter)); buyerCount++; env.close(); @@ -3285,7 +3285,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); // If the sell offer is expired it cannot be brokered. - env(token::brokerOffers(issuer, buyOffer1, sellOffer1), ter(tecEXPIRED)); + env(token::brokerOffers(issuer, buyOffer1, sellOffer1), Ter(tecEXPIRED)); env.close(); if (features[fixSecurity3_1_3]) @@ -3323,8 +3323,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, XRP(0)), - txflags(tfSellNFToken), - token::destination(minter)); + Txflags(tfSellNFToken), + token::Destination(minter)); env.close(); env(token::acceptSellOffer(minter, offerSellBack)); env.close(); @@ -3341,20 +3341,20 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::uint32_t const expiration = lastClose(env) + 25; uint256 const sellOffer0 = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftokenID0, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftokenID0, drops(1)), Txflags(tfSellNFToken)); uint256 const sellOffer1 = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftokenID1, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftokenID1, drops(1)), Txflags(tfSellNFToken)); uint256 const buyOffer0 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, drops(1)), - token::expiration(expiration), - token::owner(minter)); + token::Expiration(expiration), + token::Owner(minter)); uint256 const buyOffer1 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID1, drops(1)), - token::expiration(expiration), - token::owner(minter)); + token::Expiration(expiration), + token::Owner(minter)); env.close(); BEAST_EXPECT(lastClose(env) < expiration); @@ -3373,7 +3373,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 2); BEAST_EXPECT(ownerCount(env, buyer) == 2); - env(token::brokerOffers(issuer, buyOffer1, sellOffer1), ter(tecEXPIRED)); + env(token::brokerOffers(issuer, buyOffer1, sellOffer1), Ter(tecEXPIRED)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); @@ -3404,8 +3404,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, XRP(0)), - txflags(tfSellNFToken), - token::destination(minter)); + Txflags(tfSellNFToken), + token::Destination(minter)); env.close(); env(token::acceptSellOffer(minter, offerSellBack)); env.close(); @@ -3423,23 +3423,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const sellOffer0 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID0, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); uint256 const sellOffer1 = keylet::nftoffer(minter, env.seq(minter)).key; env(token::createOffer(minter, nftokenID1, drops(1)), - token::expiration(expiration), - txflags(tfSellNFToken)); + token::Expiration(expiration), + Txflags(tfSellNFToken)); uint256 const buyOffer0 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, drops(1)), - token::expiration(expiration), - token::owner(minter)); + token::Expiration(expiration), + token::Owner(minter)); uint256 const buyOffer1 = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID1, drops(1)), - token::expiration(expiration), - token::owner(minter)); + token::Expiration(expiration), + token::Owner(minter)); env.close(); BEAST_EXPECT(lastClose(env) < expiration); @@ -3458,7 +3458,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 2); BEAST_EXPECT(ownerCount(env, buyer) == 2); - env(token::brokerOffers(issuer, buyOffer1, sellOffer1), ter(tecEXPIRED)); + env(token::brokerOffers(issuer, buyOffer1, sellOffer1), Ter(tecEXPIRED)); env.close(); // The expired offers are still in the ledger. @@ -3480,8 +3480,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftokenID0, XRP(0)), - txflags(tfSellNFToken), - token::destination(minter)); + Txflags(tfSellNFToken), + token::Destination(minter)); env.close(); env(token::acceptSellOffer(minter, offerSellBack)); env.close(); @@ -3512,20 +3512,20 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftokenID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(alice, 0), txflags(tfTransferable)); + env(token::mint(alice, 0), Txflags(tfTransferable)); env.close(); // Anyone can cancel an expired offer. uint256 const expiredOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftokenID, XRP(1000)), - txflags(tfSellNFToken), - token::expiration(lastClose(env) + 13)); + Txflags(tfSellNFToken), + token::Expiration(lastClose(env) + 13)); env.close(); // The offer has not expired yet, so becky can't cancel it now. BEAST_EXPECT(ownerCount(env, alice) == 2); - env(token::cancelOffer(becky, {expiredOfferIndex}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(becky, {expiredOfferIndex}), Ter(tecNO_PERMISSION)); env.close(); // Close a couple of ledgers and advance the time. Then becky @@ -3541,13 +3541,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const dest1OfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftokenID, XRP(1000)), - token::destination(becky), - txflags(tfSellNFToken)); + token::Destination(becky), + Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); // Minter can't cancel that offer, but becky (the destination) can. - env(token::cancelOffer(minter, {dest1OfferIndex}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(minter, {dest1OfferIndex}), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -3559,8 +3559,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const dest2OfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftokenID, XRP(1000)), - token::destination(becky), - txflags(tfSellNFToken)); + token::Destination(becky), + Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); @@ -3572,18 +3572,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Minter creates a token with alice as issuer. alice cannot cancel // minter's offer. uint256 const mintersNFTokenID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(minter, 0), token::issuer(alice), txflags(tfTransferable)); + env(token::mint(minter, 0), token::Issuer(alice), Txflags(tfTransferable)); env.close(); uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, mintersNFTokenID, XRP(1000)), txflags(tfSellNFToken)); + env(token::createOffer(minter, mintersNFTokenID, XRP(1000)), Txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 2); // Nobody other than minter should be able to cancel minter's offer. - env(token::cancelOffer(alice, {minterOfferIndex}), ter(tecNO_PERMISSION)); - env(token::cancelOffer(becky, {minterOfferIndex}), ter(tecNO_PERMISSION)); + env(token::cancelOffer(alice, {minterOfferIndex}), Ter(tecNO_PERMISSION)); + env(token::cancelOffer(becky, {minterOfferIndex}), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -3619,10 +3619,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - std::string const uri(maxTokenURILength, '?'); + std::string const uri(kMAX_TOKEN_URI_LENGTH, '?'); std::vector offerIndexes; - offerIndexes.reserve(maxTokenOfferCancelCount + 1); - for (uint32_t i = 0; i < maxTokenOfferCancelCount + 1; ++i) + offerIndexes.reserve(kMAX_TOKEN_OFFER_CANCEL_COUNT + 1); + for (uint32_t i = 0; i < kMAX_TOKEN_OFFER_CANCEL_COUNT + 1; ++i) { Account const nftAcct(std::string("nftAcct") + std::to_string(i)); Account const offerAcct(std::string("offerAcct") + std::to_string(i)); @@ -3630,13 +3630,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftokenID = token::getNextID(env, nftAcct, 0, tfTransferable); - env(token::mint(nftAcct, 0), token::uri(uri), txflags(tfTransferable)); + env(token::mint(nftAcct, 0), token::Uri(uri), Txflags(tfTransferable)); env.close(); offerIndexes.push_back(keylet::nftoffer(offerAcct, env.seq(offerAcct)).key); env(token::createOffer(offerAcct, nftokenID, drops(1)), - token::owner(nftAcct), - token::expiration(lastClose(env) + 5)); + token::Owner(nftAcct), + token::Expiration(lastClose(env) + 5)); env.close(); } @@ -3651,7 +3651,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice attempts to cancel all of the expired offers. There is one // too many so the request fails. - env(token::cancelOffer(alice, offerIndexes), ter(temMALFORMED)); + env(token::cancelOffer(alice, offerIndexes), Ter(temMALFORMED)); env.close(); // However alice can cancel just one of the offers. @@ -3665,11 +3665,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // But alice adds a sell offer to the list... { uint256 const nftokenID = token::getNextID(env, alice, 0, tfTransferable); - env(token::mint(alice, 0), token::uri(uri), txflags(tfTransferable)); + env(token::mint(alice, 0), token::Uri(uri), Txflags(tfTransferable)); env.close(); offerIndexes.push_back(keylet::nftoffer(alice, env.seq(alice)).key); - env(token::createOffer(alice, nftokenID, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftokenID, drops(1)), Txflags(tfSellNFToken)); env.close(); // alice's owner count should now to 2 for the nft and the offer. @@ -3677,7 +3677,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Because alice added the sell offer there are still too many // offers in the list to cancel. - env(token::cancelOffer(alice, offerIndexes), ter(temMALFORMED)); + env(token::cancelOffer(alice, offerIndexes), Ter(temMALFORMED)); env.close(); // alice burns her nft which removes the nft and the offer. @@ -3761,9 +3761,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto mintNFT = [&env, &issuer, &minter](std::uint16_t xferFee = 0) { uint256 const nftID = token::getNextID(env, issuer, 0, tfTransferable, xferFee); env(token::mint(minter, 0), - token::issuer(issuer), - token::xferFee(xferFee), - txflags(tfTransferable)); + token::Issuer(issuer), + token::XferFee(xferFee), + Txflags(tfTransferable)); env.close(); return nftID; }; @@ -3780,13 +3780,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); // buyer creates their offer. Note: a buy offer can never // offer zero. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(1)), token::owner(minter)); + env(token::createOffer(buyer, nftID, XRP(1)), token::Owner(minter)); env.close(); auto const minterBalance = env.balance(minter); @@ -3822,19 +3822,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); // buyer creates their offer. Note: a buy offer can never // offer zero. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(1)), token::owner(minter)); + env(token::createOffer(buyer, nftID, XRP(1)), token::Owner(minter)); env.close(); // Broker attempts to charge a 1.1 XRP brokerFee and fails. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(XRP(1.1)), - ter(tecINSUFFICIENT_PAYMENT)); + token::BrokerFee(XRP(1.1)), + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); auto const minterBalance = env.balance(minter); @@ -3844,7 +3844,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Broker charges a 0.5 XRP brokerFee. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(XRP(0.5))); + token::BrokerFee(XRP(0.5))); env.close(); // Note that minter's XRP balance goes up even though they @@ -3867,17 +3867,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { checkOwnerCountIsOne({issuer, minter, buyer, broker}, __LINE__); - uint256 const nftID = mintNFT(maxTransferFee); + uint256 const nftID = mintNFT(kMAX_TRANSFER_FEE); // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); // buyer creates their offer. Note: a buy offer can never // offer zero. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(1)), token::owner(minter)); + env(token::createOffer(buyer, nftID, XRP(1)), token::Owner(minter)); env.close(); auto const minterBalance = env.balance(minter); @@ -3909,17 +3909,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { checkOwnerCountIsOne({issuer, minter, buyer, broker}, __LINE__); - uint256 const nftID = mintNFT(maxTransferFee); + uint256 const nftID = mintNFT(kMAX_TRANSFER_FEE); // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, XRP(0)), Txflags(tfSellNFToken)); env.close(); // buyer creates their offer. Note: a buy offer can never // offer zero. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, XRP(1)), token::owner(minter)); + env(token::createOffer(buyer, nftID, XRP(1)), token::Owner(minter)); env.close(); auto const minterBalance = env.balance(minter); @@ -3929,7 +3929,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Broker charges a 0.75 XRP brokerFee. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(XRP(0.75))); + token::BrokerFee(XRP(0.75))); env.close(); // Note that, with a 50% transfer fee, issuer gets 1/2 of what's @@ -3986,19 +3986,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(1000)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(1000)), Txflags(tfSellNFToken)); env.close(); { // buyer creates an offer for more XAU than they currently // own. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1001)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1001)), token::Owner(minter)); env.close(); // broker attempts to broker the offers but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); env.close(); // Cancel buyer's bad offer so the next test starts in a @@ -4010,12 +4010,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // buyer creates an offer for less that what minter is // asking. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(999)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(999)), token::Owner(minter)); env.close(); // broker attempts to broker the offers but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - ter(tecINSUFFICIENT_PAYMENT)); + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); // Cancel buyer's bad offer so the next test starts in a @@ -4026,13 +4026,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1000)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1000)), token::Owner(minter)); env.close(); // Broker attempts to charge a brokerFee but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(gwXAU(0.1)), - ter(tecINSUFFICIENT_PAYMENT)); + token::BrokerFee(gwXAU(0.1)), + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); // broker charges no brokerFee and succeeds. @@ -4059,22 +4059,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkOwnerCountIsOne({issuer, minter, buyer, broker}, __LINE__); setXAUBalance({issuer, minter, buyer, broker}, 1000, __LINE__); - uint256 const nftID = mintNFT(maxTransferFee); + uint256 const nftID = mintNFT(kMAX_TRANSFER_FEE); // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(900)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(900)), Txflags(tfSellNFToken)); env.close(); { // buyer creates an offer for more XAU than they currently // own. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1001)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1001)), token::Owner(minter)); env.close(); // broker attempts to broker the offers but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); env.close(); // Cancel buyer's bad offer so the next test starts in a @@ -4086,12 +4086,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // buyer creates an offer for less that what minter is // asking. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(899)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(899)), token::Owner(minter)); env.close(); // broker attempts to broker the offers but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - ter(tecINSUFFICIENT_PAYMENT)); + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); // Cancel buyer's bad offer so the next test starts in a @@ -4101,20 +4101,20 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1000)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1000)), token::Owner(minter)); env.close(); // Broker attempts to charge a brokerFee larger than the // difference between the two offers but cannot. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(gwXAU(101)), - ter(tecINSUFFICIENT_PAYMENT)); + token::BrokerFee(gwXAU(101)), + Ter(tecINSUFFICIENT_PAYMENT)); env.close(); // broker charges the full difference between the two offers and // succeeds. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(gwXAU(100))); + token::BrokerFee(gwXAU(100))); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); @@ -4137,23 +4137,23 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkOwnerCountIsOne({issuer, minter, buyer, broker}, __LINE__); setXAUBalance({issuer, minter, buyer, broker}, 1000, __LINE__); - uint256 const nftID = mintNFT(maxTransferFee / 2); // 25% + uint256 const nftID = mintNFT(kMAX_TRANSFER_FEE / 2); // 25% // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(900)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(900)), Txflags(tfSellNFToken)); env.close(); // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1000)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1000)), token::Owner(minter)); env.close(); // broker charges half difference between the two offers and // succeeds. 25% of the remaining difference goes to issuer. // The rest goes to minter. env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(gwXAU(50))); + token::BrokerFee(gwXAU(50))); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); @@ -4174,20 +4174,20 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkOwnerCountIsOne({issuer, minter, buyer, broker}, __LINE__); setXAUBalance({issuer, minter, buyer}, 1000, __LINE__); setXAUBalance({broker}, 500, __LINE__); - uint256 const nftID = mintNFT(maxTransferFee / 2); // 25% + uint256 const nftID = mintNFT(kMAX_TRANSFER_FEE / 2); // 25% // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer(minter, env.seq(minter)).key; - env(token::createOffer(minter, nftID, gwXAU(900)), txflags(tfSellNFToken)); + env(token::createOffer(minter, nftID, gwXAU(900)), Txflags(tfSellNFToken)); env.close(); // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; - env(token::createOffer(buyer, nftID, gwXAU(1000)), token::owner(minter)); + env(token::createOffer(buyer, nftID, gwXAU(1000)), token::Owner(minter)); env.close(); env(token::brokerOffers(broker, buyOfferIndex, minterOfferIndex), - token::brokerFee(gwXAU(50))); + token::BrokerFee(gwXAU(50))); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); BEAST_EXPECT(ownerCount(env, minter) == 1); @@ -4223,7 +4223,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // issuer creates an NFT. uint256 const nftId{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(issuer, 0u), txflags(tfTransferable)); + env(token::mint(issuer, 0u), Txflags(tfTransferable)); env.close(); // Prove that issuer now owns nftId. @@ -4233,18 +4233,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Both buyer1 and buyer2 create buy offers for nftId. uint256 const buyer1OfferIndex = keylet::nftoffer(buyer1, env.seq(buyer1)).key; - env(token::createOffer(buyer1, nftId, XRP(100)), token::owner(issuer)); + env(token::createOffer(buyer1, nftId, XRP(100)), token::Owner(issuer)); uint256 const buyer2OfferIndex = keylet::nftoffer(buyer2, env.seq(buyer2)).key; - env(token::createOffer(buyer2, nftId, XRP(100)), token::owner(issuer)); + env(token::createOffer(buyer2, nftId, XRP(100)), token::Owner(issuer)); env.close(); // Lambda that counts the number of buy offers for a given NFT. auto nftBuyOfferCount = [&env](uint256 const& nftId) -> std::size_t { // We know that in this case not very many offers will be // returned, so we skip the marker stuff. - Json::Value params; + json::Value params; params[jss::nft_id] = to_string(nftId); - Json::Value buyOffers = env.rpc("json", "nft_buy_offers", to_string(params)); + json::Value buyOffers = env.rpc("json", "nft_buy_offers", to_string(params)); if (buyOffers.isMember(jss::result) && buyOffers[jss::result].isMember(jss::offers)) return buyOffers[jss::result][jss::offers].size(); @@ -4315,7 +4315,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // NFTokenMint BEAST_EXPECT(ownerCount(env, issuer) == 10); uint256 const nftId{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(issuer, 0u), txflags(tfTransferable), ticket::use(issuerTicketSeq++)); + env(token::mint(issuer, 0u), Txflags(tfTransferable), ticket::Use(issuerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 10); BEAST_EXPECT(ticketCount(env, issuer) == 9); @@ -4324,14 +4324,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 10); uint256 const offerIndex0 = keylet::nftoffer(buyer, buyerTicketSeq).key; env(token::createOffer(buyer, nftId, XRP(1)), - token::owner(issuer), - ticket::use(buyerTicketSeq++)); + token::Owner(issuer), + ticket::Use(buyerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 10); BEAST_EXPECT(ticketCount(env, buyer) == 9); // NFTokenCancelOffer - env(token::cancelOffer(buyer, {offerIndex0}), ticket::use(buyerTicketSeq++)); + env(token::cancelOffer(buyer, {offerIndex0}), ticket::Use(buyerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 8); BEAST_EXPECT(ticketCount(env, buyer) == 8); @@ -4339,21 +4339,21 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // NFTokenCreateOffer. buyer tries again. uint256 const offerIndex1 = keylet::nftoffer(buyer, buyerTicketSeq).key; env(token::createOffer(buyer, nftId, XRP(2)), - token::owner(issuer), - ticket::use(buyerTicketSeq++)); + token::Owner(issuer), + ticket::Use(buyerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 8); BEAST_EXPECT(ticketCount(env, buyer) == 7); // NFTokenAcceptOffer. issuer accepts buyer's offer. - env(token::acceptBuyOffer(issuer, offerIndex1), ticket::use(issuerTicketSeq++)); + env(token::acceptBuyOffer(issuer, offerIndex1), ticket::Use(issuerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 8); BEAST_EXPECT(ownerCount(env, buyer) == 8); BEAST_EXPECT(ticketCount(env, issuer) == 8); // NFTokenBurn. buyer burns the token they just bought. - env(token::burn(buyer, nftId), ticket::use(buyerTicketSeq++)); + env(token::burn(buyer, nftId), ticket::Use(buyerTicketSeq++)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 8); BEAST_EXPECT(ownerCount(env, buyer) == 6); @@ -4395,14 +4395,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftId{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(minter, 0u), token::issuer(issuer), txflags(tfTransferable)); + env(token::mint(minter, 0u), token::Issuer(issuer), Txflags(tfTransferable)); env.close(); // At the moment issuer and minter cannot delete themselves. // o issuer has an issued NFT in the ledger. // o minter owns an NFT. - env(acctdelete(issuer, daria), fee(XRP(50)), ter(tecHAS_OBLIGATIONS)); - env(acctdelete(minter, daria), fee(XRP(50)), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(issuer, daria), Fee(XRP(50)), Ter(tecHAS_OBLIGATIONS)); + env(acctdelete(minter, daria), Fee(XRP(50)), Ter(tecHAS_OBLIGATIONS)); env.close(); // Let enough ledgers pass so the account delete transactions are @@ -4411,16 +4411,16 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // becky and carla create offers for minter's NFT. - env(token::createOffer(becky, nftId, XRP(2)), token::owner(minter)); + env(token::createOffer(becky, nftId, XRP(2)), token::Owner(minter)); env.close(); uint256 const carlaOfferIndex = keylet::nftoffer(carla, env.seq(carla)).key; - env(token::createOffer(carla, nftId, XRP(3)), token::owner(minter)); + env(token::createOffer(carla, nftId, XRP(3)), token::Owner(minter)); env.close(); // It should be possible for becky to delete herself, even though // becky has an active NFT offer. - env(acctdelete(becky, daria), fee(XRP(50))); + env(acctdelete(becky, daria), Fee(XRP(50))); env.close(); // minter accepts carla's offer. @@ -4429,14 +4429,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Now it should be possible for minter to delete themselves since // they no longer own an NFT. - env(acctdelete(minter, daria), fee(XRP(50))); + env(acctdelete(minter, daria), Fee(XRP(50))); env.close(); // 1. issuer cannot delete themselves because they issued an NFT that // is still in the ledger. // 2. carla owns an NFT, so she cannot delete herself. - env(acctdelete(issuer, daria), fee(XRP(50)), ter(tecHAS_OBLIGATIONS)); - env(acctdelete(carla, daria), fee(XRP(50)), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(issuer, daria), Fee(XRP(50)), Ter(tecHAS_OBLIGATIONS)); + env(acctdelete(carla, daria), Fee(XRP(50)), Ter(tecHAS_OBLIGATIONS)); env.close(); // Let enough ledgers pass so the account delete transactions are @@ -4449,8 +4449,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(token::burn(carla, nftId)); env.close(); - env(acctdelete(issuer, daria), fee(XRP(50))); - env(acctdelete(carla, daria), fee(XRP(50))); + env(acctdelete(issuer, daria), Fee(XRP(50))); + env(acctdelete(carla, daria), Fee(XRP(50))); env.close(); } @@ -4479,7 +4479,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Create an NFT that we'll make offers for. uint256 const nftID{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(issuer, 0), txflags(tfTransferable)); + env(token::mint(issuer, 0), Txflags(tfTransferable)); env.close(); // A lambda that validates nft_XXX_offers query responses. @@ -4489,14 +4489,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite int expectMarkerCount, int line) { int markerCount = 0; - Json::Value allOffers(Json::arrayValue); + json::Value allOffers(json::ArrayValue); std::string marker; // The do/while collects results until no marker is returned. do { - Json::Value nftOffers = [&env, &nftID, &request, &marker]() { - Json::Value params; + json::Value nftOffers = [&env, &nftID, &request, &marker]() { + json::Value params; params[jss::nft_id] = to_string(nftID); if (!marker.empty()) @@ -4529,7 +4529,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite marker.clear(); if (expect(nftOffers.isMember(jss::result), "expected \"result\"", __FILE__, line)) { - Json::Value& result = nftOffers[jss::result]; + json::Value& result = nftOffers[jss::result]; if (result.isMember(jss::marker)) { @@ -4539,7 +4539,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite if (expect(result.isMember(jss::offers), "expected \"offers\"", __FILE__, line)) { - Json::Value& someOffers = result[jss::offers]; + json::Value& someOffers = result[jss::offers]; for (std::size_t i = 0; i < someOffers.size(); ++i) allOffers.append(someOffers[i]); } @@ -4553,7 +4553,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::optional globalFlags; std::set offerIndexes; std::set amounts; - for (Json::Value const& offer : allOffers) + for (json::Value const& offer : allOffers) { // The flags on all found offers should be the same. if (!globalFlags) @@ -4587,7 +4587,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite while (sellPrice < limit) { sellPrice += XRP(1); - env(token::createOffer(issuer, nftID, sellPrice), txflags(tfSellNFToken)); + env(token::createOffer(issuer, nftID, sellPrice), Txflags(tfSellNFToken)); if (++offerCount % 10 == 0) env.close(); } @@ -4625,7 +4625,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite while (buyPrice < limit) { buyPrice += XRP(1); - env(token::createOffer(buyer, nftID, buyPrice), token::owner(issuer)); + env(token::createOffer(buyer, nftID, buyPrice), token::Owner(issuer)); if (++offerCount % 10 == 0) env.close(); } @@ -4681,12 +4681,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Create an NFT that we'll make XRP offers for. uint256 const nftID0{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(issuer, 0), txflags(tfTransferable)); + env(token::mint(issuer, 0), Txflags(tfTransferable)); env.close(); // Create an NFT that we'll make IOU offers for. uint256 const nftID1{token::getNextID(env, issuer, 1u, tfTransferable)}; - env(token::mint(issuer, 1), txflags(tfTransferable)); + env(token::mint(issuer, 1), Txflags(tfTransferable)); env.close(); TER const offerCreateTER = temBAD_AMOUNT; @@ -4694,26 +4694,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Make offers with negative amounts for the NFTs uint256 const sellNegXrpOfferIndex = keylet::nftoffer(issuer, env.seq(issuer)).key; env(token::createOffer(issuer, nftID0, XRP(-2)), - txflags(tfSellNFToken), - ter(offerCreateTER)); + Txflags(tfSellNFToken), + Ter(offerCreateTER)); env.close(); uint256 const sellNegIouOfferIndex = keylet::nftoffer(issuer, env.seq(issuer)).key; env(token::createOffer(issuer, nftID1, gwXAU(-2)), - txflags(tfSellNFToken), - ter(offerCreateTER)); + Txflags(tfSellNFToken), + Ter(offerCreateTER)); env.close(); uint256 const buyNegXrpOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftID0, XRP(-1)), - token::owner(issuer), - ter(offerCreateTER)); + token::Owner(issuer), + Ter(offerCreateTER)); env.close(); uint256 const buyNegIouOfferIndex = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::createOffer(buyer, nftID1, gwXAU(-1)), - token::owner(issuer), - ter(offerCreateTER)); + token::Owner(issuer), + Ter(offerCreateTER)); env.close(); { @@ -4721,15 +4721,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite TER const offerAcceptTER = tecOBJECT_NOT_FOUND; // Sell offers. - env(token::acceptSellOffer(buyer, sellNegXrpOfferIndex), ter(offerAcceptTER)); + env(token::acceptSellOffer(buyer, sellNegXrpOfferIndex), Ter(offerAcceptTER)); env.close(); - env(token::acceptSellOffer(buyer, sellNegIouOfferIndex), ter(offerAcceptTER)); + env(token::acceptSellOffer(buyer, sellNegIouOfferIndex), Ter(offerAcceptTER)); env.close(); // Buy offers. - env(token::acceptBuyOffer(issuer, buyNegXrpOfferIndex), ter(offerAcceptTER)); + env(token::acceptBuyOffer(issuer, buyNegXrpOfferIndex), Ter(offerAcceptTER)); env.close(); - env(token::acceptBuyOffer(issuer, buyNegIouOfferIndex), ter(offerAcceptTER)); + env(token::acceptBuyOffer(issuer, buyNegIouOfferIndex), Ter(offerAcceptTER)); env.close(); } { @@ -4737,10 +4737,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Brokered offers. env(token::brokerOffers(gw, buyNegXrpOfferIndex, sellNegXrpOfferIndex), - ter(offerAcceptTER)); + Ter(offerAcceptTER)); env.close(); env(token::brokerOffers(gw, buyNegIouOfferIndex, sellNegIouOfferIndex), - ter(offerAcceptTER)); + Ter(offerAcceptTER)); env.close(); } } @@ -4753,15 +4753,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Create an NFT that we'll make offers for. uint256 const nftID{token::getNextID(env, issuer, 0u, tfTransferable)}; - env(token::mint(issuer, 0), txflags(tfTransferable)); + env(token::mint(issuer, 0), Txflags(tfTransferable)); env.close(); TER const offerCreateTER = tesSUCCESS; env(token::createOffer(buyer, nftID, drops(1)), - token::owner(issuer), - token::destination(issuer), - ter(offerCreateTER)); + token::Owner(issuer), + token::Destination(issuer), + Ter(offerCreateTER)); env.close(); } } @@ -4862,7 +4862,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto mintNFT = [&env](Account const& minter, int transferFee = 0) { uint256 const nftID = token::getNextID(env, minter, 0, tfTransferable, transferFee); - env(token::mint(minter), token::xferFee(transferFee), txflags(tfTransferable)); + env(token::mint(minter), token::XferFee(transferFee), Txflags(tfTransferable)); env.close(); return nftID; }; @@ -4875,8 +4875,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::optional const terCode = {}) { uint256 const offerID = keylet::nftoffer(offerer, env.seq(offerer)).key; env(token::createOffer(offerer, nftID, amount), - token::owner(owner), - terCode ? ter(*terCode) : ter(static_cast(tesSUCCESS))); + token::Owner(owner), + terCode ? Ter(*terCode) : Ter(static_cast(tesSUCCESS))); env.close(); return offerID; }; @@ -4888,8 +4888,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite std::optional const terCode = {}) { uint256 const offerID = keylet::nftoffer(offerer, env.seq(offerer)).key; env(token::createOffer(offerer, nftID, amount), - txflags(tfSellNFToken), - terCode ? ter(*terCode) : ter(static_cast(tesSUCCESS))); + Txflags(tfSellNFToken), + terCode ? Ter(*terCode) : Ter(static_cast(tesSUCCESS))); env.close(); return offerID; }; @@ -4901,7 +4901,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createSellOffer(minter, nftID, gwXAU(1000)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptSellOffer(buyer, offerID), ter(sellTER)); + env(token::acceptSellOffer(buyer, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -4913,7 +4913,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createBuyOffer(buyer, minter, nftID, gwXAU(1000)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptBuyOffer(minter, offerID), ter(sellTER)); + env(token::acceptBuyOffer(minter, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -4926,7 +4926,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createSellOffer(minter, nftID, gwXAU(995)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptSellOffer(buyer, offerID), ter(sellTER)); + env(token::acceptSellOffer(buyer, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -4939,7 +4939,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createBuyOffer(buyer, minter, nftID, gwXAU(995)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptBuyOffer(minter, offerID), ter(sellTER)); + env(token::acceptBuyOffer(minter, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -5026,7 +5026,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createSellOffer(minter, nftID, gwXAU(1000)); TER const sellTER = tesSUCCESS; - env(token::acceptSellOffer(gw, offerID), ter(sellTER)); + env(token::acceptSellOffer(gw, offerID), Ter(sellTER)); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(1000)); @@ -5041,7 +5041,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite TER const offerTER = tesSUCCESS; auto const offerID = createBuyOffer(gw, minter, nftID, gwXAU(1000), {offerTER}); TER const sellTER = tesSUCCESS; - env(token::acceptBuyOffer(minter, offerID), ter(sellTER)); + env(token::acceptBuyOffer(minter, offerID), Ter(sellTER)); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(1000)); @@ -5054,7 +5054,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const offerID = createSellOffer(minter, nftID, gwXAU(5000)); TER const sellTER = tesSUCCESS; - env(token::acceptSellOffer(gw, offerID), ter(sellTER)); + env(token::acceptSellOffer(gw, offerID), Ter(sellTER)); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(5000)); @@ -5069,7 +5069,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite TER const offerTER = tesSUCCESS; auto const offerID = createBuyOffer(gw, minter, nftID, gwXAU(5000), {offerTER}); TER const sellTER = tesSUCCESS; - env(token::acceptBuyOffer(minter, offerID), ter(sellTER)); + env(token::acceptBuyOffer(minter, offerID), Ter(sellTER)); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(5000)); @@ -5110,7 +5110,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(gw); auto const offerID = createSellOffer(gw, nftID, gwXAU(2000)); env(token::acceptSellOffer(buyer, offerID), - ter(static_cast(tecINSUFFICIENT_FUNDS))); + Ter(static_cast(tecINSUFFICIENT_FUNDS))); env.close(); expectInitialState(); } @@ -5122,30 +5122,30 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(gw); auto const offerID = createBuyOffer(buyer, gw, nftID, gwXAU(2000)); env(token::acceptBuyOffer(gw, offerID), - ter(static_cast(tecINSUFFICIENT_FUNDS))); + Ter(static_cast(tecINSUFFICIENT_FUNDS))); env.close(); expectInitialState(); } { // Minter attempts to sell the token for XPB 10, which they - // have no trust line for and buyer has none of (sellside). + // have no trust line for and buyer has kNONE of (sellside). reinitializeTrustLineBalances(); auto const nftID = mintNFT(minter); auto const offerID = createSellOffer(minter, nftID, gwXPB(10)); env(token::acceptSellOffer(buyer, offerID), - ter(static_cast(tecINSUFFICIENT_FUNDS))); + Ter(static_cast(tecINSUFFICIENT_FUNDS))); env.close(); expectInitialState(); } { // Minter attempts to sell the token for XPB 10, which they - // have no trust line for and buyer has none of (buyside). + // have no trust line for and buyer has kNONE of (buyside). reinitializeTrustLineBalances(); auto const nftID = mintNFT(minter); auto const offerID = createBuyOffer( buyer, minter, nftID, gwXPB(10), {static_cast(tecUNFUNDED_OFFER)}); env(token::acceptBuyOffer(minter, offerID), - ter(static_cast(tecOBJECT_NOT_FOUND))); + Ter(static_cast(tecOBJECT_NOT_FOUND))); env.close(); expectInitialState(); } @@ -5200,7 +5200,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // now we can do a secondary sale auto const offerID = createSellOffer(secondarySeller, nftID, gwXAU(1000)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptSellOffer(buyer, offerID), ter(sellTER)); + env(token::acceptSellOffer(buyer, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -5220,7 +5220,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // now we can do a secondary sale auto const offerID = createBuyOffer(buyer, secondarySeller, nftID, gwXAU(1000)); TER const sellTER = tecINSUFFICIENT_FUNDS; - env(token::acceptBuyOffer(secondarySeller, offerID), ter(sellTER)); + env(token::acceptBuyOffer(secondarySeller, offerID), Ter(sellTER)); env.close(); expectInitialState(); @@ -5297,7 +5297,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const nftID = mintNFT(minter); auto const sellOffer = createSellOffer(minter, nftID, gwXAU(300)); auto const buyOffer = createBuyOffer(buyer, minter, nftID, gwXAU(500)); - env(token::brokerOffers(broker, buyOffer, sellOffer), token::brokerFee(gwXAU(100))); + env(token::brokerOffers(broker, buyOffer, sellOffer), token::BrokerFee(gwXAU(100))); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(400)); @@ -5335,7 +5335,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // now we can do a secondary sale auto const sellOffer = createSellOffer(secondarySeller, nftID, gwXAU(300)); auto const buyOffer = createBuyOffer(buyer, secondarySeller, nftID, gwXAU(500)); - env(token::brokerOffers(broker, buyOffer, sellOffer), token::brokerFee(gwXAU(100))); + env(token::brokerOffers(broker, buyOffer, sellOffer), token::BrokerFee(gwXAU(100))); env.close(); BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(12)); @@ -5394,18 +5394,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // a broker can sell the NFT that bob owns to bob and pocket the // difference. uint256 const nftId{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); // Bob creates a buy offer for 5 XRP. Alice creates a sell offer // for 0 XRP. uint256 const bobBuyOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId, XRP(5)), token::owner(alice)); + env(token::createOffer(bob, nftId, XRP(5)), token::Owner(alice)); uint256 const aliceSellOfferIndex = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftId, XRP(0)), - token::destination(bob), - txflags(tfSellNFToken)); + token::Destination(bob), + Txflags(tfSellNFToken)); env.close(); // bob accepts alice's offer but forgets to remove the old buy offer. @@ -5417,7 +5417,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Bob creates a sell offer for the gift NFT from alice. uint256 const bobSellOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId, XRP(4)), txflags(tfSellNFToken)); + env(token::createOffer(bob, nftId, XRP(4)), Txflags(tfSellNFToken)); env.close(); // bob now has a buy offer and a sell offer on the books. A broker @@ -5426,8 +5426,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite auto const bobPriorBalance = env.balance(bob); auto const brokerPriorBalance = env.balance(broker); env(token::brokerOffers(broker, bobBuyOfferIndex, bobSellOfferIndex), - token::brokerFee(XRP(1)), - ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); + token::BrokerFee(XRP(1)), + Ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); env.close(); // A tec result was returned, so no state should change other @@ -5503,7 +5503,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice's account is deleted Keylet const aliceAcctKey{keylet::account(alice.id())}; auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, becky), fee(acctDelFee)); + env(acctdelete(alice, becky), Fee(acctDelFee)); env.close(); // alice's account root is gone from the most recently @@ -5555,7 +5555,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const nftokenID = token::getNextID(env, alice, 0u); nftIDs.push_back(nftokenID); - env(token::mint(minter), token::issuer(alice)); + env(token::mint(minter), token::Issuer(alice)); } env.close(); @@ -5582,7 +5582,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // MintedNFTokens + 256> enabled by this amendment will enforce // alice to wait for more ledgers to close before she can // delete her account, to prevent duplicate NFTokenIDs - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); env.close(); // alice's account is still present @@ -5594,7 +5594,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite incLgrSeqForFixNftRemint(env, alice); // alice's account is deleted - env(acctdelete(alice, becky), fee(acctDelFee)); + env(acctdelete(alice, becky), Fee(acctDelFee)); env.close(); // alice's account root is gone from the most recently @@ -5652,14 +5652,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite for (int i = 0; i < 50; i++) { nftIDs.push_back(token::getNextID(env, alice, 0u)); - env(token::mint(alice, 0u), ticket::use(aliceTicketSeq++)); + env(token::mint(alice, 0u), ticket::Use(aliceTicketSeq++)); env.close(); } // alice burns 50 NFTs using tickets for (auto const nftokenID : nftIDs) { - env(token::burn(alice, nftokenID), ticket::use(aliceTicketSeq++)); + env(token::burn(alice, nftokenID), ticket::Use(aliceTicketSeq++)); } env.close(); @@ -5681,7 +5681,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // MintedNFTokens + 256> enabled by this amendment will enforce // alice to wait for more ledgers to close before she can // delete her account, to prevent duplicate NFTokenIDs - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); env.close(); // alice's account is still present @@ -5693,7 +5693,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite incLgrSeqForFixNftRemint(env, alice); // alice's account is deleted - env(acctdelete(alice, becky), fee(acctDelFee)); + env(acctdelete(alice, becky), Fee(acctDelFee)); env.close(); // alice's account root is gone from the most recently @@ -5756,14 +5756,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { uint256 const nftokenID = token::getNextID(env, alice, 0u); nftIDs.push_back(nftokenID); - env(token::mint(minter), token::issuer(alice), ticket::use(minterTicketSeq++)); + env(token::mint(minter), token::Issuer(alice), ticket::Use(minterTicketSeq++)); } env.close(); // minter burns 50 NFTs using tickets for (auto const nftokenID : nftIDs) { - env(token::burn(minter, nftokenID), ticket::use(minterTicketSeq++)); + env(token::burn(minter, nftokenID), ticket::Use(minterTicketSeq++)); } env.close(); @@ -5784,7 +5784,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // alice to wait for more ledgers to close before she can delete her // account, to prevent duplicate NFTokenIDs auto const acctDelFee{drops(env.current()->fees().increment)}; - env(acctdelete(alice, becky), fee(acctDelFee), ter(tecTOO_SOON)); + env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON)); env.close(); // alice's account is still present @@ -5796,7 +5796,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite incLgrSeqForFixNftRemint(env, alice); // alice's account is deleted - env(acctdelete(alice, becky), fee(acctDelFee)); + env(acctdelete(alice, becky), Fee(acctDelFee)); env.close(); // alice's account root is gone from the most recently @@ -5844,13 +5844,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.fund(XRP(10000), alice, buyer); env.close(); - env(token::mint(alice), token::amount(XRP(10000)), ter(temDISABLED)); + env(token::mint(alice), token::Amount(XRP(10000)), Ter(temDISABLED)); env.close(); - env(token::mint(alice), token::destination("buyer"), ter(temDISABLED)); + env(token::mint(alice), token::Destination("buyer"), Ter(temDISABLED)); env.close(); - env(token::mint(alice), token::expiration(lastClose(env) + 25), ter(temDISABLED)); + env(token::mint(alice), token::Expiration(lastClose(env) + 25), Ter(temDISABLED)); env.close(); return; @@ -5873,12 +5873,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Destination field specified but Amount field not specified - env(token::mint(alice), token::destination(buyer), ter(temMALFORMED)); + env(token::mint(alice), token::Destination(buyer), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // Expiration field specified but Amount field not specified - env(token::mint(alice), token::expiration(lastClose(env) + 25), ter(temMALFORMED)); + env(token::mint(alice), token::Expiration(lastClose(env) + 25), Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 0); } @@ -5887,18 +5887,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The destination may not be the account submitting the // transaction. env(token::mint(alice), - token::amount(XRP(1000)), - token::destination(alice), - ter(temMALFORMED)); + token::Amount(XRP(1000)), + token::Destination(alice), + Ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // The destination must be an account already established in the // ledger. env(token::mint(alice), - token::amount(XRP(1000)), - token::destination(Account("demon")), - ter(tecNO_DST)); + token::Amount(XRP(1000)), + token::Destination(Account("demon")), + Ter(tecNO_DST)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); } @@ -5906,17 +5906,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Set a bad expiration. env(token::mint(alice), - token::amount(XRP(1000)), - token::expiration(0), - ter(temBAD_EXPIRATION)); + token::Amount(XRP(1000)), + token::Expiration(0), + Ter(temBAD_EXPIRATION)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // The new NFTokenOffer may not have passed its expiration time. env(token::mint(alice), - token::amount(XRP(1000)), - token::expiration(lastClose(env)), - ter(tecEXPIRED)); + token::Amount(XRP(1000)), + token::Expiration(lastClose(env)), + Ter(tecEXPIRED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); } @@ -5924,19 +5924,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Set an invalid amount. env(token::mint(alice), - token::amount(buyer["USD"](1)), - txflags(tfOnlyXRP), - ter(temBAD_AMOUNT)); - env(token::mint(alice), token::amount(buyer["USD"](0)), ter(temBAD_AMOUNT)); + token::Amount(buyer["USD"](1)), + Txflags(tfOnlyXRP), + Ter(temBAD_AMOUNT)); + env(token::mint(alice), token::Amount(buyer["USD"](0)), Ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // Issuer (alice) must have a trust line for the offered funds. env(token::mint(alice), - token::amount(gwAUD(1000)), - txflags(tfTransferable), - token::xferFee(10), - ter(tecNO_LINE)); + token::Amount(gwAUD(1000)), + Txflags(tfTransferable), + token::XferFee(10), + Ter(tecNO_LINE)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -5944,9 +5944,9 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // then that issuer does not need a trust line to accept their // fee. env(token::mint(gw), - token::amount(gwAUD(1000)), - txflags(tfTransferable), - token::xferFee(10)); + token::Amount(gwAUD(1000)), + Txflags(tfTransferable), + token::XferFee(10)); env.close(); // Give alice the needed trust line, but freeze it. @@ -5956,15 +5956,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Issuer (alice) must have a trust line for the offered funds // and the trust line may not be frozen. env(token::mint(alice), - token::amount(gwAUD(1000)), - txflags(tfTransferable), - token::xferFee(10), - ter(tecFROZEN)); + token::Amount(gwAUD(1000)), + Txflags(tfTransferable), + token::XferFee(10), + Ter(tecFROZEN)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); // Seller (alice) must have a trust line may not be frozen. - env(token::mint(alice), token::amount(gwAUD(1000)), ter(tecFROZEN)); + env(token::mint(alice), token::Amount(gwAUD(1000)), Ter(tecFROZEN)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -5982,66 +5982,66 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); // doesn't have reserve for 2 objects (NFTokenPage, Offer) - env(token::mint(bob), token::amount(XRP(0)), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(bob), token::Amount(XRP(0)), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // have reserve for NFTokenPage, Offer env(pay(env.master, bob, incReserve + drops(baseFee))); env.close(); - env(token::mint(bob), token::amount(XRP(0))); + env(token::mint(bob), token::Amount(XRP(0))); env.close(); // doesn't have reserve for Offer env(pay(env.master, bob, drops(baseFee))); env.close(); - env(token::mint(bob), token::amount(XRP(0)), ter(tecINSUFFICIENT_RESERVE)); + env(token::mint(bob), token::Amount(XRP(0)), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // have reserve for Offer env(pay(env.master, bob, incReserve + drops(baseFee))); env.close(); - env(token::mint(bob), token::amount(XRP(0))); + env(token::mint(bob), token::Amount(XRP(0))); env.close(); } // Amount field specified BEAST_EXPECT(ownerCount(env, alice) == 0); - env(token::mint(alice), token::amount(XRP(10))); + env(token::mint(alice), token::Amount(XRP(10))); BEAST_EXPECT(ownerCount(env, alice) == 2); env.close(); // Amount field and Destination field, Expiration field specified env(token::mint(alice), - token::amount(XRP(10)), - token::destination(buyer), - token::expiration(lastClose(env) + 25)); + token::Amount(XRP(10)), + token::Destination(buyer), + token::Expiration(lastClose(env) + 25)); env.close(); // With TransferFee field env(trust(alice, gwAUD(1000))); env.close(); env(token::mint(alice), - token::amount(gwAUD(1)), - token::destination(buyer), - token::expiration(lastClose(env) + 25), - txflags(tfTransferable), - token::xferFee(10)); + token::Amount(gwAUD(1)), + token::Destination(buyer), + token::Expiration(lastClose(env) + 25), + Txflags(tfTransferable), + token::XferFee(10)); env.close(); // Can be canceled by the issuer. env(token::mint(alice), - token::amount(XRP(10)), - token::destination(buyer), - token::expiration(lastClose(env) + 25)); + token::Amount(XRP(10)), + token::Destination(buyer), + token::Expiration(lastClose(env) + 25)); uint256 const offerAliceSellsToBuyer = keylet::nftoffer(alice, env.seq(alice)).key; env(token::cancelOffer(alice, {offerAliceSellsToBuyer})); env.close(); // Can be canceled by the buyer. env(token::mint(buyer), - token::amount(XRP(10)), - token::destination(alice), - token::expiration(lastClose(env) + 25)); + token::Amount(XRP(10)), + token::Destination(alice), + token::Expiration(lastClose(env) + 25)); uint256 const offerBuyerSellsToAlice = keylet::nftoffer(buyer, env.seq(buyer)).key; env(token::cancelOffer(alice, {offerBuyerSellsToAlice})); env.close(); @@ -6052,7 +6052,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Minter will have offer not issuer BEAST_EXPECT(ownerCount(env, minter) == 0); BEAST_EXPECT(ownerCount(env, issuer) == 0); - env(token::mint(minter), token::issuer(issuer), token::amount(drops(1))); + env(token::mint(minter), token::Issuer(issuer), token::Amount(drops(1))); env.close(); BEAST_EXPECT(ownerCount(env, minter) == 2); BEAST_EXPECT(ownerCount(env, issuer) == 0); @@ -6066,7 +6066,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite TER const offerCreateTER = temBAD_AMOUNT; // Make offers with negative amounts for the NFTs - env(token::mint(alice), token::amount(XRP(-2)), ter(offerCreateTER)); + env(token::mint(alice), token::Amount(XRP(-2)), Ter(offerCreateTER)); env.close(); } @@ -6101,10 +6101,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // transaction auto verifyNFTokenID = [&](uint256 const& actualNftID) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect nftokens_id field if (!BEAST_EXPECT(meta.isMember(jss::nftoken_id))) @@ -6121,22 +6121,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // changed in the most recent NFTokenCancelOffer transaction auto verifyNFTokenIDsInCancelOffer = [&](std::vector actualNftIDs) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect nftokens_ids field and verify the values if (!BEAST_EXPECT(meta.isMember(jss::nftoken_ids))) return; - // Convert NFT IDs from Json::Value to uint256 + // Convert NFT IDs from json::Value to uint256 std::vector metaIDs; std::transform( meta[jss::nftoken_ids].begin(), meta[jss::nftoken_ids].end(), std::back_inserter(metaIDs), - [this](Json::Value id) { + [this](json::Value id) { uint256 nftID; BEAST_EXPECT(nftID.parseHex(id.asString())); return nftID; @@ -6159,10 +6159,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // changed in the most recent NFTokenCreateOffer tx auto verifyNFTokenOfferID = [&](uint256 const& offerID) { // Get the hash for the most recent transaction. - std::string const txHash{env.tx()->getJson(JsonOptions::none)[jss::hash].asString()}; + std::string const txHash{env.tx()->getJson(JsonOptions::KNone)[jss::hash].asString()}; env.close(); - Json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; + json::Value const meta = env.rpc("tx", txHash)[jss::result][jss::meta]; // Expect offer_id field and verify the value if (!BEAST_EXPECT(meta.isMember(jss::offer_id))) @@ -6178,12 +6178,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Alice mints 2 NFTs // Verify the NFTokenIDs are correct in the NFTokenMint tx meta uint256 const nftId1{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); verifyNFTokenID(nftId1); uint256 const nftId2{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); verifyNFTokenID(nftId2); @@ -6191,12 +6191,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Verify the offer indexes are correct in the NFTokenCreateOffer tx // meta uint256 const aliceOfferIndex1 = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftId1, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftId1, drops(1)), Txflags(tfSellNFToken)); env.close(); verifyNFTokenOfferID(aliceOfferIndex1); uint256 const aliceOfferIndex2 = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftId2, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftId2, drops(1)), Txflags(tfSellNFToken)); env.close(); verifyNFTokenOfferID(aliceOfferIndex2); @@ -6210,7 +6210,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Bobs creates a buy offer for nftId1 // Verify the offer id is correct in the NFTokenCreateOffer tx meta auto const bobBuyOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId1, drops(1)), token::owner(alice)); + env(token::createOffer(bob, nftId1, drops(1)), token::Owner(alice)); env.close(); verifyNFTokenOfferID(bobBuyOfferIndex); @@ -6225,21 +6225,21 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Alice mints a NFT uint256 const nftId{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); verifyNFTokenID(nftId); // Alice creates sell offer and set broker as destination uint256 const offerAliceToBroker = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftId, drops(1)), - token::destination(broker), - txflags(tfSellNFToken)); + token::Destination(broker), + Txflags(tfSellNFToken)); env.close(); verifyNFTokenOfferID(offerAliceToBroker); // Bob creates buy offer uint256 const offerBobToBroker = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId, drops(1)), token::owner(alice)); + env(token::createOffer(bob, nftId, drops(1)), token::Owner(alice)); env.close(); verifyNFTokenOfferID(offerBobToBroker); @@ -6254,18 +6254,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Alice mints a NFT uint256 const nftId{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); verifyNFTokenID(nftId); // Alice creates 2 sell offers for the same NFT uint256 const aliceOfferIndex1 = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftId, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftId, drops(1)), Txflags(tfSellNFToken)); env.close(); verifyNFTokenOfferID(aliceOfferIndex1); uint256 const aliceOfferIndex2 = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::createOffer(alice, nftId, drops(1)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftId, drops(1)), Txflags(tfSellNFToken)); env.close(); verifyNFTokenOfferID(aliceOfferIndex2); @@ -6279,7 +6279,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite if (features[featureNFTokenMintOffer]) { uint256 const aliceMintWithOfferIndex1 = keylet::nftoffer(alice, env.seq(alice)).key; - env(token::mint(alice), token::amount(XRP(0))); + env(token::mint(alice), token::Amount(XRP(0))); env.close(); verifyNFTokenOfferID(aliceMintWithOfferIndex1); } @@ -6297,12 +6297,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite [](test::jtx::Env& env, test::jtx::Account const& acct, STAmount const amt) -> uint256 { // acct mints a NFT uint256 const nftId{token::getNextID(env, acct, 0u, tfTransferable)}; - env(token::mint(acct, 0u), txflags(tfTransferable)); + env(token::mint(acct, 0u), Txflags(tfTransferable)); env.close(); // acct makes an sell offer uint256 const sellOfferIndex = keylet::nftoffer(acct, env.seq(acct)).key; - env(token::createOffer(acct, nftId, amt), txflags(tfSellNFToken)); + env(token::createOffer(acct, nftId, amt), Txflags(tfSellNFToken)); env.close(); return sellOfferIndex; @@ -6357,7 +6357,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { // Bob is not able to accept the offer with only the account // reserve (200,000,000 drops) - env(token::acceptSellOffer(bob, sellOfferIndex), ter(tecINSUFFICIENT_RESERVE)); + env(token::acceptSellOffer(bob, sellOfferIndex), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // after prev transaction, Bob owns `200M - base fee` drops due @@ -6365,7 +6365,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, bob) == 0); - // Send bob an increment reserve and base fee (to make up for + // Send bob an kINCREMENT reserve and base fee (to make up for // the transaction fee burnt from the prev failed tx) Bob now // owns 250,000,000 drops env(pay(env.master, bob, incReserve + drops(baseFee))); @@ -6373,7 +6373,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // However, this transaction will still fail because the reserve // requirement is `base fee` drops higher - env(token::acceptSellOffer(bob, sellOfferIndex), ter(tecINSUFFICIENT_RESERVE)); + env(token::acceptSellOffer(bob, sellOfferIndex), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // Send bob `base fee * 2` drops @@ -6425,7 +6425,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Bob cannot accept this offer because he doesn't have the // reserve for the NFT - env(token::acceptSellOffer(bob, sellOfferIndex1), ter(tecINSUFFICIENT_RESERVE)); + env(token::acceptSellOffer(bob, sellOfferIndex1), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // Give bob enough reserve @@ -6461,7 +6461,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Bob fails to accept this NFT because he does not have enough // reserve for a new NFTokenPage - env(token::acceptSellOffer(bob, sellOfferIndex33), ter(tecINSUFFICIENT_RESERVE)); + env(token::acceptSellOffer(bob, sellOfferIndex33), Ter(tecINSUFFICIENT_RESERVE)); env.close(); // Send bob incremental reserve @@ -6494,26 +6494,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.fund(XRP(10000), alice); env.close(); - // Bob is funded with account reserve + increment reserve + 1 XRP - // increment reserve is for the buy offer, and 1 XRP is for offer + // Bob is funded with account reserve + kINCREMENT reserve + 1 XRP + // kINCREMENT reserve is for the buy offer, and 1 XRP is for offer // price env.fund(acctReserve + incReserve + XRP(1), bob); env.close(); // Alice mints a NFT uint256 const nftId{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); // Bob makes a buy offer for 1 XRP auto const buyOfferIndex = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId, XRP(1)), token::owner(alice)); + env(token::createOffer(bob, nftId, XRP(1)), token::Owner(alice)); env.close(); // accepting the buy offer fails because bob's balance is `base fee` // drops lower than the required amount, since the previous tx burnt // drops for tx fee. - env(token::acceptBuyOffer(alice, buyOfferIndex), ter(tecINSUFFICIENT_FUNDS)); + env(token::acceptBuyOffer(alice, buyOfferIndex), Ter(tecINSUFFICIENT_FUNDS)); env.close(); // send Bob `base fee` drops @@ -6550,19 +6550,19 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Alice mints a NFT uint256 const nftId{token::getNextID(env, alice, 0u, tfTransferable)}; - env(token::mint(alice, 0u), txflags(tfTransferable)); + env(token::mint(alice, 0u), Txflags(tfTransferable)); env.close(); // Alice creates sell offer and set broker as destination uint256 const offerAliceToBroker = keylet::nftoffer(alice, env.seq(alice)).key; env(token::createOffer(alice, nftId, XRP(1)), - token::destination(broker), - txflags(tfSellNFToken)); + token::Destination(broker), + Txflags(tfSellNFToken)); env.close(); // Bob creates buy offer uint256 const offerBobToBroker = keylet::nftoffer(bob, env.seq(bob)).key; - env(token::createOffer(bob, nftId, XRP(1)), token::owner(alice)); + env(token::createOffer(bob, nftId, XRP(1)), token::Owner(alice)); env.close(); // broker offers. @@ -6570,7 +6570,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // created his buy offer, which makes his spendable balance to be // less than the required amount. env(token::brokerOffers(broker, offerBobToBroker, offerAliceToBroker), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); env.close(); // send Bob `base fee` drops @@ -6644,22 +6644,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const nftAutoTrustID{ token::getNextID(env, issuer, 0u, tfTransferable | tfTrustLine, xferFee)}; env(token::mint(issuer, 0u), - token::xferFee(xferFee), - txflags(tfTransferable | tfTrustLine)); + token::XferFee(xferFee), + Txflags(tfTransferable | tfTrustLine)); env.close(); uint256 const nftNoAutoTrustID{ token::getNextID(env, issuer, 0u, tfTransferable, xferFee)}; - env(token::mint(issuer, 0u), token::xferFee(xferFee), txflags(tfTransferable)); + env(token::mint(issuer, 0u), token::XferFee(xferFee), Txflags(tfTransferable)); env.close(); // becky buys the nfts for 1 drop each. { uint256 const beckyBuyOfferIndex1 = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::owner(issuer)); + env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::Owner(issuer)); uint256 const beckyBuyOfferIndex2 = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::owner(issuer)); + env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::Owner(issuer)); env.close(); env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex1)); @@ -6669,14 +6669,14 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // becky creates offers to sell the nfts for AUD. uint256 const beckyAutoTrustOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, gwAUD(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftAutoTrustID, gwAUD(100)), Txflags(tfSellNFToken)); env.close(); // Creating an offer for the NFToken without tfTrustLine fails // because issuer does not have a trust line for AUD. env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), - txflags(tfSellNFToken), - ter(tecNO_LINE)); + Txflags(tfSellNFToken), + Ter(tecNO_LINE)); env.close(); // issuer creates a trust line. Now the offer create for the @@ -6687,7 +6687,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, issuer) == 1); uint256 const beckyNoAutoTrustOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), Txflags(tfSellNFToken)); env.close(); // Now that the offers are in place, issuer removes the trustline. @@ -6717,7 +6717,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // With fixEnforceNFTokenTrustline cheri can't accept the // offer because issuer could not get their transfer fee // without the appropriate trustline. - env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex), ter(tecNO_LINE)); + env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex), Ter(tecNO_LINE)); env.close(); // But if issuer re-establishes the trustline then the offer @@ -6800,21 +6800,21 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const nftAutoTrustID{ token::getNextID(env, issuer, 0u, tfTransferable | tfTrustLine, xferFee)}; env(token::mint(issuer, 0u), - token::xferFee(xferFee), - txflags(tfTransferable | tfTrustLine)); + token::XferFee(xferFee), + Txflags(tfTransferable | tfTrustLine)); env.close(); uint256 const nftNoAutoTrustID{token::getNextID(env, issuer, 0u, tfTransferable, xferFee)}; - env(token::mint(issuer, 0u), token::xferFee(xferFee), txflags(tfTransferable)); + env(token::mint(issuer, 0u), token::XferFee(xferFee), Txflags(tfTransferable)); env.close(); // becky buys the nfts for 1 drop each. { uint256 const beckyBuyOfferIndex1 = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::owner(issuer)); + env(token::createOffer(becky, nftAutoTrustID, drops(1)), token::Owner(issuer)); uint256 const beckyBuyOfferIndex2 = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::owner(issuer)); + env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), token::Owner(issuer)); env.close(); env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex1)); @@ -6830,18 +6830,18 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // create an offer for a non-tfTrustLine NFToken that would // pay the transfer fee in issuer's own IOU. env(token::createOffer(becky, nftNoAutoTrustID, isISU(100)), - txflags(tfSellNFToken), - ter(tecNO_LINE)); + Txflags(tfSellNFToken), + Ter(tecNO_LINE)); env.close(); // And issuer can't create a trust line to themselves. - env(trust(issuer, isISU(1000)), ter(temDST_IS_SRC)); + env(trust(issuer, isISU(1000)), Ter(temDST_IS_SRC)); env.close(); // However if the NFToken has the tfTrustLine flag set, // then becky can create the offer. uint256 const beckyAutoTrustOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, isISU(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftAutoTrustID, isISU(100)), Txflags(tfSellNFToken)); env.close(); // And cheri can accept the offer. @@ -6858,10 +6858,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // With featureNFTokenMintOffer things go better. // becky creates offers to sell the nfts for ISU. uint256 const beckyNoAutoTrustOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftNoAutoTrustID, isISU(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftNoAutoTrustID, isISU(100)), Txflags(tfSellNFToken)); env.close(); uint256 const beckyAutoTrustOfferIndex = keylet::nftoffer(becky, env.seq(becky)).key; - env(token::createOffer(becky, nftAutoTrustID, isISU(100)), txflags(tfSellNFToken)); + env(token::createOffer(becky, nftAutoTrustID, isISU(100)), Txflags(tfSellNFToken)); env.close(); // cheri accepts becky's offers. Behavior is uniform: @@ -6905,7 +6905,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); auto const expectedTer = modifyEnabled ? TER{tesSUCCESS} : TER{temINVALID_FLAG}; - env(token::mint(issuer, 0u), txflags(tfMutable), ter(expectedTer)); + env(token::mint(issuer, 0u), Txflags(tfMutable), Ter(expectedTer)); env.close(); } { @@ -6917,7 +6917,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const nftId{token::getNextID(env, issuer, 0u, tfMutable)}; if (modifyEnabled) { - env(token::mint(issuer, 0u), txflags(tfMutable)); + env(token::mint(issuer, 0u), Txflags(tfMutable)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 1); env(token::modify(issuer, nftId)); @@ -6927,7 +6927,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite { env(token::mint(issuer, 0u)); env.close(); - env(token::modify(issuer, nftId), ter(temDISABLED)); + env(token::modify(issuer, nftId), Ter(temDISABLED)); env.close(); } } @@ -6940,28 +6940,28 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); uint256 const nftId{token::getNextID(env, issuer, 0u, tfMutable)}; - env(token::mint(issuer, 0u), txflags(tfMutable)); + env(token::mint(issuer, 0u), Txflags(tfMutable)); env.close(); // Set a negative fee. Exercises invalid preflight1. - env(token::modify(issuer, nftId), fee(STAmount(10ull, true)), ter(temBAD_FEE)); + env(token::modify(issuer, nftId), Fee(STAmount(10ull, true)), Ter(temBAD_FEE)); env.close(); // Invalid Flags - env(token::modify(issuer, nftId), txflags(0x00000001), ter(temINVALID_FLAG)); + env(token::modify(issuer, nftId), Txflags(0x00000001), Ter(temINVALID_FLAG)); // Invalid Owner - env(token::modify(issuer, nftId), token::owner(issuer), ter(temMALFORMED)); + env(token::modify(issuer, nftId), token::Owner(issuer), Ter(temMALFORMED)); env.close(); // Invalid URI length = 0 - env(token::modify(issuer, nftId), token::uri(""), ter(temMALFORMED)); + env(token::modify(issuer, nftId), token::Uri(""), Ter(temMALFORMED)); env.close(); // Invalid URI length > 256 env(token::modify(issuer, nftId), - token::uri(std::string(maxTokenURILength + 1, 'q')), - ter(temMALFORMED)); + token::Uri(std::string(kMAX_TOKEN_URI_LENGTH + 1, 'q')), + Ter(temMALFORMED)); env.close(); } { @@ -6974,7 +6974,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const nftIDNotExists{token::getNextID(env, issuer, 0u, tfMutable)}; env.close(); - env(token::modify(issuer, nftIDNotExists), ter(tecNO_ENTRY)); + env(token::modify(issuer, nftIDNotExists), Ter(tecNO_ENTRY)); env.close(); } { @@ -6983,22 +6983,22 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env(token::mint(issuer, 0u)); env.close(); - env(token::modify(issuer, nftIDNotModifiable), ter(tecNO_PERMISSION)); + env(token::modify(issuer, nftIDNotModifiable), Ter(tecNO_PERMISSION)); env.close(); } { // Unauthorized account uint256 const nftId{token::getNextID(env, issuer, 0u, tfMutable)}; - env(token::mint(issuer, 0u), txflags(tfMutable)); + env(token::mint(issuer, 0u), Txflags(tfMutable)); env.close(); - env(token::modify(bob, nftId), token::owner(issuer), ter(tecNO_PERMISSION)); + env(token::modify(bob, nftId), token::Owner(issuer), Ter(tecNO_PERMISSION)); env.close(); env(token::setMinter(issuer, alice)); env.close(); - env(token::modify(bob, nftId), token::owner(issuer), ter(tecNO_PERMISSION)); + env(token::modify(bob, nftId), token::Owner(issuer), Ter(tecNO_PERMISSION)); env.close(); } } @@ -7009,10 +7009,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // modify with tfFullyCanonicalSig should success uint256 const nftId{token::getNextID(env, issuer, 0u, tfMutable)}; - env(token::mint(issuer, 0u), txflags(tfMutable), token::uri("uri")); + env(token::mint(issuer, 0u), Txflags(tfMutable), token::Uri("uri")); env.close(); - env(token::modify(issuer, nftId), txflags(tfFullyCanonicalSig)); + env(token::modify(issuer, nftId), Txflags(tfFullyCanonicalSig)); env.close(); } { @@ -7022,7 +7022,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // lambda that returns the JSON form of NFTokens held by acct auto accountNFTs = [&env](Account const& acct) { - Json::Value params; + json::Value params; params[jss::account] = acct.human(); params[jss::type] = "state"; auto response = env.rpc("json", "account_nfts", to_string(params)); @@ -7074,12 +7074,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite uint256 const nftId{token::getNextID(env, issuer, 0u, tfMutable)}; env.close(); - env(token::mint(issuer, 0u), txflags(tfMutable), token::uri("uri")); + env(token::mint(issuer, 0u), Txflags(tfMutable), token::Uri("uri")); env.close(); checkURI(issuer, "uri", __LINE__); // set URI Field - env(token::modify(issuer, nftId), token::uri("new_uri")); + env(token::modify(issuer, nftId), token::Uri("new_uri")); env.close(); checkURI(issuer, "new_uri", __LINE__); @@ -7089,13 +7089,13 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkURI(issuer, nullptr, __LINE__); // set URI Field - env(token::modify(issuer, nftId), token::uri("uri")); + env(token::modify(issuer, nftId), token::Uri("uri")); env.close(); checkURI(issuer, "uri", __LINE__); // Account != Owner uint256 const offerID = keylet::nftoffer(issuer, env.seq(issuer)).key; - env(token::createOffer(issuer, nftId, XRP(0)), txflags(tfSellNFToken)); + env(token::createOffer(issuer, nftId, XRP(0)), Txflags(tfSellNFToken)); env.close(); env(token::acceptSellOffer(alice, offerID)); env.close(); @@ -7104,45 +7104,45 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite checkURI(alice, "uri", __LINE__); // Modify by owner fails. - env(token::modify(alice, nftId), token::uri("new_uri"), ter(tecNO_PERMISSION)); + env(token::modify(alice, nftId), token::Uri("new_uri"), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, alice) == 1); checkURI(alice, "uri", __LINE__); - env(token::modify(issuer, nftId), token::owner(alice), token::uri("new_uri")); + env(token::modify(issuer, nftId), token::Owner(alice), token::Uri("new_uri")); env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); BEAST_EXPECT(ownerCount(env, alice) == 1); checkURI(alice, "new_uri", __LINE__); - env(token::modify(issuer, nftId), token::owner(alice)); + env(token::modify(issuer, nftId), token::Owner(alice)); env.close(); checkURI(alice, nullptr, __LINE__); - env(token::modify(issuer, nftId), token::owner(alice), token::uri("uri")); + env(token::modify(issuer, nftId), token::Owner(alice), token::Uri("uri")); env.close(); checkURI(alice, "uri", __LINE__); // Modify by authorized minter env(token::setMinter(issuer, bob)); env.close(); - env(token::modify(bob, nftId), token::owner(alice), token::uri("new_uri")); + env(token::modify(bob, nftId), token::Owner(alice), token::Uri("new_uri")); env.close(); checkURI(alice, "new_uri", __LINE__); - env(token::modify(bob, nftId), token::owner(alice)); + env(token::modify(bob, nftId), token::Owner(alice)); env.close(); checkURI(alice, nullptr, __LINE__); - env(token::modify(bob, nftId), token::owner(alice), token::uri("uri")); + env(token::modify(bob, nftId), token::Owner(alice), token::Uri("uri")); env.close(); checkURI(alice, "uri", __LINE__); } } protected: - FeatureBitset const allFeatures{test::jtx::testable_amendments()}; + FeatureBitset const allFeatures_{test::jtx::testableAmendments()}; void testWithFeats(FeatureBitset features) @@ -7189,7 +7189,7 @@ public: run() override { testWithFeats( - allFeatures - fixNFTokenReserve - featureNFTokenMintOffer - featureDynamicNFT - + allFeatures_ - fixNFTokenReserve - featureNFTokenMintOffer - featureDynamicNFT - fixSecurity3_1_3); } }; @@ -7200,7 +7200,7 @@ class NFTokenDisallowIncoming_test : public NFTokenBaseUtil_test run() override { testWithFeats( - allFeatures - fixNFTokenReserve - featureNFTokenMintOffer - featureDynamicNFT); + allFeatures_ - fixNFTokenReserve - featureNFTokenMintOffer - featureDynamicNFT); } }; @@ -7209,7 +7209,7 @@ class NFTokenWOMintOffer_test : public NFTokenBaseUtil_test void run() override { - testWithFeats(allFeatures - featureNFTokenMintOffer - featureDynamicNFT); + testWithFeats(allFeatures_ - featureNFTokenMintOffer - featureDynamicNFT); } }; @@ -7218,16 +7218,16 @@ class NFTokenWOModify_test : public NFTokenBaseUtil_test void run() override { - testWithFeats(allFeatures - featureDynamicNFT); + testWithFeats(allFeatures_ - featureDynamicNFT); } }; -class NFTokenWOExpiredOfferRemoval_test : public NFTokenBaseUtil_test +class NfTokenWoExpiredOfferRemovalTest : public NFTokenBaseUtil_test { void run() override { - testWithFeats(allFeatures - fixSecurity3_1_3); + testWithFeats(allFeatures_ - fixSecurity3_1_3); } }; @@ -7236,7 +7236,7 @@ class NFTokenAllFeatures_test : public NFTokenBaseUtil_test void run() override { - testWithFeats(allFeatures); + testWithFeats(allFeatures_); } }; diff --git a/src/test/app/NetworkID_test.cpp b/src/test/app/NetworkID_test.cpp index 5ac97b8df3..a98fbd6b4f 100644 --- a/src/test/app/NetworkID_test.cpp +++ b/src/test/app/NetworkID_test.cpp @@ -23,7 +23,7 @@ namespace xrpl::test { -class NetworkID_test : public beast::unit_test::suite +class NetworkID_test : public beast::unit_test::Suite { public: void @@ -52,21 +52,21 @@ public: auto const alice = Account{"alice"}; - auto const runTx = [&](test::jtx::Env& env, Json::Value const& jv, TER expectedOutcome) { + auto const runTx = [&](test::jtx::Env& env, json::Value const& jv, TER expectedOutcome) { env.memoize(env.master); env.memoize(alice); // fund alice { - Json::Value jv; + json::Value jv; jv[jss::Account] = env.master.human(); jv[jss::Destination] = alice.human(); jv[jss::TransactionType] = "Payment"; jv[jss::Amount] = "10000000000"; - env(jv, fee(1000), sig(env.master)); + env(jv, Fee(1000), Sig(env.master)); } - env(jv, fee(1000), ter(expectedOutcome)); + env(jv, Fee(1000), Ter(expectedOutcome)); env.close(); }; @@ -76,7 +76,7 @@ public: BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 0); // try to submit a txn without network id, this should work - Json::Value jv; + json::Value jv; jv[jss::Account] = alice.human(); jv[jss::TransactionType] = jss::AccountSet; runTx(env, jv, tesSUCCESS); @@ -99,7 +99,7 @@ public: BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 1024); // try to submit a txn without network id, this should work - Json::Value jv; + json::Value jv; jv[jss::Account] = alice.human(); jv[jss::TransactionType] = jss::AccountSet; runTx(env, jv, tesSUCCESS); @@ -120,7 +120,7 @@ public: { env.fund(XRP(200), alice); // try to submit a txn without network id, this should not work - Json::Value jvn; + json::Value jvn; jvn[jss::Account] = alice.human(); jvn[jss::TransactionType] = jss::AccountSet; jvn[jss::Fee] = to_string(env.current()->fees().base); @@ -135,7 +135,7 @@ public: env.close(); } - Json::Value jv; + json::Value jv; jv[jss::Account] = alice.human(); jv[jss::TransactionType] = jss::AccountSet; diff --git a/src/test/app/NetworkOPs_test.cpp b/src/test/app/NetworkOPs_test.cpp index e6673dc2f5..02667ce275 100644 --- a/src/test/app/NetworkOPs_test.cpp +++ b/src/test/app/NetworkOPs_test.cpp @@ -17,7 +17,7 @@ namespace xrpl::test { -class NetworkOPs_test : public beast::unit_test::suite +class NetworkOPs_test : public beast::unit_test::Suite { public: void @@ -39,16 +39,16 @@ public: using namespace jtx; auto const alice = Account{"alice"}; Env env{ - *this, envconfig(), std::make_unique(&logs), beast::severities::kAll}; + *this, envconfig(), std::make_unique(&logs), beast::severities::KAll}; env.memoize(env.master); env.memoize(alice); - auto const jtx = env.jt(ticket::create(alice, 1), seq(1), fee(10)); + auto const jtx = env.jt(ticket::create(alice, 1), Seq(1), Fee(10)); auto transactionId = jtx.stx->getTransactionID(); env.app().getHashRouter().setFlags(transactionId, HashRouterFlags::HELD); - env(jtx, json(jss::Sequence, 1), ter(terNO_ACCOUNT)); + env(jtx, Json(jss::Sequence, 1), Ter(terNO_ACCOUNT)); env.app().getHashRouter().setFlags(transactionId, HashRouterFlags::BAD); diff --git a/src/test/app/OfferMPT_test.cpp b/src/test/app/OfferMPT_test.cpp index f67c2ce9c2..21ee05289c 100644 --- a/src/test/app/OfferMPT_test.cpp +++ b/src/test/app/OfferMPT_test.cpp @@ -53,7 +53,7 @@ namespace xrpl::test { -class OfferMPT_test : public beast::unit_test::suite +class OfferMPT_test : public beast::unit_test::Suite { static XRPAmount reserve(jtx::Env& env, std::uint32_t count) @@ -94,40 +94,40 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}}); - auto const BTC = + auto const btc = issue2({.env = env, .token = "BTC", .issuer = gw, .holders = {alice, bob, carol}}); - env(pay(gw, alice, BTC(1'000))); + env(pay(gw, alice, btc(1'000))); - env(pay(gw, carol, USD(1'000))); - env(pay(gw, carol, BTC(1'000))); + env(pay(gw, carol, usd(1'000))); + env(pay(gw, carol, btc(1'000))); // Must be two offers at the same quality // "taker gets" must be XRP // (Different amounts, so I can distinguish the offers) - env(offer(carol, BTC(49), XRP(49))); - env(offer(carol, BTC(51), XRP(51))); + env(offer(carol, btc(49), XRP(49))); + env(offer(carol, btc(51), XRP(51))); // Offers for the poor quality path // Must be two offers at the same quality - env(offer(carol, XRP(50), USD(50))); - env(offer(carol, XRP(50), USD(50))); + env(offer(carol, XRP(50), usd(50))); + env(offer(carol, XRP(50), usd(50))); // Offers for the good quality path - env(offer(carol, BTC(1), USD(100))); + env(offer(carol, btc(1), usd(100))); - PathSet const paths(Path(XRP, USD), Path(USD)); + PathSet const paths(TestPath(XRP, usd), TestPath(usd)); - env(pay(alice, bob, USD(100)), - json(paths.json()), - sendmax(BTC(1'000)), - txflags(tfPartialPayment)); + env(pay(alice, bob, usd(100)), + Json(paths.json()), + Sendmax(btc(1'000)), + Txflags(tfPartialPayment)); - env.require(balance(bob, USD(100))); + env.require(Balance(bob, usd(100))); BEAST_EXPECT( - !isOffer(env, carol, BTC(1), USD(100)) && isOffer(env, carol, BTC(49), XRP(49))); + !isOffer(env, carol, btc(1), usd(100)) && isOffer(env, carol, btc(49), XRP(49))); }; testHelper2TokensMix(test); } @@ -146,65 +146,65 @@ public: env.fund(XRP(10'000), alice, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - env(pay(gw, alice, USD(50))); + env(pay(gw, alice, usd(50))); env.close(); auto const offer1Seq = env.seq(alice); - env(offer(alice, XRP(500), USD(100)), require(offers(alice, 1))); + env(offer(alice, XRP(500), usd(100)), Require(offers(alice, 1))); env.close(); - BEAST_EXPECT(isOffer(env, alice, XRP(500), USD(100))); + BEAST_EXPECT(isOffer(env, alice, XRP(500), usd(100))); // cancel the offer above and replace it with a new offer auto const offer2Seq = env.seq(alice); - env(offer(alice, XRP(300), USD(100)), - json(jss::OfferSequence, offer1Seq), - require(offers(alice, 1))); + env(offer(alice, XRP(300), usd(100)), + Json(jss::OfferSequence, offer1Seq), + Require(offers(alice, 1))); env.close(); BEAST_EXPECT( - isOffer(env, alice, XRP(300), USD(100)) && !isOffer(env, alice, XRP(500), USD(100))); + isOffer(env, alice, XRP(300), usd(100)) && !isOffer(env, alice, XRP(500), usd(100))); // Test canceling non-existent offer. // auto const offer3Seq = env.seq (alice); - env(offer(alice, XRP(400), USD(200)), - json(jss::OfferSequence, offer1Seq), - require(offers(alice, 2))); + env(offer(alice, XRP(400), usd(200)), + Json(jss::OfferSequence, offer1Seq), + Require(offers(alice, 2))); env.close(); BEAST_EXPECT( - isOffer(env, alice, XRP(300), USD(100)) && isOffer(env, alice, XRP(400), USD(200))); + isOffer(env, alice, XRP(300), usd(100)) && isOffer(env, alice, XRP(400), usd(200))); // Test cancellation now with OfferCancel tx auto const offer4Seq = env.seq(alice); - env(offer(alice, XRP(222), USD(111)), require(offers(alice, 3))); + env(offer(alice, XRP(222), usd(111)), Require(offers(alice, 3))); env.close(); - BEAST_EXPECT(isOffer(env, alice, XRP(222), USD(111))); - env(offer_cancel(alice, offer4Seq)); + BEAST_EXPECT(isOffer(env, alice, XRP(222), usd(111))); + env(offerCancel(alice, offer4Seq)); env.close(); BEAST_EXPECT(env.seq(alice) == offer4Seq + 2); - BEAST_EXPECT(!isOffer(env, alice, XRP(222), USD(111))); + BEAST_EXPECT(!isOffer(env, alice, XRP(222), usd(111))); // Create an offer that both fails with a tecEXPIRED code and removes // an offer. Show that the attempt to remove the offer fails. env.require(offers(alice, 2)); - env(offer(alice, XRP(5), USD(2)), - json(sfExpiration.fieldName, lastClose(env)), - json(jss::OfferSequence, offer2Seq), - ter(TER{tecEXPIRED})); + env(offer(alice, XRP(5), usd(2)), + Json(sfExpiration.fieldName, lastClose(env)), + Json(jss::OfferSequence, offer2Seq), + Ter(TER{tecEXPIRED})); env.close(); env.require(offers(alice, 2)); - BEAST_EXPECT(isOffer(env, alice, XRP(300), USD(100))); // offer2 - BEAST_EXPECT(!isOffer(env, alice, XRP(5), USD(2))); // expired + BEAST_EXPECT(isOffer(env, alice, XRP(300), usd(100))); // offer2 + BEAST_EXPECT(!isOffer(env, alice, XRP(5), usd(2))); // expired } void @@ -226,33 +226,33 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 400'000'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 400'000'000}); - env(pay(gw, alice, USD(100'000'000))); - env(pay(gw, carol, EUR(100'000'000))); + env(pay(gw, alice, usd(100'000'000))); + env(pay(gw, carol, eur(100'000'000))); // Create more offers than the loop max count in DeliverNodeReverse // Note: the DeliverNodeReverse code has been removed; however since // this is a regression test the original test is being left as-is // for now. for (int i = 0; i < 101; ++i) - env(offer(carol, USD(1'000'000), EUR(2'000'000))); + env(offer(carol, usd(1'000'000), eur(2'000'000))); // Original Offer test sends EUR(10**-81). MPT is integral, // therefore and integral value is sent respecting the exchange // rate. I.e. if EUR(1) is sent then it'll result in USD(0). - env(pay(alice, bob, EUR(2)), path(~EUR), sendmax(USD(100))); + env(pay(alice, bob, eur(2)), Path(~eur), Sendmax(usd(100))); }; testHelper2TokensMix(test); } @@ -291,14 +291,14 @@ public: env.fund(XRP(10'000), alice, bob, carol, dan, erin, gw); env.close(); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol, dan, erin}, .pay = std::nullopt}); - env(pay(gw, carol, USD(99'999))); - env(pay(gw, dan, USD(100'000))); - env(pay(gw, erin, USD(100'000))); + env(pay(gw, carol, usd(99'999))); + env(pay(gw, dan, usd(100'000))); + env(pay(gw, erin, usd(100'000))); env.close(); // Carol doesn't quite have enough funds for this offer @@ -306,10 +306,10 @@ public: // STAmount to incorrectly round to zero when the next offer // (at a good quality) is considered. (when the now removed // stAmountCalcSwitchover2 patch was inactive) - env(offer(carol, drops(1), USD(99'999))); + env(offer(carol, drops(1), usd(99'999))); // Offer at a quality poor enough so when the input xrp is // calculated in the reverse pass, the amount is not zero. - env(offer(dan, XRP(100), USD(1))); + env(offer(dan, XRP(100), usd(1))); env.close(); // This is the funded offer that will be incorrectly removed. @@ -318,18 +318,18 @@ public: // needed for this offer, it will incorrectly compute zero in both // the forward and reverse passes (when the now removed // stAmountCalcSwitchover2 was inactive.) - env(offer(erin, drops(2), USD(100'000))); + env(offer(erin, drops(2), usd(100'000))); - env(pay(alice, bob, USD(100'000)), - path(~USD), - sendmax(XRP(102)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice, bob, usd(100'000)), + Path(~usd), + Sendmax(XRP(102)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.require(offers(carol, 0), offers(dan, 1)); // offer was correctly consumed. There is still some // liquidity left on that offer. - env.require(balance(erin, USD(99'999)), offers(erin, 1)); + env.require(Balance(erin, usd(99'999)), offers(erin, 1)); } void @@ -356,40 +356,40 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); // underfund carol's offer - auto initialCarolUSD = USD(499); + auto initialCarolUSD = usd(499); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100'000))); + env(pay(gw, bob, usd(100'000))); env.close(); // This offer is underfunded - env(offer(carol, drops(1), USD(1'000))); + env(offer(carol, drops(1), usd(1'000))); env.close(); // offer at a lower quality - env(offer(bob, drops(2), USD(1'000), tfPassive)); + env(offer(bob, drops(2), usd(1'000), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); // alice places an offer that crosses carol's; depending on // "crossBothOffers" it may cross bob's as well auto aliceTakerGets = crossBothOffers ? drops(2) : drops(1); - env(offer(alice, USD(1'000), aliceTakerGets)); + env(offer(alice, usd(1'000), aliceTakerGets)); env.close(); env.require( offers(carol, 0), - balance( + Balance( carol, initialCarolUSD)); // offer is removed but not taken if (crossBothOffers) { env.require( - offers(alice, 0), balance(alice, USD(1'000))); // alice's offer is crossed + offers(alice, 0), Balance(alice, usd(1'000))); // alice's offer is crossed } else { env.require( - offers(alice, 1), balance(alice, USD(0))); // alice's offer is not crossed + offers(alice, 1), Balance(alice, usd(0))); // alice's offer is not crossed } } @@ -401,15 +401,15 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); - auto const initialCarolUSD = USD(999); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, carol}}); + auto const initialCarolUSD = usd(999); env(pay(gw, carol, initialCarolUSD)); env.close(); - env(pay(gw, bob, USD(100'000))); + env(pay(gw, bob, usd(100'000))); env.close(); - env(offer(carol, drops(1), USD(1'000))); + env(offer(carol, drops(1), usd(1'000))); env.close(); - env(offer(bob, drops(2), USD(2'000), tfPassive)); + env(offer(bob, drops(2), usd(2'000), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); @@ -418,17 +418,17 @@ public: TER const expectedTer = partialPayment ? TER{tesSUCCESS} : TER{tecPATH_PARTIAL}; - env(pay(alice, bob, USD(5'000)), - path(~USD), - sendmax(XRP(1)), - txflags(flags), - ter(expectedTer)); + env(pay(alice, bob, usd(5'000)), + Path(~usd), + Sendmax(XRP(1)), + Txflags(flags), + Ter(expectedTer)); env.close(); if (expectedTer == tesSUCCESS) { env.require(offers(carol, 0)); - env.require(balance(carol, + env.require(Balance(carol, initialCarolUSD)); // offer is removed but not taken } else @@ -486,57 +486,57 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000'000}); // underfund carol's offer - auto initialCarolUSD = tinyAmount(USD); + auto initialCarolUSD = tinyAmount(usd); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100'000))); - env(pay(gw, alice, EUR(100'000))); + env(pay(gw, bob, usd(100'000))); + env(pay(gw, alice, eur(100'000))); env.close(); // This offer is underfunded - env(offer(carol, EUR(10), USD(10'000))); + env(offer(carol, eur(10), usd(10'000))); env.close(); // offer at a lower quality - env(offer(bob, EUR(10), USD(5'000), tfPassive)); + env(offer(bob, eur(10), usd(5'000), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); // alice places an offer that crosses carol's; depending on // "crossBothOffers" it may cross bob's as well // Whatever - auto aliceTakerGets = crossBothOffers ? EUR(2) : EUR(1); - env(offer(alice, USD(1'000), aliceTakerGets)); + auto aliceTakerGets = crossBothOffers ? eur(2) : eur(1); + env(offer(alice, usd(1'000), aliceTakerGets)); env.close(); // carol's offer can be partially crossed when EUR is IOU: // 10e-3EUR/1USD - using tEUR = std::decay_t; - bool constexpr isEURIOU = std::is_same_v; + using tEUR = std::decay_t; + bool constexpr kIS_EURIOU = std::is_same_v; // partially crossed if IOU, removed but not taken if MPT - auto const balanceCarolUSD = isEURIOU ? USD(0) : initialCarolUSD; + auto const balanceCarolUSD = kIS_EURIOU ? usd(0) : initialCarolUSD; - env.require(offers(carol, 0), balance(carol, balanceCarolUSD)); + env.require(offers(carol, 0), Balance(carol, balanceCarolUSD)); if (crossBothOffers) { env.require( - offers(alice, 0), balance(alice, USD(1'000))); // alice's offer is crossed + offers(alice, 0), Balance(alice, usd(1'000))); // alice's offer is crossed } else { // partially crossed if IOU, not crossed if MPT - auto const balanceAliceUSD = isEURIOU ? USD(1) : USD(0); - env.require(offers(alice, 1), balance(alice, balanceAliceUSD)); + auto const balanceAliceUSD = kIS_EURIOU ? usd(1) : usd(0); + env.require(offers(alice, 1), Balance(alice, balanceAliceUSD)); } } @@ -548,28 +548,28 @@ public: env.fund(XRP(10'000), alice, bob, carol, gw); env.close(); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 100'000'000}); // underfund carol's offer - auto const initialCarolUSD = tinyAmount(USD); + auto const initialCarolUSD = tinyAmount(usd); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100'000))); - env(pay(gw, alice, EUR(100'000))); + env(pay(gw, bob, usd(100'000))); + env(pay(gw, alice, eur(100'000))); env.close(); // This offer is underfunded - env(offer(carol, EUR(10), USD(2'000))); + env(offer(carol, eur(10), usd(2'000))); env.close(); - env(offer(bob, EUR(20), USD(4'000), tfPassive)); + env(offer(bob, eur(20), usd(4'000), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); @@ -578,23 +578,23 @@ public: TER const expectedTer = partialPayment ? TER{tesSUCCESS} : TER{tecPATH_PARTIAL}; - env(pay(alice, bob, USD(5'000)), - path(~USD), - sendmax(EUR(100)), - txflags(flags), - ter(expectedTer)); + env(pay(alice, bob, usd(5'000)), + Path(~usd), + Sendmax(eur(100)), + Txflags(flags), + Ter(expectedTer)); env.close(); if (expectedTer == tesSUCCESS) { // carol's offer can be partially crossed when EUR is IOU: // 10e-3EUR/1USD - using tEUR = std::decay_t; - bool constexpr isEURIOU = std::is_same_v; + using tEUR = std::decay_t; + bool constexpr kIS_EURIOU = std::is_same_v; // partially crossed if IOU, removed but not taken if MPT - auto const balanceCarolUSD = isEURIOU ? USD(0) : initialCarolUSD; + auto const balanceCarolUSD = kIS_EURIOU ? usd(0) : initialCarolUSD; env.require(offers(carol, 0)); - env.require(balance(carol, balanceCarolUSD)); + env.require(Balance(carol, balanceCarolUSD)); } else { @@ -639,14 +639,14 @@ public: env.fund(r + f, alice); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - auto const usdOffer = USD(1'000); + auto const usdOffer = usd(1'000); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tecINSUF_RESERVE_OFFER)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tecINSUF_RESERVE_OFFER)); - env.require(balance(alice, r - f), owners(alice, 1)); + env.require(Balance(alice, r - f), Owners(alice, 1)); } // Partial cross: @@ -661,24 +661,24 @@ public: env.fund(r + f, alice); env.fund(r + 2 * f + xrpOffer, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - auto const usdOffer = USD(1'000); - auto const usdOffer2 = USD(500); + auto const usdOffer = usd(1'000); + auto const usdOffer2 = usd(500); auto const xrpOffer2 = XRP(500); - env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); + env(offer(bob, usdOffer2, xrpOffer2), Ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tesSUCCESS)); env.require( - balance(alice, r - f + xrpOffer2), - balance(alice, usdOffer2), - owners(alice, 1), - balance(bob, r + xrpOffer2), - balance(bob, usdOffer2), - owners(bob, 1)); + Balance(alice, r - f + xrpOffer2), + Balance(alice, usdOffer2), + Owners(alice, 1), + Balance(bob, r + xrpOffer2), + Balance(bob, usdOffer2), + Owners(bob, 1)); } // Account has enough reserve as is, but not enough @@ -694,29 +694,29 @@ public: env.fund(r + f, alice); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - auto const usdOffer = USD(1'000); - auto const usdOffer2 = USD(500); + auto const usdOffer = usd(1'000); + auto const usdOffer2 = usd(500); auto const xrpOffer2 = XRP(500); env.fund(r + f + xrpOffer, bob, carol); - env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); - env(offer(carol, usdOffer, xrpOffer), ter(tesSUCCESS)); + env(offer(bob, usdOffer2, xrpOffer2), Ter(tesSUCCESS)); + env(offer(carol, usdOffer, xrpOffer), Ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tesSUCCESS)); env.require( - balance(alice, r - f + xrpOffer), - balance(alice, USD(0)), - owners(alice, 1), - balance(bob, r + xrpOffer2), - balance(bob, usdOffer2), - owners(bob, 1), - balance(carol, r + xrpOffer2), - balance(carol, usdOffer2), - owners(carol, 2)); + Balance(alice, r - f + xrpOffer), + Balance(alice, usd(0)), + Owners(alice, 1), + Balance(bob, r + xrpOffer2), + Balance(bob, usdOffer2), + Owners(bob, 1), + Balance(carol, r + xrpOffer2), + Balance(carol, usdOffer2), + Owners(carol, 2)); } } @@ -755,50 +755,50 @@ public: env.fund(startBalance, gw, alice, bob); - MPTTester MUSD({.env = env, .issuer = gw}); - MPT const USD = MUSD["USD"]; + MPTTester musd({.env = env, .issuer = gw}); + MPT const usd = musd["USD"]; // bob creates an offer that expires before the next ledger close. - env(offer(bob, USD(500), XRP(500)), - json(sfExpiration.fieldName, lastClose(env) + 1), - ter(tesSUCCESS)); + env(offer(bob, usd(500), XRP(500)), + Json(sfExpiration.fieldName, lastClose(env) + 1), + Ter(tesSUCCESS)); // The offer expires (it's not removed yet). env.close(); - env.require(owners(bob, 1), offers(bob, 1)); + env.require(Owners(bob, 1), offers(bob, 1)); // bob creates the offer that will be crossed. - env(offer(bob, USD(500), XRP(500)), ter(tesSUCCESS)); + env(offer(bob, usd(500), XRP(500)), Ter(tesSUCCESS)); env.close(); - env.require(owners(bob, 2), offers(bob, 2)); + env.require(Owners(bob, 2), offers(bob, 2)); - MUSD.authorize({.account = alice}); - env(pay(gw, alice, USD(1'000)), ter(tesSUCCESS)); + musd.authorize({.account = alice}); + env(pay(gw, alice, usd(1'000)), Ter(tesSUCCESS)); // Order that can't be filled but will remove bob's expired offer: - env(offer(alice, XRP(1'000), USD(1'000)), txflags(tfFillOrKill), ter(tecKILLED)); + env(offer(alice, XRP(1'000), usd(1'000)), Txflags(tfFillOrKill), Ter(tecKILLED)); env.require( - balance(alice, startBalance - (f * 2)), - balance(alice, USD(1'000)), - owners(alice, 1), + Balance(alice, startBalance - (f * 2)), + Balance(alice, usd(1'000)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - (f * 2)), - balance(bob, USD(none)), - owners(bob, 1), + Balance(bob, startBalance - (f * 2)), + Balance(bob, usd(kNONE)), + Owners(bob, 1), offers(bob, 1)); // Order that can be filled - env(offer(alice, XRP(500), USD(500)), txflags(tfFillOrKill), ter(tesSUCCESS)); + env(offer(alice, XRP(500), usd(500)), Txflags(tfFillOrKill), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - (f * 3) + XRP(500)), - balance(alice, USD(500)), - owners(alice, 1), + Balance(alice, startBalance - (f * 3) + XRP(500)), + Balance(alice, usd(500)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - (f * 2) - XRP(500)), - balance(bob, USD(500)), - owners(bob, 1), + Balance(bob, startBalance - (f * 2) - XRP(500)), + Balance(bob, usd(500)), + Owners(bob, 1), offers(bob, 0)); } @@ -811,49 +811,49 @@ public: env.fund(startBalance, gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - env(pay(gw, alice, USD(1'000)), ter(tesSUCCESS)); + env(pay(gw, alice, usd(1'000)), Ter(tesSUCCESS)); // No cross: { - env(offer(alice, XRP(1'000), USD(1000)), - txflags(tfImmediateOrCancel), - ter(tecKILLED)); + env(offer(alice, XRP(1'000), usd(1000)), + Txflags(tfImmediateOrCancel), + Ter(tecKILLED)); } env.require( - balance(alice, startBalance - f - f), - balance(alice, USD(1000)), - owners(alice, 1), + Balance(alice, startBalance - f - f), + Balance(alice, usd(1000)), + Owners(alice, 1), offers(alice, 0)); // Partially cross: - env(offer(bob, USD(50), XRP(50)), ter(tesSUCCESS)); - env(offer(alice, XRP(1000), USD(1000)), txflags(tfImmediateOrCancel), ter(tesSUCCESS)); + env(offer(bob, usd(50), XRP(50)), Ter(tesSUCCESS)); + env(offer(alice, XRP(1000), usd(1000)), Txflags(tfImmediateOrCancel), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f + XRP(50)), - balance(alice, USD(950)), - owners(alice, 1), + Balance(alice, startBalance - f - f - f + XRP(50)), + Balance(alice, usd(950)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - f - XRP(50)), - balance(bob, USD(50)), - owners(bob, 1), + Balance(bob, startBalance - f - XRP(50)), + Balance(bob, usd(50)), + Owners(bob, 1), offers(bob, 0)); // Fully cross: - env(offer(bob, USD(50), XRP(50)), ter(tesSUCCESS)); - env(offer(alice, XRP(50), USD(50)), txflags(tfImmediateOrCancel), ter(tesSUCCESS)); + env(offer(bob, usd(50), XRP(50)), Ter(tesSUCCESS)); + env(offer(alice, XRP(50), usd(50)), Txflags(tfImmediateOrCancel), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f - f + XRP(100)), - balance(alice, USD(900)), - owners(alice, 1), + Balance(alice, startBalance - f - f - f - f + XRP(100)), + Balance(alice, usd(900)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - f - f - XRP(100)), - balance(bob, USD(100)), - owners(bob, 1), + Balance(bob, startBalance - f - f - XRP(100)), + Balance(bob, usd(100)), + Owners(bob, 1), offers(bob, 0)); } @@ -864,12 +864,12 @@ public: env.fund(startBalance, gw, alice, bob); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); - env(pay(gw, bob, USD(1'000))); + env(pay(gw, bob, usd(1'000))); env.close(); - env(offer(alice, USD(1'000), XRP(2'000))); + env(offer(alice, usd(1'000), XRP(2'000))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -878,12 +878,12 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfTakerGets] == XRP(2'000)); - BEAST_EXPECT(offer[sfTakerPays] == USD(1'000)); + BEAST_EXPECT(offer[sfTakerPays] == usd(1'000)); } // bob creates a passive offer that could cross alice's. // bob's offer should stay in the ledger. - env(offer(bob, XRP(2'000), USD(1'000), tfPassive)); + env(offer(bob, XRP(2'000), usd(1'000), tfPassive)); env.close(); env.require(offers(alice, 1)); @@ -892,18 +892,18 @@ public: for (auto const& offerPtr : bobOffers) { auto const& offer = *offerPtr; - BEAST_EXPECT(offer[sfTakerGets] == USD(1'000)); + BEAST_EXPECT(offer[sfTakerGets] == usd(1'000)); BEAST_EXPECT(offer[sfTakerPays] == XRP(2'000)); } // It should be possible for gw to cross both of those offers. - env(offer(gw, XRP(2'000), USD(1'000))); + env(offer(gw, XRP(2'000), usd(1'000))); env.close(); env.require(offers(alice, 0)); env.require(offers(gw, 0)); env.require(offers(bob, 1)); - env(offer(gw, USD(1'000), XRP(2'000))); + env(offer(gw, usd(1'000), XRP(2'000))); env.close(); env.require(offers(bob, 0)); env.require(offers(gw, 0)); @@ -916,13 +916,13 @@ public: env.fund(startBalance, gw, "alice", "bob"); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); - env(pay(gw, "bob", USD(10'000))); - env(offer("alice", USD(5'000), XRP(1'001))); + env(pay(gw, "bob", usd(10'000))); + env(offer("alice", usd(5'000), XRP(1'001))); env.close(); - env(offer("alice", USD(5'000), XRP(1'000))); + env(offer("alice", usd(5'000), XRP(1'000))); env.close(); auto const aliceOffers = offersOnAccount(env, "alice"); @@ -931,7 +931,7 @@ public: // bob creates a passive offer. That offer should cross one // of alice's (the one with better quality) and leave alice's // other offer untouched. - env(offer("bob", XRP(2'000), USD(10'000), tfPassive)); + env(offer("bob", XRP(2'000), usd(10'000), tfPassive)); env.close(); env.require(offers("alice", 1)); @@ -940,7 +940,7 @@ public: for (auto const& offerPtr : bobOffers) { auto const& offer = *offerPtr; - BEAST_EXPECT(offer[sfTakerGets] == USD(4'995)); + BEAST_EXPECT(offer[sfTakerGets] == usd(4'995)); BEAST_EXPECT(offer[sfTakerPays] == XRP(999)); } } @@ -961,28 +961,28 @@ public: env.fund(startBalance, gw, alice); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); // Sell and buy the same asset { // Alice tries an MPT to MPT order: - env(pay(gw, alice, USD(1'000)), ter(tesSUCCESS)); - env(offer(alice, USD(1'000), USD(1'000)), ter(temREDUNDANT)); - env.require(owners(alice, 1), offers(alice, 0)); + env(pay(gw, alice, usd(1'000)), Ter(tesSUCCESS)); + env(offer(alice, usd(1'000), usd(1'000)), Ter(temREDUNDANT)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Offers with negative amounts { - env(offer(alice, -USD(1'000), XRP(1'000)), ter(temBAD_OFFER)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, -usd(1'000), XRP(1'000)), Ter(temBAD_OFFER)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Bad MPT { - auto const BAD = MPT(badMPT()); + auto const bad = MPT(badMPT()); - env(offer(alice, XRP(1'000), BAD(1'000)), ter(temBAD_CURRENCY)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, XRP(1'000), bad(1'000)), Ter(temBAD_CURRENCY)); + env.require(Owners(alice, 1), offers(alice, 0)); } } @@ -1007,59 +1007,59 @@ public: auto const f = env.current()->fees().base; - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - auto const usdOffer = USD(1'000); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + auto const usdOffer = usd(1'000); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); env.close(); env.require( - balance(alice, startBalance - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1)); + Owners(alice, 1)); // Place an offer that should have already expired. env(offer(alice, xrpOffer, usdOffer), - json(sfExpiration.fieldName, lastClose(env)), - ter(TER{tecEXPIRED})); + Json(sfExpiration.fieldName, lastClose(env)), + Ter(TER{tecEXPIRED})); env.require( - balance(alice, startBalance - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1)); + Owners(alice, 1)); env.close(); // Add an offer that expires before the next ledger close env(offer(alice, xrpOffer, usdOffer), - json(sfExpiration.fieldName, lastClose(env) + 1), - ter(tesSUCCESS)); + Json(sfExpiration.fieldName, lastClose(env) + 1), + Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 1), - owners(alice, 2)); + Owners(alice, 2)); // The offer expires (it's not removed yet) env.close(); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 1), - owners(alice, 2)); + Owners(alice, 2)); // Add offer - the expired offer is removed - env(offer(bob, usdOffer, xrpOffer), ter(tesSUCCESS)); + env(offer(bob, usdOffer, xrpOffer), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1), - balance(bob, startBalance - f), - balance(bob, USD(none)), + Owners(alice, 1), + Balance(bob, startBalance - f), + Balance(bob, usd(kNONE)), offers(bob, 1), - owners(bob, 1)); + Owners(bob, 1)); } void @@ -1083,41 +1083,41 @@ public: // Account is at the reserve, and will dip below once // fees are subtracted. env.fund(reserve(env, 0), "alice"); - MPT const USD = MPTTester({.env = env, .issuer = gw}); - auto const usdOffer = USD(1'000); - env(offer("alice", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); - env.require(balance("alice", reserve(env, 0) - f), owners("alice", 0)); + MPT const usd = MPTTester({.env = env, .issuer = gw}); + auto const usdOffer = usd(1'000); + env(offer("alice", usdOffer, xrpOffer), Ter(tecUNFUNDED_OFFER)); + env.require(Balance("alice", reserve(env, 0) - f), Owners("alice", 0)); // Account has just enough for the reserve and the // fee. env.fund(reserve(env, 0) + f, "bob"); - env(offer("bob", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); - env.require(balance("bob", reserve(env, 0)), owners("bob", 0)); + env(offer("bob", usdOffer, xrpOffer), Ter(tecUNFUNDED_OFFER)); + env.require(Balance("bob", reserve(env, 0)), Owners("bob", 0)); // Account has enough for the reserve, the fee and // the offer, and a bit more, but not enough for the // reserve after the offer is placed. env.fund(reserve(env, 0) + f + XRP(1), "carol"); - env(offer("carol", usdOffer, xrpOffer), ter(tecINSUF_RESERVE_OFFER)); - env.require(balance("carol", reserve(env, 0) + XRP(1)), owners("carol", 0)); + env(offer("carol", usdOffer, xrpOffer), Ter(tecINSUF_RESERVE_OFFER)); + env.require(Balance("carol", reserve(env, 0) + XRP(1)), Owners("carol", 0)); // Account has enough for the reserve plus one // offer, and the fee. env.fund(reserve(env, 1) + f, "dan"); - env(offer("dan", usdOffer, xrpOffer), ter(tesSUCCESS)); - env.require(balance("dan", reserve(env, 1)), owners("dan", 1)); + env(offer("dan", usdOffer, xrpOffer), Ter(tesSUCCESS)); + env.require(Balance("dan", reserve(env, 1)), Owners("dan", 1)); // Account has enough for the reserve plus one // offer, the fee and the entire offer amount. env.fund(reserve(env, 1) + f + xrpOffer, "eve"); - env(offer("eve", usdOffer, xrpOffer), ter(tesSUCCESS)); - env.require(balance("eve", reserve(env, 1) + xrpOffer), owners("eve", 1)); + env(offer("eve", usdOffer, xrpOffer), Ter(tesSUCCESS)); + env.require(Balance("eve", reserve(env, 1) + xrpOffer), Owners("eve", 1)); } void - testSelfCross(bool use_partner, FeatureBitset features) + testSelfCross(bool usePartner, FeatureBitset features) { - testcase(std::string("Self-crossing") + (use_partner ? ", with partner account" : "")); + testcase(std::string("Self-crossing") + (usePartner ? ", with partner account" : "")); using namespace jtx; auto const gw = Account{"gateway"}; @@ -1128,70 +1128,70 @@ public: env.close(); env.fund(XRP(10'000), gw); - auto const USD = issue1({.env = env, .token = "USD", .issuer = gw}); - auto const BTC = issue2({.env = env, .token = "BTC", .issuer = gw}); - using tUSD = std::decay_t; - using tBTC = std::decay_t; - if (use_partner) + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw}); + auto const btc = issue2({.env = env, .token = "BTC", .issuer = gw}); + using tUSD = std::decay_t; + using tBTC = std::decay_t; + if (usePartner) { env.fund(XRP(10'000), partner); if constexpr (std::is_same_v) { - env(trust(partner, USD(100))); + env(trust(partner, usd(100))); } else { - MPTTester MUSD(env, gw, USD); - MUSD.authorize({.account = partner}); + MPTTester musd(env, gw, usd); + musd.authorize({.account = partner}); } if constexpr (std::is_same_v) { - env(trust(partner, BTC(500))); + env(trust(partner, btc(500))); } else { - MPTTester MBTC(env, gw, BTC); - MBTC.authorize({.account = partner}); + MPTTester mbtc(env, gw, btc); + mbtc.authorize({.account = partner}); } - env(pay(gw, partner, USD(100))); - env(pay(gw, partner, BTC(500))); + env(pay(gw, partner, usd(100))); + env(pay(gw, partner, btc(500))); } - auto const& account_to_test = use_partner ? partner : gw; + auto const& accountToTest = usePartner ? partner : gw; env.close(); - env.require(offers(account_to_test, 0)); + env.require(offers(accountToTest, 0)); // PART 1: // we will make two offers that can be used to bridge BTC to USD // through XRP - env(offer(account_to_test, BTC(250), XRP(1'000))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, btc(250), XRP(1'000))); + env.require(offers(accountToTest, 1)); // validate that the book now shows a BTC for XRP offer - BEAST_EXPECT(isOffer(env, account_to_test, BTC(250), XRP(1'000))); + BEAST_EXPECT(isOffer(env, accountToTest, btc(250), XRP(1'000))); - auto const secondLegSeq = env.seq(account_to_test); - env(offer(account_to_test, XRP(1'000), USD(50))); - env.require(offers(account_to_test, 2)); + auto const secondLegSeq = env.seq(accountToTest); + env(offer(accountToTest, XRP(1'000), usd(50))); + env.require(offers(accountToTest, 2)); // validate that the book also shows a XRP for USD offer - BEAST_EXPECT(isOffer(env, account_to_test, XRP(1'000), USD(50))); + BEAST_EXPECT(isOffer(env, accountToTest, XRP(1'000), usd(50))); // now make an offer that will cross and auto-bridge, meaning // the outstanding offers will be taken leaving us with none - env(offer(account_to_test, USD(50), BTC(250))); + env(offer(accountToTest, usd(50), btc(250))); - auto jrr = getBookOffers(env, USD, BTC); + auto jrr = getBookOffers(env, usd, btc); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); - jrr = getBookOffers(env, BTC, XRP); + jrr = getBookOffers(env, btc, XRP); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); // At this point, all offers are expected to be consumed. { - auto acctOffers = offersOnAccount(env, account_to_test); + auto acctOffers = offersOnAccount(env, accountToTest); // No stale offers BEAST_EXPECT(acctOffers.empty()); @@ -1199,7 +1199,7 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(0)); + BEAST_EXPECT(offer[sfTakerGets] == usd(0)); BEAST_EXPECT(offer[sfTakerPays] == XRP(0)); } } @@ -1207,35 +1207,35 @@ public: // cancel that lingering second offer so that it doesn't interfere // with the next set of offers we test. This will not be needed once // the bridging bug is fixed - env(offer_cancel(account_to_test, secondLegSeq)); - env.require(offers(account_to_test, 0)); + env(offerCancel(accountToTest, secondLegSeq)); + env.require(offers(accountToTest, 0)); // PART 2: // simple direct crossing BTC to USD and then USD to BTC which // causes the first offer to be replaced - env(offer(account_to_test, BTC(250), USD(50))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, btc(250), usd(50))); + env.require(offers(accountToTest, 1)); // validate that the book shows one BTC for USD offer and no USD for // BTC offers - BEAST_EXPECT(isOffer(env, account_to_test, BTC(250), USD(50))); + BEAST_EXPECT(isOffer(env, accountToTest, btc(250), usd(50))); - jrr = getBookOffers(env, USD, BTC); + jrr = getBookOffers(env, usd, btc); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); // this second offer would self-cross directly, so it causes the // first offer by the same owner/taker to be removed - env(offer(account_to_test, USD(50), BTC(250))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, usd(50), btc(250))); + env.require(offers(accountToTest, 1)); // validate that we now have just the second offer...the first // was removed - jrr = getBookOffers(env, BTC, USD); + jrr = getBookOffers(env, btc, usd); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); - BEAST_EXPECT(isOffer(env, account_to_test, USD(50), BTC(250))); + BEAST_EXPECT(isOffer(env, accountToTest, usd(50), btc(250))); }; testHelper2TokensMix(test); } @@ -1258,55 +1258,55 @@ public: // these *interesting* amounts were taken // from the original JS test that was ported here - auto const gw_initial_balance = drops(1'149'999'730); - auto const alice_initial_balance = drops(499'946'999'680); - auto const bob_initial_balance = drops(10'199'999'920); + auto const gwInitialBalance = drops(1'149'999'730); + auto const aliceInitialBalance = drops(499'946'999'680); + auto const bobInitialBalance = drops(10'199'999'920); - env.fund(gw_initial_balance, gw); - env.fund(alice_initial_balance, alice); - env.fund(bob_initial_balance, bob); + env.fund(gwInitialBalance, gw); + env.fund(aliceInitialBalance, alice); + env.fund(bobInitialBalance, bob); - MPTTester const MUSD( + MPTTester const musd( {.env = env, .issuer = gw, .holders = {alice, bob}, .transferFee = 5'000}); - MPT const USD = MUSD; - auto const small_amount = STAmount{USD, 1}; + MPT const usd = musd; + auto const smallAmount = STAmount{usd, 1}; - env(pay(gw, alice, USD(50))); - env(pay(gw, bob, small_amount)); + env(pay(gw, alice, usd(50))); + env(pay(gw, bob, smallAmount)); - env(offer(alice, USD(50), XRP(150'000))); + env(offer(alice, usd(50), XRP(150'000))); // unfund the offer - env(pay(alice, gw, USD(50))); + env(pay(alice, gw, usd(50))); // verify balances - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); // this represents 0 since MPTAmount is a default field BEAST_EXPECT(!jrr[jss::node].isMember(sfMPTAmount.fieldName)); - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "1"); // create crossing offer std::uint32_t const bobOfferSeq = env.seq(bob); - env(offer(bob, XRP(2000), USD(1))); + env(offer(bob, XRP(2000), usd(1))); // With the rounding introduced by fixReducedOffersV2, bob's // offer does not cross alice's offer and goes straight into // the ledger. - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "1"); - Json::Value const bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq)[jss::node]; + json::Value const bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq)[jss::node]; BEAST_EXPECT(bobOffer[sfTakerGets.jsonName][jss::value] == "1"); BEAST_EXPECT(bobOffer[sfTakerPays.jsonName] == "2000000000"); } void - testOfferCrossWithXRP(bool reverse_order, FeatureBitset features) + testOfferCrossWithXRP(bool reverseOrder, FeatureBitset features) { testcase( - std::string("Offer Crossing with XRP, ") + (reverse_order ? "Reverse" : "Normal") + + std::string("Offer Crossing with XRP, ") + (reverseOrder ? "Reverse" : "Normal") + " order"); using namespace jtx; @@ -1319,38 +1319,38 @@ public: env.fund(XRP(10'000), gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(500))); + env(pay(gw, alice, usd(500))); - if (reverse_order) - env(offer(bob, USD(1), XRP(4'000))); + if (reverseOrder) + env(offer(bob, usd(1), XRP(4'000))); - env(offer(alice, XRP(150'000), USD(50))); + env(offer(alice, XRP(150'000), usd(50))); - if (!reverse_order) - env(offer(bob, USD(1), XRP(4000))); + if (!reverseOrder) + env(offer(bob, usd(1), XRP(4000))); // Existing offer pays better than this wants. // Fully consume existing offer. // Pay 1 USD, get 4000 XRP. - auto jrr = ledgerEntryMPT(env, bob, USD); + auto jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "1"); jrr = ledgerEntryRoot(env, bob); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string( - (XRP(10000) - XRP(reverse_order ? 4000 : 3000) - env.current()->fees().base * 2) + (XRP(10000) - XRP(reverseOrder ? 4000 : 3000) - env.current()->fees().base * 2) .xrp())); - jrr = ledgerEntryMPT(env, alice, USD); + jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "499"); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string( - (XRP(10000) + XRP(reverse_order ? 4000 : 3000) - env.current()->fees().base * 2) + (XRP(10000) + XRP(reverseOrder ? 4000 : 3000) - env.current()->fees().base * 2) .xrp())); } @@ -1369,21 +1369,21 @@ public: env.fund(XRP(100000), gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - env(pay(gw, alice, USD(500))); + env(pay(gw, alice, usd(500))); - env(offer(alice, XRP(150'000), USD(50))); - env(offer(bob, USD(1), XRP(3'000))); + env(offer(alice, XRP(150'000), usd(50))); + env(offer(bob, usd(1), XRP(3'000))); - auto jrr = ledgerEntryMPT(env, bob, USD); + auto jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "1"); jrr = ledgerEntryRoot(env, bob); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string((XRP(100'000) - XRP(3'000) - env.current()->fees().base * 1).xrp())); - jrr = ledgerEntryMPT(env, alice, USD); + jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "499"); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( @@ -1400,13 +1400,13 @@ public: Env env{*this, features}; - MPT const USD = MPTTester({.env = env, .issuer = env.master}); + MPT const usd = MPTTester({.env = env, .issuer = env.master}); auto const nextOfferSeq = env.seq(env.master); - env(offer(env.master, XRP(500), USD(100))); + env(offer(env.master, XRP(500), usd(100))); env.close(); - env(offer_cancel(env.master, nextOfferSeq)); + env(offerCancel(env.master, nextOfferSeq)); BEAST_EXPECT(env.seq(env.master) == nextOfferSeq + 2); // ledger_accept, call twice and verify no odd behavior @@ -1429,37 +1429,38 @@ public: auto const bob = Account{"bob"}; env.fund(XRP(10'000), gw, alice, bob); - env.require(owners(bob, 0)); + env.require(Owners(bob, 0)); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice, 1), Owners(bob, 1)); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(100), XRP(500))); + env(offer(bob, usd(100), XRP(500))); - env.require(owners(alice, 1), owners(bob, 2)); + env.require(Owners(alice, 1), Owners(bob, 2)); auto jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(500).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(100).value().getJson(JsonOptions::none)); + BEAST_EXPECT( + jro[jss::node][jss::TakerPays] == usd(100).value().getJson(JsonOptions::KNone)); - env(pay(alice, alice, XRP(500)), sendmax(USD(100))); + env(pay(alice, alice, XRP(500)), Sendmax(usd(100))); - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(!jrr[jss::node].isMember(sfMPTAmount.fieldName)); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string((XRP(10'000) + XRP(500) - env.current()->fees().base * 2).xrp())); - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "100"); jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::error] == "entryNotFound"); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice, 1), Owners(bob, 1)); } void @@ -1477,17 +1478,17 @@ public: env.fund(XRP(10'000), alice, bob, carol); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = alice, .holders = {bob}}); - auto const EURC = + auto const eurc = issue2({.env = env, .token = "EUC", .issuer = carol, .holders = {alice}}); - auto const EURB = + auto const eurb = issue3({.env = env, .token = "EUB", .issuer = bob, .holders = {carol}}); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(50), EURC(200)), ter(tecUNFUNDED_OFFER)); + env(offer(bob, usd(50), eurc(200)), Ter(tecUNFUNDED_OFFER)); - env(offer(alice, EURC(200), USD(50))); + env(offer(alice, eurc(200), usd(50))); auto jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::error] == "entryNotFound"); @@ -1510,23 +1511,23 @@ public: env.fund(XRP(10'000), gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(100), XRP(500))); + env(offer(bob, usd(100), XRP(500))); - env(pay(alice, alice, XRP(200)), sendmax(USD(100))); + env(pay(alice, alice, XRP(200)), Sendmax(usd(100))); // The previous payment reduced the remaining offer amount by 200 XRP auto jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(300).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(60).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerPays] == usd(60).value().getJson(JsonOptions::KNone)); // the balance between alice and gw is 160 USD..200 less the 40 taken // by the offer - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "160"); // alice now has 200 more XRP from the payment jrr = ledgerEntryRoot(env, alice); @@ -1535,16 +1536,16 @@ public: to_string((XRP(10'000) + XRP(200) - env.current()->fees().base * 2).xrp())); // bob got 40 USD from partial consumption of the offer - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "40"); // Alice converts USD to XRP which should fail // due to PartialPayment. - env(pay(alice, alice, XRP(600)), sendmax(USD(100)), ter(tecPATH_PARTIAL)); + env(pay(alice, alice, XRP(600)), Sendmax(usd(100)), Ter(tecPATH_PARTIAL)); // Alice converts USD to XRP, should succeed because // we permit partial payment - env(pay(alice, alice, XRP(600)), sendmax(USD(100)), txflags(tfPartialPayment)); + env(pay(alice, alice, XRP(600)), Sendmax(usd(100)), Txflags(tfPartialPayment)); // Verify the offer was consumed jro = ledgerEntryOffer(env, bob, bobOfferSeq); @@ -1555,7 +1556,7 @@ public: // that remained in the offer from bob. The alice balance is now // 100 USD because another 60 USD were transferred to bob in the second // payment - jrr = ledgerEntryMPT(env, alice, USD); + jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "100"); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( @@ -1564,7 +1565,7 @@ public: // bob now has 100 USD - 40 from the first payment and 60 from the // second (partial) payment - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "100"); } @@ -1584,23 +1585,23 @@ public: env.fund(XRP(10'000), gw, alice, bob, carol); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {carol, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {carol, bob}}); - env(pay(gw, carol, USD(500))); + env(pay(gw, carol, usd(500))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, XRP(500), USD(50))); + env(offer(carol, XRP(500), usd(50))); - env(pay(alice, bob, USD(25)), sendmax(XRP(333))); + env(pay(alice, bob, usd(25)), Sendmax(XRP(333))); - auto jrr = ledgerEntryMPT(env, bob, USD); + auto jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "25"); - jrr = ledgerEntryMPT(env, carol, USD); + jrr = ledgerEntryMPT(env, carol, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "475"); auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); - BEAST_EXPECT(jro[jss::node][jss::TakerGets] == USD(25).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerGets] == usd(25).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(jro[jss::node][jss::TakerPays] == XRP(250).value().getText()); } @@ -1620,19 +1621,19 @@ public: env.fund(XRP(10'000), gw, alice, bob, carol); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, carol}}); - env(pay(gw, alice, USD(500))); + env(pay(gw, alice, usd(500))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, USD(50), XRP(500))); + env(offer(carol, usd(50), XRP(500))); - env(pay(alice, bob, XRP(250)), sendmax(USD(333))); + env(pay(alice, bob, XRP(250)), Sendmax(usd(333))); - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "475"); - jrr = ledgerEntryMPT(env, carol, USD); + jrr = ledgerEntryMPT(env, carol, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "25"); jrr = ledgerEntryRoot(env, bob); @@ -1642,7 +1643,7 @@ public: auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(250).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(25).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerPays] == usd(25).value().getJson(JsonOptions::KNone)); } void @@ -1663,37 +1664,37 @@ public: env.fund(XRP(10'000), gw1, gw2, alice, bob, carol, dan); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw1, .holders = {alice, carol}}); - auto const EUR = + auto const eur = issue1({.env = env, .token = "EUR", .issuer = gw2, .holders = {bob, dan}}); - env(pay(gw1, alice, USD(500))); - env(pay(gw2, dan, EUR(400))); + env(pay(gw1, alice, usd(500))); + env(pay(gw2, dan, eur(400))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, USD(50), XRP(500))); + env(offer(carol, usd(50), XRP(500))); auto const danOfferSeq = env.seq(dan); - env(offer(dan, XRP(500), EUR(50))); + env(offer(dan, XRP(500), eur(50))); - Json::Value jtp{Json::arrayValue}; + json::Value jtp{json::ArrayValue}; jtp[0u][0u][jss::currency] = "XRP"; - env(pay(alice, bob, EUR(30)), json(jss::Paths, jtp), sendmax(USD(333))); + env(pay(alice, bob, eur(30)), Json(jss::Paths, jtp), Sendmax(usd(333))); - BEAST_EXPECT(env.balance(alice, USD) == USD(470)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(30)); - BEAST_EXPECT(env.balance(carol, USD) == USD(30)); - BEAST_EXPECT(env.balance(dan, EUR) == EUR(370)); + BEAST_EXPECT(env.balance(alice, usd) == usd(470)); + BEAST_EXPECT(env.balance(bob, eur) == eur(30)); + BEAST_EXPECT(env.balance(carol, usd) == usd(30)); + BEAST_EXPECT(env.balance(dan, eur) == eur(370)); auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(200).value().getText()); BEAST_EXPECT( - jro[jss::node][jss::TakerPays] == USD(20).value().getJson(JsonOptions::none)); + jro[jss::node][jss::TakerPays] == usd(20).value().getJson(JsonOptions::KNone)); jro = ledgerEntryOffer(env, dan, danOfferSeq); BEAST_EXPECT( - jro[jss::node][jss::TakerGets] == EUR(20).value().getJson(JsonOptions::none)); + jro[jss::node][jss::TakerGets] == eur(20).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(jro[jss::node][jss::TakerPays] == XRP(200).value().getText()); }; testHelper2TokensMix(test); @@ -1719,18 +1720,18 @@ public: env.fund(XRP(100'000'000), alice, bob, carol, gw); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice, carol}}); - auto const EUR = issue1({.env = env, .token = "EUR", .issuer = gw, .holders = {bob}}); + auto const eur = issue1({.env = env, .token = "EUR", .issuer = gw, .holders = {bob}}); - env(pay(gw, alice, USD(10))); - env(pay(gw, carol, USD(3))); + env(pay(gw, alice, usd(10))); + env(pay(gw, carol, usd(3))); - env(offer(alice, EUR(2), XRP(1))); - env(offer(alice, EUR(2), XRP(1))); + env(offer(alice, eur(2), XRP(1))); + env(offer(alice, eur(2), XRP(1))); - env(offer(alice, XRP(1), USD(4))); - env(offer(carol, XRP(1), USD(3))); + env(offer(alice, XRP(1), usd(4))); + env(offer(carol, XRP(1), usd(3))); env.close(); // Bob offers to buy 10 USD for 10 EUR. @@ -1742,26 +1743,26 @@ public: // The key for this test is that Alice's XRP->USD leg goes dry // before Alice's EUR->XRP. The XRP->USD leg is the second leg // which showed some sensitivity. - env(pay(gw, bob, EUR(10))); + env(pay(gw, bob, eur(10))); env.close(); - env(offer(bob, USD(10), EUR(10))); + env(offer(bob, usd(10), eur(10))); env.close(); - env.require(balance(bob, USD(7))); - env.require(balance(bob, EUR(6))); + env.require(Balance(bob, usd(7))); + env.require(Balance(bob, eur(6))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(6))); - env.require(balance(alice, EUR(4))); + env.require(Balance(alice, usd(6))); + env.require(Balance(alice, eur(4))); env.require(offers(alice, 0)); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); - env.require(balance(carol, USD(0))); - env.require(balance(carol, EUR(none))); + env.require(Balance(carol, usd(0))); + env.require(Balance(carol, eur(kNONE))); env.require(offers(carol, 0)); - env.require(owners(carol, 1)); + env.require(Owners(carol, 1)); }; testHelper2TokensMix(test); } @@ -1787,29 +1788,29 @@ public: // 1 for each trust limit == 3 (alice < mtgox/amazon/bitstamp) + // 1 for payment == 4 auto const base = env.current()->fees().base; - auto const starting_xrp = XRP(100) + env.current()->fees().accountReserve(3) + base * 4; + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(3) + base * 4; - env.fund(starting_xrp, gw1, gw2, gw3, alice, bob); + env.fund(startingXrp, gw1, gw2, gw3, alice, bob); env.close(); - auto const USD1 = + auto const usD1 = issue1({.env = env, .token = "US1", .issuer = gw1, .holders = {alice, bob}}); - auto const USD2 = + auto const usD2 = issue2({.env = env, .token = "US2", .issuer = gw2, .holders = {alice, bob}}); - auto const USD3 = + auto const usD3 = issue3({.env = env, .token = "US3", .issuer = gw3, .holders = {alice}}); - env(pay(gw1, bob, USD1(500))); + env(pay(gw1, bob, usD1(500))); - env(offer(bob, XRP(200), USD1(200))); + env(offer(bob, XRP(200), usD1(200))); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 // available. Ask for more than available to prove reserve works. - env(offer(alice, USD1(200), XRP(200))); + env(offer(alice, usD1(200), XRP(200))); - BEAST_EXPECT(env.balance(alice, USD1) == USD1(100)); + BEAST_EXPECT(env.balance(alice, usD1) == usD1(100)); BEAST_EXPECT(env.balance(alice) == STAmount(env.current()->fees().accountReserve(3))); - BEAST_EXPECT(env.balance(bob, USD1) == USD1(400)); + BEAST_EXPECT(env.balance(bob, usD1) == usD1(400)); }; testHelper3TokensMix(test); } @@ -1830,18 +1831,18 @@ public: env.fund(XRP(10'000), gw, alice, bob); - MPT const CUR = + MPT const cur = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .transferFee = 5'000}); - env(pay(gw, bob, CUR(100))); + env(pay(gw, bob, cur(100))); - env(offer(alice, CUR(50'000), XRP(150'000))); - env(offer(bob, XRP(100), CUR(100))); + env(offer(alice, cur(50'000), XRP(150'000))); + env(offer(bob, XRP(100), cur(100))); - auto jrr = ledgerEntryMPT(env, alice, CUR); + auto jrr = ledgerEntryMPT(env, alice, cur); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "34"); - jrr = ledgerEntryMPT(env, bob, CUR); + jrr = ledgerEntryMPT(env, bob, cur); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "64"); } @@ -1858,29 +1859,29 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, bob, USD(500))); + env(pay(gw, bob, usd(500))); - env(offer(bob, XRP(200), USD(200)), json(jss::Flags, tfSell)); + env(offer(bob, XRP(200), usd(200)), Json(jss::Flags, tfSell)); // Alice has 350 + fees - a reserve of 50 = 250 reserve = 100 available. // Alice has 350 + fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. - env(offer(alice, USD(200), XRP(200)), json(jss::Flags, tfSell)); + env(offer(alice, usd(200), XRP(200)), Json(jss::Flags, tfSell)); - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "100"); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == STAmount(env.current()->fees().accountReserve(1)).getText()); - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "400"); } @@ -1897,31 +1898,31 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, bob, USD(500))); + env(pay(gw, bob, usd(500))); - env(offer(bob, XRP(100), USD(200))); + env(offer(bob, XRP(100), usd(200))); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. // Taker pays 100 USD for 100 XRP. // Selling XRP. // Will sell all 100 XRP and get more USD than asked for. - env(offer(alice, USD(100), XRP(100)), json(jss::Flags, tfSell)); + env(offer(alice, usd(100), XRP(100)), Json(jss::Flags, tfSell)); - auto jrr = ledgerEntryMPT(env, alice, USD); + auto jrr = ledgerEntryMPT(env, alice, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "200"); jrr = ledgerEntryRoot(env, alice); BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == STAmount(env.current()->fees().accountReserve(1)).getText()); - jrr = ledgerEntryMPT(env, bob, USD); + jrr = ledgerEntryMPT(env, bob, usd); BEAST_EXPECT(jrr[jss::node][sfMPTAmount.fieldName] == "300"); } @@ -1939,37 +1940,37 @@ public: Env env{*this, features}; auto const base = env.current()->fees().base; - auto const starting_xrp = + auto const startingXrp = XRP(100.1) + env.current()->fees().accountReserve(1) + base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); env.close(); - auto const XTS = + auto const xts = issue1({.env = env, .token = "XTS", .issuer = gw, .holders = {alice, bob}}); - auto const XXX = + auto const xxx = issue2({.env = env, .token = "XXX", .issuer = gw, .holders = {alice, bob}}); env.close(); - env(pay(gw, alice, XTS(1'000))); - env(pay(gw, alice, XXX(100))); - env(pay(gw, bob, XTS(1'000))); - env(pay(gw, bob, XXX(100))); + env(pay(gw, alice, xts(1'000))); + env(pay(gw, alice, xxx(100))); + env(pay(gw, bob, xts(1'000))); + env(pay(gw, bob, xxx(100))); - env(offer(alice, XTS(1'000), XXX(100))); + env(offer(alice, xts(1'000), xxx(100))); // WS client is used here because the RPC client could not // be convinced to pass the build_path argument auto wsc = makeWSClient(env.app().config()); - Json::Value payment; + json::Value payment; payment[jss::secret] = toBase58(generateSeed("bob")); payment[jss::id] = env.seq(bob); payment[jss::build_path] = true; - payment[jss::tx_json] = pay(bob, bob, XXX(1)); + payment[jss::tx_json] = pay(bob, bob, xxx(1)); payment[jss::tx_json][jss::Sequence] = env.current()->read(keylet::account(bob.id()))->getFieldU32(sfSequence); payment[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); - payment[jss::tx_json][jss::SendMax] = XTS(15).value().getJson(JsonOptions::none); + payment[jss::tx_json][jss::SendMax] = xts(15).value().getJson(JsonOptions::KNone); auto jrr = wsc->invoke("submit", payment); BEAST_EXPECT(jrr[jss::status] == "success"); BEAST_EXPECT(jrr[jss::result][jss::engine_result] == "tesSUCCESS"); @@ -1980,11 +1981,11 @@ public: BEAST_EXPECT(jrr.isMember(jss::id) && jrr[jss::id] == 5); } - BEAST_EXPECT(env.balance(alice, XTS) == XTS(1010)); - BEAST_EXPECT(env.balance(alice, XXX) == XXX(99)); + BEAST_EXPECT(env.balance(alice, xts) == xts(1010)); + BEAST_EXPECT(env.balance(alice, xxx) == xxx(99)); - BEAST_EXPECT(env.balance(bob, XTS) == XTS(990)); - BEAST_EXPECT(env.balance(bob, XXX) == XXX(101)); + BEAST_EXPECT(env.balance(bob, xts) == xts(990)); + BEAST_EXPECT(env.balance(bob, xxx) == xxx(101)); }; testHelper2TokensMix(test); } @@ -2006,20 +2007,20 @@ public: env.fund(XRP(10'000'000), gw); env.close(); - auto MUSD = MPTTester({.env = env, .issuer = gw}); - MPT const USD = MUSD; + auto musd = MPTTester({.env = env, .issuer = gw}); + MPT const usd = musd; // The fee that's charged for transactions auto const f = env.current()->fees().base; // To keep things simple all offers are 1 : 1 for XRP : USD. - enum class preAuthType { noPreAuth, acctPreAuth }; + enum class PreAuthType { NoPreAuth, AcctPreAuth }; struct TestData { std::string account; // Account operated on STAmount fundXrp; // Account funded with int bookAmount; // USD -> XRP offer on the books - preAuthType preAuth; // If true, pre-auth MPToken + PreAuthType preAuth; // If true, pre-auth MPToken int offerAmount; // Account offers this much XRP -> USD TER tec; // Returned tec code STAmount spentXrp; // Amount removed from fundXrp @@ -2032,37 +2033,37 @@ public: // clang-format off TestData const tests[]{ // acct fundXrp bookAmt preTrust offerAmt tec spentXrp balanceUSD offers owners scale - {.account="ann", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account is at the reserve, and will dip below once fees are subtracted. - {.account="bev", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account has just enough for the reserve and the fee. - {.account="cam", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed. - {.account="deb", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=USD( 1), .offers=0, .owners=1, .scale=100000}, // Account has enough to buy a little USD then the offer runs dry. - {.account="eve", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=USD( 0), .offers=1, .owners=1}, // No offer to cross - {.account="flo", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="gay", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1000, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 50) + f, .balanceUsd=USD( 50), .offers=0, .owners=1}, - {.account="hye", .fundXrp=XRP(1000) + 1 * f, .bookAmount=1000, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 800) + f, .balanceUsd=USD( 800), .offers=0, .owners=1}, - {.account="ivy", .fundXrp=XRP( 1) + reserve(env, 1) + 1 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="joy", .fundXrp=XRP( 1) + reserve(env, 2) + 1 * f, .bookAmount=1, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=1, .owners=2}, - {.account="kim", .fundXrp=XRP( 900) + reserve(env, 2) + 1 * f, .bookAmount=999, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="liz", .fundXrp=XRP( 998) + reserve(env, 0) + 1 * f, .bookAmount=999, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 998) + f, .balanceUsd=USD( 998), .offers=0, .owners=1}, - {.account="meg", .fundXrp=XRP( 998) + reserve(env, 1) + 1 * f, .bookAmount=999, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="nia", .fundXrp=XRP( 998) + reserve(env, 2) + 1 * f, .bookAmount=999, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=1, .owners=2}, - {.account="ova", .fundXrp=XRP( 999) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="pam", .fundXrp=XRP( 999) + reserve(env, 1) + 1 * f, .bookAmount=1000, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=USD( 1000), .offers=0, .owners=1}, - {.account="rae", .fundXrp=XRP( 999) + reserve(env, 2) + 1 * f, .bookAmount=1000, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=USD( 1000), .offers=0, .owners=1}, - {.account="sue", .fundXrp=XRP(1000) + reserve(env, 2) + 1 * f, .bookAmount=0, .preAuth=preAuthType::noPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=USD( 0), .offers=1, .owners=1}, + {.account="ann", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account is at the reserve, and will dip below once fees are subtracted. + {.account="bev", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account has just enough for the reserve and the fee. + {.account="cam", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed. + {.account="deb", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=usd( 1), .offers=0, .owners=1, .scale=100000}, // Account has enough to buy a little USD then the offer runs dry. + {.account="eve", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=usd( 0), .offers=1, .owners=1}, // No offer to cross + {.account="flo", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="gay", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1000, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 50) + f, .balanceUsd=usd( 50), .offers=0, .owners=1}, + {.account="hye", .fundXrp=XRP(1000) + 1 * f, .bookAmount=1000, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 800) + f, .balanceUsd=usd( 800), .offers=0, .owners=1}, + {.account="ivy", .fundXrp=XRP( 1) + reserve(env, 1) + 1 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="joy", .fundXrp=XRP( 1) + reserve(env, 2) + 1 * f, .bookAmount=1, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=1, .owners=2}, + {.account="kim", .fundXrp=XRP( 900) + reserve(env, 2) + 1 * f, .bookAmount=999, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="liz", .fundXrp=XRP( 998) + reserve(env, 0) + 1 * f, .bookAmount=999, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 998) + f, .balanceUsd=usd( 998), .offers=0, .owners=1}, + {.account="meg", .fundXrp=XRP( 998) + reserve(env, 1) + 1 * f, .bookAmount=999, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="nia", .fundXrp=XRP( 998) + reserve(env, 2) + 1 * f, .bookAmount=999, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=1, .owners=2}, + {.account="ova", .fundXrp=XRP( 999) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="pam", .fundXrp=XRP( 999) + reserve(env, 1) + 1 * f, .bookAmount=1000, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=usd( 1000), .offers=0, .owners=1}, + {.account="rae", .fundXrp=XRP( 999) + reserve(env, 2) + 1 * f, .bookAmount=1000, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=usd( 1000), .offers=0, .owners=1}, + {.account="sue", .fundXrp=XRP(1000) + reserve(env, 2) + 1 * f, .bookAmount=0, .preAuth=PreAuthType::NoPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=usd( 0), .offers=1, .owners=1}, //---------------- Pre-created MPT --------------------- // Unlike from IOU, an issuer can't pre-create MPToken for an account (see similar tests in Offer_test.cpp) - {.account="ned", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="ole", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="pat", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=0, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="quy", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="ron", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=0, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="syd", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=3 * f, .balanceUsd=USD( 1), .offers=0, .owners=1, .scale=100000}, - {.account="ted", .fundXrp=XRP( 20) + reserve(env, 1) + 2 * f, .bookAmount=1000, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 2 * f, .balanceUsd=USD( 20), .offers=0, .owners=1}, - {.account="uli", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=0, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="vic", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="wes", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=0, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=1, .owners=2}, - {.account="xan", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=1, .preAuth=preAuthType::acctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=USD( 1), .offers=1, .owners=2}, + {.account="ned", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="ole", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="pat", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=0, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="quy", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="ron", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=0, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="syd", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=3 * f, .balanceUsd=usd( 1), .offers=0, .owners=1, .scale=100000}, + {.account="ted", .fundXrp=XRP( 20) + reserve(env, 1) + 2 * f, .bookAmount=1000, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 2 * f, .balanceUsd=usd( 20), .offers=0, .owners=1}, + {.account="uli", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=0, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="vic", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="wes", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=0, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=1, .owners=2}, + {.account="xan", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=1, .preAuth=PreAuthType::AcctPreAuth, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=usd( 1), .offers=1, .owners=2}, }; // clang-format on @@ -2078,21 +2079,21 @@ public: // The gateway optionally creates an offer that would be crossed. auto const book = t.bookAmount; if (book != 0) - env(offer(gw, XRP(book), USD(book * t.scale))); + env(offer(gw, XRP(book), usd(book * t.scale))); env.close(); std::uint32_t const gwOfferSeq = env.seq(gw) - 1; // Optionally pre-authorize MPT for acct. // Note this is not really part of the test, so we expect there // to be enough XRP reserve for acct to create the trust line. - if (t.preAuth == preAuthType::acctPreAuth) - MUSD.authorize({.account = acct}); + if (t.preAuth == PreAuthType::AcctPreAuth) + musd.authorize({.account = acct}); env.close(); { // Acct creates an offer. This is the heart of the test. auto const acctOffer = t.offerAmount; - env(offer(acct, USD(acctOffer * t.scale), XRP(acctOffer)), ter(t.tec)); + env(offer(acct, usd(acctOffer * t.scale), XRP(acctOffer)), Ter(t.tec)); env.close(); } std::uint32_t const acctOfferSeq = env.seq(acct) - 1; @@ -2102,12 +2103,12 @@ public: return t.balanceUsd; // crossed offer has XRP available balance of 1 fee // mpt to XRP ratio is 10 - return USD(f.value() / 10); + return usd(f.value() / 10); }(); - BEAST_EXPECT(env.balance(acct, USD) == expBalanceUsd); + BEAST_EXPECT(env.balance(acct, usd) == expBalanceUsd); BEAST_EXPECT(env.balance(acct, xrpIssue()) == t.fundXrp - t.spentXrp); env.require(offers(acct, t.offers)); - env.require(owners(acct, t.owners)); + env.require(Owners(acct, t.owners)); auto acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == t.offers); @@ -2117,28 +2118,28 @@ public: auto const leftover = t.offerAmount - t.bookAmount; BEAST_EXPECT(acctOffer[sfTakerGets] == XRP(leftover)); - BEAST_EXPECT(acctOffer[sfTakerPays] == USD(leftover)); + BEAST_EXPECT(acctOffer[sfTakerPays] == usd(leftover)); } - if (t.preAuth == preAuthType::noPreAuth) + if (t.preAuth == PreAuthType::NoPreAuth) { if (t.balanceUsd.value().signum() != 0) { // Verify the correct contents of MPT - BEAST_EXPECT(env.balance(acct, USD) == expBalanceUsd); + BEAST_EXPECT(env.balance(acct, usd) == expBalanceUsd); } else { // Verify that no MPT was created. - auto const sle = env.le(keylet::mptoken(USD.issuanceID, acct)); + auto const sle = env.le(keylet::mptoken(usd.issuanceID, acct)); BEAST_EXPECT(!sle); } } // Give the next loop a clean slate by canceling any left-overs // in the offers. - env(offer_cancel(acct, acctOfferSeq)); - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(acct, acctOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); } } @@ -2167,14 +2168,14 @@ public: env.fund(reserve(env, 2) + fee * 2, alice); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - auto const usdOffer = USD(1'000); + auto const usdOffer = usd(1'000); auto const xrpOffer = XRP(1'000); env(pay(gw, alice, usdOffer)); env.close(); - env.require(balance(alice, usdOffer), offers(alice, 0), offers(bob, 0)); + env.require(Balance(alice, usdOffer), offers(alice, 0), offers(bob, 0)); // The scenario: // o alice has USD but wants XRP. @@ -2188,31 +2189,31 @@ public: env.close(); env.require( - balance(alice, USD(0)), - balance(bob, usdOffer), - balance(alice, aliceXRP + xrpOffer - fee), - balance(bob, bobsXRP - xrpOffer - fee), + Balance(alice, usd(0)), + Balance(bob, usdOffer), + Balance(alice, aliceXRP + xrpOffer - fee), + Balance(bob, bobsXRP - xrpOffer - fee), offers(alice, 0), offers(bob, 0)); - BEAST_EXPECT(env.balance(bob, USD) == usdOffer); + BEAST_EXPECT(env.balance(bob, usd) == usdOffer); // Make two more offers that leave one of the offers non-dry. - env(offer(alice, USD(999), XRP(999))); + env(offer(alice, usd(999), XRP(999))); env(offer(bob, xrpOffer, usdOffer)); env.close(); - env.require(balance(alice, USD(999))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(999))); + env.require(Balance(bob, usd(1))); env.require(offers(alice, 0)); - BEAST_EXPECT(env.balance(bob, USD) == USD(1)); + BEAST_EXPECT(env.balance(bob, usd) == usd(1)); { auto const bobsOffers = offersOnAccount(env, bob); BEAST_EXPECT(bobsOffers.size() == 1); auto const& bobsOffer = *(bobsOffers.front()); BEAST_EXPECT(bobsOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(bobsOffer[sfTakerGets] == USD(1)); + BEAST_EXPECT(bobsOffer[sfTakerGets] == usd(1)); BEAST_EXPECT(bobsOffer[sfTakerPays] == XRP(1)); } } @@ -2242,17 +2243,17 @@ public: env.fund(reserve(env, 3) + fee * 2, bob); env.close(); - auto const USD = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice}}); - auto const EUR = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {bob}}); + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice}}); + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {bob}}); - auto const usdOffer = USD(1'000); - auto const eurOffer = EUR(1'000); + auto const usdOffer = usd(1'000); + auto const eurOffer = eur(1'000); env(pay(gw, alice, usdOffer)); env(pay(gw, bob, eurOffer)); env.close(); - env.require(balance(alice, usdOffer), balance(bob, eurOffer)); + env.require(Balance(alice, usdOffer), Balance(bob, eurOffer)); // The scenario: // o alice has USD but wants EUR. @@ -2262,12 +2263,12 @@ public: env.close(); env.require( - balance(alice, eurOffer), balance(bob, usdOffer), offers(alice, 0), offers(bob, 0)); + Balance(alice, eurOffer), Balance(bob, usdOffer), offers(alice, 0), offers(bob, 0)); // Alice's offer crossing created a default EUR trustline and // Bob's offer crossing created a default USD trustline: - BEAST_EXPECT(env.balance(alice, EUR) == eurOffer); - BEAST_EXPECT(env.balance(bob, USD) == usdOffer); + BEAST_EXPECT(env.balance(alice, eur) == eurOffer); + BEAST_EXPECT(env.balance(bob, usd) == usdOffer); // Make two more offers that leave one of the offers non-dry. // Guarantee the order of application by putting a close() @@ -2275,16 +2276,16 @@ public: env(offer(bob, eurOffer, usdOffer)); env.close(); - env(offer(alice, USD(999), eurOffer)); + env(offer(alice, usd(999), eurOffer)); env.close(); env.require(offers(alice, 0)); env.require(offers(bob, 1)); - env.require(balance(alice, USD(999))); - env.require(balance(alice, EUR(1))); - env.require(balance(bob, USD(1))); - env.require(balance(bob, EUR(999))); + env.require(Balance(alice, usd(999))); + env.require(Balance(alice, eur(1))); + env.require(Balance(bob, usd(1))); + env.require(Balance(bob, eur(999))); { auto bobsOffers = offersOnAccount(env, bob); @@ -2292,42 +2293,42 @@ public: { auto const& bobsOffer = *(bobsOffers.front()); - BEAST_EXPECT(bobsOffer[sfTakerGets] == USD(1)); - BEAST_EXPECT(bobsOffer[sfTakerPays] == EUR(1)); + BEAST_EXPECT(bobsOffer[sfTakerGets] == usd(1)); + BEAST_EXPECT(bobsOffer[sfTakerPays] == eur(1)); } } // alice makes one more offer that cleans out bob's offer. - env(offer(alice, USD(1), EUR(1))); + env(offer(alice, usd(1), eur(1))); env.close(); - env.require(balance(alice, USD(1'000))); - env.require(balance(alice, EUR(none))); - env.require(balance(bob, USD(none))); - env.require(balance(bob, EUR(1'000))); + env.require(Balance(alice, usd(1'000))); + env.require(Balance(alice, eur(kNONE))); + env.require(Balance(bob, usd(kNONE))); + env.require(Balance(bob, eur(1'000))); env.require(offers(alice, 0)); env.require(offers(bob, 0)); // The two MPT that were generated by the offers still here // Unlike IOU, MPToken is not automatically deleted - if constexpr (std::is_same_v, MPT>) + if constexpr (std::is_same_v, MPT>) { - BEAST_EXPECT(env.le(keylet::mptoken(EUR.issuanceID, alice))); - auto MEUR = MPTTester(env, gw, EUR, {bob}); + BEAST_EXPECT(env.le(keylet::mptoken(eur.issuanceID, alice))); + auto meur = MPTTester(env, gw, eur, {bob}); // Delete created MPToken to free up reserve - MEUR.authorize({.account = alice, .flags = tfMPTUnauthorize}); + meur.authorize({.account = alice, .flags = tfMPTUnauthorize}); } - if constexpr (std::is_same_v, MPT>) + if constexpr (std::is_same_v, MPT>) { - BEAST_EXPECT(env.le(keylet::mptoken(USD.issuanceID, bob))); - auto MUSD = MPTTester(env, gw, USD, {alice}); + BEAST_EXPECT(env.le(keylet::mptoken(usd.issuanceID, bob))); + auto musd = MPTTester(env, gw, usd, {alice}); // Delete created MPToken to free up reserve - MUSD.authorize({.account = bob, .flags = tfMPTUnauthorize}); + musd.authorize({.account = bob, .flags = tfMPTUnauthorize}); } // Make two more offers that leave one of the offers non-dry. We // need to properly sequence the transactions: - env(offer(alice, EUR(999), usdOffer)); + env(offer(alice, eur(999), usdOffer)); env.close(); env(offer(bob, usdOffer, eurOffer)); @@ -2336,10 +2337,10 @@ public: env.require(offers(alice, 0)); env.require(offers(bob, 0)); - env.require(balance(alice, USD(0))); - env.require(balance(alice, EUR(999))); - env.require(balance(bob, USD(1'000))); - env.require(balance(bob, EUR(1))); + env.require(Balance(alice, usd(0))); + env.require(Balance(alice, eur(999))); + env.require(Balance(bob, usd(1'000))); + env.require(Balance(bob, eur(1))); }; testHelper2TokensMix(test); } @@ -2361,11 +2362,11 @@ public: env.fund(XRP(1'000'000), gw, alice, bob, carol); env.close(); - auto const USD = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice}}); - auto const EUR = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {carol}}); + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw, .holders = {alice}}); + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw, .holders = {carol}}); - auto const usdOffer = USD(1'000); - auto const eurOffer = EUR(1'000); + auto const usdOffer = usd(1'000); + auto const eurOffer = eur(1'000); env(pay(gw, alice, usdOffer)); env(pay(gw, carol, eurOffer)); @@ -2384,24 +2385,24 @@ public: // carol makes an offer that partially consumes alice and bob's // offers. - env(offer(carol, USD(400), EUR(400))); + env(offer(carol, usd(400), eur(400))); env.close(); env.require( - balance(alice, USD(600)), - balance(bob, EUR(400)), - balance(carol, USD(400)), - balance(bob, bobXrpBalance - XRP(400)), + Balance(alice, usd(600)), + Balance(bob, eur(400)), + Balance(carol, usd(400)), + Balance(bob, bobXrpBalance - XRP(400)), offers(carol, 0)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(400)); - BEAST_EXPECT(env.balance(carol, USD) == USD(400)); + BEAST_EXPECT(env.balance(bob, eur) == eur(400)); + BEAST_EXPECT(env.balance(carol, usd) == usd(400)); { auto const aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); auto const& aliceOffer = *(aliceOffers.front()); BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(600)); + BEAST_EXPECT(aliceOffer[sfTakerGets] == usd(600)); BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(600)); } { @@ -2411,23 +2412,23 @@ public: BEAST_EXPECT(bobsOffer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(bobsOffer[sfTakerGets] == XRP(600)); - BEAST_EXPECT(bobsOffer[sfTakerPays] == EUR(600)); + BEAST_EXPECT(bobsOffer[sfTakerPays] == eur(600)); } // carol makes an offer that exactly consumes alice and bob's // offers. - env(offer(carol, USD(600), EUR(600))); + env(offer(carol, usd(600), eur(600))); env.close(); env.require( - balance(alice, USD(0)), - balance(bob, eurOffer), - balance(carol, usdOffer), - balance(bob, bobXrpBalance - XRP(1'000)), + Balance(alice, usd(0)), + Balance(bob, eurOffer), + Balance(carol, usdOffer), + Balance(bob, bobXrpBalance - XRP(1'000)), offers(bob, 0), offers(carol, 0)); - BEAST_EXPECT(env.balance(bob, EUR) == EUR(1'000)); - BEAST_EXPECT(env.balance(carol, USD) == USD(1'000)); + BEAST_EXPECT(env.balance(bob, eur) == eur(1'000)); + BEAST_EXPECT(env.balance(carol, usd) == usd(1'000)); // In pre-flow code alice's offer is left empty in the ledger. auto const aliceOffers = offersOnAccount(env, alice); @@ -2437,7 +2438,7 @@ public: auto const& aliceOffer = *(aliceOffers.front()); BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(0)); + BEAST_EXPECT(aliceOffer[sfTakerGets] == usd(0)); BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(0)); } }; @@ -2460,8 +2461,8 @@ public: env.fund(XRP(10'000'000), gw); - auto MUSD = MPTTester({.env = env, .issuer = gw}); - MPT const USD = MUSD; + auto musd = MPTTester({.env = env, .issuer = gw}); + MPT const usd = musd; // The fee that's charged for transactions auto const f = env.current()->fees().base; @@ -2486,64 +2487,64 @@ public: // Constructor with takerGets/takerPays TestData( - std::string&& account_, // Account operated on - STAmount fundXrp_, // XRP acct funded with - STAmount fundUSD_, // USD acct funded with - STAmount gwGets_, // gw's offer - STAmount gwPays_, // - STAmount acctGets_, // acct's offer - STAmount acctPays_, // - TER tec_, // Returned tec code - STAmount spentXrp_, // Amount removed from fundXrp - STAmount finalUsd_, // Final USD balance on acct - int offers_, // Offers on acct - int owners_, // Owners on acct - STAmount takerGets_, // Remainder of acct's offer - STAmount takerPays_) // - : account(std::move(account_)) - , fundXrp(std::move(fundXrp_)) - , fundUSD(std::move(fundUSD_)) - , gwGets(std::move(gwGets_)) - , gwPays(std::move(gwPays_)) - , acctGets(std::move(acctGets_)) - , acctPays(std::move(acctPays_)) - , tec(tec_) - , spentXrp(std::move(spentXrp_)) - , finalUsd(std::move(finalUsd_)) - , offers(offers_) - , owners(owners_) - , takerGets(std::move(takerGets_)) - , takerPays(std::move(takerPays_)) + std::string&& account, // Account operated on + STAmount fundXrp, // XRP acct funded with + STAmount fundUsd, // USD acct funded with + STAmount gwGets, // gw's offer + STAmount gwPays, // + STAmount acctGets, // acct's offer + STAmount acctPays, // + TER tec, // Returned tec code + STAmount spentXrp, // Amount removed from fundXrp + STAmount finalUsd, // Final USD balance on acct + int offers, // Offers on acct + int owners, // Owners on acct + STAmount takerGets, // Remainder of acct's offer + STAmount takerPays) // + : account(std::move(account)) + , fundXrp(std::move(fundXrp)) + , fundUSD(std::move(fundUsd)) + , gwGets(std::move(gwGets)) + , gwPays(std::move(gwPays)) + , acctGets(std::move(acctGets)) + , acctPays(std::move(acctPays)) + , tec(tec) + , spentXrp(std::move(spentXrp)) + , finalUsd(std::move(finalUsd)) + , offers(offers) + , owners(owners) + , takerGets(std::move(takerGets)) + , takerPays(std::move(takerPays)) { } // Constructor without takerGets/takerPays TestData( - std::string&& account_, // Account operated on - STAmount const& fundXrp_, // XRP acct funded with - STAmount const& fundUSD_, // USD acct funded with - STAmount const& gwGets_, // gw's offer - STAmount const& gwPays_, // - STAmount const& acctGets_, // acct's offer - STAmount const& acctPays_, // - TER tec_, // Returned tec code - STAmount const& spentXrp_, // Amount removed from fundXrp - STAmount const& finalUsd_, // Final USD balance on acct - int offers_, // Offers on acct - int owners_) // Owners on acct + std::string&& account, // Account operated on + STAmount const& fundXrp, // XRP acct funded with + STAmount const& fundUsd, // USD acct funded with + STAmount const& gwGets, // gw's offer + STAmount const& gwPays, // + STAmount const& acctGets, // acct's offer + STAmount const& acctPays, // + TER tec, // Returned tec code + STAmount const& spentXrp, // Amount removed from fundXrp + STAmount const& finalUsd, // Final USD balance on acct + int offers, // Offers on acct + int owners) // Owners on acct : TestData( - std::move(account_), - fundXrp_, - fundUSD_, - gwGets_, - gwPays_, - acctGets_, - acctPays_, - tec_, - spentXrp_, - finalUsd_, - offers_, - owners_, + std::move(account), + fundXrp, + fundUsd, + gwGets, + gwPays, + acctGets, + acctPays, + tec, + spentXrp, + finalUsd, + offers, + owners, STAmount{0}, STAmount{0}) { @@ -2554,26 +2555,26 @@ public: TestData const tests[]{ // acct pays XRP // acct fundXrp fundUSD gwGets gwPays acctGets acctPays tec spentXrp finalUSD offers owners takerGets takerPays - {"ann", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (1 * f), USD( 0), 0, 0}, - {"bev", XRP(10) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tesSUCCESS, XRP( 0) + (1 * f), USD( 0), 1, 1, XRP(10), USD(10)}, - {"cam", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(10), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(10), 0, 1}, - {"deb", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"eve", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD( 5), XRP( 5), tesSUCCESS, XRP( 5) + (1 * f), USD(10), 0, 1}, - {"flo", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"gay", XRP(20) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"hye", XRP(20) + reserve(env, 2) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 1, 2, XRP(10), USD(10)}, + {"ann", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd( 5), usd(10), XRP(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (1 * f), usd( 0), 0, 0}, + {"bev", XRP(10) + reserve(env, 1) + 1 * f, usd( 0), XRP(10), usd( 5), usd(10), XRP(10), tesSUCCESS, XRP( 0) + (1 * f), usd( 0), 1, 1, XRP(10), usd(10)}, + {"cam", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(10), usd(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), usd(10), 0, 1}, + {"deb", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"eve", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd( 5), XRP( 5), tesSUCCESS, XRP( 5) + (1 * f), usd(10), 0, 1}, + {"flo", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"gay", XRP(20) + reserve(env, 1) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"hye", XRP(20) + reserve(env, 2) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 1, 2, XRP(10), usd(10)}, // acct pays USD - {"meg", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (2 * f), USD(10), 0, 1}, - {"nia", reserve(env, 2) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( 0) + (2 * f), USD(10), 1, 2, USD(10), XRP(10)}, - {"ova", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 0), 0, 1}, - {"pam", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(20), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1}, - {"qui", reserve(env, 1) + 2 * f, USD(10), USD(20), XRP(40), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1}, - {"rae", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( -5) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)}, - {"sue", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)}, + {"meg", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP( 5), XRP(10), usd(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (2 * f), usd(10), 0, 1}, + {"nia", reserve(env, 2) + 2 * f, usd(10), usd(10), XRP( 5), XRP(10), usd(10), tesSUCCESS, XRP( 0) + (2 * f), usd(10), 1, 2, usd(10), XRP(10)}, + {"ova", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP(10), XRP(10), usd(10), tesSUCCESS, XRP(-10) + (2 * f), usd( 0), 0, 1}, + {"pam", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP(20), XRP(10), usd(10), tesSUCCESS, XRP(-20) + (2 * f), usd( 0), 0, 1}, + {"qui", reserve(env, 1) + 2 * f, usd(10), usd(20), XRP(40), XRP(10), usd(10), tesSUCCESS, XRP(-20) + (2 * f), usd( 0), 0, 1}, + {"rae", reserve(env, 2) + 2 * f, usd(10), usd( 5), XRP( 5), XRP(10), usd(10), tesSUCCESS, XRP( -5) + (2 * f), usd( 5), 1, 2, usd( 5), XRP( 5)}, + {"sue", reserve(env, 2) + 2 * f, usd(10), usd( 5), XRP(10), XRP(10), usd(10), tesSUCCESS, XRP(-10) + (2 * f), usd( 5), 1, 2, usd( 5), XRP( 5)}, }; // clang-format on - auto const zeroUsd = USD(0); + auto const zeroUsd = usd(0); for (auto const& t : tests) { // Make sure gateway has no current offers. @@ -2589,7 +2590,7 @@ public: // on the trust line. if (t.fundUSD != zeroUsd) { - MUSD.authorize({.account = acct}); + musd.authorize({.account = acct}); env.close(); env(pay(gw, acct, t.fundUSD)); env.close(); @@ -2600,15 +2601,15 @@ public: std::uint32_t const gwOfferSeq = env.seq(gw) - 1; // Acct creates a tfSell offer. This is the heart of the test. - env(offer(acct, t.acctGets, t.acctPays, tfSell), ter(t.tec)); + env(offer(acct, t.acctGets, t.acctPays, tfSell), Ter(t.tec)); env.close(); std::uint32_t const acctOfferSeq = env.seq(acct) - 1; // Check results - BEAST_EXPECT(env.balance(acct, USD) == t.finalUsd); + BEAST_EXPECT(env.balance(acct, usd) == t.finalUsd); BEAST_EXPECT(env.balance(acct, xrpIssue()) == t.fundXrp - t.spentXrp); env.require(offers(acct, t.offers)); - env.require(owners(acct, t.owners)); + env.require(Owners(acct, t.owners)); if (t.offers != 0) { @@ -2626,8 +2627,8 @@ public: // Give the next loop a clean slate by canceling any left-overs // in the offers. - env(offer_cancel(acct, acctOfferSeq)); - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(acct, acctOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); } } @@ -2649,40 +2650,40 @@ public: env.fund(XRP(10'000'000), gw, alice, bob); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); // bob offers XRP for USD. - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); env.close(); - env(offer(bob, XRP(2'000), USD(20))); + env(offer(bob, XRP(2'000), usd(20))); env.close(); { // alice submits a tfSell | tfFillOrKill offer that does not cross. - env(offer(alice, USD(21), XRP(2'100), tfSell | tfFillOrKill), ter(tecKILLED)); + env(offer(alice, usd(21), XRP(2'100), tfSell | tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(alice, USD(none))); + env.require(Balance(alice, usd(kNONE))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(100))); + env.require(Balance(bob, usd(100))); } { // alice submits a tfSell | tfFillOrKill offer that crosses. // Even though tfSell is present it doesn't matter this time. - env(offer(alice, USD(20), XRP(2'000), tfSell | tfFillOrKill)); + env(offer(alice, usd(20), XRP(2'000), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(20))); + env.require(Balance(alice, usd(20))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(80))); + env.require(Balance(bob, usd(80))); } { // alice submits a tfSell | tfFillOrKill offer that crosses and // returns more than was asked for (because of the tfSell flag). - env(offer(bob, XRP(2'000), USD(20))); + env(offer(bob, XRP(2'000), usd(20))); env.close(); - env(offer(alice, USD(10), XRP(1'500), tfSell | tfFillOrKill)); + env(offer(alice, usd(10), XRP(1'500), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(35))); + env.require(Balance(alice, usd(35))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(65))); + env.require(Balance(bob, usd(65))); } { // alice submits a tfSell | tfFillOrKill offer that doesn't cross. @@ -2691,22 +2692,22 @@ public: // all of the offer is consumed. // We're using bob's left-over offer for XRP(500), USD(5) - env(offer(alice, USD(1), XRP(501), tfSell | tfFillOrKill), ter(tecKILLED)); + env(offer(alice, usd(1), XRP(501), tfSell | tfFillOrKill), Ter(tecKILLED)); env.close(); - env.require(balance(alice, USD(35))); + env.require(Balance(alice, usd(35))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(65))); + env.require(Balance(bob, usd(65))); } { // Alice submits a tfSell | tfFillOrKill offer that finishes // off the remainder of bob's offer. // We're using bob's left-over offer for XRP(500), USD(5) - env(offer(alice, USD(1), XRP(500), tfSell | tfFillOrKill)); + env(offer(alice, usd(1), XRP(500), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(40))); + env.require(Balance(alice, usd(40))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(60))); + env.require(Balance(bob, usd(60))); } } @@ -2727,9 +2728,9 @@ public: env.fund(XRP(100'000), gw1); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw1, .transferFee = 25'000}); - using tUSD = std::decay_t; + using tUSD = std::decay_t; { auto const ann = Account("ann"); auto const bob = Account("bob"); @@ -2738,18 +2739,18 @@ public: if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = ann}); - MUSD.authorize({.account = bob}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = ann}); + musd.authorize({.account = bob}); } else { - env(trust(ann, USD(20'000))); - env(trust(bob, USD(20'000))); + env(trust(ann, usd(20'000))); + env(trust(bob, usd(20'000))); env.close(); } - env(pay(gw1, bob, USD(12'500))); + env(pay(gw1, bob, usd(12'500))); env.close(); // bob offers to sell USD(100) for XRP. alice takes bob's @@ -2758,18 +2759,18 @@ public: // // A comparable payment would look like this: // env (pay (bob, alice, USD(100)), sendmax(USD(125))) - env(offer(bob, XRP(1), USD(10'000))); + env(offer(bob, XRP(1), usd(10'000))); env.close(); - env(offer(ann, USD(10'000), XRP(1))); + env(offer(ann, usd(10'000), XRP(1))); env.close(); - env.require(balance(ann, USD(10'000))); - env.require(balance(ann, XRP(99) + reserve(env, 2))); + env.require(Balance(ann, usd(10'000))); + env.require(Balance(ann, XRP(99) + reserve(env, 2))); env.require(offers(ann, 0)); - env.require(balance(bob, USD(0))); - env.require(balance(bob, XRP(101) + reserve(env, 2))); + env.require(Balance(bob, usd(0))); + env.require(Balance(bob, XRP(101) + reserve(env, 2))); env.require(offers(bob, 0)); } { @@ -2783,32 +2784,32 @@ public: if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = che}); - MUSD.authorize({.account = deb}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = che}); + musd.authorize({.account = deb}); } else { - env(trust(che, USD(20'000))); - env(trust(deb, USD(20'000))); + env(trust(che, usd(20'000))); + env(trust(deb, usd(20'000))); env.close(); } - env(pay(gw1, deb, USD(12'500))); + env(pay(gw1, deb, usd(12'500))); env.close(); - env(offer(che, USD(10'000), XRP(1))); + env(offer(che, usd(10'000), XRP(1))); env.close(); - env(offer(deb, XRP(1), USD(10'000))); + env(offer(deb, XRP(1), usd(10'000))); env.close(); - env.require(balance(che, USD(10'000))); - env.require(balance(che, XRP(99) + reserve(env, 2))); + env.require(Balance(che, usd(10'000))); + env.require(Balance(che, XRP(99) + reserve(env, 2))); env.require(offers(che, 0)); - env.require(balance(deb, USD(0))); - env.require(balance(deb, XRP(101) + reserve(env, 2))); + env.require(Balance(deb, usd(0))); + env.require(Balance(deb, XRP(101) + reserve(env, 2))); env.require(offers(deb, 0)); } { @@ -2820,33 +2821,33 @@ public: if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = eve}); - MUSD.authorize({.account = fyn}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = eve}); + musd.authorize({.account = fyn}); } else { - env(trust(eve, USD(20'000))); - env(trust(fyn, USD(20'000))); + env(trust(eve, usd(20'000))); + env(trust(fyn, usd(20'000))); env.close(); } - env(pay(gw1, eve, USD(10'000))); - env(pay(gw1, fyn, USD(10'000))); + env(pay(gw1, eve, usd(10'000))); + env(pay(gw1, fyn, usd(10'000))); env.close(); // This test verifies that the amount removed from an offer // accounts for the transfer fee that is removed from the // account but not from the remaining offer. - env(offer(eve, USD(1'000), XRP(4'000))); + env(offer(eve, usd(1'000), XRP(4'000))); env.close(); std::uint32_t const eveOfferSeq = env.seq(eve) - 1; - env(offer(fyn, XRP(2'000), USD(500))); + env(offer(fyn, XRP(2'000), usd(500))); env.close(); - env.require(balance(eve, USD(10'500))); - env.require(balance(eve, XRP(18'000))); + env.require(Balance(eve, usd(10'500))); + env.require(Balance(eve, XRP(18'000))); auto const evesOffers = offersOnAccount(env, eve); BEAST_EXPECT(evesOffers.size() == 1); if (!evesOffers.empty()) @@ -2854,12 +2855,12 @@ public: auto const& evesOffer = *(evesOffers.front()); BEAST_EXPECT(evesOffer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(evesOffer[sfTakerGets] == XRP(2'000)); - BEAST_EXPECT(evesOffer[sfTakerPays] == USD(500)); + BEAST_EXPECT(evesOffer[sfTakerPays] == usd(500)); } - env(offer_cancel(eve, eveOfferSeq)); // For later tests + env(offerCancel(eve, eveOfferSeq)); // For later tests - env.require(balance(fyn, USD(9'375))); - env.require(balance(fyn, XRP(22'000))); + env.require(Balance(fyn, usd(9'375))); + env.require(Balance(fyn, XRP(22'000))); env.require(offers(fyn, 0)); } // Start messing with two non-native currencies. @@ -2868,9 +2869,9 @@ public: env.fund(XRP(100'000), gw2); env.close(); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw2, .transferFee = 50'000}); - using tEUR = std::decay_t; + using tEUR = std::decay_t; { // Remove XRP from the equation. Give the two currencies two // different transfer rates so we can see both transfer rates @@ -2882,47 +2883,47 @@ public: if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = gay}); - MUSD.authorize({.account = hal}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = gay}); + musd.authorize({.account = hal}); } else { - env(trust(gay, USD(20'000))); - env(trust(hal, USD(20'000))); + env(trust(gay, usd(20'000))); + env(trust(hal, usd(20'000))); env.close(); } if constexpr (std::is_same_v) { - auto MEUR = MPTTester(env, gw2, EUR); - MEUR.authorize({.account = gay}); - MEUR.authorize({.account = hal}); + auto meur = MPTTester(env, gw2, eur); + meur.authorize({.account = gay}); + meur.authorize({.account = hal}); } else { - env(trust(gay, EUR(20'000))); - env(trust(hal, EUR(20'000))); + env(trust(gay, eur(20'000))); + env(trust(hal, eur(20'000))); env.close(); } - env(pay(gw1, gay, USD(12'500))); - env(pay(gw2, hal, EUR(150))); + env(pay(gw1, gay, usd(12'500))); + env(pay(gw2, hal, eur(150))); env.close(); - env(offer(gay, EUR(100), USD(10'000))); + env(offer(gay, eur(100), usd(10'000))); env.close(); - env(offer(hal, USD(10'000), EUR(100))); + env(offer(hal, usd(10'000), eur(100))); env.close(); - env.require(balance(gay, USD(0))); - env.require(balance(gay, EUR(100))); - env.require(balance(gay, reserve(env, 3))); + env.require(Balance(gay, usd(0))); + env.require(Balance(gay, eur(100))); + env.require(Balance(gay, reserve(env, 3))); env.require(offers(gay, 0)); - env.require(balance(hal, USD(10'000))); - env.require(balance(hal, EUR(0))); - env.require(balance(hal, reserve(env, 3))); + env.require(Balance(hal, usd(10'000))); + env.require(Balance(hal, eur(0))); + env.require(Balance(hal, reserve(env, 3))); env.require(offers(hal, 0)); } @@ -2939,47 +2940,47 @@ public: // o qae has EUR but wants USD. if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = ova}); - MUSD.authorize({.account = pat}); - MUSD.authorize({.account = qae}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = ova}); + musd.authorize({.account = pat}); + musd.authorize({.account = qae}); } else { - env(trust(ova, USD(20'000))); - env(trust(pat, USD(20'000))); - env(trust(qae, USD(20'000))); + env(trust(ova, usd(20'000))); + env(trust(pat, usd(20'000))); + env(trust(qae, usd(20'000))); env.close(); } if constexpr (std::is_same_v) { - auto MEUR = MPTTester(env, gw2, EUR); - MEUR.authorize({.account = ova}); - MEUR.authorize({.account = pat}); - MEUR.authorize({.account = qae}); + auto meur = MPTTester(env, gw2, eur); + meur.authorize({.account = ova}); + meur.authorize({.account = pat}); + meur.authorize({.account = qae}); } else { - env(trust(ova, EUR(20'000))); - env(trust(pat, EUR(20'000))); - env(trust(qae, EUR(20'000))); + env(trust(ova, eur(20'000))); + env(trust(pat, eur(20'000))); + env(trust(qae, eur(20'000))); env.close(); } - env(pay(gw1, ova, USD(12'500))); - env(pay(gw2, qae, EUR(150))); + env(pay(gw1, ova, usd(12'500))); + env(pay(gw2, qae, eur(150))); env.close(); - env(offer(ova, XRP(2), USD(10'000))); - env(offer(pat, EUR(100), XRP(2))); + env(offer(ova, XRP(2), usd(10'000))); + env(offer(pat, eur(100), XRP(2))); env.close(); - env(offer(qae, USD(10'000), EUR(100))); + env(offer(qae, usd(10'000), eur(100))); env.close(); - env.require(balance(ova, USD(0))); - env.require(balance(ova, EUR(0))); - env.require(balance(ova, XRP(4) + reserve(env, 3))); + env.require(Balance(ova, usd(0))); + env.require(Balance(ova, eur(0))); + env.require(Balance(ova, XRP(4) + reserve(env, 3))); // In pre-flow code ova's offer is left empty in the ledger. auto const ovasOffers = offersOnAccount(env, ova); @@ -2989,18 +2990,18 @@ public: auto const& ovasOffer = *(ovasOffers.front()); BEAST_EXPECT(ovasOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(ovasOffer[sfTakerGets] == USD(0)); + BEAST_EXPECT(ovasOffer[sfTakerGets] == usd(0)); BEAST_EXPECT(ovasOffer[sfTakerPays] == XRP(0)); } - env.require(balance(pat, USD(0))); - env.require(balance(pat, EUR(100))); - env.require(balance(pat, XRP(0) + reserve(env, 3))); + env.require(Balance(pat, usd(0))); + env.require(Balance(pat, eur(100))); + env.require(Balance(pat, XRP(0) + reserve(env, 3))); env.require(offers(pat, 0)); - env.require(balance(qae, USD(10'000))); - env.require(balance(qae, EUR(0))); - env.require(balance(qae, XRP(2) + reserve(env, 3))); + env.require(Balance(qae, usd(10'000))); + env.require(Balance(qae, eur(0))); + env.require(Balance(qae, XRP(2) + reserve(env, 3))); env.require(offers(qae, 0)); } }; @@ -3037,18 +3038,18 @@ public: env.fund(startBalance + (fee * 5), gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw}); + MPT const usd = MPTTester({.env = env, .issuer = gw}); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); // three offers + MPTokenIssuance - env.require(owners(gw, 4)); - env.require(balance(gw, startBalance + fee)); + env.require(Owners(gw, 4)); + env.require(Balance(gw, startBalance + fee)); auto gwOffers = offersOnAccount(env, gw); BEAST_EXPECT(gwOffers.size() == 3); @@ -3057,16 +3058,16 @@ public: auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(offer[sfTakerGets] == XRP(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(60)); + BEAST_EXPECT(offer[sfTakerPays] == usd(60)); } // Since this offer crosses the first offers, the previous offers // will be deleted and this offer will be put on the order book. - env(offer(gw, XRP(1'000), USD(100))); + env(offer(gw, XRP(1'000), usd(100))); env.close(); - env.require(owners(gw, 2)); + env.require(Owners(gw, 2)); env.require(offers(gw, 1)); - env.require(balance(gw, startBalance)); + env.require(Balance(gw, startBalance)); gwOffers = offersOnAccount(env, gw); BEAST_EXPECT(gwOffers.size() == 1); @@ -3074,7 +3075,7 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(100)); + BEAST_EXPECT(offer[sfTakerGets] == usd(100)); BEAST_EXPECT(offer[sfTakerPays] == XRP(1'000)); } } @@ -3094,10 +3095,10 @@ public: env.fund(XRP(1'000'000), gw1, gw2); env.close(); - auto const USD = issue1({.env = env, .token = "USD", .issuer = gw1}); - using tUSD = std::decay_t; - auto const EUR = issue2({.env = env, .token = "EUR", .issuer = gw2}); - using tEUR = std::decay_t; + auto const usd = issue1({.env = env, .token = "USD", .issuer = gw1}); + using tUSD = std::decay_t; + auto const eur = issue2({.env = env, .token = "EUR", .issuer = gw2}); + using tEUR = std::decay_t; // The fee that's charged for transactions. auto const f = env.current()->fees().base; @@ -3116,12 +3117,12 @@ public: // clang-format off TestData const tests[]{ // acct fundXRP fundUSD fundEUR firstOfferTec secondOfferTec - {"ann", reserve(env, 3) + f * 4, USD(1000), EUR(1000), tesSUCCESS, tesSUCCESS}, - {"bev", reserve(env, 3) + f * 4, USD( 1), EUR(1000), tesSUCCESS, tesSUCCESS}, - {"cam", reserve(env, 3) + f * 4, USD(1000), EUR( 1), tesSUCCESS, tesSUCCESS}, - {"deb", reserve(env, 3) + f * 4, USD( 0), EUR( 1), tesSUCCESS, tecUNFUNDED_OFFER}, - {"eve", reserve(env, 3) + f * 4, USD( 1), EUR( 0), tecUNFUNDED_OFFER, tesSUCCESS}, - {"flo", reserve(env, 3) + 0, USD(1000), EUR(1000), tecINSUF_RESERVE_OFFER, tecINSUF_RESERVE_OFFER}, + {"ann", reserve(env, 3) + f * 4, usd(1000), eur(1000), tesSUCCESS, tesSUCCESS}, + {"bev", reserve(env, 3) + f * 4, usd( 1), eur(1000), tesSUCCESS, tesSUCCESS}, + {"cam", reserve(env, 3) + f * 4, usd(1000), eur( 1), tesSUCCESS, tesSUCCESS}, + {"deb", reserve(env, 3) + f * 4, usd( 0), eur( 1), tesSUCCESS, tecUNFUNDED_OFFER}, + {"eve", reserve(env, 3) + f * 4, usd( 1), eur( 0), tecUNFUNDED_OFFER, tesSUCCESS}, + {"flo", reserve(env, 3) + 0, usd(1000), eur(1000), tecINSUF_RESERVE_OFFER, tecINSUF_RESERVE_OFFER}, }; //clang-format on @@ -3133,39 +3134,39 @@ public: if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw1, USD); - MUSD.authorize({.account = acct}); + auto musd = MPTTester(env, gw1, usd); + musd.authorize({.account = acct}); } else { - env(trust(acct, USD(1'000))); + env(trust(acct, usd(1'000))); env.close(); } if constexpr (std::is_same_v) { - auto MEUR = MPTTester(env, gw2, EUR); - MEUR.authorize({.account = acct}); + auto meur = MPTTester(env, gw2, eur); + meur.authorize({.account = acct}); } else { - env(trust(acct, EUR(1'000))); + env(trust(acct, eur(1'000))); env.close(); } - if (t.fundUSD > USD(0)) + if (t.fundUSD > usd(0)) env(pay(gw1, acct, t.fundUSD)); - if (t.fundEUR > EUR(0)) + if (t.fundEUR > eur(0)) env(pay(gw2, acct, t.fundEUR)); env.close(); - env(offer(acct, USD(500), EUR(600)), ter(t.firstOfferTec)); + env(offer(acct, usd(500), eur(600)), Ter(t.firstOfferTec)); env.close(); std::uint32_t const firstOfferSeq = env.seq(acct) - 1; int offerCount = t.firstOfferTec == tesSUCCESS ? 1 : 0; - env.require(owners(acct, 2 + offerCount)); - env.require(balance(acct, t.fundUSD)); - env.require(balance(acct, t.fundEUR)); + env.require(Owners(acct, 2 + offerCount)); + env.require(Balance(acct, t.fundUSD)); + env.require(Balance(acct, t.fundEUR)); auto acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == offerCount); @@ -3173,18 +3174,18 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } - env(offer(acct, EUR(600), USD(500)), ter(t.secondOfferTec)); + env(offer(acct, eur(600), usd(500)), Ter(t.secondOfferTec)); env.close(); std::uint32_t const secondOfferSeq = env.seq(acct) - 1; offerCount = t.secondOfferTec == tesSUCCESS ? 1 : offerCount; - env.require(owners(acct, 2 + offerCount)); - env.require(balance(acct, t.fundUSD)); - env.require(balance(acct, t.fundEUR)); + env.require(Owners(acct, 2 + offerCount)); + env.require(Balance(acct, t.fundUSD)); + env.require(Balance(acct, t.fundEUR)); acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == offerCount); @@ -3194,20 +3195,20 @@ public: BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); if (offer[sfSequence] == firstOfferSeq) { - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } else { - BEAST_EXPECT(offer[sfTakerGets] == USD(500)); - BEAST_EXPECT(offer[sfTakerPays] == EUR(600)); + BEAST_EXPECT(offer[sfTakerGets] == usd(500)); + BEAST_EXPECT(offer[sfTakerPays] == eur(600)); } } // Remove any offers from acct for the next pass. - env(offer_cancel(acct, firstOfferSeq)); + env(offerCancel(acct, firstOfferSeq)); env.close(); - env(offer_cancel(acct, secondOfferSeq)); + env(offerCancel(acct, secondOfferSeq)); env.close(); } }; @@ -3240,19 +3241,19 @@ public: env.fund(XRP(50'000) + f, alice, bob); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = bob}); + MPT const usd = MPTTester({.env = env, .issuer = bob}); - env(offer(alice, USD(5'000), XRP(50'000))); + env(offer(alice, usd(5'000), XRP(50'000))); env.close(); // This offer should take alice's offer up to Alice's reserve. - env(offer(bob, XRP(50'000), USD(5'000))); + env(offer(bob, XRP(50'000), usd(5'000))); env.close(); // alice's offer should have been removed, since she's down to her // XRP reserve. - env.require(balance(alice, XRP(250))); - env.require(owners(alice, 1)); + env.require(Balance(alice, XRP(250))); + env.require(Owners(alice, 1)); env.require(mptokens(alice, 1)); // However bob's offer should be in the ledger, since it was not @@ -3263,7 +3264,7 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(25)); + BEAST_EXPECT(offer[sfTakerGets] == usd(25)); BEAST_EXPECT(offer[sfTakerPays] == XRP(250)); } } @@ -3289,36 +3290,36 @@ public: env.fund(reserve(env, 4) + (fee * 5), ann, bob, cam); env.close(); - auto const A_BUX = issue1( + auto const aBux = issue1( {.env = env, .token = "AUX", .issuer = ann, .holders = {cam}}); - auto const B_BUX = issue2( + auto const bBux = issue2( {.env = env, .token = "BUX", .issuer = bob, .holders = {ann, cam}}); - env(pay(ann, cam, A_BUX(35))); - env(pay(bob, cam, B_BUX(35))); + env(pay(ann, cam, aBux(35))); + env(pay(bob, cam, bBux(35))); - env(offer(bob, A_BUX(30), B_BUX(30))); + env(offer(bob, aBux(30), bBux(30))); env.close(); // cam puts an offer on the books that her upcoming offer could // cross. But this offer should be deleted, not crossed, by her // upcoming offer. - env(offer(cam, A_BUX(29), B_BUX(30), tfPassive)); + env(offer(cam, aBux(29), bBux(30), tfPassive)); env.close(); - env.require(balance(cam, A_BUX(35))); - env.require(balance(cam, B_BUX(35))); + env.require(Balance(cam, aBux(35))); + env.require(Balance(cam, bBux(35))); env.require(offers(cam, 1)); // This offer caused the assert. - env(offer(cam, B_BUX(30), A_BUX(30))); + env(offer(cam, bBux(30), aBux(30))); env.close(); - env.require(balance(bob, A_BUX(30))); - env.require(balance(cam, A_BUX(5))); - env.require(balance(cam, B_BUX(65))); + env.require(Balance(bob, aBux(30))); + env.require(Balance(cam, aBux(5))); + env.require(Balance(cam, bBux(65))); env.require(offers(cam, 0)); }; testHelper2TokensMix(test); @@ -3344,18 +3345,18 @@ public: env.fund(reserve(env, 2) + (fee * 4), gw); env.close(); - MPT const BTC = MPTTester( + MPT const btc = MPTTester( {.env = env, .issuer = gw, .holders = {ann}, .transferFee = 2'000}); - env(pay(gw, ann, BTC(2'856))); + env(pay(gw, ann, btc(2'856))); env.close(); - env(offer(ann, drops(365'611'702'030), BTC(5'713))); + env(offer(ann, drops(365'611'702'030), btc(5'713))); env.close(); // This offer caused the assert. - env(offer(ann, BTC(687), drops(20'000'000'000)), - ter(tecINSUF_RESERVE_OFFER)); + env(offer(ann, btc(687), drops(20'000'000'000)), + Ter(tecINSUF_RESERVE_OFFER)); } void @@ -3380,16 +3381,16 @@ public: env.fund(reserve(env, 2) + (fee * 4), gw); env.close(); - MPT const CNY = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); + MPT const cny = MPTTester({.env = env, .issuer = gw, .holders = {bob}}); - env(pay(gw, bob, CNY(3'000'000))); + env(pay(gw, bob, cny(3'000'000))); env.close(); - env(offer(bob, drops(5'400'000'000), CNY(2'160'540))); + env(offer(bob, drops(5'400'000'000), cny(2'160'540))); env.close(); // This offer did not round result of partial crossing correctly. - env(offer(alice, CNY(135'620'001), drops(339'000'000'000))); + env(offer(alice, cny(135'620'001), drops(339'000'000'000))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -3399,7 +3400,7 @@ public: auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(offer[sfTakerGets] == drops(333'599'446'582)); - BEAST_EXPECT(offer[sfTakerPays] == CNY(13'3459'461)); + BEAST_EXPECT(offer[sfTakerPays] == cny(13'3459'461)); } } @@ -3427,32 +3428,32 @@ public: env.fund(reserve(env, 2) + (fee * 4), gw); env.close(); - auto const JPY = issue1( + auto const jpy = issue1( {.env = env, .token = "JPY", .issuer = gw, .holders = {alice}, - .limit = maxMPTokenAmount, + .limit = kMAX_MP_TOKEN_AMOUNT, .transferFee = 2'000}); - auto const BTC = issue2( + auto const btc = issue2( {.env = env, .token = "BTC", .issuer = gw, .holders = {bob}, - .limit = maxMPTokenAmount, + .limit = kMAX_MP_TOKEN_AMOUNT, .transferFee = 2'000}); - env(pay(gw, alice, JPY(3'699'034'802'280'317))); - env(pay(gw, bob, BTC(115'672'255'914'031'100))); + env(pay(gw, alice, jpy(3'699'034'802'280'317))); + env(pay(gw, bob, btc(115'672'255'914'031'100))); env.close(); env(offer( - bob, JPY(1'241'913'390'770'747), BTC(1'969'825'690'469'254))); + bob, jpy(1'241'913'390'770'747), btc(1'969'825'690'469'254))); env.close(); // This offer did not round result of partial crossing correctly. env(offer( - alice, BTC(5'507'568'706'427'876), JPY(3'472'696'773'391'072))); + alice, btc(5'507'568'706'427'876), jpy(3'472'696'773'391'072))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -3469,8 +3470,8 @@ public: // MPT test has the same order of magnitude for the scaled // values and the first 5 digits match. Is the difference due to // int arithmetics? - BEAST_EXPECT(offer[sfTakerGets] == JPY(2'230'659'191'281'247)); - BEAST_EXPECT(offer[sfTakerPays] == BTC(3'537'743'015'958'622)); + BEAST_EXPECT(offer[sfTakerGets] == jpy(2'230'659'191'281'247)); + BEAST_EXPECT(offer[sfTakerPays] == btc(3'537'743'015'958'622)); } }; testHelper2TokensMix(test); @@ -3527,19 +3528,19 @@ public: env.fund(startXrpBalance, gw); env.close(); - auto const BTC = issue1( + auto const btc = issue1( {.env = env, .token = "BTC", .issuer = gw, .transferFee = 25'000}); - using tBTC = std::decay_t; + using tBTC = std::decay_t; env.close(); - auto const USD = issue2( + auto const usd = issue2( {.env = env, .token = "USD", .issuer = gw, .transferFee = 25'000}); - using tUSD = std::decay_t; + using tUSD = std::decay_t; env.close(); // Test cases @@ -3567,10 +3568,10 @@ public: // clang-format off TestData const tests[]{ // btcStart --------------------- actor[0] --------------------- -------------------- actor[1] ------------------- - {0, 0, 1, BTC(200), {{"ann", 0, drops(3900000'000000 - (4 * baseFee)), BTC(200), USD(3000)}, {"abe", 0, drops(4100000'000000 - (3 * baseFee)), BTC( 0), USD(750)}}}, // no BTC xfer fee - {0, 1, 0, BTC(200), {{"bev", 0, drops(4100000'000000 - (4 * baseFee)), BTC( 75), USD(2000)}, {"bob", 0, drops(3900000'000000 - (3 * baseFee)), BTC(100), USD( 0)}}}, // no USD xfer fee - {0, 0, 0, BTC(200), {{"cam", 0, drops(4000000'000000 - (5 * baseFee)), BTC(200), USD(2000)} }}, // no xfer fee - {0, 1, 0, BTC( 50), {{"deb", 1, drops(4040000'000000 - (4 * baseFee)), BTC( 0), USD(2000)}, {"dan", 1, drops(3960000'000000 - (3 * baseFee)), BTC( 40), USD( 0)}}}, // no USD xfer fee + {0, 0, 1, btc(200), {{"ann", 0, drops(3900000'000000 - (4 * baseFee)), btc(200), usd(3000)}, {"abe", 0, drops(4100000'000000 - (3 * baseFee)), btc( 0), usd(750)}}}, // no BTC xfer fee + {0, 1, 0, btc(200), {{"bev", 0, drops(4100000'000000 - (4 * baseFee)), btc( 75), usd(2000)}, {"bob", 0, drops(3900000'000000 - (3 * baseFee)), btc(100), usd( 0)}}}, // no USD xfer fee + {0, 0, 0, btc(200), {{"cam", 0, drops(4000000'000000 - (5 * baseFee)), btc(200), usd(2000)} }}, // no xfer fee + {0, 1, 0, btc( 50), {{"deb", 1, drops(4040000'000000 - (4 * baseFee)), btc( 0), usd(2000)}, {"dan", 1, drops(3960000'000000 - (3 * baseFee)), btc( 40), usd( 0)}}}, // no USD xfer fee }; // clang-format on @@ -3587,45 +3588,45 @@ public: if constexpr (std::is_same_v) { - auto MBTC = MPTTester(env, gw, BTC); - MBTC.authorize({.account = actor.acct}); + auto mbtc = MPTTester(env, gw, btc); + mbtc.authorize({.account = actor.acct}); } else { - env(trust(actor.acct, BTC(400))); + env(trust(actor.acct, btc(400))); env.close(); } if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw, USD); - MUSD.authorize({.account = actor.acct}); + auto musd = MPTTester(env, gw, usd); + musd.authorize({.account = actor.acct}); } else { - env(trust(actor.acct, USD(8000))); + env(trust(actor.acct, usd(8000))); env.close(); } env.close(); } env(pay(gw, self, t.btcStart)); - env(pay(gw, self, USD(2'000))); + env(pay(gw, self, usd(2'000))); if (self.id() != leg1.id()) - env(pay(gw, leg1, USD(2'000))); + env(pay(gw, leg1, usd(2'000))); env.close(); // Get the initial offers in place. Remember their sequences // so we can delete them later. - env(offer(leg0, BTC(100), XRP(100'000), tfPassive)); + env(offer(leg0, btc(100), XRP(100'000), tfPassive)); env.close(); std::uint32_t const leg0OfferSeq = env.seq(leg0) - 1; - env(offer(leg1, XRP(100'000), USD(1'000), tfPassive)); + env(offer(leg1, XRP(100'000), usd(1'000), tfPassive)); env.close(); std::uint32_t const leg1OfferSeq = env.seq(leg1) - 1; // This is the offer that matters. - env(offer(self, USD(1'000), BTC(100))); + env(offer(self, usd(1'000), btc(100))); env.close(); std::uint32_t const selfOfferSeq = env.seq(self) - 1; @@ -3645,17 +3646,17 @@ public: })); BEAST_EXPECT(offerCount == actor.offers); - env.require(balance(actor.acct, actor.xrp)); - env.require(balance(actor.acct, actor.btc)); - env.require(balance(actor.acct, actor.usd)); + env.require(Balance(actor.acct, actor.xrp)); + env.require(Balance(actor.acct, actor.btc)); + env.require(Balance(actor.acct, actor.usd)); } // Remove any offers that might be left hanging around. They // could bollix up later loops. - env(offer_cancel(leg0, leg0OfferSeq)); + env(offerCancel(leg0, leg0OfferSeq)); env.close(); - env(offer_cancel(leg1, leg1OfferSeq)); + env(offerCancel(leg1, leg1OfferSeq)); env.close(); - env(offer_cancel(self, selfOfferSeq)); + env(offerCancel(self, selfOfferSeq)); env.close(); } }; @@ -3709,12 +3710,12 @@ public: env.fund(startXrpBalance, gw); env.close(); - auto const BTC = issue1( + auto const btc = issue1( {.env = env, .token = "BTC", .issuer = gw, .limit = 40, .transferFee = 25'000}); - using tBTC = std::decay_t; - auto const USD = issue2( + using tBTC = std::decay_t; + auto const usd = issue2( {.env = env, .token = "USD", .issuer = gw, .limit = 8'000, .transferFee = 25'000}); - using tUSD = std::decay_t; + using tUSD = std::decay_t; env.close(); // Test cases @@ -3742,8 +3743,8 @@ public: // clang-format off TestData const flowTests[]{ // btcStart ------------------- actor[0] -------------------- ------------------- actor[1] -------------------- - {0, 0, 1, BTC(5), {{"gay", 1, drops(3950000'000000 - (4 * baseFee)), BTC(5), USD (2500)}, {"gar", 1, drops(4050000'000000 - (3 * baseFee)), BTC(0), USD(1375)}}}, // no BTC xfer fee - {0, 0, 0, BTC(5), {{"hye", 2, drops(4000000'000000 - (5 * baseFee)), BTC(5), USD (2000)} }} // no xfer fee + {0, 0, 1, btc(5), {{"gay", 1, drops(3950000'000000 - (4 * baseFee)), btc(5), usd (2500)}, {"gar", 1, drops(4050000'000000 - (3 * baseFee)), btc(0), usd(1375)}}}, // no BTC xfer fee + {0, 0, 0, btc(5), {{"hye", 2, drops(4000000'000000 - (5 * baseFee)), btc(5), usd (2000)} }} // no xfer fee }; // clang-format on @@ -3760,44 +3761,44 @@ public: if constexpr (std::is_same_v) { - auto MBTC = MPTTester(env, gw, BTC); - MBTC.authorize({.account = actor.acct}); + auto mbtc = MPTTester(env, gw, btc); + mbtc.authorize({.account = actor.acct}); } else { - env(trust(actor.acct, BTC(40))); + env(trust(actor.acct, btc(40))); env.close(); } if constexpr (std::is_same_v) { - auto MUSD = MPTTester(env, gw, USD); - MUSD.authorize({.account = actor.acct}); + auto musd = MPTTester(env, gw, usd); + musd.authorize({.account = actor.acct}); } else { - env(trust(actor.acct, USD(8'000))); + env(trust(actor.acct, usd(8'000))); env.close(); } } env(pay(gw, self, t.btcStart)); - env(pay(gw, self, USD(2'000))); + env(pay(gw, self, usd(2'000))); if (self.id() != leg1.id()) - env(pay(gw, leg1, USD(2'000))); + env(pay(gw, leg1, usd(2'000))); env.close(); // Get the initial offers in place. Remember their sequences // so we can delete them later. - env(offer(leg0, BTC(10), XRP(100'000), tfPassive)); + env(offer(leg0, btc(10), XRP(100'000), tfPassive)); env.close(); std::uint32_t const leg0OfferSeq = env.seq(leg0) - 1; - env(offer(leg1, XRP(100'000), USD(1'000), tfPassive)); + env(offer(leg1, XRP(100'000), usd(1'000), tfPassive)); env.close(); std::uint32_t const leg1OfferSeq = env.seq(leg1) - 1; // This is the offer that matters. - env(offer(self, USD(1'000), BTC(10))); + env(offer(self, usd(1'000), btc(10))); env.close(); std::uint32_t const selfOfferSeq = env.seq(self) - 1; @@ -3817,17 +3818,17 @@ public: })); BEAST_EXPECT(offerCount == actor.offers); - env.require(balance(actor.acct, actor.xrp)); - env.require(balance(actor.acct, actor.btc)); - env.require(balance(actor.acct, actor.usd)); + env.require(Balance(actor.acct, actor.xrp)); + env.require(Balance(actor.acct, actor.btc)); + env.require(Balance(actor.acct, actor.usd)); } // Remove any offers that might be left hanging around. They // could bollix up later loops. - env(offer_cancel(leg0, leg0OfferSeq)); + env(offerCancel(leg0, leg0OfferSeq)); env.close(); - env(offer_cancel(leg1, leg1OfferSeq)); + env(offerCancel(leg1, leg1OfferSeq)); env.close(); - env(offer_cancel(self, selfOfferSeq)); + env(offerCancel(self, selfOfferSeq)); env.close(); } }; @@ -3852,7 +3853,7 @@ public: // GW requires authorization for holders of its IOUs auto gwMUSD = - MPTTester({.env = env, .issuer = gw, .flags = MPTDEXFlags | tfMPTRequireAuth}); + MPTTester({.env = env, .issuer = gw, .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth}); MPT const gwUSD = gwMUSD; // Have gw authorize bob and alice @@ -3865,22 +3866,22 @@ public: env.close(); env.require(offers(alice, 1)); - env.require(balance(alice, gwUSD(0))); + env.require(Balance(alice, gwUSD(0))); env(pay(gw, bob, gwUSD(50))); env.close(); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // Bob's offer should cross Alice's env(offer(bob, XRP(4'000), gwUSD(40))); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(40))); + env.require(Balance(alice, gwUSD(40))); env.require(offers(bob, 0)); - env.require(balance(bob, gwUSD(10))); + env.require(Balance(bob, gwUSD(10))); } void @@ -3911,23 +3912,23 @@ public: env.close(); auto gwMUSD = - MPTTester({.env = env, .issuer = gw, .flags = MPTDEXFlags | tfMPTRequireAuth}); + MPTTester({.env = env, .issuer = gw, .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth}); MPT const gwUSD = gwMUSD; // alice can't create an offer because alice doesn't own // MPToken and MPTokenIssuance requires authorization - env(offer(alice, gwUSD(40), XRP(4'000)), ter(tecNO_AUTH)); + env(offer(alice, gwUSD(40), XRP(4'000)), Ter(tecNO_AUTH)); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(none))); + env.require(Balance(alice, gwUSD(kNONE))); gwMUSD.authorize({.account = bob}); gwMUSD.authorize({.account = gw, .holder = bob}); env(pay(gw, bob, gwUSD(50))); env.close(); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // bob can create an offer since bob owns MPToken // and it is authorized. @@ -3941,17 +3942,17 @@ public: // should still not be able to create an offer for USD/gw. gwMUSD.authorize({.account = alice}); - env(offer(alice, gwUSD(40), XRP(4'000)), ter(tecNO_AUTH)); + env(offer(alice, gwUSD(40), XRP(4'000)), Ter(tecNO_AUTH)); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(0))); + env.require(Balance(alice, gwUSD(0))); env.require(offers(bob, 1)); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // Delete bob's offer so alice can create an offer without crossing. - env(offer_cancel(bob, bobOfferSeq)); + env(offerCancel(bob, bobOfferSeq)); env.close(); env.require(offers(bob, 0)); @@ -3969,10 +3970,10 @@ public: env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(40))); + env.require(Balance(alice, gwUSD(40))); env.require(offers(bob, 0)); - env.require(balance(bob, gwUSD(10))); + env.require(Balance(bob, gwUSD(10))); } void @@ -3991,7 +3992,7 @@ public: env.close(); auto gwMUSD = - MPTTester({.env = env, .issuer = gw, .flags = MPTDEXFlags | tfMPTRequireAuth}); + MPTTester({.env = env, .issuer = gw, .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth}); MPT const gwUSD = gwMUSD; // Test that gw can create an offer to buy gw's currency. @@ -4001,7 +4002,7 @@ public: env.require(offers(gw, 1)); // Cancel gw's offer - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); env.require(offers(gw, 0)); @@ -4022,14 +4023,14 @@ public: env(pay(gw, alice, gwUSD(50))); env.close(); - env.require(balance(alice, gwUSD(50))); + env.require(Balance(alice, gwUSD(50))); // alice's offer should cross gw's env(offer(alice, XRP(4'000), gwUSD(40))); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(10))); + env.require(Balance(alice, gwUSD(10))); env.require(offers(gw, 0)); } @@ -4042,7 +4043,7 @@ public: testcase("Deleted offer issuer"); - auto MPTokenExists = + auto mpTokenExists = [](jtx::Env const& env, AccountID const& account, MPTID const& issuanceID) -> bool { return bool(env.le(keylet::mptoken(issuanceID, account))); }; @@ -4056,36 +4057,36 @@ public: env.fund(XRP(10'000), alice, becky, carol, noripple(gw)); - auto MUSD = MPTTester({.env = env, .issuer = gw}); - MPT const USD = MUSD; + auto musd = MPTTester({.env = env, .issuer = gw}); + MPT const usd = musd; - MUSD.authorize({.account = becky}); - BEAST_EXPECT(MPTokenExists(env, becky, USD.issuanceID)); - env(pay(gw, becky, USD(5))); + musd.authorize({.account = becky}); + BEAST_EXPECT(mpTokenExists(env, becky, usd.issuanceID)); + env(pay(gw, becky, usd(5))); env.close(); - auto MBUX = MPTTester({.env = env, .issuer = alice}); - MPT const BUX = MBUX; + auto mbux = MPTTester({.env = env, .issuer = alice}); + MPT const bux = mbux; // Make offers that produce USD and can be crossed two ways: // direct XRP -> USD // direct BUX -> USD - env(offer(becky, XRP(2), USD(2)), txflags(tfPassive)); + env(offer(becky, XRP(2), usd(2)), Txflags(tfPassive)); std::uint32_t const beckyBuxUsdSeq{env.seq(becky)}; - env(offer(becky, BUX(3), USD(3)), txflags(tfPassive)); + env(offer(becky, bux(3), usd(3)), Txflags(tfPassive)); env.close(); // becky keeps the offers, but removes MPT. - env(pay(becky, gw, USD(5))); - MUSD.authorize({.account = becky, .flags = tfMPTUnauthorize}); + env(pay(becky, gw, usd(5))); + musd.authorize({.account = becky, .flags = tfMPTUnauthorize}); - BEAST_EXPECT(!MPTokenExists(env, becky, USD.issuanceID)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(!mpTokenExists(env, becky, usd.issuanceID)); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // Have to delete MPTokenIssuance in order to delete // the issuer account. - MUSD.destroy({}); + musd.destroy({}); // Delete gw's account. { @@ -4102,7 +4103,7 @@ public: env.close(); // Account deletion has a high fee. Account for that. - env(acctdelete(gw, alice), fee(drops(env.current()->fees().increment))); + env(acctdelete(gw, alice), Fee(drops(env.current()->fees().increment))); env.close(); // Verify that gw's account root is gone from the ledger. @@ -4111,38 +4112,38 @@ public: // alice crosses becky's first offer. The offer create fails because // the USD issuer is not in the ledger. - env(offer(alice, USD(2), XRP(2)), ter(tecNO_ISSUER)); + env(offer(alice, usd(2), XRP(2)), Ter(tecNO_ISSUER)); env.close(); env.require(offers(alice, 0)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // alice crosses becky's second offer. Again, the offer create fails // because the USD issuer is not in the ledger. - env(offer(alice, USD(3), BUX(3)), ter(tecNO_ISSUER)); + env(offer(alice, usd(3), bux(3)), Ter(tecNO_ISSUER)); env.require(offers(alice, 0)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // Cancel becky's BUX -> USD offer so we can try auto-bridging. - env(offer_cancel(becky, beckyBuxUsdSeq)); + env(offerCancel(becky, beckyBuxUsdSeq)); env.close(); - BEAST_EXPECT(!isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(!isOffer(env, becky, bux(3), usd(3))); // alice creates an offer that can be auto-bridged with becky's // remaining offer. - MBUX.authorize({.account = carol}); - env(pay(alice, carol, BUX(2))); + mbux.authorize({.account = carol}); + env(pay(alice, carol, bux(2))); - env(offer(alice, BUX(2), XRP(2))); + env(offer(alice, bux(2), XRP(2))); env.close(); // carol attempts the auto-bridge. Again, the offer create fails // because the USD issuer is not in the ledger. - env(offer(carol, USD(2), BUX(2)), ter(tecNO_ISSUER)); + env(offer(carol, usd(2), bux(2)), Ter(tecNO_ISSUER)); env.close(); - BEAST_EXPECT(isOffer(env, alice, BUX(2), XRP(2))); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); + BEAST_EXPECT(isOffer(env, alice, bux(2), XRP(2))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); } // Helper function that returns offers on an account sorted by sequence. @@ -4179,16 +4180,16 @@ public: env.fund(XRP(10'000), gw, alice, bob); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Create four offers from the same account with identical quality // so they go in the same order book. Each offer goes in a different // ledger so the chronology is clear. - std::uint32_t const offerId_0{env.seq(alice)}; - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerId0{env.seq(alice)}; + env(offer(alice, XRP(50), usd(50))); env.close(); // Create two tickets. @@ -4197,71 +4198,71 @@ public: env.close(); // Create another sequence-based offer. - std::uint32_t const offerId_1{env.seq(alice)}; - BEAST_EXPECT(offerId_1 == offerId_0 + 4); - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerId1{env.seq(alice)}; + BEAST_EXPECT(offerId1 == offerId0 + 4); + env(offer(alice, XRP(50), usd(50))); env.close(); // Create two ticket based offers in reverse order. - std::uint32_t const offerId_2{ticketSeq + 1}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerId_2)); + std::uint32_t const offerId2{ticketSeq + 1}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerId2)); env.close(); // Create the last offer. - std::uint32_t const offerId_3{ticketSeq}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerId_3)); + std::uint32_t const offerId3{ticketSeq}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerId3)); env.close(); // Verify that all of alice's offers are present. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 4); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_0); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId_2); - BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerId_1); - env.require(balance(alice, USD(200))); - env.require(owners(alice, 5)); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId0); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId2); + BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerId1); + env.require(Balance(alice, usd(200))); + env.require(Owners(alice, 5)); } // Cross alice's first offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the first offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 3); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_2); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId2); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId1); } // Cross alice's second offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the second offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 2); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_2); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId2); } // Cross alice's third offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the third offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 1); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); } // Cross alice's last offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the third offer alice created was consumed. @@ -4269,10 +4270,10 @@ public: auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.empty()); } - env.require(balance(alice, USD(0))); - env.require(owners(alice, 1)); - env.require(balance(bob, USD(200))); - env.require(owners(bob, 1)); + env.require(Balance(alice, usd(0))); + env.require(Owners(alice, 1)); + env.require(Balance(bob, usd(200))); + env.require(Owners(bob, 1)); } void @@ -4291,99 +4292,99 @@ public: env.fund(XRP(10'000), gw, alice); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice}}); - env.require(owners(alice, 1), tickets(alice, 0)); + env.require(Owners(alice, 1), tickets(alice, 0)); - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Create the first of four offers using a sequence. - std::uint32_t const offerSeqId_0{env.seq(alice)}; - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerSeqId0{env.seq(alice)}; + env(offer(alice, XRP(50), usd(50))); env.close(); - env.require(owners(alice, 2), tickets(alice, 0)); + env.require(Owners(alice, 2), tickets(alice, 0)); // Create four tickets. std::uint32_t const ticketSeq{env.seq(alice) + 1}; env(ticket::create(alice, 4)); env.close(); - env.require(owners(alice, 6), tickets(alice, 4)); + env.require(Owners(alice, 6), tickets(alice, 4)); // Create the second (also sequence-based) offer. - std::uint32_t const offerSeqId_1{env.seq(alice)}; - BEAST_EXPECT(offerSeqId_1 == offerSeqId_0 + 6); - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerSeqId1{env.seq(alice)}; + BEAST_EXPECT(offerSeqId1 == offerSeqId0 + 6); + env(offer(alice, XRP(50), usd(50))); env.close(); // Create the third (ticket-based) offer. - std::uint32_t const offerTixId_0{ticketSeq + 1}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerTixId_0)); + std::uint32_t const offerTixId0{ticketSeq + 1}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerTixId0)); env.close(); // Create the last offer. - std::uint32_t const offerTixId_1{ticketSeq}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerTixId_1)); + std::uint32_t const offerTixId1{ticketSeq}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerTixId1)); env.close(); // Verify that all of alice's offers are present. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 4); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId_0); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerTixId_0); - BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerSeqId_1); - env.require(balance(alice, USD(200))); - env.require(owners(alice, 7)); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId0); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerTixId0); + BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerSeqId1); + env.require(Balance(alice, usd(200))); + env.require(Owners(alice, 7)); } // Use a ticket to cancel an offer created with a sequence. - env(offer_cancel(alice, offerSeqId_0), ticket::use(ticketSeq + 2)); + env(offerCancel(alice, offerSeqId0), ticket::Use(ticketSeq + 2)); env.close(); // Verify that offerSeqId_0 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 3); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId_0); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId0); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerSeqId1); } // Use a ticket to cancel an offer created with a ticket. - env(offer_cancel(alice, offerTixId_0), ticket::use(ticketSeq + 3)); + env(offerCancel(alice, offerTixId0), ticket::Use(ticketSeq + 3)); env.close(); // Verify that offerTixId_0 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 2); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerSeqId1); } // All of alice's tickets should now be used up. - env.require(owners(alice, 3), tickets(alice, 0)); + env.require(Owners(alice, 3), tickets(alice, 0)); // Use a sequence to cancel an offer created with a ticket. - env(offer_cancel(alice, offerTixId_1)); + env(offerCancel(alice, offerTixId1)); env.close(); // Verify that offerTixId_1 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 1); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId1); } // Use a sequence to cancel an offer created with a sequence. - env(offer_cancel(alice, offerSeqId_1)); + env(offerCancel(alice, offerSeqId1)); env.close(); // Verify that offerSeqId_1 was canceled. // All of alice's tickets should now be used up. - env.require(owners(alice, 1), tickets(alice, 0), offers(alice, 0)); + env.require(Owners(alice, 1), tickets(alice, 0), offers(alice, 0)); } void @@ -4402,20 +4403,20 @@ public: env.fund(XRP(1'000), maker, taker); env.close(); - auto const USD = + auto const usd = issue1({.env = env, .token = "USD", .issuer = issuer, .holders = {maker, taker}}); - auto const EUR = + auto const eur = issue2({.env = env, .token = "EUR", .issuer = issuer, .holders = {maker, taker}}); - env(pay(issuer, maker, USD(1'000))); - env(pay(issuer, taker, USD(1'000))); - env(pay(issuer, maker, EUR(1'000))); + env(pay(issuer, maker, usd(1'000))); + env(pay(issuer, taker, usd(1'000))); + env(pay(issuer, maker, eur(1'000))); env.close(); - auto makerUSDBalance = env.balance(maker, USD).value(); - auto takerUSDBalance = env.balance(taker, USD).value(); - auto makerEURBalance = env.balance(maker, EUR).value(); - auto takerEURBalance = env.balance(taker, EUR).value(); + auto makerUSDBalance = env.balance(maker, usd).value(); + auto takerUSDBalance = env.balance(taker, usd).value(); + auto makerEURBalance = env.balance(maker, eur).value(); + auto takerEURBalance = env.balance(taker, eur).value(); auto makerXRPBalance = env.balance(maker, XRP).value(); auto takerXRPBalance = env.balance(taker, XRP).value(); @@ -4423,138 +4424,138 @@ public: { TER const err = features[fixFillOrKill] ? TER(tesSUCCESS) : tecKILLED; - env(offer(maker, XRP(100), USD(100))); + env(offer(maker, XRP(100), usd(100))); env.close(); - env(offer(taker, USD(100), XRP(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, usd(100), XRP(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (err == tesSUCCESS) { - makerUSDBalance -= USD(100); - takerUSDBalance += USD(100); + makerUSDBalance -= usd(100); + takerUSDBalance += usd(100); makerXRPBalance += XRP(100).value(); takerXRPBalance -= XRP(100).value(); } BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), XRP(100))); + env(offer(maker, usd(100), XRP(100))); env.close(); - env(offer(taker, XRP(100), USD(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, XRP(100), usd(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (err == tesSUCCESS) { - makerUSDBalance += USD(100); - takerUSDBalance -= USD(100); + makerUSDBalance += usd(100); + takerUSDBalance -= usd(100); makerXRPBalance -= XRP(100).value(); takerXRPBalance += XRP(100).value(); } BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), EUR(100))); + env(offer(maker, usd(100), eur(100))); env.close(); - env(offer(taker, EUR(100), USD(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, eur(100), usd(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (err == tesSUCCESS) { - makerUSDBalance += USD(100); - takerUSDBalance -= USD(100); - makerEURBalance -= EUR(100); - takerEURBalance += EUR(100); + makerUSDBalance += usd(100); + takerUSDBalance -= usd(100); + makerEURBalance -= eur(100); + takerEURBalance += eur(100); } BEAST_EXPECT(expectOffers(env, taker, 0)); } // tfFillOrKill + tfSell, TakerGets must be filled { - env(offer(maker, XRP(101), USD(101))); + env(offer(maker, XRP(101), usd(101))); env.close(); - env(offer(taker, USD(100), XRP(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, usd(100), XRP(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance -= USD(101); - takerUSDBalance += USD(101); - makerXRPBalance += XRP(101).value() - txfee(env, 1); - takerXRPBalance -= XRP(101).value() + txfee(env, 1); + makerUSDBalance -= usd(101); + takerUSDBalance += usd(101); + makerXRPBalance += XRP(101).value() - txFee(env, 1); + takerXRPBalance -= XRP(101).value() + txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(101), XRP(101))); + env(offer(maker, usd(101), XRP(101))); env.close(); - env(offer(taker, XRP(100), USD(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, XRP(100), usd(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance += USD(101); - takerUSDBalance -= USD(101); - makerXRPBalance -= XRP(101).value() + txfee(env, 1); - takerXRPBalance += XRP(101).value() - txfee(env, 1); + makerUSDBalance += usd(101); + takerUSDBalance -= usd(101); + makerXRPBalance -= XRP(101).value() + txFee(env, 1); + takerXRPBalance += XRP(101).value() - txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(101), EUR(101))); + env(offer(maker, usd(101), eur(101))); env.close(); - env(offer(taker, EUR(100), USD(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, eur(100), usd(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance += USD(101); - takerUSDBalance -= USD(101); - makerEURBalance -= EUR(101); - takerEURBalance += EUR(101); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerUSDBalance += usd(101); + takerUSDBalance -= usd(101); + makerEURBalance -= eur(101); + takerEURBalance += eur(101); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); } // Fail regardless of fixFillOrKill amendment for (auto const flags : {tfFillOrKill, tfFillOrKill + tfSell}) { - env(offer(maker, XRP(100), USD(100))); + env(offer(maker, XRP(100), usd(100))); env.close(); - env(offer(taker, USD(100), XRP(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, usd(100), XRP(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), XRP(100))); + env(offer(maker, usd(100), XRP(100))); env.close(); - env(offer(taker, XRP(100), USD(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, XRP(100), usd(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), EUR(100))); + env(offer(maker, usd(100), eur(100))); env.close(); - env(offer(taker, EUR(100), USD(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, eur(100), usd(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); } BEAST_EXPECT( - env.balance(maker, USD) == makerUSDBalance && - env.balance(taker, USD) == takerUSDBalance && - env.balance(maker, EUR) == makerEURBalance && - env.balance(taker, EUR) == takerEURBalance && + env.balance(maker, usd) == makerUSDBalance && + env.balance(taker, usd) == takerUSDBalance && + env.balance(maker, eur) == makerEURBalance && + env.balance(taker, eur) == takerEURBalance && env.balance(maker, XRP) == makerXRPBalance && env.balance(taker, XRP) == takerXRPBalance); }; @@ -4572,8 +4573,8 @@ public: auto const alice = Account{"alice"}; auto getIOU = [&](Env& env) -> PrettyAsset { - static int i = 0; - std::string const name = "IO" + std::to_string(i++); + static int kI = 0; + std::string const name = "IO" + std::to_string(kI++); auto const iou = gw[name]; env(trust(alice, iou(1'000))); env(pay(gw, alice, iou(100))); @@ -4613,8 +4614,8 @@ public: env.fund(XRP(10'000), gw, alice); env.close(); - auto const XTS = t.toAsset1(env); - auto const XXX = t.toAsset2(env); + auto const xts = t.toAsset1(env); + auto const xxx = t.toAsset2(env); auto tokenType = [](PrettyAsset const& asset) -> std::string { return asset.raw().visit( @@ -4622,7 +4623,7 @@ public: [&](MPTIssue const&) { return "MPTIssue"; }); }; - testcase << "offer: " << tokenType(XTS) << "/" << tokenType(XXX); + testcase << "offer: " << tokenType(xts) << "/" << tokenType(xxx); { // Gateway sets its tick size to 5 @@ -4632,10 +4633,10 @@ public: BEAST_EXPECT((*env.le(gw))[sfTickSize] == 5); } - env(offer(alice, XTS(t.val1), XXX(t.val2))); - env(offer(alice, XTS(t.val2), XXX(t.val1))); - env(offer(alice, XTS(t.val1), XXX(t.val2)), json(jss::Flags, tfSell)); - env(offer(alice, XTS(t.val2), XXX(t.val1)), json(jss::Flags, tfSell)); + env(offer(alice, xts(t.val1), xxx(t.val2))); + env(offer(alice, xts(t.val2), xxx(t.val1))); + env(offer(alice, xts(t.val1), xxx(t.val2)), Json(jss::Flags, tfSell)); + env(offer(alice, xts(t.val2), xxx(t.val1)), Json(jss::Flags, tfSell)); std::map> offers; forEachItem(*env.current(), alice, [&](std::shared_ptr const& sle) { @@ -4650,51 +4651,51 @@ public: // first offer auto it = offers.begin(); BEAST_EXPECT(it != offers.end()); - if (XXX.native() && !XTS.holds()) + if (xxx.native() && !xts.holds()) { BEAST_EXPECT( - it->second.first == XTS(t.val1) && it->second.second == XRPAmount(29'999'400)); + it->second.first == xts(t.val1) && it->second.second == XRPAmount(29'999'400)); } - else if (!XXX.integral()) + else if (!xxx.integral()) { BEAST_EXPECT( - it->second.first == XTS(t.val1) && it->second.second < XXX(t.val2) && - it->second.second > STAmount(XXX, 29'9994, -4)); + it->second.first == xts(t.val1) && it->second.second < xxx(t.val2) && + it->second.second > STAmount(xxx, 29'9994, -4)); } else { - BEAST_EXPECT(it->second.first == XTS(t.val1) && it->second.second == XXX(t.val2)); + BEAST_EXPECT(it->second.first == xts(t.val1) && it->second.second == xxx(t.val2)); } // second offer ++it; BEAST_EXPECT(it != offers.end()); - BEAST_EXPECT(it->second.first == XTS(t.val2) && it->second.second == XXX(t.val1)); + BEAST_EXPECT(it->second.first == xts(t.val2) && it->second.second == xxx(t.val1)); // third offer ++it; BEAST_EXPECT(it != offers.end()); - if (XTS.native() && !XXX.holds()) + if (xts.native() && !xxx.holds()) { BEAST_EXPECT( - it->second.first == XRPAmount(10'000'200) && it->second.second == XXX(t.val2)); + it->second.first == XRPAmount(10'000'200) && it->second.second == xxx(t.val2)); } - else if (!XTS.integral()) + else if (!xts.integral()) { BEAST_EXPECT( - it->second.first == STAmount(XTS, 10'0002, -4) && - it->second.second == XXX(t.val2)); + it->second.first == STAmount(xts, 10'0002, -4) && + it->second.second == xxx(t.val2)); } else { - BEAST_EXPECT(it->second.first == XTS(t.val1) && it->second.second == XXX(t.val2)); + BEAST_EXPECT(it->second.first == xts(t.val1) && it->second.second == xxx(t.val2)); } // fourth offer // exact TakerPays is XTS(1/.033333) ++it; BEAST_EXPECT(it != offers.end()); - BEAST_EXPECT(it->second.first == XTS(t.val2) && it->second.second == XXX(t.val1)); + BEAST_EXPECT(it->second.first == xts(t.val2) && it->second.second == xxx(t.val1)); BEAST_EXPECT(++it == offers.end()); } @@ -4762,8 +4763,8 @@ public: run() override { using namespace jtx; - static FeatureBitset const all{testable_amendments()}; - testAll(all); + static FeatureBitset const kALL{testableAmendments()}; + testAll(kALL); } }; diff --git a/src/test/app/OfferStream_test.cpp b/src/test/app/OfferStream_test.cpp index 9cd3724b7b..72d1c29b42 100644 --- a/src/test/app/OfferStream_test.cpp +++ b/src/test/app/OfferStream_test.cpp @@ -2,7 +2,7 @@ namespace xrpl { -class OfferStream_test : public beast::unit_test::suite +class OfferStream_test : public beast::unit_test::Suite { public: void diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 78bdd3fef2..5d5f16981c 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -56,7 +56,7 @@ namespace xrpl::test { -class OfferBaseUtil_test : public beast::unit_test::suite +class OfferBaseUtil_test : public beast::unit_test::Suite { static XRPAmount reserve(jtx::Env& env, std::uint32_t count) @@ -71,23 +71,23 @@ class OfferBaseUtil_test : public beast::unit_test::suite } static auto - ledgerEntryOffer(jtx::Env& env, jtx::Account const& acct, std::uint32_t offer_seq) + ledgerEntryOffer(jtx::Env& env, jtx::Account const& acct, std::uint32_t offerSeq) { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::offer][jss::account] = acct.human(); - jvParams[jss::offer][jss::seq] = offer_seq; + jvParams[jss::offer][jss::seq] = offerSeq; return env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; } static auto - getBookOffers(jtx::Env& env, Issue const& taker_pays, Issue const& taker_gets) + getBookOffers(jtx::Env& env, Issue const& takerPays, Issue const& takerGets) { - Json::Value jvbp; + json::Value jvbp; jvbp[jss::ledger_index] = "current"; - jvbp[jss::taker_pays][jss::currency] = to_string(taker_pays.currency); - jvbp[jss::taker_pays][jss::issuer] = to_string(taker_pays.account); - jvbp[jss::taker_gets][jss::currency] = to_string(taker_gets.currency); - jvbp[jss::taker_gets][jss::issuer] = to_string(taker_gets.account); + jvbp[jss::taker_pays][jss::currency] = to_string(takerPays.currency); + jvbp[jss::taker_pays][jss::issuer] = to_string(takerPays.account); + jvbp[jss::taker_gets][jss::currency] = to_string(takerGets.currency); + jvbp[jss::taker_gets][jss::issuer] = to_string(takerGets.account); return env.rpc("json", "book_offers", to_string(jvbp))[jss::result]; } @@ -110,46 +110,46 @@ public: Env env{*this, features}; auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; Account const alice{"alice"}; Account const bob{"bob"}; Account const carol{"carol"}; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(BTC(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(btc(1000), alice, bob, carol); - env(pay(gw, alice, BTC(1000))); + env(pay(gw, alice, btc(1000))); - env(pay(gw, carol, USD(1000))); - env(pay(gw, carol, BTC(1000))); + env(pay(gw, carol, usd(1000))); + env(pay(gw, carol, btc(1000))); // Must be two offers at the same quality // "taker gets" must be XRP // (Different amounts so I can distinguish the offers) - env(offer(carol, BTC(49), XRP(49))); - env(offer(carol, BTC(51), XRP(51))); + env(offer(carol, btc(49), XRP(49))); + env(offer(carol, btc(51), XRP(51))); // Offers for the poor quality path // Must be two offers at the same quality - env(offer(carol, XRP(50), USD(50))); - env(offer(carol, XRP(50), USD(50))); + env(offer(carol, XRP(50), usd(50))); + env(offer(carol, XRP(50), usd(50))); // Offers for the good quality path - env(offer(carol, BTC(1), USD(100))); + env(offer(carol, btc(1), usd(100))); - PathSet const paths(Path(XRP, USD), Path(USD)); + PathSet const paths(TestPath(XRP, usd), TestPath(usd)); - env(pay(alice, bob, USD(100)), - json(paths.json()), - sendmax(BTC(1000)), - txflags(tfPartialPayment)); + env(pay(alice, bob, usd(100)), + Json(paths.json()), + Sendmax(btc(1000)), + Txflags(tfPartialPayment)); - env.require(balance(bob, USD(100))); + env.require(Balance(bob, usd(100))); BEAST_EXPECT( - !isOffer(env, carol, BTC(1), USD(100)) && isOffer(env, carol, BTC(49), XRP(49))); + !isOffer(env, carol, btc(1), usd(100)) && isOffer(env, carol, btc(49), XRP(49))); } void @@ -162,70 +162,70 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), alice, gw); env.close(); - env.trust(USD(100), alice); + env.trust(usd(100), alice); env.close(); - env(pay(gw, alice, USD(50))); + env(pay(gw, alice, usd(50))); env.close(); auto const offer1Seq = env.seq(alice); - env(offer(alice, XRP(500), USD(100)), require(offers(alice, 1))); + env(offer(alice, XRP(500), usd(100)), Require(offers(alice, 1))); env.close(); - BEAST_EXPECT(isOffer(env, alice, XRP(500), USD(100))); + BEAST_EXPECT(isOffer(env, alice, XRP(500), usd(100))); // cancel the offer above and replace it with a new offer auto const offer2Seq = env.seq(alice); - env(offer(alice, XRP(300), USD(100)), - json(jss::OfferSequence, offer1Seq), - require(offers(alice, 1))); + env(offer(alice, XRP(300), usd(100)), + Json(jss::OfferSequence, offer1Seq), + Require(offers(alice, 1))); env.close(); BEAST_EXPECT( - isOffer(env, alice, XRP(300), USD(100)) && !isOffer(env, alice, XRP(500), USD(100))); + isOffer(env, alice, XRP(300), usd(100)) && !isOffer(env, alice, XRP(500), usd(100))); // Test canceling non-existent offer. // auto const offer3Seq = env.seq (alice); - env(offer(alice, XRP(400), USD(200)), - json(jss::OfferSequence, offer1Seq), - require(offers(alice, 2))); + env(offer(alice, XRP(400), usd(200)), + Json(jss::OfferSequence, offer1Seq), + Require(offers(alice, 2))); env.close(); BEAST_EXPECT( - isOffer(env, alice, XRP(300), USD(100)) && isOffer(env, alice, XRP(400), USD(200))); + isOffer(env, alice, XRP(300), usd(100)) && isOffer(env, alice, XRP(400), usd(200))); // Test cancellation now with OfferCancel tx auto const offer4Seq = env.seq(alice); - env(offer(alice, XRP(222), USD(111)), require(offers(alice, 3))); + env(offer(alice, XRP(222), usd(111)), Require(offers(alice, 3))); env.close(); - BEAST_EXPECT(isOffer(env, alice, XRP(222), USD(111))); - env(offer_cancel(alice, offer4Seq)); + BEAST_EXPECT(isOffer(env, alice, XRP(222), usd(111))); + env(offerCancel(alice, offer4Seq)); env.close(); BEAST_EXPECT(env.seq(alice) == offer4Seq + 2); - BEAST_EXPECT(!isOffer(env, alice, XRP(222), USD(111))); + BEAST_EXPECT(!isOffer(env, alice, XRP(222), usd(111))); // Create an offer that both fails with a tecEXPIRED code and removes // an offer. Show that the attempt to remove the offer fails. env.require(offers(alice, 2)); - env(offer(alice, XRP(5), USD(2)), - json(sfExpiration.fieldName, lastClose(env)), - json(jss::OfferSequence, offer2Seq), - ter(tecEXPIRED)); + env(offer(alice, XRP(5), usd(2)), + Json(sfExpiration.fieldName, lastClose(env)), + Json(jss::OfferSequence, offer2Seq), + Ter(tecEXPIRED)); env.close(); env.require(offers(alice, 2)); - BEAST_EXPECT(isOffer(env, alice, XRP(300), USD(100))); // offer2 - BEAST_EXPECT(!isOffer(env, alice, XRP(5), USD(2))); // expired + BEAST_EXPECT(isOffer(env, alice, XRP(300), usd(100))); // offer2 + BEAST_EXPECT(!isOffer(env, alice, XRP(5), usd(2))); // expired } void @@ -241,26 +241,26 @@ public: auto const carol = Account{"carol"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); - env(pay(gw, alice, USD(100))); - env(pay(gw, carol, EUR(100))); + env.trust(usd(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); + env(pay(gw, alice, usd(100))); + env(pay(gw, carol, eur(100))); // Create more offers than the loop max count in DeliverNodeReverse // Note: the DeliverNodeReverse code has been removed; however since // this is a regression test the original test is being left as-is for // now. for (int i = 0; i < 101; ++i) - env(offer(carol, USD(1), EUR(2))); + env(offer(carol, usd(1), eur(2))); - env(pay(alice, bob, EUR(epsilon)), path(~EUR), sendmax(USD(100))); + env(pay(alice, bob, eur(kEPSILON)), Path(~eur), Sendmax(usd(100))); } void @@ -292,16 +292,16 @@ public: auto const erin = Account{"erin"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol, dan, erin, gw); env.close(); - env.trust(USD(1000), alice, bob, carol, dan, erin); + env.trust(usd(1000), alice, bob, carol, dan, erin); env.close(); - env(pay(gw, carol, USD(0.99999))); - env(pay(gw, dan, USD(1))); - env(pay(gw, erin, USD(1))); + env(pay(gw, carol, usd(0.99999))); + env(pay(gw, dan, usd(1))); + env(pay(gw, erin, usd(1))); env.close(); // Carol doesn't quite have enough funds for this offer @@ -309,10 +309,10 @@ public: // STAmount to incorrectly round to zero when the next offer // (at a good quality) is considered. (when the now removed // stAmountCalcSwitchover2 patch was inactive) - env(offer(carol, drops(1), USD(0.99999))); + env(offer(carol, drops(1), usd(0.99999))); // Offer at a quality poor enough so when the input xrp is // calculated in the reverse pass, the amount is not zero. - env(offer(dan, XRP(100), USD(1))); + env(offer(dan, XRP(100), usd(1))); env.close(); // This is the funded offer that will be incorrectly removed. @@ -321,18 +321,18 @@ public: // needed for this offer, it will incorrectly compute zero in both // the forward and reverse passes (when the now removed // stAmountCalcSwitchover2 was inactive.) - env(offer(erin, drops(2), USD(1))); + env(offer(erin, drops(2), usd(1))); - env(pay(alice, bob, USD(1)), - path(~USD), - sendmax(XRP(102)), - txflags(tfNoRippleDirect | tfPartialPayment)); + env(pay(alice, bob, usd(1)), + Path(~usd), + Sendmax(XRP(102)), + Txflags(tfNoRippleDirect | tfPartialPayment)); env.require(offers(carol, 0), offers(dan, 1)); // offer was correctly consumed. There is still some // liquidity left on that offer. - env.require(balance(erin, USD(0.99999)), offers(erin, 1)); + env.require(Balance(erin, usd(0.99999)), offers(erin, 1)); } void @@ -352,7 +352,7 @@ public: auto const carol = Account{"carol"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Test offer crossing for (auto crossBothOffers : {false, true}) @@ -361,39 +361,39 @@ public: env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); // underfund carol's offer - auto initialCarolUSD = USD(0.499); + auto initialCarolUSD = usd(0.499); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); env.close(); // This offer is underfunded - env(offer(carol, drops(1), USD(1))); + env(offer(carol, drops(1), usd(1))); env.close(); // offer at a lower quality - env(offer(bob, drops(2), USD(1), tfPassive)); + env(offer(bob, drops(2), usd(1), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); // alice places an offer that crosses carol's; depending on // "crossBothOffers" it may cross bob's as well auto aliceTakerGets = crossBothOffers ? drops(2) : drops(1); - env(offer(alice, USD(1), aliceTakerGets)); + env(offer(alice, usd(1), aliceTakerGets)); env.close(); env.require( offers(carol, 0), - balance( + Balance( carol, initialCarolUSD)); // offer is removed but not taken if (crossBothOffers) { - env.require(offers(alice, 0), balance(alice, USD(1))); // alice's offer is crossed + env.require(offers(alice, 0), Balance(alice, usd(1))); // alice's offer is crossed } else { env.require( - offers(alice, 1), balance(alice, USD(0))); // alice's offer is not crossed + offers(alice, 1), Balance(alice, usd(0))); // alice's offer is not crossed } } @@ -404,16 +404,16 @@ public: env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); env.close(); - auto const initialCarolUSD = USD(0.999); + auto const initialCarolUSD = usd(0.999); env(pay(gw, carol, initialCarolUSD)); env.close(); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); env.close(); - env(offer(carol, drops(1), USD(1))); + env(offer(carol, drops(1), usd(1))); env.close(); - env(offer(bob, drops(2), USD(2), tfPassive)); + env(offer(bob, drops(2), usd(2), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); @@ -422,17 +422,17 @@ public: TER const expectedTer = partialPayment ? TER{tesSUCCESS} : TER{tecPATH_PARTIAL}; - env(pay(alice, bob, USD(5)), - path(~USD), - sendmax(XRP(1)), - txflags(flags), - ter(expectedTer)); + env(pay(alice, bob, usd(5)), + Path(~usd), + Sendmax(XRP(1)), + Txflags(flags), + Ter(expectedTer)); env.close(); if (isTesSuccess(expectedTer)) { env.require(offers(carol, 0)); - env.require(balance(carol, + env.require(Balance(carol, initialCarolUSD)); // offer is removed but not taken } else @@ -462,8 +462,8 @@ public: auto const carol = Account{"carol"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; auto tinyAmount = [&](IOU const& iou) -> PrettyAmount { STAmount const amt( @@ -480,42 +480,42 @@ public: env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); // underfund carol's offer - auto initialCarolUSD = tinyAmount(USD); + auto initialCarolUSD = tinyAmount(usd); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100))); - env(pay(gw, alice, EUR(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); // This offer is underfunded - env(offer(carol, EUR(1), USD(10))); + env(offer(carol, eur(1), usd(10))); env.close(); // offer at a lower quality - env(offer(bob, EUR(1), USD(5), tfPassive)); + env(offer(bob, eur(1), usd(5), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); // alice places an offer that crosses carol's; depending on // "crossBothOffers" it may cross bob's as well // Whatever - auto aliceTakerGets = crossBothOffers ? EUR(0.2) : EUR(0.1); - env(offer(alice, USD(1), aliceTakerGets)); + auto aliceTakerGets = crossBothOffers ? eur(0.2) : eur(0.1); + env(offer(alice, usd(1), aliceTakerGets)); env.close(); env.require( offers(carol, 0), - balance( + Balance( carol, initialCarolUSD)); // offer is removed but not taken if (crossBothOffers) { - env.require(offers(alice, 0), balance(alice, USD(1))); // alice's offer is crossed + env.require(offers(alice, 0), Balance(alice, usd(1))); // alice's offer is crossed } else { env.require( - offers(alice, 1), balance(alice, USD(0))); // alice's offer is not crossed + offers(alice, 1), Balance(alice, usd(0))); // alice's offer is not crossed } } @@ -526,19 +526,19 @@ public: env.fund(XRP(10000), alice, bob, carol, gw); env.close(); - env.trust(USD(1000), alice, bob, carol); - env.trust(EUR(1000), alice, bob, carol); + env.trust(usd(1000), alice, bob, carol); + env.trust(eur(1000), alice, bob, carol); env.close(); // underfund carol's offer - auto const initialCarolUSD = tinyAmount(USD); + auto const initialCarolUSD = tinyAmount(usd); env(pay(gw, carol, initialCarolUSD)); - env(pay(gw, bob, USD(100))); - env(pay(gw, alice, EUR(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, alice, eur(100))); env.close(); // This offer is underfunded - env(offer(carol, EUR(1), USD(2))); + env(offer(carol, eur(1), usd(2))); env.close(); - env(offer(bob, EUR(2), USD(4), tfPassive)); + env(offer(bob, eur(2), usd(4), tfPassive)); env.close(); env.require(offers(bob, 1), offers(carol, 1)); @@ -547,17 +547,17 @@ public: TER const expectedTer = partialPayment ? TER{tesSUCCESS} : TER{tecPATH_PARTIAL}; - env(pay(alice, bob, USD(5)), - path(~USD), - sendmax(EUR(10)), - txflags(flags), - ter(expectedTer)); + env(pay(alice, bob, usd(5)), + Path(~usd), + Sendmax(eur(10)), + Txflags(flags), + Ter(expectedTer)); env.close(); if (isTesSuccess(expectedTer)) { env.require(offers(carol, 0)); - env.require(balance(carol, + env.require(Balance(carol, initialCarolUSD)); // offer is removed but not taken } else @@ -578,9 +578,9 @@ public: using namespace jtx; auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; + auto const eur = gw["EUR"]; Account const alice{"alice"}; Account const bob{"bob"}; Account const carol{"carol"}; @@ -591,58 +591,58 @@ public: Env env{*this, features}; auto const gw1 = Account{"gw1"}; - auto const USD1 = gw1["USD"]; + auto const usD1 = gw1["USD"]; auto const gw2 = Account{"gw2"}; - auto const USD2 = gw2["USD"]; + auto const usD2 = gw2["USD"]; env.fund(XRP(10000), alice, noripple(bob), carol, dan, gw1, gw2); env.close(); - env.trust(USD1(1000), alice, carol, dan); - env(trust(bob, USD1(1000), tfSetNoRipple)); - env.trust(USD2(1000), alice, carol, dan); - env(trust(bob, USD2(1000), tfSetNoRipple)); + env.trust(usD1(1000), alice, carol, dan); + env(trust(bob, usD1(1000), tfSetNoRipple)); + env.trust(usD2(1000), alice, carol, dan); + env(trust(bob, usD2(1000), tfSetNoRipple)); - env(pay(gw1, dan, USD1(50))); - env(pay(gw1, bob, USD1(50))); - env(pay(gw2, bob, USD2(50))); + env(pay(gw1, dan, usD1(50))); + env(pay(gw1, bob, usD1(50))); + env(pay(gw2, bob, usD2(50))); - env(offer(dan, XRP(50), USD1(50))); + env(offer(dan, XRP(50), usD1(50))); - env(pay(alice, carol, USD2(50)), - path(~USD1, bob), - sendmax(XRP(50)), - txflags(tfNoRippleDirect), - ter(tecPATH_DRY)); + env(pay(alice, carol, usD2(50)), + Path(~usD1, bob), + Sendmax(XRP(50)), + Txflags(tfNoRippleDirect), + Ter(tecPATH_DRY)); } { // Make sure payment works with default flags Env env{*this, features}; auto const gw1 = Account{"gw1"}; - auto const USD1 = gw1["USD"]; + auto const usD1 = gw1["USD"]; auto const gw2 = Account{"gw2"}; - auto const USD2 = gw2["USD"]; + auto const usD2 = gw2["USD"]; env.fund(XRP(10000), alice, bob, carol, dan, gw1, gw2); env.close(); - env.trust(USD1(1000), alice, bob, carol, dan); - env.trust(USD2(1000), alice, bob, carol, dan); + env.trust(usD1(1000), alice, bob, carol, dan); + env.trust(usD2(1000), alice, bob, carol, dan); - env(pay(gw1, dan, USD1(50))); - env(pay(gw1, bob, USD1(50))); - env(pay(gw2, bob, USD2(50))); + env(pay(gw1, dan, usD1(50))); + env(pay(gw1, bob, usD1(50))); + env(pay(gw2, bob, usD2(50))); - env(offer(dan, XRP(50), USD1(50))); + env(offer(dan, XRP(50), usD1(50))); - env(pay(alice, carol, USD2(50)), - path(~USD1, bob), - sendmax(XRP(50)), - txflags(tfNoRippleDirect)); + env(pay(alice, carol, usD2(50)), + Path(~usD1, bob), + Sendmax(XRP(50)), + Txflags(tfNoRippleDirect)); - env.require(balance(alice, xrpMinusFee(env, 10000 - 50))); - env.require(balance(bob, USD1(100))); - env.require(balance(bob, USD2(0))); - env.require(balance(carol, USD2(50))); + env.require(Balance(alice, xrpMinusFee(env, 10000 - 50))); + env.require(Balance(bob, usD1(100))); + env.require(Balance(bob, usD2(0))); + env.require(Balance(carol, usD2(50))); } } @@ -663,9 +663,9 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; auto const carol = Account{"carol"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; - auto const usdOffer = USD(1000); + auto const usdOffer = usd(1000); auto const xrpOffer = XRP(1000); // No crossing: @@ -679,11 +679,11 @@ public: env.fund(r + f, alice); - env(trust(alice, usdOffer), ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tecINSUF_RESERVE_OFFER)); + env(trust(alice, usdOffer), Ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tecINSUF_RESERVE_OFFER)); - env.require(balance(alice, r - f), owners(alice, 1)); + env.require(Balance(alice, r - f), Owners(alice, 1)); } // Partial cross: @@ -695,25 +695,25 @@ public: auto const f = env.current()->fees().base; auto const r = reserve(env, 0); - auto const usdOffer2 = USD(500); + auto const usdOffer2 = usd(500); auto const xrpOffer2 = XRP(500); env.fund(r + f + xrpOffer, bob); - env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); + env(offer(bob, usdOffer2, xrpOffer2), Ter(tesSUCCESS)); env.fund(r + f, alice); - env(trust(alice, usdOffer), ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); + env(trust(alice, usdOffer), Ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tesSUCCESS)); env.require( - balance(alice, r - f + xrpOffer2), - balance(alice, usdOffer2), - owners(alice, 1), - balance(bob, r + xrpOffer2), - balance(bob, usdOffer2), - owners(bob, 1)); + Balance(alice, r - f + xrpOffer2), + Balance(alice, usdOffer2), + Owners(alice, 1), + Balance(bob, r + xrpOffer2), + Balance(bob, usdOffer2), + Owners(bob, 1)); } // Account has enough reserve as is, but not enough @@ -727,30 +727,30 @@ public: auto const f = env.current()->fees().base; auto const r = reserve(env, 0); - auto const usdOffer2 = USD(500); + auto const usdOffer2 = usd(500); auto const xrpOffer2 = XRP(500); env.fund(r + f + xrpOffer, bob, carol); - env(offer(bob, usdOffer2, xrpOffer2), ter(tesSUCCESS)); - env(offer(carol, usdOffer, xrpOffer), ter(tesSUCCESS)); + env(offer(bob, usdOffer2, xrpOffer2), Ter(tesSUCCESS)); + env(offer(carol, usdOffer, xrpOffer), Ter(tesSUCCESS)); env.fund(r + f, alice); - env(trust(alice, usdOffer), ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); - env(offer(alice, xrpOffer, usdOffer), ter(tesSUCCESS)); + env(trust(alice, usdOffer), Ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); + env(offer(alice, xrpOffer, usdOffer), Ter(tesSUCCESS)); env.require( - balance(alice, r - f + xrpOffer), - balance(alice, USD(0)), - owners(alice, 1), - balance(bob, r + xrpOffer2), - balance(bob, usdOffer2), - owners(bob, 1), - balance(carol, r + xrpOffer2), - balance(carol, usdOffer2), - owners(carol, 2)); + Balance(alice, r - f + xrpOffer), + Balance(alice, usd(0)), + Owners(alice, 1), + Balance(bob, r + xrpOffer2), + Balance(bob, usdOffer2), + Owners(bob, 1), + Balance(carol, r + xrpOffer2), + Balance(carol, usdOffer2), + Owners(carol, 2)); } } @@ -777,7 +777,7 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Fill or Kill - unless we fully cross, just charge a fee and don't // place the offer on the books. But also clean up expired offers @@ -791,48 +791,48 @@ public: env.close(); // bob creates an offer that expires before the next ledger close. - env(offer(bob, USD(500), XRP(500)), - json(sfExpiration.fieldName, lastClose(env) + 1), - ter(tesSUCCESS)); + env(offer(bob, usd(500), XRP(500)), + Json(sfExpiration.fieldName, lastClose(env) + 1), + Ter(tesSUCCESS)); // The offer expires (it's not removed yet). env.close(); - env.require(owners(bob, 1), offers(bob, 1)); + env.require(Owners(bob, 1), offers(bob, 1)); // bob creates the offer that will be crossed. - env(offer(bob, USD(500), XRP(500)), ter(tesSUCCESS)); + env(offer(bob, usd(500), XRP(500)), Ter(tesSUCCESS)); env.close(); - env.require(owners(bob, 2), offers(bob, 2)); + env.require(Owners(bob, 2), offers(bob, 2)); - env(trust(alice, USD(1000)), ter(tesSUCCESS)); - env(pay(gw, alice, USD(1000)), ter(tesSUCCESS)); + env(trust(alice, usd(1000)), Ter(tesSUCCESS)); + env(pay(gw, alice, usd(1000)), Ter(tesSUCCESS)); // Order that can't be filled but will remove bob's expired offer: { TER const killedCode{TER{tecKILLED}}; - env(offer(alice, XRP(1000), USD(1000)), txflags(tfFillOrKill), ter(killedCode)); + env(offer(alice, XRP(1000), usd(1000)), Txflags(tfFillOrKill), Ter(killedCode)); } env.require( - balance(alice, startBalance - (f * 2)), - balance(alice, USD(1000)), - owners(alice, 1), + Balance(alice, startBalance - (f * 2)), + Balance(alice, usd(1000)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - (f * 2)), - balance(bob, USD(none)), - owners(bob, 1), + Balance(bob, startBalance - (f * 2)), + Balance(bob, usd(kNONE)), + Owners(bob, 1), offers(bob, 1)); // Order that can be filled - env(offer(alice, XRP(500), USD(500)), txflags(tfFillOrKill), ter(tesSUCCESS)); + env(offer(alice, XRP(500), usd(500)), Txflags(tfFillOrKill), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - (f * 3) + XRP(500)), - balance(alice, USD(500)), - owners(alice, 1), + Balance(alice, startBalance - (f * 3) + XRP(500)), + Balance(alice, usd(500)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - (f * 2) - XRP(500)), - balance(bob, USD(500)), - owners(bob, 1), + Balance(bob, startBalance - (f * 2) - XRP(500)), + Balance(bob, usd(500)), + Owners(bob, 1), offers(bob, 0)); } @@ -846,49 +846,49 @@ public: env.fund(startBalance, gw, alice, bob); env.close(); - env(trust(alice, USD(1000)), ter(tesSUCCESS)); - env(pay(gw, alice, USD(1000)), ter(tesSUCCESS)); + env(trust(alice, usd(1000)), Ter(tesSUCCESS)); + env(pay(gw, alice, usd(1000)), Ter(tesSUCCESS)); // No cross: { TER const expectedCode = tecKILLED; - env(offer(alice, XRP(1000), USD(1000)), - txflags(tfImmediateOrCancel), - ter(expectedCode)); + env(offer(alice, XRP(1000), usd(1000)), + Txflags(tfImmediateOrCancel), + Ter(expectedCode)); } env.require( - balance(alice, startBalance - f - f), - balance(alice, USD(1000)), - owners(alice, 1), + Balance(alice, startBalance - f - f), + Balance(alice, usd(1000)), + Owners(alice, 1), offers(alice, 0)); // Partially cross: - env(offer(bob, USD(50), XRP(50)), ter(tesSUCCESS)); - env(offer(alice, XRP(1000), USD(1000)), txflags(tfImmediateOrCancel), ter(tesSUCCESS)); + env(offer(bob, usd(50), XRP(50)), Ter(tesSUCCESS)); + env(offer(alice, XRP(1000), usd(1000)), Txflags(tfImmediateOrCancel), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f + XRP(50)), - balance(alice, USD(950)), - owners(alice, 1), + Balance(alice, startBalance - f - f - f + XRP(50)), + Balance(alice, usd(950)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - f - XRP(50)), - balance(bob, USD(50)), - owners(bob, 1), + Balance(bob, startBalance - f - XRP(50)), + Balance(bob, usd(50)), + Owners(bob, 1), offers(bob, 0)); // Fully cross: - env(offer(bob, USD(50), XRP(50)), ter(tesSUCCESS)); - env(offer(alice, XRP(50), USD(50)), txflags(tfImmediateOrCancel), ter(tesSUCCESS)); + env(offer(bob, usd(50), XRP(50)), Ter(tesSUCCESS)); + env(offer(alice, XRP(50), usd(50)), Txflags(tfImmediateOrCancel), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f - f + XRP(100)), - balance(alice, USD(900)), - owners(alice, 1), + Balance(alice, startBalance - f - f - f - f + XRP(100)), + Balance(alice, usd(900)), + Owners(alice, 1), offers(alice, 0), - balance(bob, startBalance - f - f - XRP(100)), - balance(bob, USD(100)), - owners(bob, 1), + Balance(bob, startBalance - f - f - XRP(100)), + Balance(bob, usd(100)), + Owners(bob, 1), offers(bob, 0)); } @@ -899,13 +899,13 @@ public: env.fund(startBalance, gw, alice, bob); env.close(); - env(trust(bob, USD(1000))); + env(trust(bob, usd(1000))); env.close(); - env(pay(gw, bob, USD(1000))); + env(pay(gw, bob, usd(1000))); env.close(); - env(offer(alice, USD(1000), XRP(2000))); + env(offer(alice, usd(1000), XRP(2000))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -914,12 +914,12 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfTakerGets] == XRP(2000)); - BEAST_EXPECT(offer[sfTakerPays] == USD(1000)); + BEAST_EXPECT(offer[sfTakerPays] == usd(1000)); } // bob creates a passive offer that could cross alice's. // bob's offer should stay in the ledger. - env(offer(bob, XRP(2000), USD(1000), tfPassive)); + env(offer(bob, XRP(2000), usd(1000), tfPassive)); env.close(); env.require(offers(alice, 1)); @@ -928,18 +928,18 @@ public: for (auto const& offerPtr : bobOffers) { auto const& offer = *offerPtr; - BEAST_EXPECT(offer[sfTakerGets] == USD(1000)); + BEAST_EXPECT(offer[sfTakerGets] == usd(1000)); BEAST_EXPECT(offer[sfTakerPays] == XRP(2000)); } // It should be possible for gw to cross both of those offers. - env(offer(gw, XRP(2000), USD(1000))); + env(offer(gw, XRP(2000), usd(1000))); env.close(); env.require(offers(alice, 0)); env.require(offers(gw, 0)); env.require(offers(bob, 1)); - env(offer(gw, USD(1000), XRP(2000))); + env(offer(gw, usd(1000), XRP(2000))); env.close(); env.require(offers(bob, 0)); env.require(offers(gw, 0)); @@ -952,14 +952,14 @@ public: env.fund(startBalance, gw, "alice", "bob"); env.close(); - env(trust("bob", USD(1000))); + env(trust("bob", usd(1000))); env.close(); - env(pay(gw, "bob", USD(1000))); - env(offer("alice", USD(500), XRP(1001))); + env(pay(gw, "bob", usd(1000))); + env(offer("alice", usd(500), XRP(1001))); env.close(); - env(offer("alice", USD(500), XRP(1000))); + env(offer("alice", usd(500), XRP(1000))); env.close(); auto const aliceOffers = offersOnAccount(env, "alice"); @@ -968,7 +968,7 @@ public: // bob creates a passive offer. That offer should cross one // of alice's (the one with better quality) and leave alice's // other offer untouched. - env(offer("bob", XRP(2000), USD(1000), tfPassive)); + env(offer("bob", XRP(2000), usd(1000), tfPassive)); env.close(); env.require(offers("alice", 1)); @@ -977,7 +977,7 @@ public: for (auto const& offerPtr : bobOffers) { auto const& offer = *offerPtr; - BEAST_EXPECT(offer[sfTakerGets] == USD(499.5)); + BEAST_EXPECT(offer[sfTakerGets] == usd(499.5)); BEAST_EXPECT(offer[sfTakerPays] == XRP(999)); } } @@ -993,7 +993,7 @@ public: auto const startBalance = XRP(1000000); auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; @@ -1001,61 +1001,61 @@ public: env.close(); // Order that has invalid flags - env(offer(alice, USD(1000), XRP(1000)), - txflags(tfImmediateOrCancel + 1), - ter(temINVALID_FLAG)); - env.require(balance(alice, startBalance), owners(alice, 0), offers(alice, 0)); + env(offer(alice, usd(1000), XRP(1000)), + Txflags(tfImmediateOrCancel + 1), + Ter(temINVALID_FLAG)); + env.require(Balance(alice, startBalance), Owners(alice, 0), offers(alice, 0)); // Order with incompatible flags - env(offer(alice, USD(1000), XRP(1000)), - txflags(tfImmediateOrCancel | tfFillOrKill), - ter(temINVALID_FLAG)); - env.require(balance(alice, startBalance), owners(alice, 0), offers(alice, 0)); + env(offer(alice, usd(1000), XRP(1000)), + Txflags(tfImmediateOrCancel | tfFillOrKill), + Ter(temINVALID_FLAG)); + env.require(Balance(alice, startBalance), Owners(alice, 0), offers(alice, 0)); // Sell and buy the same asset { // Alice tries an XRP to XRP order: - env(offer(alice, XRP(1000), XRP(1000)), ter(temBAD_OFFER)); - env.require(owners(alice, 0), offers(alice, 0)); + env(offer(alice, XRP(1000), XRP(1000)), Ter(temBAD_OFFER)); + env.require(Owners(alice, 0), offers(alice, 0)); // Alice tries an IOU to IOU order: - env(trust(alice, USD(1000)), ter(tesSUCCESS)); - env(pay(gw, alice, USD(1000)), ter(tesSUCCESS)); - env(offer(alice, USD(1000), USD(1000)), ter(temREDUNDANT)); - env.require(owners(alice, 1), offers(alice, 0)); + env(trust(alice, usd(1000)), Ter(tesSUCCESS)); + env(pay(gw, alice, usd(1000)), Ter(tesSUCCESS)); + env(offer(alice, usd(1000), usd(1000)), Ter(temREDUNDANT)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Offers with negative amounts { - env(offer(alice, -USD(1000), XRP(1000)), ter(temBAD_OFFER)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, -usd(1000), XRP(1000)), Ter(temBAD_OFFER)); + env.require(Owners(alice, 1), offers(alice, 0)); - env(offer(alice, USD(1000), -XRP(1000)), ter(temBAD_OFFER)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, usd(1000), -XRP(1000)), Ter(temBAD_OFFER)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Offer with a bad expiration { - env(offer(alice, USD(1000), XRP(1000)), - json(sfExpiration.fieldName, std::uint32_t(0)), - ter(temBAD_EXPIRATION)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, usd(1000), XRP(1000)), + Json(sfExpiration.fieldName, std::uint32_t(0)), + Ter(temBAD_EXPIRATION)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Offer with a bad offer sequence { - env(offer(alice, USD(1000), XRP(1000)), - json(jss::OfferSequence, std::uint32_t(0)), - ter(temBAD_SEQUENCE)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, usd(1000), XRP(1000)), + Json(jss::OfferSequence, std::uint32_t(0)), + Ter(temBAD_SEQUENCE)); + env.require(Owners(alice, 1), offers(alice, 0)); } // Use XRP as a currency code { - auto const BAD = IOU(gw, badCurrency()); + auto const bad = IOU(gw, badCurrency()); - env(offer(alice, XRP(1000), BAD(1000)), ter(temBAD_CURRENCY)); - env.require(owners(alice, 1), offers(alice, 0)); + env(offer(alice, XRP(1000), bad(1000)), Ter(temBAD_CURRENCY)); + env.require(Owners(alice, 1), offers(alice, 0)); } } @@ -1069,10 +1069,10 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const startBalance = XRP(1000000); - auto const usdOffer = USD(1000); + auto const usdOffer = usd(1000); auto const xrpOffer = XRP(1000); Env env{*this, features}; @@ -1082,55 +1082,55 @@ public: auto const f = env.current()->fees().base; - env(trust(alice, usdOffer), ter(tesSUCCESS)); - env(pay(gw, alice, usdOffer), ter(tesSUCCESS)); + env(trust(alice, usdOffer), Ter(tesSUCCESS)); + env(pay(gw, alice, usdOffer), Ter(tesSUCCESS)); env.close(); env.require( - balance(alice, startBalance - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1)); + Owners(alice, 1)); env(offer(alice, xrpOffer, usdOffer), - json(sfExpiration.fieldName, lastClose(env)), - ter(tecEXPIRED)); + Json(sfExpiration.fieldName, lastClose(env)), + Ter(tecEXPIRED)); env.require( - balance(alice, startBalance - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1)); + Owners(alice, 1)); env.close(); // Add an offer that expires before the next ledger close env(offer(alice, xrpOffer, usdOffer), - json(sfExpiration.fieldName, lastClose(env) + 1), - ter(tesSUCCESS)); + Json(sfExpiration.fieldName, lastClose(env) + 1), + Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 1), - owners(alice, 2)); + Owners(alice, 2)); // The offer expires (it's not removed yet) env.close(); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 1), - owners(alice, 2)); + Owners(alice, 2)); // Add offer - the expired offer is removed - env(offer(bob, usdOffer, xrpOffer), ter(tesSUCCESS)); + env(offer(bob, usdOffer, xrpOffer), Ter(tesSUCCESS)); env.require( - balance(alice, startBalance - f - f - f), - balance(alice, usdOffer), + Balance(alice, startBalance - f - f - f), + Balance(alice, usdOffer), offers(alice, 0), - owners(alice, 1), - balance(bob, startBalance - f), - balance(bob, USD(none)), + Owners(alice, 1), + Balance(bob, startBalance - f), + Balance(bob, usd(kNONE)), offers(bob, 1), - owners(bob, 1)); + Owners(bob, 1)); } void @@ -1141,9 +1141,9 @@ public: using namespace jtx; auto const gw = Account{"gateway"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; - auto const usdOffer = USD(1000); + auto const usdOffer = usd(1000); auto const xrpOffer = XRP(1000); Env env{*this, features}; @@ -1158,108 +1158,108 @@ public: // fees are subtracted. env.fund(reserve(env, 0), "alice"); env.close(); - env(offer("alice", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); - env.require(balance("alice", reserve(env, 0) - f), owners("alice", 0)); + env(offer("alice", usdOffer, xrpOffer), Ter(tecUNFUNDED_OFFER)); + env.require(Balance("alice", reserve(env, 0) - f), Owners("alice", 0)); // Account has just enough for the reserve and the // fee. env.fund(reserve(env, 0) + f, "bob"); env.close(); - env(offer("bob", usdOffer, xrpOffer), ter(tecUNFUNDED_OFFER)); - env.require(balance("bob", reserve(env, 0)), owners("bob", 0)); + env(offer("bob", usdOffer, xrpOffer), Ter(tecUNFUNDED_OFFER)); + env.require(Balance("bob", reserve(env, 0)), Owners("bob", 0)); // Account has enough for the reserve, the fee and // the offer, and a bit more, but not enough for the // reserve after the offer is placed. env.fund(reserve(env, 0) + f + XRP(1), "carol"); env.close(); - env(offer("carol", usdOffer, xrpOffer), ter(tecINSUF_RESERVE_OFFER)); - env.require(balance("carol", reserve(env, 0) + XRP(1)), owners("carol", 0)); + env(offer("carol", usdOffer, xrpOffer), Ter(tecINSUF_RESERVE_OFFER)); + env.require(Balance("carol", reserve(env, 0) + XRP(1)), Owners("carol", 0)); // Account has enough for the reserve plus one // offer, and the fee. env.fund(reserve(env, 1) + f, "dan"); env.close(); - env(offer("dan", usdOffer, xrpOffer), ter(tesSUCCESS)); - env.require(balance("dan", reserve(env, 1)), owners("dan", 1)); + env(offer("dan", usdOffer, xrpOffer), Ter(tesSUCCESS)); + env.require(Balance("dan", reserve(env, 1)), Owners("dan", 1)); // Account has enough for the reserve plus one // offer, the fee and the entire offer amount. env.fund(reserve(env, 1) + f + xrpOffer, "eve"); env.close(); - env(offer("eve", usdOffer, xrpOffer), ter(tesSUCCESS)); - env.require(balance("eve", reserve(env, 1) + xrpOffer), owners("eve", 1)); + env(offer("eve", usdOffer, xrpOffer), Ter(tesSUCCESS)); + env.require(Balance("eve", reserve(env, 1) + xrpOffer), Owners("eve", 1)); } void - testSelfCross(bool use_partner, FeatureBitset features) + testSelfCross(bool usePartner, FeatureBitset features) { - testcase(std::string("Self-crossing") + (use_partner ? ", with partner account" : "")); + testcase(std::string("Self-crossing") + (usePartner ? ", with partner account" : "")); using namespace jtx; auto const gw = Account{"gateway"}; auto const partner = Account{"partner"}; - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; Env env{*this, features}; env.close(); env.fund(XRP(10000), gw); - if (use_partner) + if (usePartner) { env.fund(XRP(10000), partner); env.close(); - env(trust(partner, USD(100))); - env(trust(partner, BTC(500))); + env(trust(partner, usd(100))); + env(trust(partner, btc(500))); env.close(); - env(pay(gw, partner, USD(100))); - env(pay(gw, partner, BTC(500))); + env(pay(gw, partner, usd(100))); + env(pay(gw, partner, btc(500))); } - auto const& account_to_test = use_partner ? partner : gw; + auto const& accountToTest = usePartner ? partner : gw; env.close(); - env.require(offers(account_to_test, 0)); + env.require(offers(accountToTest, 0)); // PART 1: // we will make two offers that can be used to bridge BTC to USD // through XRP - env(offer(account_to_test, BTC(250), XRP(1000))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, btc(250), XRP(1000))); + env.require(offers(accountToTest, 1)); // validate that the book now shows a BTC for XRP offer - BEAST_EXPECT(isOffer(env, account_to_test, BTC(250), XRP(1000))); + BEAST_EXPECT(isOffer(env, accountToTest, btc(250), XRP(1000))); - auto const secondLegSeq = env.seq(account_to_test); - env(offer(account_to_test, XRP(1000), USD(50))); - env.require(offers(account_to_test, 2)); + auto const secondLegSeq = env.seq(accountToTest); + env(offer(accountToTest, XRP(1000), usd(50))); + env.require(offers(accountToTest, 2)); // validate that the book also shows a XRP for USD offer - BEAST_EXPECT(isOffer(env, account_to_test, XRP(1000), USD(50))); + BEAST_EXPECT(isOffer(env, accountToTest, XRP(1000), usd(50))); // now make an offer that will cross and auto-bridge, meaning - // the outstanding offers will be taken leaving us with none - env(offer(account_to_test, USD(50), BTC(250))); + // the outstanding offers will be taken leaving us with kNONE + env(offer(accountToTest, usd(50), btc(250))); - auto jrr = getBookOffers(env, USD, BTC); + auto jrr = getBookOffers(env, usd, btc); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); - jrr = getBookOffers(env, BTC, XRP); + jrr = getBookOffers(env, btc, XRP); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); // At this point, all offers are expected to be consumed. { - auto acctOffers = offersOnAccount(env, account_to_test); + auto acctOffers = offersOnAccount(env, accountToTest); BEAST_EXPECT(acctOffers.empty()); for (auto const& offerPtr : acctOffers) { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(0)); + BEAST_EXPECT(offer[sfTakerGets] == usd(0)); BEAST_EXPECT(offer[sfTakerPays] == XRP(0)); } } @@ -1267,35 +1267,35 @@ public: // cancel that lingering second offer so that it doesn't interfere // with the next set of offers we test. This will not be needed once // the bridging bug is fixed - env(offer_cancel(account_to_test, secondLegSeq)); - env.require(offers(account_to_test, 0)); + env(offerCancel(accountToTest, secondLegSeq)); + env.require(offers(accountToTest, 0)); // PART 2: // simple direct crossing BTC to USD and then USD to BTC which causes // the first offer to be replaced - env(offer(account_to_test, BTC(250), USD(50))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, btc(250), usd(50))); + env.require(offers(accountToTest, 1)); // validate that the book shows one BTC for USD offer and no USD for // BTC offers - BEAST_EXPECT(isOffer(env, account_to_test, BTC(250), USD(50))); + BEAST_EXPECT(isOffer(env, accountToTest, btc(250), usd(50))); - jrr = getBookOffers(env, USD, BTC); + jrr = getBookOffers(env, usd, btc); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); // this second offer would self-cross directly, so it causes the first // offer by the same owner/taker to be removed - env(offer(account_to_test, USD(50), BTC(250))); - env.require(offers(account_to_test, 1)); + env(offer(accountToTest, usd(50), btc(250))); + env.require(offers(accountToTest, 1)); // validate that we now have just the second offer...the first // was removed - jrr = getBookOffers(env, BTC, USD); + jrr = getBookOffers(env, btc, usd); BEAST_EXPECT(jrr[jss::offers].isArray()); BEAST_EXPECT(jrr[jss::offers].size() == 0); - BEAST_EXPECT(isOffer(env, account_to_test, USD(50), BTC(250))); + BEAST_EXPECT(isOffer(env, accountToTest, usd(50), btc(250))); } void @@ -1317,34 +1317,34 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; + auto const usd = gw["USD"]; + auto const btc = gw["BTC"]; // these *interesting* amounts were taken // from the original JS test that was ported here - auto const gw_initial_balance = drops(1149999730); - auto const alice_initial_balance = drops(499946999680); - auto const bob_initial_balance = drops(10199999920); - auto const small_amount = STAmount{bob["USD"], UINT64_C(2710505431213761), -33}; + auto const gwInitialBalance = drops(1149999730); + auto const aliceInitialBalance = drops(499946999680); + auto const bobInitialBalance = drops(10199999920); + auto const smallAmount = STAmount{bob["USD"], UINT64_C(2710505431213761), -33}; - env.fund(gw_initial_balance, gw); - env.fund(alice_initial_balance, alice); - env.fund(bob_initial_balance, bob); + env.fund(gwInitialBalance, gw); + env.fund(aliceInitialBalance, alice); + env.fund(bobInitialBalance, bob); env.close(); env(rate(gw, 1.005)); - env(trust(alice, USD(500))); - env(trust(bob, USD(50))); + env(trust(alice, usd(500))); + env(trust(bob, usd(50))); env(trust(gw, alice["USD"](100))); env(pay(gw, alice, alice["USD"](50))); - env(pay(gw, bob, small_amount)); + env(pay(gw, bob, smallAmount)); - env(offer(alice, USD(50), XRP(150000))); + env(offer(alice, usd(50), XRP(150000))); // unfund the offer - env(pay(alice, gw, USD(100))); + env(pay(alice, gw, usd(100))); // drop the trust line (set to 0) env(trust(gw, alice["USD"](0))); @@ -1359,7 +1359,7 @@ public: // create crossing offer std::uint32_t const bobOfferSeq = env.seq(bob); - env(offer(bob, XRP(2000), USD(1))); + env(offer(bob, XRP(2000), usd(1))); if (localFeatures[fixReducedOffersV2]) { @@ -1370,7 +1370,7 @@ public: BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName][jss::value] == "-2710505431213761e-33"); - Json::Value const bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq)[jss::node]; + json::Value const bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq)[jss::node]; BEAST_EXPECT(bobOffer[sfTakerGets.jsonName][jss::value] == "1"); BEAST_EXPECT(bobOffer[sfTakerPays.jsonName] == "2000000000"); return; @@ -1389,21 +1389,21 @@ public: BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "50"); BEAST_EXPECT( env.balance(alice, xrpIssue()) == - alice_initial_balance - env.current()->fees().base * 3 - crossingDelta); + aliceInitialBalance - env.current()->fees().base * 3 - crossingDelta); jrr = ledgerEntryState(env, bob, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "0"); BEAST_EXPECT( env.balance(bob, xrpIssue()) == - bob_initial_balance - env.current()->fees().base * 2 + crossingDelta); + bobInitialBalance - env.current()->fees().base * 2 + crossingDelta); } } void - testOfferCrossWithXRP(bool reverse_order, FeatureBitset features) + testOfferCrossWithXRP(bool reverseOrder, FeatureBitset features) { testcase( - std::string("Offer Crossing with XRP, ") + (reverse_order ? "Reverse" : "Normal") + + std::string("Offer Crossing with XRP, ") + (reverseOrder ? "Reverse" : "Normal") + " order"); using namespace jtx; @@ -1413,23 +1413,23 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env(pay(gw, alice, alice["USD"](500))); - if (reverse_order) - env(offer(bob, USD(1), XRP(4000))); + if (reverseOrder) + env(offer(bob, usd(1), XRP(4000))); - env(offer(alice, XRP(150000), USD(50))); + env(offer(alice, XRP(150000), usd(50))); - if (!reverse_order) - env(offer(bob, USD(1), XRP(4000))); + if (!reverseOrder) + env(offer(bob, usd(1), XRP(4000))); // Existing offer pays better than this wants. // Fully consume existing offer. @@ -1441,7 +1441,7 @@ public: BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string( - (XRP(10000) - XRP(reverse_order ? 4000 : 3000) - env.current()->fees().base * 2) + (XRP(10000) - XRP(reverseOrder ? 4000 : 3000) - env.current()->fees().base * 2) .xrp())); jrr = ledgerEntryState(env, alice, gw, "USD"); @@ -1450,7 +1450,7 @@ public: BEAST_EXPECT( jrr[jss::node][sfBalance.fieldName] == to_string( - (XRP(10000) + XRP(reverse_order ? 4000 : 3000) - env.current()->fees().base * 2) + (XRP(10000) + XRP(reverseOrder ? 4000 : 3000) - env.current()->fees().base * 2) .xrp())); } @@ -1466,17 +1466,17 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(100000), gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); + env(trust(alice, usd(1000))); env(pay(gw, alice, alice["USD"](500))); - env(offer(alice, XRP(150000), USD(50))); - env(offer(bob, USD(1), XRP(3000))); + env(offer(alice, XRP(150000), usd(50))); + env(offer(bob, usd(1), XRP(3000))); auto jrr = ledgerEntryState(env, bob, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-1"); @@ -1502,13 +1502,13 @@ public: Env env{*this, features}; - auto const USD = env.master["USD"]; + auto const usd = env.master["USD"]; auto const nextOfferSeq = env.seq(env.master); - env(offer(env.master, XRP(500), USD(100))); + env(offer(env.master, XRP(500), usd(100))); env.close(); - env(offer_cancel(env.master, nextOfferSeq)); + env(offerCancel(env.master, nextOfferSeq)); BEAST_EXPECT(env.seq(env.master) == nextOfferSeq + 2); // ledger_accept, call twice and verify no odd behavior @@ -1532,11 +1532,11 @@ public: env.fund(XRP(10000), alice); env.close(); - env(offer_cancel(env.master, nextOfferSeq)); + env(offerCancel(env.master, nextOfferSeq)); - env(offer_cancel(env.master, env.seq(env.master)), ter(temBAD_SEQUENCE)); + env(offerCancel(env.master, env.seq(env.master)), Ter(temBAD_SEQUENCE)); - env(offer_cancel(env.master, env.seq(env.master) + 1), ter(temBAD_SEQUENCE)); + env(offerCancel(env.master, env.seq(env.master) + 1), Ter(temBAD_SEQUENCE)); env.close(); } @@ -1553,27 +1553,28 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); - env.require(owners(bob, 0)); + env.require(Owners(bob, 0)); - env(trust(alice, USD(100))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(100))); + env(trust(bob, usd(1000))); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice, 1), Owners(bob, 1)); env(pay(gw, alice, alice["USD"](100))); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(100), XRP(500))); + env(offer(bob, usd(100), XRP(500))); - env.require(owners(alice, 1), owners(bob, 2)); + env.require(Owners(alice, 1), Owners(bob, 2)); auto jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(500).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(100).value().getJson(JsonOptions::none)); + BEAST_EXPECT( + jro[jss::node][jss::TakerPays] == usd(100).value().getJson(JsonOptions::KNone)); - env(pay(alice, alice, XRP(500)), sendmax(USD(100))); + env(pay(alice, alice, XRP(500)), Sendmax(usd(100))); auto jrr = ledgerEntryState(env, alice, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "0"); @@ -1588,7 +1589,7 @@ public: jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::error] == "entryNotFound"); - env.require(owners(alice, 1), owners(bob, 1)); + env.require(Owners(alice, 1), Owners(bob, 1)); } void @@ -1612,7 +1613,7 @@ public: env(trust(carol, bob["EUR"](1000))); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, alice["USD"](50), carol["EUR"](200)), ter(tecUNFUNDED_OFFER)); + env(offer(bob, alice["USD"](50), carol["EUR"](200)), Ter(tecUNFUNDED_OFFER)); env(offer(alice, carol["EUR"](200), alice["USD"](50))); @@ -1632,25 +1633,25 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); - env(trust(alice, USD(200))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(200))); + env(trust(bob, usd(1000))); env(pay(gw, alice, alice["USD"](200))); auto const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(100), XRP(500))); + env(offer(bob, usd(100), XRP(500))); - env(pay(alice, alice, XRP(200)), sendmax(USD(100))); + env(pay(alice, alice, XRP(200)), Sendmax(usd(100))); // The previous payment reduced the remaining offer amount by 200 XRP auto jro = ledgerEntryOffer(env, bob, bobOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(300).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(60).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerPays] == usd(60).value().getJson(JsonOptions::KNone)); // the balance between alice and gw is 160 USD..200 less the 40 taken // by the offer @@ -1668,11 +1669,11 @@ public: // Alice converts USD to XRP which should fail // due to PartialPayment. - env(pay(alice, alice, XRP(600)), sendmax(USD(100)), ter(tecPATH_PARTIAL)); + env(pay(alice, alice, XRP(600)), Sendmax(usd(100)), Ter(tecPATH_PARTIAL)); // Alice converts USD to XRP, should succeed because // we permit partial payment - env(pay(alice, alice, XRP(600)), sendmax(USD(100)), txflags(tfPartialPayment)); + env(pay(alice, alice, XRP(600)), Sendmax(usd(100)), Txflags(tfPartialPayment)); // Verify the offer was consumed jro = ledgerEntryOffer(env, bob, bobOfferSeq); @@ -1709,20 +1710,20 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; auto const carol = Account{"carol"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob, carol); env.close(); - env(trust(carol, USD(1000))); - env(trust(bob, USD(2000))); + env(trust(carol, usd(1000))); + env(trust(bob, usd(2000))); env(pay(gw, carol, carol["USD"](500))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, XRP(500), USD(50))); + env(offer(carol, XRP(500), usd(50))); - env(pay(alice, bob, USD(25)), sendmax(XRP(333))); + env(pay(alice, bob, usd(25)), Sendmax(XRP(333))); auto jrr = ledgerEntryState(env, bob, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-25"); @@ -1731,7 +1732,7 @@ public: BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-475"); auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); - BEAST_EXPECT(jro[jss::node][jss::TakerGets] == USD(25).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerGets] == usd(25).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(jro[jss::node][jss::TakerPays] == XRP(250).value().getText()); } @@ -1748,20 +1749,20 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; auto const carol = Account{"carol"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob, carol); env.close(); - env(trust(alice, USD(1000))); - env(trust(carol, USD(2000))); + env(trust(alice, usd(1000))); + env(trust(carol, usd(2000))); env(pay(gw, alice, alice["USD"](500))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, USD(50), XRP(500))); + env(offer(carol, usd(50), XRP(500))); - env(pay(alice, bob, XRP(250)), sendmax(USD(333))); + env(pay(alice, bob, XRP(250)), Sendmax(usd(333))); auto jrr = ledgerEntryState(env, alice, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-475"); @@ -1776,7 +1777,7 @@ public: auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(250).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(25).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerPays] == usd(25).value().getJson(JsonOptions::KNone)); } void @@ -1794,29 +1795,29 @@ public: auto const bob = Account{"bob"}; auto const carol = Account{"carol"}; auto const dan = Account{"dan"}; - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; env.fund(XRP(10000), gw1, gw2, alice, bob, carol, dan); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, EUR(1000))); - env(trust(carol, USD(1000))); - env(trust(dan, EUR(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, eur(1000))); + env(trust(carol, usd(1000))); + env(trust(dan, eur(1000))); env(pay(gw1, alice, alice["USD"](500))); env(pay(gw2, dan, dan["EUR"](400))); auto const carolOfferSeq = env.seq(carol); - env(offer(carol, USD(50), XRP(500))); + env(offer(carol, usd(50), XRP(500))); auto const danOfferSeq = env.seq(dan); - env(offer(dan, XRP(500), EUR(50))); + env(offer(dan, XRP(500), eur(50))); - Json::Value jtp{Json::arrayValue}; + json::Value jtp{json::ArrayValue}; jtp[0u][0u][jss::currency] = "XRP"; - env(pay(alice, bob, EUR(30)), json(jss::Paths, jtp), sendmax(USD(333))); + env(pay(alice, bob, eur(30)), Json(jss::Paths, jtp), Sendmax(usd(333))); auto jrr = ledgerEntryState(env, alice, gw1, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "470"); @@ -1832,11 +1833,11 @@ public: auto jro = ledgerEntryOffer(env, carol, carolOfferSeq); BEAST_EXPECT(jro[jss::node][jss::TakerGets] == XRP(200).value().getText()); - BEAST_EXPECT(jro[jss::node][jss::TakerPays] == USD(20).value().getJson(JsonOptions::none)); + BEAST_EXPECT(jro[jss::node][jss::TakerPays] == usd(20).value().getJson(JsonOptions::KNone)); jro = ledgerEntryOffer(env, dan, danOfferSeq); BEAST_EXPECT( - jro[jss::node][jss::TakerGets] == gw2["EUR"](20).value().getJson(JsonOptions::none)); + jro[jss::node][jss::TakerGets] == gw2["EUR"](20).value().getJson(JsonOptions::KNone)); BEAST_EXPECT(jro[jss::node][jss::TakerPays] == XRP(200).value().getText()); } @@ -1855,24 +1856,24 @@ public: Account const bob{"bob"}; Account const carol{"carol"}; Account const gw{"gateway"}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; env.fund(XRP(100000000), alice, bob, carol, gw); env.close(); - env.trust(USD(10), alice); + env.trust(usd(10), alice); env.close(); - env(pay(gw, alice, USD(10))); - env.trust(USD(10), carol); + env(pay(gw, alice, usd(10))); + env.trust(usd(10), carol); env.close(); - env(pay(gw, carol, USD(3))); + env(pay(gw, carol, usd(3))); - env(offer(alice, EUR(2), XRP(1))); - env(offer(alice, EUR(2), XRP(1))); + env(offer(alice, eur(2), XRP(1))); + env(offer(alice, eur(2), XRP(1))); - env(offer(alice, XRP(1), USD(4))); - env(offer(carol, XRP(1), USD(3))); + env(offer(alice, XRP(1), usd(4))); + env(offer(carol, XRP(1), usd(3))); env.close(); // Bob offers to buy 10 USD for 10 EUR. @@ -1883,28 +1884,28 @@ public: // The key for this test is that Alice's XRP->USD leg goes dry before // Alice's EUR->XRP. The XRP->USD leg is the second leg which showed // some sensitivity. - env.trust(EUR(10), bob); + env.trust(eur(10), bob); env.close(); - env(pay(gw, bob, EUR(10))); + env(pay(gw, bob, eur(10))); env.close(); - env(offer(bob, USD(10), EUR(10))); + env(offer(bob, usd(10), eur(10))); env.close(); - env.require(balance(bob, USD(7))); - env.require(balance(bob, EUR(6))); + env.require(Balance(bob, usd(7))); + env.require(Balance(bob, eur(6))); env.require(offers(bob, 1)); - env.require(owners(bob, 3)); + env.require(Owners(bob, 3)); - env.require(balance(alice, USD(6))); - env.require(balance(alice, EUR(4))); + env.require(Balance(alice, usd(6))); + env.require(Balance(alice, eur(4))); env.require(offers(alice, 0)); - env.require(owners(alice, 2)); + env.require(Owners(alice, 2)); - env.require(balance(carol, USD(0))); - env.require(balance(carol, EUR(none))); + env.require(Balance(carol, usd(0))); + env.require(Balance(carol, eur(kNONE))); env.require(offers(carol, 0)); - env.require(owners(carol, 1)); + env.require(Owners(carol, 1)); } void @@ -1921,9 +1922,9 @@ public: auto const gw3 = Account{"gateway_3"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD1 = gw1["USD"]; - auto const USD2 = gw2["USD"]; - auto const USD3 = gw3["USD"]; + auto const usD1 = gw1["USD"]; + auto const usD2 = gw2["USD"]; + auto const usD3 = gw3["USD"]; // Provide micro amounts to compensate for fees to make results round // nice. @@ -1931,24 +1932,24 @@ public: // fees: // 1 for each trust limit == 3 (alice < mtgox/amazon/bitstamp) + // 1 for payment == 4 - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(3) + env.current()->fees().base * 4; - env.fund(starting_xrp, gw1, gw2, gw3, alice, bob); + env.fund(startingXrp, gw1, gw2, gw3, alice, bob); env.close(); - env(trust(alice, USD1(1000))); - env(trust(alice, USD2(1000))); - env(trust(alice, USD3(1000))); - env(trust(bob, USD1(1000))); - env(trust(bob, USD2(1000))); + env(trust(alice, usD1(1000))); + env(trust(alice, usD2(1000))); + env(trust(alice, usD3(1000))); + env(trust(bob, usD1(1000))); + env(trust(bob, usD2(1000))); env(pay(gw1, bob, bob["USD"](500))); - env(offer(bob, XRP(200), USD1(200))); + env(offer(bob, XRP(200), usD1(200))); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. - env(offer(alice, USD1(200), XRP(200))); + env(offer(alice, usD1(200), XRP(200))); auto jrr = ledgerEntryState(env, alice, gw1, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "100"); @@ -1968,10 +1969,10 @@ public: using namespace jtx; - for (auto NumberSwitchOver : {false, true}) + for (auto numberSwitchOver : {false, true}) { Env env{*this, features}; - if (NumberSwitchOver) + if (numberSwitchOver) { env.enableFeature(fixUniversalNumber); } @@ -1983,31 +1984,31 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); env(rate(gw, 1.005)); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env(trust(gw, alice["USD"](50))); env(pay(gw, bob, bob["USD"](1))); - env(pay(alice, gw, USD(50))); + env(pay(alice, gw, usd(50))); env(trust(gw, alice["USD"](0))); - env(offer(alice, USD(50), XRP(150000))); - env(offer(bob, XRP(100), USD(0.1))); + env(offer(alice, usd(50), XRP(150000))); + env(offer(bob, XRP(100), usd(0.1))); auto jrr = ledgerEntryState(env, alice, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "49.96666666666667"); jrr = ledgerEntryState(env, bob, gw, "USD"); - Json::Value const bobUSD = jrr[jss::node][sfBalance.fieldName][jss::value]; - if (!NumberSwitchOver) + json::Value const bobUSD = jrr[jss::node][sfBalance.fieldName][jss::value]; + if (!numberSwitchOver) { BEAST_EXPECT(bobUSD == "-0.966500000033334"); } @@ -2030,24 +2031,24 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env(pay(gw, bob, bob["USD"](500))); - env(offer(bob, XRP(200), USD(200)), json(jss::Flags, tfSell)); + env(offer(bob, XRP(200), usd(200)), Json(jss::Flags, tfSell)); // Alice has 350 + fees - a reserve of 50 = 250 reserve = 100 available. // Alice has 350 + fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. - env(offer(alice, USD(200), XRP(200)), json(jss::Flags, tfSell)); + env(offer(alice, usd(200), XRP(200)), Json(jss::Flags, tfSell)); auto jrr = ledgerEntryState(env, alice, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-100"); @@ -2072,26 +2073,26 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; - auto const starting_xrp = + auto const startingXrp = XRP(100) + env.current()->fees().accountReserve(1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); env.close(); - env(trust(alice, USD(150))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(150))); + env(trust(bob, usd(1000))); env(pay(gw, bob, bob["USD"](500))); - env(offer(bob, XRP(100), USD(200))); + env(offer(bob, XRP(100), usd(200))); // Alice has 350 fees - a reserve of 50 = 250 reserve = 100 available. // Ask for more than available to prove reserve works. // Taker pays 100 USD for 100 XRP. // Selling XRP. // Will sell all 100 XRP and get more USD than asked for. - env(offer(alice, USD(100), XRP(100)), json(jss::Flags, tfSell)); + env(offer(alice, usd(100), XRP(100)), Json(jss::Flags, tfSell)); auto jrr = ledgerEntryState(env, alice, gw, "USD"); BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "-200"); @@ -2116,31 +2117,31 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const XTS = gw["XTS"]; - auto const XXX = gw["XXX"]; + auto const xts = gw["XTS"]; + auto const xxx = gw["XXX"]; - auto const starting_xrp = + auto const startingXrp = XRP(100.1) + env.current()->fees().accountReserve(1) + env.current()->fees().base * 2; - env.fund(starting_xrp, gw, alice, bob); + env.fund(startingXrp, gw, alice, bob); env.close(); - env(trust(alice, XTS(1000))); - env(trust(alice, XXX(1000))); - env(trust(bob, XTS(1000))); - env(trust(bob, XXX(1000))); + env(trust(alice, xts(1000))); + env(trust(alice, xxx(1000))); + env(trust(bob, xts(1000))); + env(trust(bob, xxx(1000))); env(pay(gw, alice, alice["XTS"](100))); env(pay(gw, alice, alice["XXX"](100))); env(pay(gw, bob, bob["XTS"](100))); env(pay(gw, bob, bob["XXX"](100))); - env(offer(alice, XTS(100), XXX(100))); + env(offer(alice, xts(100), xxx(100))); // WS client is used here because the RPC client could not // be convinced to pass the build_path argument auto wsc = makeWSClient(env.app().config()); - Json::Value payment; + json::Value payment; payment[jss::secret] = toBase58(generateSeed("bob")); payment[jss::id] = env.seq(bob); payment[jss::build_path] = true; @@ -2148,7 +2149,7 @@ public: payment[jss::tx_json][jss::Sequence] = env.current()->read(keylet::account(bob.id()))->getFieldU32(sfSequence); payment[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); - payment[jss::tx_json][jss::SendMax] = bob["XTS"](1.5).value().getJson(JsonOptions::none); + payment[jss::tx_json][jss::SendMax] = bob["XTS"](1.5).value().getJson(JsonOptions::KNone); auto jrr = wsc->invoke("submit", payment); BEAST_EXPECT(jrr[jss::status] == "success"); BEAST_EXPECT(jrr[jss::result][jss::engine_result] == "tesSUCCESS"); @@ -2217,7 +2218,7 @@ public: using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; @@ -2228,13 +2229,13 @@ public: auto const f = env.current()->fees().base; // To keep things simple all offers are 1 : 1 for XRP : USD. - enum class preTrustType { noPreTrust, gwPreTrust, acctPreTrust }; + enum class PreTrustType { NoPreTrust, GwPreTrust, AcctPreTrust }; struct TestData { std::string account; // Account operated on STAmount fundXrp; // Account funded with int bookAmount; // USD -> XRP offer on the books - preTrustType preTrust; // If true, pre-establish trust line + PreTrustType preTrust; // If true, pre-establish trust line int offerAmount; // Account offers this much XRP -> USD TER tec; // Returned tec code STAmount spentXrp; // Amount removed from fundXrp @@ -2246,45 +2247,45 @@ public: // clang-format off TestData const tests[]{ // acct fundXrp bookAmt preTrust offerAmount tec spentXrp balanceUSD offers owners - {.account="ann", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account is at the reserve, and will dip below once fees are subtracted. - {.account="bev", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account has just enough for the reserve and the fee. - {.account="cam", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed. - {.account="deb", .fundXrp=drops(10) + reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + f, .balanceUsd=USD(0.00001), .offers=0, .owners=1}, // Account has enough to buy a little USD then the offer runs dry. - {.account="eve", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=USD( 0), .offers=1, .owners=1}, // No offer to cross - {.account="flo", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="gay", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 50) + f, .balanceUsd=USD( 50), .offers=0, .owners=1}, - {.account="hye", .fundXrp=XRP(1000) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 800) + f, .balanceUsd=USD( 800), .offers=0, .owners=1}, - {.account="ivy", .fundXrp=XRP( 1) + reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="joy", .fundXrp=XRP( 1) + reserve(env, 2) + 1 * f, .bookAmount=1, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=1, .owners=2}, - {.account="kim", .fundXrp=XRP( 900) + reserve(env, 2) + 1 * f, .bookAmount=999, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="liz", .fundXrp=XRP( 998) + reserve(env, 0) + 1 * f, .bookAmount=999, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 998) + f, .balanceUsd=USD( 998), .offers=0, .owners=1}, - {.account="meg", .fundXrp=XRP( 998) + reserve(env, 1) + 1 * f, .bookAmount=999, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="nia", .fundXrp=XRP( 998) + reserve(env, 2) + 1 * f, .bookAmount=999, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=1, .owners=2}, - {.account="ova", .fundXrp=XRP( 999) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=USD( 999), .offers=0, .owners=1}, - {.account="pam", .fundXrp=XRP( 999) + reserve(env, 1) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=USD( 1000), .offers=0, .owners=1}, - {.account="rae", .fundXrp=XRP( 999) + reserve(env, 2) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=USD( 1000), .offers=0, .owners=1}, - {.account="sue", .fundXrp=XRP(1000) + reserve(env, 2) + 1 * f, .bookAmount=0, .preTrust=preTrustType::noPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=USD( 0), .offers=1, .owners=1}, + {.account="ann", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account is at the reserve, and will dip below once fees are subtracted. + {.account="bev", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account has just enough for the reserve and the fee. + {.account="cam", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, // Account has enough for the reserve, the fee and the offer, and a bit more, but not enough for the reserve after the offer is placed. + {.account="deb", .fundXrp=drops(10) + reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + f, .balanceUsd=usd(0.00001), .offers=0, .owners=1}, // Account has enough to buy a little USD then the offer runs dry. + {.account="eve", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=usd( 0), .offers=1, .owners=1}, // No offer to cross + {.account="flo", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="gay", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 50) + f, .balanceUsd=usd( 50), .offers=0, .owners=1}, + {.account="hye", .fundXrp=XRP(1000) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 800) + f, .balanceUsd=usd( 800), .offers=0, .owners=1}, + {.account="ivy", .fundXrp=XRP( 1) + reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="joy", .fundXrp=XRP( 1) + reserve(env, 2) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=1, .owners=2}, + {.account="kim", .fundXrp=XRP( 900) + reserve(env, 2) + 1 * f, .bookAmount=999, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="liz", .fundXrp=XRP( 998) + reserve(env, 0) + 1 * f, .bookAmount=999, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 998) + f, .balanceUsd=usd( 998), .offers=0, .owners=1}, + {.account="meg", .fundXrp=XRP( 998) + reserve(env, 1) + 1 * f, .bookAmount=999, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="nia", .fundXrp=XRP( 998) + reserve(env, 2) + 1 * f, .bookAmount=999, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=1, .owners=2}, + {.account="ova", .fundXrp=XRP( 999) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 999) + f, .balanceUsd=usd( 999), .offers=0, .owners=1}, + {.account="pam", .fundXrp=XRP( 999) + reserve(env, 1) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=usd( 1000), .offers=0, .owners=1}, + {.account="rae", .fundXrp=XRP( 999) + reserve(env, 2) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(1000) + f, .balanceUsd=usd( 1000), .offers=0, .owners=1}, + {.account="sue", .fundXrp=XRP(1000) + reserve(env, 2) + 1 * f, .bookAmount=0, .preTrust=PreTrustType::NoPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=usd( 0), .offers=1, .owners=1}, //---------------- Pre-established trust lines --------------------- - {.account="abe", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, - {.account="bud", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, - {.account="che", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=USD( 0), .offers=0, .owners=0}, - {.account="dan", .fundXrp=drops(10) + reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + f, .balanceUsd=USD(0.00001), .offers=0, .owners=0}, - {.account="eli", .fundXrp=XRP( 20) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 1 * f, .balanceUsd=USD( 20), .offers=0, .owners=0}, - {.account="fyn", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=USD( 0), .offers=1, .owners=1}, - {.account="gar", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=1, .owners=1}, - {.account="hal", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=preTrustType::gwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=USD( 1), .offers=1, .owners=1}, + {.account="abe", .fundXrp=reserve(env, 0) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, + {.account="bud", .fundXrp=reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, + {.account="che", .fundXrp=reserve(env, 0) + 2 * f, .bookAmount=0, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=f, .balanceUsd=usd( 0), .offers=0, .owners=0}, + {.account="dan", .fundXrp=drops(10) + reserve(env, 0) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + f, .balanceUsd=usd(0.00001), .offers=0, .owners=0}, + {.account="eli", .fundXrp=XRP( 20) + reserve(env, 0) + 1 * f, .bookAmount=1000, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 1 * f, .balanceUsd=usd( 20), .offers=0, .owners=0}, + {.account="fyn", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=0, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=f, .balanceUsd=usd( 0), .offers=1, .owners=1}, + {.account="gar", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=1, .owners=1}, + {.account="hal", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::GwPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + f, .balanceUsd=usd( 1), .offers=1, .owners=1}, - {.account="ned", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="ole", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="pat", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=0, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="quy", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="ron", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=0, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="syd", .fundXrp=drops(10) + reserve(env, 1) + 2 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + 2 * f, .balanceUsd=USD(0.00001), .offers=0, .owners=1}, - {.account="ted", .fundXrp=XRP( 20) + reserve(env, 1) + 2 * f, .bookAmount=1000, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 2 * f, .balanceUsd=USD( 20), .offers=0, .owners=1}, - {.account="uli", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=0, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=0, .owners=1}, - {.account="vic", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=USD( 1), .offers=0, .owners=1}, - {.account="wes", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=0, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=USD( 0), .offers=1, .owners=2}, - {.account="xan", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=1, .preTrust=preTrustType::acctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=USD( 1), .offers=1, .owners=2}, + {.account="ned", .fundXrp=reserve(env, 1) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="ole", .fundXrp=reserve(env, 1) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="pat", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=0, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="quy", .fundXrp=reserve(env, 1) + 2 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecUNFUNDED_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="ron", .fundXrp=reserve(env, 1) + 3 * f, .bookAmount=0, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="syd", .fundXrp=drops(10) + reserve(env, 1) + 2 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=drops(10) + 2 * f, .balanceUsd=usd(0.00001), .offers=0, .owners=1}, + {.account="ted", .fundXrp=XRP( 20) + reserve(env, 1) + 2 * f, .bookAmount=1000, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP(20) + 2 * f, .balanceUsd=usd( 20), .offers=0, .owners=1}, + {.account="uli", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=0, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tecINSUF_RESERVE_OFFER, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=0, .owners=1}, + {.account="vic", .fundXrp=reserve(env, 2) + 0 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=usd( 1), .offers=0, .owners=1}, + {.account="wes", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=0, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=2 * f, .balanceUsd=usd( 0), .offers=1, .owners=2}, + {.account="xan", .fundXrp=reserve(env, 2) + 1 * f, .bookAmount=1, .preTrust=PreTrustType::AcctPreTrust, .offerAmount=1000, .tec=tesSUCCESS, .spentXrp=XRP( 1) + 2 * f, .balanceUsd=usd( 1), .offers=1, .owners=2}, }; // clang-format on @@ -2300,34 +2301,34 @@ public: // The gateway optionally creates an offer that would be crossed. auto const book = t.bookAmount; if (book != 0) - env(offer(gw, XRP(book), USD(book))); + env(offer(gw, XRP(book), usd(book))); env.close(); std::uint32_t const gwOfferSeq = env.seq(gw) - 1; // Optionally pre-establish a trustline between gw and acct. - if (t.preTrust == preTrustType::gwPreTrust) + if (t.preTrust == PreTrustType::GwPreTrust) env(trust(gw, acct["USD"](1))); env.close(); // Optionally pre-establish a trustline between acct and gw. // Note this is not really part of the test, so we expect there // to be enough XRP reserve for acct to create the trust line. - if (t.preTrust == preTrustType::acctPreTrust) - env(trust(acct, USD(1))); + if (t.preTrust == PreTrustType::AcctPreTrust) + env(trust(acct, usd(1))); env.close(); { // Acct creates an offer. This is the heart of the test. auto const acctOffer = t.offerAmount; - env(offer(acct, USD(acctOffer), XRP(acctOffer)), ter(t.tec)); + env(offer(acct, usd(acctOffer), XRP(acctOffer)), Ter(t.tec)); env.close(); } std::uint32_t const acctOfferSeq = env.seq(acct) - 1; - BEAST_EXPECT(env.balance(acct, USD) == t.balanceUsd); + BEAST_EXPECT(env.balance(acct, usd) == t.balanceUsd); BEAST_EXPECT(env.balance(acct, xrpIssue()) == t.fundXrp - t.spentXrp); env.require(offers(acct, t.offers)); - env.require(owners(acct, t.owners)); + env.require(Owners(acct, t.owners)); auto acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == t.offers); @@ -2337,10 +2338,10 @@ public: auto const leftover = t.offerAmount - t.bookAmount; BEAST_EXPECT(acctOffer[sfTakerGets] == XRP(leftover)); - BEAST_EXPECT(acctOffer[sfTakerPays] == USD(leftover)); + BEAST_EXPECT(acctOffer[sfTakerPays] == usd(leftover)); } - if (t.preTrust == preTrustType::noPreTrust) + if (t.preTrust == PreTrustType::NoPreTrust) { if (t.balanceUsd.value().signum() != 0) { @@ -2350,15 +2351,15 @@ public: else { // Verify that no trustline was created. - auto const sleTrust = env.le(keylet::line(acct, USD)); + auto const sleTrust = env.le(keylet::line(acct, usd)); BEAST_EXPECT(!sleTrust); } } // Give the next loop a clean slate by canceling any left-overs // in the offers. - env(offer_cancel(acct, acctOfferSeq)); - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(acct, acctOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); } } @@ -2373,9 +2374,9 @@ public: auto const gw = Account("gateway"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; - auto const usdOffer = USD(1000); + auto const usdOffer = usd(1000); auto const xrpOffer = XRP(1000); Env env{*this, features}; @@ -2397,7 +2398,7 @@ public: env(pay(gw, alice, usdOffer)); env.close(); - env.require(balance(alice, usdOffer), offers(alice, 0), offers(bob, 0)); + env.require(Balance(alice, usdOffer), offers(alice, 0), offers(bob, 0)); // The scenario: // o alice has USD but wants XRP. @@ -2411,31 +2412,31 @@ public: env.close(); env.require( - balance(alice, USD(0)), - balance(bob, usdOffer), - balance(alice, aliceXRP + xrpOffer - fee), - balance(bob, bobXRP - xrpOffer - fee), + Balance(alice, usd(0)), + Balance(bob, usdOffer), + Balance(alice, aliceXRP + xrpOffer - fee), + Balance(bob, bobXRP - xrpOffer - fee), offers(alice, 0), offers(bob, 0)); verifyDefaultTrustline(env, bob, usdOffer); // Make two more offers that leave one of the offers non-dry. - env(offer(alice, USD(999), XRP(999))); + env(offer(alice, usd(999), XRP(999))); env(offer(bob, xrpOffer, usdOffer)); env.close(); - env.require(balance(alice, USD(999))); - env.require(balance(bob, USD(1))); + env.require(Balance(alice, usd(999))); + env.require(Balance(bob, usd(1))); env.require(offers(alice, 0)); - verifyDefaultTrustline(env, bob, USD(1)); + verifyDefaultTrustline(env, bob, usd(1)); { auto const bobOffers = offersOnAccount(env, bob); BEAST_EXPECT(bobOffers.size() == 1); auto const& bobOffer = *(bobOffers.front()); BEAST_EXPECT(bobOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(bobOffer[sfTakerGets] == USD(1)); + BEAST_EXPECT(bobOffer[sfTakerGets] == usd(1)); BEAST_EXPECT(bobOffer[sfTakerPays] == XRP(1)); } } @@ -2450,11 +2451,11 @@ public: auto const gw = Account("gateway"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; - auto const usdOffer = USD(1000); - auto const eurOffer = EUR(1000); + auto const usdOffer = usd(1000); + auto const eurOffer = eur(1000); Env env{*this, features}; @@ -2478,7 +2479,7 @@ public: env(pay(gw, bob, eurOffer)); env.close(); - env.require(balance(alice, usdOffer), balance(bob, eurOffer)); + env.require(Balance(alice, usdOffer), Balance(bob, eurOffer)); // The scenario: // o alice has USD but wants EUR. @@ -2488,7 +2489,7 @@ public: env.close(); env.require( - balance(alice, eurOffer), balance(bob, usdOffer), offers(alice, 0), offers(bob, 0)); + Balance(alice, eurOffer), Balance(bob, usdOffer), offers(alice, 0), offers(bob, 0)); // Alice's offer crossing created a default EUR trustline and // Bob's offer crossing created a default USD trustline: @@ -2501,16 +2502,16 @@ public: env(offer(bob, eurOffer, usdOffer)); env.close(); - env(offer(alice, USD(999), eurOffer)); + env(offer(alice, usd(999), eurOffer)); env.close(); env.require(offers(alice, 0)); env.require(offers(bob, 1)); - env.require(balance(alice, USD(999))); - env.require(balance(alice, EUR(1))); - env.require(balance(bob, USD(1))); - env.require(balance(bob, EUR(999))); + env.require(Balance(alice, usd(999))); + env.require(Balance(alice, eur(1))); + env.require(Balance(bob, usd(1))); + env.require(Balance(bob, eur(999))); { auto bobOffers = offersOnAccount(env, bob); @@ -2518,29 +2519,29 @@ public: { auto const& bobOffer = *(bobOffers.front()); - BEAST_EXPECT(bobOffer[sfTakerGets] == USD(1)); - BEAST_EXPECT(bobOffer[sfTakerPays] == EUR(1)); + BEAST_EXPECT(bobOffer[sfTakerGets] == usd(1)); + BEAST_EXPECT(bobOffer[sfTakerPays] == eur(1)); } } // alice makes one more offer that cleans out bob's offer. - env(offer(alice, USD(1), EUR(1))); + env(offer(alice, usd(1), eur(1))); env.close(); - env.require(balance(alice, USD(1000))); - env.require(balance(alice, EUR(none))); - env.require(balance(bob, USD(none))); - env.require(balance(bob, EUR(1000))); + env.require(Balance(alice, usd(1000))); + env.require(Balance(alice, eur(kNONE))); + env.require(Balance(bob, usd(kNONE))); + env.require(Balance(bob, eur(1000))); env.require(offers(alice, 0)); env.require(offers(bob, 0)); // The two trustlines that were generated by offers should be gone. - BEAST_EXPECT(!env.le(keylet::line(alice.id(), EUR))); - BEAST_EXPECT(!env.le(keylet::line(bob.id(), USD))); + BEAST_EXPECT(!env.le(keylet::line(alice.id(), eur))); + BEAST_EXPECT(!env.le(keylet::line(bob.id(), usd))); // Make two more offers that leave one of the offers non-dry. We // need to properly sequence the transactions: - env(offer(alice, EUR(999), usdOffer)); + env(offer(alice, eur(999), usdOffer)); env.close(); env(offer(bob, usdOffer, eurOffer)); @@ -2549,10 +2550,10 @@ public: env.require(offers(alice, 0)); env.require(offers(bob, 0)); - env.require(balance(alice, USD(0))); - env.require(balance(alice, EUR(999))); - env.require(balance(bob, USD(1000))); - env.require(balance(bob, EUR(1))); + env.require(Balance(alice, usd(0))); + env.require(Balance(alice, eur(999))); + env.require(Balance(bob, usd(1000))); + env.require(Balance(bob, eur(1))); } void @@ -2566,11 +2567,11 @@ public: auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; - auto const usdOffer = USD(1000); - auto const eurOffer = EUR(1000); + auto const usdOffer = usd(1000); + auto const eurOffer = eur(1000); Env env{*this, features}; @@ -2596,24 +2597,24 @@ public: env.close(); // carol makes an offer that partially consumes alice and bob's offers. - env(offer(carol, USD(400), EUR(400))); + env(offer(carol, usd(400), eur(400))); env.close(); env.require( - balance(alice, USD(600)), - balance(bob, EUR(400)), - balance(carol, USD(400)), - balance(bob, bobXrpBalance - XRP(400)), + Balance(alice, usd(600)), + Balance(bob, eur(400)), + Balance(carol, usd(400)), + Balance(bob, bobXrpBalance - XRP(400)), offers(carol, 0)); - verifyDefaultTrustline(env, bob, EUR(400)); - verifyDefaultTrustline(env, carol, USD(400)); + verifyDefaultTrustline(env, bob, eur(400)); + verifyDefaultTrustline(env, carol, usd(400)); { auto const aliceOffers = offersOnAccount(env, alice); BEAST_EXPECT(aliceOffers.size() == 1); auto const& aliceOffer = *(aliceOffers.front()); BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(600)); + BEAST_EXPECT(aliceOffer[sfTakerGets] == usd(600)); BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(600)); } { @@ -2623,22 +2624,22 @@ public: BEAST_EXPECT(bobOffer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(bobOffer[sfTakerGets] == XRP(600)); - BEAST_EXPECT(bobOffer[sfTakerPays] == EUR(600)); + BEAST_EXPECT(bobOffer[sfTakerPays] == eur(600)); } // carol makes an offer that exactly consumes alice and bob's offers. - env(offer(carol, USD(600), EUR(600))); + env(offer(carol, usd(600), eur(600))); env.close(); env.require( - balance(alice, USD(0)), - balance(bob, eurOffer), - balance(carol, usdOffer), - balance(bob, bobXrpBalance - XRP(1000)), + Balance(alice, usd(0)), + Balance(bob, eurOffer), + Balance(carol, usdOffer), + Balance(bob, bobXrpBalance - XRP(1000)), offers(bob, 0), offers(carol, 0)); - verifyDefaultTrustline(env, bob, EUR(1000)); - verifyDefaultTrustline(env, carol, USD(1000)); + verifyDefaultTrustline(env, bob, eur(1000)); + verifyDefaultTrustline(env, carol, usd(1000)); // In pre-flow code alice's offer is left empty in the ledger. auto const aliceOffers = offersOnAccount(env, alice); @@ -2648,7 +2649,7 @@ public: auto const& aliceOffer = *(aliceOffers.front()); BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(0)); + BEAST_EXPECT(aliceOffer[sfTakerGets] == usd(0)); BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(0)); } } @@ -2664,7 +2665,7 @@ public: using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; @@ -2675,7 +2676,7 @@ public: auto const f = env.current()->fees().base; // To keep things simple all offers are 1 : 1 for XRP : USD. - enum class preTrustType { noPreTrust, gwPreTrust, acctPreTrust }; + enum class PreTrustType { NoPreTrust, GwPreTrust, AcctPreTrust }; struct TestData { std::string account; // Account operated on @@ -2695,64 +2696,64 @@ public: // Constructor with takerGets/takerPays TestData( - std::string&& account_, // Account operated on - STAmount fundXrp_, // XRP acct funded with - STAmount fundUSD_, // USD acct funded with - STAmount gwGets_, // gw's offer - STAmount gwPays_, // - STAmount acctGets_, // acct's offer - STAmount acctPays_, // - TER tec_, // Returned tec code - STAmount spentXrp_, // Amount removed from fundXrp - STAmount finalUsd_, // Final USD balance on acct - int offers_, // Offers on acct - int owners_, // Owners on acct - STAmount takerGets_, // Remainder of acct's offer - STAmount takerPays_) // - : account(std::move(account_)) - , fundXrp(std::move(fundXrp_)) - , fundUSD(std::move(fundUSD_)) - , gwGets(std::move(gwGets_)) - , gwPays(std::move(gwPays_)) - , acctGets(std::move(acctGets_)) - , acctPays(std::move(acctPays_)) - , tec(tec_) - , spentXrp(std::move(spentXrp_)) - , finalUsd(std::move(finalUsd_)) - , offers(offers_) - , owners(owners_) - , takerGets(std::move(takerGets_)) - , takerPays(std::move(takerPays_)) + std::string&& account, // Account operated on + STAmount fundXrp, // XRP acct funded with + STAmount fundUsd, // USD acct funded with + STAmount gwGets, // gw's offer + STAmount gwPays, // + STAmount acctGets, // acct's offer + STAmount acctPays, // + TER tec, // Returned tec code + STAmount spentXrp, // Amount removed from fundXrp + STAmount finalUsd, // Final USD balance on acct + int offers, // Offers on acct + int owners, // Owners on acct + STAmount takerGets, // Remainder of acct's offer + STAmount takerPays) // + : account(std::move(account)) + , fundXrp(std::move(fundXrp)) + , fundUSD(std::move(fundUsd)) + , gwGets(std::move(gwGets)) + , gwPays(std::move(gwPays)) + , acctGets(std::move(acctGets)) + , acctPays(std::move(acctPays)) + , tec(tec) + , spentXrp(std::move(spentXrp)) + , finalUsd(std::move(finalUsd)) + , offers(offers) + , owners(owners) + , takerGets(std::move(takerGets)) + , takerPays(std::move(takerPays)) { } // Constructor without takerGets/takerPays TestData( - std::string&& account_, // Account operated on - STAmount const& fundXrp_, // XRP acct funded with - STAmount const& fundUSD_, // USD acct funded with - STAmount const& gwGets_, // gw's offer - STAmount const& gwPays_, // - STAmount const& acctGets_, // acct's offer - STAmount const& acctPays_, // - TER tec_, // Returned tec code - STAmount const& spentXrp_, // Amount removed from fundXrp - STAmount const& finalUsd_, // Final USD balance on acct - int offers_, // Offers on acct - int owners_) // Owners on acct + std::string&& account, // Account operated on + STAmount const& fundXrp, // XRP acct funded with + STAmount const& fundUsd, // USD acct funded with + STAmount const& gwGets, // gw's offer + STAmount const& gwPays, // + STAmount const& acctGets, // acct's offer + STAmount const& acctPays, // + TER tec, // Returned tec code + STAmount const& spentXrp, // Amount removed from fundXrp + STAmount const& finalUsd, // Final USD balance on acct + int offers, // Offers on acct + int owners) // Owners on acct : TestData( - std::move(account_), - fundXrp_, - fundUSD_, - gwGets_, - gwPays_, - acctGets_, - acctPays_, - tec_, - spentXrp_, - finalUsd_, - offers_, - owners_, + std::move(account), + fundXrp, + fundUsd, + gwGets, + gwPays, + acctGets, + acctPays, + tec, + spentXrp, + finalUsd, + offers, + owners, STAmount{0}, STAmount{0}) { @@ -2763,26 +2764,26 @@ public: TestData const tests[]{ // acct pays XRP // acct fundXrp fundUSD gwGets gwPays acctGets acctPays tec spentXrp finalUSD offers owners takerGets takerPays - {"ann", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (1 * f), USD( 0), 0, 0}, - {"bev", XRP(10) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD( 5), USD(10), XRP(10), tesSUCCESS, XRP( 0) + (1 * f), USD( 0), 1, 1, XRP(10), USD(10)}, - {"cam", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(10), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(10), 0, 1}, - {"deb", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"eve", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD( 5), XRP( 5), tesSUCCESS, XRP( 5) + (1 * f), USD(10), 0, 1}, - {"flo", XRP(10) + reserve(env, 0) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"gay", XRP(20) + reserve(env, 1) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 0, 1}, - {"hye", XRP(20) + reserve(env, 2) + 1 * f, USD( 0), XRP(10), USD(20), USD(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), USD(20), 1, 2, XRP(10), USD(10)}, + {"ann", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd( 5), usd(10), XRP(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (1 * f), usd( 0), 0, 0}, + {"bev", XRP(10) + reserve(env, 1) + 1 * f, usd( 0), XRP(10), usd( 5), usd(10), XRP(10), tesSUCCESS, XRP( 0) + (1 * f), usd( 0), 1, 1, XRP(10), usd(10)}, + {"cam", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(10), usd(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), usd(10), 0, 1}, + {"deb", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd(10), XRP(10), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"eve", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd( 5), XRP( 5), tesSUCCESS, XRP( 5) + (1 * f), usd(10), 0, 1}, + {"flo", XRP(10) + reserve(env, 0) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"gay", XRP(20) + reserve(env, 1) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 0, 1}, + {"hye", XRP(20) + reserve(env, 2) + 1 * f, usd( 0), XRP(10), usd(20), usd(20), XRP(20), tesSUCCESS, XRP( 10) + (1 * f), usd(20), 1, 2, XRP(10), usd(10)}, // acct pays USD - {"meg", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (2 * f), USD(10), 0, 1}, - {"nia", reserve(env, 2) + 2 * f, USD(10), USD(10), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( 0) + (2 * f), USD(10), 1, 2, USD(10), XRP(10)}, - {"ova", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 0), 0, 1}, - {"pam", reserve(env, 1) + 2 * f, USD(10), USD(10), XRP(20), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1}, - {"qui", reserve(env, 1) + 2 * f, USD(10), USD(20), XRP(40), XRP(10), USD(10), tesSUCCESS, XRP(-20) + (2 * f), USD( 0), 0, 1}, - {"rae", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP( 5), XRP(10), USD(10), tesSUCCESS, XRP( -5) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)}, - {"sue", reserve(env, 2) + 2 * f, USD(10), USD( 5), XRP(10), XRP(10), USD(10), tesSUCCESS, XRP(-10) + (2 * f), USD( 5), 1, 2, USD( 5), XRP( 5)}, + {"meg", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP( 5), XRP(10), usd(10), tecINSUF_RESERVE_OFFER, XRP( 0) + (2 * f), usd(10), 0, 1}, + {"nia", reserve(env, 2) + 2 * f, usd(10), usd(10), XRP( 5), XRP(10), usd(10), tesSUCCESS, XRP( 0) + (2 * f), usd(10), 1, 2, usd(10), XRP(10)}, + {"ova", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP(10), XRP(10), usd(10), tesSUCCESS, XRP(-10) + (2 * f), usd( 0), 0, 1}, + {"pam", reserve(env, 1) + 2 * f, usd(10), usd(10), XRP(20), XRP(10), usd(10), tesSUCCESS, XRP(-20) + (2 * f), usd( 0), 0, 1}, + {"qui", reserve(env, 1) + 2 * f, usd(10), usd(20), XRP(40), XRP(10), usd(10), tesSUCCESS, XRP(-20) + (2 * f), usd( 0), 0, 1}, + {"rae", reserve(env, 2) + 2 * f, usd(10), usd( 5), XRP( 5), XRP(10), usd(10), tesSUCCESS, XRP( -5) + (2 * f), usd( 5), 1, 2, usd( 5), XRP( 5)}, + {"sue", reserve(env, 2) + 2 * f, usd(10), usd( 5), XRP(10), XRP(10), usd(10), tesSUCCESS, XRP(-10) + (2 * f), usd( 5), 1, 2, usd( 5), XRP( 5)}, }; // clang-format on - auto const zeroUsd = USD(0); + auto const zeroUsd = usd(0); for (auto const& t : tests) { // Make sure gateway has no current offers. @@ -2809,15 +2810,15 @@ public: std::uint32_t const gwOfferSeq = env.seq(gw) - 1; // Acct creates a tfSell offer. This is the heart of the test. - env(offer(acct, t.acctGets, t.acctPays, tfSell), ter(t.tec)); + env(offer(acct, t.acctGets, t.acctPays, tfSell), Ter(t.tec)); env.close(); std::uint32_t const acctOfferSeq = env.seq(acct) - 1; // Check results - BEAST_EXPECT(env.balance(acct, USD) == t.finalUsd); + BEAST_EXPECT(env.balance(acct, usd) == t.finalUsd); BEAST_EXPECT(env.balance(acct, xrpIssue()) == t.fundXrp - t.spentXrp); env.require(offers(acct, t.offers)); - env.require(owners(acct, t.owners)); + env.require(Owners(acct, t.owners)); if (t.offers != 0) { @@ -2835,8 +2836,8 @@ public: // Give the next loop a clean slate by canceling any left-overs // in the offers. - env(offer_cancel(acct, acctOfferSeq)); - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(acct, acctOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); } } @@ -2853,7 +2854,7 @@ public: auto const gw = Account("gateway"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; @@ -2864,39 +2865,39 @@ public: TER const killedCode{TER{tecKILLED}}; // bob offers XRP for USD. - env(trust(bob, USD(200))); + env(trust(bob, usd(200))); env.close(); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); env.close(); - env(offer(bob, XRP(2000), USD(20))); + env(offer(bob, XRP(2000), usd(20))); env.close(); { // alice submits a tfSell | tfFillOrKill offer that does not cross. - env(offer(alice, USD(21), XRP(2100), tfSell | tfFillOrKill), ter(killedCode)); + env(offer(alice, usd(21), XRP(2100), tfSell | tfFillOrKill), Ter(killedCode)); env.close(); - env.require(balance(alice, USD(none))); + env.require(Balance(alice, usd(kNONE))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(100))); + env.require(Balance(bob, usd(100))); } { // alice submits a tfSell | tfFillOrKill offer that crosses. // Even though tfSell is present it doesn't matter this time. - env(offer(alice, USD(20), XRP(2000), tfSell | tfFillOrKill)); + env(offer(alice, usd(20), XRP(2000), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(20))); + env.require(Balance(alice, usd(20))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(80))); + env.require(Balance(bob, usd(80))); } { // alice submits a tfSell | tfFillOrKill offer that crosses and // returns more than was asked for (because of the tfSell flag). - env(offer(bob, XRP(2000), USD(20))); + env(offer(bob, XRP(2000), usd(20))); env.close(); - env(offer(alice, USD(10), XRP(1500), tfSell | tfFillOrKill)); + env(offer(alice, usd(10), XRP(1500), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(35))); + env.require(Balance(alice, usd(35))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(65))); + env.require(Balance(bob, usd(65))); } { // alice submits a tfSell | tfFillOrKill offer that doesn't cross. @@ -2905,22 +2906,22 @@ public: // all of the offer is consumed. // We're using bob's left-over offer for XRP(500), USD(5) - env(offer(alice, USD(1), XRP(501), tfSell | tfFillOrKill), ter(killedCode)); + env(offer(alice, usd(1), XRP(501), tfSell | tfFillOrKill), Ter(killedCode)); env.close(); - env.require(balance(alice, USD(35))); + env.require(Balance(alice, usd(35))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(65))); + env.require(Balance(bob, usd(65))); } { // Alice submits a tfSell | tfFillOrKill offer that finishes // off the remainder of bob's offer. // We're using bob's left-over offer for XRP(500), USD(5) - env(offer(alice, USD(1), XRP(500), tfSell | tfFillOrKill)); + env(offer(alice, usd(1), XRP(500), tfSell | tfFillOrKill)); env.close(); - env.require(balance(alice, USD(40))); + env.require(Balance(alice, usd(40))); env.require(offers(alice, 0)); - env.require(balance(bob, USD(60))); + env.require(Balance(bob, usd(60))); } } @@ -2932,7 +2933,7 @@ public: using namespace jtx; auto const gw1 = Account("gateway1"); - auto const USD = gw1["USD"]; + auto const usd = gw1["USD"]; Env env{*this, features}; @@ -2949,11 +2950,11 @@ public: env.fund(XRP(100) + reserve(env, 2) + (fee * 2), ann, bob); env.close(); - env(trust(ann, USD(200))); - env(trust(bob, USD(200))); + env(trust(ann, usd(200))); + env(trust(bob, usd(200))); env.close(); - env(pay(gw1, bob, USD(125))); + env(pay(gw1, bob, usd(125))); env.close(); // bob offers to sell USD(100) for XRP. alice takes bob's offer. @@ -2962,18 +2963,18 @@ public: // // A comparable payment would look like this: // env (pay (bob, alice, USD(100)), sendmax(USD(125))) - env(offer(bob, XRP(1), USD(100))); + env(offer(bob, XRP(1), usd(100))); env.close(); - env(offer(ann, USD(100), XRP(1))); + env(offer(ann, usd(100), XRP(1))); env.close(); - env.require(balance(ann, USD(100))); - env.require(balance(ann, XRP(99) + reserve(env, 2))); + env.require(Balance(ann, usd(100))); + env.require(Balance(ann, XRP(99) + reserve(env, 2))); env.require(offers(ann, 0)); - env.require(balance(bob, USD(0))); - env.require(balance(bob, XRP(101) + reserve(env, 2))); + env.require(Balance(bob, usd(0))); + env.require(Balance(bob, XRP(101) + reserve(env, 2))); env.require(offers(bob, 0)); } { @@ -2984,25 +2985,25 @@ public: env.fund(XRP(100) + reserve(env, 2) + (fee * 2), che, deb); env.close(); - env(trust(che, USD(200))); - env(trust(deb, USD(200))); + env(trust(che, usd(200))); + env(trust(deb, usd(200))); env.close(); - env(pay(gw1, deb, USD(125))); + env(pay(gw1, deb, usd(125))); env.close(); - env(offer(che, USD(100), XRP(1))); + env(offer(che, usd(100), XRP(1))); env.close(); - env(offer(deb, XRP(1), USD(100))); + env(offer(deb, XRP(1), usd(100))); env.close(); - env.require(balance(che, USD(100))); - env.require(balance(che, XRP(99) + reserve(env, 2))); + env.require(Balance(che, usd(100))); + env.require(Balance(che, XRP(99) + reserve(env, 2))); env.require(offers(che, 0)); - env.require(balance(deb, USD(0))); - env.require(balance(deb, XRP(101) + reserve(env, 2))); + env.require(Balance(deb, usd(0))); + env.require(Balance(deb, XRP(101) + reserve(env, 2))); env.require(offers(deb, 0)); } { @@ -3012,26 +3013,26 @@ public: env.fund(XRP(20000) + (fee * 2), eve, fyn); env.close(); - env(trust(eve, USD(1000))); - env(trust(fyn, USD(1000))); + env(trust(eve, usd(1000))); + env(trust(fyn, usd(1000))); env.close(); - env(pay(gw1, eve, USD(100))); - env(pay(gw1, fyn, USD(100))); + env(pay(gw1, eve, usd(100))); + env(pay(gw1, fyn, usd(100))); env.close(); // This test verifies that the amount removed from an offer // accounts for the transfer fee that is removed from the // account but not from the remaining offer. - env(offer(eve, USD(10), XRP(4000))); + env(offer(eve, usd(10), XRP(4000))); env.close(); std::uint32_t const eveOfferSeq = env.seq(eve) - 1; - env(offer(fyn, XRP(2000), USD(5))); + env(offer(fyn, XRP(2000), usd(5))); env.close(); - env.require(balance(eve, USD(105))); - env.require(balance(eve, XRP(18000))); + env.require(Balance(eve, usd(105))); + env.require(Balance(eve, XRP(18000))); auto const evesOffers = offersOnAccount(env, eve); BEAST_EXPECT(evesOffers.size() == 1); if (!evesOffers.empty()) @@ -3039,17 +3040,17 @@ public: auto const& evesOffer = *(evesOffers.front()); BEAST_EXPECT(evesOffer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(evesOffer[sfTakerGets] == XRP(2000)); - BEAST_EXPECT(evesOffer[sfTakerPays] == USD(5)); + BEAST_EXPECT(evesOffer[sfTakerPays] == usd(5)); } - env(offer_cancel(eve, eveOfferSeq)); // For later tests + env(offerCancel(eve, eveOfferSeq)); // For later tests - env.require(balance(fyn, USD(93.75))); - env.require(balance(fyn, XRP(22000))); + env.require(Balance(fyn, usd(93.75))); + env.require(Balance(fyn, XRP(22000))); env.require(offers(fyn, 0)); } // Start messing with two non-native currencies. auto const gw2 = Account("gateway2"); - auto const EUR = gw2["EUR"]; + auto const eur = gw2["EUR"]; env.fund(XRP(100000), gw2); env.close(); @@ -3064,30 +3065,30 @@ public: env.fund(reserve(env, 3) + (fee * 3), gay, hal); env.close(); - env(trust(gay, USD(200))); - env(trust(gay, EUR(200))); - env(trust(hal, USD(200))); - env(trust(hal, EUR(200))); + env(trust(gay, usd(200))); + env(trust(gay, eur(200))); + env(trust(hal, usd(200))); + env(trust(hal, eur(200))); env.close(); - env(pay(gw1, gay, USD(125))); - env(pay(gw2, hal, EUR(150))); + env(pay(gw1, gay, usd(125))); + env(pay(gw2, hal, eur(150))); env.close(); - env(offer(gay, EUR(100), USD(100))); + env(offer(gay, eur(100), usd(100))); env.close(); - env(offer(hal, USD(100), EUR(100))); + env(offer(hal, usd(100), eur(100))); env.close(); - env.require(balance(gay, USD(0))); - env.require(balance(gay, EUR(100))); - env.require(balance(gay, reserve(env, 3))); + env.require(Balance(gay, usd(0))); + env.require(Balance(gay, eur(100))); + env.require(Balance(gay, reserve(env, 3))); env.require(offers(gay, 0)); - env.require(balance(hal, USD(100))); - env.require(balance(hal, EUR(0))); - env.require(balance(hal, reserve(env, 3))); + env.require(Balance(hal, usd(100))); + env.require(Balance(hal, eur(0))); + env.require(Balance(hal, reserve(env, 3))); env.require(offers(hal, 0)); } { @@ -3097,82 +3098,82 @@ public: env.fund(reserve(env, 3) + (fee * 3), ivy, joe); env.close(); - env(trust(ivy, USD(400)), qualityInPercent(90)); - env(trust(ivy, EUR(400)), qualityInPercent(80)); - env(trust(joe, USD(400)), qualityInPercent(70)); - env(trust(joe, EUR(400)), qualityInPercent(60)); + env(trust(ivy, usd(400)), QualityInPercent(90)); + env(trust(ivy, eur(400)), QualityInPercent(80)); + env(trust(joe, usd(400)), QualityInPercent(70)); + env(trust(joe, eur(400)), QualityInPercent(60)); env.close(); - env(pay(gw1, ivy, USD(270)), sendmax(USD(500))); - env(pay(gw2, joe, EUR(150)), sendmax(EUR(300))); + env(pay(gw1, ivy, usd(270)), Sendmax(usd(500))); + env(pay(gw2, joe, eur(150)), Sendmax(eur(300))); env.close(); - env.require(balance(ivy, USD(300))); - env.require(balance(joe, EUR(250))); + env.require(Balance(ivy, usd(300))); + env.require(Balance(joe, eur(250))); - env(offer(ivy, EUR(100), USD(200))); + env(offer(ivy, eur(100), usd(200))); env.close(); - env(offer(joe, USD(200), EUR(100))); + env(offer(joe, usd(200), eur(100))); env.close(); - env.require(balance(ivy, USD(50))); - env.require(balance(ivy, EUR(100))); - env.require(balance(ivy, reserve(env, 3))); + env.require(Balance(ivy, usd(50))); + env.require(Balance(ivy, eur(100))); + env.require(Balance(ivy, reserve(env, 3))); env.require(offers(ivy, 0)); - env.require(balance(joe, USD(200))); - env.require(balance(joe, EUR(100))); - env.require(balance(joe, reserve(env, 3))); + env.require(Balance(joe, usd(200))); + env.require(Balance(joe, eur(100))); + env.require(Balance(joe, reserve(env, 3))); env.require(offers(joe, 0)); } { // A trust line's QualityOut should not affect offer crossing. auto const kim = Account("kim"); - auto const K_BUX = kim["BUX"]; + auto const kBux = kim["BUX"]; auto const lex = Account("lex"); auto const meg = Account("meg"); auto const ned = Account("ned"); - auto const N_BUX = ned["BUX"]; + auto const nBux = ned["BUX"]; // Verify trust line QualityOut affects payments. env.fund(reserve(env, 4) + (fee * 4), kim, lex, meg, ned); env.close(); - env(trust(lex, K_BUX(400))); - env(trust(lex, N_BUX(200)), qualityOutPercent(120)); - env(trust(meg, N_BUX(100))); + env(trust(lex, kBux(400))); + env(trust(lex, nBux(200)), QualityOutPercent(120)); + env(trust(meg, nBux(100))); env.close(); - env(pay(ned, lex, N_BUX(100))); + env(pay(ned, lex, nBux(100))); env.close(); - env.require(balance(lex, N_BUX(100))); + env.require(Balance(lex, nBux(100))); - env(pay(kim, meg, N_BUX(60)), path(lex, ned), sendmax(K_BUX(200))); + env(pay(kim, meg, nBux(60)), Path(lex, ned), Sendmax(kBux(200))); env.close(); - env.require(balance(kim, K_BUX(none))); - env.require(balance(kim, N_BUX(none))); - env.require(balance(lex, K_BUX(72))); - env.require(balance(lex, N_BUX(40))); - env.require(balance(meg, K_BUX(none))); - env.require(balance(meg, N_BUX(60))); - env.require(balance(ned, K_BUX(none))); - env.require(balance(ned, N_BUX(none))); + env.require(Balance(kim, kBux(kNONE))); + env.require(Balance(kim, nBux(kNONE))); + env.require(Balance(lex, kBux(72))); + env.require(Balance(lex, nBux(40))); + env.require(Balance(meg, kBux(kNONE))); + env.require(Balance(meg, nBux(60))); + env.require(Balance(ned, kBux(kNONE))); + env.require(Balance(ned, nBux(kNONE))); // Now verify that offer crossing is unaffected by QualityOut. - env(offer(lex, K_BUX(30), N_BUX(30))); + env(offer(lex, kBux(30), nBux(30))); env.close(); - env(offer(kim, N_BUX(30), K_BUX(30))); + env(offer(kim, nBux(30), kBux(30))); env.close(); - env.require(balance(kim, K_BUX(none))); - env.require(balance(kim, N_BUX(30))); - env.require(balance(lex, K_BUX(102))); - env.require(balance(lex, N_BUX(10))); - env.require(balance(meg, K_BUX(none))); - env.require(balance(meg, N_BUX(60))); - env.require(balance(ned, K_BUX(-30))); - env.require(balance(ned, N_BUX(none))); + env.require(Balance(kim, kBux(kNONE))); + env.require(Balance(kim, nBux(30))); + env.require(Balance(lex, kBux(102))); + env.require(Balance(lex, nBux(10))); + env.require(Balance(meg, kBux(kNONE))); + env.require(Balance(meg, nBux(60))); + env.require(Balance(ned, kBux(-30))); + env.require(Balance(ned, nBux(kNONE))); } { // Make sure things work right when we're auto-bridging as well. @@ -3185,28 +3186,28 @@ public: // o ova has USD but wants XRP. // o pat has XRP but wants EUR. // o qae has EUR but wants USD. - env(trust(ova, USD(200))); - env(trust(ova, EUR(200))); - env(trust(pat, USD(200))); - env(trust(pat, EUR(200))); - env(trust(qae, USD(200))); - env(trust(qae, EUR(200))); + env(trust(ova, usd(200))); + env(trust(ova, eur(200))); + env(trust(pat, usd(200))); + env(trust(pat, eur(200))); + env(trust(qae, usd(200))); + env(trust(qae, eur(200))); env.close(); - env(pay(gw1, ova, USD(125))); - env(pay(gw2, qae, EUR(150))); + env(pay(gw1, ova, usd(125))); + env(pay(gw2, qae, eur(150))); env.close(); - env(offer(ova, XRP(2), USD(100))); - env(offer(pat, EUR(100), XRP(2))); + env(offer(ova, XRP(2), usd(100))); + env(offer(pat, eur(100), XRP(2))); env.close(); - env(offer(qae, USD(100), EUR(100))); + env(offer(qae, usd(100), eur(100))); env.close(); - env.require(balance(ova, USD(0))); - env.require(balance(ova, EUR(0))); - env.require(balance(ova, XRP(4) + reserve(env, 3))); + env.require(Balance(ova, usd(0))); + env.require(Balance(ova, eur(0))); + env.require(Balance(ova, XRP(4) + reserve(env, 3))); // In pre-flow code ova's offer is left empty in the ledger. auto const ovasOffers = offersOnAccount(env, ova); @@ -3216,18 +3217,18 @@ public: auto const& ovasOffer = *(ovasOffers.front()); BEAST_EXPECT(ovasOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(ovasOffer[sfTakerGets] == USD(0)); + BEAST_EXPECT(ovasOffer[sfTakerGets] == usd(0)); BEAST_EXPECT(ovasOffer[sfTakerPays] == XRP(0)); } - env.require(balance(pat, USD(0))); - env.require(balance(pat, EUR(100))); - env.require(balance(pat, XRP(0) + reserve(env, 3))); + env.require(Balance(pat, usd(0))); + env.require(Balance(pat, eur(100))); + env.require(Balance(pat, XRP(0) + reserve(env, 3))); env.require(offers(pat, 0)); - env.require(balance(qae, USD(100))); - env.require(balance(qae, EUR(0))); - env.require(balance(qae, XRP(2) + reserve(env, 3))); + env.require(Balance(qae, usd(100))); + env.require(Balance(qae, eur(0))); + env.require(Balance(qae, XRP(2) + reserve(env, 3))); env.require(offers(qae, 0)); } } @@ -3252,7 +3253,7 @@ public: using namespace jtx; auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env{*this, features}; @@ -3263,15 +3264,15 @@ public: env.fund(startBalance + (fee * 4), gw); env.close(); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); - env(offer(gw, USD(60), XRP(600))); + env(offer(gw, usd(60), XRP(600))); env.close(); - env.require(owners(gw, 3)); - env.require(balance(gw, startBalance + fee)); + env.require(Owners(gw, 3)); + env.require(Balance(gw, startBalance + fee)); auto gwOffers = offersOnAccount(env, gw); BEAST_EXPECT(gwOffers.size() == 3); @@ -3280,16 +3281,16 @@ public: auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(offer[sfTakerGets] == XRP(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(60)); + BEAST_EXPECT(offer[sfTakerPays] == usd(60)); } // Since this offer crosses the first offers, the previous offers // will be deleted and this offer will be put on the order book. - env(offer(gw, XRP(1000), USD(100))); + env(offer(gw, XRP(1000), usd(100))); env.close(); - env.require(owners(gw, 1)); + env.require(Owners(gw, 1)); env.require(offers(gw, 1)); - env.require(balance(gw, startBalance)); + env.require(Balance(gw, startBalance)); gwOffers = offersOnAccount(env, gw); BEAST_EXPECT(gwOffers.size() == 1); @@ -3297,7 +3298,7 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(100)); + BEAST_EXPECT(offer[sfTakerGets] == usd(100)); BEAST_EXPECT(offer[sfTakerPays] == XRP(1000)); } } @@ -3310,8 +3311,8 @@ public: auto const gw1 = Account("gateway1"); auto const gw2 = Account("gateway2"); auto const alice = Account("alice"); - auto const USD = gw1["USD"]; - auto const EUR = gw2["EUR"]; + auto const usd = gw1["USD"]; + auto const eur = gw2["EUR"]; Env env{*this, features}; @@ -3335,12 +3336,12 @@ public: // clang-format off TestData const tests[]{ // acct fundXRP fundUSD fundEUR firstOfferTec secondOfferTec - {.acct="ann", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=USD(1000), .fundEUR=EUR(1000), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, - {.acct="bev", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=USD( 1), .fundEUR=EUR(1000), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, - {.acct="cam", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=USD(1000), .fundEUR=EUR( 1), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, - {.acct="deb", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=USD( 0), .fundEUR=EUR( 1), .firstOfferTec=tesSUCCESS, .secondOfferTec=tecUNFUNDED_OFFER}, - {.acct="eve", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=USD( 1), .fundEUR=EUR( 0), .firstOfferTec=tecUNFUNDED_OFFER, .secondOfferTec=tesSUCCESS}, - {.acct="flo", .fundXRP=reserve(env, 3) + 0, .fundUSD=USD(1000), .fundEUR=EUR(1000), .firstOfferTec=tecINSUF_RESERVE_OFFER, .secondOfferTec=tecINSUF_RESERVE_OFFER}, + {.acct="ann", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=usd(1000), .fundEUR=eur(1000), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, + {.acct="bev", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=usd( 1), .fundEUR=eur(1000), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, + {.acct="cam", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=usd(1000), .fundEUR=eur( 1), .firstOfferTec=tesSUCCESS, .secondOfferTec=tesSUCCESS}, + {.acct="deb", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=usd( 0), .fundEUR=eur( 1), .firstOfferTec=tesSUCCESS, .secondOfferTec=tecUNFUNDED_OFFER}, + {.acct="eve", .fundXRP=reserve(env, 3) + f * 4, .fundUSD=usd( 1), .fundEUR=eur( 0), .firstOfferTec=tecUNFUNDED_OFFER, .secondOfferTec=tesSUCCESS}, + {.acct="flo", .fundXRP=reserve(env, 3) + 0, .fundUSD=usd(1000), .fundEUR=eur(1000), .firstOfferTec=tecINSUF_RESERVE_OFFER, .secondOfferTec=tecINSUF_RESERVE_OFFER}, }; //clang-format on @@ -3350,24 +3351,24 @@ public: env.fund(t.fundXRP, acct); env.close(); - env(trust(acct, USD(1000))); - env(trust(acct, EUR(1000))); + env(trust(acct, usd(1000))); + env(trust(acct, eur(1000))); env.close(); - if (t.fundUSD > USD(0)) + if (t.fundUSD > usd(0)) env(pay(gw1, acct, t.fundUSD)); - if (t.fundEUR > EUR(0)) + if (t.fundEUR > eur(0)) env(pay(gw2, acct, t.fundEUR)); env.close(); - env(offer(acct, USD(500), EUR(600)), ter(t.firstOfferTec)); + env(offer(acct, usd(500), eur(600)), Ter(t.firstOfferTec)); env.close(); std::uint32_t const firstOfferSeq = env.seq(acct) - 1; int offerCount = isTesSuccess(t.firstOfferTec) ? 1 : 0; - env.require(owners(acct, 2 + offerCount)); - env.require(balance(acct, t.fundUSD)); - env.require(balance(acct, t.fundEUR)); + env.require(Owners(acct, 2 + offerCount)); + env.require(Balance(acct, t.fundUSD)); + env.require(Balance(acct, t.fundEUR)); auto acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == offerCount); @@ -3375,18 +3376,18 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } - env(offer(acct, EUR(600), USD(500)), ter(t.secondOfferTec)); + env(offer(acct, eur(600), usd(500)), Ter(t.secondOfferTec)); env.close(); std::uint32_t const secondOfferSeq = env.seq(acct) - 1; offerCount = isTesSuccess(t.secondOfferTec) ? 1 : offerCount; - env.require(owners(acct, 2 + offerCount)); - env.require(balance(acct, t.fundUSD)); - env.require(balance(acct, t.fundEUR)); + env.require(Owners(acct, 2 + offerCount)); + env.require(Balance(acct, t.fundUSD)); + env.require(Balance(acct, t.fundEUR)); acctOffers = offersOnAccount(env, acct); BEAST_EXPECT(acctOffers.size() == offerCount); @@ -3396,20 +3397,20 @@ public: BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); if (offer[sfSequence] == firstOfferSeq) { - BEAST_EXPECT(offer[sfTakerGets] == EUR(600)); - BEAST_EXPECT(offer[sfTakerPays] == USD(500)); + BEAST_EXPECT(offer[sfTakerGets] == eur(600)); + BEAST_EXPECT(offer[sfTakerPays] == usd(500)); } else { - BEAST_EXPECT(offer[sfTakerGets] == USD(500)); - BEAST_EXPECT(offer[sfTakerPays] == EUR(600)); + BEAST_EXPECT(offer[sfTakerGets] == usd(500)); + BEAST_EXPECT(offer[sfTakerPays] == eur(600)); } } // Remove any offers from acct for the next pass. - env(offer_cancel(acct, firstOfferSeq)); + env(offerCancel(acct, firstOfferSeq)); env.close(); - env(offer_cancel(acct, secondOfferSeq)); + env(offerCancel(acct, secondOfferSeq)); env.close(); } } @@ -3435,23 +3436,23 @@ public: auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = bob["USD"]; + auto const usd = bob["USD"]; auto const f = env.current()->fees().base; env.fund(XRP(50000) + f, alice, bob); env.close(); - env(offer(alice, USD(5000), XRP(50000))); + env(offer(alice, usd(5000), XRP(50000))); env.close(); // This offer should take alice's offer up to Alice's reserve. - env(offer(bob, XRP(50000), USD(5000))); + env(offer(bob, XRP(50000), usd(5000))); env.close(); // alice's offer should have been removed, since she's down to her // XRP reserve. - env.require(balance(alice, XRP(250))); - env.require(owners(alice, 1)); + env.require(Balance(alice, XRP(250))); + env.require(Owners(alice, 1)); env.require(lines(alice, 1)); // However bob's offer should be in the ledger, since it was not @@ -3462,7 +3463,7 @@ public: { auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(offer[sfTakerGets] == USD(25)); + BEAST_EXPECT(offer[sfTakerGets] == usd(25)); BEAST_EXPECT(offer[sfTakerPays] == XRP(250)); } } @@ -3484,57 +3485,57 @@ public: { // A trust line's QualityOut should not affect offer crossing. auto const ann = Account("ann"); - auto const A_BUX = ann["BUX"]; + auto const aBux = ann["BUX"]; auto const bob = Account("bob"); auto const cam = Account("cam"); auto const dan = Account("dan"); - auto const D_BUX = dan["BUX"]; + auto const dBux = dan["BUX"]; // Verify trust line QualityOut affects payments. env.fund(reserve(env, 4) + (fee * 4), ann, bob, cam, dan); env.close(); - env(trust(bob, A_BUX(400))); - env(trust(bob, D_BUX(200)), qualityOutPercent(120)); - env(trust(cam, D_BUX(100))); + env(trust(bob, aBux(400))); + env(trust(bob, dBux(200)), QualityOutPercent(120)); + env(trust(cam, dBux(100))); env.close(); - env(pay(dan, bob, D_BUX(100))); + env(pay(dan, bob, dBux(100))); env.close(); - env.require(balance(bob, D_BUX(100))); + env.require(Balance(bob, dBux(100))); - env(pay(ann, cam, D_BUX(60)), path(bob, dan), sendmax(A_BUX(200))); + env(pay(ann, cam, dBux(60)), Path(bob, dan), Sendmax(aBux(200))); env.close(); - env.require(balance(ann, A_BUX(none))); - env.require(balance(ann, D_BUX(none))); - env.require(balance(bob, A_BUX(72))); - env.require(balance(bob, D_BUX(40))); - env.require(balance(cam, A_BUX(none))); - env.require(balance(cam, D_BUX(60))); - env.require(balance(dan, A_BUX(none))); - env.require(balance(dan, D_BUX(none))); + env.require(Balance(ann, aBux(kNONE))); + env.require(Balance(ann, dBux(kNONE))); + env.require(Balance(bob, aBux(72))); + env.require(Balance(bob, dBux(40))); + env.require(Balance(cam, aBux(kNONE))); + env.require(Balance(cam, dBux(60))); + env.require(Balance(dan, aBux(kNONE))); + env.require(Balance(dan, dBux(kNONE))); - env(offer(bob, A_BUX(30), D_BUX(30))); + env(offer(bob, aBux(30), dBux(30))); env.close(); - env(trust(ann, D_BUX(100))); + env(trust(ann, dBux(100))); env.close(); // This payment caused the assert. - env(pay(ann, ann, D_BUX(30)), - path(A_BUX, D_BUX), - sendmax(A_BUX(30)), - ter(temBAD_PATH)); + env(pay(ann, ann, dBux(30)), + Path(aBux, dBux), + Sendmax(aBux(30)), + Ter(temBAD_PATH)); env.close(); - env.require(balance(ann, A_BUX(none))); - env.require(balance(ann, D_BUX(0))); - env.require(balance(bob, A_BUX(72))); - env.require(balance(bob, D_BUX(40))); - env.require(balance(cam, A_BUX(none))); - env.require(balance(cam, D_BUX(60))); - env.require(balance(dan, A_BUX(0))); - env.require(balance(dan, D_BUX(none))); + env.require(Balance(ann, aBux(kNONE))); + env.require(Balance(ann, dBux(0))); + env.require(Balance(bob, aBux(72))); + env.require(Balance(bob, dBux(40))); + env.require(Balance(cam, aBux(kNONE))); + env.require(Balance(cam, dBux(60))); + env.require(Balance(dan, aBux(0))); + env.require(Balance(dan, dBux(kNONE))); } } @@ -3554,40 +3555,40 @@ public: auto const ann = Account("ann"); auto const bob = Account("bob"); auto const cam = Account("cam"); - auto const A_BUX = ann["BUX"]; - auto const B_BUX = bob["BUX"]; + auto const aBux = ann["BUX"]; + auto const bBux = bob["BUX"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 4) + (fee * 5), ann, bob, cam); env.close(); - env(trust(ann, B_BUX(40))); - env(trust(cam, A_BUX(40))); - env(trust(cam, B_BUX(40))); + env(trust(ann, bBux(40))); + env(trust(cam, aBux(40))); + env(trust(cam, bBux(40))); env.close(); - env(pay(ann, cam, A_BUX(35))); - env(pay(bob, cam, B_BUX(35))); + env(pay(ann, cam, aBux(35))); + env(pay(bob, cam, bBux(35))); - env(offer(bob, A_BUX(30), B_BUX(30))); + env(offer(bob, aBux(30), bBux(30))); env.close(); // cam puts an offer on the books that her upcoming offer could cross. // But this offer should be deleted, not crossed, by her upcoming // offer. - env(offer(cam, A_BUX(29), B_BUX(30), tfPassive)); + env(offer(cam, aBux(29), bBux(30), tfPassive)); env.close(); - env.require(balance(cam, A_BUX(35))); - env.require(balance(cam, B_BUX(35))); + env.require(Balance(cam, aBux(35))); + env.require(Balance(cam, bBux(35))); env.require(offers(cam, 1)); // This offer caused the assert. - env(offer(cam, B_BUX(30), A_BUX(30))); + env(offer(cam, bBux(30), aBux(30))); env.close(); - env.require(balance(bob, A_BUX(30))); - env.require(balance(cam, A_BUX(5))); - env.require(balance(cam, B_BUX(65))); + env.require(Balance(bob, aBux(30))); + env.require(Balance(cam, aBux(5))); + env.require(Balance(cam, bBux(65))); env.require(offers(cam, 0)); } @@ -3605,7 +3606,7 @@ public: auto const ann = Account("ann"); auto const gw = Account("gateway"); - auto const BTC = gw["BTC"]; + auto const btc = gw["BTC"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 2) + drops(9999640) + (fee), ann); @@ -3613,18 +3614,18 @@ public: env.close(); env(rate(gw, 1.002)); - env(trust(ann, BTC(10))); + env(trust(ann, btc(10))); env.close(); - env(pay(gw, ann, BTC(2.856))); + env(pay(gw, ann, btc(2.856))); env.close(); - env(offer(ann, drops(365611702030), BTC(5.713))); + env(offer(ann, drops(365611702030), btc(5.713))); env.close(); // This offer caused the assert. - env(offer(ann, BTC(0.687), drops(20000000000)), - ter(tecINSUF_RESERVE_OFFER)); + env(offer(ann, btc(0.687), drops(20000000000)), + Ter(tecINSUF_RESERVE_OFFER)); } void @@ -3643,24 +3644,24 @@ public: auto const gw = Account("gateway"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const CNY = gw["CNY"]; + auto const cny = gw["CNY"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 2) + drops(400000000000) + (fee), alice, bob); env.fund(reserve(env, 2) + (fee * 4), gw); env.close(); - env(trust(bob, CNY(500))); + env(trust(bob, cny(500))); env.close(); - env(pay(gw, bob, CNY(300))); + env(pay(gw, bob, cny(300))); env.close(); - env(offer(bob, drops(5400000000), CNY(216.054))); + env(offer(bob, drops(5400000000), cny(216.054))); env.close(); // This offer did not round result of partial crossing correctly. - env(offer(alice, CNY(13562.0001), drops(339000000000))); + env(offer(alice, cny(13562.0001), drops(339000000000))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -3670,7 +3671,7 @@ public: auto const& offer = *offerPtr; BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT(offer[sfTakerGets] == drops(333599446582)); - BEAST_EXPECT(offer[sfTakerPays] == CNY(13345.9461)); + BEAST_EXPECT(offer[sfTakerPays] == cny(13345.9461)); } } @@ -3689,8 +3690,8 @@ public: auto const gw = Account("gateway"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const BTC = gw["BTC"]; - auto const JPY = gw["JPY"]; + auto const btc = gw["BTC"]; + auto const jpy = gw["JPY"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 2) + drops(400000000000) + (fee), alice, bob); @@ -3698,19 +3699,19 @@ public: env.close(); env(rate(gw, 1.002)); - env(trust(alice, JPY(4000))); - env(trust(bob, BTC(2))); + env(trust(alice, jpy(4000))); + env(trust(bob, btc(2))); env.close(); - env(pay(gw, alice, JPY(3699.034802280317))); - env(pay(gw, bob, BTC(1.156722559140311))); + env(pay(gw, alice, jpy(3699.034802280317))); + env(pay(gw, bob, btc(1.156722559140311))); env.close(); - env(offer(bob, JPY(1241.913390770747), BTC(0.01969825690469254))); + env(offer(bob, jpy(1241.913390770747), btc(0.01969825690469254))); env.close(); // This offer did not round result of partial crossing correctly. - env(offer(alice, BTC(0.05507568706427876), JPY(3472.696773391072))); + env(offer(alice, btc(0.05507568706427876), jpy(3472.696773391072))); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -3721,8 +3722,8 @@ public: BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT( offer[sfTakerGets] == - STAmount(JPY, std::uint64_t(2230682446713524ul), -12)); - BEAST_EXPECT(offer[sfTakerPays] == BTC(0.035378)); + STAmount(jpy, std::uint64_t(2230682446713524ul), -12)); + BEAST_EXPECT(offer[sfTakerPays] == btc(0.035378)); } } @@ -3742,8 +3743,8 @@ public: auto const gw2 = Account("gw2"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const USD = gw1["USD"]; - auto const JPY = gw2["JPY"]; + auto const usd = gw1["USD"]; + auto const jpy = gw2["JPY"]; auto const fee = env.current()->fees().base; env.fund(reserve(env, 2) + drops(400000000000) + (fee), alice, bob); @@ -3751,31 +3752,31 @@ public: env.close(); env(rate(gw1, 1.002)); - env(trust(alice, USD(1000))); - env(trust(bob, JPY(100000))); + env(trust(alice, usd(1000))); + env(trust(bob, jpy(100000))); env.close(); env( pay(gw1, alice, - STAmount{USD, std::uint64_t(2185410179555600), -14})); + STAmount{usd, std::uint64_t(2185410179555600), -14})); env( pay(gw2, bob, - STAmount{JPY, std::uint64_t(6351823459548956), -12})); + STAmount{jpy, std::uint64_t(6351823459548956), -12})); env.close(); env(offer( bob, - STAmount{USD, std::uint64_t(4371257532306000), -17}, - STAmount{JPY, std::uint64_t(4573216636606000), -15})); + STAmount{usd, std::uint64_t(4371257532306000), -17}, + STAmount{jpy, std::uint64_t(4573216636606000), -15})); env.close(); // This offer did not partially cross correctly. env(offer( alice, - STAmount{JPY, std::uint64_t(2291181510070762), -12}, - STAmount{USD, std::uint64_t(2190218999914694), -14})); + STAmount{jpy, std::uint64_t(2291181510070762), -12}, + STAmount{usd, std::uint64_t(2190218999914694), -14})); env.close(); auto const aliceOffers = offersOnAccount(env, alice); @@ -3786,10 +3787,10 @@ public: BEAST_EXPECT(offer[sfLedgerEntryType] == ltOFFER); BEAST_EXPECT( offer[sfTakerGets] == - STAmount(USD, std::uint64_t(2185847305256635), -14)); + STAmount(usd, std::uint64_t(2185847305256635), -14)); BEAST_EXPECT( offer[sfTakerPays] == - STAmount(JPY, std::uint64_t(2286608293434156), -12)); + STAmount(jpy, std::uint64_t(2286608293434156), -12)); } } @@ -3805,40 +3806,40 @@ public: auto const gw = Account("gw"); auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const CNY = gw["CNY"]; + auto const cny = gw["CNY"]; auto const fee = env.current()->fees().base; auto const startXrpBalance = drops(400000000000) + (fee * 2); env.fund(startXrpBalance, gw, alice, bob); env.close(); - env(trust(bob, CNY(100000))); + env(trust(bob, cny(100000))); env.close(); // Place alice's tiny offer in the book first. Let's see what happens // when a reasonable offer crosses it. STAmount const aliceCnyOffer{ - CNY, std::uint64_t(4926000000000000), -23}; + cny, std::uint64_t(4926000000000000), -23}; env(offer(alice, aliceCnyOffer, drops(1), tfPassive)); env.close(); // bob places an ordinary offer STAmount const bobCnyStartBalance{ - CNY, std::uint64_t(3767479960090235), -15}; + cny, std::uint64_t(3767479960090235), -15}; env(pay(gw, bob, bobCnyStartBalance)); env.close(); env(offer( bob, drops(203), - STAmount{CNY, std::uint64_t(1000000000000000), -20})); + STAmount{cny, std::uint64_t(1000000000000000), -20})); env.close(); - env.require(balance(alice, aliceCnyOffer)); - env.require(balance(alice, startXrpBalance - fee - drops(1))); - env.require(balance(bob, bobCnyStartBalance - aliceCnyOffer)); - env.require(balance(bob, startXrpBalance - (fee * 2) + drops(1))); + env.require(Balance(alice, aliceCnyOffer)); + env.require(Balance(alice, startXrpBalance - fee - drops(1))); + env.require(Balance(bob, bobCnyStartBalance - aliceCnyOffer)); + env.require(Balance(bob, startXrpBalance - (fee * 2) + drops(1))); } void @@ -3886,8 +3887,8 @@ public: auto const baseFee = env.current()->fees().base.drops(); auto const gw = Account("gw"); - auto const BTC = gw["BTC"]; - auto const USD = gw["USD"]; + auto const btc = gw["BTC"]; + auto const usd = gw["USD"]; auto const startXrpBalance = XRP(4000000); env.fund(startXrpBalance, gw); @@ -3921,10 +3922,10 @@ public: // clang-format off TestData const tests[]{ // btcStart --------------------- actor[0] --------------------- -------------------- actor[1] ------------------- - {.self=0, .leg0=0, .leg1=1, .btcStart=BTC(20), .actors={{"ann", 0, drops(3900000'000000 - (4 * baseFee)), BTC(20.0), USD(3000)}, {"abe", 0, drops(4100000'000000 - (3 * baseFee)), BTC( 0), USD(750)}}}, // no BTC xfer fee - {.self=0, .leg0=1, .leg1=0, .btcStart=BTC(20), .actors={{"bev", 0, drops(4100000'000000 - (4 * baseFee)), BTC( 7.5), USD(2000)}, {"bob", 0, drops(3900000'000000 - (3 * baseFee)), BTC(10), USD( 0)}}}, // no USD xfer fee - {.self=0, .leg0=0, .leg1=0, .btcStart=BTC(20), .actors={{"cam", 0, drops(4000000'000000 - (5 * baseFee)), BTC(20.0), USD(2000)} }}, // no xfer fee - {.self=0, .leg0=1, .leg1=0, .btcStart=BTC( 5), .actors={{"deb", 1, drops(4040000'000000 - (4 * baseFee)), BTC( 0.0), USD(2000)}, {"dan", 1, drops(3960000'000000 - (3 * baseFee)), BTC( 4), USD( 0)}}}, // no USD xfer fee + {.self=0, .leg0=0, .leg1=1, .btcStart=btc(20), .actors={{"ann", 0, drops(3900000'000000 - (4 * baseFee)), btc(20.0), usd(3000)}, {"abe", 0, drops(4100000'000000 - (3 * baseFee)), btc( 0), usd(750)}}}, // no BTC xfer fee + {.self=0, .leg0=1, .leg1=0, .btcStart=btc(20), .actors={{"bev", 0, drops(4100000'000000 - (4 * baseFee)), btc( 7.5), usd(2000)}, {"bob", 0, drops(3900000'000000 - (3 * baseFee)), btc(10), usd( 0)}}}, // no USD xfer fee + {.self=0, .leg0=0, .leg1=0, .btcStart=btc(20), .actors={{"cam", 0, drops(4000000'000000 - (5 * baseFee)), btc(20.0), usd(2000)} }}, // no xfer fee + {.self=0, .leg0=1, .leg1=0, .btcStart=btc( 5), .actors={{"deb", 1, drops(4040000'000000 - (4 * baseFee)), btc( 0.0), usd(2000)}, {"dan", 1, drops(3960000'000000 - (3 * baseFee)), btc( 4), usd( 0)}}}, // no USD xfer fee }; // clang-format on @@ -3939,29 +3940,29 @@ public: env.fund(XRP(4000000), actor.acct); env.close(); - env(trust(actor.acct, BTC(40))); - env(trust(actor.acct, USD(8000))); + env(trust(actor.acct, btc(40))); + env(trust(actor.acct, usd(8000))); env.close(); } env(pay(gw, self, t.btcStart)); - env(pay(gw, self, USD(2000))); + env(pay(gw, self, usd(2000))); if (self.id() != leg1.id()) - env(pay(gw, leg1, USD(2000))); + env(pay(gw, leg1, usd(2000))); env.close(); // Get the initial offers in place. Remember their sequences // so we can delete them later. - env(offer(leg0, BTC(10), XRP(100000), tfPassive)); + env(offer(leg0, btc(10), XRP(100000), tfPassive)); env.close(); std::uint32_t const leg0OfferSeq = env.seq(leg0) - 1; - env(offer(leg1, XRP(100000), USD(1000), tfPassive)); + env(offer(leg1, XRP(100000), usd(1000), tfPassive)); env.close(); std::uint32_t const leg1OfferSeq = env.seq(leg1) - 1; // This is the offer that matters. - env(offer(self, USD(1000), BTC(10))); + env(offer(self, usd(1000), btc(10))); env.close(); std::uint32_t const selfOfferSeq = env.seq(self) - 1; @@ -3978,17 +3979,17 @@ public: }).begin()); BEAST_EXPECT(offerCount == actor.offers); - env.require(balance(actor.acct, actor.xrp)); - env.require(balance(actor.acct, actor.btc)); - env.require(balance(actor.acct, actor.usd)); + env.require(Balance(actor.acct, actor.xrp)); + env.require(Balance(actor.acct, actor.btc)); + env.require(Balance(actor.acct, actor.usd)); } // Remove any offers that might be left hanging around. They // could bollix up later loops. - env(offer_cancel(leg0, leg0OfferSeq)); + env(offerCancel(leg0, leg0OfferSeq)); env.close(); - env(offer_cancel(leg1, leg1OfferSeq)); + env(offerCancel(leg1, leg1OfferSeq)); env.close(); - env(offer_cancel(self, selfOfferSeq)); + env(offerCancel(self, selfOfferSeq)); env.close(); } } @@ -4034,8 +4035,8 @@ public: auto const baseFee = env.current()->fees().base.drops(); auto const gw = Account("gw"); - auto const BTC = gw["BTC"]; - auto const USD = gw["USD"]; + auto const btc = gw["BTC"]; + auto const usd = gw["USD"]; auto const startXrpBalance = XRP(4000000); env.fund(startXrpBalance, gw); @@ -4069,8 +4070,8 @@ public: // clang-format off TestData const tests[]{ // btcStart ------------------- actor[0] -------------------- ------------------- actor[1] -------------------- - {.self=0, .leg0=0, .leg1=1, .btcStart=BTC(5), .actors={{"gay", 1, drops(3950000'000000 - (4 * baseFee)), BTC(5), USD(2500)}, {"gar", 1, drops(4050000'000000 - (3 * baseFee)), BTC(0), USD(1375)}}}, // no BTC xfer fee - {.self=0, .leg0=0, .leg1=0, .btcStart=BTC(5), .actors={{"hye", 2, drops(4000000'000000 - (5 * baseFee)), BTC(5), USD(2000)} }} // no xfer fee + {.self=0, .leg0=0, .leg1=1, .btcStart=btc(5), .actors={{"gay", 1, drops(3950000'000000 - (4 * baseFee)), btc(5), usd(2500)}, {"gar", 1, drops(4050000'000000 - (3 * baseFee)), btc(0), usd(1375)}}}, // no BTC xfer fee + {.self=0, .leg0=0, .leg1=0, .btcStart=btc(5), .actors={{"hye", 2, drops(4000000'000000 - (5 * baseFee)), btc(5), usd(2000)} }} // no xfer fee }; // clang-format on @@ -4085,29 +4086,29 @@ public: env.fund(XRP(4000000), actor.acct); env.close(); - env(trust(actor.acct, BTC(40))); - env(trust(actor.acct, USD(8000))); + env(trust(actor.acct, btc(40))); + env(trust(actor.acct, usd(8000))); env.close(); } env(pay(gw, self, t.btcStart)); - env(pay(gw, self, USD(2000))); + env(pay(gw, self, usd(2000))); if (self.id() != leg1.id()) - env(pay(gw, leg1, USD(2000))); + env(pay(gw, leg1, usd(2000))); env.close(); // Get the initial offers in place. Remember their sequences // so we can delete them later. - env(offer(leg0, BTC(10), XRP(100000), tfPassive)); + env(offer(leg0, btc(10), XRP(100000), tfPassive)); env.close(); std::uint32_t const leg0OfferSeq = env.seq(leg0) - 1; - env(offer(leg1, XRP(100000), USD(1000), tfPassive)); + env(offer(leg1, XRP(100000), usd(1000), tfPassive)); env.close(); std::uint32_t const leg1OfferSeq = env.seq(leg1) - 1; // This is the offer that matters. - env(offer(self, USD(1000), BTC(10))); + env(offer(self, usd(1000), btc(10))); env.close(); std::uint32_t const selfOfferSeq = env.seq(self) - 1; @@ -4124,17 +4125,17 @@ public: }).begin()); BEAST_EXPECT(offerCount == actor.offers); - env.require(balance(actor.acct, actor.xrp)); - env.require(balance(actor.acct, actor.btc)); - env.require(balance(actor.acct, actor.usd)); + env.require(Balance(actor.acct, actor.xrp)); + env.require(Balance(actor.acct, actor.btc)); + env.require(Balance(actor.acct, actor.usd)); } // Remove any offers that might be left hanging around. They // could bollix up later loops. - env(offer_cancel(leg0, leg0OfferSeq)); + env(offerCancel(leg0, leg0OfferSeq)); env.close(); - env(offer_cancel(leg1, leg1OfferSeq)); + env(offerCancel(leg1, leg1OfferSeq)); env.close(); - env(offer_cancel(self, selfOfferSeq)); + env(offerCancel(self, selfOfferSeq)); env.close(); } } @@ -4163,31 +4164,31 @@ public: env.close(); // Properly set trust and have gw authorize bob and alice - env(trust(gw, bobUSD(100)), txflags(tfSetfAuth)); + env(trust(gw, bobUSD(100)), Txflags(tfSetfAuth)); env(trust(bob, gwUSD(100))); - env(trust(gw, aliceUSD(100)), txflags(tfSetfAuth)); + env(trust(gw, aliceUSD(100)), Txflags(tfSetfAuth)); env(trust(alice, gwUSD(100))); // Alice is able to place the offer since the GW has authorized her env(offer(alice, gwUSD(40), XRP(4000))); env.close(); env.require(offers(alice, 1)); - env.require(balance(alice, gwUSD(0))); + env.require(Balance(alice, gwUSD(0))); env(pay(gw, bob, gwUSD(50))); env.close(); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // Bob's offer should cross Alice's env(offer(bob, XRP(4000), gwUSD(40))); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(40))); + env.require(Balance(alice, gwUSD(40))); env.require(offers(bob, 0)); - env.require(balance(bob, gwUSD(10))); + env.require(Balance(bob, gwUSD(10))); } void @@ -4230,18 +4231,18 @@ public: env.close(); env.require(offers(alice, 1)); - env.require(balance(alice, gwUSD(none))); + env.require(Balance(alice, gwUSD(kNONE))); env(fset(gw, asfRequireAuth)); env.close(); - env(trust(gw, bobUSD(100)), txflags(tfSetfAuth)); + env(trust(gw, bobUSD(100)), Txflags(tfSetfAuth)); env.close(); env(trust(bob, gwUSD(100))); env.close(); env(pay(gw, bob, gwUSD(50))); env.close(); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // gw now requires authorization and bob has gwUSD(50). Let's see if // bob can cross alice's offer. @@ -4254,45 +4255,45 @@ public: env.require(offers(alice, 0)); // alice's unauthorized offer is deleted & bob's offer not crossed. - env.require(balance(alice, gwUSD(none))); + env.require(Balance(alice, gwUSD(kNONE))); env.require(offers(bob, 1)); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // See if alice can create an offer without authorization. alice // should not be able to create the offer and bob's offer should be // untouched. - env(offer(alice, gwUSD(40), XRP(4000)), ter(tecNO_LINE)); + env(offer(alice, gwUSD(40), XRP(4000)), Ter(tecNO_LINE)); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(none))); + env.require(Balance(alice, gwUSD(kNONE))); env.require(offers(bob, 1)); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // Set up a trust line for alice, but don't authorize it. alice // should still not be able to create an offer for USD/gw. env(trust(gw, aliceUSD(100))); env.close(); - env(offer(alice, gwUSD(40), XRP(4000)), ter(tecNO_AUTH)); + env(offer(alice, gwUSD(40), XRP(4000)), Ter(tecNO_AUTH)); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(0))); + env.require(Balance(alice, gwUSD(0))); env.require(offers(bob, 1)); - env.require(balance(bob, gwUSD(50))); + env.require(Balance(bob, gwUSD(50))); // Delete bob's offer so alice can create an offer without crossing. - env(offer_cancel(bob, bobOfferSeq)); + env(offerCancel(bob, bobOfferSeq)); env.close(); env.require(offers(bob, 0)); // Finally, set up an authorized trust line for alice. Now alice's // offer should succeed. Note that, since this is an offer rather // than a payment, alice does not need to set a trust line limit. - env(trust(gw, aliceUSD(100)), txflags(tfSetfAuth)); + env(trust(gw, aliceUSD(100)), Txflags(tfSetfAuth)); env.close(); env(offer(alice, gwUSD(40), XRP(4000))); @@ -4305,10 +4306,10 @@ public: env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(40))); + env.require(Balance(alice, gwUSD(40))); env.require(offers(bob, 0)); - env.require(balance(bob, gwUSD(10))); + env.require(Balance(bob, gwUSD(10))); } void @@ -4332,8 +4333,8 @@ public: auto const coldEU = Account("coldEU"); auto const mm = Account("mm"); - auto const USD = coldUS["USD"]; - auto const EUR = coldEU["EUR"]; + auto const usd = coldUS["USD"]; + auto const eur = coldEU["EUR"]; env.fund(XRP(100000), hotUS, coldUS, hotEU, coldEU, mm); env.close(); @@ -4347,52 +4348,52 @@ public: env.close(); // Each hot wallet trusts the related cold wallet for a large amount - env(trust(hotUS, USD(10000000)), txflags(tfSetNoRipple)); - env(trust(hotEU, EUR(10000000)), txflags(tfSetNoRipple)); + env(trust(hotUS, usd(10000000)), Txflags(tfSetNoRipple)); + env(trust(hotEU, eur(10000000)), Txflags(tfSetNoRipple)); // Market maker trusts both cold wallets for a large amount - env(trust(mm, USD(10000000)), txflags(tfSetNoRipple)); - env(trust(mm, EUR(10000000)), txflags(tfSetNoRipple)); + env(trust(mm, usd(10000000)), Txflags(tfSetNoRipple)); + env(trust(mm, eur(10000000)), Txflags(tfSetNoRipple)); env.close(); // Gateways authorize the trustlines of hot and market maker - env(trust(coldUS, USD(0), hotUS, tfSetfAuth)); - env(trust(coldEU, EUR(0), hotEU, tfSetfAuth)); - env(trust(coldUS, USD(0), mm, tfSetfAuth)); - env(trust(coldEU, EUR(0), mm, tfSetfAuth)); + env(trust(coldUS, usd(0), hotUS, tfSetfAuth)); + env(trust(coldEU, eur(0), hotEU, tfSetfAuth)); + env(trust(coldUS, usd(0), mm, tfSetfAuth)); + env(trust(coldEU, eur(0), mm, tfSetfAuth)); env.close(); // Issue currency from cold wallets to hot and market maker - env(pay(coldUS, hotUS, USD(5000000))); - env(pay(coldEU, hotEU, EUR(5000000))); - env(pay(coldUS, mm, USD(5000000))); - env(pay(coldEU, mm, EUR(5000000))); + env(pay(coldUS, hotUS, usd(5000000))); + env(pay(coldEU, hotEU, eur(5000000))); + env(pay(coldUS, mm, usd(5000000))); + env(pay(coldEU, mm, eur(5000000))); env.close(); // MM places offers float const rate = 0.9f; // 0.9 USD = 1 EUR - env(offer(mm, EUR(4000000 * rate), USD(4000000)), json(jss::Flags, tfSell)); + env(offer(mm, eur(4000000 * rate), usd(4000000)), Json(jss::Flags, tfSell)); float const reverseRate = 1.0f / rate * 1.00101f; - env(offer(mm, USD(4000000 * reverseRate), EUR(4000000)), json(jss::Flags, tfSell)); + env(offer(mm, usd(4000000 * reverseRate), eur(4000000)), Json(jss::Flags, tfSell)); env.close(); // There should be a path available from hot US to cold EUR { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::destination_account] = coldEU.human(); jvParams[jss::destination_amount][jss::issuer] = coldEU.human(); jvParams[jss::destination_amount][jss::currency] = "EUR"; jvParams[jss::destination_amount][jss::value] = 10; jvParams[jss::source_account] = hotUS.human(); - Json::Value const jrr{ + json::Value const jrr{ env.rpc("json", "ripple_path_find", to_string(jvParams))[jss::result]}; BEAST_EXPECT(jrr[jss::status] == "success"); BEAST_EXPECT(jrr[jss::alternatives].isArray() && jrr[jss::alternatives].size() > 0); } // Send the payment using the found path. - env(pay(hotUS, coldEU, EUR(10)), sendmax(USD(11.1223326))); + env(pay(hotUS, coldEU, eur(10)), Sendmax(usd(11.1223326))); } void @@ -4419,11 +4420,11 @@ public: env.require(offers(gw, 1)); // Since gw has an offer out, gw should not be able to set RequireAuth. - env(fset(gw, asfRequireAuth), ter(tecOWNERS)); + env(fset(gw, asfRequireAuth), Ter(tecOWNERS)); env.close(); // Cancel gw's offer so we can set RequireAuth. - env(offer_cancel(gw, gwOfferSeq)); + env(offerCancel(gw, gwOfferSeq)); env.close(); env.require(offers(gw, 0)); @@ -4434,27 +4435,27 @@ public: // Before DepositPreauth an account with lsfRequireAuth set could not // create an offer to buy their own currency. After DepositPreauth // they can. - env(offer(gw, gwUSD(40), XRP(4000)), ter(tesSUCCESS)); + env(offer(gw, gwUSD(40), XRP(4000)), Ter(tesSUCCESS)); env.close(); env.require(offers(gw, 1)); // Set up an authorized trust line and pay alice gwUSD 50. - env(trust(gw, aliceUSD(100)), txflags(tfSetfAuth)); + env(trust(gw, aliceUSD(100)), Txflags(tfSetfAuth)); env(trust(alice, gwUSD(100))); env.close(); env(pay(gw, alice, gwUSD(50))); env.close(); - env.require(balance(alice, gwUSD(50))); + env.require(Balance(alice, gwUSD(50))); // alice's offer should cross gw's env(offer(alice, XRP(4000), gwUSD(40))); env.close(); env.require(offers(alice, 0)); - env.require(balance(alice, gwUSD(10))); + env.require(Balance(alice, gwUSD(10))); env.require(offers(gw, 0)); } @@ -4478,33 +4479,33 @@ public: Account const becky("becky"); Account const carol("carol"); Account const gw("gateway"); - auto const USD = gw["USD"]; - auto const BUX = alice["BUX"]; + auto const usd = gw["USD"]; + auto const bux = alice["BUX"]; Env env{*this, features}; env.fund(XRP(10000), alice, becky, carol, noripple(gw)); env.close(); - env.trust(USD(1000), becky); - env(pay(gw, becky, USD(5))); + env.trust(usd(1000), becky); + env(pay(gw, becky, usd(5))); env.close(); - BEAST_EXPECT(trustLineExists(env, gw, becky, USD.currency)); + BEAST_EXPECT(trustLineExists(env, gw, becky, usd.currency)); // Make offers that produce USD and can be crossed two ways: // direct XRP -> USD // direct BUX -> USD - env(offer(becky, XRP(2), USD(2)), txflags(tfPassive)); + env(offer(becky, XRP(2), usd(2)), Txflags(tfPassive)); std::uint32_t const beckyBuxUsdSeq{env.seq(becky)}; - env(offer(becky, BUX(3), USD(3)), txflags(tfPassive)); + env(offer(becky, bux(3), usd(3)), Txflags(tfPassive)); env.close(); // becky keeps the offers, but removes the trustline. - env(pay(becky, gw, USD(5))); - env.trust(USD(0), becky); + env(pay(becky, gw, usd(5))); + env.trust(usd(0), becky); env.close(); - BEAST_EXPECT(!trustLineExists(env, gw, becky, USD.currency)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(!trustLineExists(env, gw, becky, usd.currency)); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // Delete gw's account. { @@ -4521,7 +4522,7 @@ public: env.close(); // Account deletion has a high fee. Account for that. - env(acctdelete(gw, alice), fee(drops(env.current()->fees().increment))); + env(acctdelete(gw, alice), Fee(drops(env.current()->fees().increment))); env.close(); // Verify that gw's account root is gone from the ledger. @@ -4530,38 +4531,38 @@ public: // alice crosses becky's first offer. The offer create fails because // the USD issuer is not in the ledger. - env(offer(alice, USD(2), XRP(2)), ter(tecNO_ISSUER)); + env(offer(alice, usd(2), XRP(2)), Ter(tecNO_ISSUER)); env.close(); env.require(offers(alice, 0)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // alice crosses becky's second offer. Again, the offer create fails // because the USD issuer is not in the ledger. - env(offer(alice, USD(3), BUX(3)), ter(tecNO_ISSUER)); + env(offer(alice, usd(3), bux(3)), Ter(tecNO_ISSUER)); env.require(offers(alice, 0)); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); - BEAST_EXPECT(isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); + BEAST_EXPECT(isOffer(env, becky, bux(3), usd(3))); // Cancel becky's BUX -> USD offer so we can try auto-bridging. - env(offer_cancel(becky, beckyBuxUsdSeq)); + env(offerCancel(becky, beckyBuxUsdSeq)); env.close(); - BEAST_EXPECT(!isOffer(env, becky, BUX(3), USD(3))); + BEAST_EXPECT(!isOffer(env, becky, bux(3), usd(3))); // alice creates an offer that can be auto-bridged with becky's // remaining offer. - env.trust(BUX(1000), carol); - env(pay(alice, carol, BUX(2))); + env.trust(bux(1000), carol); + env(pay(alice, carol, bux(2))); - env(offer(alice, BUX(2), XRP(2))); + env(offer(alice, bux(2), XRP(2))); env.close(); // carol attempts the auto-bridge. Again, the offer create fails // because the USD issuer is not in the ledger. - env(offer(carol, USD(2), BUX(2)), ter(tecNO_ISSUER)); + env(offer(carol, usd(2), bux(2)), Ter(tecNO_ISSUER)); env.close(); - BEAST_EXPECT(isOffer(env, alice, BUX(2), XRP(2))); - BEAST_EXPECT(isOffer(env, becky, XRP(2), USD(2))); + BEAST_EXPECT(isOffer(env, alice, bux(2), XRP(2))); + BEAST_EXPECT(isOffer(env, becky, XRP(2), usd(2))); } void @@ -4579,26 +4580,26 @@ public: env.close(); auto txn = noop(gw); - txn[sfTickSize.fieldName] = Quality::minTickSize - 1; - env(txn, ter(temBAD_TICK_SIZE)); + txn[sfTickSize.fieldName] = Quality::kMIN_TICK_SIZE - 1; + env(txn, Ter(temBAD_TICK_SIZE)); - txn[sfTickSize.fieldName] = Quality::minTickSize; + txn[sfTickSize.fieldName] = Quality::kMIN_TICK_SIZE; env(txn); - BEAST_EXPECT((*env.le(gw))[sfTickSize] == Quality::minTickSize); + BEAST_EXPECT((*env.le(gw))[sfTickSize] == Quality::kMIN_TICK_SIZE); txn = noop(gw); - txn[sfTickSize.fieldName] = Quality::maxTickSize; + txn[sfTickSize.fieldName] = Quality::kMAX_TICK_SIZE; env(txn); BEAST_EXPECT(!env.le(gw)->isFieldPresent(sfTickSize)); txn = noop(gw); - txn[sfTickSize.fieldName] = Quality::maxTickSize - 1; + txn[sfTickSize.fieldName] = Quality::kMAX_TICK_SIZE - 1; env(txn); - BEAST_EXPECT((*env.le(gw))[sfTickSize] == Quality::maxTickSize - 1); + BEAST_EXPECT((*env.le(gw))[sfTickSize] == Quality::kMAX_TICK_SIZE - 1); txn = noop(gw); - txn[sfTickSize.fieldName] = Quality::maxTickSize + 1; - env(txn, ter(temBAD_TICK_SIZE)); + txn[sfTickSize.fieldName] = Quality::kMAX_TICK_SIZE + 1; + env(txn, Ter(temBAD_TICK_SIZE)); txn[sfTickSize.fieldName] = 0; env(txn); @@ -4608,8 +4609,8 @@ public: Env env{*this, features}; auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; - auto const XTS = gw["XTS"]; - auto const XXX = gw["XXX"]; + auto const xts = gw["XTS"]; + auto const xxx = gw["XXX"]; env.fund(XRP(10000), gw, alice); env.close(); @@ -4622,16 +4623,16 @@ public: BEAST_EXPECT((*env.le(gw))[sfTickSize] == 5); } - env(trust(alice, XTS(1000))); - env(trust(alice, XXX(1000))); + env(trust(alice, xts(1000))); + env(trust(alice, xxx(1000))); env(pay(gw, alice, alice["XTS"](100))); env(pay(gw, alice, alice["XXX"](100))); - env(offer(alice, XTS(10), XXX(30))); - env(offer(alice, XTS(30), XXX(10))); - env(offer(alice, XTS(10), XXX(30)), json(jss::Flags, tfSell)); - env(offer(alice, XTS(30), XXX(10)), json(jss::Flags, tfSell)); + env(offer(alice, xts(10), xxx(30))); + env(offer(alice, xts(30), xxx(10))); + env(offer(alice, xts(10), xxx(30)), Json(jss::Flags, tfSell)); + env(offer(alice, xts(30), xxx(10)), Json(jss::Flags, tfSell)); std::map> offers; forEachItem(*env.current(), alice, [&](std::shared_ptr const& sle) { @@ -4646,24 +4647,24 @@ public: auto it = offers.begin(); BEAST_EXPECT(it != offers.end()); BEAST_EXPECT( - it->second.first == XTS(10) && it->second.second < XXX(30) && - it->second.second > XXX(29.9994)); + it->second.first == xts(10) && it->second.second < xxx(30) && + it->second.second > xxx(29.9994)); // second offer ++it; BEAST_EXPECT(it != offers.end()); - BEAST_EXPECT(it->second.first == XTS(30) && it->second.second == XXX(10)); + BEAST_EXPECT(it->second.first == xts(30) && it->second.second == xxx(10)); // third offer ++it; BEAST_EXPECT(it != offers.end()); - BEAST_EXPECT(it->second.first == XTS(10.0002) && it->second.second == XXX(30)); + BEAST_EXPECT(it->second.first == xts(10.0002) && it->second.second == xxx(30)); // fourth offer // exact TakerPays is XTS(1/.033333) ++it; BEAST_EXPECT(it != offers.end()); - BEAST_EXPECT(it->second.first == XTS(30) && it->second.second == XXX(10)); + BEAST_EXPECT(it->second.first == xts(30) && it->second.second == xxx(10)); BEAST_EXPECT(++it == offers.end()); } @@ -4698,23 +4699,23 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); - env(trust(alice, USD(1000))); - env(trust(bob, USD(1000))); + env(trust(alice, usd(1000))); + env(trust(bob, usd(1000))); env.close(); - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Create four offers from the same account with identical quality // so they go in the same order book. Each offer goes in a different // ledger so the chronology is clear. - std::uint32_t const offerId_0{env.seq(alice)}; - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerId0{env.seq(alice)}; + env(offer(alice, XRP(50), usd(50))); env.close(); // Create two tickets. @@ -4723,71 +4724,71 @@ public: env.close(); // Create another sequence-based offer. - std::uint32_t const offerId_1{env.seq(alice)}; - BEAST_EXPECT(offerId_1 == offerId_0 + 4); - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerId1{env.seq(alice)}; + BEAST_EXPECT(offerId1 == offerId0 + 4); + env(offer(alice, XRP(50), usd(50))); env.close(); // Create two ticket based offers in reverse order. - std::uint32_t const offerId_2{ticketSeq + 1}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerId_2)); + std::uint32_t const offerId2{ticketSeq + 1}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerId2)); env.close(); // Create the last offer. - std::uint32_t const offerId_3{ticketSeq}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerId_3)); + std::uint32_t const offerId3{ticketSeq}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerId3)); env.close(); // Verify that all of alice's offers are present. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 4); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_0); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId_2); - BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerId_1); - env.require(balance(alice, USD(200))); - env.require(owners(alice, 5)); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId0); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId2); + BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerId1); + env.require(Balance(alice, usd(200))); + env.require(Owners(alice, 5)); } // Cross alice's first offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the first offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 3); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_2); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId2); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerId1); } // Cross alice's second offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the second offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 2); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId_2); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerId2); } // Cross alice's third offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the third offer alice created was consumed. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 1); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId_3); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerId3); } // Cross alice's last offer. - env(offer(bob, USD(50), XRP(50))); + env(offer(bob, usd(50), XRP(50))); env.close(); // Verify that the third offer alice created was consumed. @@ -4795,10 +4796,10 @@ public: auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.empty()); } - env.require(balance(alice, USD(0))); - env.require(owners(alice, 1)); - env.require(balance(bob, USD(200))); - env.require(owners(bob, 1)); + env.require(Balance(alice, usd(0))); + env.require(Owners(alice, 1)); + env.require(Balance(bob, usd(200))); + env.require(Owners(bob, 1)); } void @@ -4813,104 +4814,104 @@ public: Env env{*this, features}; auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice); env.close(); - env(trust(alice, USD(1000))); + env(trust(alice, usd(1000))); env.close(); - env.require(owners(alice, 1), tickets(alice, 0)); + env.require(Owners(alice, 1), tickets(alice, 0)); - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Create the first of four offers using a sequence. - std::uint32_t const offerSeqId_0{env.seq(alice)}; - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerSeqId0{env.seq(alice)}; + env(offer(alice, XRP(50), usd(50))); env.close(); - env.require(owners(alice, 2), tickets(alice, 0)); + env.require(Owners(alice, 2), tickets(alice, 0)); // Create four tickets. std::uint32_t const ticketSeq{env.seq(alice) + 1}; env(ticket::create(alice, 4)); env.close(); - env.require(owners(alice, 6), tickets(alice, 4)); + env.require(Owners(alice, 6), tickets(alice, 4)); // Create the second (also sequence-based) offer. - std::uint32_t const offerSeqId_1{env.seq(alice)}; - BEAST_EXPECT(offerSeqId_1 == offerSeqId_0 + 6); - env(offer(alice, XRP(50), USD(50))); + std::uint32_t const offerSeqId1{env.seq(alice)}; + BEAST_EXPECT(offerSeqId1 == offerSeqId0 + 6); + env(offer(alice, XRP(50), usd(50))); env.close(); // Create the third (ticket-based) offer. - std::uint32_t const offerTixId_0{ticketSeq + 1}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerTixId_0)); + std::uint32_t const offerTixId0{ticketSeq + 1}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerTixId0)); env.close(); // Create the last offer. - std::uint32_t const offerTixId_1{ticketSeq}; - env(offer(alice, XRP(50), USD(50)), ticket::use(offerTixId_1)); + std::uint32_t const offerTixId1{ticketSeq}; + env(offer(alice, XRP(50), usd(50)), ticket::Use(offerTixId1)); env.close(); // Verify that all of alice's offers are present. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 4); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId_0); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerTixId_0); - BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerSeqId_1); - env.require(balance(alice, USD(200))); - env.require(owners(alice, 7)); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId0); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerTixId0); + BEAST_EXPECT(offers[3]->getFieldU32(sfSequence) == offerSeqId1); + env.require(Balance(alice, usd(200))); + env.require(Owners(alice, 7)); } // Use a ticket to cancel an offer created with a sequence. - env(offer_cancel(alice, offerSeqId_0), ticket::use(ticketSeq + 2)); + env(offerCancel(alice, offerSeqId0), ticket::Use(ticketSeq + 2)); env.close(); // Verify that offerSeqId_0 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 3); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId_0); - BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerTixId0); + BEAST_EXPECT(offers[2]->getFieldU32(sfSequence) == offerSeqId1); } // Use a ticket to cancel an offer created with a ticket. - env(offer_cancel(alice, offerTixId_0), ticket::use(ticketSeq + 3)); + env(offerCancel(alice, offerTixId0), ticket::Use(ticketSeq + 3)); env.close(); // Verify that offerTixId_0 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 2); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId_1); - BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerTixId1); + BEAST_EXPECT(offers[1]->getFieldU32(sfSequence) == offerSeqId1); } // All of alice's tickets should now be used up. - env.require(owners(alice, 3), tickets(alice, 0)); + env.require(Owners(alice, 3), tickets(alice, 0)); // Use a sequence to cancel an offer created with a ticket. - env(offer_cancel(alice, offerTixId_1)); + env(offerCancel(alice, offerTixId1)); env.close(); // Verify that offerTixId_1 was canceled. { auto offers = sortedOffersOnAccount(env, alice); BEAST_EXPECT(offers.size() == 1); - BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId_1); + BEAST_EXPECT(offers[0]->getFieldU32(sfSequence) == offerSeqId1); } // Use a sequence to cancel an offer created with a sequence. - env(offer_cancel(alice, offerSeqId_1)); + env(offerCancel(alice, offerSeqId1)); env.close(); // Verify that offerSeqId_1 was canceled. // All of alice's tickets should now be used up. - env.require(owners(alice, 1), tickets(alice, 0), offers(alice, 0)); + env.require(Owners(alice, 1), tickets(alice, 0), offers(alice, 0)); } void @@ -4923,11 +4924,11 @@ public: Env env{*this}; auto const alice = Account("alice"); - auto const USD = alice["USD"]; + auto const usd = alice["USD"]; env.fund(XRP(10000), alice); env.close(); - env(offer(alice, XRP(100000000000), USD(100000000))); + env(offer(alice, XRP(100000000000), usd(100000000))); pass(); } @@ -4940,26 +4941,26 @@ public: Account const issuer("issuer"); Account const maker("maker"); Account const taker("taker"); - auto const USD = issuer["USD"]; - auto const EUR = issuer["EUR"]; + auto const usd = issuer["USD"]; + auto const eur = issuer["EUR"]; env.fund(XRP(1'000), issuer); env.fund(XRP(1'000), maker, taker); env.close(); - env.trust(USD(1'000), maker, taker); - env.trust(EUR(1'000), maker, taker); + env.trust(usd(1'000), maker, taker); + env.trust(eur(1'000), maker, taker); env.close(); - env(pay(issuer, maker, USD(1'000))); - env(pay(issuer, taker, USD(1'000))); - env(pay(issuer, maker, EUR(1'000))); + env(pay(issuer, maker, usd(1'000))); + env(pay(issuer, taker, usd(1'000))); + env(pay(issuer, maker, eur(1'000))); env.close(); - auto makerUSDBalance = env.balance(maker, USD).value(); - auto takerUSDBalance = env.balance(taker, USD).value(); - auto makerEURBalance = env.balance(maker, EUR).value(); - auto takerEURBalance = env.balance(taker, EUR).value(); + auto makerUSDBalance = env.balance(maker, usd).value(); + auto takerUSDBalance = env.balance(taker, usd).value(); + auto makerEURBalance = env.balance(maker, eur).value(); + auto takerEURBalance = env.balance(taker, eur).value(); auto makerXRPBalance = env.balance(maker, XRP).value(); auto takerXRPBalance = env.balance(taker, XRP).value(); @@ -4967,138 +4968,138 @@ public: { TER const err = features[fixFillOrKill] ? TER(tesSUCCESS) : tecKILLED; - env(offer(maker, XRP(100), USD(100))); + env(offer(maker, XRP(100), usd(100))); env.close(); - env(offer(taker, USD(100), XRP(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, usd(100), XRP(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (isTesSuccess(err)) { - makerUSDBalance -= USD(100); - takerUSDBalance += USD(100); + makerUSDBalance -= usd(100); + takerUSDBalance += usd(100); makerXRPBalance += XRP(100).value(); takerXRPBalance -= XRP(100).value(); } BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), XRP(100))); + env(offer(maker, usd(100), XRP(100))); env.close(); - env(offer(taker, XRP(100), USD(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, XRP(100), usd(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (isTesSuccess(err)) { - makerUSDBalance += USD(100); - takerUSDBalance -= USD(100); + makerUSDBalance += usd(100); + takerUSDBalance -= usd(100); makerXRPBalance -= XRP(100).value(); takerXRPBalance += XRP(100).value(); } BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), EUR(100))); + env(offer(maker, usd(100), eur(100))); env.close(); - env(offer(taker, EUR(100), USD(101)), txflags(tfFillOrKill), ter(err)); + env(offer(taker, eur(100), usd(101)), Txflags(tfFillOrKill), Ter(err)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); if (isTesSuccess(err)) { - makerUSDBalance += USD(100); - takerUSDBalance -= USD(100); - makerEURBalance -= EUR(100); - takerEURBalance += EUR(100); + makerUSDBalance += usd(100); + takerUSDBalance -= usd(100); + makerEURBalance -= eur(100); + takerEURBalance += eur(100); } BEAST_EXPECT(expectOffers(env, taker, 0)); } // tfFillOrKill + tfSell, TakerGets must be filled { - env(offer(maker, XRP(101), USD(101))); + env(offer(maker, XRP(101), usd(101))); env.close(); - env(offer(taker, USD(100), XRP(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, usd(100), XRP(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance -= USD(101); - takerUSDBalance += USD(101); - makerXRPBalance += XRP(101).value() - txfee(env, 1); - takerXRPBalance -= XRP(101).value() + txfee(env, 1); + makerUSDBalance -= usd(101); + takerUSDBalance += usd(101); + makerXRPBalance += XRP(101).value() - txFee(env, 1); + takerXRPBalance -= XRP(101).value() + txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(101), XRP(101))); + env(offer(maker, usd(101), XRP(101))); env.close(); - env(offer(taker, XRP(100), USD(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, XRP(100), usd(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance += USD(101); - takerUSDBalance -= USD(101); - makerXRPBalance -= XRP(101).value() + txfee(env, 1); - takerXRPBalance += XRP(101).value() - txfee(env, 1); + makerUSDBalance += usd(101); + takerUSDBalance -= usd(101); + makerXRPBalance -= XRP(101).value() + txFee(env, 1); + takerXRPBalance += XRP(101).value() - txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(101), EUR(101))); + env(offer(maker, usd(101), eur(101))); env.close(); - env(offer(taker, EUR(100), USD(101)), txflags(tfFillOrKill | tfSell)); + env(offer(taker, eur(100), usd(101)), Txflags(tfFillOrKill | tfSell)); env.close(); - makerUSDBalance += USD(101); - takerUSDBalance -= USD(101); - makerEURBalance -= EUR(101); - takerEURBalance += EUR(101); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerUSDBalance += usd(101); + takerUSDBalance -= usd(101); + makerEURBalance -= eur(101); + takerEURBalance += eur(101); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); } // Fail regardless of fixFillOrKill amendment for (auto const flags : {tfFillOrKill, tfFillOrKill + tfSell}) { - env(offer(maker, XRP(100), USD(100))); + env(offer(maker, XRP(100), usd(100))); env.close(); - env(offer(taker, USD(100), XRP(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, usd(100), XRP(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), XRP(100))); + env(offer(maker, usd(100), XRP(100))); env.close(); - env(offer(taker, XRP(100), USD(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, XRP(100), usd(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); - env(offer(maker, USD(100), EUR(100))); + env(offer(maker, usd(100), eur(100))); env.close(); - env(offer(taker, EUR(100), USD(99)), txflags(flags), ter(tecKILLED)); + env(offer(taker, eur(100), usd(99)), Txflags(flags), Ter(tecKILLED)); env.close(); - makerXRPBalance -= txfee(env, 1); - takerXRPBalance -= txfee(env, 1); + makerXRPBalance -= txFee(env, 1); + takerXRPBalance -= txFee(env, 1); BEAST_EXPECT(expectOffers(env, taker, 0)); } BEAST_EXPECT( - env.balance(maker, USD) == makerUSDBalance && - env.balance(taker, USD) == takerUSDBalance && - env.balance(maker, EUR) == makerEURBalance && - env.balance(taker, EUR) == takerEURBalance && + env.balance(maker, usd) == makerUSDBalance && + env.balance(taker, usd) == takerUSDBalance && + env.balance(maker, eur) == makerEURBalance && + env.balance(taker, eur) == takerEURBalance && env.balance(maker, XRP) == makerXRPBalance && env.balance(taker, XRP) == takerXRPBalance); } @@ -5167,7 +5168,7 @@ public: testFillOrKill(features); } - FeatureBitset const allFeatures{jtx::testable_amendments()}; + FeatureBitset const allFeatures{jtx::testableAmendments()}; void run() override @@ -5201,7 +5202,7 @@ class Offer_manual_test : public OfferBaseUtil_test run() override { using namespace jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; FeatureBitset const fillOrKill{fixFillOrKill}; FeatureBitset const permDEX{featurePermissionedDEX}; diff --git a/src/test/app/Oracle_test.cpp b/src/test/app/Oracle_test.cpp index 43d4a13e2b..84ef568d52 100644 --- a/src/test/app/Oracle_test.cpp +++ b/src/test/app/Oracle_test.cpp @@ -33,7 +33,7 @@ namespace xrpl::test::jtx::oracle { -struct Oracle_test : public beast::unit_test::suite +struct Oracle_test : public beast::unit_test::Suite { private: void @@ -52,9 +52,9 @@ private: Oracle const oracle( env, {.owner = bad, - .seq = seq(1), + .seq = Seq(1), .fee = static_cast(env.current()->fees().base.drops()), - .err = ter(terNO_ACCOUNT)}); + .err = Ter(terNO_ACCOUNT)}); } // Insufficient reserve @@ -65,7 +65,7 @@ private: env, {.owner = owner, .fee = static_cast(env.current()->fees().base.drops()), - .err = ter(tecINSUFFICIENT_RESERVE)}); + .err = Ter(tecINSUFFICIENT_RESERVE)}); } // Insufficient reserve if the data series extends to greater than 5 { @@ -86,7 +86,7 @@ private: {"XRP", "AUD", 740, 1}, }, .fee = static_cast(env.current()->fees().base.drops()), - .err = ter(tecINSUFFICIENT_RESERVE)}); + .err = Ter(tecINSUFFICIENT_RESERVE)}); } { @@ -97,34 +97,34 @@ private: // Invalid flag oracle.set( - CreateArg{.flags = tfSellNFToken, .fee = baseFee, .err = ter(temINVALID_FLAG)}); + CreateArg{.flags = tfSellNFToken, .fee = baseFee, .err = Ter(temINVALID_FLAG)}); // Duplicate token pair oracle.set( CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", 750, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Price is not included oracle.set( CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Token pair is in update and delete oracle.set( CreateArg{ .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", std::nullopt, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Token pair is in add and delete oracle.set( CreateArg{ .series = {{"XRP", "EUR", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Array of token pair is 0 or exceeds 10 oracle.set( @@ -142,8 +142,8 @@ private: {"XRP", "U10", 750, 1}, {"XRP", "U11", 740, 1}}, .fee = baseFee, - .err = ter(temARRAY_TOO_LARGE)}); - oracle.set(CreateArg{.series = {}, .fee = baseFee, .err = ter(temARRAY_EMPTY)}); + .err = Ter(temARRAY_TOO_LARGE)}); + oracle.set(CreateArg{.series = {}, .fee = baseFee, .err = Ter(temARRAY_EMPTY)}); } // Array of token pair exceeds 10 after update @@ -171,7 +171,7 @@ private: {"XRP", "U10", 750, 1}, }, .fee = baseFee, - .err = ter(tecARRAY_TOO_LARGE)}); + .err = Ter(tecARRAY_TOO_LARGE)}); } { @@ -186,14 +186,14 @@ private: .assetClass = std::nullopt, .provider = "provider", .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); oracle.set( CreateArg{ .assetClass = "currency", .provider = std::nullopt, .uri = "URI", .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Asset class or provider are included on update // and don't match the current values @@ -204,13 +204,13 @@ private: .series = {{"XRP", "USD", 740, 1}}, .provider = "provider1", .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .assetClass = "currency1", .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); } { @@ -223,19 +223,19 @@ private: // Asset class std::string assetClass(17, '0'); oracle.set( - CreateArg{.assetClass = assetClass, .fee = baseFee, .err = ter(temMALFORMED)}); + CreateArg{.assetClass = assetClass, .fee = baseFee, .err = Ter(temMALFORMED)}); // provider std::string const large(257, '0'); - oracle.set(CreateArg{.provider = large, .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{.provider = large, .fee = baseFee, .err = Ter(temMALFORMED)}); // URI - oracle.set(CreateArg{.uri = large, .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{.uri = large, .fee = baseFee, .err = Ter(temMALFORMED)}); // Empty field // Asset class - oracle.set(CreateArg{.assetClass = "", .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{.assetClass = "", .fee = baseFee, .err = Ter(temMALFORMED)}); // provider - oracle.set(CreateArg{.provider = "", .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{.provider = "", .fee = baseFee, .err = Ter(temMALFORMED)}); // URI - oracle.set(CreateArg{.uri = "", .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set(CreateArg{.uri = "", .fee = baseFee, .err = Ter(temMALFORMED)}); } { @@ -253,7 +253,7 @@ private: .owner = some, .series = {{"XRP", "USD", 740, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); } { @@ -276,31 +276,31 @@ private: .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(closeTime() - 301), .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + .err = Ter(tecINVALID_UPDATE_TIME)}); // Greater than last close time + 300s oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(closeTime() + 311), .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + .err = Ter(tecINVALID_UPDATE_TIME)}); oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 1}}, .fee = baseFee}); BEAST_EXPECT(oracle.expectLastUpdateTime( - static_cast(testStartTime.count() + 450))); + static_cast(kTEST_START_TIME.count() + 450))); // Less than the previous lastUpdateTime oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, .lastUpdateTime = static_cast(449), .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + .err = Ter(tecINVALID_UPDATE_TIME)}); // Less than the epoch time oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = static_cast(epoch_offset.count() - 1), + .lastUpdateTime = static_cast(kEPOCH_OFFSET.count() - 1), .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + .err = Ter(tecINVALID_UPDATE_TIME)}); } { @@ -314,13 +314,13 @@ private: UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, .fee = baseFee, - .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); + .err = Ter(tecTOKEN_PAIR_NOT_FOUND)}); // delete all token pairs oracle.set( UpdateArg{ .series = {{"XRP", "USD", std::nullopt, std::nullopt}}, .fee = baseFee, - .err = ter(tecARRAY_EMPTY)}); + .err = Ter(tecARRAY_EMPTY)}); } { @@ -333,7 +333,7 @@ private: {.owner = owner, .series = {{"USD", "USD", 740, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); } { @@ -344,9 +344,9 @@ private: Oracle const oracle( env, {.owner = owner, - .series = {{"USD", "BTC", 740, maxPriceScale + 1}}, + .series = {{"USD", "BTC", 740, kMAX_PRICE_SCALE + 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); } { @@ -359,30 +359,30 @@ private: UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}, {"XRP", "EUR", 740, 1}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); // Delete token pair that doesn't exist in this oracle oracle.set( UpdateArg{ .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, .fee = baseFee, - .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); + .err = Ter(tecTOKEN_PAIR_NOT_FOUND)}); // Delete token pair in oracle, which is not in the ledger oracle.set( UpdateArg{ .documentID = 10, .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, .fee = baseFee, - .err = ter(temMALFORMED)}); + .err = Ter(temMALFORMED)}); } { // Bad fee Env env(*this); env.fund(XRP(1'000), owner); - Oracle oracle(env, {.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); + Oracle oracle(env, {.owner = owner, .fee = -1, .err = Ter(temBAD_FEE)}); Oracle const oracle1( env, {.owner = owner, .fee = static_cast(env.current()->fees().base.drops())}); - oracle.set(UpdateArg{.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); + oracle.set(UpdateArg{.owner = owner, .fee = -1, .err = Ter(temBAD_FEE)}); } } @@ -465,22 +465,22 @@ private: // Invalid account Account const bad("bad"); env.memoize(bad); - oracle.remove({.owner = bad, .seq = seq(1), .fee = baseFee, .err = ter(terNO_ACCOUNT)}); + oracle.remove({.owner = bad, .seq = Seq(1), .fee = baseFee, .err = Ter(terNO_ACCOUNT)}); } // Invalid DocumentID - oracle.remove({.documentID = 2, .fee = baseFee, .err = ter(tecNO_ENTRY)}); + oracle.remove({.documentID = 2, .fee = baseFee, .err = Ter(tecNO_ENTRY)}); // Invalid owner Account const invalid("invalid"); env.fund(XRP(1'000), invalid); - oracle.remove({.owner = invalid, .fee = baseFee, .err = ter(tecNO_ENTRY)}); + oracle.remove({.owner = invalid, .fee = baseFee, .err = Ter(tecNO_ENTRY)}); // Invalid flags - oracle.remove({.flags = tfSellNFToken, .fee = baseFee, .err = ter(temINVALID_FLAG)}); + oracle.remove({.flags = tfSellNFToken, .fee = baseFee, .err = Ter(temINVALID_FLAG)}); // Bad fee - oracle.remove({.fee = -1, .err = ter(temBAD_FEE)}); + oracle.remove({.fee = -1, .err = Ter(temBAD_FEE)}); } void @@ -547,18 +547,18 @@ private: auto const hash = env.closed()->header().hash; for (int i = 0; i < 256; ++i) env.close(); - env(acctdelete(owner, alice), fee(acctDelFee)); + env(acctdelete(owner, alice), Fee(acctDelFee)); env.close(); BEAST_EXPECT(!oracle.exists()); BEAST_EXPECT(!oracle1.exists()); // can still get the oracles via the ledger index or hash auto verifyLedgerData = [&](auto const& field, auto const& value) { - Json::Value jvParams; + json::Value jvParams; jvParams[field] = value; jvParams[jss::binary] = false; jvParams[jss::type] = jss::oracle; - Json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jrr = env.rpc("json", "ledger_data", to_string(jvParams)); BEAST_EXPECT(jrr[jss::result][jss::state].size() == 2); }; verifyLedgerData(jss::ledger_index, index); @@ -650,7 +650,7 @@ private: // Should be same order as creation Env env( *this, - withFixOrder ? testable_amendments() : testable_amendments() - fixPriceOracleOrder); + withFixOrder ? testableAmendments() : testableAmendments() - fixPriceOracleOrder); auto const baseFee = static_cast(env.current()->fees().base.drops()); auto test = [&](Env& env, DataSeries const& series) { @@ -702,78 +702,78 @@ private: Env env(*this); auto const baseFee = static_cast(env.current()->fees().base.drops()); - Account const alice{"alice", KeyType::secp256k1}; - Account const bogie{"bogie", KeyType::secp256k1}; - Account const ed{"ed", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; - Account const zelda{"zelda", KeyType::secp256k1}; - Account const bob{"bob", KeyType::secp256k1}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const bogie{"bogie", KeyType::Secp256k1}; + Account const ed{"ed", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; + Account const zelda{"zelda", KeyType::Secp256k1}; + Account const bob{"bob", KeyType::Secp256k1}; env.fund(XRP(10'000), alice, becky, zelda, ed, bob); // alice uses a regular key with the master disabled. - Account const alie{"alie", KeyType::secp256k1}; + Account const alie{"alie", KeyType::Secp256k1}; env(regkey(alice, alie)); - env(fset(alice, asfDisableMaster), sig(alice)); + env(fset(alice, asfDisableMaster), Sig(alice)); // Attach signers to alice. - env(signers(alice, 2, {{becky, 1}, {bogie, 1}, {ed, 2}}), sig(alie)); + env(signers(alice, 2, {{becky, 1}, {bogie, 1}, {ed, 2}}), Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // Create // Force close (true) and time advancement because the close time // is no longer 0. Oracle oracle(env, CreateArg{.owner = alice, .fee = baseFee, .close = true}, false); - oracle.set(CreateArg{.msig = msig(becky), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); - oracle.set(CreateArg{.msig = msig(zelda), .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); - oracle.set(CreateArg{.msig = msig(becky, bogie), .fee = baseFee}); + oracle.set(CreateArg{.msig = Msig(becky), .fee = baseFee, .err = Ter(tefBAD_QUORUM)}); + oracle.set(CreateArg{.msig = Msig(zelda), .fee = baseFee, .err = Ter(tefBAD_SIGNATURE)}); + oracle.set(CreateArg{.msig = Msig(becky, bogie), .fee = baseFee}); BEAST_EXPECT(oracle.exists()); // Update oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .msig = msig(becky), + .msig = Msig(becky), .fee = baseFee, - .err = ter(tefBAD_QUORUM)}); + .err = Ter(tefBAD_QUORUM)}); oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .msig = msig(zelda), + .msig = Msig(zelda), .fee = baseFee, - .err = ter(tefBAD_SIGNATURE)}); + .err = Ter(tefBAD_SIGNATURE)}); oracle.set( UpdateArg{ - .series = {{"XRP", "USD", 741, 1}}, .msig = msig(becky, bogie), .fee = baseFee}); + .series = {{"XRP", "USD", 741, 1}}, .msig = Msig(becky, bogie), .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 741, 1}})); // remove the signer list - env(signers(alice, jtx::none), sig(alie)); + env(signers(alice, jtx::kNONE), Sig(alie)); env.close(); - env.require(owners(alice, 1)); + env.require(Owners(alice, 1)); // create new signer list - env(signers(alice, 2, {{zelda, 1}, {bob, 1}, {ed, 2}}), sig(alie)); + env(signers(alice, 2, {{zelda, 1}, {bob, 1}, {ed, 2}}), Sig(alie)); env.close(); // old list fails oracle.set( UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .msig = msig(becky, bogie), + .msig = Msig(becky, bogie), .fee = baseFee, - .err = ter(tefBAD_SIGNATURE)}); + .err = Ter(tefBAD_SIGNATURE)}); // updated list succeeds oracle.set( UpdateArg{ - .series = {{"XRP", "USD", 7412, 2}}, .msig = msig(zelda, bob), .fee = baseFee}); + .series = {{"XRP", "USD", 7412, 2}}, .msig = Msig(zelda, bob), .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 7412, 2}})); oracle.set( - UpdateArg{.series = {{"XRP", "USD", 74245, 3}}, .msig = msig(ed), .fee = baseFee}); + UpdateArg{.series = {{"XRP", "USD", 74245, 3}}, .msig = Msig(ed), .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 74245, 3}})); // Remove - oracle.remove({.msig = msig(bob), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); - oracle.remove({.msig = msig(becky), .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); - oracle.remove({.msig = msig(ed), .fee = baseFee}); + oracle.remove({.msig = Msig(bob), .fee = baseFee, .err = Ter(tefBAD_QUORUM)}); + oracle.remove({.msig = Msig(becky), .fee = baseFee, .err = Ter(tefBAD_SIGNATURE)}); + oracle.remove({.msig = Msig(ed), .fee = baseFee}); BEAST_EXPECT(!oracle.exists()); } @@ -783,19 +783,19 @@ private: testcase("Amendment"); using namespace jtx; - auto const features = testable_amendments() - featurePriceOracle; + auto const features = testableAmendments() - featurePriceOracle; Account const owner("owner"); Env env(*this, features); auto const baseFee = static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); { - Oracle const oracle(env, {.owner = owner, .fee = baseFee, .err = ter(temDISABLED)}); + Oracle const oracle(env, {.owner = owner, .fee = baseFee, .err = Ter(temDISABLED)}); } { Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); - oracle.remove({.fee = baseFee, .err = ter(temDISABLED)}); + oracle.remove({.fee = baseFee, .err = Ter(temDISABLED)}); } } @@ -804,7 +804,7 @@ public: run() override { using namespace jtx; - auto const all = testable_amendments(); + auto const all = testableAmendments(); testInvalidSet(); testInvalidDelete(); testCreate(all); diff --git a/src/test/app/OversizeMeta_test.cpp b/src/test/app/OversizeMeta_test.cpp index 17f4410cf6..729fc57f70 100644 --- a/src/test/app/OversizeMeta_test.cpp +++ b/src/test/app/OversizeMeta_test.cpp @@ -15,7 +15,7 @@ namespace xrpl::test { // Make sure "plump" order books don't have problems -class PlumpBook_test : public beast::unit_test::suite +class PlumpBook_test : public beast::unit_test::Suite { public: static void @@ -35,13 +35,13 @@ public: using namespace jtx; auto const billion = 1000000000ul; Env env(*this); - env.disable_sigs(); + env.disableSigs(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(billion), gw, "alice"); - env.trust(USD(billion), "alice"); - env(pay(gw, "alice", USD(billion))); - createOffers(env, USD, n); + env.trust(usd(billion), "alice"); + env(pay(gw, "alice", usd(billion))); + createOffers(env, usd, n); } void @@ -70,7 +70,7 @@ BEAST_DEFINE_TESTSUITE(ThinBook, app, xrpl); //------------------------------------------------------------------------------ -class OversizeMeta_test : public beast::unit_test::suite +class OversizeMeta_test : public beast::unit_test::Suite { public: static void @@ -91,15 +91,15 @@ public: using namespace jtx; auto const billion = 1000000000ul; Env env(*this); - env.disable_sigs(); + env.disableSigs(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(billion), gw, "alice"); - env.trust(USD(billion), "alice"); - env(pay(gw, "alice", USD(billion))); - createOffers(env, USD, n); - env(pay("alice", gw, USD(billion))); - env(offer("alice", USD(1), XRP(1))); + env.trust(usd(billion), "alice"); + env(pay(gw, "alice", usd(billion))); + createOffers(env, usd, n); + env(pay("alice", gw, usd(billion))); + env(offer("alice", usd(1), XRP(1))); } void @@ -113,7 +113,7 @@ BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(OversizeMeta, app, xrpl, 3); //------------------------------------------------------------------------------ -class FindOversizeCross_test : public beast::unit_test::suite +class FindOversizeCross_test : public beast::unit_test::Suite { public: // Return lowest x in [lo, hi] for which f(x)==true @@ -156,15 +156,15 @@ public: using namespace jtx; auto const billion = 1000000000ul; Env env(*this); - env.disable_sigs(); + env.disableSigs(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(billion), gw, "alice"); - env.trust(USD(billion), "alice"); - env(pay(gw, "alice", USD(billion))); - createOffers(env, USD, n); - env(pay("alice", gw, USD(billion))); - env(offer("alice", USD(1), XRP(1)), ter(std::ignore)); + env.trust(usd(billion), "alice"); + env(pay(gw, "alice", usd(billion))); + createOffers(env, usd, n); + env(pay("alice", gw, usd(billion))); + env(offer("alice", usd(1), XRP(1)), Ter(std::ignore)); return env.ter() == tecOVERSIZE; } diff --git a/src/test/app/PathMPT_test.cpp b/src/test/app/PathMPT_test.cpp index 482d120342..ef8aa587f8 100644 --- a/src/test/app/PathMPT_test.cpp +++ b/src/test/app/PathMPT_test.cpp @@ -42,21 +42,21 @@ namespace xrpl::test { namespace detail { -static Json::Value +static json::Value rpf(jtx::Account const& src, jtx::Account const& dst, - xrpl::test::jtx::MPT const& USD, - std::vector const& num_src) + xrpl::test::jtx::MPT const& usd, + std::vector const& numSrc) { - Json::Value jv = Json::objectValue; + json::Value jv = json::ObjectValue; jv[jss::command] = "ripple_path_find"; jv[jss::source_account] = toBase58(src); - if (!num_src.empty()) + if (!numSrc.empty()) { - auto& sc = (jv[jss::source_currencies] = Json::arrayValue); - Json::Value j = Json::objectValue; - for (auto const& id : num_src) + auto& sc = (jv[jss::source_currencies] = json::ArrayValue); + json::Value j = json::ObjectValue; + for (auto const& id : numSrc) { j[jss::mpt_issuance_id] = to_string(id); sc.append(j); @@ -66,8 +66,8 @@ rpf(jtx::Account const& src, auto const d = toBase58(dst); jv[jss::destination_account] = d; - Json::Value& j = (jv[jss::destination_amount] = Json::objectValue); - j[jss::mpt_issuance_id] = to_string(USD.mpt()); + json::Value& j = (jv[jss::destination_amount] = json::ObjectValue); + j[jss::mpt_issuance_id] = to_string(usd.mpt()); j[jss::value] = "1"; return jv; @@ -77,7 +77,7 @@ rpf(jtx::Account const& src, //------------------------------------------------------------------------------ -class PathMPT_test : public beast::unit_test::suite +class PathMPT_test : public beast::unit_test::Suite { jtx::Env pathTestEnv() @@ -96,7 +96,7 @@ class PathMPT_test : public beast::unit_test::suite public: void - source_currencies_limit() + sourceCurrenciesLimit() { testcase("source currency limits"); using namespace std::chrono_literals; @@ -108,11 +108,11 @@ public: env.fund(XRP(10'000), "alice", "bob", gw); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 100}); auto& app = env.app(); - Resource::Charge loadType = Resource::feeReferenceRPC; + Resource::Charge loadType = Resource::kFEE_REFERENCE_RPC; Resource::Consumer c; RPC::JsonContext context{ @@ -125,66 +125,66 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::apiVersionIfUnspecified}, + .apiVersion = RPC::kAPI_VERSION_IF_UNSPECIFIED}, {}, {}}; - Json::Value result; - gate g; + json::Value result; + Gate g; // Test RPC::Tuning::max_src_cur source currencies. - std::vector num_src; - num_src.reserve(RPC::Tuning::max_src_cur); - for (std::uint8_t i = 0; i < RPC::Tuning::max_src_cur; ++i) - num_src.push_back(makeMptID(i, bob)); - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = xrpl::test::detail::rpf(alice, bob, USD, num_src); + std::vector numSrc; + numSrc.reserve(RPC::Tuning::kMAX_SRC_CUR); + for (std::uint8_t i = 0; i < RPC::Tuning::kMAX_SRC_CUR; ++i) + numSrc.push_back(makeMptID(i, bob)); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = xrpl::test::detail::rpf(alice, bob, usd, numSrc); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); // Test more than RPC::Tuning::max_src_cur source currencies. - num_src.push_back(makeMptID(RPC::Tuning::max_src_cur, bob)); - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = xrpl::test::detail::rpf(alice, bob, USD, num_src); + numSrc.push_back(makeMptID(RPC::Tuning::kMAX_SRC_CUR, bob)); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = xrpl::test::detail::rpf(alice, bob, usd, numSrc); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); // Test RPC::Tuning::max_auto_src_cur source currencies. - num_src.clear(); - for (auto i = 0; i < (RPC::Tuning::max_auto_src_cur - 1); ++i) + numSrc.clear(); + for (auto i = 0; i < (RPC::Tuning::kMAX_AUTO_SRC_CUR - 1); ++i) { - auto CURM = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); - num_src.push_back(CURM.issuanceID()); + auto curm = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); + numSrc.push_back(curm.issuanceID()); } - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = xrpl::test::detail::rpf(alice, bob, USD, {}); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = xrpl::test::detail::rpf(alice, bob, usd, {}); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); // Test more than RPC::Tuning::max_auto_src_cur source currencies. - auto CURM = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = xrpl::test::detail::rpf(alice, bob, USD, {}); + auto curm = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = xrpl::test::detail::rpf(alice, bob, usd, {}); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); } void - no_direct_path_no_intermediary_no_alternatives() + noDirectPathNoIntermediaryNoAlternatives() { testcase("no direct path no intermediary no alternatives"); using namespace jtx; @@ -193,55 +193,55 @@ public: env.fund(XRP(10'000), "alice", "bob"); - auto USDM = MPTTester({.env = env, .issuer = "bob"}); + auto usdm = MPTTester({.env = env, .issuer = "bob"}); - auto const result = find_paths(env, "alice", "bob", USDM(5)); + auto const result = findPaths(env, "alice", "bob", usdm(5)); BEAST_EXPECT(std::get<0>(result).empty()); } void - direct_path_no_intermediary() + directPathNoIntermediary() { testcase("direct path no intermediary"); using namespace jtx; Env env = pathTestEnv(); env.fund(XRP(10'000), "alice", "bob"); - MPT const USD = MPTTester({.env = env, .issuer = "alice", .holders = {"bob"}}); + MPT const usd = MPTTester({.env = env, .issuer = "alice", .holders = {"bob"}}); STPathSet st; STAmount sa; - std::tie(st, sa, std::ignore) = find_paths(env, "alice", "bob", USD(5)); + std::tie(st, sa, std::ignore) = findPaths(env, "alice", "bob", usd(5)); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(sa, USD(5))); + BEAST_EXPECT(equal(sa, usd(5))); } void - payment_auto_path_find() + paymentAutoPathFind() { testcase("payment auto path find"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); env.fund(XRP(10'000), "alice", "bob", gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); - env(pay(gw, "alice", USD(70))); - env(pay("alice", "bob", USD(24))); - env.require(balance("alice", USD(46))); - env.require(balance("bob", USD(24))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); + env(pay(gw, "alice", usd(70))); + env(pay("alice", "bob", usd(24))); + env.require(Balance("alice", usd(46))); + env.require(Balance("bob", usd(24))); } void - path_find(bool const domainEnabled) + pathFind(bool const domainEnabled) { testcase(std::string("path find") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); env.fund(XRP(10'000), "alice", "bob", gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); - env(pay(gw, "alice", USD(70))); - env(pay(gw, "bob", USD(50))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); + env(pay(gw, "alice", usd(70))); + env(pay(gw, "bob", usd(50))); std::optional domainID; if (domainEnabled) @@ -250,17 +250,17 @@ public: STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = find_paths( - env, "alice", "bob", USD(5), std::nullopt, std::nullopt, std::nullopt, domainID); + std::tie(st, sa, da) = findPaths( + env, "alice", "bob", usd(5), std::nullopt, std::nullopt, std::nullopt, domainID); // Note, a direct IOU payment will have "gateway" as alternative path // since IOU supports rippling BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(sa, USD(5))); - BEAST_EXPECT(equal(da, USD(5))); + BEAST_EXPECT(equal(sa, usd(5))); + BEAST_EXPECT(equal(da, usd(5))); } void - path_find_consume_all(bool const domainEnabled) + pathFindConsumeAll(bool const domainEnabled) { testcase( std::string("path find consume all") + (domainEnabled ? " w/ " : " w/o ") + "domain"); @@ -270,39 +270,39 @@ public: Env env = pathTestEnv(); auto const gw = Account("gateway"); env.fund(XRP(10'000), "alice", "bob", "carol", gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {"bob", "carol"}}); - MPT const AUD(makeMptID(0, gw)); - env(pay(gw, "carol", USD(100))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"bob", "carol"}}); + MPT const aud(makeMptID(0, gw)); + env(pay(gw, "carol", usd(100))); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "carol", "gateway"}); - env(offer("carol", XRP(100), USD(100)), domain(*domainID)); + env(offer("carol", XRP(100), usd(100)), Domain(*domainID)); } else { - env(offer("carol", XRP(100), USD(100))); + env(offer("carol", XRP(100), usd(100))); } env.close(); STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", - AUD(-1), + aud(-1), std::optional(XRP(100'000'000)), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(st.empty()); - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", - USD(-1), + usd(-1), std::optional(XRP(100'000'000)), std::nullopt, std::nullopt, @@ -312,16 +312,16 @@ public: auto const& pathElem = st[0][0]; BEAST_EXPECT( pathElem.isOffer() && pathElem.getIssuerID() == gw.id() && - pathElem.getMPTID() == USD.issuanceID); + pathElem.getMPTID() == usd.issuanceID); } BEAST_EXPECT(sa == XRP(100)); - BEAST_EXPECT(equal(da, USD(100))); + BEAST_EXPECT(equal(da, usd(100))); // if domain is used, finding path in the open offerbook will return // empty result if (domainEnabled) { - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", @@ -335,7 +335,7 @@ public: } void - alternative_paths_consume_best_transfer(bool const domainEnabled) + alternativePathsConsumeBestTransfer(bool const domainEnabled) { testcase( std::string("alternative path consume best transfer") + @@ -345,31 +345,31 @@ public: auto const gw = Account("gateway"); auto const gw2 = Account("gateway2"); env.fund(XRP(10'000), "alice", "bob", gw, gw2); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); - MPT const gw2_USD = MPTTester( + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {"alice", "bob"}}); + MPT const gw2Usd = MPTTester( {.env = env, .issuer = gw2, .holders = {"alice", "bob"}, .transferFee = 1'000}); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "gateway", "gateway2"}); - env(pay(gw, "alice", USD(70)), domain(*domainID)); - env(pay(gw2, "alice", gw2_USD(70)), domain(*domainID)); - env(pay("alice", "bob", USD(70)), domain(*domainID)); + env(pay(gw, "alice", usd(70)), Domain(*domainID)); + env(pay(gw2, "alice", gw2Usd(70)), Domain(*domainID)); + env(pay("alice", "bob", usd(70)), Domain(*domainID)); } else { - env(pay(gw, "alice", USD(70))); - env(pay(gw2, "alice", gw2_USD(70))); - env(pay("alice", "bob", USD(70))); + env(pay(gw, "alice", usd(70))); + env(pay(gw2, "alice", gw2Usd(70))); + env(pay("alice", "bob", usd(70))); } - env.require(balance("alice", USD(0))); - env.require(balance("alice", gw2_USD(70))); - env.require(balance("bob", USD(70))); - env.require(balance("bob", gw2_USD(0))); + env.require(Balance("alice", usd(0))); + env.require(Balance("alice", gw2Usd(70))); + env.require(Balance("bob", usd(70))); + env.require(Balance("bob", gw2Usd(0))); } void - receive_max(bool const domainEnabled) + receiveMax(bool const domainEnabled) { testcase(std::string("Receive max") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; @@ -382,30 +382,30 @@ public: Env env = pathTestEnv(); env.fund(XRP(10'000), alice, bob, charlie, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, charlie}}); - env(pay(gw, charlie, USD(10))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, charlie}}); + env(pay(gw, charlie, usd(10))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {alice, bob, charlie, gw}); - env(offer(charlie, XRP(10), USD(10)), domain(*domainID)); + env(offer(charlie, XRP(10), usd(10)), Domain(*domainID)); } else { - env(offer(charlie, XRP(10), USD(10))); + env(offer(charlie, XRP(10), usd(10))); } env.close(); - auto [st, sa, da] = find_paths( - env, alice, bob, USD(-1), XRP(100).value(), std::nullopt, std::nullopt, domainID); + auto [st, sa, da] = findPaths( + env, alice, bob, usd(-1), XRP(100).value(), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(sa == XRP(10)); - BEAST_EXPECT(equal(da, USD(10))); + BEAST_EXPECT(equal(da, usd(10))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { auto const& pathElem = st[0][0]; BEAST_EXPECT( pathElem.isOffer() && pathElem.getIssuerID() == gw.id() && - pathElem.getMPTID() == USD.mpt()); + pathElem.getMPTID() == usd.mpt()); } } { @@ -413,23 +413,23 @@ public: Env env = pathTestEnv(); env.fund(XRP(10'000), alice, bob, charlie, gw); env.close(); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, charlie}}); - env(pay(gw, alice, USD(10))); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob, charlie}}); + env(pay(gw, alice, usd(10))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {alice, bob, charlie, gw}); - env(offer(charlie, USD(10), XRP(10)), domain(*domainID)); + env(offer(charlie, usd(10), XRP(10)), Domain(*domainID)); } else { - env(offer(charlie, USD(10), XRP(10))); + env(offer(charlie, usd(10), XRP(10))); } env.close(); - auto [st, sa, da] = find_paths( - env, alice, bob, drops(-1), USD(100).value(), std::nullopt, std::nullopt, domainID); - BEAST_EXPECT(sa == USD(10)); + auto [st, sa, da] = findPaths( + env, alice, bob, drops(-1), usd(100).value(), std::nullopt, std::nullopt, domainID); + BEAST_EXPECT(sa == usd(10)); BEAST_EXPECT(equal(da, XRP(10))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { @@ -444,16 +444,16 @@ public: void run() override { - source_currencies_limit(); - no_direct_path_no_intermediary_no_alternatives(); - direct_path_no_intermediary(); - payment_auto_path_find(); + sourceCurrenciesLimit(); + noDirectPathNoIntermediaryNoAlternatives(); + directPathNoIntermediary(); + paymentAutoPathFind(); for (auto const domainEnabled : {false, true}) { - path_find(domainEnabled); - path_find_consume_all(domainEnabled); - alternative_paths_consume_best_transfer(domainEnabled); - receive_max(domainEnabled); + pathFind(domainEnabled); + pathFindConsumeAll(domainEnabled); + alternativePathsConsumeBestTransfer(domainEnabled); + receiveMax(domainEnabled); } } }; diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index e6d27de415..9424bc05bf 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -60,20 +60,20 @@ namespace xrpl::test { //------------------------------------------------------------------------------ -Json::Value -rpf(jtx::Account const& src, jtx::Account const& dst, std::uint32_t num_src) +json::Value +rpf(jtx::Account const& src, jtx::Account const& dst, std::uint32_t numSrc) { - Json::Value jv = Json::objectValue; + json::Value jv = json::ObjectValue; jv[jss::command] = "ripple_path_find"; jv[jss::source_account] = toBase58(src); - if (num_src > 0) + if (numSrc > 0) { - auto& sc = (jv[jss::source_currencies] = Json::arrayValue); - Json::Value j = Json::objectValue; - while ((num_src--) != 0u) + auto& sc = (jv[jss::source_currencies] = json::ArrayValue); + json::Value j = json::ObjectValue; + while ((numSrc--) != 0u) { - j[jss::currency] = std::to_string(num_src + 100); + j[jss::currency] = std::to_string(numSrc + 100); sc.append(j); } } @@ -81,7 +81,7 @@ rpf(jtx::Account const& src, jtx::Account const& dst, std::uint32_t num_src) auto const d = toBase58(dst); jv[jss::destination_account] = d; - Json::Value& j = (jv[jss::destination_amount] = Json::objectValue); + json::Value& j = (jv[jss::destination_amount] = json::ObjectValue); j[jss::currency] = "USD"; j[jss::value] = "0.01"; j[jss::issuer] = d; @@ -91,7 +91,7 @@ rpf(jtx::Account const& src, jtx::Account const& dst, std::uint32_t num_src) //------------------------------------------------------------------------------ -class Path_test : public beast::unit_test::suite +class Path_test : public beast::unit_test::Suite { jtx::Env pathTestEnv() @@ -109,7 +109,7 @@ class Path_test : public beast::unit_test::suite } public: - class gate + class Gate { private: std::condition_variable cv_; @@ -121,10 +121,10 @@ public: // Returns `true` if signaled. template bool - wait_for(std::chrono::duration const& rel_time) + waitFor(std::chrono::duration const& relTime) { std::unique_lock lk(mutex_); - auto b = cv_.wait_for(lk, rel_time, [this] { return signaled_; }); + auto b = cv_.wait_for(lk, relTime, [this] { return signaled_; }); signaled_ = false; return b; } @@ -139,7 +139,7 @@ public: }; auto - find_paths_request( + findPathsRequest( jtx::Env& env, jtx::Account const& src, jtx::Account const& dst, @@ -151,7 +151,7 @@ public: using namespace jtx; auto& app = env.app(); - Resource::Charge loadType = Resource::feeReferenceRPC; + Resource::Charge loadType = Resource::kFEE_REFERENCE_RPC; Resource::Consumer c; RPC::JsonContext context{ @@ -164,30 +164,30 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::apiVersionIfUnspecified}, + .apiVersion = RPC::kAPI_VERSION_IF_UNSPECIFIED}, {}, {}}; - Json::Value params = Json::objectValue; + json::Value params = json::ObjectValue; params[jss::command] = "ripple_path_find"; params[jss::source_account] = toBase58(src); params[jss::destination_account] = toBase58(dst); - params[jss::destination_amount] = saDstAmount.getJson(JsonOptions::none); + params[jss::destination_amount] = saDstAmount.getJson(JsonOptions::KNone); if (saSendMax) - params[jss::send_max] = saSendMax->getJson(JsonOptions::none); + params[jss::send_max] = saSendMax->getJson(JsonOptions::KNone); if (saSrcCurrency) { - auto& sc = params[jss::source_currencies] = Json::arrayValue; - Json::Value j = Json::objectValue; + auto& sc = params[jss::source_currencies] = json::ArrayValue; + json::Value j = json::ObjectValue; j[jss::currency] = to_string(saSrcCurrency.value()); sc.append(j); } if (domain) params[jss::domain] = to_string(*domain); - Json::Value result; - gate g; - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { + json::Value result; + Gate g; + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = std::move(params); context.coro = coro; RPC::doCommand(context, result); @@ -195,13 +195,13 @@ public: }); using namespace std::chrono_literals; - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); return result; } std::tuple - find_paths( + findPaths( jtx::Env& env, jtx::Account const& src, jtx::Account const& dst, @@ -210,13 +210,13 @@ public: std::optional const& saSrcCurrency = std::nullopt, std::optional const& domain = std::nullopt) { - Json::Value result = - find_paths_request(env, src, dst, saDstAmount, saSendMax, saSrcCurrency, domain); + json::Value result = + findPathsRequest(env, src, dst, saDstAmount, saSendMax, saSrcCurrency, domain); BEAST_EXPECT(!result.isMember(jss::error)); STAmount da; if (result.isMember(jss::destination_amount)) - da = amountFromJson(sfGeneric, result[jss::destination_amount]); + da = amountFromJson(kSF_GENERIC, result[jss::destination_amount]); STAmount sa; STPathSet paths; @@ -228,14 +228,14 @@ public: auto const& path = alts[0u]; if (path.isMember(jss::source_amount)) - sa = amountFromJson(sfGeneric, path[jss::source_amount]); + sa = amountFromJson(kSF_GENERIC, path[jss::source_amount]); if (path.isMember(jss::destination_amount)) - da = amountFromJson(sfGeneric, path[jss::destination_amount]); + da = amountFromJson(kSF_GENERIC, path[jss::destination_amount]); if (path.isMember(jss::paths_computed)) { - Json::Value p; + json::Value p; p["Paths"] = path[jss::paths_computed]; STParsedJSONObject po("generic", p); @@ -249,7 +249,7 @@ public: } void - source_currencies_limit() + sourceCurrenciesLimit() { testcase("source currency limits"); using namespace std::chrono_literals; @@ -262,7 +262,7 @@ public: env.close(); auto& app = env.app(); - Resource::Charge loadType = Resource::feeReferenceRPC; + Resource::Charge loadType = Resource::kFEE_REFERENCE_RPC; Resource::Consumer c; RPC::JsonContext context{ @@ -275,57 +275,57 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::apiVersionIfUnspecified}, + .apiVersion = RPC::kAPI_VERSION_IF_UNSPECIFIED}, {}, {}}; - Json::Value result; - gate g; + json::Value result; + Gate g; // Test RPC::Tuning::max_src_cur source currencies. - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::max_src_cur); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::kMAX_SRC_CUR); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); // Test more than RPC::Tuning::max_src_cur source currencies. - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { - context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::max_src_cur + 1); + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { + context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::kMAX_SRC_CUR + 1); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); // Test RPC::Tuning::max_auto_src_cur source currencies. - for (auto i = 0; i < (RPC::Tuning::max_auto_src_cur - 1); ++i) + for (auto i = 0; i < (RPC::Tuning::kMAX_AUTO_SRC_CUR - 1); ++i) env.trust(Account("alice")[std::to_string(i + 100)](100), "bob"); - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = rpf(Account("alice"), Account("bob"), 0); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); // Test more than RPC::Tuning::max_auto_src_cur source currencies. env.trust(Account("alice")["AUD"](100), "bob"); - app.getJobQueue().postCoro(jtCLIENT, "RPC-Client", [&](auto const& coro) { + app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = rpf(Account("alice"), Account("bob"), 0); context.coro = coro; RPC::doCommand(context, result); g.signal(); }); - BEAST_EXPECT(g.wait_for(5s)); + BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); } void - no_direct_path_no_intermediary_no_alternatives() + noDirectPathNoIntermediaryNoAlternatives() { testcase("no direct path no intermediary no alternatives"); using namespace jtx; @@ -333,12 +333,12 @@ public: env.fund(XRP(10000), "alice", "bob"); env.close(); - auto const result = find_paths(env, "alice", "bob", Account("bob")["USD"](5)); + auto const result = findPaths(env, "alice", "bob", Account("bob")["USD"](5)); BEAST_EXPECT(std::get<0>(result).empty()); } void - direct_path_no_intermediary() + directPathNoIntermediary() { testcase("direct path no intermediary"); using namespace jtx; @@ -349,45 +349,45 @@ public: STPathSet st; STAmount sa; - std::tie(st, sa, std::ignore) = find_paths(env, "alice", "bob", Account("bob")["USD"](5)); + std::tie(st, sa, std::ignore) = findPaths(env, "alice", "bob", Account("bob")["USD"](5)); BEAST_EXPECT(st.empty()); BEAST_EXPECT(equal(sa, Account("alice")["USD"](5))); } void - payment_auto_path_find() + paymentAutoPathFind() { testcase("payment auto path find"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), "alice", "bob", gw); env.close(); - env.trust(USD(600), "alice"); - env.trust(USD(700), "bob"); - env(pay(gw, "alice", USD(70))); - env(pay("alice", "bob", USD(24))); - env.require(balance("alice", USD(46))); - env.require(balance(gw, Account("alice")["USD"](-46))); - env.require(balance("bob", USD(24))); - env.require(balance(gw, Account("bob")["USD"](-24))); + env.trust(usd(600), "alice"); + env.trust(usd(700), "bob"); + env(pay(gw, "alice", usd(70))); + env(pay("alice", "bob", usd(24))); + env.require(Balance("alice", usd(46))); + env.require(Balance(gw, Account("alice")["USD"](-46))); + env.require(Balance("bob", usd(24))); + env.require(Balance(gw, Account("bob")["USD"](-24))); } void - path_find(bool const domainEnabled) + pathFind(bool const domainEnabled) { testcase(std::string("path find") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), "alice", "bob", gw); env.close(); - env.trust(USD(600), "alice"); - env.trust(USD(700), "bob"); - env(pay(gw, "alice", USD(70))); - env(pay(gw, "bob", USD(50))); + env.trust(usd(600), "alice"); + env.trust(usd(700), "bob"); + env(pay(gw, "alice", usd(70))); + env(pay(gw, "bob", usd(50))); std::optional domainID; if (domainEnabled) @@ -395,14 +395,14 @@ public: STPathSet st; STAmount sa; - std::tie(st, sa, std::ignore) = find_paths( + std::tie(st, sa, std::ignore) = findPaths( env, "alice", "bob", Account("bob")["USD"](5), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(same(st, stpath("gateway"))); BEAST_EXPECT(equal(sa, Account("alice")["USD"](5))); } void - xrp_to_xrp(bool const domainEnabled) + xrpToXrp(bool const domainEnabled) { using namespace jtx; testcase(std::string("XRP to XRP") + (domainEnabled ? " w/ " : " w/o ") + "domain"); @@ -415,12 +415,12 @@ public: domainID = setupDomain(env, {"alice", "bob"}); auto const result = - find_paths(env, "alice", "bob", XRP(5), std::nullopt, std::nullopt, domainID); + findPaths(env, "alice", "bob", XRP(5), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(std::get<0>(result).empty()); } void - path_find_consume_all(bool const domainEnabled) + pathFindConsumeAll(bool const domainEnabled) { testcase( std::string("path find consume all") + (domainEnabled ? " w/ " : " w/o ") + "domain"); @@ -443,7 +443,7 @@ public: STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "edward", @@ -459,30 +459,30 @@ public: { Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), "alice", "bob", "carol", gw); env.close(); - env.trust(USD(100), "bob", "carol"); + env.trust(usd(100), "bob", "carol"); env.close(); - env(pay(gw, "carol", USD(100))); + env(pay(gw, "carol", usd(100))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "carol", "gateway"}); - env(offer("carol", XRP(100), USD(100)), domain(*domainID)); + env(offer("carol", XRP(100), usd(100)), Domain(*domainID)); } else { - env(offer("carol", XRP(100), USD(100))); + env(offer("carol", XRP(100), usd(100))); } env.close(); STPathSet st; STAmount sa; STAmount da; - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", @@ -491,7 +491,7 @@ public: std::nullopt, domainID); BEAST_EXPECT(st.empty()); - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", @@ -506,7 +506,7 @@ public: // empty result if (domainEnabled) { - std::tie(st, sa, da) = find_paths( + std::tie(st, sa, da) = findPaths( env, "alice", "bob", @@ -520,7 +520,7 @@ public: } void - alternative_path_consume_both(bool const domainEnabled) + alternativePathConsumeBoth(bool const domainEnabled) { testcase( std::string("alternative path consume both") + (domainEnabled ? " w/ " : " w/o ") + @@ -528,45 +528,45 @@ public: using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const gw2 = Account("gateway2"); - auto const gw2_USD = gw2["USD"]; + auto const gw2Usd = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); env.close(); - env.trust(USD(600), "alice"); - env.trust(gw2_USD(800), "alice"); - env.trust(USD(700), "bob"); - env.trust(gw2_USD(900), "bob"); + env.trust(usd(600), "alice"); + env.trust(gw2Usd(800), "alice"); + env.trust(usd(700), "bob"); + env.trust(gw2Usd(900), "bob"); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "gateway", "gateway2"}); - env(pay(gw, "alice", USD(70)), domain(*domainID)); - env(pay(gw2, "alice", gw2_USD(70)), domain(*domainID)); + env(pay(gw, "alice", usd(70)), Domain(*domainID)); + env(pay(gw2, "alice", gw2Usd(70)), Domain(*domainID)); env(pay("alice", "bob", Account("bob")["USD"](140)), - paths(Account("alice")["USD"]), - domain(*domainID)); + Paths(Account("alice")["USD"]), + Domain(*domainID)); } else { - env(pay(gw, "alice", USD(70))); - env(pay(gw2, "alice", gw2_USD(70))); - env(pay("alice", "bob", Account("bob")["USD"](140)), paths(Account("alice")["USD"])); + env(pay(gw, "alice", usd(70))); + env(pay(gw2, "alice", gw2Usd(70))); + env(pay("alice", "bob", Account("bob")["USD"](140)), Paths(Account("alice")["USD"])); } - env.require(balance("alice", USD(0))); - env.require(balance("alice", gw2_USD(0))); - env.require(balance("bob", USD(70))); - env.require(balance("bob", gw2_USD(70))); - env.require(balance(gw, Account("alice")["USD"](0))); - env.require(balance(gw, Account("bob")["USD"](-70))); - env.require(balance(gw2, Account("alice")["USD"](0))); - env.require(balance(gw2, Account("bob")["USD"](-70))); + env.require(Balance("alice", usd(0))); + env.require(Balance("alice", gw2Usd(0))); + env.require(Balance("bob", usd(70))); + env.require(Balance("bob", gw2Usd(70))); + env.require(Balance(gw, Account("alice")["USD"](0))); + env.require(Balance(gw, Account("bob")["USD"](-70))); + env.require(Balance(gw2, Account("alice")["USD"](0))); + env.require(Balance(gw2, Account("bob")["USD"](-70))); } void - alternative_paths_consume_best_transfer(bool const domainEnabled) + alternativePathsConsumeBestTransfer(bool const domainEnabled) { testcase( std::string("alternative paths consume best transfer") + @@ -574,75 +574,75 @@ public: using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const gw2 = Account("gateway2"); - auto const gw2_USD = gw2["USD"]; + auto const gw2Usd = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); env.close(); env(rate(gw2, 1.1)); - env.trust(USD(600), "alice"); - env.trust(gw2_USD(800), "alice"); - env.trust(USD(700), "bob"); - env.trust(gw2_USD(900), "bob"); + env.trust(usd(600), "alice"); + env.trust(gw2Usd(800), "alice"); + env.trust(usd(700), "bob"); + env.trust(gw2Usd(900), "bob"); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "gateway", "gateway2"}); - env(pay(gw, "alice", USD(70)), domain(*domainID)); - env(pay(gw2, "alice", gw2_USD(70)), domain(*domainID)); - env(pay("alice", "bob", USD(70)), domain(*domainID)); + env(pay(gw, "alice", usd(70)), Domain(*domainID)); + env(pay(gw2, "alice", gw2Usd(70)), Domain(*domainID)); + env(pay("alice", "bob", usd(70)), Domain(*domainID)); } else { - env(pay(gw, "alice", USD(70))); - env(pay(gw2, "alice", gw2_USD(70))); - env(pay("alice", "bob", USD(70))); + env(pay(gw, "alice", usd(70))); + env(pay(gw2, "alice", gw2Usd(70))); + env(pay("alice", "bob", usd(70))); } - env.require(balance("alice", USD(0))); - env.require(balance("alice", gw2_USD(70))); - env.require(balance("bob", USD(70))); - env.require(balance("bob", gw2_USD(0))); - env.require(balance(gw, Account("alice")["USD"](0))); - env.require(balance(gw, Account("bob")["USD"](-70))); - env.require(balance(gw2, Account("alice")["USD"](-70))); - env.require(balance(gw2, Account("bob")["USD"](0))); + env.require(Balance("alice", usd(0))); + env.require(Balance("alice", gw2Usd(70))); + env.require(Balance("bob", usd(70))); + env.require(Balance("bob", gw2Usd(0))); + env.require(Balance(gw, Account("alice")["USD"](0))); + env.require(Balance(gw, Account("bob")["USD"](-70))); + env.require(Balance(gw2, Account("alice")["USD"](-70))); + env.require(Balance(gw2, Account("bob")["USD"](0))); } void - alternative_paths_consume_best_transfer_first() + alternativePathsConsumeBestTransferFirst() { testcase("alternative paths - consume best transfer first"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const gw2 = Account("gateway2"); - auto const gw2_USD = gw2["USD"]; + auto const gw2Usd = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", gw, gw2); env.close(); env(rate(gw2, 1.1)); - env.trust(USD(600), "alice"); - env.trust(gw2_USD(800), "alice"); - env.trust(USD(700), "bob"); - env.trust(gw2_USD(900), "bob"); - env(pay(gw, "alice", USD(70))); - env(pay(gw2, "alice", gw2_USD(70))); + env.trust(usd(600), "alice"); + env.trust(gw2Usd(800), "alice"); + env.trust(usd(700), "bob"); + env.trust(gw2Usd(900), "bob"); + env(pay(gw, "alice", usd(70))); + env(pay(gw2, "alice", gw2Usd(70))); env(pay("alice", "bob", Account("bob")["USD"](77)), - sendmax(Account("alice")["USD"](100)), - paths(Account("alice")["USD"])); - env.require(balance("alice", USD(0))); - env.require(balance("alice", gw2_USD(62.3))); - env.require(balance("bob", USD(70))); - env.require(balance("bob", gw2_USD(7))); - env.require(balance(gw, Account("alice")["USD"](0))); - env.require(balance(gw, Account("bob")["USD"](-70))); - env.require(balance(gw2, Account("alice")["USD"](-62.3))); - env.require(balance(gw2, Account("bob")["USD"](-7))); + Sendmax(Account("alice")["USD"](100)), + Paths(Account("alice")["USD"])); + env.require(Balance("alice", usd(0))); + env.require(Balance("alice", gw2Usd(62.3))); + env.require(Balance("bob", usd(70))); + env.require(Balance("bob", gw2Usd(7))); + env.require(Balance(gw, Account("alice")["USD"](0))); + env.require(Balance(gw, Account("bob")["USD"](-70))); + env.require(Balance(gw2, Account("alice")["USD"](-62.3))); + env.require(Balance(gw2, Account("bob")["USD"](-7))); } void - alternative_paths_limit_returned_paths_to_best_quality(bool const domainEnabled) + alternativePathsLimitReturnedPathsToBestQuality(bool const domainEnabled) { testcase( std::string("alternative paths - limit returned paths to best quality") + @@ -650,24 +650,24 @@ public: using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const gw2 = Account("gateway2"); - auto const gw2_USD = gw2["USD"]; + auto const gw2Usd = gw2["USD"]; env.fund(XRP(10000), "alice", "bob", "carol", "dan", gw, gw2); env.close(); env(rate("carol", 1.1)); env.trust(Account("carol")["USD"](800), "alice", "bob"); env.trust(Account("dan")["USD"](800), "alice", "bob"); - env.trust(USD(800), "alice", "bob"); - env.trust(gw2_USD(800), "alice", "bob"); + env.trust(usd(800), "alice", "bob"); + env.trust(gw2Usd(800), "alice", "bob"); env.trust(Account("alice")["USD"](800), "dan"); env.trust(Account("bob")["USD"](800), "dan"); env.close(); - env(pay(gw2, "alice", gw2_USD(100))); + env(pay(gw2, "alice", gw2Usd(100))); env.close(); env(pay("carol", "alice", Account("carol")["USD"](100))); env.close(); - env(pay(gw, "alice", USD(100))); + env(pay(gw, "alice", usd(100))); env.close(); std::optional domainID; @@ -678,7 +678,7 @@ public: STPathSet st; STAmount sa; - std::tie(st, sa, std::ignore) = find_paths( + std::tie(st, sa, std::ignore) = findPaths( env, "alice", "bob", Account("bob")["USD"](5), std::nullopt, std::nullopt, domainID); BEAST_EXPECT( same(st, stpath("gateway"), stpath("gateway2"), stpath("dan"), stpath("carol"))); @@ -686,7 +686,7 @@ public: } void - issues_path_negative_issue(bool const domainEnabled) + issuesPathNegativeIssue(bool const domainEnabled) { testcase( std::string("path negative: Issue #5") + (domainEnabled ? " w/ " : " w/o ") + "domain"); @@ -698,8 +698,8 @@ public: env.trust(Account("alice")["USD"](100), "dan"); env.trust(Account("carol")["USD"](100), "dan"); env(pay("bob", "carol", Account("bob")["USD"](75))); - env.require(balance("bob", Account("carol")["USD"](-75))); - env.require(balance("carol", Account("bob")["USD"](75))); + env.require(Balance("bob", Account("carol")["USD"](-75))); + env.require(Balance("carol", Account("bob")["USD"](75))); env.close(); std::optional domainID; @@ -708,34 +708,34 @@ public: domainID = setupDomain(env, {"alice", "bob", "carol", "dan"}); } - auto result = find_paths( + auto result = findPaths( env, "alice", "bob", Account("bob")["USD"](25), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(std::get<0>(result).empty()); - env(pay("alice", "bob", Account("alice")["USD"](25)), ter(tecPATH_DRY)); + env(pay("alice", "bob", Account("alice")["USD"](25)), Ter(tecPATH_DRY)); env.close(); - result = find_paths( + result = findPaths( env, "alice", "bob", Account("alice")["USD"](25), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(std::get<0>(result).empty()); - env.require(balance("alice", Account("bob")["USD"](0))); - env.require(balance("alice", Account("dan")["USD"](0))); - env.require(balance("bob", Account("alice")["USD"](0))); - env.require(balance("bob", Account("carol")["USD"](-75))); - env.require(balance("bob", Account("dan")["USD"](0))); - env.require(balance("carol", Account("bob")["USD"](75))); - env.require(balance("carol", Account("dan")["USD"](0))); - env.require(balance("dan", Account("alice")["USD"](0))); - env.require(balance("dan", Account("bob")["USD"](0))); - env.require(balance("dan", Account("carol")["USD"](0))); + env.require(Balance("alice", Account("bob")["USD"](0))); + env.require(Balance("alice", Account("dan")["USD"](0))); + env.require(Balance("bob", Account("alice")["USD"](0))); + env.require(Balance("bob", Account("carol")["USD"](-75))); + env.require(Balance("bob", Account("dan")["USD"](0))); + env.require(Balance("carol", Account("bob")["USD"](75))); + env.require(Balance("carol", Account("dan")["USD"](0))); + env.require(Balance("dan", Account("alice")["USD"](0))); + env.require(Balance("dan", Account("bob")["USD"](0))); + env.require(Balance("dan", Account("carol")["USD"](0))); } - // alice -- limit 40 --> bob - // alice --> carol --> dan --> bob + // alice_ -- limit 40 --> bob_ + // alice_ --> carol_ --> dan --> bob_ // Balance of 100 USD Bob - Balance of 37 USD -> Rod void - issues_path_negative_ripple_client_issue_23_smaller() + issuesPathNegativeRippleClientIssue23Smaller() { testcase("path negative: ripple-client issue #23: smaller"); using namespace jtx; @@ -746,15 +746,15 @@ public: env.trust(Account("dan")["USD"](20), "bob"); env.trust(Account("alice")["USD"](20), "carol"); env.trust(Account("carol")["USD"](20), "dan"); - env(pay("alice", "bob", Account("bob")["USD"](55)), paths(Account("alice")["USD"])); - env.require(balance("bob", Account("alice")["USD"](40))); - env.require(balance("bob", Account("dan")["USD"](15))); + env(pay("alice", "bob", Account("bob")["USD"](55)), Paths(Account("alice")["USD"])); + env.require(Balance("bob", Account("alice")["USD"](40))); + env.require(Balance("bob", Account("dan")["USD"](15))); } - // alice -120 USD-> edward -25 USD-> bob - // alice -25 USD-> carol -75 USD -> dan -100 USD-> bob + // alice_ -120 USD-> edward -25 USD-> bob_ + // alice_ -25 USD-> carol_ -75 USD -> dan -100 USD-> bob_ void - issues_path_negative_ripple_client_issue_23_larger() + issuesPathNegativeRippleClientIssue23Larger() { testcase("path negative: ripple-client issue #23: larger"); using namespace jtx; @@ -766,64 +766,64 @@ public: env.trust(Account("dan")["USD"](100), "bob"); env.trust(Account("alice")["USD"](25), "carol"); env.trust(Account("carol")["USD"](75), "dan"); - env(pay("alice", "bob", Account("bob")["USD"](50)), paths(Account("alice")["USD"])); - env.require(balance("alice", Account("edward")["USD"](-25))); - env.require(balance("alice", Account("carol")["USD"](-25))); - env.require(balance("bob", Account("edward")["USD"](25))); - env.require(balance("bob", Account("dan")["USD"](25))); - env.require(balance("carol", Account("alice")["USD"](25))); - env.require(balance("carol", Account("dan")["USD"](-25))); - env.require(balance("dan", Account("carol")["USD"](25))); - env.require(balance("dan", Account("bob")["USD"](-25))); + env(pay("alice", "bob", Account("bob")["USD"](50)), Paths(Account("alice")["USD"])); + env.require(Balance("alice", Account("edward")["USD"](-25))); + env.require(Balance("alice", Account("carol")["USD"](-25))); + env.require(Balance("bob", Account("edward")["USD"](25))); + env.require(Balance("bob", Account("dan")["USD"](25))); + env.require(Balance("carol", Account("alice")["USD"](25))); + env.require(Balance("carol", Account("dan")["USD"](-25))); + env.require(Balance("dan", Account("carol")["USD"](25))); + env.require(Balance("dan", Account("bob")["USD"](-25))); } - // carol holds gateway AUD, sells gateway AUD for XRP - // bob will hold gateway AUD - // alice pays bob gateway AUD using XRP + // carol_ holds gateway AUD, sells gateway AUD for XRP + // bob_ will hold gateway AUD + // alice_ pays bob_ gateway AUD using XRP void - via_offers_via_gateway(bool const domainEnabled) + viaOffersViaGateway(bool const domainEnabled) { testcase(std::string("via gateway") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); auto const gw = Account("gateway"); - auto const AUD = gw["AUD"]; + auto const aud = gw["AUD"]; env.fund(XRP(10000), "alice", "bob", "carol", gw); env.close(); env(rate(gw, 1.1)); env.close(); - env.trust(AUD(100), "bob", "carol"); + env.trust(aud(100), "bob", "carol"); env.close(); - env(pay(gw, "carol", AUD(50))); + env(pay(gw, "carol", aud(50))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {"alice", "bob", "carol", gw}); - env(offer("carol", XRP(50), AUD(50)), domain(*domainID)); + env(offer("carol", XRP(50), aud(50)), Domain(*domainID)); env.close(); - env(pay("alice", "bob", AUD(10)), sendmax(XRP(100)), paths(XRP), domain(*domainID)); + env(pay("alice", "bob", aud(10)), Sendmax(XRP(100)), Paths(XRP), Domain(*domainID)); env.close(); } else { - env(offer("carol", XRP(50), AUD(50))); + env(offer("carol", XRP(50), aud(50))); env.close(); - env(pay("alice", "bob", AUD(10)), sendmax(XRP(100)), paths(XRP)); + env(pay("alice", "bob", aud(10)), Sendmax(XRP(100)), Paths(XRP)); env.close(); } - env.require(balance("bob", AUD(10))); - env.require(balance("carol", AUD(39))); + env.require(Balance("bob", aud(10))); + env.require(Balance("carol", aud(39))); - auto const result = find_paths( + auto const result = findPaths( env, "alice", "bob", Account("bob")["USD"](25), std::nullopt, std::nullopt, domainID); BEAST_EXPECT(std::get<0>(result).empty()); } void - indirect_paths_path_find() + indirectPathsPathFind() { testcase("path find"); using namespace jtx; @@ -836,13 +836,13 @@ public: STPathSet st; STAmount sa; std::tie(st, sa, std::ignore) = - find_paths(env, "alice", "carol", Account("carol")["USD"](5)); + findPaths(env, "alice", "carol", Account("carol")["USD"](5)); BEAST_EXPECT(same(st, stpath("bob"))); BEAST_EXPECT(equal(sa, Account("alice")["USD"](5))); } void - quality_paths_quality_set_and_test() + qualityPathsQualitySetAndTest() { testcase("quality set and test"); using namespace jtx; @@ -850,11 +850,11 @@ public: env.fund(XRP(10000), "alice", "bob"); env.close(); env(trust("bob", Account("alice")["USD"](1000)), - json("{\"" + sfQualityIn.fieldName + "\": 2000}"), - json("{\"" + sfQualityOut.fieldName + "\": 1400000000}")); + Json("{\"" + sfQualityIn.fieldName + "\": 2000}"), + Json("{\"" + sfQualityOut.fieldName + "\": 1400000000}")); - Json::Value jv; - Json::Reader().parse( + json::Value jv; + json::Reader().parse( R"({ "Balance" : { "currency" : "USD", @@ -880,14 +880,14 @@ public: })", jv); - auto const jv_l = env.le(keylet::line(Account("bob").id(), Account("alice")["USD"])) - ->getJson(JsonOptions::none); + auto const jvL = env.le(keylet::line(Account("bob").id(), Account("alice")["USD"])) + ->getJson(JsonOptions::KNone); for (auto it = jv.begin(); it != jv.end(); ++it) - BEAST_EXPECT(*it == jv_l[it.memberName()]); + BEAST_EXPECT(*it == jvL[it.memberName()]); } void - trust_auto_clear_trust_normal_clear() + trustAutoClearTrustNormalClear() { testcase("trust normal clear"); using namespace jtx; @@ -897,8 +897,8 @@ public: env.trust(Account("bob")["USD"](1000), "alice"); env.trust(Account("alice")["USD"](1000), "bob"); - Json::Value jv; - Json::Reader().parse( + json::Value jv; + json::Reader().parse( R"({ "Balance" : { "currency" : "USD", @@ -922,10 +922,10 @@ public: })", jv); - auto const jv_l = env.le(keylet::line(Account("bob").id(), Account("alice")["USD"])) - ->getJson(JsonOptions::none); + auto const jvL = env.le(keylet::line(Account("bob").id(), Account("alice")["USD"])) + ->getJson(JsonOptions::KNone); for (auto it = jv.begin(); it != jv.end(); ++it) - BEAST_EXPECT(*it == jv_l[it.memberName()]); + BEAST_EXPECT(*it == jvL[it.memberName()]); env.trust(Account("bob")["USD"](0), "alice"); env.trust(Account("alice")["USD"](0), "bob"); @@ -933,7 +933,7 @@ public: } void - trust_auto_clear_trust_auto_clear() + trustAutoClearTrustAutoClear() { testcase("trust auto clear"); using namespace jtx; @@ -944,8 +944,8 @@ public: env(pay("bob", "alice", Account("bob")["USD"](50))); env.trust(Account("bob")["USD"](0), "alice"); - Json::Value jv; - Json::Reader().parse( + json::Value jv; + json::Reader().parse( R"({ "Balance" : { @@ -972,64 +972,64 @@ public: })", jv); - auto const jv_l = env.le(keylet::line(Account("alice").id(), Account("bob")["USD"])) - ->getJson(JsonOptions::none); + auto const jvL = env.le(keylet::line(Account("alice").id(), Account("bob")["USD"])) + ->getJson(JsonOptions::KNone); for (auto it = jv.begin(); it != jv.end(); ++it) - BEAST_EXPECT(*it == jv_l[it.memberName()]); + BEAST_EXPECT(*it == jvL[it.memberName()]); env(pay("alice", "bob", Account("alice")["USD"](50))); BEAST_EXPECT(env.le(keylet::line(Account("alice").id(), Account("bob")["USD"])) == nullptr); } void - path_find_01(bool const domainEnabled) + pathFind01(bool const domainEnabled) { testcase( std::string("Path Find: XRP -> XRP and XRP -> IOU") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const G3{"G3"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const g3{"G3"}; + Account const m1{"M1"}; - env.fund(XRP(100000), A1); - env.fund(XRP(10000), A2); - env.fund(XRP(1000), A3, G1, G2, G3, M1); + env.fund(XRP(100000), a1); + env.fund(XRP(10000), a2); + env.fund(XRP(1000), a3, g1, g2, g3, m1); env.close(); - env.trust(G1["XYZ"](5000), A1); - env.trust(G3["ABC"](5000), A1); - env.trust(G2["XYZ"](5000), A2); - env.trust(G3["ABC"](5000), A2); - env.trust(A2["ABC"](1000), A3); - env.trust(G1["XYZ"](100000), M1); - env.trust(G2["XYZ"](100000), M1); - env.trust(G3["ABC"](100000), M1); + env.trust(g1["XYZ"](5000), a1); + env.trust(g3["ABC"](5000), a1); + env.trust(g2["XYZ"](5000), a2); + env.trust(g3["ABC"](5000), a2); + env.trust(a2["ABC"](1000), a3); + env.trust(g1["XYZ"](100000), m1); + env.trust(g2["XYZ"](100000), m1); + env.trust(g3["ABC"](100000), m1); env.close(); - env(pay(G1, A1, G1["XYZ"](3500))); - env(pay(G3, A1, G3["ABC"](1200))); - env(pay(G2, M1, G2["XYZ"](25000))); - env(pay(G3, M1, G3["ABC"](25000))); + env(pay(g1, a1, g1["XYZ"](3500))); + env(pay(g3, a1, g3["ABC"](1200))); + env(pay(g2, m1, g2["XYZ"](25000))); + env(pay(g3, m1, g3["ABC"](25000))); env.close(); std::optional domainID; if (domainEnabled) { - domainID = setupDomain(env, {A1, A2, A3, G1, G2, G3, M1}); - env(offer(M1, G1["XYZ"](1000), G2["XYZ"](1000)), domain(*domainID)); - env(offer(M1, XRP(10000), G3["ABC"](1000)), domain(*domainID)); + domainID = setupDomain(env, {a1, a2, a3, g1, g2, g3, m1}); + env(offer(m1, g1["XYZ"](1000), g2["XYZ"](1000)), Domain(*domainID)); + env(offer(m1, XRP(10000), g3["ABC"](1000)), Domain(*domainID)); env.close(); } else { - env(offer(M1, G1["XYZ"](1000), G2["XYZ"](1000))); - env(offer(M1, XRP(10000), G3["ABC"](1000))); + env(offer(m1, g1["XYZ"](1000), g2["XYZ"](1000))); + env(offer(m1, XRP(10000), g3["ABC"](1000))); env.close(); } @@ -1037,98 +1037,98 @@ public: STAmount sa, da; { - auto const& send_amt = XRP(10); + auto const& sendAmt = XRP(10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency(), domainID); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency(), domainID); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { // no path should exist for this since dest account // does not exist. - auto const& send_amt = XRP(200); + auto const& sendAmt = XRP(200); std::tie(st, sa, da) = - find_paths(env, A1, Account{"A0"}, send_amt, std::nullopt, xrpCurrency(), domainID); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, Account{"A0"}, sendAmt, std::nullopt, xrpCurrency(), domainID); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } { - auto const& send_amt = G3["ABC"](10); + auto const& sendAmt = g3["ABC"](10); std::tie(st, sa, da) = - find_paths(env, A2, G3, send_amt, std::nullopt, xrpCurrency(), domainID); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a2, g3, sendAmt, std::nullopt, xrpCurrency(), domainID); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRP(100))); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"])))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"])))); } { - auto const& send_amt = A2["ABC"](1); + auto const& sendAmt = a2["ABC"](1); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency(), domainID); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, a2, sendAmt, std::nullopt, xrpCurrency(), domainID); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRP(10))); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"]), g3))); } { - auto const& send_amt = A3["ABC"](1); + auto const& sendAmt = a3["ABC"](1); std::tie(st, sa, da) = - find_paths(env, A1, A3, send_amt, std::nullopt, xrpCurrency(), domainID); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, a3, sendAmt, std::nullopt, xrpCurrency(), domainID); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(equal(sa, XRP(10))); - BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3, A2))); + BEAST_EXPECT(same(st, stpath(ipe(g3["ABC"]), g3, a2))); } } void - path_find_02(bool const domainEnabled) + pathFind02(bool const domainEnabled) { testcase( std::string("Path Find: non-XRP -> XRP") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const G3{"G3"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const g3{"G3"}; + Account const m1{"M1"}; - env.fund(XRP(1000), A1, A2, G3); - env.fund(XRP(11000), M1); + env.fund(XRP(1000), a1, a2, g3); + env.fund(XRP(11000), m1); env.close(); - env.trust(G3["ABC"](1000), A1, A2); - env.trust(G3["ABC"](100000), M1); + env.trust(g3["ABC"](1000), a1, a2); + env.trust(g3["ABC"](100000), m1); env.close(); - env(pay(G3, A1, G3["ABC"](1000))); - env(pay(G3, A2, G3["ABC"](1000))); - env(pay(G3, M1, G3["ABC"](1200))); + env(pay(g3, a1, g3["ABC"](1000))); + env(pay(g3, a2, g3["ABC"](1000))); + env(pay(g3, m1, g3["ABC"](1200))); env.close(); std::optional domainID; if (domainEnabled) { - domainID = setupDomain(env, {A1, A2, G3, M1}); - env(offer(M1, G3["ABC"](1000), XRP(10000)), domain(*domainID)); + domainID = setupDomain(env, {a1, a2, g3, m1}); + env(offer(m1, g3["ABC"](1000), XRP(10000)), Domain(*domainID)); } else { - env(offer(M1, G3["ABC"](1000), XRP(10000))); + env(offer(m1, g3["ABC"](1000), XRP(10000))); } STPathSet st; STAmount sa, da; - auto const& send_amt = XRP(10); + auto const& sendAmt = XRP(10); { std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, A2["ABC"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["ABC"](1))); - BEAST_EXPECT(same(st, stpath(G3, IPE(xrpIssue())))); + findPaths(env, a1, a2, sendAmt, std::nullopt, a2["ABC"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["ABC"](1))); + BEAST_EXPECT(same(st, stpath(g3, ipe(xrpIssue())))); } // domain offer will not be considered in pathfinding for non-domain @@ -1136,153 +1136,153 @@ public: if (domainEnabled) { std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, A2["ABC"].currency); - BEAST_EXPECT(equal(da, send_amt)); + findPaths(env, a1, a2, sendAmt, std::nullopt, a2["ABC"].currency); + BEAST_EXPECT(equal(da, sendAmt)); BEAST_EXPECT(st.empty()); } } void - path_find_04(bool const domainEnabled) + pathFind04(bool const domainEnabled) { testcase( std::string("Path Find: Bitstamp and SnapSwap, liquidity with no offers") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const G1BS{"G1BS"}; - Account const G2SW{"G2SW"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const g1Bs{"G1BS"}; + Account const g2Sw{"G2SW"}; + Account const m1{"M1"}; - env.fund(XRP(1000), G1BS, G2SW, A1, A2); - env.fund(XRP(11000), M1); + env.fund(XRP(1000), g1Bs, g2Sw, a1, a2); + env.fund(XRP(11000), m1); env.close(); - env.trust(G1BS["HKD"](2000), A1); - env.trust(G2SW["HKD"](2000), A2); - env.trust(G1BS["HKD"](100000), M1); - env.trust(G2SW["HKD"](100000), M1); + env.trust(g1Bs["HKD"](2000), a1); + env.trust(g2Sw["HKD"](2000), a2); + env.trust(g1Bs["HKD"](100000), m1); + env.trust(g2Sw["HKD"](100000), m1); env.close(); - env(pay(G1BS, A1, G1BS["HKD"](1000))); - env(pay(G2SW, A2, G2SW["HKD"](1000))); + env(pay(g1Bs, a1, g1Bs["HKD"](1000))); + env(pay(g2Sw, a2, g2Sw["HKD"](1000))); // SnapSwap wants to be able to set trust line quality settings so they // can charge a fee when transactions ripple across. Liquidity // provider, via trusting/holding both accounts - env(pay(G1BS, M1, G1BS["HKD"](1200))); - env(pay(G2SW, M1, G2SW["HKD"](5000))); + env(pay(g1Bs, m1, g1Bs["HKD"](1200))); + env(pay(g2Sw, m1, g2Sw["HKD"](5000))); env.close(); std::optional domainID; if (domainEnabled) - domainID = setupDomain(env, {A1, A2, G1BS, G2SW, M1}); + domainID = setupDomain(env, {a1, a2, g1Bs, g2Sw, m1}); STPathSet st; STAmount sa, da; { - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, A2["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(G1BS, M1, G2SW))); + findPaths(env, a1, a2, sendAmt, std::nullopt, a2["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(g1Bs, m1, g2Sw))); } { - auto const& send_amt = A1["HKD"](10); + auto const& sendAmt = a1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A2, A1, send_amt, std::nullopt, A1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A2["HKD"](10))); - BEAST_EXPECT(same(st, stpath(G2SW, M1, G1BS))); + findPaths(env, a2, a1, sendAmt, std::nullopt, a1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a2["HKD"](10))); + BEAST_EXPECT(same(st, stpath(g2Sw, m1, g1Bs))); } { - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, G1BS, A2, send_amt, std::nullopt, A1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1BS["HKD"](10))); - BEAST_EXPECT(same(st, stpath(M1, G2SW))); + findPaths(env, g1Bs, a2, sendAmt, std::nullopt, a1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1Bs["HKD"](10))); + BEAST_EXPECT(same(st, stpath(m1, g2Sw))); } { - auto const& send_amt = M1["HKD"](10); + auto const& sendAmt = m1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, M1, G1BS, send_amt, std::nullopt, A1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, M1["HKD"](10))); + findPaths(env, m1, g1Bs, sendAmt, std::nullopt, a1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, m1["HKD"](10))); BEAST_EXPECT(st.empty()); } { - auto const& send_amt = A1["HKD"](10); + auto const& sendAmt = a1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, G2SW, A1, send_amt, std::nullopt, A1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G2SW["HKD"](10))); - BEAST_EXPECT(same(st, stpath(M1, G1BS))); + findPaths(env, g2Sw, a1, sendAmt, std::nullopt, a1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g2Sw["HKD"](10))); + BEAST_EXPECT(same(st, stpath(m1, g1Bs))); } } void - path_find_05(bool const domainEnabled) + pathFind05(bool const domainEnabled) { testcase( std::string("Path Find: non-XRP -> non-XRP, same currency") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const G3{"G3"}; - Account const G4{"G4"}; - Account const M1{"M1"}; - Account const M2{"M2"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const g3{"G3"}; + Account const g4{"G4"}; + Account const m1{"M1"}; + Account const m2{"M2"}; - env.fund(XRP(1000), A1, A2, A3, G1, G2, G3, G4); - env.fund(XRP(10000), A4); - env.fund(XRP(11000), M1, M2); + env.fund(XRP(1000), a1, a2, a3, g1, g2, g3, g4); + env.fund(XRP(10000), a4); + env.fund(XRP(11000), m1, m2); env.close(); - env.trust(G1["HKD"](2000), A1); - env.trust(G2["HKD"](2000), A2); - env.trust(G1["HKD"](2000), A3); - env.trust(G1["HKD"](100000), M1); - env.trust(G2["HKD"](100000), M1); - env.trust(G1["HKD"](100000), M2); - env.trust(G2["HKD"](100000), M2); + env.trust(g1["HKD"](2000), a1); + env.trust(g2["HKD"](2000), a2); + env.trust(g1["HKD"](2000), a3); + env.trust(g1["HKD"](100000), m1); + env.trust(g2["HKD"](100000), m1); + env.trust(g1["HKD"](100000), m2); + env.trust(g2["HKD"](100000), m2); env.close(); - env(pay(G1, A1, G1["HKD"](1000))); - env(pay(G2, A2, G2["HKD"](1000))); - env(pay(G1, A3, G1["HKD"](1000))); - env(pay(G1, M1, G1["HKD"](1200))); - env(pay(G2, M1, G2["HKD"](5000))); - env(pay(G1, M2, G1["HKD"](1200))); - env(pay(G2, M2, G2["HKD"](5000))); + env(pay(g1, a1, g1["HKD"](1000))); + env(pay(g2, a2, g2["HKD"](1000))); + env(pay(g1, a3, g1["HKD"](1000))); + env(pay(g1, m1, g1["HKD"](1200))); + env(pay(g2, m1, g2["HKD"](5000))); + env(pay(g1, m2, g1["HKD"](1200))); + env(pay(g2, m2, g2["HKD"](5000))); env.close(); std::optional domainID; if (domainEnabled) { - domainID = setupDomain(env, {A1, A2, A3, A4, G1, G2, G3, G4, M1, M2}); - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), domain(*domainID)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), domain(*domainID)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), domain(*domainID)); + domainID = setupDomain(env, {a1, a2, a3, a4, g1, g2, g3, g4, m1, m2}); + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), Domain(*domainID)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), Domain(*domainID)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), Domain(*domainID)); } else { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000))); - env(offer(M2, XRP(10000), G2["HKD"](1000))); - env(offer(M2, G1["HKD"](1000), XRP(10000))); + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000))); + env(offer(m2, XRP(10000), g2["HKD"](1000))); + env(offer(m2, g1["HKD"](1000), XRP(10000))); } STPathSet st; @@ -1291,143 +1291,143 @@ public: { // A) Borrow or repay -- // Source -> Destination (repay source issuer) - auto const& send_amt = G1["HKD"](10); + auto const& sendAmt = g1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency, domainID); + findPaths(env, a1, g1, sendAmt, std::nullopt, g1["HKD"].currency, domainID); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // A2) Borrow or repay -- // Source -> Destination (repay destination issuer) - auto const& send_amt = A1["HKD"](10); + auto const& sendAmt = a1["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency, domainID); + findPaths(env, a1, g1, sendAmt, std::nullopt, g1["HKD"].currency, domainID); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // B) Common gateway -- // Source -> AC -> Destination - auto const& send_amt = A3["HKD"](10); + auto const& sendAmt = a3["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, A3, send_amt, std::nullopt, G1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(G1))); + findPaths(env, a1, a3, sendAmt, std::nullopt, g1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(g1))); } { // C) Gateway to gateway -- // Source -> OB -> Destination - auto const& send_amt = G2["HKD"](10); + auto const& sendAmt = g2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, G1, G2, send_amt, std::nullopt, G1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1["HKD"](10))); + findPaths(env, g1, g2, sendAmt, std::nullopt, g1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(IPE(G2["HKD"])), - stpath(M1), - stpath(M2), - stpath(IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(ipe(g2["HKD"])), + stpath(m1), + stpath(m2), + stpath(ipe(xrpIssue()), ipe(g2["HKD"])))); } { // D) User to unlinked gateway via order book -- // Source -> AC -> OB -> Destination - auto const& send_amt = G2["HKD"](10); + auto const& sendAmt = g2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, G2, send_amt, std::nullopt, G1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + findPaths(env, a1, g2, sendAmt, std::nullopt, g1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1), - stpath(G1, M2), - stpath(G1, IPE(G2["HKD"])), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(g1, m1), + stpath(g1, m2), + stpath(g1, ipe(g2["HKD"])), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"])))); } { // I4) XRP bridge" -- // Source -> AC -> OB to XRP -> OB from XRP -> AC -> // Destination - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, std::nullopt, G1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + findPaths(env, a1, a2, sendAmt, std::nullopt, g1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1, G2), - stpath(G1, M2, G2), - stpath(G1, IPE(G2["HKD"]), G2), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"]), G2))); + stpath(g1, m1, g2), + stpath(g1, m2, g2), + stpath(g1, ipe(g2["HKD"]), g2), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"]), g2))); } } void - path_find_06(bool const domainEnabled) + pathFind06(bool const domainEnabled) { testcase( std::string("Path Find: non-XRP -> non-XRP, same currency)") + (domainEnabled ? " w/ " : " w/o ") + "domain"); using namespace jtx; Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const M1{"M1"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const m1{"M1"}; - env.fund(XRP(11000), M1); - env.fund(XRP(1000), A1, A2, A3, G1, G2); + env.fund(XRP(11000), m1); + env.fund(XRP(1000), a1, a2, a3, g1, g2); env.close(); - env.trust(G1["HKD"](2000), A1); - env.trust(G2["HKD"](2000), A2); - env.trust(A2["HKD"](2000), A3); - env.trust(G1["HKD"](100000), M1); - env.trust(G2["HKD"](100000), M1); + env.trust(g1["HKD"](2000), a1); + env.trust(g2["HKD"](2000), a2); + env.trust(a2["HKD"](2000), a3); + env.trust(g1["HKD"](100000), m1); + env.trust(g2["HKD"](100000), m1); env.close(); - env(pay(G1, A1, G1["HKD"](1000))); - env(pay(G2, A2, G2["HKD"](1000))); - env(pay(G1, M1, G1["HKD"](5000))); - env(pay(G2, M1, G2["HKD"](5000))); + env(pay(g1, a1, g1["HKD"](1000))); + env(pay(g2, a2, g2["HKD"](1000))); + env(pay(g1, m1, g1["HKD"](5000))); + env(pay(g2, m1, g2["HKD"](5000))); env.close(); std::optional domainID; if (domainEnabled) { - domainID = setupDomain(env, {A1, A2, A3, G1, G2, M1}); - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), domain(*domainID)); + domainID = setupDomain(env, {a1, a2, a3, g1, g2, m1}); + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), Domain(*domainID)); } else { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000))); + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000))); } // E) Gateway to user // Source -> OB -> AC -> Destination - auto const& send_amt = A2["HKD"](10); + auto const& sendAmt = a2["HKD"](10); STPathSet st; STAmount sa, da; std::tie(st, sa, da) = - find_paths(env, G1, A2, send_amt, std::nullopt, G1["HKD"].currency, domainID); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(M1, G2), stpath(IPE(G2["HKD"]), G2))); + findPaths(env, g1, a2, sendAmt, std::nullopt, g1["HKD"].currency, domainID); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(m1, g2), stpath(ipe(g2["HKD"]), g2))); } void - receive_max(bool const domainEnabled) + receiveMax(bool const domainEnabled) { testcase(std::string("Receive max") + (domainEnabled ? " w/ " : " w/o ") + "domain"); @@ -1436,40 +1436,40 @@ public: auto const bob = Account("bob"); auto const charlie = Account("charlie"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { // XRP -> IOU receive max Env env = pathTestEnv(); env.fund(XRP(10000), alice, bob, charlie, gw); env.close(); - env.trust(USD(100), alice, bob, charlie); + env.trust(usd(100), alice, bob, charlie); env.close(); - env(pay(gw, charlie, USD(10))); + env(pay(gw, charlie, usd(10))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {alice, bob, charlie, gw}); - env(offer(charlie, XRP(10), USD(10)), domain(*domainID)); + env(offer(charlie, XRP(10), usd(10)), Domain(*domainID)); env.close(); } else { - env(offer(charlie, XRP(10), USD(10))); + env(offer(charlie, XRP(10), usd(10))); env.close(); } auto [st, sa, da] = - find_paths(env, alice, bob, USD(-1), XRP(100).value(), std::nullopt, domainID); + findPaths(env, alice, bob, usd(-1), XRP(100).value(), std::nullopt, domainID); BEAST_EXPECT(sa == XRP(10)); - BEAST_EXPECT(equal(da, USD(10))); + BEAST_EXPECT(equal(da, usd(10))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { auto const& pathElem = st[0][0]; BEAST_EXPECT( pathElem.isOffer() && pathElem.getIssuerID() == gw.id() && - pathElem.getCurrency() == USD.currency); + pathElem.getCurrency() == usd.currency); } } { @@ -1477,27 +1477,27 @@ public: Env env = pathTestEnv(); env.fund(XRP(10000), alice, bob, charlie, gw); env.close(); - env.trust(USD(100), alice, bob, charlie); + env.trust(usd(100), alice, bob, charlie); env.close(); - env(pay(gw, alice, USD(10))); + env(pay(gw, alice, usd(10))); env.close(); std::optional domainID; if (domainEnabled) { domainID = setupDomain(env, {alice, bob, charlie, gw}); - env(offer(charlie, USD(10), XRP(10)), domain(*domainID)); + env(offer(charlie, usd(10), XRP(10)), Domain(*domainID)); env.close(); } else { - env(offer(charlie, USD(10), XRP(10))); + env(offer(charlie, usd(10), XRP(10))); env.close(); } auto [st, sa, da] = - find_paths(env, alice, bob, drops(-1), USD(100).value(), std::nullopt, domainID); - BEAST_EXPECT(sa == USD(10)); + findPaths(env, alice, bob, drops(-1), usd(100).value(), std::nullopt, domainID); + BEAST_EXPECT(sa == usd(10)); BEAST_EXPECT(equal(da, XRP(10))); if (BEAST_EXPECT(st.size() == 1 && st[0].size() == 1)) { @@ -1510,17 +1510,17 @@ public: } void - noripple_combinations() + norippleCombinations() { using namespace jtx; // This test will create trust lines with various values of the noRipple - // flag. alice <-> george <-> bob george will sort of act like a + // flag. alice_ <-> george <-> bob_ george will sort of act like a // gateway, but use a different name to avoid the usual assumptions // about gateways. auto const alice = Account("alice"); auto const bob = Account("bob"); auto const george = Account("george"); - auto const USD = george["USD"]; + auto const usd = george["USD"]; auto test = [&](std::string casename, bool aliceRipple, bool bobRipple, bool expectPath) { testcase(casename); @@ -1529,15 +1529,15 @@ public: env.close(); // Set the same flags at both ends of the trustline, even though // only george's matter. - env(trust(alice, USD(100), aliceRipple ? tfClearNoRipple : tfSetNoRipple)); + env(trust(alice, usd(100), aliceRipple ? tfClearNoRipple : tfSetNoRipple)); env(trust(george, alice["USD"](100), aliceRipple ? tfClearNoRipple : tfSetNoRipple)); - env(trust(bob, USD(100), bobRipple ? tfClearNoRipple : tfSetNoRipple)); + env(trust(bob, usd(100), bobRipple ? tfClearNoRipple : tfSetNoRipple)); env(trust(george, bob["USD"](100), bobRipple ? tfClearNoRipple : tfSetNoRipple)); env.close(); - env(pay(george, alice, USD(70))); + env(pay(george, alice, usd(70))); env.close(); - auto [st, sa, da] = find_paths(env, "alice", "bob", Account("bob")["USD"](5)); + auto [st, sa, da] = findPaths(env, "alice", "bob", Account("bob")["USD"](5)); BEAST_EXPECT(equal(da, bob["USD"](5))); if (expectPath) @@ -1559,7 +1559,7 @@ public: } void - hybrid_offer_path() + hybridOfferPath() { testcase("Hybrid offer path"); using namespace jtx; @@ -1569,45 +1569,45 @@ public: // lambda param that creates different types of offers auto testPathfind = [&](auto func, bool const domainEnabled = false) { Env env = pathTestEnv(); - Account const A1{"A1"}; - Account const A2{"A2"}; - Account const A3{"A3"}; - Account const A4{"A4"}; - Account const G1{"G1"}; - Account const G2{"G2"}; - Account const G3{"G3"}; - Account const G4{"G4"}; - Account const M1{"M1"}; - Account const M2{"M2"}; + Account const a1{"A1"}; + Account const a2{"A2"}; + Account const a3{"A3"}; + Account const a4{"A4"}; + Account const g1{"G1"}; + Account const g2{"G2"}; + Account const g3{"G3"}; + Account const g4{"G4"}; + Account const m1{"M1"}; + Account const m2{"M2"}; - env.fund(XRP(1000), A1, A2, A3, G1, G2, G3, G4); - env.fund(XRP(10000), A4); - env.fund(XRP(11000), M1, M2); + env.fund(XRP(1000), a1, a2, a3, g1, g2, g3, g4); + env.fund(XRP(10000), a4); + env.fund(XRP(11000), m1, m2); env.close(); - env.trust(G1["HKD"](2000), A1); - env.trust(G2["HKD"](2000), A2); - env.trust(G1["HKD"](2000), A3); - env.trust(G1["HKD"](100000), M1); - env.trust(G2["HKD"](100000), M1); - env.trust(G1["HKD"](100000), M2); - env.trust(G2["HKD"](100000), M2); + env.trust(g1["HKD"](2000), a1); + env.trust(g2["HKD"](2000), a2); + env.trust(g1["HKD"](2000), a3); + env.trust(g1["HKD"](100000), m1); + env.trust(g2["HKD"](100000), m1); + env.trust(g1["HKD"](100000), m2); + env.trust(g2["HKD"](100000), m2); env.close(); - env(pay(G1, A1, G1["HKD"](1000))); - env(pay(G2, A2, G2["HKD"](1000))); - env(pay(G1, A3, G1["HKD"](1000))); - env(pay(G1, M1, G1["HKD"](1200))); - env(pay(G2, M1, G2["HKD"](5000))); - env(pay(G1, M2, G1["HKD"](1200))); - env(pay(G2, M2, G2["HKD"](5000))); + env(pay(g1, a1, g1["HKD"](1000))); + env(pay(g2, a2, g2["HKD"](1000))); + env(pay(g1, a3, g1["HKD"](1000))); + env(pay(g1, m1, g1["HKD"](1200))); + env(pay(g2, m1, g2["HKD"](5000))); + env(pay(g1, m2, g1["HKD"](1200))); + env(pay(g2, m2, g2["HKD"](5000))); env.close(); std::optional domainID = - setupDomain(env, {A1, A2, A3, A4, G1, G2, G3, G4, M1, M2}); + setupDomain(env, {a1, a2, a3, a4, g1, g2, g3, g4, m1, m2}); BEAST_EXPECT(domainID); - func(env, M1, M2, G1, G2, *domainID); + func(env, m1, m2, g1, g2, *domainID); STPathSet st; STAmount sa, da; @@ -1615,119 +1615,119 @@ public: { // A) Borrow or repay -- // Source -> Destination (repay source issuer) - auto const& send_amt = G1["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = g1["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - A1, - G1, - send_amt, + a1, + g1, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // A2) Borrow or repay -- // Source -> Destination (repay destination issuer) - auto const& send_amt = A1["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = a1["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - A1, - G1, - send_amt, + a1, + g1, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); BEAST_EXPECT(st.empty()); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); } { // B) Common gateway -- // Source -> AC -> Destination - auto const& send_amt = A3["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = a3["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - A1, - A3, - send_amt, + a1, + a3, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); - BEAST_EXPECT(same(st, stpath(G1))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); + BEAST_EXPECT(same(st, stpath(g1))); } { // C) Gateway to gateway -- // Source -> OB -> Destination - auto const& send_amt = G2["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = g2["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - G1, - G2, - send_amt, + g1, + g2, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, G1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, g1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(IPE(G2["HKD"])), - stpath(M1), - stpath(M2), - stpath(IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(ipe(g2["HKD"])), + stpath(m1), + stpath(m2), + stpath(ipe(xrpIssue()), ipe(g2["HKD"])))); } { // D) User to unlinked gateway via order book -- // Source -> AC -> OB -> Destination - auto const& send_amt = G2["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = g2["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - A1, - G2, - send_amt, + a1, + g2, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1), - stpath(G1, M2), - stpath(G1, IPE(G2["HKD"])), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"])))); + stpath(g1, m1), + stpath(g1, m2), + stpath(g1, ipe(g2["HKD"])), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"])))); } { // I4) XRP bridge" -- // Source -> AC -> OB to XRP -> OB from XRP -> AC -> // Destination - auto const& send_amt = A2["HKD"](10); - std::tie(st, sa, da) = find_paths( + auto const& sendAmt = a2["HKD"](10); + std::tie(st, sa, da) = findPaths( env, - A1, - A2, - send_amt, + a1, + a2, + sendAmt, std::nullopt, - G1["HKD"].currency, + g1["HKD"].currency, domainEnabled ? domainID : std::nullopt); - BEAST_EXPECT(equal(da, send_amt)); - BEAST_EXPECT(equal(sa, A1["HKD"](10))); + BEAST_EXPECT(equal(da, sendAmt)); + BEAST_EXPECT(equal(sa, a1["HKD"](10))); BEAST_EXPECT(same( st, - stpath(G1, M1, G2), - stpath(G1, M2, G2), - stpath(G1, IPE(G2["HKD"]), G2), - stpath(G1, IPE(xrpIssue()), IPE(G2["HKD"]), G2))); + stpath(g1, m1, g2), + stpath(g1, m2, g2), + stpath(g1, ipe(g2["HKD"]), g2), + stpath(g1, ipe(xrpIssue()), ipe(g2["HKD"]), g2))); } }; @@ -1736,56 +1736,56 @@ public: // order book { testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, XRP(10000), G2["HKD"](1000))); - env(offer(M2, G1["HKD"](1000), XRP(10000))); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, XRP(10000), g2["HKD"](1000))); + env(offer(m2, g1["HKD"](1000), XRP(10000))); }); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, G1["HKD"](1000), XRP(10000))); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, g1["HKD"](1000), XRP(10000))); }); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), - domain(domainID), - txflags(tfHybrid)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), + Domain(domainID), + Txflags(tfHybrid)); }); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000))); - env(offer(M2, XRP(10000), G2["HKD"](1000))); - env(offer(M2, G1["HKD"](1000), XRP(10000)), - domain(domainID), - txflags(tfHybrid)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000))); + env(offer(m2, XRP(10000), g2["HKD"](1000))); + env(offer(m2, g1["HKD"](1000), XRP(10000)), + Domain(domainID), + Txflags(tfHybrid)); }); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000))); - env(offer(M2, XRP(10000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), - domain(domainID), - txflags(tfHybrid)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000))); + env(offer(m2, XRP(10000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), + Domain(domainID), + Txflags(tfHybrid)); }); } @@ -1794,103 +1794,103 @@ public: // order book { testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), domain(domainID)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), domain(domainID)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), Domain(domainID)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), Domain(domainID)); }, true); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), domain(domainID)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), Domain(domainID)); }, true); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), domain(domainID)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), domain(domainID)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), - domain(domainID), - txflags(tfHybrid)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), Domain(domainID)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), Domain(domainID)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), + Domain(domainID), + Txflags(tfHybrid)); }, true); testPathfind( - [](Env& env, Account M1, Account M2, Account G1, Account G2, uint256 domainID) { - env(offer(M1, G1["HKD"](1000), G2["HKD"](1000)), domain(domainID)); - env(offer(M2, XRP(10000), G2["HKD"](1000)), - domain(domainID), - txflags(tfHybrid)); - env(offer(M2, G1["HKD"](1000), XRP(10000)), - domain(domainID), - txflags(tfHybrid)); + [](Env& env, Account m1, Account m2, Account g1, Account g2, uint256 domainID) { + env(offer(m1, g1["HKD"](1000), g2["HKD"](1000)), Domain(domainID)); + env(offer(m2, XRP(10000), g2["HKD"](1000)), + Domain(domainID), + Txflags(tfHybrid)); + env(offer(m2, g1["HKD"](1000), XRP(10000)), + Domain(domainID), + Txflags(tfHybrid)); }, true); } } void - amm_domain_path() + ammDomainPath() { testcase("AMM not used in domain path"); using namespace jtx; Env env = pathTestEnv(); PermissionedDEX const permDex(env); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = permDex; - AMM const amm(env, alice, XRP(10), USD(50)); + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = permDex; + AMM const amm(env, alice_, XRP(10), USD(50)); STPathSet st; STAmount sa, da; - auto const& send_amt = XRP(1); + auto const& sendAmt = XRP(1); // doing pathfind with domain won't include amm std::tie(st, sa, da) = - find_paths(env, bob, carol, send_amt, std::nullopt, USD.currency, domainID); + findPaths(env, bob_, carol_, sendAmt, std::nullopt, USD.currency, domainID); BEAST_EXPECT(st.empty()); // a non-domain pathfind returns amm in the path - std::tie(st, sa, da) = find_paths(env, bob, carol, send_amt, std::nullopt, USD.currency); - BEAST_EXPECT(same(st, stpath(gw, IPE(xrpIssue())))); + std::tie(st, sa, da) = findPaths(env, bob_, carol_, sendAmt, std::nullopt, USD.currency); + BEAST_EXPECT(same(st, stpath(gw_, ipe(xrpIssue())))); } void run() override { - source_currencies_limit(); - no_direct_path_no_intermediary_no_alternatives(); - direct_path_no_intermediary(); - payment_auto_path_find(); - indirect_paths_path_find(); - alternative_paths_consume_best_transfer_first(); - issues_path_negative_ripple_client_issue_23_smaller(); - issues_path_negative_ripple_client_issue_23_larger(); - quality_paths_quality_set_and_test(); - trust_auto_clear_trust_normal_clear(); - trust_auto_clear_trust_auto_clear(); - noripple_combinations(); + sourceCurrenciesLimit(); + noDirectPathNoIntermediaryNoAlternatives(); + directPathNoIntermediary(); + paymentAutoPathFind(); + indirectPathsPathFind(); + alternativePathsConsumeBestTransferFirst(); + issuesPathNegativeRippleClientIssue23Smaller(); + issuesPathNegativeRippleClientIssue23Larger(); + qualityPathsQualitySetAndTest(); + trustAutoClearTrustNormalClear(); + trustAutoClearTrustAutoClear(); + norippleCombinations(); for (bool const domainEnabled : {false, true}) { - path_find(domainEnabled); - path_find_consume_all(domainEnabled); - alternative_path_consume_both(domainEnabled); - alternative_paths_consume_best_transfer(domainEnabled); - alternative_paths_limit_returned_paths_to_best_quality(domainEnabled); - issues_path_negative_issue(domainEnabled); - via_offers_via_gateway(domainEnabled); - xrp_to_xrp(domainEnabled); - receive_max(domainEnabled); + pathFind(domainEnabled); + pathFindConsumeAll(domainEnabled); + alternativePathConsumeBoth(domainEnabled); + alternativePathsConsumeBestTransfer(domainEnabled); + alternativePathsLimitReturnedPathsToBestQuality(domainEnabled); + issuesPathNegativeIssue(domainEnabled); + viaOffersViaGateway(domainEnabled); + xrpToXrp(domainEnabled); + receiveMax(domainEnabled); // The following path_find_NN tests are data driven tests // that were originally implemented in js/coffee and migrated @@ -1898,15 +1898,15 @@ public: // those legacy tests, which in some cases probably represented // customer use cases. - path_find_01(domainEnabled); - path_find_02(domainEnabled); - path_find_04(domainEnabled); - path_find_05(domainEnabled); - path_find_06(domainEnabled); + pathFind01(domainEnabled); + pathFind02(domainEnabled); + pathFind04(domainEnabled); + pathFind05(domainEnabled); + pathFind06(domainEnabled); } - hybrid_offer_path(); - amm_domain_path(); + hybridOfferPath(); + ammDomainPath(); } }; diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index f69187c50f..c775dd2b6a 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,7 @@ namespace xrpl::test { using namespace jtx::paychan; -struct PayChan_test : public beast::unit_test::suite +struct PayChan_test : public beast::unit_test::Suite { static std::pair> channelKeyAndSle(ReadView const& view, jtx::Account const& account, jtx::Account const& dst) @@ -107,7 +108,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto USDA = alice["USD"]; + auto usda = alice["USD"]; env.fund(XRP(10000), alice, bob); auto const pk = alice.pk(); auto const settleDelay = 100s; @@ -130,34 +131,34 @@ struct PayChan_test : public beast::unit_test::suite { // bad amounts (non-xrp, negative amounts) - env(create(alice, bob, USDA(1000), settleDelay, pk), ter(temBAD_AMOUNT)); - env(fund(alice, chan, USDA(1000)), ter(temBAD_AMOUNT)); - env(create(alice, bob, XRP(-1000), settleDelay, pk), ter(temBAD_AMOUNT)); - env(fund(alice, chan, XRP(-1000)), ter(temBAD_AMOUNT)); + env(create(alice, bob, usda(1000), settleDelay, pk), Ter(temBAD_AMOUNT)); + env(fund(alice, chan, usda(1000)), Ter(temBAD_AMOUNT)); + env(create(alice, bob, XRP(-1000), settleDelay, pk), Ter(temBAD_AMOUNT)); + env(fund(alice, chan, XRP(-1000)), Ter(temBAD_AMOUNT)); } // invalid account - env(create(alice, "noAccount", XRP(1000), settleDelay, pk), ter(tecNO_DST)); + env(create(alice, "noAccount", XRP(1000), settleDelay, pk), Ter(tecNO_DST)); // can't create channel to the same account - env(create(alice, alice, XRP(1000), settleDelay, pk), ter(temDST_IS_SRC)); + env(create(alice, alice, XRP(1000), settleDelay, pk), Ter(temDST_IS_SRC)); // invalid channel env(fund(alice, channel(alice, "noAccount", env.seq(alice) - 1), XRP(1000)), - ter(tecNO_ENTRY)); + Ter(tecNO_ENTRY)); // not enough funds - env(create(alice, bob, XRP(10000), settleDelay, pk), ter(tecUNFUNDED)); + env(create(alice, bob, XRP(10000), settleDelay, pk), Ter(tecUNFUNDED)); { // No signature claim with bad amounts (negative and non-xrp) - auto const iou = USDA(100).value(); + auto const iou = usda(100).value(); auto const negXRP = XRP(-100).value(); auto const posXRP = XRP(100).value(); - env(claim(alice, chan, iou, iou), ter(temBAD_AMOUNT)); - env(claim(alice, chan, posXRP, iou), ter(temBAD_AMOUNT)); - env(claim(alice, chan, iou, posXRP), ter(temBAD_AMOUNT)); - env(claim(alice, chan, negXRP, negXRP), ter(temBAD_AMOUNT)); - env(claim(alice, chan, posXRP, negXRP), ter(temBAD_AMOUNT)); - env(claim(alice, chan, negXRP, posXRP), ter(temBAD_AMOUNT)); + env(claim(alice, chan, iou, iou), Ter(temBAD_AMOUNT)); + env(claim(alice, chan, posXRP, iou), Ter(temBAD_AMOUNT)); + env(claim(alice, chan, iou, posXRP), Ter(temBAD_AMOUNT)); + env(claim(alice, chan, negXRP, negXRP), Ter(temBAD_AMOUNT)); + env(claim(alice, chan, posXRP, negXRP), Ter(temBAD_AMOUNT)); + env(claim(alice, chan, negXRP, posXRP), Ter(temBAD_AMOUNT)); } { // No signature claim more than authorized @@ -165,7 +166,7 @@ struct PayChan_test : public beast::unit_test::suite auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(-100); assert(reqBal <= chanAmt); - env(claim(alice, chan, reqBal, authAmt), ter(temBAD_AMOUNT)); + env(claim(alice, chan, reqBal, authAmt), Ter(temBAD_AMOUNT)); } { // No signature needed since the owner is claiming @@ -198,7 +199,7 @@ struct PayChan_test : public beast::unit_test::suite // claim again preBob = env.balance(bob); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), - ter(tecUNFUNDED_PAYMENT)); + Ter(tecUNFUNDED_PAYMENT)); BEAST_EXPECT(channelBalance(*env.current(), chan) == chanBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); @@ -210,14 +211,14 @@ struct PayChan_test : public beast::unit_test::suite STAmount const reqAmt = authAmt + STAmount{1}; assert(reqAmt <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); - env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), ter(temBAD_AMOUNT)); + env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), Ter(temBAD_AMOUNT)); BEAST_EXPECT(channelBalance(*env.current(), chan) == chanBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); BEAST_EXPECT(env.balance(bob) == preBob); } // Dst tries to fund the channel - env(fund(bob, chan, XRP(1000)), ter(tecNO_PERMISSION)); + env(fund(bob, chan, XRP(1000)), Ter(tecNO_PERMISSION)); BEAST_EXPECT(channelBalance(*env.current(), chan) == chanBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); @@ -225,7 +226,7 @@ struct PayChan_test : public beast::unit_test::suite // Wrong signing key auto const sig = signClaimAuth(bob.pk(), bob.sk(), chan, XRP(1500)); env(claim(bob, chan, XRP(1500).value(), XRP(1500).value(), Slice(sig), bob.pk()), - ter(temBAD_SIGNER)); + Ter(temBAD_SIGNER)); BEAST_EXPECT(channelBalance(*env.current(), chan) == chanBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); } @@ -233,7 +234,7 @@ struct PayChan_test : public beast::unit_test::suite // Bad signature auto const sig = signClaimAuth(bob.pk(), bob.sk(), chan, XRP(1500)); env(claim(bob, chan, XRP(1500).value(), XRP(1500).value(), Slice(sig), alice.pk()), - ter(temBAD_SIGNATURE)); + Ter(temBAD_SIGNATURE)); BEAST_EXPECT(channelBalance(*env.current(), chan) == chanBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); } @@ -241,11 +242,11 @@ struct PayChan_test : public beast::unit_test::suite // Dst closes channel auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); - env(claim(bob, chan), txflags(tfClose)); + env(claim(bob, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + assert(delta > beast::kZERO); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } @@ -273,7 +274,7 @@ struct PayChan_test : public beast::unit_test::suite // channel creation from alice to bob is disallowed { auto const chan = channel(alice, bob, env.seq(alice)); - env(create(alice, bob, XRP(1000), settleDelay, pk), ter(tecNO_PERMISSION)); + env(create(alice, bob, XRP(1000), settleDelay, pk), Ter(tecNO_PERMISSION)); BEAST_EXPECT(!channelExists(*env.current(), chan)); } @@ -284,7 +285,7 @@ struct PayChan_test : public beast::unit_test::suite // channel creation from bob to alice is now disallowed { auto const chan = channel(bob, alice, env.seq(bob)); - env(create(bob, alice, XRP(1000), settleDelay, pk), ter(tecNO_PERMISSION)); + env(create(bob, alice, XRP(1000), settleDelay, pk), Ter(tecNO_PERMISSION)); BEAST_EXPECT(!channelExists(*env.current(), chan)); } @@ -295,14 +296,14 @@ struct PayChan_test : public beast::unit_test::suite // now the channel between alice and bob can exist { auto const chan = channel(alice, bob, env.seq(alice)); - env(create(alice, bob, XRP(1000), settleDelay, pk), ter(tesSUCCESS)); + env(create(alice, bob, XRP(1000), settleDelay, pk), Ter(tesSUCCESS)); BEAST_EXPECT(channelExists(*env.current(), chan)); } // a channel from cho to alice isn't allowed { auto const chan = channel(cho, alice, env.seq(cho)); - env(create(cho, alice, XRP(1000), settleDelay, pk), ter(tecNO_PERMISSION)); + env(create(cho, alice, XRP(1000), settleDelay, pk), Ter(tecNO_PERMISSION)); BEAST_EXPECT(!channelExists(*env.current(), chan)); } @@ -313,7 +314,7 @@ struct PayChan_test : public beast::unit_test::suite // now a channel from cho to alice is allowed { auto const chan = channel(cho, alice, env.seq(cho)); - env(create(cho, alice, XRP(1000), settleDelay, pk), ter(tesSUCCESS)); + env(create(cho, alice, XRP(1000), settleDelay, pk), Ter(tesSUCCESS)); BEAST_EXPECT(channelExists(*env.current(), chan)); } } @@ -371,12 +372,12 @@ struct PayChan_test : public beast::unit_test::suite env(create(alice, bob, channelFunds, settleDelay, pk, cancelAfter)); BEAST_EXPECT(channelExists(*env.current(), chan)); // third party close before cancelAfter - env(claim(carol, chan), txflags(tfClose), ter(tecNO_PERMISSION)); + env(claim(carol, chan), Txflags(tfClose), Ter(tecNO_PERMISSION)); BEAST_EXPECT(channelExists(*env.current(), chan)); env.close(cancelAfter); // third party close after cancelAfter auto const preAlice = env.balance(alice); - env(claim(carol, chan), txflags(tfClose)); + env(claim(carol, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); BEAST_EXPECT(env.balance(alice) == preAlice + channelFunds); } @@ -395,7 +396,7 @@ struct PayChan_test : public beast::unit_test::suite auto const channelFunds = XRP(1000); NetClock::time_point const cancelAfter = env.current()->header().parentCloseTime - 1s; - auto const txResult = withFixPayChan ? ter(tecEXPIRED) : ter(tesSUCCESS); + auto const txResult = withFixPayChan ? Ter(tecEXPIRED) : Ter(tesSUCCESS); env(create(alice, bob, channelFunds, settleDelay, pk, cancelAfter), txResult); } } @@ -414,7 +415,7 @@ struct PayChan_test : public beast::unit_test::suite auto const channelFunds = XRP(1000); NetClock::time_point const cancelAfter = env.current()->header().parentCloseTime; env(create(alice, bob, channelFunds, settleDelay, pk, cancelAfter), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); } } } @@ -441,7 +442,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(channelExists(*env.current(), chan)); BEAST_EXPECT(!channelExpiration(*env.current(), chan)); // Owner closes, will close after settleDelay - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); auto counts = [](auto const& t) { return t.time_since_epoch().count(); }; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) BEAST_EXPECT(*channelExpiration(*env.current(), chan) == counts(minExpiration)); @@ -455,17 +456,17 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(*channelExpiration(*env.current(), chan) == counts(minExpiration) + 50); // decrease the expiration below minExpiration env(fund(alice, chan, XRP(1), NetClock::time_point{minExpiration - 50s}), - ter(temBAD_EXPIRATION)); + Ter(temBAD_EXPIRATION)); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) BEAST_EXPECT(*channelExpiration(*env.current(), chan) == counts(minExpiration) + 50); - env(claim(bob, chan), txflags(tfRenew), ter(tecNO_PERMISSION)); + env(claim(bob, chan), Txflags(tfRenew), Ter(tecNO_PERMISSION)); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) BEAST_EXPECT(*channelExpiration(*env.current(), chan) == counts(minExpiration) + 50); - env(claim(alice, chan), txflags(tfRenew)); + env(claim(alice, chan), Txflags(tfRenew)); BEAST_EXPECT(!channelExpiration(*env.current(), chan)); // decrease the expiration below minExpiration env(fund(alice, chan, XRP(1), NetClock::time_point{minExpiration - 50s}), - ter(temBAD_EXPIRATION)); + Ter(temBAD_EXPIRATION)); BEAST_EXPECT(!channelExpiration(*env.current(), chan)); env(fund(alice, chan, XRP(1), NetClock::time_point{minExpiration})); env.close(minExpiration); @@ -493,7 +494,7 @@ struct PayChan_test : public beast::unit_test::suite env(create(alice, bob, channelFunds, settleDelay, pk)); BEAST_EXPECT(channelExists(*env.current(), chan)); // Owner closes, will close after settleDelay - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); BEAST_EXPECT(channelExists(*env.current(), chan)); env.close(settleTimepoint - settleDelay / 2); { @@ -549,7 +550,7 @@ struct PayChan_test : public beast::unit_test::suite env(create(alice, bob, channelFunds, settleDelay, pk)); BEAST_EXPECT(channelExists(*env.current(), chan)); // Owner tries to close channel, but it will remain open (settle delay) - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); BEAST_EXPECT(channelExists(*env.current(), chan)); { // claim the entire amount @@ -560,7 +561,7 @@ struct PayChan_test : public beast::unit_test::suite } auto const preAlice = env.balance(alice); // Channel is now dry, can close before expiration date - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; BEAST_EXPECT(env.balance(alice) == preAlice - feeDrops); @@ -584,7 +585,7 @@ struct PayChan_test : public beast::unit_test::suite env(create(alice, bob, channelFunds, settleDelay, pk)); BEAST_EXPECT(channelExists(*env.current(), chan)); // Owner tries to close channel, but it will remain open (settle delay) - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); BEAST_EXPECT(channelExists(*env.current(), chan)); { auto chanBal = channelBalance(*env.current(), chan); @@ -674,7 +675,7 @@ struct PayChan_test : public beast::unit_test::suite auto const channelFunds = XRP(1000); { auto const chan = channel(alice, bob, env.seq(alice)); - env(create(alice, bob, channelFunds, settleDelay, pk), ter(tecDST_TAG_NEEDED)); + env(create(alice, bob, channelFunds, settleDelay, pk), Ter(tecDST_TAG_NEEDED)); BEAST_EXPECT(!channelExists(*env.current(), chan)); } { @@ -694,7 +695,7 @@ struct PayChan_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const carol = Account("carol"); - auto USDA = alice["USD"]; + auto usda = alice["USD"]; { Env env{*this, features}; env.fund(XRP(10000), alice, bob, carol); @@ -717,7 +718,7 @@ struct PayChan_test : public beast::unit_test::suite env.close(); // alice claims. Fails because bob's lsfDepositAuth flag is set. - env(claim(alice, chan, XRP(500).value(), XRP(500).value()), ter(tecNO_PERMISSION)); + env(claim(alice, chan, XRP(500).value(), XRP(500).value()), Ter(tecNO_PERMISSION)); env.close(); // Claim with signature @@ -729,13 +730,13 @@ struct PayChan_test : public beast::unit_test::suite // alice claims with signature. Fails since bob has // lsfDepositAuth flag set. - env(claim(alice, chan, delta, delta, Slice(sig), pk), ter(tecNO_PERMISSION)); + env(claim(alice, chan, delta, delta, Slice(sig), pk), Ter(tecNO_PERMISSION)); env.close(); BEAST_EXPECT(env.balance(bob) == preBob); // bob claims but omits the signature. Fails because only // alice can claim without a signature. - env(claim(bob, chan, delta, delta), ter(temBAD_SIGNATURE)); + env(claim(bob, chan, delta, delta), Ter(temBAD_SIGNATURE)); env.close(); // bob claims with signature. Succeeds even though bob's @@ -752,7 +753,7 @@ struct PayChan_test : public beast::unit_test::suite // carol claims and fails. Only channel participants (bob or // alice) may claim. - env(claim(carol, chan, delta, delta, Slice(sig), pk), ter(tecNO_PERMISSION)); + env(claim(carol, chan, delta, delta, Slice(sig), pk), Ter(tecNO_PERMISSION)); env.close(); // bob preauthorizes carol for deposit. But after that carol @@ -760,11 +761,11 @@ struct PayChan_test : public beast::unit_test::suite env(deposit::auth(bob, carol)); env.close(); - env(claim(carol, chan, delta, delta, Slice(sig), pk), ter(tecNO_PERMISSION)); + env(claim(carol, chan, delta, delta, Slice(sig), pk), Ter(tecNO_PERMISSION)); // Since alice is not preauthorized she also may not claim // for bob. - env(claim(alice, chan, delta, delta, Slice(sig), pk), ter(tecNO_PERMISSION)); + env(claim(alice, chan, delta, delta, Slice(sig), pk), Ter(tecNO_PERMISSION)); env.close(); // However if bob preauthorizes alice for deposit then she can @@ -786,7 +787,7 @@ struct PayChan_test : public beast::unit_test::suite env.close(); // alice claims and fails since she is no longer preauthorized. - env(claim(alice, chan, delta, delta), ter(tecNO_PERMISSION)); + env(claim(alice, chan, delta, delta), Ter(tecNO_PERMISSION)); env.close(); // bob clears lsfDepositAuth. Now alice can claim. @@ -854,8 +855,8 @@ struct PayChan_test : public beast::unit_test::suite // Fail, credentials not accepted env(claim(alice, chan, delta, delta), - credentials::ids({credIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Ter(tecBAD_CREDENTIALS)); env.close(); env(credentials::accept(alice, carol, credType)); @@ -863,8 +864,8 @@ struct PayChan_test : public beast::unit_test::suite // Fail, no depositPreauth object env(claim(alice, chan, delta, delta), - credentials::ids({credIdx}), - ter(tecNO_PERMISSION)); + credentials::Ids({credIdx}), + Ter(tecNO_PERMISSION)); env.close(); // Setup deposit authorization @@ -873,19 +874,19 @@ struct PayChan_test : public beast::unit_test::suite // Fail, credentials doesn’t belong to root account env(claim(dillon, chan, delta, delta), - credentials::ids({credIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credIdx}), + Ter(tecBAD_CREDENTIALS)); // Fails because bob's lsfDepositAuth flag is set. - env(claim(alice, chan, delta, delta), ter(tecNO_PERMISSION)); + env(claim(alice, chan, delta, delta), Ter(tecNO_PERMISSION)); // Fail, bad credentials index. env(claim(alice, chan, delta, delta), - credentials::ids({credBadIdx}), - ter(tecBAD_CREDENTIALS)); + credentials::Ids({credBadIdx}), + Ter(tecBAD_CREDENTIALS)); // Fail, empty credentials - env(claim(alice, chan, delta, delta), credentials::ids({}), ter(temMALFORMED)); + env(claim(alice, chan, delta, delta), credentials::Ids({}), Ter(temMALFORMED)); { // claim fails cause of expired credentials @@ -894,7 +895,7 @@ struct PayChan_test : public beast::unit_test::suite for (int i = 0; i < 10; ++i) env.close(); - env(claim(alice, chan, delta, delta), credentials::ids({credIdx}), ter(tecEXPIRED)); + env(claim(alice, chan, delta, delta), credentials::Ids({credIdx}), Ter(tecEXPIRED)); env.close(); } @@ -908,7 +909,7 @@ struct PayChan_test : public beast::unit_test::suite std::string const credIdx = jv[jss::result][jss::index].asString(); // Success - env(claim(alice, chan, delta, delta), credentials::ids({credIdx})); + env(claim(alice, chan, delta, delta), credentials::Ids({credIdx})); } } @@ -939,13 +940,13 @@ struct PayChan_test : public beast::unit_test::suite std::string const credIdx = jv[jss::result][jss::index].asString(); // Succeed, lsfDepositAuth is not set - env(claim(alice, chan, delta, delta), credentials::ids({credIdx})); + env(claim(alice, chan, delta, delta), credentials::Ids({credIdx})); env.close(); } { // Credentials amendment not enabled - Env env(*this, testable_amendments() - featureCredentials); + Env env(*this, testableAmendments() - featureCredentials); env.fund(XRP(5000), "alice", "bob"); env.close(); @@ -968,8 +969,8 @@ struct PayChan_test : public beast::unit_test::suite env.close(); env(claim(alice, chan, XRP(500).value(), XRP(500).value()), - credentials::ids({credIdx}), - ter(temDISABLED)); + credentials::Ids({credIdx}), + Ter(temDISABLED)); } } @@ -1006,7 +1007,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const charlie = Account("charlie", KeyType::ed25519); + auto const charlie = Account("charlie", KeyType::Ed25519); env.fund(XRP(10000), alice, bob, charlie); auto const pk = alice.pk(); auto const settleDelay = 3600s; @@ -1017,7 +1018,7 @@ struct PayChan_test : public beast::unit_test::suite { // test account non-string auto testInvalidAccountParam = [&](auto const& param) { - Json::Value params; + json::Value params; params[jss::account] = param; auto const jrr = env.rpc("json", "account_channels", to_string(params))[jss::result]; @@ -1028,14 +1029,14 @@ struct PayChan_test : public beast::unit_test::suite testInvalidAccountParam(1); testInvalidAccountParam(1.1); testInvalidAccountParam(true); - testInvalidAccountParam(Json::Value(Json::nullValue)); - testInvalidAccountParam(Json::Value(Json::objectValue)); - testInvalidAccountParam(Json::Value(Json::arrayValue)); + testInvalidAccountParam(json::Value(json::NullValue)); + testInvalidAccountParam(json::Value(json::ObjectValue)); + testInvalidAccountParam(json::Value(json::ArrayValue)); } { // test destination_account non-string auto testInvalidDestAccountParam = [&](auto const& param) { - Json::Value params; + json::Value params; params[jss::account] = alice.human(); params[jss::destination_account] = param; auto const jrr = @@ -1047,9 +1048,9 @@ struct PayChan_test : public beast::unit_test::suite testInvalidDestAccountParam(1); testInvalidDestAccountParam(1.1); testInvalidDestAccountParam(true); - testInvalidDestAccountParam(Json::Value(Json::nullValue)); - testInvalidDestAccountParam(Json::Value(Json::objectValue)); - testInvalidDestAccountParam(Json::Value(Json::arrayValue)); + testInvalidDestAccountParam(json::Value(json::NullValue)); + testInvalidDestAccountParam(json::Value(json::ObjectValue)); + testInvalidDestAccountParam(json::Value(json::ArrayValue)); } { auto const r = env.rpc("account_channels", alice.human(), bob.human()); @@ -1126,9 +1127,9 @@ struct PayChan_test : public beast::unit_test::suite auto testLimit = [](test::jtx::Env& env, test::jtx::Account const& src, std::optional limit = std::nullopt, - Json::Value const& marker = Json::nullValue, + json::Value const& marker = json::NullValue, std::optional const& dst = std::nullopt) { - Json::Value jvc; + json::Value jvc; jvc[jss::account] = src.human(); if (dst) jvc[jss::destination_account] = dst->human(); @@ -1160,7 +1161,7 @@ struct PayChan_test : public beast::unit_test::suite auto const numFull = bobs.size() / limit; auto const numNonFull = ((bobs.size() % limit) != 0u) ? 1 : 0; - Json::Value marker = Json::nullValue; + json::Value marker = json::NullValue; auto const testIt = [&](bool expectMarker, int expectedBatchSize) { auto const r = testLimit(env, alice, limit, marker); @@ -1222,7 +1223,7 @@ struct PayChan_test : public beast::unit_test::suite env(create(bob, alice, channelFunds, settleDelay, bob.pk())); auto const r = [&] { - Json::Value jvc; + json::Value jvc; jvc[jss::account] = alice.human(); return env.rpc("json", "account_channels", to_string(jvc))[jss::result]; @@ -1241,7 +1242,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const charlie = Account("charlie", KeyType::ed25519); + auto const charlie = Account("charlie", KeyType::Ed25519); env.fund(XRP(10000), alice, bob, charlie); auto const pk = alice.pk(); auto const settleDelay = 3600s; @@ -1250,7 +1251,7 @@ struct PayChan_test : public beast::unit_test::suite env(create(alice, bob, channelFunds, settleDelay, pk)); env.close(); - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::channel_id] = chan1Str; args[jss::key_type] = "ed255191"; args[jss::seed] = "snHq1rzQoN2qiUkC3XF5RyxBzUtN"; @@ -1276,7 +1277,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto const charlie = Account("charlie", KeyType::ed25519); + auto const charlie = Account("charlie", KeyType::Ed25519); env.fund(XRP(10000), alice, bob, charlie); auto const pk = alice.pk(); auto const settleDelay = 3600s; @@ -1481,7 +1482,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(rs[jss::error] == "channelAmtMalformed"); { // Missing channel_id - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = "2000"; args[jss::key_type] = "secp256k1"; args[jss::passphrase] = "passphrase_can_be_anything"; @@ -1490,7 +1491,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Missing amount - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::channel_id] = chan1Str; args[jss::key_type] = "secp256k1"; args[jss::passphrase] = "passphrase_can_be_anything"; @@ -1499,7 +1500,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Missing key_type and no secret. - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = "2000"; args[jss::channel_id] = chan1Str; args[jss::passphrase] = "passphrase_can_be_anything"; @@ -1508,7 +1509,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Both passphrase and seed specified. - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = "2000"; args[jss::channel_id] = chan1Str; args[jss::key_type] = "secp256k1"; @@ -1519,7 +1520,7 @@ struct PayChan_test : public beast::unit_test::suite } { // channel_id is not exact hex. - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = "2000"; args[jss::channel_id] = chan1Str + "1"; args[jss::key_type] = "secp256k1"; @@ -1529,7 +1530,7 @@ struct PayChan_test : public beast::unit_test::suite } { // amount is not a string - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = 2000; args[jss::channel_id] = chan1Str; args[jss::key_type] = "secp256k1"; @@ -1539,7 +1540,7 @@ struct PayChan_test : public beast::unit_test::suite } { // Amount is not a decimal string. - Json::Value args{Json::objectValue}; + json::Value args{json::ObjectValue}; args[jss::amount] = "TwoThousand"; args[jss::channel_id] = chan1Str; args[jss::key_type] = "secp256k1"; @@ -1596,7 +1597,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto USDA = alice["USD"]; + auto usda = alice["USD"]; env.fund(XRP(10000), alice, bob); auto const pk = alice.pk(); auto const settleDelay = 100s; @@ -1605,14 +1606,14 @@ struct PayChan_test : public beast::unit_test::suite auto jv = create(alice, bob, XRP(1000), settleDelay, pk); auto const pkHex = strHex(pk.slice()); jv["PublicKey"] = pkHex.substr(2, pkHex.size() - 2); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); jv["PublicKey"] = pkHex.substr(0, pkHex.size() - 2); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); auto badPrefix = pkHex; badPrefix[0] = 'f'; badPrefix[1] = 'f'; jv["PublicKey"] = badPrefix; - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); jv["PublicKey"] = pkHex; env(jv); @@ -1621,18 +1622,18 @@ struct PayChan_test : public beast::unit_test::suite auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); jv = claim(bob, chan, authAmt.value(), authAmt.value(), Slice(sig), alice.pk()); jv["PublicKey"] = pkHex.substr(2, pkHex.size() - 2); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); jv["PublicKey"] = pkHex.substr(0, pkHex.size() - 2); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); badPrefix = pkHex; badPrefix[0] = 'f'; badPrefix[1] = 'f'; jv["PublicKey"] = badPrefix; - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); // missing public key jv.removeMember("PublicKey"); - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); { auto const txn = R"*( @@ -1689,7 +1690,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(inOwnerDir(*env.current(), bob, chanSle)); BEAST_EXPECT(ownerDirCount(*env.current(), bob) == 1); // close the channel - env(claim(bob, chan), txflags(tfClose)); + env(claim(bob, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); BEAST_EXPECT(!inOwnerDir(*env.current(), alice, chanSle)); BEAST_EXPECT(ownerDirCount(*env.current(), alice) == 0); @@ -1711,7 +1712,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(inOwnerDir(*env.current(), bob, chanSle)); BEAST_EXPECT(ownerDirCount(*env.current(), bob) == 1); - env(claim(bob, chan), txflags(tfClose)); + env(claim(bob, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); BEAST_EXPECT(!inOwnerDir(*env.current(), alice, chanSle)); BEAST_EXPECT(ownerDirCount(*env.current(), alice) == 0); @@ -1737,8 +1738,8 @@ struct PayChan_test : public beast::unit_test::suite } env(acctdelete(toRm, dst), - fee(drops(env.current()->fees().increment)), - ter(expectedTer)); + Fee(drops(env.current()->fees().increment)), + Ter(expectedTer)); env.close(); this->BEAST_EXPECT( isTesSuccess(expectedTer) == !env.closed()->exists(keylet::account(toRm.id()))); @@ -1793,14 +1794,14 @@ struct PayChan_test : public beast::unit_test::suite { // Owner closes, will close after settleDelay - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); env.close(); // settle delay hasn't elapsed. Channels should exist. BEAST_EXPECT(channelExists(*env.current(), chan)); auto const closeTime = env.current()->header().parentCloseTime; auto const minExpiration = closeTime + settleDelay; env.close(minExpiration); - env(claim(alice, chan), txflags(tfClose)); + env(claim(alice, chan), Txflags(tfClose)); BEAST_EXPECT(!channelExists(*env.current(), chan)); } } @@ -1815,7 +1816,7 @@ struct PayChan_test : public beast::unit_test::suite Env env{*this, features}; auto const alice = Account("alice"); auto const bob = Account("bob"); - auto USDA = alice["USD"]; + auto usda = alice["USD"]; env.fund(XRP(10000), alice, bob); // alice and bob grab enough tickets for all of the following @@ -1833,7 +1834,7 @@ struct PayChan_test : public beast::unit_test::suite auto const settleDelay = 100s; auto const chan = channel(alice, bob, aliceTicketSeq); - env(create(alice, bob, XRP(1000), settleDelay, pk), ticket::use(aliceTicketSeq++)); + env(create(alice, bob, XRP(1000), settleDelay, pk), ticket::Use(aliceTicketSeq++)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1843,7 +1844,7 @@ struct PayChan_test : public beast::unit_test::suite { auto const preAlice = env.balance(alice); - env(fund(alice, chan, XRP(1000)), ticket::use(aliceTicketSeq++)); + env(fund(alice, chan, XRP(1000)), ticket::Use(aliceTicketSeq++)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1864,7 +1865,7 @@ struct PayChan_test : public beast::unit_test::suite auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); assert(reqBal <= chanAmt); - env(claim(alice, chan, reqBal, authAmt), ticket::use(aliceTicketSeq++)); + env(claim(alice, chan, reqBal, authAmt), ticket::Use(aliceTicketSeq++)); env.require(tickets(alice, env.seq(alice) - aliceTicketSeq)); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1883,7 +1884,7 @@ struct PayChan_test : public beast::unit_test::suite assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), - ticket::use(bobTicketSeq++)); + ticket::Use(bobTicketSeq++)); env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); @@ -1898,8 +1899,8 @@ struct PayChan_test : public beast::unit_test::suite preBob = env.balance(bob); // A transaction that generates a tec still consumes its ticket. env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), - ticket::use(bobTicketSeq++), - ter(tecUNFUNDED_PAYMENT)); + ticket::Use(bobTicketSeq++), + Ter(tecUNFUNDED_PAYMENT)); env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); @@ -1915,11 +1916,11 @@ struct PayChan_test : public beast::unit_test::suite STAmount const reqAmt = authAmt + drops(1); assert(reqAmt <= chanAmt); // Note that since claim() returns a tem (neither tec nor tes), - // the ticket is not consumed. So we don't increment bobTicket. + // the ticket is not consumed. So we don't kINCREMENT bobTicket. auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), - ticket::use(bobTicketSeq), - ter(temBAD_AMOUNT)); + ticket::Use(bobTicketSeq), + Ter(temBAD_AMOUNT)); env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); @@ -1930,7 +1931,7 @@ struct PayChan_test : public beast::unit_test::suite } // Dst tries to fund the channel - env(fund(bob, chan, XRP(1000)), ticket::use(bobTicketSeq++), ter(tecNO_PERMISSION)); + env(fund(bob, chan, XRP(1000)), ticket::Use(bobTicketSeq++), Ter(tecNO_PERMISSION)); env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); @@ -1942,7 +1943,7 @@ struct PayChan_test : public beast::unit_test::suite // Dst closes channel auto const preAlice = env.balance(alice); auto const preBob = env.balance(bob); - env(claim(bob, chan), txflags(tfClose), ticket::use(bobTicketSeq++)); + env(claim(bob, chan), Txflags(tfClose), ticket::Use(bobTicketSeq++)); env.require(tickets(bob, env.seq(bob) - bobTicketSeq)); BEAST_EXPECT(env.seq(bob) == bobSeq); @@ -1950,7 +1951,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + assert(delta > beast::kZERO); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } @@ -1991,7 +1992,7 @@ public: run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; testWithFeats(all); testDepositAuthCreds(); testMetaAndOwnership(all - fixIncludeKeyletFields); diff --git a/src/test/app/PayStrandMPT_test.cpp b/src/test/app/PayStrandMPT_test.cpp index 44f25d54dc..5550a26ab2 100644 --- a/src/test/app/PayStrandMPT_test.cpp +++ b/src/test/app/PayStrandMPT_test.cpp @@ -34,7 +34,7 @@ namespace xrpl::test { -struct PayStrandMPT_test : public beast::unit_test::suite +struct PayStrandMPT_test : public beast::unit_test::Suite { static jtx::DirectStepInfo makeEndpointStep(jtx::Account const& src, jtx::Account const& dst, jtx::IOU const& iou) @@ -81,7 +81,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite sendMaxIssue, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getLogs().journal("Flow")); @@ -94,7 +94,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite auto testMultiToken = [&](auto&& issue1, auto&& issue2) { Env env(*this, features); env.fund(XRP(10'000), alice, bob, gw); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 1'000}); auto const bobUSD = issue1( {.env = env, @@ -102,7 +102,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite .issuer = bob, .holders = {alice}, .limit = 1'000}); - MPT const EUR = + MPT const eur = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 1'000}); auto const bobEUR = issue2( {.env = env, @@ -110,7 +110,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite .issuer = bob, .holders = {alice}, .limit = 1'000}); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, eur(100))); { // Original test is @@ -130,10 +130,10 @@ struct PayStrandMPT_test : public beast::unit_test::suite alice, /*deliver*/ xrpIssue(), /*limitQuality*/ std::nullopt, - /*sendMaxIssue*/ EUR, + /*sendMaxIssue*/ eur, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getLogs().journal("Flow")); @@ -141,17 +141,17 @@ struct PayStrandMPT_test : public beast::unit_test::suite BEAST_EXPECT(ter == tesSUCCESS); } { - STPath const path = STPath({ipe(USD), cpe(xrpCurrency())}); + STPath const path = STPath({ipe(usd), cpe(xrpCurrency())}); auto [ter, _] = toStrand( *env.current(), alice, alice, /*deliver*/ xrpIssue(), /*limitQuality*/ std::nullopt, - /*sendMaxIssue*/ EUR, + /*sendMaxIssue*/ eur, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getLogs().journal("Flow")); @@ -165,10 +165,10 @@ struct PayStrandMPT_test : public beast::unit_test::suite auto testMultiToken = [&](auto&& issue1, auto&& issue2) { Env env(*this, features); env.fund(XRP(10'000), alice, bob, carol, gw); - auto USD = issue1({.env = env, .token = "USD", .issuer = gw, .limit = 1'000}); - using tUSD = std::decay_t; - auto EUR = issue2({.env = env, .token = "EUR", .issuer = gw, .limit = 1'000}); - using tEUR = std::decay_t; + auto usd = issue1({.env = env, .token = "USD", .issuer = gw, .limit = 1'000}); + using tUSD = std::decay_t; + auto eur = issue2({.env = env, .token = "EUR", .issuer = gw, .limit = 1'000}); + using tEUR = std::decay_t; auto const err = [&]() { if constexpr (std::is_same_v) @@ -180,102 +180,102 @@ struct PayStrandMPT_test : public beast::unit_test::suite return terNO_LINE; } }(); - test(env, USD, std::nullopt, STPath(), err); + test(env, usd, std::nullopt, STPath(), err); if constexpr (std::is_same_v) { - MPTTester(env, gw, USD).authorizeHolders({alice, bob, carol}); + MPTTester(env, gw, usd).authorizeHolders({alice, bob, carol}); } else { - env.trust(USD(1'000), alice, bob, carol); + env.trust(usd(1'000), alice, bob, carol); } - test(env, USD, std::nullopt, STPath(), tecPATH_DRY); + test(env, usd, std::nullopt, STPath(), tecPATH_DRY); - env(pay(gw, alice, USD(100))); - env(pay(gw, carol, USD(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, carol, usd(100))); // Insert implied account test( env, - USD, + usd, std::nullopt, STPath(), tesSUCCESS, - makeEndpointStep(alice, gw, USD), - makeEndpointStep(gw, bob, USD)); + makeEndpointStep(alice, gw, usd), + makeEndpointStep(gw, bob, usd)); if constexpr (std::is_same_v) { - MPTTester(env, gw, EUR).authorizeHolders({alice, bob}); + MPTTester(env, gw, eur).authorizeHolders({alice, bob}); } else { - env.trust(EUR(1'000), alice, bob); + env.trust(eur(1'000), alice, bob); } // Insert implied offer test( env, - EUR, - USD, + eur, + usd, STPath(), tesSUCCESS, - makeEndpointStep(alice, gw, USD), - B{USD, EUR, std::nullopt}, - makeEndpointStep(gw, bob, EUR)); + makeEndpointStep(alice, gw, usd), + B{usd, eur, std::nullopt}, + makeEndpointStep(gw, bob, eur)); // Path with explicit offer test( env, - EUR, - USD, - STPath({ipe(EUR)}), + eur, + usd, + STPath({ipe(eur)}), tesSUCCESS, - makeEndpointStep(alice, gw, USD), - B{USD, EUR, std::nullopt}, - makeEndpointStep(gw, bob, EUR)); + makeEndpointStep(alice, gw, usd), + B{usd, eur, std::nullopt}, + makeEndpointStep(gw, bob, eur)); // Path with XRP src currency test( env, - USD, + usd, xrpIssue(), - STPath({ipe(USD)}), + STPath({ipe(usd)}), tesSUCCESS, XRPS{alice}, - B{XRP, USD, std::nullopt}, - makeEndpointStep(gw, bob, USD)); + B{XRP, usd, std::nullopt}, + makeEndpointStep(gw, bob, usd)); // Path with XRP dst currency. test( env, xrpIssue(), - USD, + usd, STPath({STPathElement{ - STPathElement::typeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()}}), + STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()}}), tesSUCCESS, - makeEndpointStep(alice, gw, USD), - B{USD, XRP, std::nullopt}, + makeEndpointStep(alice, gw, usd), + B{usd, XRP, std::nullopt}, XRPS{bob}); // Path with XRP cross currency bridged payment test( env, - EUR, - USD, + eur, + usd, STPath({cpe(xrpCurrency())}), tesSUCCESS, - makeEndpointStep(alice, gw, USD), - B{USD, XRP, std::nullopt}, - B{XRP, EUR, std::nullopt}, - makeEndpointStep(gw, bob, EUR)); + makeEndpointStep(alice, gw, usd), + B{usd, XRP, std::nullopt}, + B{XRP, eur, std::nullopt}, + makeEndpointStep(gw, bob, eur)); // Create an offer with the same in/out issue - test(env, EUR, USD, STPath({ipe(USD), ipe(EUR)}), temBAD_PATH); + test(env, eur, usd, STPath({ipe(usd), ipe(eur)}), temBAD_PATH); // The same offer can't appear more than once on a path - test(env, EUR, USD, STPath({ipe(EUR), ipe(USD), ipe(EUR)}), temBAD_PATH_LOOP); + test(env, eur, usd, STPath({ipe(eur), ipe(usd), ipe(eur)}), temBAD_PATH_LOOP); }; testHelper2TokensMix(testMultiToken); } @@ -290,32 +290,32 @@ struct PayStrandMPT_test : public beast::unit_test::suite env.fund(XRP(10'000), alice, bob, carol, gw); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 10'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 10'000}); - env(pay(gw, bob, USD(100))); - env(pay(gw, bob, EUR(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, bob, eur(100))); - env(offer(bob, XRP(100), USD(100))); - env(offer(bob, USD(100), EUR(100)), txflags(tfPassive)); - env(offer(bob, EUR(100), USD(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100))); + env(offer(bob, usd(100), eur(100)), Txflags(tfPassive)); + env(offer(bob, eur(100), usd(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/EUR -> EUR/USD - env(pay(alice, carol, USD(100)), - path(~USD, ~EUR, ~USD), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, usd(100)), + Path(~usd, ~eur, ~usd), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper2TokensMix(testMultiToken); } @@ -324,32 +324,32 @@ struct PayStrandMPT_test : public beast::unit_test::suite // check global freeze Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - auto USDM = MPTTester( + auto usdm = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob}, - .flags = MPTDEXFlags | tfMPTCanLock, + .flags = kMPT_DEX_FLAGS | tfMPTCanLock, .maxAmt = 1'000}); - MPT const USD = USDM; - env(pay(gw, alice, USD(100))); + MPT const usd = usdm; + env(pay(gw, alice, usd(100))); // Account can't issue payments - USDM.set({.holder = alice, .flags = tfMPTLock}); - test(env, USD, std::nullopt, STPath(), terLOCKED); - USDM.set({.holder = alice, .flags = tfMPTUnlock}); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + usdm.set({.holder = alice, .flags = tfMPTLock}); + test(env, usd, std::nullopt, STPath(), terLOCKED); + usdm.set({.holder = alice, .flags = tfMPTUnlock}); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); // Account can not issue funds - USDM.set({.flags = tfMPTLock}); - test(env, USD, std::nullopt, STPath(), terLOCKED); - USDM.set({.flags = tfMPTUnlock}); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + usdm.set({.flags = tfMPTLock}); + test(env, usd, std::nullopt, STPath(), terLOCKED); + usdm.set({.flags = tfMPTUnlock}); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); // Account can not receive funds - USDM.set({.holder = bob, .flags = tfMPTLock}); - test(env, USD, std::nullopt, STPath(), terLOCKED); - USDM.set({.holder = bob, .flags = tfMPTUnlock}); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + usdm.set({.holder = bob, .flags = tfMPTLock}); + test(env, usd, std::nullopt, STPath(), terLOCKED); + usdm.set({.holder = bob, .flags = tfMPTUnlock}); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); } { @@ -358,49 +358,49 @@ struct PayStrandMPT_test : public beast::unit_test::suite // issuer Env env(*this, features); env.fund(XRP(10'000), alice, bob, gw); - auto USDM = MPTTester( + auto usdm = MPTTester( {.env = env, .issuer = gw, - .flags = MPTDEXFlags | tfMPTRequireAuth, + .flags = kMPT_DEX_FLAGS | tfMPTRequireAuth, .maxAmt = 1'000}); - MPT const USD = USDM; + MPT const usd = usdm; // Authorize alice but not bob - USDM.authorize({.account = alice}); - USDM.authorize({.holder = alice}); - env(pay(gw, alice, USD(100))); - env.require(balance(alice, USD(100))); - test(env, USD, std::nullopt, STPath(), tecNO_AUTH); + usdm.authorize({.account = alice}); + usdm.authorize({.holder = alice}); + env(pay(gw, alice, usd(100))); + env.require(Balance(alice, usd(100))); + test(env, usd, std::nullopt, STPath(), tecNO_AUTH); // Check pure issue redeem still works auto [ter, strand] = toStrand( *env.current(), alice, gw, - USD, + usd, std::nullopt, std::nullopt, STPath(), true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getLogs().journal("Flow")); BEAST_EXPECT(ter == tesSUCCESS); - BEAST_EXPECT(equal(strand, M{alice, gw, USD})); + BEAST_EXPECT(equal(strand, M{alice, gw, usd})); } { // last step xrp from offer Env env(*this, features); env.fund(XRP(10'000), alice, bob, gw); - MPT const USD = + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 1'000}); - env(pay(gw, alice, USD(100))); + env(pay(gw, alice, usd(100))); // alice -> USD/XRP -> bob STPath path; - path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt); + path.emplaceBack(std::nullopt, xrpCurrency(), std::nullopt); auto [ter, strand] = toStrand( *env.current(), @@ -408,16 +408,16 @@ struct PayStrandMPT_test : public beast::unit_test::suite bob, XRP, std::nullopt, - USD, + usd, path, false, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getLogs().journal("Flow")); BEAST_EXPECT(ter == tesSUCCESS); BEAST_EXPECT( - equal(strand, M{alice, gw, USD}, B{USD, xrpIssue(), std::nullopt}, XRPS{bob})); + equal(strand, M{alice, gw, usd}, B{usd, xrpIssue(), std::nullopt}, XRPS{bob})); } } @@ -436,39 +436,39 @@ struct PayStrandMPT_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .maxAmt = 10'000}); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/XRP env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_PATHS)); + Path(~usd, ~XRP), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_PATHS)); } { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .maxAmt = 10'000}); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/XRP env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_MAX)); + Path(~usd, ~XRP), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_MAX)); } } @@ -482,67 +482,67 @@ struct PayStrandMPT_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const EUR = gw["EUR"]; - auto const CNY = gw["CNY"]; + auto const eur = gw["EUR"]; + auto const cny = gw["CNY"]; { Env env(*this, features); env.fund(XRP(10'000), alice, bob, carol, gw); - MPT const USD = MPTTester( + MPT const usd = MPTTester( {.env = env, .issuer = gw, .holders = {alice, bob, carol}, .maxAmt = 10'000}); - env(pay(gw, bob, USD(100))); - env(pay(gw, alice, USD(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, alice, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: USD -> USD/XRP -> XRP/USD - env(pay(alice, carol, USD(100)), - sendmax(USD(100)), - path(~XRP, ~USD), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, usd(100)), + Sendmax(usd(100)), + Path(~XRP, ~usd), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { auto testMultiToken = [&](auto&& issue1, auto&& issue2, auto&& issue3) { Env env(*this, features); env.fund(XRP(10'000), alice, bob, carol, gw); - auto const USD = issue1( + auto const usd = issue1( {.env = env, .token = "USD", .issuer = gw, .holders = {alice, bob, carol}, .limit = 10'000}); - auto const EUR = issue2( + auto const eur = issue2( {.env = env, .token = "EUR", .issuer = gw, .holders = {alice, bob, carol}, .limit = 10'000}); - auto const CNY = issue3( + auto const cny = issue3( {.env = env, .token = "CNY", .issuer = gw, .holders = {alice, bob, carol}, .limit = 10'000}); - env(pay(gw, bob, USD(100))); - env(pay(gw, bob, EUR(100))); - env(pay(gw, bob, CNY(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, bob, eur(100))); + env(pay(gw, bob, cny(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), EUR(100)), txflags(tfPassive)); - env(offer(bob, EUR(100), CNY(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), eur(100)), Txflags(tfPassive)); + env(offer(bob, eur(100), cny(100)), Txflags(tfPassive)); // payment path: XRP->XRP/USD->USD/EUR->USD/CNY - env(pay(alice, carol, CNY(100)), - sendmax(XRP(100)), - path(~USD, ~EUR, ~USD, ~CNY), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, cny(100)), + Sendmax(XRP(100)), + Path(~usd, ~eur, ~usd, ~cny), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); }; testHelper3TokensMix(testMultiToken); } @@ -560,9 +560,9 @@ struct PayStrandMPT_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10'000), alice, bob, gw); - MPT const USD = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); + MPT const usd = MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}}); - STAmount const sendMax{USD, 100, 1}; + STAmount const sendMax{usd, 100, 1}; STAmount const noAccountAmount{MPTIssue{0, noAccount()}, 100, 1}; STAmount const deliver; AccountID const srcAcc = alice.id(); @@ -572,7 +572,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite inputs.defaultPathsAllowed = true; try { - PaymentSandbox sb{env.current().get(), tapNONE}; + PaymentSandbox sb{env.current().get(), TapNone}; { auto const r = ::xrpl::path::RippleCalc::rippleCalculate( sb, @@ -636,7 +636,7 @@ struct PayStrandMPT_test : public beast::unit_test::suite run() override { using namespace jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testToStrand(sa); testRIPD1373(sa); diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 161903ee6d..78b152d690 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -49,22 +49,22 @@ namespace xrpl::test { -enum class TrustFlag { freeze, auth, noripple }; +enum class TrustFlag { Freeze, Auth, Noripple }; /*constexpr*/ std::uint32_t trustFlag(TrustFlag f, bool useHigh) { switch (f) { - case TrustFlag::freeze: + case TrustFlag::Freeze: if (useHigh) return lsfHighFreeze; return lsfLowFreeze; - case TrustFlag::auth: + case TrustFlag::Auth: if (useHigh) return lsfHighAuth; return lsfLowAuth; - case TrustFlag::noripple: + case TrustFlag::Noripple: if (useHigh) return lsfHighNoRipple; return lsfLowNoRipple; @@ -93,25 +93,25 @@ class ElementComboIter { enum class SB /*state bit*/ : std::uint16_t { - acc, - iss, - cur, - rootAcc, - rootIss, - xrp, - sameAccIss, - existingAcc, - existingCur, - existingIss, - prevAcc, - prevCur, - prevIss, - boundary, - last + Acc, + Iss, + Cur, + RootAcc, + RootIss, + Xrp, + SameAccIss, + ExistingAcc, + ExistingCur, + ExistingIss, + PrevAcc, + PrevCur, + PrevIss, + Boundary, + Last }; std::uint16_t state_ = 0; - static_assert(safe_cast(SB::last) <= sizeof(decltype(state_)) * 8, ""); + static_assert(safeCast(SB::Last) <= sizeof(decltype(state_)) * 8, ""); STPathElement const* prev_ = nullptr; // disallow iss and cur to be specified with acc is specified (simplifies // some tests) @@ -120,7 +120,7 @@ class ElementComboIter [[nodiscard]] bool has(SB s) const { - return (state_ & (1 << safe_cast(s))) != 0; + return (state_ & (1 << safeCast(s))) != 0; } [[nodiscard]] bool @@ -155,34 +155,34 @@ public: [[nodiscard]] bool valid() const { - return (allowCompound_ || !(has(SB::acc) && hasAny({SB::cur, SB::iss}))) && - (!hasAny({SB::prevAcc, SB::prevCur, SB::prevIss}) || (prev_ != nullptr)) && - (!hasAny({SB::rootAcc, SB::sameAccIss, SB::existingAcc, SB::prevAcc}) || - has(SB::acc)) && - (!hasAny({SB::rootIss, SB::sameAccIss, SB::existingIss, SB::prevIss}) || - has(SB::iss)) && - (!hasAny({SB::xrp, SB::existingCur, SB::prevCur}) || has(SB::cur)) && + return (allowCompound_ || !(has(SB::Acc) && hasAny({SB::Cur, SB::Iss}))) && + (!hasAny({SB::PrevAcc, SB::PrevCur, SB::PrevIss}) || (prev_ != nullptr)) && + (!hasAny({SB::RootAcc, SB::SameAccIss, SB::ExistingAcc, SB::PrevAcc}) || + has(SB::Acc)) && + (!hasAny({SB::RootIss, SB::SameAccIss, SB::ExistingIss, SB::PrevIss}) || + has(SB::Iss)) && + (!hasAny({SB::Xrp, SB::ExistingCur, SB::PrevCur}) || has(SB::Cur)) && // These will be duplicates - (count({SB::xrp, SB::existingCur, SB::prevCur}) <= 1) && - (count({SB::rootAcc, SB::existingAcc, SB::prevAcc}) <= 1) && - (count({SB::rootIss, SB::existingIss, SB::rootIss}) <= 1); + (count({SB::Xrp, SB::ExistingCur, SB::PrevCur}) <= 1) && + (count({SB::RootAcc, SB::ExistingAcc, SB::PrevAcc}) <= 1) && + (count({SB::RootIss, SB::ExistingIss, SB::RootIss}) <= 1); } bool next() { - if (!(has(SB::last))) + if (!(has(SB::Last))) { do { ++state_; } while (!valid()); } - return !has(SB::last); + return !has(SB::Last); } template void - emplace_into( + emplaceInto( Col& col, AccFactory&& accF, IssFactory&& issF, @@ -191,45 +191,45 @@ public: std::optional const& existingCur, std::optional const& existingIss) { - assert(!has(SB::last)); + assert(!has(SB::Last)); auto const acc = [&]() -> std::optional { - if (!has(SB::acc)) + if (!has(SB::Acc)) return std::nullopt; - if (has(SB::rootAcc)) + if (has(SB::RootAcc)) return xrpAccount(); - if (has(SB::existingAcc) && existingAcc) + if (has(SB::ExistingAcc) && existingAcc) return existingAcc; return accF().id(); }(); auto const iss = [&]() -> std::optional { - if (!has(SB::iss)) + if (!has(SB::Iss)) return std::nullopt; - if (has(SB::rootIss)) + if (has(SB::RootIss)) return xrpAccount(); - if (has(SB::sameAccIss)) + if (has(SB::SameAccIss)) return acc; - if (has(SB::existingIss) && existingIss) + if (has(SB::ExistingIss) && existingIss) return existingIss; return issF().id(); }(); auto const cur = [&]() -> std::optional { - if (!has(SB::cur)) + if (!has(SB::Cur)) return std::nullopt; - if (has(SB::xrp)) + if (has(SB::Xrp)) return xrpCurrency(); - if (has(SB::existingCur) && existingCur) + if (has(SB::ExistingCur) && existingCur) return existingCur; return currencyF(); }(); - if (!has(SB::boundary)) + if (!has(SB::Boundary)) { col.emplace_back(acc, cur, iss); } else { col.emplace_back( - STPathElement::Type::typeBoundary, + STPathElement::Type::TypeBoundary, acc.value_or(AccountID{}), cur.value_or(Currency{}), iss.value_or(AccountID{})); @@ -277,15 +277,15 @@ struct ExistingElementPool struct StateGuard { - ExistingElementPool& p_; - ResetState state_; + ExistingElementPool& p; + ResetState state; - explicit StateGuard(ExistingElementPool& p) : p_{p}, state_{p.getResetState()} + explicit StateGuard(ExistingElementPool& p) : p{p}, state{p.getResetState()} { } ~StateGuard() { - p_.resetTo(state_); + p.resetTo(state); } }; @@ -308,12 +308,12 @@ struct ExistingElementPool currencyNames.clear(); currencyNames.reserve(numCur); - constexpr size_t bufSize = 32; - char buf[bufSize]; + constexpr size_t kBUF_SIZE = 32; + char buf[kBUF_SIZE]; for (size_t id = 0; id < numAct; ++id) { - snprintf(buf, bufSize, "A%zu", id); + snprintf(buf, kBUF_SIZE, "A%zu", id); accounts.emplace_back(buf); } @@ -321,17 +321,17 @@ struct ExistingElementPool { if (id < 10) { - snprintf(buf, bufSize, "CC%zu", id); + snprintf(buf, kBUF_SIZE, "CC%zu", id); } else if (id < 100) { - snprintf(buf, bufSize, "C%zu", id); + snprintf(buf, kBUF_SIZE, "C%zu", id); } else { - snprintf(buf, bufSize, "%zu", id); + snprintf(buf, kBUF_SIZE, "%zu", id); } - currencies.emplace_back(to_currency(buf)); + currencies.emplace_back(toCurrency(buf)); currencyNames.emplace_back(buf); } @@ -381,7 +381,7 @@ struct ExistingElementPool if (owner.id() != takerGets->account.id()) env(pay(takerGets->account, owner, (*takerGets)(1000))); - env(offer(owner, (*takerPays)(1000), (*takerGets)(1000)), txflags(tfPassive)); + env(offer(owner, (*takerPays)(1000), (*takerGets)(1000)), Txflags(tfPassive)); } env.close(); } @@ -390,8 +390,8 @@ struct ExistingElementPool for (auto const& iou : ious) { auto const owner = offererIndex ? accounts[*offererIndex] : iou.account; - env(offer(owner, iou(1000), XRP(1000)), txflags(tfPassive)); - env(offer(owner, XRP(1000), iou(1000)), txflags(tfPassive)); + env(offer(owner, iou(1000), XRP(1000)), Txflags(tfPassive)); + env(offer(owner, XRP(1000), iou(1000)), Txflags(tfPassive)); env.close(); } } @@ -479,7 +479,7 @@ struct ExistingElementPool template void - for_each_element_pair( + forEachElementPair( STAmount const& sendMax, STAmount const& deliver, std::vector const& prefix, @@ -505,7 +505,7 @@ struct ExistingElementPool { StateGuard const og{*this}; outerResult = prefix; - outer.emplace_into( + outer.emplaceInto( outerResult, accF, issF, currencyF, existingAcc, existingCur, existingIss); STPathElement const* prevInner = &outerResult.back(); ElementComboIter inner(prevInner); @@ -513,7 +513,7 @@ struct ExistingElementPool { StateGuard const ig{*this}; result = outerResult; - inner.emplace_into( + inner.emplaceInto( result, accF, issF, currencyF, existingAcc, existingCur, existingIss); result.insert(result.end(), suffix.begin(), suffix.end()); f(sendMax, deliver, result); @@ -522,7 +522,7 @@ struct ExistingElementPool } }; -struct PayStrand_test : public beast::unit_test::suite +struct PayStrand_test : public beast::unit_test::Suite { void testToStrand(FeatureBitset features) @@ -536,11 +536,11 @@ struct PayStrand_test : public beast::unit_test::suite auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; - auto const eurC = EUR.currency; - auto const usdC = USD.currency; + auto const eurC = eur.currency; + auto const usdC = usd.currency; using D = DirectStepInfo; using B = xrpl::Book; @@ -564,7 +564,7 @@ struct PayStrand_test : public beast::unit_test::suite sendMaxIssue, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getJournal("Flow")); @@ -576,22 +576,22 @@ struct PayStrand_test : public beast::unit_test::suite { Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); - env(pay(gw, alice, EUR(100))); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); + env(pay(gw, alice, eur(100))); { - STPath const path = STPath({ipe(bob["USD"]), cpe(EUR.currency)}); + STPath const path = STPath({ipe(bob["USD"]), cpe(eur.currency)}); auto [ter, _] = toStrand( *env.current(), alice, alice, /*deliver*/ xrpIssue(), /*limitQuality*/ std::nullopt, - /*sendMaxIssue*/ EUR, + /*sendMaxIssue*/ eur, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getJournal("Flow")); @@ -599,17 +599,17 @@ struct PayStrand_test : public beast::unit_test::suite BEAST_EXPECT(isTesSuccess(ter)); } { - STPath const path = STPath({ipe(USD), cpe(xrpCurrency())}); + STPath const path = STPath({ipe(usd), cpe(xrpCurrency())}); auto [ter, _] = toStrand( *env.current(), alice, alice, /*deliver*/ xrpIssue(), /*limitQuality*/ std::nullopt, - /*sendMaxIssue*/ EUR, + /*sendMaxIssue*/ eur, path, true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getJournal("Flow")); @@ -622,39 +622,39 @@ struct PayStrand_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - test(env, USD, std::nullopt, STPath(), terNO_LINE); + test(env, usd, std::nullopt, STPath(), terNO_LINE); - env.trust(USD(1000), alice, bob, carol); - test(env, USD, std::nullopt, STPath(), tecPATH_DRY); + env.trust(usd(1000), alice, bob, carol); + test(env, usd, std::nullopt, STPath(), tecPATH_DRY); - env(pay(gw, alice, USD(100))); - env(pay(gw, carol, USD(100))); + env(pay(gw, alice, usd(100))); + env(pay(gw, carol, usd(100))); // Insert implied account test( - env, USD, std::nullopt, STPath(), tesSUCCESS, D{alice, gw, usdC}, D{gw, bob, usdC}); - env.trust(EUR(1000), alice, bob); + env, usd, std::nullopt, STPath(), tesSUCCESS, D{alice, gw, usdC}, D{gw, bob, usdC}); + env.trust(eur(1000), alice, bob); // Insert implied offer test( env, - EUR, - USD, + eur, + usd, STPath(), tesSUCCESS, D{alice, gw, usdC}, - B{USD, EUR, std::nullopt}, + B{usd, eur, std::nullopt}, D{gw, bob, eurC}); // Path with explicit offer test( env, - EUR, - USD, - STPath({ipe(EUR)}), + eur, + usd, + STPath({ipe(eur)}), tesSUCCESS, D{alice, gw, usdC}, - B{USD, EUR, std::nullopt}, + B{usd, eur, std::nullopt}, D{gw, bob, eurC}); // Path with offer that changes issuer only @@ -662,46 +662,46 @@ struct PayStrand_test : public beast::unit_test::suite test( env, carol["USD"], - USD, + usd, STPath({iape(carol)}), tesSUCCESS, D{alice, gw, usdC}, - B{USD, carol["USD"], std::nullopt}, + B{usd, carol["USD"], std::nullopt}, D{carol, bob, usdC}); // Path with XRP src currency test( env, - USD, + usd, xrpIssue(), - STPath({ipe(USD)}), + STPath({ipe(usd)}), tesSUCCESS, XRPS{alice}, - B{XRP, USD, std::nullopt}, + B{XRP, usd, std::nullopt}, D{gw, bob, usdC}); // Path with XRP dst currency. test( env, xrpIssue(), - USD, + usd, STPath({STPathElement{ - STPathElement::typeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()}}), + STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()}}), tesSUCCESS, D{alice, gw, usdC}, - B{USD, XRP, std::nullopt}, + B{usd, XRP, std::nullopt}, XRPS{bob}); // Path with XRP cross currency bridged payment test( env, - EUR, - USD, + eur, + usd, STPath({cpe(xrpCurrency())}), tesSUCCESS, D{alice, gw, usdC}, - B{USD, XRP, std::nullopt}, - B{XRP, EUR, std::nullopt}, + B{usd, XRP, std::nullopt}, + B{XRP, eur, std::nullopt}, D{gw, bob, eurC}); // XRP -> XRP transaction can't include a path @@ -718,10 +718,10 @@ struct PayStrand_test : public beast::unit_test::suite xrpAccount(), XRP, std::nullopt, - USD, + usd, STPath(), true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, flowJournal); @@ -738,7 +738,7 @@ struct PayStrand_test : public beast::unit_test::suite std::nullopt, STPath(), true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, flowJournal); @@ -750,12 +750,12 @@ struct PayStrand_test : public beast::unit_test::suite *env.current(), noAccount(), bob, - USD, + usd, std::nullopt, std::nullopt, STPath(), true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, flowJournal); @@ -764,12 +764,12 @@ struct PayStrand_test : public beast::unit_test::suite } // Create an offer with the same in/out issue - test(env, EUR, USD, STPath({ipe(USD), ipe(EUR)}), temBAD_PATH); + test(env, eur, usd, STPath({ipe(usd), ipe(eur)}), temBAD_PATH); // Path element with type zero test( env, - USD, + usd, std::nullopt, STPath({STPathElement(0, xrpAccount(), xrpCurrency(), xrpAccount())}), temBAD_PATH); @@ -777,10 +777,10 @@ struct PayStrand_test : public beast::unit_test::suite // The same account can't appear more than once on a path // `gw` will be used from alice->carol and implied between carol // and bob - test(env, USD, std::nullopt, STPath({ape(gw), ape(carol)}), temBAD_PATH_LOOP); + test(env, usd, std::nullopt, STPath({ape(gw), ape(carol)}), temBAD_PATH_LOOP); // The same offer can't appear more than once on a path - test(env, EUR, USD, STPath({ipe(EUR), ipe(USD), ipe(EUR)}), temBAD_PATH_LOOP); + test(env, eur, usd, STPath({ipe(eur), ipe(usd), ipe(eur)}), temBAD_PATH_LOOP); } { @@ -790,67 +790,67 @@ struct PayStrand_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - env.trust(USD(10000), alice, bob, carol); - env.trust(EUR(10000), alice, bob, carol); + env.trust(usd(10000), alice, bob, carol); + env.trust(eur(10000), alice, bob, carol); - env(pay(gw, bob, USD(100))); - env(pay(gw, bob, EUR(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, bob, eur(100))); - env(offer(bob, XRP(100), USD(100))); - env(offer(bob, USD(100), EUR(100)), txflags(tfPassive)); - env(offer(bob, EUR(100), USD(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100))); + env(offer(bob, usd(100), eur(100)), Txflags(tfPassive)); + env(offer(bob, eur(100), usd(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/EUR -> EUR/USD - env(pay(alice, carol, USD(100)), - path(~USD, ~EUR, ~USD), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, usd(100)), + Path(~usd, ~eur, ~usd), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { Env env(*this, features); env.fund(XRP(10000), alice, bob, noripple(gw)); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - test(env, USD, std::nullopt, STPath(), terNO_RIPPLE); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + test(env, usd, std::nullopt, STPath(), terNO_RIPPLE); } { // check global freeze Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); // Account can still issue payments env(fset(alice, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); env(fclear(alice, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); // Account can not issue funds env(fset(gw, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), terNO_LINE); + test(env, usd, std::nullopt, STPath(), terNO_LINE); env(fclear(gw, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); // Account can not receive funds env(fset(bob, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), terNO_LINE); + test(env, usd, std::nullopt, STPath(), terNO_LINE); env(fclear(bob, asfGlobalFreeze)); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); } { // Freeze between gw and alice Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); - test(env, USD, std::nullopt, STPath(), tesSUCCESS); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); + test(env, usd, std::nullopt, STPath(), tesSUCCESS); env(trust(gw, alice["USD"](0), tfSetFreeze)); - BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::freeze)); - test(env, USD, std::nullopt, STPath(), terNO_LINE); + BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::Freeze)); + test(env, usd, std::nullopt, STPath(), terNO_LINE); } { // check no auth @@ -859,25 +859,25 @@ struct PayStrand_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); env(fset(gw, asfRequireAuth)); - env.trust(USD(1000), alice, bob); + env.trust(usd(1000), alice, bob); // Authorize alice but not bob env(trust(gw, alice["USD"](1000), tfSetfAuth)); - BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::auth)); - env(pay(gw, alice, USD(100))); - env.require(balance(alice, USD(100))); - test(env, USD, std::nullopt, STPath(), terNO_AUTH); + BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::Auth)); + env(pay(gw, alice, usd(100))); + env.require(Balance(alice, usd(100))); + test(env, usd, std::nullopt, STPath(), terNO_AUTH); // Check pure issue redeem still works auto [ter, strand] = toStrand( *env.current(), alice, gw, - USD, + usd, std::nullopt, std::nullopt, STPath(), true, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getJournal("Flow")); @@ -889,12 +889,12 @@ struct PayStrand_test : public beast::unit_test::suite // last step xrp from offer Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - env.trust(USD(1000), alice, bob); - env(pay(gw, alice, USD(100))); + env.trust(usd(1000), alice, bob); + env(pay(gw, alice, usd(100))); // alice -> USD/XRP -> bob STPath path; - path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt); + path.emplaceBack(std::nullopt, xrpCurrency(), std::nullopt); auto [ter, strand] = toStrand( *env.current(), @@ -902,16 +902,16 @@ struct PayStrand_test : public beast::unit_test::suite bob, XRP, std::nullopt, - USD, + usd, path, false, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, env.app().getJournal("Flow")); BEAST_EXPECT(isTesSuccess(ter)); BEAST_EXPECT( - equal(strand, D{alice, gw, usdC}, B{USD, xrpIssue(), std::nullopt}, XRPS{bob})); + equal(strand, D{alice, gw, usdC}, B{usd, xrpIssue(), std::nullopt}, XRPS{bob})); } } @@ -925,75 +925,75 @@ struct PayStrand_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; { Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); env.trust(bob["USD"](1000), alice, gw); env.trust(bob["EUR"](1000), alice, gw); - env(offer(bob, XRP(100), bob["USD"](100)), txflags(tfPassive)); - env(offer(gw, XRP(100), USD(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), bob["USD"](100)), Txflags(tfPassive)); + env(offer(gw, XRP(100), usd(100)), Txflags(tfPassive)); - env(offer(bob, bob["USD"](100), bob["EUR"](100)), txflags(tfPassive)); - env(offer(gw, USD(100), EUR(100)), txflags(tfPassive)); + env(offer(bob, bob["USD"](100), bob["EUR"](100)), Txflags(tfPassive)); + env(offer(gw, usd(100), eur(100)), Txflags(tfPassive)); - Path const p = [&] { - Path result; - result.push_back(allPathElements(gw, bob["USD"])); - result.push_back(cpe(EUR.currency)); + TestPath const p = [&] { + TestPath result; + result.pushBack(allPathElements(gw, bob["USD"])); + result.pushBack(cpe(eur.currency)); return result; }(); PathSet const paths(p); - env(pay(alice, alice, EUR(1)), - json(paths.json()), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(temBAD_PATH)); + env(pay(alice, alice, eur(1)), + Json(paths.json()), + Sendmax(XRP(10)), + Txflags(tfNoRippleDirect | tfPartialPayment), + Ter(temBAD_PATH)); } { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - env.trust(USD(10000), alice, bob, carol); + env.trust(usd(10000), alice, bob, carol); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/XRP env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_PATHS)); + Path(~usd, ~XRP), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_PATHS)); } { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - env.trust(USD(10000), alice, bob, carol); + env.trust(usd(10000), alice, bob, carol); - env(pay(gw, bob, USD(100))); + env(pay(gw, bob, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: XRP -> XRP/USD -> USD/XRP env(pay(alice, carol, XRP(100)), - path(~USD, ~XRP), - sendmax(XRP(200)), - txflags(tfNoRippleDirect), - ter(temBAD_SEND_XRP_MAX)); + Path(~usd, ~XRP), + Sendmax(XRP(200)), + Txflags(tfNoRippleDirect), + Ter(temBAD_SEND_XRP_MAX)); } } @@ -1007,51 +1007,51 @@ struct PayStrand_test : public beast::unit_test::suite auto const bob = Account("bob"); auto const carol = Account("carol"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; - auto const CNY = gw["CNY"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; + auto const cny = gw["CNY"]; { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - env.trust(USD(10000), alice, bob, carol); + env.trust(usd(10000), alice, bob, carol); - env(pay(gw, bob, USD(100))); - env(pay(gw, alice, USD(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, alice, usd(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), XRP(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), XRP(100)), Txflags(tfPassive)); // payment path: USD -> USD/XRP -> XRP/USD - env(pay(alice, carol, USD(100)), - sendmax(USD(100)), - path(~XRP, ~USD), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, usd(100)), + Sendmax(usd(100)), + Path(~XRP, ~usd), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } { Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - env.trust(USD(10000), alice, bob, carol); - env.trust(EUR(10000), alice, bob, carol); - env.trust(CNY(10000), alice, bob, carol); + env.trust(usd(10000), alice, bob, carol); + env.trust(eur(10000), alice, bob, carol); + env.trust(cny(10000), alice, bob, carol); - env(pay(gw, bob, USD(100))); - env(pay(gw, bob, EUR(100))); - env(pay(gw, bob, CNY(100))); + env(pay(gw, bob, usd(100))); + env(pay(gw, bob, eur(100))); + env(pay(gw, bob, cny(100))); - env(offer(bob, XRP(100), USD(100)), txflags(tfPassive)); - env(offer(bob, USD(100), EUR(100)), txflags(tfPassive)); - env(offer(bob, EUR(100), CNY(100)), txflags(tfPassive)); + env(offer(bob, XRP(100), usd(100)), Txflags(tfPassive)); + env(offer(bob, usd(100), eur(100)), Txflags(tfPassive)); + env(offer(bob, eur(100), cny(100)), Txflags(tfPassive)); // payment path: XRP->XRP/USD->USD/EUR->USD/CNY - env(pay(alice, carol, CNY(100)), - sendmax(XRP(100)), - path(~USD, ~EUR, ~USD, ~CNY), - txflags(tfNoRippleDirect), - ter(temBAD_PATH_LOOP)); + env(pay(alice, carol, cny(100)), + Sendmax(XRP(100)), + Path(~usd, ~eur, ~usd, ~cny), + Txflags(tfNoRippleDirect), + Ter(temBAD_PATH_LOOP)); } } @@ -1064,13 +1064,13 @@ struct PayStrand_test : public beast::unit_test::suite auto const alice = Account("alice"); auto const bob = Account("bob"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env(*this, features); env.fund(XRP(10000), alice, bob, gw); - STAmount const sendMax{USD, 100, 1}; - STAmount const noAccountAmount{Issue{USD.currency, noAccount()}, 100, 1}; + STAmount const sendMax{usd, 100, 1}; + STAmount const noAccountAmount{Issue{usd.currency, noAccount()}, 100, 1}; STAmount const deliver; AccountID const srcAcc = alice.id(); AccountID const dstAcc = bob.id(); @@ -1079,7 +1079,7 @@ struct PayStrand_test : public beast::unit_test::suite inputs.defaultPathsAllowed = true; try { - PaymentSandbox sb{env.current().get(), tapNONE}; + PaymentSandbox sb{env.current().get(), TapNone}; { auto const r = ::xrpl::path::RippleCalc::rippleCalculate( sb, @@ -1143,7 +1143,7 @@ struct PayStrand_test : public beast::unit_test::suite run() override { using namespace jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testToStrand(sa - featurePermissionedDEX); testToStrand(sa); diff --git a/src/test/app/PermissionedDEX_test.cpp b/src/test/app/PermissionedDEX_test.cpp index 600f753c96..a0b16aa557 100644 --- a/src/test/app/PermissionedDEX_test.cpp +++ b/src/test/app/PermissionedDEX_test.cpp @@ -49,7 +49,7 @@ namespace xrpl::test { using namespace jtx; -class PermissionedDEX_test : public beast::unit_test::suite +class PermissionedDEX_test : public beast::unit_test::Suite { [[nodiscard]] static bool offerExists(Env const& env, Account const& account, std::uint32_t offerSeq) @@ -140,7 +140,7 @@ class PermissionedDEX_test : public beast::unit_test::suite static uint256 getBookDirKey(Book const& book, STAmount const& takerPays, STAmount const& takerGets) { - return keylet::quality(keylet::book(book), getRate(takerGets, takerPays)).key; + return keylet::quality(keylet::kBOOK(book), getRate(takerGets, takerPays)).key; } static std::optional @@ -181,22 +181,22 @@ class PermissionedDEX_test : public beast::unit_test::suite // test preflight { Env env(*this, features - featurePermissionedDEX); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), domain(domainID), ter(temDISABLED)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID), Ter(temDISABLED)); env.close(); env.enableFeature(featurePermissionedDEX); env.close(); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); } // preclaim - someone outside of the domain cannot create domain offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // create devin account who is not part of the domain @@ -205,10 +205,10 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); - env(offer(devin, XRP(10), USD(10)), domain(domainID), ter(tecNO_PERMISSION)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID), Ter(tecNO_PERMISSION)); env.close(); // domain owner also issues a credential for devin @@ -216,20 +216,20 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); // devin still cannot create offer since he didn't accept credential - env(offer(devin, XRP(10), USD(10)), domain(domainID), ter(tecNO_PERMISSION)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID), Ter(tecNO_PERMISSION)); env.close(); env(credentials::accept(devin, domainOwner, credType)); env.close(); - env(offer(devin, XRP(10), USD(10)), domain(domainID)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID)); env.close(); } // preclaim - someone with expired cred cannot create domain offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // create devin account who is not part of the domain @@ -238,7 +238,7 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); auto jv = credentials::create(devin, domainOwner, credType); @@ -250,27 +250,27 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); // devin can still create offer while his cred is not expired - env(offer(devin, XRP(10), USD(10)), domain(domainID)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID)); env.close(); // time advance env.close(std::chrono::seconds(20)); // devin cannot create offer with expired cred - env(offer(devin, XRP(10), USD(10)), domain(domainID), ter(tecNO_PERMISSION)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID), Ter(tecNO_PERMISSION)); env.close(); } // preclaim - cannot create an offer in a non existent domain { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); uint256 const badDomain{ "F10D0CC9A0F9A3CBF585B80BE09A186483668FDBDD39AA7E3370F3649CE134" "E5"}; - env(offer(bob, XRP(10), USD(10)), domain(badDomain), ter(tecNO_PERMISSION)); + env(offer(bob_, XRP(10), USD(10)), Domain(badDomain), Ter(tecNO_PERMISSION)); env.close(); } @@ -278,68 +278,68 @@ class PermissionedDEX_test : public beast::unit_test::suite // domain { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(credentials::deleteCred(domainOwner, gw, domainOwner, credType)); + env(credentials::deleteCred(domainOwner, gw_, domainOwner, credType)); env.close(); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); } // apply - offer can be created even if takerpays issuer is not in // domain { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(credentials::deleteCred(domainOwner, gw, domainOwner, credType)); + env(credentials::deleteCred(domainOwner, gw_, domainOwner, credType)); env.close(); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, USD(10), XRP(10)), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, USD(10), XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, USD(10), XRP(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, USD(10), XRP(10), 0, true)); } // apply - two domain offers cross with each other { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); - BEAST_EXPECT(ownerCount(env, bob) == 3); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(ownerCount(env, bob_) == 3); // a non domain offer cannot cross with domain offer - env(offer(carol, USD(10), XRP(10))); + env(offer(carol_, USD(10), XRP(10))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, USD(10), XRP(10)), domain(domainID)); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, USD(10), XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, alice, aliceOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, alice) == 2); + BEAST_EXPECT(!offerExists(env, alice_, aliceOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, alice_) == 2); } // apply - create lots of domain offers { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); std::vector offerSeqs; @@ -347,19 +347,19 @@ class PermissionedDEX_test : public beast::unit_test::suite for (size_t i = 0; i <= 100; i++) { - auto const bobOfferSeq{env.seq(bob)}; + auto const bobOfferSeq{env.seq(bob_)}; offerSeqs.emplace_back(bobOfferSeq); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); } for (auto const offerSeq : offerSeqs) { - env(offer_cancel(bob, offerSeq)); + env(offerCancel(bob_, offerSeq)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, offerSeq)); + BEAST_EXPECT(!offerExists(env, bob_, offerSeq)); } } } @@ -372,50 +372,50 @@ class PermissionedDEX_test : public beast::unit_test::suite // test preflight - without enabling featurePermissionedDEX amendment { Env env(*this, features - featurePermissionedDEX); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(pay(bob, alice, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(temDISABLED)); + env(pay(bob_, alice_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(temDISABLED)); env.close(); env.enableFeature(featurePermissionedDEX); env.close(); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - env(pay(bob, alice, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(bob_, alice_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); } // preclaim - cannot send payment with non existent domain { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); uint256 const badDomain{ "F10D0CC9A0F9A3CBF585B80BE09A186483668FDBDD39AA7E3370F3649CE134" "E5"}; - env(pay(bob, alice, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(badDomain), - ter(tecNO_PERMISSION)); + env(pay(bob_, alice_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(badDomain), + Ter(tecNO_PERMISSION)); env.close(); } // preclaim - payment with non-domain destination fails { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // create devin account who is not part of the domain @@ -424,15 +424,15 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); // devin is not part of domain - env(pay(alice, devin, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecNO_PERMISSION)); + env(pay(alice_, devin, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecNO_PERMISSION)); env.close(); // domain owner also issues a credential for devin @@ -440,28 +440,28 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); // devin has not yet accepted cred - env(pay(alice, devin, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecNO_PERMISSION)); + env(pay(alice_, devin, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecNO_PERMISSION)); env.close(); env(credentials::accept(devin, domainOwner, credType)); env.close(); // devin can now receive payment after he is in domain - env(pay(alice, devin, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice_, devin, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); } // preclaim - non-domain sender cannot send payment { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // create devin account who is not part of the domain @@ -470,15 +470,15 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); // devin tries to send domain payment - env(pay(devin, alice, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecNO_PERMISSION)); + env(pay(devin, alice_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecNO_PERMISSION)); env.close(); // domain owner also issues a credential for devin @@ -486,39 +486,39 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); // devin has not yet accepted cred - env(pay(devin, alice, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecNO_PERMISSION)); + env(pay(devin, alice_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecNO_PERMISSION)); env.close(); env(credentials::accept(devin, domainOwner, credType)); env.close(); // devin can now send payment after he is in domain - env(pay(devin, alice, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(devin, alice_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); } // apply - domain owner can always send and receive domain payment { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // domain owner can always be destination - env(pay(alice, domainOwner, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice_, domainOwner, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // domain owner can send - env(pay(domainOwner, alice, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(domainOwner, alice_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); } } @@ -531,46 +531,46 @@ class PermissionedDEX_test : public beast::unit_test::suite // test domain cross currency payment consuming one offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // create a regular offer without domain - auto const regularOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10))); + auto const regularOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, XRP(10), USD(10))); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, XRP(10), USD(10))); - auto const regularDirKey = getDefaultOfferDirKey(env, bob, regularOfferSeq); + auto const regularDirKey = getDefaultOfferDirKey(env, bob_, regularOfferSeq); BEAST_EXPECT(regularDirKey); BEAST_EXPECT(checkDirectorySize( env, *regularDirKey, 1)); // NOLINT(bugprone-unchecked-optional-access) // a domain payment cannot consume regular offers - env(pay(alice, carol, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); // create a domain offer - auto const domainOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const domainOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, domainOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, domainOfferSeq, XRP(10), USD(10), 0, true)); - auto const domainDirKey = getDefaultOfferDirKey(env, bob, domainOfferSeq); + auto const domainDirKey = getDefaultOfferDirKey(env, bob_, domainOfferSeq); BEAST_EXPECT(domainDirKey); BEAST_EXPECT(checkDirectorySize( env, *domainDirKey, 1)); // NOLINT(bugprone-unchecked-optional-access) // cross-currency permissioned payment consumed // domain offer instead of regular offer - env(pay(alice, carol, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice_, carol_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, domainOfferSeq)); - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, XRP(10), USD(10))); + BEAST_EXPECT(!offerExists(env, bob_, domainOfferSeq)); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, XRP(10), USD(10))); // domain directory is empty BEAST_EXPECT(checkDirectorySize( @@ -582,79 +582,79 @@ class PermissionedDEX_test : public beast::unit_test::suite // test domain payment consuming two offers in the path { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const EUR = gw["EUR"]; - env.trust(EUR(1000), alice); + auto const eur = gw_["EUR"]; + env.trust(eur(1000), alice_); env.close(); - env.trust(EUR(1000), bob); + env.trust(eur(1000), bob_); env.close(); - env.trust(EUR(1000), carol); + env.trust(eur(1000), carol_); env.close(); - env(pay(gw, bob, EUR(100))); + env(pay(gw_, bob_, eur(100))); env.close(); // create XRP/USD domain offer - auto const usdOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const usdOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(10), USD(10), 0, true)); // payment fail because there isn't eur offer - env(pay(alice, carol, EUR(10)), - path(~USD, ~EUR), - sendmax(XRP(10)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, eur(10)), + Path(~USD, ~eur), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(10), USD(10), 0, true)); - // bob creates a regular USD/EUR offer - auto const regularOfferSeq{env.seq(bob)}; - env(offer(bob, USD(10), EUR(10))); + // bob_ creates a regular USD/EUR offer + auto const regularOfferSeq{env.seq(bob_)}; + env(offer(bob_, USD(10), eur(10))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, USD(10), EUR(10))); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, USD(10), eur(10))); - // alice tries to pay again, but still fails because the regular + // alice_ tries to pay again, but still fails because the regular // offer cannot be consumed - env(pay(alice, carol, EUR(10)), - path(~USD, ~EUR), - sendmax(XRP(10)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, eur(10)), + Path(~USD, ~eur), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - // bob creates a domain USD/EUR offer - auto const eurOfferSeq{env.seq(bob)}; - env(offer(bob, USD(10), EUR(10)), domain(domainID)); + // bob_ creates a domain USD/EUR offer + auto const eurOfferSeq{env.seq(bob_)}; + env(offer(bob_, USD(10), eur(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(10), EUR(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(10), eur(10), 0, true)); - // alice successfully consume two domain offers: xrp/usd and usd/eur - env(pay(alice, carol, EUR(5)), sendmax(XRP(5)), domain(domainID), path(~USD, ~EUR)); + // alice_ successfully consume two domain offers: xrp/usd and usd/eur + env(pay(alice_, carol_, eur(5)), Sendmax(XRP(5)), Domain(domainID), Path(~USD, ~eur)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(5), USD(5), 0, true)); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(5), EUR(5), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(5), USD(5), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(5), eur(5), 0, true)); - // alice successfully consume two domain offers and deletes them + // alice_ successfully consume two domain offers and deletes them // we compute path this time using `paths` - env(pay(alice, carol, EUR(5)), sendmax(XRP(5)), domain(domainID), paths(XRP)); + env(pay(alice_, carol_, eur(5)), Sendmax(XRP(5)), Domain(domainID), Paths(XRP)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, usdOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, eurOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, usdOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, eurOfferSeq)); // regular offer is not consumed - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, USD(10), EUR(10))); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, USD(10), eur(10))); } // domain payment cannot consume offer from another domain { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // Fund devin and create USD trustline @@ -664,7 +664,7 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); auto const badCredType = "badCred"; @@ -679,28 +679,28 @@ class PermissionedDEX_test : public beast::unit_test::suite env(credentials::accept(devin, badDomainOwner, badCredType)); // devin creates a domain offer in another domain - env(offer(devin, XRP(10), USD(10)), domain(badDomainID)); + env(offer(devin, XRP(10), USD(10)), Domain(badDomainID)); env.close(); // domain payment can't consume an offer from another domain - env(pay(alice, carol, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(10)), + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - // bob creates an offer under the right domain - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + // bob_ creates an offer under the right domain + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); // domain payment now consumes from the right domain - env(pay(alice, carol, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice_, carol_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); } // sanity check: devin, who is part of the domain but doesn't have a @@ -708,10 +708,10 @@ class PermissionedDEX_test : public beast::unit_test::suite // offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // fund devin but don't create a USD trustline with gateway @@ -727,14 +727,14 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); // successful payment because offer is consumed - env(pay(devin, alice, USD(10)), sendmax(XRP(10)), domain(domainID)); + env(pay(devin, alice_, USD(10)), Sendmax(XRP(10)), Domain(domainID)); env.close(); } // offer becomes unfunded when offer owner's cred expires { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // create devin account who is not part of the domain @@ -743,7 +743,7 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(); env.trust(USD(1000), devin); env.close(); - env(pay(gw, devin, USD(100))); + env(pay(gw_, devin, USD(100))); env.close(); auto jv = credentials::create(devin, domainOwner, credType); @@ -756,11 +756,11 @@ class PermissionedDEX_test : public beast::unit_test::suite // devin can still create offer while his cred is not expired auto const offerSeq{env.seq(devin)}; - env(offer(devin, XRP(10), USD(10)), domain(domainID)); + env(offer(devin, XRP(10), USD(10)), Domain(domainID)); env.close(); // devin's offer can still be consumed while his cred isn't expired - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5)), domain(domainID)); + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5)), Domain(domainID)); env.close(); BEAST_EXPECT(checkOffer(env, devin, offerSeq, XRP(5), USD(5), 0, true)); @@ -768,11 +768,11 @@ class PermissionedDEX_test : public beast::unit_test::suite env.close(std::chrono::seconds(20)); // devin's offer is unfunded now due to expired cred - env(pay(alice, carol, USD(5)), - path(~USD), - sendmax(XRP(5)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(5)), + Path(~USD), + Sendmax(XRP(5)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); BEAST_EXPECT(checkOffer(env, devin, offerSeq, XRP(5), USD(5), 0, true)); } @@ -780,30 +780,30 @@ class PermissionedDEX_test : public beast::unit_test::suite // offer becomes unfunded when offer owner's cred is removed { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const offerSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const offerSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - // bob's offer can still be consumed while his cred exists - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5)), domain(domainID)); + // bob_'s offer can still be consumed while his cred exists + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, offerSeq, XRP(5), USD(5), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, offerSeq, XRP(5), USD(5), 0, true)); - // remove bob's cred - env(credentials::deleteCred(domainOwner, bob, domainOwner, credType)); + // remove bob_'s cred + env(credentials::deleteCred(domainOwner, bob_, domainOwner, credType)); env.close(); - // bob's offer is unfunded now due to expired cred - env(pay(alice, carol, USD(5)), - path(~USD), - sendmax(XRP(5)), - domain(domainID), - ter(tecPATH_PARTIAL)); + // bob_'s offer is unfunded now due to expired cred + env(pay(alice_, carol_, USD(5)), + Path(~USD), + Sendmax(XRP(5)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, offerSeq, XRP(5), USD(5), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, offerSeq, XRP(5), USD(5), 0, true)); } } @@ -816,34 +816,34 @@ class PermissionedDEX_test : public beast::unit_test::suite // payment. If the domain wishes to control who is allowed to ripple // through, they should set the rippling individually Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const EURA = alice["EUR"]; - auto const EURB = bob["EUR"]; + auto const eura = alice_["EUR"]; + auto const eurb = bob_["EUR"]; - env.trust(EURA(100), bob); - env.trust(EURB(100), carol); + env.trust(eura(100), bob_); + env.trust(eurb(100), carol_); env.close(); - // remove bob from domain - env(credentials::deleteCred(domainOwner, bob, domainOwner, credType)); + // remove bob_ from domain + env(credentials::deleteCred(domainOwner, bob_, domainOwner, credType)); env.close(); - // alice can still ripple through bob even though he's not part + // alice_ can still ripple through bob_ even though he's not part // of the domain, this is intentional - env(pay(alice, carol, EURB(10)), paths(EURA), domain(domainID)); + env(pay(alice_, carol_, eurb(10)), Paths(eura), Domain(domainID)); env.close(); - env.require(balance(bob, EURA(10)), balance(carol, EURB(10))); + env.require(Balance(bob_, eura(10)), Balance(carol_, eurb(10))); - // carol sets no ripple on bob - env(trust(carol, bob["EUR"](0), bob, tfSetNoRipple)); + // carol_ sets no ripple on bob_ + env(trust(carol_, bob_["EUR"](0), bob_, tfSetNoRipple)); env.close(); - // payment no longer works because carol has no ripple on bob - env(pay(alice, carol, EURB(5)), paths(EURA), domain(domainID), ter(tecPATH_DRY)); + // payment no longer works because carol_ has no ripple on bob_ + env(pay(alice_, carol_, eurb(5)), Paths(eura), Domain(domainID), Ter(tecPATH_DRY)); env.close(); - env.require(balance(bob, EURA(10)), balance(carol, EURB(10))); + env.require(Balance(bob_, eura(10)), Balance(carol_, eurb(10))); } void @@ -854,37 +854,37 @@ class PermissionedDEX_test : public beast::unit_test::suite // whether the issuer is in the domain should NOT affect whether an // offer can be consumed in domain payment Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // create an xrp/usd offer with usd as takergets - auto const bobOffer1Seq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const bobOffer1Seq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); // create an usd/xrp offer with usd as takerpays - auto const bobOffer2Seq{env.seq(bob)}; - env(offer(bob, USD(10), XRP(10)), domain(domainID), txflags(tfPassive)); + auto const bobOffer2Seq{env.seq(bob_)}; + env(offer(bob_, USD(10), XRP(10)), Domain(domainID), Txflags(tfPassive)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOffer1Seq, XRP(10), USD(10), 0, true)); - BEAST_EXPECT(checkOffer(env, bob, bobOffer2Seq, USD(10), XRP(10), lsfPassive, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOffer1Seq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOffer2Seq, USD(10), XRP(10), lsfPassive, true)); // remove gateway from domain - env(credentials::deleteCred(domainOwner, gw, domainOwner, credType)); + env(credentials::deleteCred(domainOwner, gw_, domainOwner, credType)); env.close(); // payment succeeds even if issuer is not in domain // xrp/usd offer is consumed - env(pay(alice, carol, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice_, carol_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, bobOffer1Seq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOffer1Seq)); // payment succeeds even if issuer is not in domain // usd/xrp offer is consumed - env(pay(alice, carol, XRP(10)), path(~XRP), sendmax(USD(10)), domain(domainID)); + env(pay(alice_, carol_, XRP(10)), Path(~XRP), Sendmax(USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, bobOffer2Seq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOffer2Seq)); } void @@ -895,36 +895,36 @@ class PermissionedDEX_test : public beast::unit_test::suite // checking that an unfunded offer will be implicitly removed by a // successful payment tx Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, XRP(100), USD(100)), domain(domainID)); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, XRP(100), USD(100)), Domain(domainID)); env.close(); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(20), USD(20)), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(20), USD(20)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(20), USD(20), 0, true)); - BEAST_EXPECT(checkOffer(env, alice, aliceOfferSeq, XRP(100), USD(100), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(20), USD(20), 0, true)); + BEAST_EXPECT(checkOffer(env, alice_, aliceOfferSeq, XRP(100), USD(100), 0, true)); - auto const domainDirKey = getDefaultOfferDirKey(env, bob, bobOfferSeq); + auto const domainDirKey = getDefaultOfferDirKey(env, bob_, bobOfferSeq); BEAST_EXPECT(domainDirKey); BEAST_EXPECT(checkDirectorySize( env, *domainDirKey, 2)); // NOLINT(bugprone-unchecked-optional-access) - // remove alice from domain and thus alice's offer becomes unfunded - env(credentials::deleteCred(domainOwner, alice, domainOwner, credType)); + // remove alice_ from domain and thus alice_'s offer becomes unfunded + env(credentials::deleteCred(domainOwner, alice_, domainOwner, credType)); env.close(); - env(pay(gw, carol, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(gw_, carol_, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); - // alice's unfunded offer is removed implicitly - BEAST_EXPECT(!offerExists(env, alice, aliceOfferSeq)); + // alice_'s unfunded offer is removed implicitly + BEAST_EXPECT(!offerExists(env, alice_, aliceOfferSeq)); BEAST_EXPECT(checkDirectorySize( env, *domainDirKey, 1)); // NOLINT(bugprone-unchecked-optional-access) } @@ -935,20 +935,20 @@ class PermissionedDEX_test : public beast::unit_test::suite testcase("AMM not used"); Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - AMM const amm(env, alice, XRP(10), USD(50)); + AMM const amm(env, alice_, XRP(10), USD(50)); // a domain payment isn't able to consume AMM - env(pay(bob, carol, USD(5)), - path(~USD), - sendmax(XRP(5)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(bob_, carol_, USD(5)), + Path(~USD), + Sendmax(XRP(5)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); // a non domain payment can use AMM - env(pay(bob, carol, USD(5)), path(~USD), sendmax(XRP(5))); + env(pay(bob_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5))); env.close(); // USD amount in AMM is changed @@ -964,126 +964,126 @@ class PermissionedDEX_test : public beast::unit_test::suite // test preflight - invalid hybrid flag { Env env(*this, features - featurePermissionedDEX); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - env(offer(bob, XRP(10), USD(10)), - domain(domainID), - txflags(tfHybrid), - ter(temDISABLED)); + env(offer(bob_, XRP(10), USD(10)), + Domain(domainID), + Txflags(tfHybrid), + Ter(temDISABLED)); env.close(); - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), ter(temINVALID_FLAG)); + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Ter(temINVALID_FLAG)); env.close(); env.enableFeature(featurePermissionedDEX); env.close(); // hybrid offer must have domainID - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), ter(temINVALID_FLAG)); + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Ter(temINVALID_FLAG)); env.close(); // hybrid offer must have domainID - auto const offerSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + auto const offerSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, offerSeq, XRP(10), USD(10), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, offerSeq, XRP(10), USD(10), lsfHybrid, true)); } // apply - domain offer can cross with hybrid { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); - BEAST_EXPECT(offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, bob) == 3); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); + BEAST_EXPECT(offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, bob_) == 3); - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, USD(10), XRP(10)), domain(domainID)); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, USD(10), XRP(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, alice, aliceOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, alice) == 2); + BEAST_EXPECT(!offerExists(env, alice_, aliceOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, alice_) == 2); } // apply - open offer can cross with hybrid { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); - BEAST_EXPECT(offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, bob) == 3); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); + BEAST_EXPECT(offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, bob_) == 3); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, USD(10), XRP(10))); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, USD(10), XRP(10))); env.close(); - BEAST_EXPECT(!offerExists(env, alice, aliceOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, alice) == 2); + BEAST_EXPECT(!offerExists(env, alice_, aliceOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, alice_) == 2); } // apply - by default, hybrid offer tries to cross with offers in the // domain book { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, true)); - BEAST_EXPECT(ownerCount(env, bob) == 3); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(ownerCount(env, bob_) == 3); // hybrid offer auto crosses with domain offer - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, USD(10), XRP(10)), domain(domainID), txflags(tfHybrid)); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, USD(10), XRP(10)), Domain(domainID), Txflags(tfHybrid)); env.close(); - BEAST_EXPECT(!offerExists(env, alice, aliceOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(ownerCount(env, alice) == 2); + BEAST_EXPECT(!offerExists(env, alice_, aliceOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(ownerCount(env, alice_) == 2); } // apply - hybrid offer does not automatically cross with open offers // because by default, it only tries to cross domain offers { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10))); + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, false)); - BEAST_EXPECT(ownerCount(env, bob) == 3); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, false)); + BEAST_EXPECT(ownerCount(env, bob_) == 3); // hybrid offer auto crosses with domain offer - auto const aliceOfferSeq{env.seq(alice)}; - env(offer(alice, USD(10), XRP(10)), domain(domainID), txflags(tfHybrid)); + auto const aliceOfferSeq{env.seq(alice_)}; + env(offer(alice_, USD(10), XRP(10)), Domain(domainID), Txflags(tfHybrid)); env.close(); - BEAST_EXPECT(offerExists(env, alice, aliceOfferSeq)); - BEAST_EXPECT(offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), 0, false)); - BEAST_EXPECT(checkOffer(env, alice, aliceOfferSeq, USD(10), XRP(10), lsfHybrid, true)); - BEAST_EXPECT(ownerCount(env, alice) == 3); + BEAST_EXPECT(offerExists(env, alice_, aliceOfferSeq)); + BEAST_EXPECT(offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), 0, false)); + BEAST_EXPECT(checkOffer(env, alice_, aliceOfferSeq, USD(10), XRP(10), lsfHybrid, true)); + BEAST_EXPECT(ownerCount(env, alice_) == 3); } } @@ -1092,45 +1092,45 @@ class PermissionedDEX_test : public beast::unit_test::suite { testcase("Hybrid invalid offer"); - // bob has a hybrid offer and then he is removed from domain. + // bob_ has a hybrid offer and then he is removed from domain. // in this case, the hybrid offer will be considered as unfunded even in // a regular payment Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const hybridOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(50), USD(50)), txflags(tfHybrid), domain(domainID)); + auto const hybridOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(50), USD(50)), Txflags(tfHybrid), Domain(domainID)); env.close(); - // remove bob from domain - env(credentials::deleteCred(domainOwner, bob, domainOwner, credType)); + // remove bob_ from domain + env(credentials::deleteCred(domainOwner, bob_, domainOwner, credType)); env.close(); - // bob's hybrid offer is unfunded and can not be consumed in a domain + // bob_'s hybrid offer is unfunded and can not be consumed in a domain // payment - env(pay(alice, carol, USD(5)), - path(~USD), - sendmax(XRP(5)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(5)), + Path(~USD), + Sendmax(XRP(5)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, hybridOfferSeq, XRP(50), USD(50), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, hybridOfferSeq, XRP(50), USD(50), lsfHybrid, true)); - // bob's unfunded hybrid offer can't be consumed even with a regular + // bob_'s unfunded hybrid offer can't be consumed even with a regular // payment - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5)), ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5)), Ter(tecPATH_PARTIAL)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, hybridOfferSeq, XRP(50), USD(50), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, hybridOfferSeq, XRP(50), USD(50), lsfHybrid, true)); // create a regular offer - auto const regularOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10))); + auto const regularOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10))); env.close(); - BEAST_EXPECT(offerExists(env, bob, regularOfferSeq)); - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, XRP(10), USD(10))); + BEAST_EXPECT(offerExists(env, bob_, regularOfferSeq)); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, XRP(10), USD(10))); - auto const sleHybridOffer = env.le(keylet::offer(bob.id(), hybridOfferSeq)); + auto const sleHybridOffer = env.le(keylet::offer(bob_.id(), hybridOfferSeq)); BEAST_EXPECT(sleHybridOffer); auto const openDir = sleHybridOffer->getFieldArray(sfAdditionalBooks)[0].getFieldH256(sfBookDirectory); @@ -1138,11 +1138,11 @@ class PermissionedDEX_test : public beast::unit_test::suite // this normal payment should consume the regular offer and remove the // unfunded hybrid offer - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5))); + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5))); env.close(); - BEAST_EXPECT(!offerExists(env, bob, hybridOfferSeq)); - BEAST_EXPECT(checkOffer(env, bob, regularOfferSeq, XRP(5), USD(5))); + BEAST_EXPECT(!offerExists(env, bob_, hybridOfferSeq)); + BEAST_EXPECT(checkOffer(env, bob_, regularOfferSeq, XRP(5), USD(5))); BEAST_EXPECT(checkDirectorySize(env, openDir, 1)); } @@ -1154,29 +1154,29 @@ class PermissionedDEX_test : public beast::unit_test::suite // both non domain and domain payments can consume hybrid offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const hybridOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + auto const hybridOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5)), domain(domainID)); + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, hybridOfferSeq, XRP(5), USD(5), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, hybridOfferSeq, XRP(5), USD(5), lsfHybrid, true)); - // hybrid offer can't be consumed since bob is not in domain anymore - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5))); + // hybrid offer can't be consumed since bob_ is not in domain anymore + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5))); env.close(); - BEAST_EXPECT(!offerExists(env, bob, hybridOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, hybridOfferSeq)); } // someone from another domain can't cross hybrid if they specified // wrong domainID { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); // Fund accounts @@ -1197,110 +1197,110 @@ class PermissionedDEX_test : public beast::unit_test::suite env(credentials::accept(devin, badDomainOwner, badCredType)); env.close(); - auto const hybridOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + auto const hybridOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); // other domains can't consume the offer env(pay(devin, badDomainOwner, USD(5)), - path(~USD), - sendmax(XRP(5)), - domain(badDomainID), - ter(tecPATH_DRY)); + Path(~USD), + Sendmax(XRP(5)), + Domain(badDomainID), + Ter(tecPATH_DRY)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, hybridOfferSeq, XRP(10), USD(10), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, hybridOfferSeq, XRP(10), USD(10), lsfHybrid, true)); - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5)), domain(domainID)); + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, hybridOfferSeq, XRP(5), USD(5), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, hybridOfferSeq, XRP(5), USD(5), lsfHybrid, true)); - // hybrid offer can't be consumed since bob is not in domain anymore - env(pay(alice, carol, USD(5)), path(~USD), sendmax(XRP(5))); + // hybrid offer can't be consumed since bob_ is not in domain anymore + env(pay(alice_, carol_, USD(5)), Path(~USD), Sendmax(XRP(5))); env.close(); - BEAST_EXPECT(!offerExists(env, bob, hybridOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, hybridOfferSeq)); } // test domain payment consuming two offers w/ hybrid offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const EUR = gw["EUR"]; - env.trust(EUR(1000), alice); + auto const eur = gw_["EUR"]; + env.trust(eur(1000), alice_); env.close(); - env.trust(EUR(1000), bob); + env.trust(eur(1000), bob_); env.close(); - env.trust(EUR(1000), carol); + env.trust(eur(1000), carol_); env.close(); - env(pay(gw, bob, EUR(100))); + env(pay(gw_, bob_, eur(100))); env.close(); - auto const usdOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), domain(domainID)); + auto const usdOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(10), USD(10), 0, true)); // payment fail because there isn't eur offer - env(pay(alice, carol, EUR(5)), - path(~USD, ~EUR), - sendmax(XRP(5)), - domain(domainID), - ter(tecPATH_PARTIAL)); + env(pay(alice_, carol_, eur(5)), + Path(~USD, ~eur), + Sendmax(XRP(5)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(10), USD(10), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(10), USD(10), 0, true)); - // bob creates a hybrid eur offer - auto const eurOfferSeq{env.seq(bob)}; - env(offer(bob, USD(10), EUR(10)), domain(domainID), txflags(tfHybrid)); + // bob_ creates a hybrid eur offer + auto const eurOfferSeq{env.seq(bob_)}; + env(offer(bob_, USD(10), eur(10)), Domain(domainID), Txflags(tfHybrid)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(10), EUR(10), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(10), eur(10), lsfHybrid, true)); - // alice successfully consume two domain offers: xrp/usd and usd/eur - env(pay(alice, carol, EUR(5)), path(~USD, ~EUR), sendmax(XRP(5)), domain(domainID)); + // alice_ successfully consume two domain offers: xrp/usd and usd/eur + env(pay(alice_, carol_, eur(5)), Path(~USD, ~eur), Sendmax(XRP(5)), Domain(domainID)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(5), USD(5), 0, true)); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(5), EUR(5), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(5), USD(5), 0, true)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(5), eur(5), lsfHybrid, true)); } // test regular payment using a regular offer and a hybrid offer { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const EUR = gw["EUR"]; - env.trust(EUR(1000), alice); + auto const eur = gw_["EUR"]; + env.trust(eur(1000), alice_); env.close(); - env.trust(EUR(1000), bob); + env.trust(eur(1000), bob_); env.close(); - env.trust(EUR(1000), carol); + env.trust(eur(1000), carol_); env.close(); - env(pay(gw, bob, EUR(100))); + env(pay(gw_, bob_, eur(100))); env.close(); - // bob creates a regular usd offer - auto const usdOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10))); + // bob_ creates a regular usd offer + auto const usdOfferSeq{env.seq(bob_)}; + env(offer(bob_, XRP(10), USD(10))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(10), USD(10), 0, false)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(10), USD(10), 0, false)); - // bob creates a hybrid eur offer - auto const eurOfferSeq{env.seq(bob)}; - env(offer(bob, USD(10), EUR(10)), domain(domainID), txflags(tfHybrid)); + // bob_ creates a hybrid eur offer + auto const eurOfferSeq{env.seq(bob_)}; + env(offer(bob_, USD(10), eur(10)), Domain(domainID), Txflags(tfHybrid)); env.close(); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(10), EUR(10), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(10), eur(10), lsfHybrid, true)); - // alice successfully consume two offers: xrp/usd and usd/eur - env(pay(alice, carol, EUR(5)), path(~USD, ~EUR), sendmax(XRP(5))); + // alice_ successfully consume two offers: xrp/usd and usd/eur + env(pay(alice_, carol_, eur(5)), Path(~USD, ~eur), Sendmax(XRP(5))); env.close(); - BEAST_EXPECT(checkOffer(env, bob, usdOfferSeq, XRP(5), USD(5), 0, false)); - BEAST_EXPECT(checkOffer(env, bob, eurOfferSeq, USD(5), EUR(5), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, usdOfferSeq, XRP(5), USD(5), 0, false)); + BEAST_EXPECT(checkOffer(env, bob_, eurOfferSeq, USD(5), eur(5), lsfHybrid, true)); } } @@ -1308,7 +1308,7 @@ class PermissionedDEX_test : public beast::unit_test::suite testHybridOfferDirectories(FeatureBitset features) { Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); std::vector offerSeqs; @@ -1324,12 +1324,12 @@ class PermissionedDEX_test : public beast::unit_test::suite for (size_t i = 1; i <= dirCnt; i++) { - auto const bobOfferSeq{env.seq(bob)}; + auto const bobOfferSeq{env.seq(bob_)}; offerSeqs.emplace_back(bobOfferSeq); - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + env(offer(bob_, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); - auto const sleOffer = env.le(keylet::offer(bob.id(), bobOfferSeq)); + auto const sleOffer = env.le(keylet::offer(bob_.id(), bobOfferSeq)); BEAST_EXPECT(sleOffer); BEAST_EXPECT(sleOffer->getFieldH256(sfBookDirectory) == domainDir); BEAST_EXPECT(sleOffer->getFieldArray(sfAdditionalBooks).size() == 1); @@ -1337,17 +1337,17 @@ class PermissionedDEX_test : public beast::unit_test::suite sleOffer->getFieldArray(sfAdditionalBooks)[0].getFieldH256(sfBookDirectory) == openDir); - BEAST_EXPECT(checkOffer(env, bob, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); + BEAST_EXPECT(checkOffer(env, bob_, bobOfferSeq, XRP(10), USD(10), lsfHybrid, true)); BEAST_EXPECT(checkDirectorySize(env, domainDir, i)); BEAST_EXPECT(checkDirectorySize(env, openDir, i)); } for (auto const offerSeq : offerSeqs) { - env(offer_cancel(bob, offerSeq)); + env(offerCancel(bob_, offerSeq)); env.close(); dirCnt--; - BEAST_EXPECT(!offerExists(env, bob, offerSeq)); + BEAST_EXPECT(!offerExists(env, bob_, offerSeq)); BEAST_EXPECT(checkDirectorySize(env, domainDir, dirCnt)); BEAST_EXPECT(checkDirectorySize(env, openDir, dirCnt)); } @@ -1359,34 +1359,34 @@ class PermissionedDEX_test : public beast::unit_test::suite testcase("Auto bridge"); Env env(*this, features); - auto const& [gw, domainOwner, alice, bob, carol, USD, domainID, credType] = + auto const& [gw_, domainOwner, alice_, bob_, carol_, USD, domainID, credType] = PermissionedDEX(env); - auto const EUR = gw["EUR"]; + auto const eur = gw_["EUR"]; - for (auto const& account : {alice, bob, carol}) + for (auto const& account : {alice_, bob_, carol_}) { - env(trust(account, EUR(10000))); + env(trust(account, eur(10000))); env.close(); } - env(pay(gw, carol, EUR(1))); + env(pay(gw_, carol_, eur(1))); env.close(); - auto const aliceOfferSeq{env.seq(alice)}; - auto const bobOfferSeq{env.seq(bob)}; - env(offer(alice, XRP(100), USD(1)), domain(domainID)); - env(offer(bob, EUR(1), XRP(100)), domain(domainID)); + auto const aliceOfferSeq{env.seq(alice_)}; + auto const bobOfferSeq{env.seq(bob_)}; + env(offer(alice_, XRP(100), USD(1)), Domain(domainID)); + env(offer(bob_, eur(1), XRP(100)), Domain(domainID)); env.close(); - // carol's offer should cross bob and alice's offers due to auto + // carol_'s offer should cross bob_ and alice_'s offers due to auto // bridging - auto const carolOfferSeq{env.seq(carol)}; - env(offer(carol, USD(1), EUR(1)), domain(domainID)); + auto const carolOfferSeq{env.seq(carol_)}; + env(offer(carol_, USD(1), eur(1)), Domain(domainID)); env.close(); - BEAST_EXPECT(!offerExists(env, bob, aliceOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, bobOfferSeq)); - BEAST_EXPECT(!offerExists(env, bob, carolOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, aliceOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, bobOfferSeq)); + BEAST_EXPECT(!offerExists(env, bob_, carolOfferSeq)); } void @@ -1419,7 +1419,7 @@ class PermissionedDEX_test : public beast::unit_test::suite // Create a valid hybrid offer (sfAdditionalBooks has exactly 1 entry) auto const bobOfferSeq{env.seq(bob)}; - env(offer(bob, XRP(10), USD(10)), txflags(tfHybrid), domain(domainID)); + env(offer(bob, XRP(10), USD(10)), Txflags(tfHybrid), Domain(domainID)); env.close(); BEAST_EXPECT(offerExists(env, bob, bobOfferSeq)); @@ -1442,17 +1442,17 @@ class PermissionedDEX_test : public beast::unit_test::suite // post-fixSecurity3_1_3: offerInDomain rejects the malformed // offer (size == 0), so no valid domain offer is found. env(pay(alice, carol, USD(10)), - path(~USD), - sendmax(XRP(10)), - domain(domainID), - ter(tecPATH_PARTIAL)); + Path(~USD), + Sendmax(XRP(10)), + Domain(domainID), + Ter(tecPATH_PARTIAL)); } else { // pre-fixSecurity3_1_3: offerInDomain only checks for a missing // sfAdditionalBooks field; size == 0 passes through, so the // malformed offer is crossed and the payment succeeds. - env(pay(alice, carol, USD(10)), path(~USD), sendmax(XRP(10)), domain(domainID)); + env(pay(alice, carol, USD(10)), Path(~USD), Sendmax(XRP(10)), Domain(domainID)); } } @@ -1460,7 +1460,7 @@ public: void run() override { - FeatureBitset const all{jtx::testable_amendments()}; + FeatureBitset const all{jtx::testableAmendments()}; // Test domain offer (w/o hybrid) testOfferCreate(all); diff --git a/src/test/app/PermissionedDomains_test.cpp b/src/test/app/PermissionedDomains_test.cpp index f94fc53f71..a49f913861 100644 --- a/src/test/app/PermissionedDomains_test.cpp +++ b/src/test/app/PermissionedDomains_test.cpp @@ -34,11 +34,11 @@ namespace xrpl::test { using namespace jtx; static std::string -exceptionExpected(Env& env, Json::Value const& jv) +exceptionExpected(Env& env, json::Value const& jv) { try { - env(jv, ter(temMALFORMED)); + env(jv, Ter(temMALFORMED)); } catch (std::exception const& ex) { @@ -47,15 +47,15 @@ exceptionExpected(Env& env, Json::Value const& jv) return {}; } -class PermissionedDomains_test : public beast::unit_test::suite +class PermissionedDomains_test : public beast::unit_test::Suite { - FeatureBitset withoutFeature_{testable_amendments() - featurePermissionedDomains}; + FeatureBitset withoutFeature_{testableAmendments() - featurePermissionedDomains}; FeatureBitset withFeature_{ - testable_amendments() // + testableAmendments() // | featurePermissionedDomains | featureCredentials}; FeatureBitset withFix_{ - testable_amendments() // + testableAmendments() // | featurePermissionedDomains | featureCredentials}; // Verify that each tx type can execute if the feature is enabled. @@ -81,7 +81,7 @@ class PermissionedDomains_test : public beast::unit_test::suite void testCredentialsDisabled() { - auto amendments = testable_amendments(); + auto amendments = testableAmendments(); amendments.set(featurePermissionedDomains); amendments.reset(featureCredentials); testcase("Credentials disabled"); @@ -89,7 +89,7 @@ class PermissionedDomains_test : public beast::unit_test::suite Env env(*this, amendments); env.fund(XRP(1000), alice); pdomain::Credentials const credentials{{alice, "first credential"}}; - env(pdomain::setTx(alice, credentials), ter(temDISABLED)); + env(pdomain::setTx(alice, credentials), Ter(temDISABLED)); } // Verify that each tx does not execute if feature is disabled @@ -101,8 +101,8 @@ class PermissionedDomains_test : public beast::unit_test::suite Env env(*this, withoutFeature_); env.fund(XRP(1000), alice); pdomain::Credentials const credentials{{alice, "first credential"}}; - env(pdomain::setTx(alice, credentials), ter(temDISABLED)); - env(pdomain::deleteTx(alice, uint256(75)), ter(temDISABLED)); + env(pdomain::setTx(alice, credentials), Ter(temDISABLED)); + env(pdomain::deleteTx(alice, uint256(75)), Ter(temDISABLED)); } // Verify that bad inputs fail for each of create new and update @@ -124,7 +124,7 @@ class PermissionedDomains_test : public beast::unit_test::suite auto const setFee(drops(env.current()->fees().increment)); // Test empty credentials. - env(pdomain::setTx(account, pdomain::Credentials(), domain), ter(temARRAY_EMPTY)); + env(pdomain::setTx(account, pdomain::Credentials(), domain), Ter(temARRAY_EMPTY)); // Test 11 credentials. pdomain::Credentials const credentials11{ @@ -139,8 +139,8 @@ class PermissionedDomains_test : public beast::unit_test::suite {alice10, "credential9"}, {alice11, "credential10"}, {alice12, "credential11"}}; - BEAST_EXPECT(credentials11.size() == maxPermissionedDomainCredentialsArraySize + 1); - env(pdomain::setTx(account, credentials11, domain), ter(temARRAY_TOO_LARGE)); + BEAST_EXPECT(credentials11.size() == kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE + 1); + env(pdomain::setTx(account, credentials11, domain), Ter(temARRAY_TOO_LARGE)); // Test credentials including non-existent issuer. Account const nobody("nobody"); @@ -152,10 +152,10 @@ class PermissionedDomains_test : public beast::unit_test::suite {alice5, "credential5"}, {alice6, "credential6"}, {alice7, "credential7"}}; - env(pdomain::setTx(account, credentialsNon, domain), ter(tecNO_ISSUER)); + env(pdomain::setTx(account, credentialsNon, domain), Ter(tecNO_ISSUER)); // Test bad fee - env(pdomain::setTx(account, credentials11, domain), fee(1, true), ter(temBAD_FEE)); + env(pdomain::setTx(account, credentials11, domain), Fee(1, true), Ter(temBAD_FEE)); pdomain::Credentials const credentials4{ {alice2, "credential1"}, @@ -173,15 +173,15 @@ class PermissionedDomains_test : public beast::unit_test::suite // Make an empty CredentialType. txJsonMutable["AcceptedCredentials"][2u] = credentialOrig; txJsonMutable["AcceptedCredentials"][2u][jss::Credential]["CredentialType"] = ""; - env(txJsonMutable, ter(temMALFORMED)); + env(txJsonMutable, Ter(temMALFORMED)); // Make too long CredentialType. - constexpr std::string_view longCredentialType = + constexpr std::string_view kLONG_CREDENTIAL_TYPE = "Cred0123456789012345678901234567890123456789012345678901234567890"; - static_assert(longCredentialType.size() == maxCredentialTypeLength + 1); + static_assert(kLONG_CREDENTIAL_TYPE.size() == kMAX_CREDENTIAL_TYPE_LENGTH + 1); txJsonMutable["AcceptedCredentials"][2u] = credentialOrig; txJsonMutable["AcceptedCredentials"][2u][jss::Credential]["CredentialType"] = - std::string(longCredentialType); + std::string(kLONG_CREDENTIAL_TYPE); BEAST_EXPECT(exceptionExpected(env, txJsonMutable).starts_with("invalidParams")); // Remove Credentialtype from a credential and apply. @@ -209,7 +209,7 @@ class PermissionedDomains_test : public beast::unit_test::suite auto const sorted = pdomain::sortCredentials(credentialsDup); BEAST_EXPECT(sorted.size() == 4); - env(pdomain::setTx(account, credentialsDup, domain), ter(temMALFORMED)); + env(pdomain::setTx(account, credentialsDup, domain), Ter(temMALFORMED)); env.close(); env(pdomain::setTx(account, sorted, domain)); @@ -270,7 +270,7 @@ class PermissionedDomains_test : public beast::unit_test::suite { testcase("Set"); Env env(*this, features); - env.set_parse_failure_expected(true); + env.setParseFailureExpected(true); int const accNum = 12; Account const alice[accNum] = { @@ -298,7 +298,7 @@ class PermissionedDomains_test : public beast::unit_test::suite { env(pdomain::setTx(alice[0], credentials1)); BEAST_EXPECT(env.ownerCount(alice[0]) == 1); - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); BEAST_EXPECT(tx[jss::TransactionType] == "PermissionedDomainSet"); BEAST_EXPECT(tx["Account"] == alice[0].human()); auto objects = pdomain::getObjects(alice[0], env); @@ -313,18 +313,19 @@ class PermissionedDomains_test : public beast::unit_test::suite // Make longest possible CredentialType. { - constexpr std::string_view longCredentialType = + constexpr std::string_view kLONG_CREDENTIAL_TYPE = "Cred0123456789012345678901234567890123456789012345678901234567" "89"; - static_assert(longCredentialType.size() == maxCredentialTypeLength); - pdomain::Credentials const longCredentials{{alice[1], std::string(longCredentialType)}}; + static_assert(kLONG_CREDENTIAL_TYPE.size() == kMAX_CREDENTIAL_TYPE_LENGTH); + pdomain::Credentials const longCredentials{ + {alice[1], std::string(kLONG_CREDENTIAL_TYPE)}}; env(pdomain::setTx(alice[0], longCredentials)); // One account can create multiple domains BEAST_EXPECT(env.ownerCount(alice[0]) == 2); - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); BEAST_EXPECT(tx[jss::TransactionType] == "PermissionedDomainSet"); BEAST_EXPECT(tx["Account"] == alice[0].human()); @@ -361,10 +362,10 @@ class PermissionedDomains_test : public beast::unit_test::suite }; uint256 domain2; { - BEAST_EXPECT(credentials10.size() == maxPermissionedDomainCredentialsArraySize); + BEAST_EXPECT(credentials10.size() == kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE); BEAST_EXPECT(credentials10 != pdomain::sortCredentials(credentials10)); env(pdomain::setTx(alice[0], credentials10)); - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); domain2 = pdomain::getNewDomain(env.meta()); auto objects = pdomain::getObjects(alice[0], env); auto object = objects[domain2]; @@ -387,16 +388,16 @@ class PermissionedDomains_test : public beast::unit_test::suite pdomain::sortCredentials(credentials10)); // Update from the wrong owner. - env(pdomain::setTx(alice[2], credentials1, domain2), ter(tecNO_PERMISSION)); + env(pdomain::setTx(alice[2], credentials1, domain2), Ter(tecNO_PERMISSION)); // Update a uint256(0) domain - env(pdomain::setTx(alice[0], credentials1, uint256(0)), ter(temMALFORMED)); + env(pdomain::setTx(alice[0], credentials1, uint256(0)), Ter(temMALFORMED)); // Update non-existent domain - env(pdomain::setTx(alice[0], credentials1, uint256(75)), ter(tecNO_ENTRY)); + env(pdomain::setTx(alice[0], credentials1, uint256(75)), Ter(tecNO_ENTRY)); // Wrong flag - env(pdomain::setTx(alice[0], credentials1), txflags(tfClawTwoAssets), ter(temINVALID_FLAG)); + env(pdomain::setTx(alice[0], credentials1), Txflags(tfClawTwoAssets), Ter(temINVALID_FLAG)); // Test bad data when creating a domain. testBadData(alice[0], env); @@ -405,13 +406,13 @@ class PermissionedDomains_test : public beast::unit_test::suite // Try to delete the account with domains. auto const acctDelFee(drops(env.current()->fees().increment)); - constexpr std::size_t deleteDelta = 255; + constexpr std::size_t kDELETE_DELTA = 255; { // Close enough ledgers to make it potentially deletable if empty. std::size_t const ownerSeq = env.seq(alice[0]); - while (deleteDelta + ownerSeq > env.current()->seq()) + while (kDELETE_DELTA + ownerSeq > env.current()->seq()) env.close(); - env(acctdelete(alice[0], alice[2]), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + env(acctdelete(alice[0], alice[2]), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); } { @@ -420,9 +421,9 @@ class PermissionedDomains_test : public beast::unit_test::suite env(pdomain::deleteTx(alice[0], objs.first)); env.close(); std::size_t const ownerSeq = env.seq(alice[0]); - while (deleteDelta + ownerSeq > env.current()->seq()) + while (kDELETE_DELTA + ownerSeq > env.current()->seq()) env.close(); - env(acctdelete(alice[0], alice[2]), fee(acctDelFee)); + env(acctdelete(alice[0], alice[2]), Fee(acctDelFee)); } } @@ -448,19 +449,19 @@ class PermissionedDomains_test : public beast::unit_test::suite // Delete a domain that doesn't belong to the account. Account const bob("bob"); env.fund(XRP(1000), bob); - env(pdomain::deleteTx(bob, domain), ter(tecNO_PERMISSION)); + env(pdomain::deleteTx(bob, domain), Ter(tecNO_PERMISSION)); // Delete a non-existent domain. - env(pdomain::deleteTx(alice, uint256(75)), ter(tecNO_ENTRY)); + env(pdomain::deleteTx(alice, uint256(75)), Ter(tecNO_ENTRY)); // Test bad fee - env(pdomain::deleteTx(alice, uint256(75)), ter(temBAD_FEE), fee(1, true)); + env(pdomain::deleteTx(alice, uint256(75)), Ter(temBAD_FEE), Fee(1, true)); // Wrong flag - env(pdomain::deleteTx(alice, domain), ter(temINVALID_FLAG), txflags(tfClawTwoAssets)); + env(pdomain::deleteTx(alice, domain), Ter(temINVALID_FLAG), Txflags(tfClawTwoAssets)); // Delete a zero domain. - env(pdomain::deleteTx(alice, uint256(0)), ter(temMALFORMED)); + env(pdomain::deleteTx(alice, uint256(0)), Ter(temMALFORMED)); // Make sure owner count reflects the existing domain. BEAST_EXPECT(env.ownerCount(alice) == 1); @@ -469,7 +470,7 @@ class PermissionedDomains_test : public beast::unit_test::suite // Delete domain that belongs to user. env(pdomain::deleteTx(alice, domain)); - auto const tx = env.tx()->getJson(JsonOptions::none); + auto const tx = env.tx()->getJson(JsonOptions::KNone); BEAST_EXPECT(tx[jss::TransactionType] == "PermissionedDomainDelete"); // Make sure the owner count goes back to 0. @@ -502,7 +503,7 @@ class PermissionedDomains_test : public beast::unit_test::suite // alice does not have enough XRP to cover the reserve. pdomain::Credentials const credentials{{alice, "first credential"}}; - env(pdomain::setTx(alice, credentials), ter(tecINSUFFICIENT_RESERVE)); + env(pdomain::setTx(alice, credentials), Ter(tecINSUFFICIENT_RESERVE)); BEAST_EXPECT(env.ownerCount(alice) == 0); BEAST_EXPECT(pdomain::getObjects(alice, env).empty()); env.close(); @@ -515,7 +516,7 @@ class PermissionedDomains_test : public beast::unit_test::suite env.close(); // alice still does not have enough XRP for the reserve. - env(pdomain::setTx(alice, credentials), ter(tecINSUFFICIENT_RESERVE)); + env(pdomain::setTx(alice, credentials), Ter(tecINSUFFICIENT_RESERVE)); env.close(); BEAST_EXPECT(env.ownerCount(alice) == 0); diff --git a/src/test/app/PseudoTx_test.cpp b/src/test/app/PseudoTx_test.cpp index 22c0cff075..9f65daad18 100644 --- a/src/test/app/PseudoTx_test.cpp +++ b/src/test/app/PseudoTx_test.cpp @@ -20,7 +20,7 @@ namespace xrpl::test { -struct PseudoTx_test : public beast::unit_test::suite +struct PseudoTx_test : public beast::unit_test::Suite { static std::vector getPseudoTxs(Rules const& rules, std::uint32_t seq) @@ -82,7 +82,7 @@ struct PseudoTx_test : public beast::unit_test::suite BEAST_EXPECT(!passesLocalChecks(stx, reason)); BEAST_EXPECT(reason == "Cannot submit pseudo transactions."); env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, stx, tapNONE, j); + auto const result = xrpl::apply(env.app(), view, stx, TapNone, j); BEAST_EXPECT(!result.applied && result.ter == temINVALID); return result.applied; }); @@ -104,7 +104,7 @@ struct PseudoTx_test : public beast::unit_test::suite run() override { using namespace test::jtx; - FeatureBitset const all{testable_amendments()}; + FeatureBitset const all{testableAmendments()}; FeatureBitset const xrpFees{featureXRPFees}; testPrevented(all - featureXRPFees); diff --git a/src/test/app/RCLValidations_test.cpp b/src/test/app/RCLValidations_test.cpp index 14b9979e07..6b3ea8cdbe 100644 --- a/src/test/app/RCLValidations_test.cpp +++ b/src/test/app/RCLValidations_test.cpp @@ -21,13 +21,13 @@ namespace xrpl::test { -class RCLValidations_test : public beast::unit_test::suite +class RCLValidations_test : public beast::unit_test::Suite { void testChangeTrusted() { testcase("Change validation trusted status"); - auto keys = randomKeyPair(KeyType::secp256k1); + auto keys = randomKeyPair(KeyType::Secp256k1); auto v = std::make_shared( xrpl::NetClock::time_point{}, keys.first, @@ -69,7 +69,7 @@ class RCLValidations_test : public beast::unit_test::suite jtx::Env env(*this); Config const config; auto prev = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{config.features}, config.FEES.toFees(), std::vector{}, @@ -235,7 +235,7 @@ class RCLValidations_test : public beast::unit_test::suite auto& j = env.journal; Config const config; auto prev = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{config.features}, config.FEES.toFees(), std::vector{}, @@ -253,37 +253,37 @@ class RCLValidations_test : public beast::unit_test::suite // First, create the single branch trie, with ledgers // separated by exactly 256 ledgers - auto ledg_002 = RCLValidatedLedger{history[1], j}; - auto ledg_258 = RCLValidatedLedger{history[257], j}; - auto ledg_259 = RCLValidatedLedger{history[258], j}; + auto ledg002 = RCLValidatedLedger{history[1], j}; + auto ledg258 = RCLValidatedLedger{history[257], j}; + auto ledg259 = RCLValidatedLedger{history[258], j}; - trie.insert(ledg_002); - trie.insert(ledg_258, 4); + trie.insert(ledg002); + trie.insert(ledg258, 4); // trie.dump(std::cout); // 000000[0,1)(T:0,B:5) // |-AB868A..36C8[1,3)(T:1,B:5) // |-AB868A..37C8[3,259)(T:4,B:4) - BEAST_EXPECT(trie.tipSupport(ledg_002) == 1); - BEAST_EXPECT(trie.branchSupport(ledg_002) == 5); - BEAST_EXPECT(trie.tipSupport(ledg_258) == 4); - BEAST_EXPECT(trie.branchSupport(ledg_258) == 4); + BEAST_EXPECT(trie.tipSupport(ledg002) == 1); + BEAST_EXPECT(trie.branchSupport(ledg002) == 5); + BEAST_EXPECT(trie.tipSupport(ledg258) == 4); + BEAST_EXPECT(trie.branchSupport(ledg258) == 4); // Move three of the s258 ledgers to s259, which splits the trie // due to the 256 ancestry limit - BEAST_EXPECT(trie.remove(ledg_258, 3)); - trie.insert(ledg_259, 3); + BEAST_EXPECT(trie.remove(ledg258, 3)); + trie.insert(ledg259, 3); [[maybe_unused]] auto unused1 = trie.getPreferred(1); // trie.dump(std::cout); // 000000[0,1)(T:0,B:5) // |-AB868A..37C9[1,260)(T:3,B:3) // |-AB868A..36C8[1,3)(T:1,B:2) // |-AB868A..37C8[3,259)(T:1,B:1) - BEAST_EXPECT(trie.tipSupport(ledg_002) == 1); - BEAST_EXPECT(trie.branchSupport(ledg_002) == 2); - BEAST_EXPECT(trie.tipSupport(ledg_258) == 1); - BEAST_EXPECT(trie.branchSupport(ledg_258) == 1); - BEAST_EXPECT(trie.tipSupport(ledg_259) == 3); - BEAST_EXPECT(trie.branchSupport(ledg_259) == 3); + BEAST_EXPECT(trie.tipSupport(ledg002) == 1); + BEAST_EXPECT(trie.branchSupport(ledg002) == 2); + BEAST_EXPECT(trie.tipSupport(ledg258) == 1); + BEAST_EXPECT(trie.branchSupport(ledg258) == 1); + BEAST_EXPECT(trie.tipSupport(ledg259) == 3); + BEAST_EXPECT(trie.branchSupport(ledg259) == 3); // The last call to trie.getPreferred cycled the children of the root // node to make the new branch the first child (since it has support 3) @@ -301,15 +301,15 @@ class RCLValidations_test : public beast::unit_test::suite // 000000[0,1)(T:0,B:5) // |-AB868A..37C9[1,260)(T:4,B:4) // |-AB868A..36C8[1,3)(T:1,B:1) - BEAST_EXPECT(trie.tipSupport(ledg_002) == 1); - BEAST_EXPECT(trie.branchSupport(ledg_002) == 1); - BEAST_EXPECT(trie.tipSupport(ledg_258) == 0); + BEAST_EXPECT(trie.tipSupport(ledg002) == 1); + BEAST_EXPECT(trie.branchSupport(ledg002) == 1); + BEAST_EXPECT(trie.tipSupport(ledg258) == 0); // 258 no longer lives on a tip in the tree, BUT it is an ancestor // of 259 which is a tip and therefore gets it's branchSupport value // implicitly - BEAST_EXPECT(trie.branchSupport(ledg_258) == 4); - BEAST_EXPECT(trie.tipSupport(ledg_259) == 4); - BEAST_EXPECT(trie.branchSupport(ledg_259) == 4); + BEAST_EXPECT(trie.branchSupport(ledg258) == 4); + BEAST_EXPECT(trie.tipSupport(ledg259) == 4); + BEAST_EXPECT(trie.branchSupport(ledg259) == 4); } public: diff --git a/src/test/app/ReducedOffer_test.cpp b/src/test/app/ReducedOffer_test.cpp index a6d7160071..4a2c2dba0a 100644 --- a/src/test/app/ReducedOffer_test.cpp +++ b/src/test/app/ReducedOffer_test.cpp @@ -26,21 +26,21 @@ namespace xrpl::test { -class ReducedOffer_test : public beast::unit_test::suite +class ReducedOffer_test : public beast::unit_test::Suite { static auto - ledgerEntryOffer(jtx::Env& env, jtx::Account const& acct, std::uint32_t offer_seq) + ledgerEntryOffer(jtx::Env& env, jtx::Account const& acct, std::uint32_t offerSeq) { - Json::Value jvParams; + json::Value jvParams; jvParams[jss::offer][jss::account] = acct.human(); - jvParams[jss::offer][jss::seq] = offer_seq; + jvParams[jss::offer][jss::seq] = offerSeq; return env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; } static bool offerInLedger(jtx::Env& env, jtx::Account const& acct, std::uint32_t offerSeq) { - Json::Value ledgerOffer = ledgerEntryOffer(env, acct, offerSeq); + json::Value ledgerOffer = ledgerEntryOffer(env, acct, offerSeq); return !( ledgerOffer.isMember(jss::error) && ledgerOffer[jss::error].asString() == "entryNotFound"); @@ -53,7 +53,7 @@ class ReducedOffer_test : public beast::unit_test::suite std::initializer_list> list) { for (auto [acct, offerSeq] : list) - env(offer_cancel(acct, offerSeq)); + env(offerCancel(acct, offerSeq)); env.close(); } @@ -68,20 +68,20 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; // Make sure none of the offers we generate are under funded. env.fund(XRP(10'000'000), gw, alice, bob); env.close(); - env(trust(alice, USD(10'000'000))); - env(trust(bob, USD(10'000'000))); + env(trust(alice, usd(10'000'000))); + env(trust(bob, usd(10'000'000))); env.close(); - env(pay(gw, bob, USD(10'000'000))); + env(pay(gw, bob, usd(10'000'000))); env.close(); // Lambda that: @@ -102,7 +102,7 @@ public: std::uint32_t const bobOfferSeq = env.seq(bob); STAmount const bobInitialBalance = env.balance(bob); STAmount const bobFee = env.current()->fees().base; - env(offer(bob, newOffer.in, newOffer.out, tfSell), fee(bobFee)); + env(offer(bob, newOffer.in, newOffer.out, tfSell), Fee(bobFee)); env.close(); STAmount const bobFinalBalance = env.balance(bob); @@ -118,7 +118,7 @@ public: // bob's offer should be in the ledger, but reduced in size. unsigned int badRate = 1; { - Json::Value bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq); + json::Value bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq); STAmount const reducedTakerGets = amountFromJson(sfTakerGets, bobOffer[jss::node][sfTakerGets.jsonName]); @@ -167,7 +167,7 @@ public: }; // bob's offer (the new offer) is the same every time: - Amounts const bobOffer{STAmount(XRP(1)), STAmount(USD, 1, 0)}; + Amounts const bobOffer{STAmount(XRP(1)), STAmount(usd, 1, 0)}; // alice's offer has a slightly smaller TakerPays with each // iteration. This should mean that the size of the offer bob @@ -202,19 +202,19 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { // Make sure none of the offers we generate are under funded. - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; env.fund(XRP(10'000'000), gw, alice, bob); env.close(); - env(trust(alice, USD(10'000'000))); - env(trust(bob, USD(10'000'000))); + env(trust(alice, usd(10'000'000))); + env(trust(bob, usd(10'000'000))); env.close(); - env(pay(gw, alice, USD(10'000'000))); + env(pay(gw, alice, usd(10'000'000))); env.close(); // Lambda that: @@ -250,7 +250,7 @@ public: // size. unsigned int badRate = 1; { - Json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq); + json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq); STAmount const reducedTakerGets = amountFromJson(sfTakerGets, aliceOffer[jss::node][sfTakerGets.jsonName]); @@ -299,7 +299,7 @@ public: }; // alice's offer (the old offer) is the same every time: - Amounts const aliceOffer{STAmount(XRP(1)), STAmount(USD, 1, 0)}; + Amounts const aliceOffer{STAmount(XRP(1)), STAmount(usd, 1, 0)}; // bob's offer has a slightly smaller TakerPays with each iteration. // This should mean that the size of the offer alice leaves in the @@ -336,31 +336,31 @@ public: auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); + env.trust(usd(1000), alice, bob); int blockedOrderBookCount = 0; - for (STAmount initialBobUSD = USD(0.45); initialBobUSD <= USD(1); - initialBobUSD += USD(0.025)) + for (STAmount initialBobUSD = usd(0.45); initialBobUSD <= usd(1); + initialBobUSD += usd(0.025)) { // underfund bob's offer env(pay(gw, bob, initialBobUSD)); env.close(); std::uint32_t const bobOfferSeq = env.seq(bob); - env(offer(bob, drops(2), USD(1))); + env(offer(bob, drops(2), usd(1))); env.close(); // alice places an offer that would cross bob's if bob's were // well funded. std::uint32_t const aliceOfferSeq = env.seq(alice); - env(offer(alice, USD(1), drops(2))); + env(offer(alice, usd(1), drops(2))); env.close(); // We want to detect order book blocking. If: @@ -370,13 +370,13 @@ public: // order book. { bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq); - STAmount const aliceBalanceUSD = env.balance(alice, USD); + STAmount const aliceBalanceUSD = env.balance(alice, usd); // Sanity check the ledger if alice got USD. if (aliceBalanceUSD.signum() > 0) { BEAST_EXPECT(aliceBalanceUSD == initialBobUSD); - BEAST_EXPECT(env.balance(bob, USD) == USD(0)); + BEAST_EXPECT(env.balance(bob, usd) == usd(0)); BEAST_EXPECT(bobOfferGone); } @@ -391,11 +391,11 @@ public: cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); // Zero out alice's and bob's USD balances. - if (STAmount const aliceBalance = env.balance(alice, USD); + if (STAmount const aliceBalance = env.balance(alice, usd); aliceBalance.signum() > 0) env(pay(alice, gw, aliceBalance)); - if (STAmount const bobBalance = env.balance(bob, USD); bobBalance.signum() > 0) + if (STAmount const bobBalance = env.balance(bob, usd); bobBalance.signum() > 0) env(pay(bob, gw, bobBalance)); env.close(); @@ -421,23 +421,23 @@ public: auto const bob = Account{"bob"}; auto const gw = Account{"gw"}; - auto const USD = gw["USD"]; - auto const EUR = gw["EUR"]; + auto const usd = gw["USD"]; + auto const eur = gw["EUR"]; - STAmount const tinyUSD(USD, /*mantissa*/ 1, /*exponent*/ -81); + STAmount const tinyUSD(usd, /*mantissa*/ 1, /*exponent*/ -81); { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; env.fund(XRP(10000), alice, bob, gw); env.close(); - env.trust(USD(1000), alice, bob); - env.trust(EUR(1000), alice, bob); + env.trust(usd(1000), alice, bob); + env.trust(eur(1000), alice, bob); - STAmount const eurOffer(EUR, /*mantissa*/ 2957, /*exponent*/ -76); - STAmount const usdOffer(USD, /*mantissa*/ 7109, /*exponent*/ -76); + STAmount const eurOffer(eur, /*mantissa*/ 2957, /*exponent*/ -76); + STAmount const usdOffer(usd, /*mantissa*/ 7109, /*exponent*/ -76); - STAmount const endLoop(USD, /*mantissa*/ 50, /*exponent*/ -81); + STAmount const endLoop(usd, /*mantissa*/ 50, /*exponent*/ -81); int blockedOrderBookCount = 0; for (STAmount initialBobUSD = tinyUSD; initialBobUSD <= endLoop; @@ -445,7 +445,7 @@ public: { // underfund bob's offer env(pay(gw, bob, initialBobUSD)); - env(pay(gw, alice, EUR(100))); + env(pay(gw, alice, eur(100))); env.close(); // This offer is underfunded @@ -462,7 +462,7 @@ public: // Examine the aftermath of alice's offer. { bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq); - STAmount const aliceBalanceUSD = env.balance(alice, USD); + STAmount const aliceBalanceUSD = env.balance(alice, usd); #if 0 std::cout << "bob initial: " << initialBobUSD @@ -474,7 +474,7 @@ public: if (aliceBalanceUSD.signum() > 0) { BEAST_EXPECT(aliceBalanceUSD == initialBobUSD); - BEAST_EXPECT(env.balance(bob, USD) == USD(0)); + BEAST_EXPECT(env.balance(bob, usd) == usd(0)); BEAST_EXPECT(bobOfferGone); } @@ -495,10 +495,10 @@ public: env(pay(acct, gw, balance)); }; - zeroBalance(alice, EUR); - zeroBalance(alice, USD); - zeroBalance(bob, EUR); - zeroBalance(bob, USD); + zeroBalance(alice, eur); + zeroBalance(alice, usd); + zeroBalance(bob, eur); + zeroBalance(bob, usd); env.close(); } @@ -509,7 +509,7 @@ public: } static Amounts - jsonOfferToAmounts(Json::Value const& json) + jsonOfferToAmounts(json::Value const& json) { STAmount const in = amountFromJson(sfTakerPays, json[sfTakerPays.jsonName]); STAmount const out = amountFromJson(sfTakerGets, json[sfTakerGets.jsonName]); @@ -531,38 +531,37 @@ public: Account const alice("alice"); Account const bob("bob"); Account const carol("carol"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; // Make one test run without fixReducedOffersV2 and one with. for (FeatureBitset features : - {testable_amendments() - fixReducedOffersV2, - testable_amendments() | fixReducedOffersV2}) + {testableAmendments() - fixReducedOffersV2, testableAmendments() | fixReducedOffersV2}) { // Make sure none of the offers we generate are under funded. Env env{*this, features}; env.fund(XRP(10'000'000), gw, alice, bob, carol); env.close(); - env(trust(alice, USD(10'000'000))); - env(trust(bob, USD(10'000'000))); - env(trust(carol, USD(10'000'000))); + env(trust(alice, usd(10'000'000))); + env(trust(bob, usd(10'000'000))); + env(trust(carol, usd(10'000'000))); env.close(); - env(pay(gw, alice, USD(10'000'000))); - env(pay(gw, bob, USD(10'000'000))); - env(pay(gw, carol, USD(10'000'000))); + env(pay(gw, alice, usd(10'000'000))); + env(pay(gw, bob, usd(10'000'000))); + env(pay(gw, carol, usd(10'000'000))); env.close(); // Lambda that: // 1. Exercises one offer trio, // 2. Collects the results, and // 3. Cleans up for the next offer trio. - auto exerciseOfferTrio = [this, &env, &alice, &bob, &carol, &USD]( + auto exerciseOfferTrio = [this, &env, &alice, &bob, &carol, &usd]( Amounts const& carolOffer) -> unsigned int { // alice submits an offer that may become a blocker. std::uint32_t const aliceOfferSeq = env.seq(alice); - static Amounts const aliceInitialOffer(USD(2), drops(3382562)); - env(offer(alice, aliceInitialOffer.in, aliceInitialOffer.out)); + static Amounts const kALICE_INITIAL_OFFER(usd(2), drops(3382562)); + env(offer(alice, kALICE_INITIAL_OFFER.in, kALICE_INITIAL_OFFER.out)); env.close(); STAmount const initialRate = Quality(jsonOfferToAmounts(ledgerEntryOffer( env, alice, aliceOfferSeq)[jss::node])) @@ -570,13 +569,13 @@ public: // bob submits an offer that is more desirable than alice's std::uint32_t const bobOfferSeq = env.seq(bob); - env(offer(bob, USD(0.97086565812384), drops(1642020))); + env(offer(bob, usd(0.97086565812384), drops(1642020))); env.close(); // Now carol's offer consumes bob's and partially crosses // alice's. The tfSell flag is important. std::uint32_t const carolOfferSeq = env.seq(carol); - env(offer(carol, carolOffer.in, carolOffer.out), txflags(tfSell)); + env(offer(carol, carolOffer.in, carolOffer.out), Txflags(tfSell)); env.close(); // carol's offer should not have made it into the ledger and @@ -595,12 +594,12 @@ public: // size. unsigned int badRate = 1; { - Json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq); + json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq); Amounts const aliceReducedOffer = jsonOfferToAmounts(aliceOffer[jss::node]); - BEAST_EXPECT(aliceReducedOffer.in < aliceInitialOffer.in); - BEAST_EXPECT(aliceReducedOffer.out < aliceInitialOffer.out); + BEAST_EXPECT(aliceReducedOffer.in < kALICE_INITIAL_OFFER.in); + BEAST_EXPECT(aliceReducedOffer.out < kALICE_INITIAL_OFFER.out); STAmount const inLedgerRate = Quality(aliceReducedOffer).rate(); badRate = inLedgerRate > initialRate ? 1 : 0; @@ -642,15 +641,15 @@ public: return badRate; }; - constexpr int loopCount = 100; + constexpr int kLOOP_COUNT = 100; unsigned int blockedCount = 0; { - STAmount increaseGets = USD(0); + STAmount increaseGets = usd(0); STAmount const step(increaseGets.asset(), 1, -8); - for (unsigned int i = 0; i < loopCount; ++i) + for (unsigned int i = 0; i < kLOOP_COUNT; ++i) { blockedCount += - exerciseOfferTrio(Amounts(drops(1642020), USD(1) + increaseGets)); + exerciseOfferTrio(Amounts(drops(1642020), usd(1) + increaseGets)); increaseGets += step; } } diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index c38013d1f3..d7c92f1748 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -53,7 +54,7 @@ namespace xrpl::test { -struct Regression_test : public beast::unit_test::suite +struct Regression_test : public beast::unit_test::Suite { // OfferCreate, then OfferCreate with cancel void @@ -62,14 +63,14 @@ struct Regression_test : public beast::unit_test::suite using namespace jtx; Env env(*this); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), "alice", gw); - env(offer("alice", USD(10), XRP(10)), require(owners("alice", 1))); - env(offer("alice", USD(20), XRP(10)), - json(R"raw( + env(offer("alice", usd(10), XRP(10)), Require(Owners("alice", 1))); + env(offer("alice", usd(20), XRP(10)), + Json(R"raw( { "OfferSequence" : 4 } )raw"), - require(owners("alice", 1))); + Require(Owners("alice", 1))); } void @@ -84,12 +85,12 @@ struct Regression_test : public beast::unit_test::suite // be reproduced against an open ledger. Make a local // closed ledger and work with it directly. auto closed = std::make_shared( - create_genesis, + kCREATE_GENESIS, Rules{env.app().config().features}, env.app().config().FEES.toFees(), std::vector{}, env.app().getNodeFamily()); - auto expectedDrops = INITIAL_XRP; + auto expectedDrops = kINITIAL_XRP; BEAST_EXPECT(closed->header().drops == expectedDrops); auto const aliceXRP = 400; @@ -101,7 +102,7 @@ struct Regression_test : public beast::unit_test::suite auto const jt = env.jt(pay(env.master, "alice", aliceAmount)); OpenView accum(&*next); - auto const result = xrpl::apply(env.app(), accum, *jt.stx, tapNONE, env.journal); + auto const result = xrpl::apply(env.app(), accum, *jt.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(result.ter)); BEAST_EXPECT(result.applied); @@ -120,11 +121,11 @@ struct Regression_test : public beast::unit_test::suite { // Specify the seq manually since the env's open ledger // doesn't know about this account. - auto const jt = env.jt(noop("alice"), fee(expectedDrops), seq(2)); + auto const jt = env.jt(noop("alice"), Fee(expectedDrops), Seq(2)); OpenView accum(&*next); - auto const result = xrpl::apply(env.app(), accum, *jt.stx, tapNONE, env.journal); + auto const result = xrpl::apply(env.app(), accum, *jt.stx, TapNone, env.journal); BEAST_EXPECT(result.ter == tecINSUFF_FEE); BEAST_EXPECT(result.applied); @@ -137,7 +138,7 @@ struct Regression_test : public beast::unit_test::suite BEAST_EXPECT(balance == XRP(0)); } - expectedDrops -= aliceXRP * dropsPerXRP; + expectedDrops -= aliceXRP * kDROPS_PER_XRP; BEAST_EXPECT(next->header().drops == expectedDrops); } @@ -152,10 +153,10 @@ struct Regression_test : public beast::unit_test::suite auto test256r1key = [&env](Account const& acct) { auto const baseFee = env.current()->fees().base; std::uint32_t const acctSeq = env.seq(acct); - Json::Value const jsonNoop = - env.json(noop(acct), fee(baseFee), seq(acctSeq), sig(acct)); - JTx jt = env.jt(jsonNoop); - jt.fill_sig = false; + json::Value const jsonNoOp = + env.json(noop(acct), Fee(baseFee), Seq(acctSeq), Sig(acct)); + JTx jt = env.jt(jsonNoOp); + jt.fillSig = false; // Random secp256r1 public key generated by // https://kjur.github.io/jsrsasign/sample-ecdsa.html @@ -174,11 +175,11 @@ struct Regression_test : public beast::unit_test::suite secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob); jt.stx.reset(secp256r1Sig.release()); - env(jt, rpc("invalidTransaction", "fails local checks: Invalid signature.")); + env(jt, Rpc("invalidTransaction", "fails local checks: Invalid signature.")); }; - Account const alice{"alice", KeyType::secp256k1}; - Account const becky{"becky", KeyType::ed25519}; + Account const alice{"alice", KeyType::Secp256k1}; + Account const becky{"becky", KeyType::Ed25519}; env.fund(XRP(10000), alice, becky); @@ -196,12 +197,12 @@ struct Regression_test : public beast::unit_test::suite cfg->FEES.reference_fee = 10; return cfg; })); - Env_ss envs(env); + EnvSs envs(env); auto const alice = Account("alice"); env.fund(XRP(100000), alice); - auto params = Json::Value(Json::objectValue); + auto params = json::Value(json::ObjectValue); // Max fee = 50k drops params[jss::fee_mult_max] = 5000; std::vector const expectedFees({10, 10, 8889, 13889, 20000}); @@ -210,7 +211,7 @@ struct Regression_test : public beast::unit_test::suite // our fee limit. for (int i = 0; i < 5; ++i) { - envs(noop(alice), fee(none), seq(none))(params); + envs(noop(alice), Fee(kNONE), Seq(kNONE))(params); auto tx = env.tx(); if (BEAST_EXPECT(tx)) @@ -259,8 +260,8 @@ struct Regression_test : public beast::unit_test::suite std::string const request = R"json({"command":"path_find","id":19,"subcommand":"create","source_account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","destination_account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","destination_amount":"1000000","source_currencies":[{"currency":"0000000000000000000000000000000000000000"},{"currency":"0000000000000000000000005553440000000000"},{"currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004254430000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004555520000000000"},{"currency":"0000000000000000000000004554480000000000"},{"currency":"0000000000000000000000004A50590000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"000000000000000000000000434E590000000000"},{"currency":"0000000000000000000000004742490000000000"},{"issuer":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","currency":"0000000000000000000000004341440000000000"}]})json"; - Json::Value jvRequest; - Json::Reader jrReader; + json::Value jvRequest; + json::Reader jrReader; std::vector buffers; buffers.emplace_back(buffer(request, 1024)); @@ -283,22 +284,22 @@ struct Regression_test : public beast::unit_test::suite env.close(); { - auto const alice_index = keylet::account(alice).key; - if (BEAST_EXPECT(alice_index.isNonZero())) + auto const aliceIndex = keylet::account(alice).key; + if (BEAST_EXPECT(aliceIndex.isNonZero())) { - env(check::cash(alice, alice_index, check::DeliverMin(XRP(100))), ter(tecNO_ENTRY)); + env(check::cash(alice, aliceIndex, check::DeliverMin(XRP(100))), Ter(tecNO_ENTRY)); } } { - auto const bob_index = keylet::account(bob).key; + auto const bobIndex = keylet::account(bob).key; auto const digest = [&]() -> std::optional { auto const& state = env.app().getLedgerMaster().getClosedLedger()->stateMap(); SHAMapHash digest; - if (!state.peekItem(bob_index, digest)) + if (!state.peekItem(bobIndex, digest)) return std::nullopt; - return digest.as_uint256(); + return digest.asUint256(); }(); auto const mapCounts = [&](CountedObjects::List const& list) { @@ -311,13 +312,13 @@ struct Regression_test : public beast::unit_test::suite return result; }; - if (BEAST_EXPECT(bob_index.isNonZero()) && BEAST_EXPECT(digest.has_value())) + if (BEAST_EXPECT(bobIndex.isNonZero()) && BEAST_EXPECT(digest.has_value())) { auto& cache = env.app().getCachedSLEs(); cache.del(*digest, false); // NOLINT(bugprone-unchecked-optional-access) auto const beforeCounts = mapCounts(CountedObjects::getInstance().getCounts(0)); - env(check::cash(alice, bob_index, check::DeliverMin(XRP(100))), ter(tecNO_ENTRY)); + env(check::cash(alice, bobIndex, check::DeliverMin(XRP(100))), Ter(tecNO_ENTRY)); auto const afterCounts = mapCounts(CountedObjects::getInstance().getCounts(0)); diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 75e4c0c721..574874e005 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -34,16 +34,16 @@ namespace xrpl::test { -class SHAMapStore_test : public beast::unit_test::suite +class SHAMapStore_test : public beast::unit_test::Suite { - static auto const deleteInterval = 8; + static auto const kDELETE_INTERVAL = 8; static auto onlineDelete(std::unique_ptr cfg) { - cfg->LEDGER_HISTORY = deleteInterval; + cfg->LEDGER_HISTORY = kDELETE_INTERVAL; auto& section = cfg->section(ConfigSection::nodeDatabase()); - section.set("online_delete", std::to_string(deleteInterval)); + section.set("online_delete", std::to_string(kDELETE_INTERVAL)); return cfg; } @@ -56,9 +56,9 @@ class SHAMapStore_test : public beast::unit_test::suite } static bool - goodLedger(jtx::Env& env, Json::Value const& json, std::string ledgerID, bool checkDB = false) + goodLedger(jtx::Env& env, json::Value const& json, std::string ledgerID, bool checkDB = false) { - auto good = json.isMember(jss::result) && !RPC::contains_error(json[jss::result]) && + auto good = json.isMember(jss::result) && !RPC::containsError(json[jss::result]) && json[jss::result][jss::ledger][jss::ledger_index] == ledgerID; if (!good || !checkDB) return good; @@ -95,14 +95,14 @@ class SHAMapStore_test : public beast::unit_test::suite } static bool - bad(Json::Value const& json, error_code_i error = rpcLGR_NOT_FOUND) + bad(json::Value const& json, ErrorCodeI error = RpcLgrNotFound) { - return json.isMember(jss::result) && RPC::contains_error(json[jss::result]) && + return json.isMember(jss::result) && RPC::containsError(json[jss::result]) && json[jss::result][jss::error_code] == error; } std::string - getHash(Json::Value const& json) + getHash(json::Value const& json) { BEAST_EXPECT( json.isMember(jss::result) && json[jss::result].isMember(jss::ledger) && @@ -173,7 +173,7 @@ public: transactionCheck(env, 0); accountTransactionCheck(env, 0); - std::map ledgers; + std::map ledgers; auto ledgerTmp = env.rpc("ledger", "0"); BEAST_EXPECT(bad(ledgerTmp)); @@ -196,7 +196,7 @@ public: auto const firstSeq = waitForReady(env); auto lastRotated = firstSeq - 1; - for (auto i = firstSeq + 1; i < deleteInterval + firstSeq; ++i) + for (auto i = firstSeq + 1; i < kDELETE_INTERVAL + firstSeq; ++i) { env.fund(XRP(10000), noripple("test" + std::to_string(i))); env.close(); @@ -206,7 +206,7 @@ public: } BEAST_EXPECT(store.getLastRotated() == lastRotated); - for (auto i = 3; i < deleteInterval + lastRotated; ++i) + for (auto i = 3; i < kDELETE_INTERVAL + lastRotated; ++i) { ledgers.emplace(i, env.rpc("ledger", std::to_string(i))); BEAST_EXPECT( @@ -214,31 +214,31 @@ public: !getHash(ledgers[i]).empty()); } - ledgerCheck(env, deleteInterval + 1, 2); - transactionCheck(env, deleteInterval); - accountTransactionCheck(env, 2 * deleteInterval); + ledgerCheck(env, kDELETE_INTERVAL + 1, 2); + transactionCheck(env, kDELETE_INTERVAL); + accountTransactionCheck(env, 2 * kDELETE_INTERVAL); { // Closing one more ledger triggers a rotate env.close(); auto ledger = env.rpc("ledger", "current"); - BEAST_EXPECT(goodLedger(env, ledger, std::to_string(deleteInterval + 4))); + BEAST_EXPECT(goodLedger(env, ledger, std::to_string(kDELETE_INTERVAL + 4))); } store.rendezvous(); - BEAST_EXPECT(store.getLastRotated() == deleteInterval + 3); + BEAST_EXPECT(store.getLastRotated() == kDELETE_INTERVAL + 3); lastRotated = store.getLastRotated(); BEAST_EXPECT(lastRotated == 11); // That took care of the fake hashes - ledgerCheck(env, deleteInterval + 1, 3); - transactionCheck(env, deleteInterval); - accountTransactionCheck(env, 2 * deleteInterval); + ledgerCheck(env, kDELETE_INTERVAL + 1, 3); + transactionCheck(env, kDELETE_INTERVAL); + accountTransactionCheck(env, 2 * kDELETE_INTERVAL); // The last iteration of this loop should trigger a rotate - for (auto i = lastRotated - 1; i < lastRotated + deleteInterval - 1; ++i) + for (auto i = lastRotated - 1; i < lastRotated + kDELETE_INTERVAL - 1; ++i) { env.close(); @@ -247,7 +247,7 @@ public: ledgers.emplace(i, env.rpc("ledger", std::to_string(i))); BEAST_EXPECT( - store.getLastRotated() == lastRotated || i == lastRotated + deleteInterval - 2); + store.getLastRotated() == lastRotated || i == lastRotated + kDELETE_INTERVAL - 2); BEAST_EXPECT( goodLedger(env, ledgers[i], std::to_string(i), true) && !getHash(ledgers[i]).empty()); @@ -255,9 +255,9 @@ public: store.rendezvous(); - BEAST_EXPECT(store.getLastRotated() == deleteInterval + lastRotated); + BEAST_EXPECT(store.getLastRotated() == kDELETE_INTERVAL + lastRotated); - ledgerCheck(env, deleteInterval + 1, lastRotated); + ledgerCheck(env, kDELETE_INTERVAL + 1, lastRotated); transactionCheck(env, 0); accountTransactionCheck(env, 0); } @@ -280,10 +280,10 @@ public: // Because advisory_delete is unset, // "can_delete" is disabled. auto const canDelete = env.rpc("can_delete"); - BEAST_EXPECT(bad(canDelete, rpcNOT_ENABLED)); + BEAST_EXPECT(bad(canDelete, RpcNotEnabled)); // Close ledgers without triggering a rotate - for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq) { env.close(); @@ -314,7 +314,7 @@ public: lastRotated = store.getLastRotated(); // Close enough ledgers to trigger another rotate - for (; ledgerSeq < lastRotated + deleteInterval + 1; ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDELETE_INTERVAL + 1; ++ledgerSeq) { env.close(); @@ -324,7 +324,7 @@ public: store.rendezvous(); - ledgerCheck(env, deleteInterval + 1, lastRotated); + ledgerCheck(env, kDELETE_INTERVAL + 1, lastRotated); BEAST_EXPECT(lastRotated != store.getLastRotated()); } @@ -345,14 +345,14 @@ public: BEAST_EXPECT(lastRotated != 2); auto canDelete = env.rpc("can_delete"); - BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result])); + BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0); canDelete = env.rpc("can_delete", "never"); - BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result])); + BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0); - auto const firstBatch = deleteInterval + ledgerSeq; + auto const firstBatch = kDELETE_INTERVAL + ledgerSeq; for (; ledgerSeq < firstBatch; ++ledgerSeq) { env.close(); @@ -367,9 +367,9 @@ public: BEAST_EXPECT(lastRotated == store.getLastRotated()); // This does not kick off a cleanup - canDelete = env.rpc("can_delete", std::to_string(ledgerSeq + (deleteInterval / 2))); - BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result])); - BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (deleteInterval / 2)); + canDelete = env.rpc("can_delete", std::to_string(ledgerSeq + (kDELETE_INTERVAL / 2))); + BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (kDELETE_INTERVAL / 2)); store.rendezvous(); @@ -391,7 +391,7 @@ public: BEAST_EXPECT(store.getLastRotated() == ledgerSeq - 1); lastRotated = ledgerSeq - 1; - for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq) { // No cleanups in this loop. env.close(); @@ -421,11 +421,11 @@ public: // This does not kick off a cleanup canDelete = env.rpc("can_delete", "always"); - BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result])); + BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); BEAST_EXPECT( canDelete[jss::result][jss::can_delete] == std::numeric_limits::max()); - for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq) { // No cleanups in this loop. env.close(); @@ -455,10 +455,10 @@ public: // This does not kick off a cleanup canDelete = env.rpc("can_delete", "now"); - BEAST_EXPECT(!RPC::contains_error(canDelete[jss::result])); + BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq - 1); - for (; ledgerSeq < lastRotated + deleteInterval; ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDELETE_INTERVAL; ++ledgerSeq) { // No cleanups in this loop. env.close(); @@ -498,9 +498,9 @@ public: newPath = path; section.set("path", newPath.string()); - auto backend{NodeStore::Manager::instance().make_Backend( + auto backend{NodeStore::Manager::instance().makeBackend( section, - megabytes(env.app().config().getValueFor(SizedItem::burstSize, std::nullopt)), + megabytes(env.app().config().getValueFor(SizedItem::BurstSize, std::nullopt)), scheduler, env.app().getJournal("NodeStoreTest"))}; backend->open(); @@ -527,11 +527,11 @@ public: auto writableBackend = makeBackendRotating(env, scheduler, writableDb); auto archiveBackend = makeBackendRotating(env, scheduler, archiveDb); - constexpr int readThreads = 4; + constexpr int kREAD_THREADS = 4; auto nscfg = env.app().config().section(ConfigSection::nodeDatabase()); auto dbr = std::make_unique( scheduler, - readThreads, + kREAD_THREADS, std::move(writableBackend), std::move(archiveBackend), nscfg, diff --git a/src/test/app/SetAuth_test.cpp b/src/test/app/SetAuth_test.cpp index 5982fc282d..f2e6aa29cc 100644 --- a/src/test/app/SetAuth_test.cpp +++ b/src/test/app/SetAuth_test.cpp @@ -20,19 +20,19 @@ namespace xrpl::test { -struct SetAuth_test : public beast::unit_test::suite +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 + static json::Value auth(jtx::Account const& account, jtx::Account const& dest, std::string const& currency) { using namespace jtx; - Json::Value jv; + json::Value jv; jv[jss::Account] = account.human(); jv[jss::LimitAmount] = - STAmount(Issue{to_currency(currency), dest}).getJson(JsonOptions::none); + STAmount(Issue{toCurrency(currency), dest}).getJson(JsonOptions::KNone); jv[jss::TransactionType] = jss::TrustSet; jv[jss::Flags] = tfSetfAuth; return jv; @@ -43,7 +43,7 @@ struct SetAuth_test : public beast::unit_test::suite { using namespace jtx; auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; Env env(*this); @@ -51,21 +51,21 @@ struct SetAuth_test : public beast::unit_test::suite 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 + 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(); + auto const sa = testableAmendments(); testAuth(sa - featurePermissionedDEX); testAuth(sa); } diff --git a/src/test/app/SetRegularKey_test.cpp b/src/test/app/SetRegularKey_test.cpp index af79bb75bc..00b1fe3f84 100644 --- a/src/test/app/SetRegularKey_test.cpp +++ b/src/test/app/SetRegularKey_test.cpp @@ -23,7 +23,7 @@ namespace xrpl { -class SetRegularKey_test : public beast::unit_test::suite +class SetRegularKey_test : public beast::unit_test::Suite { public: void @@ -32,31 +32,31 @@ public: using namespace test::jtx; testcase("Set regular key"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const alice("alice"); Account const bob("bob"); env.fund(XRP(10000), alice, bob); env(regkey(alice, bob)); - env(noop(alice), sig(bob)); - env(noop(alice), sig(alice)); + env(noop(alice), Sig(bob)); + env(noop(alice), Sig(alice)); testcase("Disable master key"); - env(fset(alice, asfDisableMaster), sig(alice)); - env(noop(alice), sig(bob)); - env(noop(alice), sig(alice), ter(tefMASTER_DISABLED)); + env(fset(alice, asfDisableMaster), Sig(alice)); + env(noop(alice), Sig(bob)); + env(noop(alice), Sig(alice), Ter(tefMASTER_DISABLED)); testcase("Re-enable master key"); - env(fclear(alice, asfDisableMaster), sig(alice), ter(tefMASTER_DISABLED)); + env(fclear(alice, asfDisableMaster), Sig(alice), Ter(tefMASTER_DISABLED)); - env(fclear(alice, asfDisableMaster), sig(bob)); - env(noop(alice), sig(bob)); - env(noop(alice), sig(alice)); + env(fclear(alice, asfDisableMaster), Sig(bob)); + env(noop(alice), Sig(bob)); + env(noop(alice), Sig(alice)); testcase("Revoke regular key"); - env(regkey(alice, disabled)); - env(noop(alice), sig(bob), ter(tefBAD_AUTH)); - env(noop(alice), sig(alice)); + env(regkey(alice, kDISABLED)); + env(noop(alice), Sig(bob), Ter(tefBAD_AUTH)); + env(noop(alice), Sig(alice)); } void @@ -65,11 +65,11 @@ public: using namespace test::jtx; testcase("Set regular key to master key"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const alice("alice"); env.fund(XRP(10000), alice); - env(regkey(alice, alice), ter(temBAD_REGKEY)); + env(regkey(alice, alice), Ter(temBAD_REGKEY)); } void @@ -87,7 +87,7 @@ public: BEAST_EXPECT( ar->isFieldPresent(sfFlags) && ((ar->getFieldU32(sfFlags) & lsfPasswordSpent) == 0)); - env(regkey(alice, bob), sig(alice), fee(0)); + env(regkey(alice, bob), Sig(alice), Fee(0)); ar = env.le(alice); BEAST_EXPECT( @@ -95,7 +95,7 @@ public: ((ar->getFieldU32(sfFlags) & lsfPasswordSpent) == lsfPasswordSpent)); // The second SetRegularKey transaction with Fee=0 should fail. - env(regkey(alice, bob), sig(alice), fee(0), ter(telINSUF_FEE_P)); + env(regkey(alice, bob), Sig(alice), Fee(0), Ter(telINSUF_FEE_P)); env.trust(bob["USD"](1), alice); env(pay(bob, alice, bob["USD"](1))); @@ -117,7 +117,7 @@ public: auto jv = regkey(alice, bob); jv[sfFlags.fieldName] = tfUniversalMask; - env(jv, ter(temINVALID_FLAG)); + env(jv, Ter(temINVALID_FLAG)); } void @@ -127,7 +127,7 @@ public: testcase("Ticket regular key"); Env env{*this}; - Account const alice{"alice", KeyType::ed25519}; + Account const alice{"alice", KeyType::Ed25519}; env.fund(XRP(1000), alice); env.close(); @@ -137,34 +137,34 @@ public: std::uint32_t ticketSeq{env.seq(alice)}; // Make sure we can give a regular key using a ticket. - Account const alie{"alie", KeyType::secp256k1}; - env(regkey(alice, alie), ticket::use(--ticketSeq)); + Account const alie{"alie", KeyType::Secp256k1}; + env(regkey(alice, alie), ticket::Use(--ticketSeq)); env.close(); // Disable alice's master key using a ticket. - env(fset(alice, asfDisableMaster), sig(alice), ticket::use(--ticketSeq)); + env(fset(alice, asfDisableMaster), Sig(alice), ticket::Use(--ticketSeq)); env.close(); // alice should be able to sign using the regular key but not the // master key. std::uint32_t const aliceSeq{env.seq(alice)}; - env(noop(alice), sig(alice), ter(tefMASTER_DISABLED)); - env(noop(alice), sig(alie), ter(tesSUCCESS)); + env(noop(alice), Sig(alice), Ter(tefMASTER_DISABLED)); + env(noop(alice), Sig(alie), Ter(tesSUCCESS)); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); // Re-enable the master key using a ticket. - env(fclear(alice, asfDisableMaster), sig(alie), ticket::use(--ticketSeq)); + env(fclear(alice, asfDisableMaster), Sig(alie), ticket::Use(--ticketSeq)); env.close(); // Disable the regular key using a ticket. - env(regkey(alice, disabled), sig(alie), ticket::use(--ticketSeq)); + env(regkey(alice, kDISABLED), Sig(alie), ticket::Use(--ticketSeq)); env.close(); // alice should be able to sign using the master key but not the // regular key. - env(noop(alice), sig(alice), ter(tesSUCCESS)); - env(noop(alice), sig(alie), ter(tefBAD_AUTH)); + env(noop(alice), Sig(alice), Ter(tesSUCCESS)); + env(noop(alice), Sig(alie), Ter(tefBAD_AUTH)); env.close(); } diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index 2316b3249f..ed6f91f475 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -56,7 +56,7 @@ struct RippleCalcTestParams STPathSet paths; - explicit RippleCalcTestParams(Json::Value const& jv) + explicit RippleCalcTestParams(json::Value const& jv) // NOLINTNEXTLINE(bugprone-unchecked-optional-access) : srcAccount{*parseBase58(jv[jss::Account].asString())} // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -78,7 +78,7 @@ struct RippleCalcTestParams if (pe.isMember(jss::account)) { assert(!pe.isMember(jss::currency) && !pe.isMember(jss::issuer)); - p.emplace_back( + p.emplaceBack( // NOLINTNEXTLINE(bugprone-unchecked-optional-access) *parseBase58(pe[jss::account].asString()), std::nullopt, @@ -86,7 +86,7 @@ struct RippleCalcTestParams } else if (pe.isMember(jss::currency) && pe.isMember(jss::issuer)) { - auto const currency = to_currency(pe[jss::currency].asString()); + auto const currency = toCurrency(pe[jss::currency].asString()); std::optional issuer; if (!isXRP(currency)) { @@ -98,14 +98,14 @@ struct RippleCalcTestParams // NOLINTNEXTLINE(bugprone-unchecked-optional-access) assert(isXRP(*parseBase58(pe[jss::issuer].asString()))); } - p.emplace_back(std::nullopt, currency, issuer); + p.emplaceBack(std::nullopt, currency, issuer); } else { assert(0); } } - paths.emplace_back(std::move(p)); + paths.emplaceBack(std::move(p)); } } } @@ -125,9 +125,9 @@ class RandomAccountParams std::uint32_t const initialBalance_; // probability of changing a value from its default - constexpr static double probChangeDefault_ = 0.75; + constexpr static double kPROB_CHANGE_DEFAULT = 0.75; // probability that an account redeems into another account - constexpr static double probRedeem_ = 0.5; + constexpr static double kPROB_REDEEM = 0.5; std::uniform_real_distribution<> zeroOneDist_{0.0, 1.0}; std::uniform_real_distribution<> transferRateDist_{1.0, 2.0}; std::uniform_real_distribution<> qualityPercentDist_{80, 120}; @@ -135,17 +135,17 @@ class RandomAccountParams bool shouldSet() { - return zeroOneDist_(engine_) <= probChangeDefault_; + return zeroOneDist_(engine_) <= kPROB_CHANGE_DEFAULT; }; void - maybeInsertQuality(Json::Value& jv, QualityDirection qDir) + maybeInsertQuality(json::Value& jv, QualityDirection qDir) { if (!shouldSet()) return; auto const percent = qualityPercentDist_(engine_); - auto const& field = qDir == QualityDirection::in ? sfQualityIn : sfQualityOut; + auto const& field = qDir == QualityDirection::In ? sfQualityIn : sfQualityOut; auto const value = static_cast((percent / 100) * QUALITY_ONE); jv[field.jsonName] = value; }; @@ -160,9 +160,9 @@ class RandomAccountParams { using namespace jtx; IOU const iou{peer, currency}; - Json::Value jv = trust(acc, iou(trustAmount_)); - maybeInsertQuality(jv, QualityDirection::in); - maybeInsertQuality(jv, QualityDirection::out); + json::Value jv = trust(acc, iou(trustAmount_)); + maybeInsertQuality(jv, QualityDirection::In); + maybeInsertQuality(jv, QualityDirection::Out); env(jv); env.close(); }; @@ -193,8 +193,8 @@ public: // Since input qualities complicate this payment, use `sendMax` with // `initialBalance` to make sure the balance is set correctly. env(pay(peer, acc, iou(trustAmount_)), - sendmax(iou(initialBalance_)), - txflags(tfPartialPayment)); + Sendmax(iou(initialBalance_)), + Txflags(tfPartialPayment)); env.close(); } @@ -206,7 +206,7 @@ public: Currency const& currency) { using namespace jtx; - if (zeroOneDist_(engine_) > probRedeem_) + if (zeroOneDist_(engine_) > kPROB_REDEEM) return; setInitialBalance(env, acc, peer, currency); } @@ -225,7 +225,7 @@ public: }; }; -class TheoreticalQuality_test : public beast::unit_test::suite +class TheoreticalQuality_test : public beast::unit_test::Suite { static std::string prettyQuality(Quality const& q) @@ -252,7 +252,7 @@ class TheoreticalQuality_test : public beast::unit_test::suite std::shared_ptr closed, std::optional const& expectedQ = {}) { - PaymentSandbox const sb(closed.get(), tapNONE); + PaymentSandbox const sb(closed.get(), TapNone); AMMContext ammContext(rcp.srcAccount, false); auto const sendMaxIssue = [&rcp]() -> std::optional { @@ -273,7 +273,7 @@ class TheoreticalQuality_test : public beast::unit_test::suite rcp.paths, /*defaultPaths*/ rcp.paths.empty(), false, - OfferCrossing::no, + OfferCrossing::No, ammContext, std::nullopt, dummyJ); @@ -290,8 +290,8 @@ class TheoreticalQuality_test : public beast::unit_test::suite auto compareClose = [](Quality const& q1, Quality const& q2) { // relative diff is fabs(a-b)/min(a,b) // can't get access to internal value. Use the rate - constexpr double tolerance = 0.0000001; - return relativeDistance(q1, q2) <= tolerance; + constexpr double kTOLERANCE = 0.0000001; + return relativeDistance(q1, q2) <= kTOLERANCE; }; for (auto const& strand : sr.second) @@ -337,15 +337,15 @@ public: using namespace jtx; - auto const currency = to_currency("USD"); + auto const currency = toCurrency("USD"); - constexpr std::size_t const numAccounts = 4; + constexpr std::size_t const kNUM_ACCOUNTS = 4; // There are three relevant trust lines: `alice->bob`, `bob->carol`, and // `carol->dan`. There are four accounts. If we count the number of // combinations of parameters where a parameter is changed from its // default value, there are - // 2^(num_trust_lines*num_trust_qualities+numAccounts) combinations of + // 2^(nutrust_lines_*nutrust_qualities_+numAccounts) combinations of // values to test, or 2^13 combinations. Use this value to set the // number of iterations. Note however that many of these parameter // combinations run essentially the same test. For example, changing the @@ -355,7 +355,7 @@ public: // randomly sample the test space. int const numTestIterations = reqNumIterations.value_or(250); - constexpr std::uint32_t paymentAmount = 1; + constexpr std::uint32_t kPAYMENT_AMOUNT = 1; // Class to randomly set account transfer rates, qualities, and other // params. @@ -363,7 +363,7 @@ public: // Tests are sped up by a factor of 2 if a new environment isn't created // on every iteration. - Env env(*this, testable_amendments()); + Env env(*this, testableAmendments()); for (int i = 0; i < numTestIterations; ++i) { auto const iterAsStr = std::to_string(i); @@ -373,15 +373,15 @@ public: auto const bob = Account("bob" + iterAsStr); auto const carol = Account("carol" + iterAsStr); auto const dan = Account("dan" + iterAsStr); - std::array accounts{{alice, bob, carol, dan}}; - static_assert(numAccounts == 4, "Path is only correct for four accounts"); - path const accountsPath(accounts[1], accounts[2]); + std::array accounts{{alice, bob, carol, dan}}; + static_assert(kNUM_ACCOUNTS == 4, "Path is only correct for four accounts"); + Path const accountsPath(accounts[1], accounts[2]); env.fund(XRP(10000), alice, bob, carol, dan); env.close(); // iterate through all pairs of accounts, randomly set the transfer // rate, qIn, qOut, and if the account issues or redeems - for (std::size_t ii = 0; ii < numAccounts; ++ii) + for (std::size_t ii = 0; ii < kNUM_ACCOUNTS; ++ii) { rndAccParams.maybeSetTransferRate(env, accounts[ii]); // The payment is from: @@ -389,7 +389,7 @@ public: // set the trust lines and initial balances for each pair of // neighboring accounts std::size_t const j = ii + 1; - if (j == numAccounts) + if (j == kNUM_ACCOUNTS) continue; rndAccParams.setupTrustLines(env, accounts[ii], accounts[j], currency); @@ -399,9 +399,9 @@ public: // Accounts are set up, make the payment IOU const iou{accounts.back(), currency}; RippleCalcTestParams const rcp{env.json( - pay(accounts.front(), accounts.back(), iou(paymentAmount)), + pay(accounts.front(), accounts.back(), iou(kPAYMENT_AMOUNT)), accountsPath, - txflags(tfNoRippleDirect))}; + Txflags(tfNoRippleDirect))}; testCase(rcp, env.closed()); } @@ -422,10 +422,10 @@ public: int const numTestIterations = reqNumIterations.value_or(100); - constexpr std::uint32_t paymentAmount = 1; + constexpr std::uint32_t kPAYMENT_AMOUNT = 1; - Currency const eurCurrency = to_currency("EUR"); - Currency const usdCurrency = to_currency("USD"); + Currency const eurCurrency = toCurrency("EUR"); + Currency const usdCurrency = toCurrency("USD"); // Class to randomly set account transfer rates, qualities, and other // params. @@ -433,7 +433,7 @@ public: // Speed up tests by creating the environment outside the loop // (factor of 2 speedup on the DirectStep tests) - Env env(*this, testable_amendments()); + Env env(*this, testableAmendments()); for (int i = 0; i < numTestIterations; ++i) { auto const iterAsStr = std::to_string(i); @@ -442,15 +442,15 @@ public: auto const carol = Account("carol" + iterAsStr); auto const dan = Account("dan" + iterAsStr); auto const oscar = Account("oscar" + iterAsStr); // offer owner - auto const USDB = bob["USD"]; - auto const EURC = carol["EUR"]; - constexpr std::size_t const numAccounts = 5; - std::array const accounts{{alice, bob, carol, dan, oscar}}; + auto const usdb = bob["USD"]; + auto const eurc = carol["EUR"]; + constexpr std::size_t const kNUM_ACCOUNTS = 5; + std::array const accounts{{alice, bob, carol, dan, oscar}}; // sendmax should be in USDB and delivered amount should be in EURC // normalized path should be: // alice -> bob -> (USD/bob)|(EUR/carol) -> carol -> dan - path const bookPath(~EURC); + Path const bookPath(~eurc); env.fund(XRP(10000), alice, bob, carol, dan, oscar); env.close(); @@ -471,17 +471,17 @@ public: rndAccParams.setInitialBalance(env, oscar, bob, usdCurrency); rndAccParams.setInitialBalance(env, oscar, carol, eurCurrency); - env(offer(oscar, USDB(50), EURC(50))); + env(offer(oscar, usdb(50), eurc(50))); env.close(); // Accounts are set up, make the payment IOU const srcIOU{bob, usdCurrency}; IOU const dstIOU{carol, eurCurrency}; RippleCalcTestParams const rcp{env.json( - pay(alice, dan, dstIOU(paymentAmount)), - sendmax(srcIOU(100 * paymentAmount)), + pay(alice, dan, dstIOU(kPAYMENT_AMOUNT)), + Sendmax(srcIOU(100 * kPAYMENT_AMOUNT)), bookPath, - txflags(tfNoRippleDirect))}; + Txflags(tfNoRippleDirect))}; testCase(rcp, env.closed()); } diff --git a/src/test/app/Ticket_test.cpp b/src/test/app/Ticket_test.cpp index 0dc9f0155f..d266ec12d2 100644 --- a/src/test/app/Ticket_test.cpp +++ b/src/test/app/Ticket_test.cpp @@ -45,7 +45,7 @@ namespace xrpl { -class Ticket_test : public beast::unit_test::suite +class Ticket_test : public beast::unit_test::Suite { /// @brief Validate metadata for a successful TicketCreate transaction. /// @@ -55,7 +55,7 @@ class Ticket_test : public beast::unit_test::suite { using namespace std::string_literals; - Json::Value const& tx{env.tx()->getJson(JsonOptions::none)}; + json::Value const& tx{env.tx()->getJson(JsonOptions::KNone)}; { std::string const txType = tx[sfTransactionType.jsonName].asString(); @@ -71,7 +71,7 @@ class Ticket_test : public beast::unit_test::suite std::uint32_t const txSeq = {tx[sfSequence.jsonName].asUInt()}; std::string const account = tx[sfAccount.jsonName].asString(); - Json::Value const& metadata = env.meta()->getJson(JsonOptions::none); + json::Value const& metadata = env.meta()->getJson(JsonOptions::KNone); if (!BEAST_EXPECTS( metadata.isMember(sfTransactionResult.jsonName) && metadata[sfTransactionResult.jsonName].asString() == "tesSUCCESS", @@ -85,11 +85,11 @@ class Ticket_test : public beast::unit_test::suite std::uint32_t acctRootFinalSeq = {0}; std::vector ticketSeqs; ticketSeqs.reserve(count); - for (Json::Value const& node : metadata[sfAffectedNodes.jsonName]) + for (json::Value const& node : metadata[sfAffectedNodes.jsonName]) { if (node.isMember(sfModifiedNode.jsonName)) { - Json::Value const& modified = node[sfModifiedNode.jsonName]; + json::Value const& modified = node[sfModifiedNode.jsonName]; std::string const entryType = modified[sfLedgerEntryType.jsonName].asString(); if (entryType == jss::AccountRoot) { @@ -181,7 +181,7 @@ class Ticket_test : public beast::unit_test::suite } else if (node.isMember(sfCreatedNode.jsonName)) { - Json::Value const& created = node[sfCreatedNode.jsonName]; + json::Value const& created = node[sfCreatedNode.jsonName]; std::string const entryType = created[sfLedgerEntryType.jsonName].asString(); if (entryType == jss::Ticket) { @@ -201,7 +201,7 @@ class Ticket_test : public beast::unit_test::suite } else if (node.isMember(sfDeletedNode.jsonName)) { - Json::Value const& deleted = node[sfDeletedNode.jsonName]; + json::Value const& deleted = node[sfDeletedNode.jsonName]; std::string const entryType = deleted[sfLedgerEntryType.jsonName].asString(); if (entryType == jss::Ticket) @@ -241,7 +241,7 @@ class Ticket_test : public beast::unit_test::suite void checkTicketConsumeMeta(test::jtx::Env& env) { - Json::Value const& tx{env.tx()->getJson(JsonOptions::none)}; + json::Value const& tx{env.tx()->getJson(JsonOptions::KNone)}; // Verify that the transaction includes a TicketSequence. @@ -274,7 +274,7 @@ class Ticket_test : public beast::unit_test::suite std::uint32_t const ticketSeq{tx[sfTicketSequence.jsonName].asUInt()}; - Json::Value const& metadata{env.meta()->getJson(JsonOptions::none)}; + json::Value const& metadata{env.meta()->getJson(JsonOptions::KNone)}; if (!BEAST_EXPECTS( metadata.isMember(sfTransactionResult.jsonName), "Metadata is missing TransactionResult.")) @@ -295,11 +295,11 @@ class Ticket_test : public beast::unit_test::suite bool acctRootFound{false}; std::uint32_t acctRootSeq{0}; int ticketsRemoved{0}; - for (Json::Value const& node : metadata[sfAffectedNodes.jsonName]) + for (json::Value const& node : metadata[sfAffectedNodes.jsonName]) { if (node.isMember(sfModifiedNode.jsonName)) { - Json::Value const& modified{node[sfModifiedNode.jsonName]}; + json::Value const& modified{node[sfModifiedNode.jsonName]}; std::string const entryType = modified[sfLedgerEntryType.jsonName].asString(); if (entryType == "AccountRoot" && modified[sfFinalFields.jsonName][sfAccount.jsonName].asString() == account) @@ -337,7 +337,7 @@ class Ticket_test : public beast::unit_test::suite } else if (node.isMember(sfDeletedNode.jsonName)) { - Json::Value const& deleted{node[sfDeletedNode.jsonName]}; + json::Value const& deleted{node[sfDeletedNode.jsonName]}; std::string const entryType{deleted[sfLedgerEntryType.jsonName].asString()}; if (entryType == jss::Ticket) @@ -371,40 +371,40 @@ class Ticket_test : public beast::unit_test::suite Account const master{env.master}; // Exercise boundaries on count. - env(ticket::create(master, 0), ter(temINVALID_COUNT)); - env(ticket::create(master, 251), ter(temINVALID_COUNT)); + env(ticket::create(master, 0), Ter(temINVALID_COUNT)); + env(ticket::create(master, 251), Ter(temINVALID_COUNT)); // Exercise fees. - std::uint32_t const ticketSeq_A{env.seq(master) + 1}; - env(ticket::create(master, 1), fee(XRP(10))); + std::uint32_t const ticketSeqA{env.seq(master) + 1}; + env(ticket::create(master, 1), Fee(XRP(10))); checkTicketCreateMeta(env); env.close(); - env.require(owners(master, 1), tickets(master, 1)); + env.require(Owners(master, 1), tickets(master, 1)); - env(ticket::create(master, 1), fee(XRP(-1)), ter(temBAD_FEE)); + env(ticket::create(master, 1), Fee(XRP(-1)), Ter(temBAD_FEE)); // Exercise flags. - std::uint32_t const ticketSeq_B{env.seq(master) + 1}; - env(ticket::create(master, 1), txflags(tfFullyCanonicalSig)); + std::uint32_t const ticketSeqB{env.seq(master) + 1}; + env(ticket::create(master, 1), Txflags(tfFullyCanonicalSig)); checkTicketCreateMeta(env); env.close(); - env.require(owners(master, 2), tickets(master, 2)); + env.require(Owners(master, 2), tickets(master, 2)); - env(ticket::create(master, 1), txflags(tfSell), ter(temINVALID_FLAG)); + env(ticket::create(master, 1), Txflags(tfSell), Ter(temINVALID_FLAG)); env.close(); - env.require(owners(master, 2), tickets(master, 2)); + env.require(Owners(master, 2), tickets(master, 2)); // We successfully created 1 ticket earlier. Verify that we can // create 250 tickets in one shot. We must consume one ticket first. - env(noop(master), ticket::use(ticketSeq_A)); + env(noop(master), ticket::Use(ticketSeqA)); checkTicketConsumeMeta(env); env.close(); - env.require(owners(master, 1), tickets(master, 1)); + env.require(Owners(master, 1), tickets(master, 1)); - env(ticket::create(master, 250), ticket::use(ticketSeq_B)); + env(ticket::create(master, 250), ticket::Use(ticketSeqB)); checkTicketCreateMeta(env); env.close(); - env.require(owners(master, 250), tickets(master, 250)); + env.require(Owners(master, 250), tickets(master, 250)); } void @@ -419,7 +419,7 @@ class Ticket_test : public beast::unit_test::suite Account const alice{"alice"}; env.memoize(alice); - env(ticket::create(alice, 1), json(jss::Sequence, 1), ter(terNO_ACCOUNT)); + env(ticket::create(alice, 1), Json(jss::Sequence, 1), Ter(terNO_ACCOUNT)); } { // Exceed the threshold where tickets can no longer be @@ -433,31 +433,31 @@ class Ticket_test : public beast::unit_test::suite env(ticket::create(alice, 250)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); // Note that we can add one more ticket while consuming a ticket // because the final result is still 250 tickets. - env(ticket::create(alice, 1), ticket::use(ticketSeq + 0)); + env(ticket::create(alice, 1), ticket::Use(ticketSeq + 0)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); // Adding one more ticket will exceed the threshold. - env(ticket::create(alice, 2), ticket::use(ticketSeq + 1), ter(tecDIR_FULL)); + env(ticket::create(alice, 2), ticket::Use(ticketSeq + 1), Ter(tecDIR_FULL)); env.close(); - env.require(owners(alice, 249), tickets(alice, 249)); + env.require(Owners(alice, 249), tickets(alice, 249)); // Now we can successfully add one more ticket. - env(ticket::create(alice, 2), ticket::use(ticketSeq + 2)); + env(ticket::create(alice, 2), ticket::Use(ticketSeq + 2)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); // Since we're at 250, we can't add another ticket using a // sequence. - env(ticket::create(alice, 1), ter(tecDIR_FULL)); + env(ticket::create(alice, 1), Ter(tecDIR_FULL)); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); } { // Explore exceeding the ticket threshold from another angle. @@ -467,29 +467,29 @@ class Ticket_test : public beast::unit_test::suite env.fund(XRP(100000), alice); env.close(); - std::uint32_t const ticketSeq_AB{env.seq(alice) + 1}; + std::uint32_t const ticketSeqAb{env.seq(alice) + 1}; env(ticket::create(alice, 2)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); + env.require(Owners(alice, 2), tickets(alice, 2)); // Adding 250 tickets (while consuming one) will exceed the // threshold. - env(ticket::create(alice, 250), ticket::use(ticketSeq_AB + 0), ter(tecDIR_FULL)); + env(ticket::create(alice, 250), ticket::Use(ticketSeqAb + 0), Ter(tecDIR_FULL)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Adding 250 tickets (without consuming one) will exceed the // threshold. - env(ticket::create(alice, 250), ter(tecDIR_FULL)); + env(ticket::create(alice, 250), Ter(tecDIR_FULL)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Alice can now add 250 tickets while consuming one. - env(ticket::create(alice, 250), ticket::use(ticketSeq_AB + 1)); + env(ticket::create(alice, 250), ticket::Use(ticketSeqAb + 1)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); } } @@ -506,9 +506,9 @@ class Ticket_test : public beast::unit_test::suite env.fund(env.current()->fees().accountReserve(1) - drops(1), alice); env.close(); - env(ticket::create(alice, 1), ter(tecINSUFFICIENT_RESERVE)); + env(ticket::create(alice, 1), Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(alice, 0), tickets(alice, 0)); + env.require(Owners(alice, 0), tickets(alice, 0)); // Give alice enough to exactly meet the reserve for one Ticket. env(pay(env.master, alice, env.current()->fees().accountReserve(1) - env.balance(alice))); @@ -517,7 +517,7 @@ class Ticket_test : public beast::unit_test::suite env(ticket::create(alice, 1)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Give alice not quite enough to make the reserve for a total of // 250 Tickets. @@ -529,9 +529,9 @@ class Ticket_test : public beast::unit_test::suite // alice doesn't quite have the reserve for a total of 250 // Tickets, so the transaction fails. - env(ticket::create(alice, 249), ter(tecINSUFFICIENT_RESERVE)); + env(ticket::create(alice, 249), Ter(tecINSUFFICIENT_RESERVE)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); // Give alice enough so she can make the reserve for all 250 // Tickets. @@ -542,7 +542,7 @@ class Ticket_test : public beast::unit_test::suite env(ticket::create(alice, 249)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); BEAST_EXPECT(ticketSeq + 249 == env.seq(alice)); } @@ -559,77 +559,77 @@ class Ticket_test : public beast::unit_test::suite env.close(); // Successfully create tickets (using a sequence) - std::uint32_t const ticketSeq_AB{env.seq(alice) + 1}; + std::uint32_t const ticketSeqAb{env.seq(alice) + 1}; env(ticket::create(alice, 2)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); - BEAST_EXPECT(ticketSeq_AB + 2 == env.seq(alice)); + env.require(Owners(alice, 2), tickets(alice, 2)); + BEAST_EXPECT(ticketSeqAb + 2 == env.seq(alice)); // You can use a ticket to create one ticket ... - std::uint32_t const ticketSeq_C{env.seq(alice)}; - env(ticket::create(alice, 1), ticket::use(ticketSeq_AB + 0)); + std::uint32_t const ticketSeqC{env.seq(alice)}; + env(ticket::create(alice, 1), ticket::Use(ticketSeqAb + 0)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); - BEAST_EXPECT(ticketSeq_C + 1 == env.seq(alice)); + env.require(Owners(alice, 2), tickets(alice, 2)); + BEAST_EXPECT(ticketSeqC + 1 == env.seq(alice)); // ... you can use a ticket to create multiple tickets ... - std::uint32_t const ticketSeq_DE{env.seq(alice)}; - env(ticket::create(alice, 2), ticket::use(ticketSeq_AB + 1)); + std::uint32_t const ticketSeqDe{env.seq(alice)}; + env(ticket::create(alice, 2), ticket::Use(ticketSeqAb + 1)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 3), tickets(alice, 3)); - BEAST_EXPECT(ticketSeq_DE + 2 == env.seq(alice)); + env.require(Owners(alice, 3), tickets(alice, 3)); + BEAST_EXPECT(ticketSeqDe + 2 == env.seq(alice)); // ... and you can use a ticket for other things. - env(noop(alice), ticket::use(ticketSeq_DE + 0)); + env(noop(alice), ticket::Use(ticketSeqDe + 0)); checkTicketConsumeMeta(env); env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); - BEAST_EXPECT(ticketSeq_DE + 2 == env.seq(alice)); + env.require(Owners(alice, 2), tickets(alice, 2)); + BEAST_EXPECT(ticketSeqDe + 2 == env.seq(alice)); - env(pay(alice, env.master, XRP(20)), ticket::use(ticketSeq_DE + 1)); + env(pay(alice, env.master, XRP(20)), ticket::Use(ticketSeqDe + 1)); checkTicketConsumeMeta(env); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); - BEAST_EXPECT(ticketSeq_DE + 2 == env.seq(alice)); + env.require(Owners(alice, 1), tickets(alice, 1)); + BEAST_EXPECT(ticketSeqDe + 2 == env.seq(alice)); - env(trust(alice, env.master["USD"](20)), ticket::use(ticketSeq_C)); + env(trust(alice, env.master["USD"](20)), ticket::Use(ticketSeqC)); checkTicketConsumeMeta(env); env.close(); - env.require(owners(alice, 1), tickets(alice, 0)); - BEAST_EXPECT(ticketSeq_DE + 2 == env.seq(alice)); + env.require(Owners(alice, 1), tickets(alice, 0)); + BEAST_EXPECT(ticketSeqDe + 2 == env.seq(alice)); // Attempt to use a ticket that has already been used. - env(noop(alice), ticket::use(ticketSeq_C), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(ticketSeqC), Ter(tefNO_TICKET)); env.close(); // Attempt to use a ticket from the future. - std::uint32_t const ticketSeq_F{env.seq(alice) + 1}; - env(noop(alice), ticket::use(ticketSeq_F), ter(terPRE_TICKET)); + std::uint32_t const ticketSeqF{env.seq(alice) + 1}; + env(noop(alice), ticket::Use(ticketSeqF), Ter(terPRE_TICKET)); env.close(); // Now create the ticket. The retry will consume the new ticket. env(ticket::create(alice, 1)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 1), tickets(alice, 0)); - BEAST_EXPECT(ticketSeq_F + 1 == env.seq(alice)); + env.require(Owners(alice, 1), tickets(alice, 0)); + BEAST_EXPECT(ticketSeqF + 1 == env.seq(alice)); // Try a transaction that combines consuming a ticket with // AccountTxnID. - std::uint32_t const ticketSeq_G{env.seq(alice) + 1}; + std::uint32_t const ticketSeqG{env.seq(alice) + 1}; env(ticket::create(alice, 1)); checkTicketCreateMeta(env); env.close(); env(noop(alice), - ticket::use(ticketSeq_G), - json(R"({"AccountTxnID": "0"})"), - ter(temINVALID)); + ticket::Use(ticketSeqG), + Json(R"({"AccountTxnID": "0"})"), + Ter(temINVALID)); env.close(); - env.require(owners(alice, 2), tickets(alice, 1)); + env.require(Owners(alice, 2), tickets(alice, 1)); } void @@ -673,36 +673,36 @@ class Ticket_test : public beast::unit_test::suite // Successfully create several tickets (using a sequence). std::uint32_t ticketSeq{env.seq(alice)}; - static constexpr std::uint32_t ticketCount{10}; - env(ticket::create(alice, ticketCount)); - uint256 const txHash_1{getTxID()}; + static constexpr std::uint32_t kTICKET_COUNT{10}; + env(ticket::create(alice, kTICKET_COUNT)); + uint256 const txHash1{getTxID()}; // Just for grins use the tickets in reverse from largest to smallest. - ticketSeq += ticketCount; - env(noop(alice), ticket::use(--ticketSeq)); - uint256 const txHash_2{getTxID()}; + ticketSeq += kTICKET_COUNT; + env(noop(alice), ticket::Use(--ticketSeq)); + uint256 const txHash2{getTxID()}; - env(pay(alice, env.master, XRP(200)), ticket::use(--ticketSeq)); - uint256 const txHash_3{getTxID()}; + env(pay(alice, env.master, XRP(200)), ticket::Use(--ticketSeq)); + uint256 const txHash3{getTxID()}; - env(deposit::auth(alice, env.master), ticket::use(--ticketSeq)); - uint256 const txHash_4{getTxID()}; + env(deposit::auth(alice, env.master), ticket::Use(--ticketSeq)); + uint256 const txHash4{getTxID()}; // Close the ledger so we look at transactions from a couple of // different ledgers. env.close(); - env(pay(alice, env.master, XRP(300)), ticket::use(--ticketSeq)); - uint256 const txHash_5{getTxID()}; + env(pay(alice, env.master, XRP(300)), ticket::Use(--ticketSeq)); + uint256 const txHash5{getTxID()}; - env(pay(alice, env.master, XRP(400)), ticket::use(--ticketSeq)); - uint256 const txHash_6{getTxID()}; + env(pay(alice, env.master, XRP(400)), ticket::Use(--ticketSeq)); + uint256 const txHash6{getTxID()}; - env(deposit::unauth(alice, env.master), ticket::use(--ticketSeq)); - uint256 const txHash_7{getTxID()}; + env(deposit::unauth(alice, env.master), ticket::Use(--ticketSeq)); + uint256 const txHash7{getTxID()}; - env(noop(alice), ticket::use(--ticketSeq)); - uint256 const txHash_8{getTxID()}; + env(noop(alice), ticket::Use(--ticketSeq)); + uint256 const txHash8{getTxID()}; env.close(); @@ -718,13 +718,13 @@ class Ticket_test : public beast::unit_test::suite std::uint32_t txSeq, std::optional ticketSeq, TxType txType) { - error_code_i txErrCode{rpcSUCCESS}; + ErrorCodeI txErrCode{RpcSuccess}; using TxPair = std::pair, std::shared_ptr>; std::variant maybeTx = Transaction::load(txID, env.app(), txErrCode); - BEAST_EXPECT(txErrCode == rpcSUCCESS); + BEAST_EXPECT(txErrCode == RpcSuccess); if (auto txPtr = std::get_if(&maybeTx)) { std::shared_ptr const& tx = txPtr->first; @@ -742,22 +742,22 @@ class Ticket_test : public beast::unit_test::suite }; // txID ledgerSeq txSeq ticketSeq txType - checkTxFromDB(txHash_1, 4, 4, {}, ttTICKET_CREATE); - checkTxFromDB(txHash_2, 4, 0, 13, ttACCOUNT_SET); - checkTxFromDB(txHash_3, 4, 0, 12, ttPAYMENT); - checkTxFromDB(txHash_4, 4, 0, 11, ttDEPOSIT_PREAUTH); + checkTxFromDB(txHash1, 4, 4, {}, ttTICKET_CREATE); + checkTxFromDB(txHash2, 4, 0, 13, ttACCOUNT_SET); + checkTxFromDB(txHash3, 4, 0, 12, ttPAYMENT); + checkTxFromDB(txHash4, 4, 0, 11, ttDEPOSIT_PREAUTH); - checkTxFromDB(txHash_5, 5, 0, 10, ttPAYMENT); - checkTxFromDB(txHash_6, 5, 0, 9, ttPAYMENT); - checkTxFromDB(txHash_7, 5, 0, 8, ttDEPOSIT_PREAUTH); - checkTxFromDB(txHash_8, 5, 0, 7, ttACCOUNT_SET); + checkTxFromDB(txHash5, 5, 0, 10, ttPAYMENT); + checkTxFromDB(txHash6, 5, 0, 9, ttPAYMENT); + checkTxFromDB(txHash7, 5, 0, 8, ttDEPOSIT_PREAUTH); + checkTxFromDB(txHash8, 5, 0, 7, ttACCOUNT_SET); } void testSignWithTicketSequence() { // The sign and the submit RPC commands automatically fill in the - // Sequence field of a transaction if none is provided. If a + // Sequence field of a transaction if kNONE is provided. If a // TicketSequence is provided in the transaction, then the // auto-filled Sequence should be zero. testcase("Sign with TicketSequence"); @@ -774,16 +774,16 @@ class Ticket_test : public beast::unit_test::suite env(ticket::create(alice, 2)); checkTicketCreateMeta(env); env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); + env.require(Owners(alice, 2), tickets(alice, 2)); BEAST_EXPECT(ticketSeq + 2 == env.seq(alice)); { // Test that the "sign" RPC command fills in a "Sequence": 0 field - // if none is provided. + // if kNONE is provided. // Create a noop transaction using a TicketSequence but don't fill // in the Sequence field. - Json::Value tx = Json::objectValue; + json::Value tx = json::ObjectValue; tx[jss::tx_json] = noop(alice); tx[jss::tx_json][sfTicketSequence.jsonName] = ticketSeq; tx[jss::secret] = toBase58(generateSeed("alice")); @@ -793,7 +793,7 @@ class Ticket_test : public beast::unit_test::suite // Call the "sign" RPC command and see the "Sequence": 0 field // filled in. - Json::Value jr = env.rpc("json", "sign", to_string(tx)); + json::Value jr = env.rpc("json", "sign", to_string(tx)); // Verify that "sign" inserted a "Sequence": 0 field. if (BEAST_EXPECT(jr[jss::result][jss::tx_json].isMember(sfSequence.jsonName))) @@ -803,20 +803,20 @@ class Ticket_test : public beast::unit_test::suite // "sign" should not have consumed any of alice's tickets. env.close(); - env.require(owners(alice, 2), tickets(alice, 2)); + env.require(Owners(alice, 2), tickets(alice, 2)); // "submit" the signed blob and see one of alice's tickets consumed. env.rpc("submit", jr[jss::result][jss::tx_blob].asString()); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); } { // Test that the "submit" RPC command fills in a "Sequence": 0 - // field if none is provided. + // field if kNONE is provided. // Create a noop transaction using a TicketSequence but don't fill // in the Sequence field. - Json::Value tx = Json::objectValue; + json::Value tx = json::ObjectValue; tx[jss::tx_json] = noop(alice); tx[jss::tx_json][sfTicketSequence.jsonName] = ticketSeq + 1; tx[jss::secret] = toBase58(generateSeed("alice")); @@ -826,7 +826,7 @@ class Ticket_test : public beast::unit_test::suite // Call the "submit" RPC command and see the "Sequence": 0 field // filled in. - Json::Value jr = env.rpc("json", "submit", to_string(tx)); + json::Value jr = env.rpc("json", "submit", to_string(tx)); // Verify that "submit" inserted a "Sequence": 0 field. if (BEAST_EXPECT(jr[jss::result][jss::tx_json].isMember(sfSequence.jsonName))) @@ -836,7 +836,7 @@ class Ticket_test : public beast::unit_test::suite // "submit" should have consumed the last of alice's tickets. env.close(); - env.require(owners(alice, 0), tickets(alice, 0)); + env.require(Owners(alice, 0), tickets(alice, 0)); } } @@ -849,7 +849,7 @@ class Ticket_test : public beast::unit_test::suite // and a TicketSequence field. Verify that the error is detected. testcase("Fix both Seq and Ticket"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const alice{"alice"}; env.fund(XRP(10000), alice); @@ -859,17 +859,17 @@ class Ticket_test : public beast::unit_test::suite std::uint32_t const ticketSeq = env.seq(alice) + 1; env(ticket::create(alice, 1)); env.close(); - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); BEAST_EXPECT(ticketSeq + 1 == env.seq(alice)); // Create a transaction that includes both a ticket and a non-zero // sequence number. The transaction fails with temSEQ_AND_TICKET. - env(noop(alice), ticket::use(ticketSeq), seq(env.seq(alice)), ter(temSEQ_AND_TICKET)); + env(noop(alice), ticket::Use(ticketSeq), Seq(env.seq(alice)), Ter(temSEQ_AND_TICKET)); env.close(); // Verify that the transaction failed by looking at alice's // sequence number and tickets. - env.require(owners(alice, 1), tickets(alice, 1)); + env.require(Owners(alice, 1), tickets(alice, 1)); BEAST_EXPECT(ticketSeq + 1 == env.seq(alice)); } diff --git a/src/test/app/Transaction_ordering_test.cpp b/src/test/app/Transaction_ordering_test.cpp index af5001b06e..50340497a4 100644 --- a/src/test/app/Transaction_ordering_test.cpp +++ b/src/test/app/Transaction_ordering_test.cpp @@ -20,7 +20,7 @@ namespace xrpl::test { -struct Transaction_ordering_test : public beast::unit_test::suite +struct Transaction_ordering_test : public beast::unit_test::Suite { void testCorrectOrder() @@ -34,8 +34,8 @@ struct Transaction_ordering_test : public beast::unit_test::suite auto const aliceSequence = env.seq(alice); - auto const tx1 = env.jt(noop(alice), seq(aliceSequence)); - auto const tx2 = env.jt(noop(alice), seq(aliceSequence + 1), last_ledger_seq(7)); + auto const tx1 = env.jt(noop(alice), Seq(aliceSequence)); + auto const tx2 = env.jt(noop(alice), Seq(aliceSequence + 1), LastLedgerSeq(7)); env(tx1); env.close(); @@ -73,10 +73,10 @@ struct Transaction_ordering_test : public beast::unit_test::suite auto const aliceSequence = env.seq(alice); - auto const tx1 = env.jt(noop(alice), seq(aliceSequence)); - auto const tx2 = env.jt(noop(alice), seq(aliceSequence + 1), last_ledger_seq(7)); + auto const tx1 = env.jt(noop(alice), Seq(aliceSequence)); + auto const tx2 = env.jt(noop(alice), Seq(aliceSequence + 1), LastLedgerSeq(7)); - env(tx2, ter(terPRE_SEQ)); + env(tx2, Ter(terPRE_SEQ)); BEAST_EXPECT(env.seq(alice) == aliceSequence); env(tx1); env.app().getJobQueue().rendezvous(); @@ -116,12 +116,12 @@ struct Transaction_ordering_test : public beast::unit_test::suite tx.reserve(kSIZE); for (auto i = 0; i < kSIZE; ++i) { - tx.emplace_back(env.jt(noop(alice), seq(aliceSequence + i), last_ledger_seq(7))); + tx.emplace_back(env.jt(noop(alice), Seq(aliceSequence + i), LastLedgerSeq(7))); } for (auto i = 1; i < kSIZE; ++i) { - env(tx[i], ter(terPRE_SEQ)); + env(tx[i], Ter(terPRE_SEQ)); BEAST_EXPECT(env.seq(alice) == aliceSequence); } diff --git a/src/test/app/TrustAndBalance_test.cpp b/src/test/app/TrustAndBalance_test.cpp index e6cc7e71ca..fe3d442f73 100644 --- a/src/test/app/TrustAndBalance_test.cpp +++ b/src/test/app/TrustAndBalance_test.cpp @@ -23,7 +23,7 @@ namespace xrpl { -class TrustAndBalance_test : public beast::unit_test::suite +class TrustAndBalance_test : public beast::unit_test::Suite { void testPayNonexistent(FeatureBitset features) @@ -32,7 +32,7 @@ class TrustAndBalance_test : public beast::unit_test::suite using namespace test::jtx; Env env{*this, features}; - env(pay(env.master, "alice", XRP(1)), ter(tecNO_DST_INSUF_XRP)); + env(pay(env.master, "alice", XRP(1)), Ter(tecNO_DST_INSUF_XRP)); env.close(); } @@ -45,7 +45,7 @@ class TrustAndBalance_test : public beast::unit_test::suite Env env{*this}; Account const alice{"alice"}; - env(trust(env.master, alice["USD"](100)), ter(tecNO_DST)); + env(trust(env.master, alice["USD"](100)), Ter(tecNO_DST)); } void @@ -92,7 +92,7 @@ class TrustAndBalance_test : public beast::unit_test::suite BEAST_EXPECT(jrr[jss::node][sfLowLimit.fieldName][jss::currency] == "USD"); // set negative limit - expect failure - env(trust(alice, gw["USD"](-1)), ter(temBAD_LIMIT)); + env(trust(alice, gw["USD"](-1)), Ter(temBAD_LIMIT)); // set zero limit env(trust(alice, gw["USD"](0))); @@ -138,34 +138,34 @@ class TrustAndBalance_test : public beast::unit_test::suite // alice sends bob partial with alice as issuer env(pay(alice, bob, alice["USD"](24))); - env.require(balance(bob, alice["USD"](24))); + env.require(Balance(bob, alice["USD"](24))); // alice sends bob more with bob as issuer env(pay(alice, bob, bob["USD"](33))); - env.require(balance(bob, alice["USD"](57))); + env.require(Balance(bob, alice["USD"](57))); // bob sends back more than sent env(pay(bob, alice, bob["USD"](90))); - env.require(balance(bob, alice["USD"](-33))); + env.require(Balance(bob, alice["USD"](-33))); // alice sends to her limit env(pay(alice, bob, bob["USD"](733))); - env.require(balance(bob, alice["USD"](700))); + env.require(Balance(bob, alice["USD"](700))); // bob sends to his limit env(pay(bob, alice, bob["USD"](1300))); - env.require(balance(bob, alice["USD"](-600))); + env.require(Balance(bob, alice["USD"](-600))); // bob sends past limit - env(pay(bob, alice, bob["USD"](1)), ter(tecPATH_DRY)); - env.require(balance(bob, alice["USD"](-600))); + env(pay(bob, alice, bob["USD"](1)), Ter(tecPATH_DRY)); + env.require(Balance(bob, alice["USD"](-600))); } void - testWithTransferFee(bool subscribe, bool with_rate, FeatureBitset features) + testWithTransferFee(bool subscribe, bool withRate, FeatureBitset features) { testcase( - std::string("Direct Payment: ") + (with_rate ? "With " : "Without ") + " Xfer Fee, " + + std::string("Direct Payment: ") + (withRate ? "With " : "Without ") + " Xfer Fee, " + (subscribe ? "With " : "Without ") + " Subscribe"); using namespace test::jtx; @@ -184,23 +184,23 @@ class TrustAndBalance_test : public beast::unit_test::suite env(pay(gw, alice, alice["AUD"](1))); env.close(); - env.require(balance(alice, gw["AUD"](1))); + env.require(Balance(alice, gw["AUD"](1))); // alice sends bob 1 AUD env(pay(alice, bob, gw["AUD"](1))); env.close(); - env.require(balance(alice, gw["AUD"](0))); - env.require(balance(bob, gw["AUD"](1))); - env.require(balance(gw, bob["AUD"](-1))); + env.require(Balance(alice, gw["AUD"](0))); + env.require(Balance(bob, gw["AUD"](1))); + env.require(Balance(gw, bob["AUD"](-1))); - if (with_rate) + if (withRate) { // set a transfer rate env(rate(gw, 1.1)); env.close(); // bob sends alice 0.5 AUD with a max to spend - env(pay(bob, alice, gw["AUD"](0.5)), sendmax(gw["AUD"](0.55))); + env(pay(bob, alice, gw["AUD"](0.5)), Sendmax(gw["AUD"](0.55))); } else { @@ -208,16 +208,16 @@ class TrustAndBalance_test : public beast::unit_test::suite env(pay(bob, alice, gw["AUD"](0.5))); } - env.require(balance(alice, gw["AUD"](0.5))); - env.require(balance(bob, gw["AUD"](with_rate ? 0.45 : 0.5))); - env.require(balance(gw, bob["AUD"](with_rate ? -0.45 : -0.5))); + env.require(Balance(alice, gw["AUD"](0.5))); + env.require(Balance(bob, gw["AUD"](withRate ? 0.45 : 0.5))); + env.require(Balance(gw, bob["AUD"](withRate ? -0.45 : -0.5))); if (subscribe) { - Json::Value jvs; - jvs[jss::accounts] = Json::arrayValue; + json::Value jvs; + jvs[jss::accounts] = json::ArrayValue; jvs[jss::accounts].append(gw.human()); - jvs[jss::streams] = Json::arrayValue; + jvs[jss::streams] = json::ArrayValue; jvs[jss::streams].append("transactions"); jvs[jss::streams].append("ledger"); auto jv = wsc->invoke("subscribe", jvs); @@ -258,30 +258,30 @@ class TrustAndBalance_test : public beast::unit_test::suite env(trust(bob, gw["AUD"](100))); env(pay(gw, alice, alice["AUD"](4.4))); - env.require(balance(alice, gw["AUD"](4.4))); + env.require(Balance(alice, gw["AUD"](4.4))); // alice sends gw issues to bob with a max spend that allows for the // xfer rate - env(pay(alice, bob, gw["AUD"](1)), sendmax(gw["AUD"](1.1))); - env.require(balance(alice, gw["AUD"](3.3))); - env.require(balance(bob, gw["AUD"](1))); + env(pay(alice, bob, gw["AUD"](1)), Sendmax(gw["AUD"](1.1))); + env.require(Balance(alice, gw["AUD"](3.3))); + env.require(Balance(bob, gw["AUD"](1))); // alice sends bob issues to bob with a max spend - env(pay(alice, bob, bob["AUD"](1)), sendmax(gw["AUD"](1.1))); - env.require(balance(alice, gw["AUD"](2.2))); - env.require(balance(bob, gw["AUD"](2))); + env(pay(alice, bob, bob["AUD"](1)), Sendmax(gw["AUD"](1.1))); + env.require(Balance(alice, gw["AUD"](2.2))); + env.require(Balance(bob, gw["AUD"](2))); // alice sends gw issues to bob with a max spend - env(pay(alice, bob, gw["AUD"](1)), sendmax(alice["AUD"](1.1))); - env.require(balance(alice, gw["AUD"](1.1))); - env.require(balance(bob, gw["AUD"](3))); + env(pay(alice, bob, gw["AUD"](1)), Sendmax(alice["AUD"](1.1))); + env.require(Balance(alice, gw["AUD"](1.1))); + env.require(Balance(bob, gw["AUD"](3))); // alice sends bob issues to bob with a max spend in alice issues. // expect fail since gw is not involved - env(pay(alice, bob, bob["AUD"](1)), sendmax(alice["AUD"](1.1)), ter(tecPATH_DRY)); + env(pay(alice, bob, bob["AUD"](1)), Sendmax(alice["AUD"](1.1)), Ter(tecPATH_DRY)); - env.require(balance(alice, gw["AUD"](1.1))); - env.require(balance(bob, gw["AUD"](3))); + env.require(Balance(alice, gw["AUD"](1.1))); + env.require(Balance(bob, gw["AUD"](3))); } void @@ -304,32 +304,32 @@ class TrustAndBalance_test : public beast::unit_test::suite env(pay(gw, alice, alice["USD"](70))); env(pay(gw, bob, bob["USD"](50))); - env.require(balance(alice, gw["USD"](70))); - env.require(balance(bob, gw["USD"](50))); + env.require(Balance(alice, gw["USD"](70))); + env.require(Balance(bob, gw["USD"](50))); // alice sends more than has to issuer: 100 out of 70 - env(pay(alice, gw, gw["USD"](100)), ter(tecPATH_PARTIAL)); + env(pay(alice, gw, gw["USD"](100)), Ter(tecPATH_PARTIAL)); // alice sends more than has to bob: 100 out of 70 - env(pay(alice, bob, gw["USD"](100)), ter(tecPATH_PARTIAL)); + env(pay(alice, bob, gw["USD"](100)), Ter(tecPATH_PARTIAL)); env.close(); - env.require(balance(alice, gw["USD"](70))); - env.require(balance(bob, gw["USD"](50))); + env.require(Balance(alice, gw["USD"](70))); + env.require(Balance(bob, gw["USD"](50))); // send with an account path - env(pay(alice, bob, gw["USD"](5)), test::jtx::path(gw)); + env(pay(alice, bob, gw["USD"](5)), test::jtx::Path(gw)); - env.require(balance(alice, gw["USD"](65))); - env.require(balance(bob, gw["USD"](55))); + env.require(Balance(alice, gw["USD"](65))); + env.require(Balance(bob, gw["USD"](55))); } void - testIndirectMultiPath(bool with_rate, FeatureBitset features) + testIndirectMultiPath(bool withRate, FeatureBitset features) { testcase( - std::string("Indirect Payment, Multi Path, ") + (with_rate ? "With " : "Without ") + + std::string("Indirect Payment, Multi Path, ") + (withRate ? "With " : "Without ") + " Xfer Fee, "); using namespace test::jtx; @@ -349,7 +349,7 @@ class TrustAndBalance_test : public beast::unit_test::suite env(trust(carol, alice["USD"](700))); env(trust(carol, gw["USD"](1000))); - if (with_rate) + if (withRate) env(rate(gw, 1.1)); env(pay(gw, bob, bob["USD"](100))); @@ -357,33 +357,33 @@ class TrustAndBalance_test : public beast::unit_test::suite env.close(); // alice pays amazon via multiple paths - if (with_rate) + if (withRate) { env(pay(alice, amazon, gw["USD"](150)), - sendmax(alice["USD"](200)), - test::jtx::path(bob), - test::jtx::path(carol)); + Sendmax(alice["USD"](200)), + test::jtx::Path(bob), + test::jtx::Path(carol)); } else { - env(pay(alice, amazon, gw["USD"](150)), test::jtx::path(bob), test::jtx::path(carol)); + env(pay(alice, amazon, gw["USD"](150)), test::jtx::Path(bob), test::jtx::Path(carol)); } - if (with_rate) + if (withRate) { - env.require(balance( + env.require(Balance( alice, - STAmount(carol["USD"], 6500000000000000ull, -14, true, STAmount::unchecked{}))); - env.require(balance(carol, gw["USD"](35))); + STAmount(carol["USD"], 6500000000000000ull, -14, true, STAmount::Unchecked{}))); + env.require(Balance(carol, gw["USD"](35))); } else { - env.require(balance(alice, carol["USD"](-50))); - env.require(balance(carol, gw["USD"](50))); + env.require(Balance(alice, carol["USD"](-50))); + env.require(Balance(carol, gw["USD"](50))); } - env.require(balance(alice, bob["USD"](-100))); - env.require(balance(amazon, gw["USD"](150))); - env.require(balance(bob, gw["USD"](0))); + env.require(Balance(alice, bob["USD"](-100))); + env.require(Balance(amazon, gw["USD"](150))); + env.require(Balance(bob, gw["USD"](0))); } void @@ -399,18 +399,18 @@ class TrustAndBalance_test : public beast::unit_test::suite env.fund(XRP(10000), alice); env.close(); - Json::Value jvs; - jvs[jss::accounts] = Json::arrayValue; + json::Value jvs; + jvs[jss::accounts] = json::ArrayValue; jvs[jss::accounts].append(env.master.human()); - jvs[jss::streams] = Json::arrayValue; + jvs[jss::streams] = json::ArrayValue; jvs[jss::streams].append("transactions"); BEAST_EXPECT(wsc->invoke("subscribe", jvs)[jss::status] == "success"); char const* invoiceId = "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89"; - Json::Value jv; + json::Value jv; auto tx = - env.jt(pay(env.master, alice, XRP(10000)), json(sfInvoiceID.fieldName, invoiceId)); + env.jt(pay(env.master, alice, XRP(10000)), Json(sfInvoiceID.fieldName, invoiceId)); jv[jss::tx_blob] = strHex(tx.stx->getSerializer().slice()); auto jrr = wsc->invoke("submit", jv)[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); @@ -448,7 +448,7 @@ public: }; using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeatures(sa - featurePermissionedDEX); testWithFeatures(sa); } diff --git a/src/test/app/TrustSet_test.cpp b/src/test/app/TrustSet_test.cpp index 6d24b695c7..31b7e97ee7 100644 --- a/src/test/app/TrustSet_test.cpp +++ b/src/test/app/TrustSet_test.cpp @@ -26,7 +26,7 @@ namespace xrpl::test { -class TrustSet_test : public beast::unit_test::suite +class TrustSet_test : public beast::unit_test::Suite { public: void @@ -57,7 +57,7 @@ public: env.require(lines(becky, 1)); // Fetch the trust-lines via RPC for verification - Json::Value jv; + json::Value jv; jv["account"] = becky.human(); auto beckyLines = env.rpc("json", "account_lines", to_string(jv)); @@ -135,7 +135,7 @@ public: env.require(lines(becky, 1)); // Fetch the trust-lines via RPC for verification - Json::Value jv; + json::Value jv; jv["account"] = becky.human(); auto beckyLines = env.rpc("json", "account_lines", to_string(jv)); @@ -201,24 +201,24 @@ public: + drops(3 * txFee) /* and to pay for 3 transactions */, creator); - env(trust(creator, gwA["USD"](100)), require(lines(creator, 1))); - env(trust(creator, gwB["USD"](100)), require(lines(creator, 2))); + env(trust(creator, gwA["USD"](100)), Require(lines(creator, 1))); + env(trust(creator, gwB["USD"](100)), Require(lines(creator, 2))); if (thirdLineCreatesLE) { // creator does not have enough for the third trust line env(trust(creator, assistor["USD"](100)), - ter(tecNO_LINE_INSUF_RESERVE), - require(lines(creator, 2))); + Ter(tecNO_LINE_INSUF_RESERVE), + Require(lines(creator, 2))); } else { // First establish opposite trust direction from assistor - env(trust(assistor, creator["USD"](100)), require(lines(creator, 3))); + env(trust(assistor, creator["USD"](100)), Require(lines(creator, 3))); // creator does not have enough to create the other direction on // the existing trust line ledger entry - env(trust(creator, assistor["USD"](100)), ter(tecINSUF_RESERVE_LINE)); + env(trust(creator, assistor["USD"](100)), Ter(tecINSUF_RESERVE_LINE)); } // Fund creator additional amount to cover @@ -226,13 +226,13 @@ public: if (thirdLineCreatesLE) { - env(trust(creator, assistor["USD"](100)), require(lines(creator, 3))); + env(trust(creator, assistor["USD"](100)), Require(lines(creator, 3))); } else { - env(trust(creator, assistor["USD"](100)), require(lines(creator, 3))); + env(trust(creator, assistor["USD"](100)), Require(lines(creator, 3))); - Json::Value jv; + json::Value jv; jv["account"] = creator.human(); auto const lines = env.rpc("json", "account_lines", to_string(jv)); // Verify that all lines have 100 limit from creator @@ -256,13 +256,13 @@ public: Env env{*this, features}; auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice); env.close(); // Cannot pay alice without a trustline. - env(pay(gw, alice, USD(200)), ter(tecPATH_DRY)); + env(pay(gw, alice, usd(200)), Ter(tecPATH_DRY)); env.close(); // Create a ticket. @@ -271,20 +271,20 @@ public: env.close(); // Use that ticket to create a trust line. - env(trust(alice, USD(1000)), ticket::use(ticketSeq)); + env(trust(alice, usd(1000)), ticket::Use(ticketSeq)); env.close(); // Now the payment succeeds. - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); } - static Json::Value - trust_explicit_amt(jtx::Account const& a, STAmount const& amt) + static json::Value + trustExplicitAmt(jtx::Account const& a, STAmount const& amt) { - Json::Value jv; + json::Value jv; jv[jss::Account] = a.human(); - jv[jss::LimitAmount] = amt.getJson(JsonOptions::none); + jv[jss::LimitAmount] = amt.getJson(JsonOptions::KNone); jv[jss::TransactionType] = jss::TrustSet; jv[jss::Flags] = 0; return jv; @@ -309,28 +309,28 @@ public: if ((badFlag & tfTrustSetMask) != 0u) { env(trust(alice, gw["USD"](100), static_cast(badFlag)), - ter(temINVALID_FLAG)); + Ter(temINVALID_FLAG)); } } // trust amount can't be XRP - env(trust_explicit_amt(alice, drops(10000)), ter(temBAD_LIMIT)); + env(trustExplicitAmt(alice, drops(10000)), Ter(temBAD_LIMIT)); // trust amount can't be badCurrency IOU - env(trust_explicit_amt(alice, gw[to_string(badCurrency())](100)), ter(temBAD_CURRENCY)); + env(trustExplicitAmt(alice, gw[to_string(badCurrency())](100)), Ter(temBAD_CURRENCY)); // trust amount can't be negative - env(trust(alice, gw["USD"](-1000)), ter(temBAD_LIMIT)); + env(trust(alice, gw["USD"](-1000)), Ter(temBAD_LIMIT)); // trust amount can't be from invalid issuer - env(trust_explicit_amt(alice, STAmount{Issue{to_currency("USD"), noAccount()}, 100}), - ter(temDST_NEEDED)); + env(trustExplicitAmt(alice, STAmount{Issue{toCurrency("USD"), noAccount()}, 100}), + Ter(temDST_NEEDED)); // trust cannot be to self - env(trust(alice, alice["USD"](100)), ter(temDST_IS_SRC)); + env(trust(alice, alice["USD"](100)), Ter(temDST_IS_SRC)); // tfSetAuth flag should not be set if not required by lsfRequireAuth - env(trust(alice, gw["USD"](100), tfSetfAuth), ter(tefNO_AUTH_REQUIRED)); + env(trust(alice, gw["USD"](100), tfSetfAuth), Ter(tefNO_AUTH_REQUIRED)); } void @@ -352,7 +352,7 @@ public: env.close(); // send a payment for a large quantity through the trust line - env(pay(gw, alice, gw["USD"](200)), ter(tecPATH_PARTIAL)); + env(pay(gw, alice, gw["USD"](200)), Ter(tecPATH_PARTIAL)); env.close(); // on the other hand, smaller payments should succeed @@ -385,7 +385,7 @@ public: env.close(); // send a payment from alice to bob, validate that the payment fails - env(pay(alice, bob, alice["USD"](10)), ter(tecPATH_DRY)); + env(pay(alice, bob, alice["USD"](10)), Ter(tecPATH_DRY)); env.close(); } @@ -409,21 +409,21 @@ public: env.close(); // archetypical payment transaction from alice to bob must succeed - env(pay(alice, bob, alice["USD"](20)), ter(tesSUCCESS)); + env(pay(alice, bob, alice["USD"](20)), Ter(tesSUCCESS)); env.close(); // Issued tokens are fungible. i.e. alice's USD is identical to bob's // USD - env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS)); + env(pay(bob, alice, bob["USD"](10)), Ter(tesSUCCESS)); env.close(); // bob cannot place alice in his debt i.e. alice's balance of the USD // tokens cannot go below zero. - env(pay(bob, alice, bob["USD"](11)), ter(tecPATH_PARTIAL)); + env(pay(bob, alice, bob["USD"](11)), Ter(tecPATH_PARTIAL)); env.close(); // payments that respect the trust line limits of alice should succeed - env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS)); + env(pay(bob, alice, bob["USD"](10)), Ter(tesSUCCESS)); env.close(); } @@ -456,8 +456,8 @@ public: auto& tx1 = createQuality ? txWithQuality : txWithoutQuality; auto& tx2 = createQuality ? txWithoutQuality : txWithQuality; - auto check_quality = [&](bool const exists) { - Json::Value jv; + auto checkQuality = [&](bool const exists) { + json::Value jv; jv["account"] = toAcct.human(); auto const lines = env.rpc("json", "account_lines", to_string(jv)); auto quality = exists ? 1000 : 0; @@ -467,11 +467,11 @@ public: BEAST_EXPECT(lines[jss::result][jss::lines][0u][jss::quality_out] == quality); }; - env(tx1, require(lines(toAcct, 1)), require(lines(fromAcct, 1))); - check_quality(createQuality); + env(tx1, Require(lines(toAcct, 1)), Require(lines(fromAcct, 1))); + checkQuality(createQuality); - env(tx2, require(lines(toAcct, 1)), require(lines(fromAcct, 1))); - check_quality(!createQuality); + env(tx2, Require(lines(toAcct, 1)), Require(lines(fromAcct, 1))); + checkQuality(!createQuality); } void @@ -490,7 +490,7 @@ public: Env env{*this, amend}; auto const dist = Account("dist"); auto const gw = Account("gw"); - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; auto const distUSD = dist["USD"]; env.fund(XRP(1000), gw, dist); @@ -502,17 +502,17 @@ public: env(fset(dist, asfDisallowIncomingTrustline)); env.close(); - env(trust(dist, USD(10000))); + env(trust(dist, usd(10000))); env.close(); // withFix: can set trustline // withOutFix: cannot set trustline - auto const trustResult = withFix ? ter(tesSUCCESS) : ter(tecNO_PERMISSION); - env(trust(gw, distUSD(10000)), txflags(tfSetfAuth), trustResult); + auto const trustResult = withFix ? Ter(tesSUCCESS) : Ter(tecNO_PERMISSION); + env(trust(gw, distUSD(10000)), Txflags(tfSetfAuth), trustResult); env.close(); - auto const txResult = withFix ? ter(tesSUCCESS) : ter(tecPATH_DRY); - env(pay(gw, dist, USD(1000)), txResult); + auto const txResult = withFix ? Ter(tesSUCCESS) : Ter(tecPATH_DRY); + env(pay(gw, dist, usd(1000)), txResult); env.close(); } } @@ -522,7 +522,7 @@ public: auto const gw = Account{"gateway"}; auto const alice = Account{"alice"}; auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; + auto const usd = gw["USD"]; env.fund(XRP(10000), gw, alice, bob); env.close(); @@ -532,7 +532,7 @@ public: env.close(); // Create a trustline which will fail - env(trust(alice, USD(1000)), ter(tecNO_PERMISSION)); + env(trust(alice, usd(1000)), Ter(tecNO_PERMISSION)); env.close(); // Unset the flag @@ -540,11 +540,11 @@ public: env.close(); // Create a trustline which will now succeed - env(trust(alice, USD(1000))); + env(trust(alice, usd(1000))); env.close(); // Now the payment succeeds. - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Set flag on gateway again @@ -552,12 +552,12 @@ public: env.close(); // Destroy the balance by sending it back - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // The trustline still exists in default state // So a further payment should work - env(pay(gw, alice, USD(200))); + env(pay(gw, alice, usd(200))); env.close(); // Also set the flag on bob @@ -565,12 +565,12 @@ public: env.close(); // But now bob can't open a trustline because he didn't already have one - env(trust(bob, USD(1000)), ter(tecNO_PERMISSION)); + env(trust(bob, usd(1000)), Ter(tecNO_PERMISSION)); env.close(); // The gateway also can't open this trustline because bob has the flag // set - env(trust(gw, bob["USD"](1000)), ter(tecNO_PERMISSION)); + env(trust(gw, bob["USD"](1000)), Ter(tecNO_PERMISSION)); env.close(); // Unset the flag only on the gateway @@ -578,11 +578,11 @@ public: env.close(); // Now bob can open a trustline - env(trust(bob, USD(1000))); + env(trust(bob, usd(1000))); env.close(); // And the gateway can send bob a balance - env(pay(gw, bob, USD(200))); + env(pay(gw, bob, usd(200))); env.close(); } @@ -614,7 +614,7 @@ public: run() override { using namespace test::jtx; - auto const sa = testable_amendments(); + auto const sa = testableAmendments(); testWithFeats(sa); } }; diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 844a3cd743..52781ee9e3 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -57,11 +57,11 @@ namespace xrpl::test { -class TxQPosNegFlows_test : public beast::unit_test::suite +class TxQPosNegFlows_test : public beast::unit_test::Suite { // Same as corresponding values from TxQ.h - static constexpr FeeLevel64 baseFeeLevel{256}; - static constexpr FeeLevel64 minEscalationFeeLevel = baseFeeLevel * 500; + static constexpr FeeLevel64 kBASE_FEE_LEVEL{256}; + static constexpr FeeLevel64 kMIN_ESCALATION_FEE_LEVEL = kBASE_FEE_LEVEL * 500; static void fillQueue(jtx::Env& env, jtx::Account const& account) @@ -109,7 +109,7 @@ class TxQPosNegFlows_test : public beast::unit_test::suite { FeeLevel64 const expectedMedFeeLevel = (feeLevel1 + feeLevel2 + FeeLevel64{1}) / 2; - return std::max(expectedMedFeeLevel, minEscalationFeeLevel).fee(); + return std::max(expectedMedFeeLevel, kMIN_ESCALATION_FEE_LEVEL).fee(); } static auto @@ -179,7 +179,7 @@ public: auto hank = Account("hank"); auto iris = Account("iris"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -193,11 +193,11 @@ public: checkMetrics(*this, env, 1, std::nullopt, 4, 3); // Bob with really high fee - applies - env(noop(bob), fee(openLedgerCost(env))); + env(noop(bob), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, std::nullopt, 5, 3); // Daria with low fee: hold - env(noop(daria), fee(baseFee * 100), queued); + env(noop(daria), Fee(baseFee * 100), queued); checkMetrics(*this, env, 2, std::nullopt, 5, 3); env.close(); @@ -211,16 +211,16 @@ public: checkMetrics(*this, env, 0, 10, 6, 5); // Now get a bunch of transactions held. - env(noop(alice), fee(baseFee * 1.2), queued); + env(noop(alice), Fee(baseFee * 1.2), queued); checkMetrics(*this, env, 1, 10, 6, 5); - env(noop(bob), fee(baseFee), queued); // won't clear the queue - env(noop(charlie), fee(baseFee * 2), queued); - env(noop(daria), fee(baseFee * 1.5), queued); - env(noop(elmo), fee(baseFee * 1.1), queued); - env(noop(fred), fee(baseFee * 1.9), queued); - env(noop(gwen), fee(baseFee * 1.6), queued); - env(noop(hank), fee(baseFee * 1.8), queued); + env(noop(bob), Fee(baseFee), queued); // won't clear the queue + env(noop(charlie), Fee(baseFee * 2), queued); + env(noop(daria), Fee(baseFee * 1.5), queued); + env(noop(elmo), Fee(baseFee * 1.1), queued); + env(noop(fred), Fee(baseFee * 1.9), queued); + env(noop(gwen), Fee(baseFee * 1.6), queued); + env(noop(hank), Fee(baseFee * 1.8), queued); checkMetrics(*this, env, 8, 10, 6, 5); env.close(); @@ -232,32 +232,32 @@ public: ////////////////////////////////////////////////////////////// // Hank sends another txn - env(noop(hank), fee(baseFee), queued); + env(noop(hank), Fee(baseFee), queued); // But he's not going to leave it in the queue checkMetrics(*this, env, 2, 12, 7, 6); // Hank sees his txn got held and bumps the fee, // but doesn't even bump it enough to requeue - env(noop(hank), fee(baseFee * 1.1), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(hank), Fee(baseFee * 1.1), Ter(telCAN_NOT_QUEUE_FEE)); checkMetrics(*this, env, 2, 12, 7, 6); // Hank sees his txn got held and bumps the fee, // enough to requeue, but doesn't bump it enough to // apply to the ledger - env(noop(hank), fee(baseFee * 600), queued); + env(noop(hank), Fee(baseFee * 600), queued); // But he's not going to leave it in the queue checkMetrics(*this, env, 2, 12, 7, 6); // Hank sees his txn got held and bumps the fee, // high enough to get into the open ledger, because // he doesn't want to wait. - env(noop(hank), fee(openLedgerCost(env))); + env(noop(hank), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, 12, 8, 6); // Hank then sends another, less important txn // (In addition to the metrics, this will verify that // the original txn got removed.) - env(noop(hank), fee(baseFee * 2), queued); + env(noop(hank), Fee(baseFee * 2), queued); checkMetrics(*this, env, 2, 12, 8, 6); env.close(); @@ -276,39 +276,39 @@ public: ////////////////////////////////////////////////////////////// - constexpr auto largeFeeMultiplier = 700; - auto const largeFee = baseFee * largeFeeMultiplier; + constexpr auto kLARGE_FEE_MULTIPLIER = 700; + auto const largeFee = baseFee * kLARGE_FEE_MULTIPLIER; // Stuff the ledger and queue so we can verify that // stuff gets kicked out. - env(noop(hank), fee(largeFee)); - env(noop(gwen), fee(largeFee)); - env(noop(fred), fee(largeFee)); - env(noop(elmo), fee(largeFee)); + env(noop(hank), Fee(largeFee)); + env(noop(gwen), Fee(largeFee)); + env(noop(fred), Fee(largeFee)); + env(noop(elmo), Fee(largeFee)); checkMetrics(*this, env, 0, 6, 4, 3); // Use explicit fees so we can control which txn // will get dropped // This one gets into the queue, but gets dropped when the // higher fee one is added later. - env(noop(daria), fee(baseFee * 1.5), queued); + env(noop(daria), Fee(baseFee * 1.5), queued); // These stay in the queue. - env(noop(elmo), fee(baseFee * 1.6), queued); - env(noop(fred), fee(baseFee * 1.7), queued); - env(noop(gwen), fee(baseFee * 1.8), queued); - env(noop(hank), fee(baseFee * 1.9), queued); - env(noop(alice), fee(baseFee * 2.0), queued); + env(noop(elmo), Fee(baseFee * 1.6), queued); + env(noop(fred), Fee(baseFee * 1.7), queued); + env(noop(gwen), Fee(baseFee * 1.8), queued); + env(noop(hank), Fee(baseFee * 1.9), queued); + env(noop(alice), Fee(baseFee * 2.0), queued); // Queue is full now. checkMetrics(*this, env, 6, 6, 4, 3, txFeeLevelByAccount(env, daria) + 1); // Try to add another transaction with the default (low) fee, // it should fail because the queue is full. - env(noop(charlie), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(charlie), Ter(telCAN_NOT_QUEUE_FULL)); // Add another transaction, with a higher fee, // Not high enough to get into the ledger, but high // enough to get into the queue (and kick somebody out) - env(noop(charlie), fee(baseFee * 10), queued); + env(noop(charlie), Fee(baseFee * 10), queued); // Queue is still full, of course, but the min fee has gone up checkMetrics(*this, env, 6, 6, 4, 3, txFeeLevelByAccount(env, elmo) + 1); @@ -318,15 +318,9 @@ public: // point, daria's transaction that was dropped from the queue // is put back in. Neat. env.close(); - checkMetrics( - *this, - env, - 2, - 8, - 5, - 4, - baseFeeLevel.fee(), - calcMedFeeLevel(FeeLevel64{baseFeeLevel.fee() * largeFeeMultiplier})); + // clang-format off + checkMetrics(*this, env, 2, 8, 5, 4, kBASE_FEE_LEVEL.fee(), calcMedFeeLevel(FeeLevel64{kBASE_FEE_LEVEL.fee() * kLARGE_FEE_MULTIPLIER})); + // clang-format on env.close(); checkMetrics(*this, env, 0, 10, 2, 5); @@ -342,13 +336,13 @@ public: env(noop(charlie)); env(noop(daria)); env(pay(alice, iris, XRP(1000)), queued); - env(noop(iris), seq(1), fee(baseFee * 2), ter(terNO_ACCOUNT)); + env(noop(iris), Seq(1), Fee(baseFee * 2), Ter(terNO_ACCOUNT)); checkMetrics(*this, env, 1, 10, 6, 5); env.close(); checkMetrics(*this, env, 0, 12, 1, 6); - env.require(balance(iris, XRP(1000))); + env.require(Balance(iris, XRP(1000))); BEAST_EXPECT(env.seq(iris) == 11); ////////////////////////////////////////////////////////////// @@ -368,7 +362,7 @@ public: } // Queue one straightforward transaction - env(noop(env.master), fee(baseFee * 2), queued); + env(noop(env.master), Fee(baseFee * 2), queued); ++metrics.txCount; checkMetrics( @@ -390,7 +384,7 @@ public: auto alice = Account("alice"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -407,15 +401,15 @@ public: // Alice requests tickets, but that transaction is queued. So // Alice can't queue ticketed transactions yet. std::uint32_t const tkt1{env.seq(alice) + 1}; - env(ticket::create(alice, 250), seq(tkt1 - 1), queued); + env(ticket::create(alice, 250), Seq(tkt1 - 1), queued); - env(noop(alice), ticket::use(tkt1 - 2), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 - 1), ter(terPRE_TICKET)); - env.require(owners(alice, 0), tickets(alice, 0)); + env(noop(alice), ticket::Use(tkt1 - 2), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 - 1), Ter(terPRE_TICKET)); + env.require(Owners(alice, 0), tickets(alice, 0)); checkMetrics(*this, env, 1, std::nullopt, 4, 3); env.close(); - env.require(owners(alice, 250), tickets(alice, 250)); + env.require(Owners(alice, 250), tickets(alice, 250)); checkMetrics(*this, env, 0, 8, 1, 4); BEAST_EXPECT(env.seq(alice) == tkt1 + 250); @@ -427,20 +421,20 @@ public: // Demonstrate that. // Fill the ledger so we can start queuing things. - env(noop(alice), ticket::use(tkt1 + 1), fee(baseFee * 1.1)); - env(noop(alice), ticket::use(tkt1 + 2), fee(baseFee * 1.2)); - env(noop(alice), ticket::use(tkt1 + 3), fee(baseFee * 1.3)); - env(noop(alice), ticket::use(tkt1 + 4), fee(baseFee * 1.4)); - env(noop(alice), ticket::use(tkt1 + 5), fee(baseFee * 1.5), queued); + env(noop(alice), ticket::Use(tkt1 + 1), Fee(baseFee * 1.1)); + env(noop(alice), ticket::Use(tkt1 + 2), Fee(baseFee * 1.2)); + env(noop(alice), ticket::Use(tkt1 + 3), Fee(baseFee * 1.3)); + env(noop(alice), ticket::Use(tkt1 + 4), Fee(baseFee * 1.4)); + env(noop(alice), ticket::Use(tkt1 + 5), Fee(baseFee * 1.5), queued); auto const expectedMinFeeLevel = txFeeLevelByAccount(env, alice) + 1; - env(noop(alice), ticket::use(tkt1 + 6), fee(baseFee * 1.6), queued); - env(noop(alice), ticket::use(tkt1 + 7), fee(baseFee * 1.7), queued); - env(noop(alice), ticket::use(tkt1 + 8), fee(baseFee * 1.8), queued); - env(noop(alice), ticket::use(tkt1 + 9), fee(baseFee * 1.9), queued); - env(noop(alice), ticket::use(tkt1 + 10), fee(baseFee * 2.0), queued); - env(noop(alice), ticket::use(tkt1 + 11), fee(baseFee * 2.1), queued); - env(noop(alice), ticket::use(tkt1 + 12), fee(baseFee * 2.2), queued); - env(noop(alice), ticket::use(tkt1 + 13), fee(baseFee * 2.3), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(tkt1 + 6), Fee(baseFee * 1.6), queued); + env(noop(alice), ticket::Use(tkt1 + 7), Fee(baseFee * 1.7), queued); + env(noop(alice), ticket::Use(tkt1 + 8), Fee(baseFee * 1.8), queued); + env(noop(alice), ticket::Use(tkt1 + 9), Fee(baseFee * 1.9), queued); + env(noop(alice), ticket::Use(tkt1 + 10), Fee(baseFee * 2.0), queued); + env(noop(alice), ticket::Use(tkt1 + 11), Fee(baseFee * 2.1), queued); + env(noop(alice), ticket::Use(tkt1 + 12), Fee(baseFee * 2.2), queued); + env(noop(alice), ticket::Use(tkt1 + 13), Fee(baseFee * 2.3), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 8, 8, 5, 4, expectedMinFeeLevel); // Check which of the queued transactions got into the ledger by @@ -448,30 +442,30 @@ public: // o Get tefNO_TICKET if the ticket has already been used. // o Get telCAN_NOT_QUEUE_FEE if the transaction is still in the queue. env.close(); - env.require(owners(alice, 240), tickets(alice, 240)); + env.require(Owners(alice, 240), tickets(alice, 240)); // These 4 went straight to the ledger: - env(noop(alice), ticket::use(tkt1 + 1), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 2), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 3), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 4), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 1), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 2), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 3), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 4), Ter(tefNO_TICKET)); // These two are still in the TxQ: - env(noop(alice), ticket::use(tkt1 + 5), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt1 + 6), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 5), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 6), Ter(telCAN_NOT_QUEUE_FEE)); // These six were moved from the queue into the open ledger // since those with the highest fees go first. - env(noop(alice), ticket::use(tkt1 + 7), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 8), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 9), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 10), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 11), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 12), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 7), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 8), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 9), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 10), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 11), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 12), Ter(tefNO_TICKET)); // This last one was moved from the local transactions into // the queue. - env(noop(alice), ticket::use(tkt1 + 13), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 13), Ter(telCAN_NOT_QUEUE_FEE)); checkMetrics(*this, env, 3, 10, 6, 5); @@ -485,25 +479,25 @@ public: // The fee is escalated so unless we pay a sufficient fee // transactions will go straight to the queue. std::uint32_t const nextSeq{env.seq(alice)}; - env(noop(alice), seq(nextSeq + 1), ter(terPRE_SEQ)); - env(noop(alice), seq(nextSeq - 1), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 0), queued); + env(noop(alice), Seq(nextSeq + 1), Ter(terPRE_SEQ)); + env(noop(alice), Seq(nextSeq - 1), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 0), queued); // Now that nextSeq is in the queue, we should be able to queue // nextSeq + 1. - env(noop(alice), seq(nextSeq + 1), queued); + env(noop(alice), Seq(nextSeq + 1), queued); // Fill the queue with sequence-based transactions. When the // ledger closes we should find the three ticket-based // transactions gone from the queue (because they had the // highest fee). Then the earliest of the sequence-based // transactions should also be gone from the queue. - env(noop(alice), seq(nextSeq + 2), queued); - env(noop(alice), seq(nextSeq + 3), queued); - env(noop(alice), seq(nextSeq + 4), queued); - env(noop(alice), seq(nextSeq + 5), queued); - env(noop(alice), seq(nextSeq + 6), queued); - env(noop(alice), seq(nextSeq + 7), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(nextSeq + 2), queued); + env(noop(alice), Seq(nextSeq + 3), queued); + env(noop(alice), Seq(nextSeq + 4), queued); + env(noop(alice), Seq(nextSeq + 5), queued); + env(noop(alice), Seq(nextSeq + 6), queued); + env(noop(alice), Seq(nextSeq + 7), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 10, 10, 6, 5, 257); // Check which of the queued transactions got into the ledger by @@ -513,24 +507,24 @@ public: // o Get telCAN_NOT_QUEUE_FEE if the transaction is still in // the queue. env.close(); - env.require(owners(alice, 237), tickets(alice, 237)); + env.require(Owners(alice, 237), tickets(alice, 237)); // The four ticket-based transactions went out first, since // they paid the highest fee. - env(noop(alice), ticket::use(tkt1 + 4), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 5), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 12), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 13), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 4), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 5), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 12), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 13), Ter(tefNO_TICKET)); // Three of the sequence-based transactions also moved out of // the queue. - env(noop(alice), seq(nextSeq + 1), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 2), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 3), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 4), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), seq(nextSeq + 5), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), seq(nextSeq + 6), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), seq(nextSeq + 7), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 1), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 2), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 3), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 4), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 5), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 6), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 7), Ter(telCAN_NOT_QUEUE_FEE)); checkMetrics(*this, env, 4, 12, 7, 6); BEAST_EXPECT(env.seq(alice) == nextSeq + 4); @@ -540,46 +534,46 @@ public: // We haven't yet shown that ticket-based transactions can be added // to the queue in any order. We should do that... std::uint32_t const tkt250 = tkt1 + 249; - env(noop(alice), ticket::use(tkt250 - 0), fee(baseFee * 3.0), queued); - env(noop(alice), ticket::use(tkt1 + 14), fee(baseFee * 2.9), queued); - env(noop(alice), ticket::use(tkt250 - 1), fee(baseFee * 2.8), queued); - env(noop(alice), ticket::use(tkt1 + 15), fee(baseFee * 2.7), queued); - env(noop(alice), ticket::use(tkt250 - 2), fee(baseFee * 2.6), queued); - env(noop(alice), ticket::use(tkt1 + 16), fee(baseFee * 2.5), queued); - env(noop(alice), ticket::use(tkt250 - 3), fee(baseFee * 2.4), ter(telCAN_NOT_QUEUE_FULL)); - env(noop(alice), ticket::use(tkt1 + 17), fee(baseFee * 2.3), ter(telCAN_NOT_QUEUE_FULL)); - env(noop(alice), ticket::use(tkt250 - 4), fee(baseFee * 2.2), ter(telCAN_NOT_QUEUE_FULL)); - env(noop(alice), ticket::use(tkt1 + 18), fee(baseFee * 2.1), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(tkt250 - 0), Fee(baseFee * 3.0), queued); + env(noop(alice), ticket::Use(tkt1 + 14), Fee(baseFee * 2.9), queued); + env(noop(alice), ticket::Use(tkt250 - 1), Fee(baseFee * 2.8), queued); + env(noop(alice), ticket::Use(tkt1 + 15), Fee(baseFee * 2.7), queued); + env(noop(alice), ticket::Use(tkt250 - 2), Fee(baseFee * 2.6), queued); + env(noop(alice), ticket::Use(tkt1 + 16), Fee(baseFee * 2.5), queued); + env(noop(alice), ticket::Use(tkt250 - 3), Fee(baseFee * 2.4), Ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(tkt1 + 17), Fee(baseFee * 2.3), Ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(tkt250 - 4), Fee(baseFee * 2.2), Ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(tkt1 + 18), Fee(baseFee * 2.1), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 10, 12, 7, 6); env.close(); - env.require(owners(alice, 231), tickets(alice, 231)); + env.require(Owners(alice, 231), tickets(alice, 231)); // These three ticket-based transactions escaped the queue. - env(noop(alice), ticket::use(tkt1 + 14), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 15), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt1 + 16), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 14), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 15), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt1 + 16), Ter(tefNO_TICKET)); // But these four ticket-based transactions are in the queue // now; they moved into the TxQ from local transactions. - env(noop(alice), ticket::use(tkt250 - 3), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt1 + 17), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt250 - 4), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt1 + 18), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt250 - 3), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 17), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt250 - 4), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 18), Ter(telCAN_NOT_QUEUE_FEE)); // These three ticket-based transactions also escaped the queue. - env(noop(alice), ticket::use(tkt250 - 2), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt250 - 1), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt250 - 0), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt250 - 2), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt250 - 1), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt250 - 0), Ter(tefNO_TICKET)); // These sequence-based transactions escaped the queue. - env(noop(alice), seq(nextSeq + 4), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 5), ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 4), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 5), Ter(tefPAST_SEQ)); // But these sequence-based transactions are still stuck in the queue. - env(noop(alice), seq(nextSeq + 6), ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), seq(nextSeq + 7), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 6), Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(nextSeq + 7), Ter(telCAN_NOT_QUEUE_FEE)); BEAST_EXPECT(env.seq(alice) == nextSeq + 6); checkMetrics(*this, env, 6, 14, 8, 7); @@ -591,28 +585,28 @@ public: // The lowest fee ticket is baseFee * 2.1, trying to replace it env(noop(alice), - ticket::use(tkt1 + 18), - fee((baseFee * 2.1 * 1.25) - 1), - ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt1 + 18), fee((baseFee * 2.1 * 1.25) + 1), queued); + ticket::Use(tkt1 + 18), + Fee((baseFee * 2.1 * 1.25) - 1), + Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt1 + 18), Fee((baseFee * 2.1 * 1.25) + 1), queued); // New lowest fee ticket is baseFee * 2.2 env(noop(alice), - ticket::use(tkt250 - 4), - fee((baseFee * 2.2 * 1.25) - 1), - ter(telCAN_NOT_QUEUE_FEE)); - env(noop(alice), ticket::use(tkt250 - 4), fee((baseFee * 2.2 * 1.25) + 1), queued); + ticket::Use(tkt250 - 4), + Fee((baseFee * 2.2 * 1.25) - 1), + Ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), ticket::Use(tkt250 - 4), Fee((baseFee * 2.2 * 1.25) + 1), queued); env.close(); - env.require(owners(alice, 227), tickets(alice, 227)); + env.require(Owners(alice, 227), tickets(alice, 227)); // Verify that all remaining transactions made it out of the TxQ. - env(noop(alice), ticket::use(tkt1 + 18), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt250 - 4), ter(tefNO_TICKET)); - env(noop(alice), seq(nextSeq + 4), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 5), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 6), ter(tefPAST_SEQ)); - env(noop(alice), seq(nextSeq + 7), ter(tefPAST_SEQ)); + env(noop(alice), ticket::Use(tkt1 + 18), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt250 - 4), Ter(tefNO_TICKET)); + env(noop(alice), Seq(nextSeq + 4), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 5), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 6), Ter(tefPAST_SEQ)); + env(noop(alice), Seq(nextSeq + 7), Ter(tefPAST_SEQ)); BEAST_EXPECT(env.seq(alice) == nextSeq + 8); checkMetrics(*this, env, 0, 16, 6, 8); @@ -628,7 +622,7 @@ public: auto alice = Account("alice"); auto gw = Account("gw"); - auto USD = gw["USD"]; + auto usd = gw["USD"]; checkMetrics(*this, env, 0, std::nullopt, 0, 2); @@ -639,14 +633,14 @@ public: checkMetrics(*this, env, 0, 4, 0, 2); // Alice creates an unfunded offer while the ledger is not full - env(offer(alice, XRP(1000), USD(1000)), ter(tecUNFUNDED_OFFER)); + env(offer(alice, XRP(1000), usd(1000)), Ter(tecUNFUNDED_OFFER)); checkMetrics(*this, env, 0, 4, 1, 2); fillQueue(env, alice); checkMetrics(*this, env, 0, 4, 3, 2); // Alice creates an unfunded offer that goes in the queue - env(offer(alice, XRP(1000), USD(1000)), ter(terQUEUED)); + env(offer(alice, XRP(1000), usd(1000)), Ter(terQUEUED)); checkMetrics(*this, env, 1, 4, 3, 2); // The offer comes out of the queue @@ -667,7 +661,7 @@ public: auto bob = Account("bob"); auto charlie = Account("charlie"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 2); @@ -677,7 +671,7 @@ public: checkMetrics(*this, env, 0, std::nullopt, 3, 2); // Future transaction for Alice - fails - env(noop(alice), fee(openLedgerCost(env)), seq(env.seq(alice) + 1), ter(terPRE_SEQ)); + env(noop(alice), Fee(openLedgerCost(env)), Seq(env.seq(alice) + 1), Ter(terPRE_SEQ)); checkMetrics(*this, env, 0, std::nullopt, 3, 2); // Current transaction for Alice: held @@ -685,19 +679,19 @@ public: checkMetrics(*this, env, 1, std::nullopt, 3, 2); // Alice - sequence is too far ahead, so won't queue. - env(noop(alice), seq(env.seq(alice) + 2), ter(telCAN_NOT_QUEUE)); + env(noop(alice), Seq(env.seq(alice) + 2), Ter(telCAN_NOT_QUEUE)); checkMetrics(*this, env, 1, std::nullopt, 3, 2); // Bob with really high fee - applies - env(noop(bob), fee(openLedgerCost(env))); + env(noop(bob), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, std::nullopt, 4, 2); // Daria with low fee: hold - env(noop(charlie), fee(baseFee * 100), queued); + env(noop(charlie), Fee(baseFee * 100), queued); checkMetrics(*this, env, 2, std::nullopt, 4, 2); // Alice with normal fee: hold - env(noop(alice), seq(env.seq(alice) + 1), queued); + env(noop(alice), Seq(env.seq(alice) + 1), queued); checkMetrics(*this, env, 3, std::nullopt, 4, 2); env.close(); @@ -723,7 +717,7 @@ public: auto edgar = Account("edgar"); auto felicia = Account("felicia"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 2); @@ -744,25 +738,25 @@ public: BEAST_EXPECT(env.current()->header().seq == 6); // Fail to queue an item with a low LastLedgerSeq - env(noop(alice), last_ledger_seq(7), ter(telCAN_NOT_QUEUE)); + env(noop(alice), LastLedgerSeq(7), Ter(telCAN_NOT_QUEUE)); // Queue an item with a sufficient LastLedgerSeq. - env(noop(alice), last_ledger_seq(8), queued); + env(noop(alice), LastLedgerSeq(8), queued); - constexpr auto largeFeeMultiplier = 700; - auto const largeFee = baseFee * largeFeeMultiplier; + constexpr auto kLARGE_FEE_MULTIPLIER = 700; + auto const largeFee = baseFee * kLARGE_FEE_MULTIPLIER; // Queue items with higher fees to force the previous // txn to wait. - env(noop(bob), fee(largeFee), queued); - env(noop(charlie), fee(largeFee), queued); - env(noop(daria), fee(largeFee), queued); - env(noop(edgar), fee(largeFee), queued); + env(noop(bob), Fee(largeFee), queued); + env(noop(charlie), Fee(largeFee), queued); + env(noop(daria), Fee(largeFee), queued); + env(noop(edgar), Fee(largeFee), queued); checkMetrics(*this, env, 5, std::nullopt, 3, 2); { auto& txQ = env.app().getTxQ(); auto aliceStat = txQ.getAccountTxs(alice.id()); BEAST_EXPECT(aliceStat.size() == 1); - BEAST_EXPECT(aliceStat.begin()->feeLevel == baseFeeLevel); + BEAST_EXPECT(aliceStat.begin()->feeLevel == kBASE_FEE_LEVEL); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) BEAST_EXPECT(aliceStat.begin()->lastValid && *aliceStat.begin()->lastValid == 8); BEAST_EXPECT(!aliceStat.begin()->consequences.isBlocker()); @@ -770,11 +764,12 @@ public: auto bobStat = txQ.getAccountTxs(bob.id()); BEAST_EXPECT(bobStat.size() == 1); BEAST_EXPECT( - bobStat.begin()->feeLevel == FeeLevel64{baseFeeLevel.fee() * largeFeeMultiplier}); + bobStat.begin()->feeLevel == + FeeLevel64{kBASE_FEE_LEVEL.fee() * kLARGE_FEE_MULTIPLIER}); BEAST_EXPECT(!bobStat.begin()->lastValid); BEAST_EXPECT(!bobStat.begin()->consequences.isBlocker()); - auto noStat = txQ.getAccountTxs(Account::master.id()); + auto noStat = txQ.getAccountTxs(Account::kMASTER.id()); BEAST_EXPECT(noStat.empty()); } @@ -782,59 +777,49 @@ public: checkMetrics(*this, env, 1, 6, 4, 3); // Keep alice's transaction waiting. - env(noop(bob), fee(largeFee), queued); - env(noop(charlie), fee(largeFee), queued); - env(noop(daria), fee(largeFee), queued); - env(noop(edgar), fee(largeFee), queued); - env(noop(felicia), fee(largeFee - 1), queued); + env(noop(bob), Fee(largeFee), queued); + env(noop(charlie), Fee(largeFee), queued); + env(noop(daria), Fee(largeFee), queued); + env(noop(edgar), Fee(largeFee), queued); + env(noop(felicia), Fee(largeFee - 1), queued); checkMetrics(*this, env, 6, 6, 4, 3, 257); env.close(); // alice's transaction is still hanging around - checkMetrics( - *this, env, 1, 8, 5, 4, baseFeeLevel.fee(), baseFeeLevel.fee() * largeFeeMultiplier); + // clang-format off + checkMetrics(*this, env, 1, 8, 5, 4, kBASE_FEE_LEVEL.fee(), kBASE_FEE_LEVEL.fee() * kLARGE_FEE_MULTIPLIER); + // clang-format on BEAST_EXPECT(env.seq(alice) == 3); - constexpr auto anotherLargeFeeMultiplier = 800; - auto const anotherLargeFee = baseFee * anotherLargeFeeMultiplier; + constexpr auto kANOTHER_LARGE_FEE_MULTIPLIER = 800; + auto const anotherLargeFee = baseFee * kANOTHER_LARGE_FEE_MULTIPLIER; // Keep alice's transaction waiting. - env(noop(bob), fee(anotherLargeFee), queued); - env(noop(charlie), fee(anotherLargeFee), queued); - env(noop(daria), fee(anotherLargeFee), queued); - env(noop(daria), fee(anotherLargeFee), seq(env.seq(daria) + 1), queued); - env(noop(edgar), fee(anotherLargeFee), queued); - env(noop(felicia), fee(anotherLargeFee - 1), queued); - env(noop(felicia), fee(anotherLargeFee - 1), seq(env.seq(felicia) + 1), queued); - checkMetrics( - *this, - env, - 8, - 8, - 5, - 4, - baseFeeLevel.fee() + 1, - baseFeeLevel.fee() * largeFeeMultiplier); + // clang-format off + env(noop(bob), Fee(anotherLargeFee), queued); + env(noop(charlie), Fee(anotherLargeFee), queued); + env(noop(daria), Fee(anotherLargeFee), queued); + env(noop(daria), Fee(anotherLargeFee), Seq(env.seq(daria) + 1), queued); + env(noop(edgar), Fee(anotherLargeFee), queued); + env(noop(felicia), Fee(anotherLargeFee - 1), queued); + env(noop(felicia), Fee(anotherLargeFee - 1), Seq(env.seq(felicia) + 1), queued); + checkMetrics(*this, env, 8, 8, 5, 4, kBASE_FEE_LEVEL.fee() + 1, kBASE_FEE_LEVEL.fee() * kLARGE_FEE_MULTIPLIER); + // clang-format on env.close(); // alice's transaction expired without getting // into the ledger, so her transaction is gone, // though one of felicia's is still in the queue. - checkMetrics( - *this, env, 1, 10, 6, 5, baseFeeLevel.fee(), baseFeeLevel.fee() * largeFeeMultiplier); + // clang-format off + checkMetrics(*this, env, 1, 10, 6, 5, kBASE_FEE_LEVEL.fee(), kBASE_FEE_LEVEL.fee() * kLARGE_FEE_MULTIPLIER); + // clang-format on BEAST_EXPECT(env.seq(alice) == 3); BEAST_EXPECT(env.seq(felicia) == 7); env.close(); // And now the queue is empty - checkMetrics( - *this, - env, - 0, - 12, - 1, - 6, - baseFeeLevel.fee(), - baseFeeLevel.fee() * anotherLargeFeeMultiplier); + // clang-format off + checkMetrics(*this, env, 0, 12, 1, 6, kBASE_FEE_LEVEL.fee(), kBASE_FEE_LEVEL.fee() * kANOTHER_LARGE_FEE_MULTIPLIER); + // clang-format on BEAST_EXPECT(env.seq(alice) == 3); BEAST_EXPECT(env.seq(felicia) == 8); } @@ -852,7 +837,7 @@ public: auto bob = Account("bob"); auto carol = Account("carol"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); auto const baseFee = env.current()->fees().base.drops(); checkMetrics(*this, env, 0, std::nullopt, 0, 2); @@ -873,7 +858,7 @@ public: checkMetrics(*this, env, 1, std::nullopt, 3, 2); // Since Alice's queue is empty this blocker can go into her queue. - env(regkey(alice, bob), fee(0), queued); + env(regkey(alice, bob), Fee(0), queued); checkMetrics(*this, env, 2, std::nullopt, 3, 2); // Close out this ledger so we can get a maxsize @@ -883,12 +868,12 @@ public: fillQueue(env, alice); checkMetrics(*this, env, 0, 6, 4, 3); - constexpr auto aliceFeeMultiplier = 3; - auto feeAlice = baseFee * aliceFeeMultiplier; + constexpr auto kALICE_FEE_MULTIPLIER = 3; + auto feeAlice = baseFee * kALICE_FEE_MULTIPLIER; auto seqAlice = env.seq(alice); for (int i = 0; i < 4; ++i) { - env(noop(alice), fee(feeAlice), seq(seqAlice), queued); + env(noop(alice), Fee(feeAlice), Seq(seqAlice), queued); feeAlice = (feeAlice + 1) * 125 / 100; ++seqAlice; } @@ -896,7 +881,7 @@ public: // Bob adds a zero fee blocker to his queue. auto const seqBob = env.seq(bob); - env(regkey(bob, alice), fee(0), queued); + env(regkey(bob, alice), Fee(0), queued); checkMetrics(*this, env, 5, 6, 4, 3); // Carol fills the queue. @@ -904,17 +889,19 @@ public: auto seqCarol = env.seq(carol); for (int i = 0; i < 4; ++i) { - env(noop(carol), fee(feeCarol), seq(seqCarol), queued); + env(noop(carol), Fee(feeCarol), Seq(seqCarol), queued); feeCarol = (feeCarol + 1) * 125 / 100; ++seqCarol; } - checkMetrics(*this, env, 6, 6, 4, 3, (baseFeeLevel.fee() * aliceFeeMultiplier) + 1); + // clang-format off + checkMetrics(*this, env, 6, 6, 4, 3, (kBASE_FEE_LEVEL.fee() * kALICE_FEE_MULTIPLIER) + 1); + // clang-format on // Carol submits high enough to beat Bob's average fee which kicks // out Bob's queued transaction. However Bob's transaction stays // in the localTx queue, so it will return to the TxQ next time // around. - env(noop(carol), fee(feeCarol), seq(seqCarol), ter(terQUEUED)); + env(noop(carol), Fee(feeCarol), Seq(seqCarol), Ter(terQUEUED)); env.close(); // Some of Alice's transactions stay in the queue. Bob's @@ -956,13 +943,13 @@ public: // expected. // Fail in preflight - env(pay(alice, bob, XRP(-1000)), ter(temBAD_AMOUNT)); + env(pay(alice, bob, XRP(-1000)), Ter(temBAD_AMOUNT)); // Fail in preflight - env(pay(alice, alice, XRP(100)), ter(temREDUNDANT)); + env(pay(alice, alice, XRP(100)), Ter(temREDUNDANT)); // Fail in preclaim - env(noop(alice), fee(XRP(100000)), ter(terINSUF_FEE_B)); + env(noop(alice), Fee(XRP(100000)), Ter(terINSUF_FEE_B)); } void @@ -976,7 +963,7 @@ public: auto alice = Account("alice"); auto bob = Account("bob"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); checkMetrics(*this, env, 0, std::nullopt, 0, 2); @@ -1000,7 +987,7 @@ public: Env::ParsedResult parsed; env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const result = xrpl::apply(env.app(), view, *jt.stx, tapNONE, env.journal); + auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, env.journal); parsed.ter = result.ter; return result.applied; }); @@ -1031,7 +1018,7 @@ public: auto charlie = Account("charlie"); auto daria = Account("daria"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -1044,7 +1031,7 @@ public: checkMetrics(*this, env, 0, initQueueMax, 4, 3); // Alice - price starts exploding: held - env(noop(alice), fee(11), queued); + env(noop(alice), Fee(11), queued); checkMetrics(*this, env, 1, initQueueMax, 4, 3); auto aliceSeq = env.seq(alice); @@ -1052,15 +1039,15 @@ public: auto charlieSeq = env.seq(charlie); // Alice - try to queue a second transaction, but leave a gap - env(noop(alice), seq(aliceSeq + 2), fee(100), ter(telCAN_NOT_QUEUE)); + env(noop(alice), Seq(aliceSeq + 2), Fee(100), Ter(telCAN_NOT_QUEUE)); checkMetrics(*this, env, 1, initQueueMax, 4, 3); // Alice - queue a second transaction. Yay! - env(noop(alice), seq(aliceSeq + 1), fee(13), queued); + env(noop(alice), Seq(aliceSeq + 1), Fee(13), queued); checkMetrics(*this, env, 2, initQueueMax, 4, 3); // Alice - queue a third transaction. Yay. - env(noop(alice), seq(aliceSeq + 2), fee(17), queued); + env(noop(alice), Seq(aliceSeq + 2), Fee(17), queued); checkMetrics(*this, env, 3, initQueueMax, 4, 3); // Bob - queue a transaction @@ -1068,12 +1055,12 @@ public: checkMetrics(*this, env, 4, initQueueMax, 4, 3); // Bob - queue a second transaction - env(noop(bob), seq(bobSeq + 1), fee(50), queued); + env(noop(bob), Seq(bobSeq + 1), Fee(50), queued); checkMetrics(*this, env, 5, initQueueMax, 4, 3); // Charlie - queue a transaction, with a higher fee // than default - env(noop(charlie), fee(15), queued); + env(noop(charlie), Fee(15), queued); checkMetrics(*this, env, 6, initQueueMax, 4, 3, 257); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -1099,9 +1086,9 @@ public: for (auto i = 0; i < 7; i++) { env(noop(alice), - seq(aliceSeq), - json(jss::LastLedgerSequence, lastLedgerSeq + i), - fee(--aliceFee), + Seq(aliceSeq), + Json(jss::LastLedgerSequence, lastLedgerSeq + i), + Fee(--aliceFee), queued); ++aliceSeq; } @@ -1131,45 +1118,45 @@ public: // but you can't force your own earlier txn off the // queue. env(noop(alice), - seq(aliceSeq), - json(jss::LastLedgerSequence, lastLedgerSeq + 7), - fee(aliceFee), - ter(telCAN_NOT_QUEUE_FULL)); + Seq(aliceSeq), + Json(jss::LastLedgerSequence, lastLedgerSeq + 7), + Fee(aliceFee), + Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 8, 8, 5, 4, 513); // Charlie - try to add another item to the queue, // which fails because fee is lower than Alice's // queued average. - env(noop(charlie), fee(19), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(charlie), Fee(19), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 8, 8, 5, 4, 513); // Charlie - add another item to the queue, which // causes Alice's last txn to drop - env(noop(charlie), fee(30), queued); + env(noop(charlie), Fee(30), queued); checkMetrics(*this, env, 8, 8, 5, 4, 538); // Alice - now attempt to add one more to the queue, // which fails because the last tx was dropped, so // there is no complete chain. - env(noop(alice), seq(aliceSeq), fee(aliceFee), ter(telCAN_NOT_QUEUE)); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), Ter(telCAN_NOT_QUEUE)); checkMetrics(*this, env, 8, 8, 5, 4, 538); // Alice wants this tx more than the dropped tx, // so resubmits with higher fee, but the queue // is full, and her account is the cheapest. - env(noop(alice), seq(aliceSeq - 1), fee(aliceFee), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq - 1), Fee(aliceFee), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 8, 8, 5, 4, 538); // Try to replace a middle item in the queue // without enough fee. aliceSeq = env.seq(alice) + 2; aliceFee = 29; - env(noop(alice), seq(aliceSeq), fee(aliceFee), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), Ter(telCAN_NOT_QUEUE_FEE)); checkMetrics(*this, env, 8, 8, 5, 4, 538); // Replace a middle item from the queue successfully ++aliceFee; - env(noop(alice), seq(aliceSeq), fee(aliceFee), queued); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), queued); checkMetrics(*this, env, 8, 8, 5, 4, 538); env.close(); @@ -1185,18 +1172,18 @@ public: // more than the minimum reserve in flight before the // last queued transaction aliceFee = env.le(alice)->getFieldAmount(sfBalance).xrp().drops() - (62); - env(noop(alice), seq(aliceSeq), fee(aliceFee), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 4, 10, 6, 5); // Try to spend more than Alice can afford with all the other txs. aliceSeq += 2; - env(noop(alice), seq(aliceSeq), fee(aliceFee), ter(terINSUF_FEE_B)); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), Ter(terINSUF_FEE_B)); checkMetrics(*this, env, 4, 10, 6, 5); // Replace the last queued item with a transaction that will // bankrupt Alice --aliceFee; - env(noop(alice), seq(aliceSeq), fee(aliceFee), queued); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), queued); checkMetrics(*this, env, 4, 10, 6, 5); // Alice - Attempt to queue a last transaction, but it @@ -1204,7 +1191,7 @@ public: // the fee is checked against the balance aliceFee /= 5; ++aliceSeq; - env(noop(alice), seq(aliceSeq), fee(aliceFee), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(alice), Seq(aliceSeq), Fee(aliceFee), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 4, 10, 6, 5); env.close(); @@ -1215,8 +1202,8 @@ public: checkMetrics(*this, env, 0, 12, 0, 6); // Alice is broke - env.require(balance(alice, XRP(0))); - env(noop(alice), ter(terINSUF_FEE_B)); + env.require(Balance(alice, XRP(0))); + env(noop(alice), Ter(terINSUF_FEE_B)); // Bob tries to queue up more than the single // account limit (10) txs. @@ -1224,21 +1211,21 @@ public: bobSeq = env.seq(bob); checkMetrics(*this, env, 0, 12, 7, 6); for (int i = 0; i < 10; ++i) - env(noop(bob), seq(bobSeq + i), queued); + env(noop(bob), Seq(bobSeq + i), queued); checkMetrics(*this, env, 10, 12, 7, 6); // Bob hit the single account limit - env(noop(bob), seq(bobSeq + 10), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(bob), Seq(bobSeq + 10), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 10, 12, 7, 6); // Bob can replace one of the earlier txs regardless // of the limit - env(noop(bob), seq(bobSeq + 5), fee(20), queued); + env(noop(bob), Seq(bobSeq + 5), Fee(20), queued); checkMetrics(*this, env, 10, 12, 7, 6); // Try to replace a middle item in the queue // with enough fee to bankrupt bob and make the // later transactions unable to pay their fees std::int64_t bobFee = env.le(bob)->getFieldAmount(sfBalance).xrp().drops() - (9 * 10 - 1); - env(noop(bob), seq(bobSeq + 5), fee(bobFee), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(bob), Seq(bobSeq + 5), Fee(bobFee), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 10, 12, 7, 6); // Attempt to replace a middle item in the queue with enough fee @@ -1248,7 +1235,7 @@ public: // The attempt fails because the sum of bob's fees now exceeds the // (artificially lowered to 200 drops) account reserve. bobFee = env.le(bob)->getFieldAmount(sfBalance).xrp().drops() - (9 * 10); - env(noop(bob), seq(bobSeq + 5), fee(bobFee), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(bob), Seq(bobSeq + 5), Fee(bobFee), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 10, 12, 7, 6); // Close the ledger and verify that the queued transactions succeed @@ -1257,7 +1244,7 @@ public: checkMetrics(*this, env, 3, 14, 8, 7); env.close(); checkMetrics(*this, env, 0, 16, 3, 8); - env.require(balance(bob, drops(499'999'999'750))); + env.require(Balance(bob, drops(499'999'999'750))); } void @@ -1280,7 +1267,7 @@ public: auto gwen = Account("gwen"); auto hank = Account("hank"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); BEAST_EXPECT(env.current()->fees().base == 10); @@ -1323,14 +1310,14 @@ public: // All of these get into the queue, but one gets dropped when the // higher fee one is added later. Which one depends on ordering. - env(noop(alice), fee(15), queued); - env(noop(bob), fee(15), queued); - env(noop(charlie), fee(15), queued); - env(noop(daria), fee(15), queued); - env(noop(elmo), fee(15), queued); - env(noop(fred), fee(15), queued); - env(noop(gwen), fee(15), queued); - env(noop(hank), fee(15), queued); + env(noop(alice), Fee(15), queued); + env(noop(bob), Fee(15), queued); + env(noop(charlie), Fee(15), queued); + env(noop(daria), Fee(15), queued); + env(noop(elmo), Fee(15), queued); + env(noop(fred), Fee(15), queued); + env(noop(gwen), Fee(15), queued); + env(noop(hank), Fee(15), queued); // Queue is full now. Minimum fee now reflects the // lowest fee in the queue. @@ -1340,12 +1327,12 @@ public: // Try to add another transaction with the default (low) fee, // it should fail because it can't replace the one already // there. - env(noop(charlie), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(charlie), Ter(telCAN_NOT_QUEUE_FEE)); // Add another transaction, with a higher fee, // Not high enough to get into the ledger, but high // enough to get into the queue (and kick somebody out) - env(noop(charlie), fee(100), seq(charlieSeq + 1), queued); + env(noop(charlie), Fee(100), Seq(charlieSeq + 1), queued); // Queue is still full. checkMetrics(*this, env, 8, 8, 5, 4, minFeeLevel + 1); @@ -1413,13 +1400,13 @@ public: BEAST_EXPECT(qTxCount1.size() <= 3); // Fill up the queue again - env(noop(alice), seq(aliceSeq + qTxCount1[alice.id()]++), fee(15), queued); - env(noop(bob), seq(bobSeq + qTxCount1[bob.id()]++), fee(15), queued); - env(noop(charlie), seq(charlieSeq + qTxCount1[charlie.id()]++), fee(15), queued); - env(noop(daria), seq(dariaSeq + qTxCount1[daria.id()]++), fee(15), queued); - env(noop(elmo), seq(elmoSeq + qTxCount1[elmo.id()]++), fee(15), queued); - env(noop(fred), seq(fredSeq + qTxCount1[fred.id()]++), fee(15), queued); - env(noop(gwen), seq(gwenSeq + qTxCount1[gwen.id()]++), fee(15), queued); + env(noop(alice), Seq(aliceSeq + qTxCount1[alice.id()]++), Fee(15), queued); + env(noop(bob), Seq(bobSeq + qTxCount1[bob.id()]++), Fee(15), queued); + env(noop(charlie), Seq(charlieSeq + qTxCount1[charlie.id()]++), Fee(15), queued); + env(noop(daria), Seq(dariaSeq + qTxCount1[daria.id()]++), Fee(15), queued); + env(noop(elmo), Seq(elmoSeq + qTxCount1[elmo.id()]++), Fee(15), queued); + env(noop(fred), Seq(fredSeq + qTxCount1[fred.id()]++), Fee(15), queued); + env(noop(gwen), Seq(gwenSeq + qTxCount1[gwen.id()]++), Fee(15), queued); minFeeLevel = txFeeLevelByAccount(env, gwen) + 1; checkMetrics(*this, env, 10, 10, 6, 5, minFeeLevel); @@ -1427,7 +1414,7 @@ public: // Add another transaction, with a higher fee, // Not high enough to get into the ledger, but high // enough to get into the queue (and kick somebody out) - env(noop(alice), fee(100), seq(aliceSeq + qTxCount1[alice.id()]++), queued); + env(noop(alice), Fee(100), Seq(aliceSeq + qTxCount1[alice.id()]++), queued); checkMetrics(*this, env, 10, 10, 6, 5, minFeeLevel); @@ -1495,7 +1482,7 @@ public: // Immediately after the fset, the sfAccountTxnID field // is still uninitialized, so preflight succeeds here, // and this txn fails because it can't be stored in the queue. - env(noop(alice), json(R"({"AccountTxnID": "0"})"), ter(telCAN_NOT_QUEUE)); + env(noop(alice), Json(R"({"AccountTxnID": "0"})"), Ter(telCAN_NOT_QUEUE)); checkMetrics(*this, env, 0, std::nullopt, 2, 1); env.close(); @@ -1506,7 +1493,7 @@ public: env(noop(alice)); checkMetrics(*this, env, 0, 4, 2, 2); - env(noop(alice), json(R"({"AccountTxnID": "0"})"), ter(tefWRONG_PRIOR)); + env(noop(alice), Json(R"({"AccountTxnID": "0"})"), Ter(tefWRONG_PRIOR)); } void @@ -1544,17 +1531,19 @@ public: { double const feeMultiplier = static_cast(cost.drops()) / baseFee; medFeeLevel = - FeeLevel64{static_cast(feeMultiplier * baseFeeLevel.fee())}; + FeeLevel64{static_cast(feeMultiplier * kBASE_FEE_LEVEL.fee())}; } - env(noop(alice), fee(cost)); + env(noop(alice), Fee(cost)); } checkMetrics(*this, env, 0, std::nullopt, 11, 2); env.close(); // If not for the maximum, the per ledger would be 11. - checkMetrics(*this, env, 0, 10, 0, 5, baseFeeLevel.fee(), calcMedFeeLevel(medFeeLevel)); + // clang-format off + checkMetrics(*this, env, 0, 10, 0, 5, kBASE_FEE_LEVEL.fee(), calcMedFeeLevel(medFeeLevel)); + // clang-format on } try @@ -1637,7 +1626,7 @@ public: auto alice = Account("alice"); auto bob = Account("bob"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); // ledgers in queue is 2 because of makeConfig auto const initQueueMax = initFee(env, 3, 2, 10, 200, 50); @@ -1647,9 +1636,9 @@ public: env.fund(drops(5000), noripple(alice)); env.fund(XRP(50000), noripple(bob)); checkMetrics(*this, env, 0, initQueueMax, 2, 3); - auto USD = bob["USD"]; + auto usd = bob["USD"]; - env(offer(alice, USD(5000), drops(5000)), require(owners(alice, 1))); + env(offer(alice, usd(5000), drops(5000)), Require(Owners(alice, 1))); checkMetrics(*this, env, 0, initQueueMax, 3, 3); env.close(); @@ -1662,33 +1651,33 @@ public: // Queue up a couple of transactions, plus one // more expensive one. auto aliceSeq = env.seq(alice); - env(noop(alice), seq(aliceSeq++), queued); - env(noop(alice), seq(aliceSeq++), queued); - env(noop(alice), seq(aliceSeq++), queued); - env(noop(alice), fee(drops(1000)), seq(aliceSeq), queued); + env(noop(alice), Seq(aliceSeq++), queued); + env(noop(alice), Seq(aliceSeq++), queued); + env(noop(alice), Seq(aliceSeq++), queued); + env(noop(alice), Fee(drops(1000)), Seq(aliceSeq), queued); checkMetrics(*this, env, 4, 6, 4, 3); // This offer should take Alice's offer // up to Alice's reserve. - env(offer(bob, drops(5000), USD(5000)), - fee(openLedgerCost(env)), - require(balance(alice, drops(250)), owners(alice, 1), lines(alice, 1))); + env(offer(bob, drops(5000), usd(5000)), + Fee(openLedgerCost(env)), + Require(Balance(alice, drops(250)), Owners(alice, 1), lines(alice, 1))); checkMetrics(*this, env, 4, 6, 5, 3); // Try adding a new transaction. // Too many fees in flight. - env(noop(alice), fee(drops(200)), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(alice), Fee(drops(200)), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 4, 6, 5, 3); // Close the ledger. All of Alice's transactions // take a fee, except the last one. env.close(); checkMetrics(*this, env, 1, 10, 3, 5); - env.require(balance(alice, drops(250 - 30))); + env.require(Balance(alice, drops(250 - 30))); // Still can't add a new transaction for Alice, // no matter the fee. - env(noop(alice), fee(drops(200)), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(alice), Fee(drops(200)), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 1, 10, 3, 5); /* At this point, Alice's transaction is indefinitely @@ -1721,7 +1710,7 @@ public: auto charlie = Account("charlie"); auto daria = Account("daria"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); @@ -1743,25 +1732,25 @@ public: // Put two "normal" txs in the queue auto const aliceSeq = env.seq(alice); - env(noop(alice), seq(aliceSeq + 0), queued); - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 0), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); // Can't replace either queued transaction with a blocker env(fset(alice, asfAccountTxnID), - seq(aliceSeq + 0), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + Seq(aliceSeq + 0), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); env(regkey(alice, bob), - seq(aliceSeq + 1), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + Seq(aliceSeq + 1), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); // Can't append a blocker to the queue. env(signers(alice, 2, {{bob}, {charlie}, {daria}}), - seq(aliceSeq + 2), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + Seq(aliceSeq + 2), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); // Other accounts are not affected env(noop(bob), queued); @@ -1778,32 +1767,32 @@ public: env(noop(alice)); auto const aliceSeq = env.seq(alice); - env(noop(alice), seq(aliceSeq + 0), queued); + env(noop(alice), Seq(aliceSeq + 0), queued); // Since there's only one entry in the queue we can replace // that entry with a blocker. - env(regkey(alice, bob), seq(aliceSeq + 0), fee(baseFee * 2), queued); + env(regkey(alice, bob), Seq(aliceSeq + 0), Fee(baseFee * 2), queued); // Now that there's a blocker in the queue we can't append to // the queue. - env(noop(alice), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // Other accounts are unaffected. env(noop(bob), queued); // We can replace the blocker with a different blocker. env(signers(alice, 2, {{bob}, {charlie}, {daria}}), - seq(aliceSeq + 0), - fee(baseFee * 2.6), + Seq(aliceSeq + 0), + Fee(baseFee * 2.6), queued); // Prove that the queue is still blocked. - env(noop(alice), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // We can replace the blocker with a non-blocker. Then we can // successfully append to the queue. - env(noop(alice), seq(aliceSeq + 0), fee(baseFee * 3.3), queued); - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 0), Fee(baseFee * 3.3), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); // Drain the queue. env.close(); @@ -1819,19 +1808,19 @@ public: env(noop(alice)); auto const aliceSeq = env.seq(alice); - env(fset(alice, asfAccountTxnID), seq(aliceSeq + 0), queued); + env(fset(alice, asfAccountTxnID), Seq(aliceSeq + 0), queued); // Since there's a blocker in the queue we can't append to // the queue. - env(noop(alice), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // Other accounts are unaffected. env(noop(bob), queued); // We can replace the blocker with a non-blocker. Then we can // successfully append to the queue. - env(noop(alice), seq(aliceSeq + 0), fee(baseFee * 2), queued); - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 0), Fee(baseFee * 2), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); // Drain the queue. env.close(); @@ -1850,7 +1839,7 @@ public: auto charlie = Account("charlie"); auto daria = Account("daria"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); @@ -1868,36 +1857,36 @@ public: // already holds two or more (non-blocker) entries. // Fill up the open ledger - env(ticket::create(alice, 250), seq(tkt - 1)); + env(ticket::create(alice, 250), Seq(tkt - 1)); // Set a regular key just to clear the password spent flag env(regkey(alice, charlie)); checkMetrics(*this, env, 0, std::nullopt, 4, 3); // Put two "normal" txs in the queue auto const aliceSeq = env.seq(alice); - env(noop(alice), ticket::use(tkt + 2), queued); - env(noop(alice), ticket::use(tkt + 1), queued); + env(noop(alice), ticket::Use(tkt + 2), queued); + env(noop(alice), ticket::Use(tkt + 1), queued); // Can't replace either queued transaction with a blocker env(fset(alice, asfAccountTxnID), - ticket::use(tkt + 1), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + ticket::Use(tkt + 1), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); env(regkey(alice, bob), - ticket::use(tkt + 2), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + ticket::Use(tkt + 2), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); // Can't append a blocker to the queue. env(signers(alice, 2, {{bob}, {charlie}, {daria}}), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); env(signers(alice, 2, {{bob}, {charlie}, {daria}}), - ticket::use(tkt + 0), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + ticket::Use(tkt + 0), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); // Other accounts are not affected env(noop(bob), queued); @@ -1909,9 +1898,9 @@ public: // Show that the local transactions have flushed through as well. BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); - env(noop(alice), ticket::use(tkt + 0), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt + 1), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt + 2), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt + 0), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt + 1), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt + 2), Ter(tefNO_TICKET)); tkt += 3; } { @@ -1919,42 +1908,42 @@ public: // Put just one entry in the TxQ. auto const aliceSeq = env.seq(alice); - env(noop(alice), ticket::use(tkt + 0), queued); + env(noop(alice), ticket::Use(tkt + 0), queued); // Since there's an entry in the queue we cannot append a // blocker to the account's queue. - env(regkey(alice, bob), fee(baseFee * 2), ter(telCAN_NOT_QUEUE_BLOCKS)); + env(regkey(alice, bob), Fee(baseFee * 2), Ter(telCAN_NOT_QUEUE_BLOCKS)); env(regkey(alice, bob), - ticket::use(tkt + 1), - fee(baseFee * 2), - ter(telCAN_NOT_QUEUE_BLOCKS)); + ticket::Use(tkt + 1), + Fee(baseFee * 2), + Ter(telCAN_NOT_QUEUE_BLOCKS)); // However we can _replace_ that lone entry with a blocker. - env(regkey(alice, bob), ticket::use(tkt + 0), fee(baseFee * 2), queued); + env(regkey(alice, bob), ticket::Use(tkt + 0), Fee(baseFee * 2), queued); // Now that there's a blocker in the queue we can't append to // the queue. - env(noop(alice), ter(telCAN_NOT_QUEUE_BLOCKED)); - env(noop(alice), ticket::use(tkt + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), Ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), ticket::Use(tkt + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // Other accounts are unaffected. env(noop(bob), queued); // We can replace the blocker with a different blocker. env(signers(alice, 2, {{bob}, {charlie}, {daria}}), - ticket::use(tkt + 0), - fee(baseFee * 2.6), + ticket::Use(tkt + 0), + Fee(baseFee * 2.6), queued); // Prove that the queue is still blocked. - env(noop(alice), ter(telCAN_NOT_QUEUE_BLOCKED)); - env(noop(alice), ticket::use(tkt + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), Ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), ticket::Use(tkt + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // We can replace the blocker with a non-blocker. Then we can // successfully append to the queue. - env(noop(alice), ticket::use(tkt + 0), fee(baseFee * 3.3), queued); - env(noop(alice), ticket::use(tkt + 1), queued); - env(noop(alice), seq(aliceSeq), queued); + env(noop(alice), ticket::Use(tkt + 0), Fee(baseFee * 3.3), queued); + env(noop(alice), ticket::Use(tkt + 1), queued); + env(noop(alice), Seq(aliceSeq), queued); // Drain the queue. env.close(); @@ -1962,8 +1951,8 @@ public: // Show that the local transactions have flushed through as well. BEAST_EXPECT(env.seq(alice) == aliceSeq + 1); - env(noop(alice), ticket::use(tkt + 0), ter(tefNO_TICKET)); - env(noop(alice), ticket::use(tkt + 1), ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt + 0), Ter(tefNO_TICKET)); + env(noop(alice), ticket::Use(tkt + 1), Ter(tefNO_TICKET)); tkt += 2; } { @@ -1974,19 +1963,19 @@ public: env(noop(alice)); env(noop(alice)); - env(fset(alice, asfAccountTxnID), ticket::use(tkt + 2), queued); + env(fset(alice, asfAccountTxnID), ticket::Use(tkt + 2), queued); // Since there's a blocker in the queue we can't append to // the queue. - env(noop(alice), ticket::use(tkt + 1), ter(telCAN_NOT_QUEUE_BLOCKED)); + env(noop(alice), ticket::Use(tkt + 1), Ter(telCAN_NOT_QUEUE_BLOCKED)); // Other accounts are unaffected. env(noop(bob), queued); // We can replace the blocker with a non-blocker. Then we can // successfully append to the queue. - env(noop(alice), ticket::use(tkt + 2), fee(baseFee * 2), queued); - env(noop(alice), ticket::use(tkt + 1), queued); + env(noop(alice), ticket::Use(tkt + 2), Fee(baseFee * 2), queued); + env(noop(alice), ticket::Use(tkt + 1), queued); // Drain the queue. env.close(); @@ -2010,7 +1999,7 @@ public: auto charlie = Account("charlie"); auto gw = Account("gw"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); // Set the fee reserves _really_ low so transactions with fees // in the ballpark of the reserves can be queued. With default @@ -2027,24 +2016,24 @@ public: env.fund(XRP(50000), noripple(alice, charlie), gw); checkMetrics(*this, env, 0, initQueueMax, limit + 1, limit); - auto USD = gw["USD"]; - auto BUX = gw["BUX"]; + auto usd = gw["USD"]; + auto bux = gw["BUX"]; ////////////////////////////////////////// // Offer with high XRP out and low fee doesn't block auto aliceSeq = env.seq(alice); auto aliceBal = env.balance(alice); - env.require(balance(alice, XRP(50000)), owners(alice, 0)); + env.require(Balance(alice, XRP(50000)), Owners(alice, 0)); // If this offer crosses, all of alice's // XRP will be taken (except the reserve). - env(offer(alice, BUX(5000), XRP(50000)), queued); + env(offer(alice, bux(5000), XRP(50000)), queued); checkMetrics(*this, env, 1, initQueueMax, limit + 1, limit); // But because the reserve is protected, another // transaction will be allowed to queue - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, initQueueMax, limit + 1, limit); env.close(); @@ -2054,9 +2043,9 @@ public: // But once we close the ledger, we find alice // has plenty of XRP, because the offer didn't // cross (of course). - env.require(balance(alice, aliceBal - drops(20)), owners(alice, 1)); + env.require(Balance(alice, aliceBal - drops(20)), Owners(alice, 1)); // cancel the offer - env(offer_cancel(alice, aliceSeq)); + env(offerCancel(alice, aliceSeq)); ////////////////////////////////////////// // Offer with high XRP out and high total fee blocks later txs @@ -2065,20 +2054,20 @@ public: aliceSeq = env.seq(alice); aliceBal = env.balance(alice); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); // Alice creates an offer with a fee of half the reserve - env(offer(alice, BUX(5000), XRP(50000)), fee(drops(100)), queued); + env(offer(alice, bux(5000), XRP(50000)), Fee(drops(100)), queued); checkMetrics(*this, env, 1, limit * 2, limit + 1, limit); // Alice creates another offer with a fee // that brings the total to just shy of the reserve - env(noop(alice), fee(drops(99)), seq(aliceSeq + 1), queued); + env(noop(alice), Fee(drops(99)), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); // So even a noop will look like alice // doesn't have the balance to pay the fee - env(noop(alice), fee(drops(51)), seq(aliceSeq + 2), ter(terINSUF_FEE_B)); + env(noop(alice), Fee(drops(51)), Seq(aliceSeq + 2), Ter(terINSUF_FEE_B)); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2088,9 +2077,9 @@ public: // But once we close the ledger, we find alice // has plenty of XRP, because the offer didn't // cross (of course). - env.require(balance(alice, aliceBal - drops(250)), owners(alice, 1)); + env.require(Balance(alice, aliceBal - drops(250)), Owners(alice, 1)); // cancel the offer - env(offer_cancel(alice, aliceSeq)); + env(offerCancel(alice, aliceSeq)); ////////////////////////////////////////// // Offer with high XRP out and super high fee blocks later txs @@ -2099,16 +2088,16 @@ public: aliceSeq = env.seq(alice); aliceBal = env.balance(alice); - env.require(owners(alice, 0)); + env.require(Owners(alice, 0)); // Alice creates an offer with a fee larger than the reserve // This one can queue because it's the first in the queue for alice - env(offer(alice, BUX(5000), XRP(50000)), fee(drops(300)), queued); + env(offer(alice, bux(5000), XRP(50000)), Fee(drops(300)), queued); checkMetrics(*this, env, 1, limit * 2, limit + 1, limit); // So even a noop will look like alice // doesn't have the balance to pay the fee - env(noop(alice), fee(drops(51)), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BALANCE)); + env(noop(alice), Fee(drops(51)), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BALANCE)); checkMetrics(*this, env, 1, limit * 2, limit + 1, limit); env.close(); @@ -2118,9 +2107,9 @@ public: // But once we close the ledger, we find alice // has plenty of XRP, because the offer didn't // cross (of course). - env.require(balance(alice, aliceBal - drops(351)), owners(alice, 1)); + env.require(Balance(alice, aliceBal - drops(351)), Owners(alice, 1)); // cancel the offer - env(offer_cancel(alice, aliceSeq)); + env(offerCancel(alice, aliceSeq)); ////////////////////////////////////////// // Offer with low XRP out allows later txs @@ -2131,10 +2120,10 @@ public: // If this offer crosses, just a bit // of alice's XRP will be taken. - env(offer(alice, BUX(50), XRP(500)), queued); + env(offer(alice, bux(50), XRP(500)), queued); // And later transactions are just fine - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2144,9 +2133,9 @@ public: // But once we close the ledger, we find alice // has plenty of XRP, because the offer didn't // cross (of course). - env.require(balance(alice, aliceBal - drops(20)), owners(alice, 1)); + env.require(Balance(alice, aliceBal - drops(20)), Owners(alice, 1)); // cancel the offer - env(offer_cancel(alice, aliceSeq)); + env(offerCancel(alice, aliceSeq)); ////////////////////////////////////////// // Large XRP payment doesn't block later txs @@ -2163,7 +2152,7 @@ public: // But because the reserve is protected, another // transaction will be allowed to queue - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2173,7 +2162,7 @@ public: // But once we close the ledger, we find alice // still has most of her balance, because the // payment was unfunded! - env.require(balance(alice, aliceBal - drops(20)), owners(alice, 0)); + env.require(Balance(alice, aliceBal - drops(20)), Owners(alice, 0)); ////////////////////////////////////////// // Small XRP payment allows later txs @@ -2188,7 +2177,7 @@ public: env(pay(alice, charlie, XRP(500)), queued); // And later transactions are just fine - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2196,13 +2185,13 @@ public: checkMetrics(*this, env, 0, limit * 2, 2, limit); // The payment succeeds - env.require(balance(alice, aliceBal - XRP(500) - drops(20)), owners(alice, 0)); + env.require(Balance(alice, aliceBal - XRP(500) - drops(20)), Owners(alice, 0)); ////////////////////////////////////////// // Large IOU payment allows later txs - auto const amount = USD(500000); - env(trust(alice, USD(50000000))); - env(trust(charlie, USD(50000000))); + auto const amount = usd(500000); + env(trust(alice, usd(50000000))); + env(trust(charlie, usd(50000000))); checkMetrics(*this, env, 0, limit * 2, 4, limit); // Close so we don't have to deal // with tx ordering in consensus. @@ -2219,7 +2208,7 @@ public: aliceSeq = env.seq(alice); aliceBal = env.balance(alice); - auto aliceUSD = env.balance(alice, USD); + auto aliceUSD = env.balance(alice, usd); // If this payment succeeds, alice will // send her entire USD balance to charlie. @@ -2227,7 +2216,7 @@ public: // But that's fine, because it doesn't affect // alice's XRP balance (other than the fee, of course). - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2237,16 +2226,16 @@ public: // So once we close the ledger, alice has her // XRP balance, but her USD balance went to charlie. env.require( - balance(alice, aliceBal - drops(20)), - balance(alice, USD(0)), - balance(charlie, aliceUSD), - owners(alice, 1), - owners(charlie, 1)); + Balance(alice, aliceBal - drops(20)), + Balance(alice, usd(0)), + Balance(charlie, aliceUSD), + Owners(alice, 1), + Owners(charlie, 1)); ////////////////////////////////////////// // Large XRP to IOU payment doesn't block later txs. - env(offer(gw, XRP(500000), USD(50000))); + env(offer(gw, XRP(500000), usd(50000))); // Close so we don't have to deal // with tx ordering in consensus. env.close(); @@ -2256,18 +2245,18 @@ public: aliceSeq = env.seq(alice); aliceBal = env.balance(alice); - auto charlieUSD = env.balance(charlie, USD); + auto charlieUSD = env.balance(charlie, usd); // If this payment succeeds, and uses the // entire sendMax, alice will send her // entire XRP balance to charlie in the // form of USD. BEAST_EXPECT(XRP(60000) > aliceBal); - env(pay(alice, charlie, USD(1000)), sendmax(XRP(60000)), queued); + env(pay(alice, charlie, usd(1000)), Sendmax(XRP(60000)), queued); // But because the reserve is protected, another // transaction will be allowed to queue - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2277,11 +2266,11 @@ public: // So once we close the ledger, alice sent a payment // to charlie using only a portion of her XRP balance env.require( - balance(alice, aliceBal - XRP(10000) - drops(20)), - balance(alice, USD(0)), - balance(charlie, charlieUSD + USD(1000)), - owners(alice, 1), - owners(charlie, 1)); + Balance(alice, aliceBal - XRP(10000) - drops(20)), + Balance(alice, usd(0)), + Balance(charlie, charlieUSD + usd(1000)), + Owners(alice, 1), + Owners(charlie, 1)); ////////////////////////////////////////// // Small XRP to IOU payment allows later txs. @@ -2291,17 +2280,17 @@ public: aliceSeq = env.seq(alice); aliceBal = env.balance(alice); - charlieUSD = env.balance(charlie, USD); + charlieUSD = env.balance(charlie, usd); // If this payment succeeds, and uses the // entire sendMax, alice will only send // a portion of her XRP balance to charlie // in the form of USD. BEAST_EXPECT(aliceBal > XRP(6001)); - env(pay(alice, charlie, USD(500)), sendmax(XRP(6000)), queued); + env(pay(alice, charlie, usd(500)), Sendmax(XRP(6000)), queued); // And later transactions are just fine - env(noop(alice), seq(aliceSeq + 1), queued); + env(noop(alice), Seq(aliceSeq + 1), queued); checkMetrics(*this, env, 2, limit * 2, limit + 1, limit); env.close(); @@ -2311,15 +2300,15 @@ public: // So once we close the ledger, alice sent a payment // to charlie using only a portion of her XRP balance env.require( - balance(alice, aliceBal - XRP(5000) - drops(20)), - balance(alice, USD(0)), - balance(charlie, charlieUSD + USD(500)), - owners(alice, 1), - owners(charlie, 1)); + Balance(alice, aliceBal - XRP(5000) - drops(20)), + Balance(alice, usd(0)), + Balance(charlie, charlieUSD + usd(500)), + Owners(alice, 1), + Owners(charlie, 1)); ////////////////////////////////////////// // Edge case: what happens if the balance is below the reserve? - env(noop(alice), fee(env.balance(alice) - drops(30))); + env(noop(alice), Fee(env.balance(alice) - drops(30))); env.close(); fillQueue(env, charlie); @@ -2329,8 +2318,8 @@ public: aliceBal = env.balance(alice); BEAST_EXPECT(aliceBal == drops(30)); - env(noop(alice), fee(drops(25)), queued); - env(noop(alice), seq(aliceSeq + 1), ter(terINSUF_FEE_B)); + env(noop(alice), Fee(drops(25)), queued); + env(noop(alice), Seq(aliceSeq + 1), Ter(terINSUF_FEE_B)); BEAST_EXPECT(env.balance(alice) == drops(30)); checkMetrics(*this, env, 1, limit * 2, limit + 1, limit); @@ -2354,9 +2343,9 @@ public: env.memoize("bob"); env.memoize("carol"); { - auto const jtx = env.jt(offer_cancel(alice, 3), seq(5), fee(10)); + auto const jtx = env.jt(offerCancel(alice, 3), Seq(5), Fee(10)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(10)); @@ -2364,11 +2353,11 @@ public: } { - auto USD = alice["USD"]; + auto usd = alice["USD"]; - auto const jtx = env.jt(trust("carol", USD(50000000)), seq(1), fee(10)); + auto const jtx = env.jt(trust("carol", usd(50000000)), Seq(1), Fee(10)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(10)); @@ -2376,9 +2365,9 @@ public: } { - auto const jtx = env.jt(ticket::create(alice, 1), seq(1), fee(10)); + auto const jtx = env.jt(ticket::create(alice, 1), Seq(1), Fee(10)); auto const pf = - preflight(env.app(), env.current()->rules(), *jtx.stx, tapNONE, env.journal); + preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal); BEAST_EXPECT(isTesSuccess(pf.ter)); BEAST_EXPECT(!pf.consequences.isBlocker()); BEAST_EXPECT(pf.consequences.fee() == drops(10)); @@ -2404,7 +2393,7 @@ public: auto bob = Account("bob"); auto charlie = Account("charlie"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); @@ -2420,11 +2409,11 @@ public: checkMetrics(*this, env, 0, std::nullopt, 4, 3); // Bob with really high fee - applies - env(noop(bob), fee(openLedgerCost(env))); + env(noop(bob), Fee(openLedgerCost(env))); checkMetrics(*this, env, 0, std::nullopt, 5, 3); // Charlie with low fee: queued - env(noop(charlie), fee(baseFee * 100), queued); + env(noop(charlie), Fee(baseFee * 100), queued); checkMetrics(*this, env, 1, std::nullopt, 5, 3); env.close(); @@ -2435,11 +2424,11 @@ public: // Stuff the ledger and queue so we can verify that // stuff gets kicked out. - env(noop(bob), fee(baseFee * 100)); - env(noop(bob), fee(baseFee * 100)); - env(noop(bob), fee(baseFee * 100)); - env(noop(bob), fee(baseFee * 100)); - env(noop(bob), fee(baseFee * 100)); + env(noop(bob), Fee(baseFee * 100)); + env(noop(bob), Fee(baseFee * 100)); + env(noop(bob), Fee(baseFee * 100)); + env(noop(bob), Fee(baseFee * 100)); + env(noop(bob), Fee(baseFee * 100)); checkMetrics(*this, env, 0, 10, 6, 5); // Use explicit fees so we can control which txn @@ -2447,34 +2436,34 @@ public: // This one gets into the queue, but gets dropped when the // higher fee one is added later. std::uint32_t const charlieSeq{env.seq(charlie)}; - env(noop(charlie), fee(baseFee * 1.5), seq(charlieSeq), queued); + env(noop(charlie), Fee(baseFee * 1.5), Seq(charlieSeq), queued); auto const expectedFeeLevel = txFeeLevelByAccount(env, charlie); // These stay in the queue. std::uint32_t aliceSeq{env.seq(alice)}; std::uint32_t bobSeq{env.seq(bob)}; - env(noop(alice), fee(baseFee * 1.6), seq(aliceSeq++), queued); - env(noop(bob), fee(baseFee * 1.6), seq(bobSeq++), queued); - env(noop(alice), fee(baseFee * 1.7), seq(aliceSeq++), queued); - env(noop(bob), fee(baseFee * 1.7), seq(bobSeq++), queued); - env(noop(alice), fee(baseFee * 1.8), seq(aliceSeq++), queued); - env(noop(bob), fee(baseFee * 1.9), seq(bobSeq++), queued); - env(noop(alice), fee(baseFee * 2), seq(aliceSeq++), queued); - env(noop(bob), fee(baseFee * 2), seq(bobSeq++), queued); - env(noop(alice), fee(baseFee * 2.1), seq(aliceSeq++), queued); + env(noop(alice), Fee(baseFee * 1.6), Seq(aliceSeq++), queued); + env(noop(bob), Fee(baseFee * 1.6), Seq(bobSeq++), queued); + env(noop(alice), Fee(baseFee * 1.7), Seq(aliceSeq++), queued); + env(noop(bob), Fee(baseFee * 1.7), Seq(bobSeq++), queued); + env(noop(alice), Fee(baseFee * 1.8), Seq(aliceSeq++), queued); + env(noop(bob), Fee(baseFee * 1.9), Seq(bobSeq++), queued); + env(noop(alice), Fee(baseFee * 2), Seq(aliceSeq++), queued); + env(noop(bob), Fee(baseFee * 2), Seq(bobSeq++), queued); + env(noop(alice), Fee(baseFee * 2.1), Seq(aliceSeq++), queued); // Queue is full now. checkMetrics(*this, env, 10, 10, 6, 5, expectedFeeLevel + 1); // Try to add another transaction with the default (low) fee, // it should fail because the queue is full. - env(noop(alice), seq(aliceSeq++), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq++), Ter(telCAN_NOT_QUEUE_FULL)); // Add another transaction, with a higher fee, // not high enough to get into the ledger, but high // enough to get into the queue (and kick Charlie's out) - env(noop(bob), fee(baseFee * 2.2), seq(bobSeq++), queued); + env(noop(bob), Fee(baseFee * 2.2), Seq(bobSeq++), queued); ///////////////////////////////////////////////////////// @@ -2486,9 +2475,9 @@ public: // Charlie is paying a high enough fee to go straight into the // ledger in order to get into the vicinity of an assert which // should no longer fire :-). - env(noop(charlie), fee(baseFee * 800), seq(charlieSeq - 1), ter(tefPAST_SEQ)); - env(noop(charlie), fee(baseFee * 800), seq(charlieSeq + 1), ter(terPRE_SEQ)); - env(noop(charlie), fee(baseFee * 800), seq(charlieSeq), ter(tesSUCCESS)); + env(noop(charlie), Fee(baseFee * 800), Seq(charlieSeq - 1), Ter(tefPAST_SEQ)); + env(noop(charlie), Fee(baseFee * 800), Seq(charlieSeq + 1), Ter(terPRE_SEQ)); + env(noop(charlie), Fee(baseFee * 800), Seq(charlieSeq), Ter(tesSUCCESS)); } void @@ -2502,7 +2491,7 @@ public: auto fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; BEAST_EXPECT( @@ -2531,7 +2520,7 @@ public: fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; BEAST_EXPECT( @@ -2590,10 +2579,10 @@ public: auto const aliceSeq = env.seq(alice); BEAST_EXPECT(env.current()->header().seq == 3); - env(noop(alice), seq(aliceSeq), last_ledger_seq(5), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 1), last_ledger_seq(5), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 2), last_ledger_seq(10), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 3), last_ledger_seq(11), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq), LastLedgerSeq(5), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 1), LastLedgerSeq(5), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 2), LastLedgerSeq(10), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 3), LastLedgerSeq(11), Ter(terQUEUED)); checkMetrics(*this, env, 4, std::nullopt, 2, 1); auto const bobSeq = env.seq(bob); // Ledger 4 gets 3, @@ -2601,7 +2590,7 @@ public: // Ledger 6 gets 5. for (int i = 0; i < 3 + 4 + 5; ++i) { - env(noop(bob), seq(bobSeq + i), fee(baseFee * 20), ter(terQUEUED)); + env(noop(bob), Seq(bobSeq + i), Fee(baseFee * 20), Ter(terQUEUED)); } checkMetrics(*this, env, 4 + 3 + 4 + 5, std::nullopt, 2, 1); // Close ledger 3 @@ -2616,22 +2605,22 @@ public: checkMetrics(*this, env, 2, 40, 5, 4); // Because aliceSeq is missing, aliceSeq + 1 fails - env(noop(alice), seq(aliceSeq + 1), ter(terPRE_SEQ)); + env(noop(alice), Seq(aliceSeq + 1), Ter(terPRE_SEQ)); // Cannot fill the gap with a blocker since Alice's queue is not empty. - env(fset(alice, asfAccountTxnID), seq(aliceSeq), ter(telCAN_NOT_QUEUE_BLOCKS)); + env(fset(alice, asfAccountTxnID), Seq(aliceSeq), Ter(telCAN_NOT_QUEUE_BLOCKS)); checkMetrics(*this, env, 2, 40, 5, 4); // However we can fill the gap with a non-blocker. - env(noop(alice), seq(aliceSeq), fee(baseFee * 2), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq), Fee(baseFee * 2), Ter(terQUEUED)); checkMetrics(*this, env, 3, 40, 5, 4); // Attempt to queue up a new aliceSeq + 1 tx that's a blocker. - env(fset(alice, asfAccountTxnID), seq(aliceSeq + 1), ter(telCAN_NOT_QUEUE_BLOCKS)); + env(fset(alice, asfAccountTxnID), Seq(aliceSeq + 1), Ter(telCAN_NOT_QUEUE_BLOCKS)); checkMetrics(*this, env, 3, 40, 5, 4); // Queue up a non-blocker replacement for aliceSeq + 1. - env(noop(alice), seq(aliceSeq + 1), fee(baseFee * 2), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 1), Fee(baseFee * 2), Ter(terQUEUED)); checkMetrics(*this, env, 4, 40, 5, 4); // Close ledger 6 @@ -2679,16 +2668,16 @@ public: // Start by procuring tickets for alice to use to keep her queue full // without affecting the sequence gap that will appear later. - env(ticket::create(alice, 11), seq(aliceSeq + 0), fee((baseFee * 20) + 1), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 11), last_ledger_seq(11), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 12), last_ledger_seq(11), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 13), last_ledger_seq(11), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 14), last_ledger_seq(11), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 15), last_ledger_seq(11), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 16), last_ledger_seq(5), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 17), last_ledger_seq(5), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 18), last_ledger_seq(5), ter(terQUEUED)); - env(noop(alice), seq(aliceSeq + 19), last_ledger_seq(11), ter(terQUEUED)); + env(ticket::create(alice, 11), Seq(aliceSeq + 0), Fee((baseFee * 20) + 1), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 11), LastLedgerSeq(11), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 12), LastLedgerSeq(11), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 13), LastLedgerSeq(11), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 14), LastLedgerSeq(11), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 15), LastLedgerSeq(11), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 16), LastLedgerSeq(5), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 17), LastLedgerSeq(5), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 18), LastLedgerSeq(5), Ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 19), LastLedgerSeq(11), Ter(terQUEUED)); checkMetrics(*this, env, 10, std::nullopt, 2, 1); auto const bobSeq = env.seq(bob); @@ -2697,7 +2686,7 @@ public: // Ledger 6 gets 5 from bob. for (int i = 0; i < 2 + 4 + 5; ++i) { - env(noop(bob), seq(bobSeq + i), fee(baseFee * 20), ter(terQUEUED)); + env(noop(bob), Seq(bobSeq + i), Fee(baseFee * 20), Ter(terQUEUED)); } checkMetrics(*this, env, 10 + 2 + 4 + 5, std::nullopt, 2, 1); // Close ledger 3 @@ -2718,12 +2707,12 @@ public: // Top off Alice's queue again using Tickets so the sequence gap is // unaffected. - env(noop(alice), ticket::use(aliceSeq + 1), ter(terQUEUED)); - env(noop(alice), ticket::use(aliceSeq + 2), ter(terQUEUED)); - env(noop(alice), ticket::use(aliceSeq + 3), ter(terQUEUED)); - env(noop(alice), ticket::use(aliceSeq + 4), ter(terQUEUED)); - env(noop(alice), ticket::use(aliceSeq + 5), ter(terQUEUED)); - env(noop(alice), ticket::use(aliceSeq + 6), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), ticket::Use(aliceSeq + 1), Ter(terQUEUED)); + env(noop(alice), ticket::Use(aliceSeq + 2), Ter(terQUEUED)); + env(noop(alice), ticket::Use(aliceSeq + 3), Ter(terQUEUED)); + env(noop(alice), ticket::Use(aliceSeq + 4), Ter(terQUEUED)); + env(noop(alice), ticket::Use(aliceSeq + 5), Ter(terQUEUED)); + env(noop(alice), ticket::Use(aliceSeq + 6), Ter(telCAN_NOT_QUEUE_FULL)); checkMetrics(*this, env, 11, 40, 5, 4); // Even though alice's queue is full we can still slide in a couple @@ -2733,32 +2722,32 @@ public: // Verify that we can't queue a sequence-based transaction that // follows a gap. - env(noop(alice), seq(aliceSeq + 20), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq + 20), Ter(telCAN_NOT_QUEUE_FULL)); // Verify that the transaction in front of the gap is still present // by attempting to replace it without a sufficient fee. - env(noop(alice), seq(aliceSeq + 15), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(aliceSeq + 15), Ter(telCAN_NOT_QUEUE_FEE)); // We can't queue a transaction into the middle of the gap. It must // go at the front. - env(noop(alice), seq(aliceSeq + 18), ter(telCAN_NOT_QUEUE_FULL)); - env(noop(alice), seq(aliceSeq + 17), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq + 18), Ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq + 17), Ter(telCAN_NOT_QUEUE_FULL)); // Successfully put this transaction into the front of the gap. - env(noop(alice), seq(aliceSeq + 16), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 16), Ter(terQUEUED)); // Still can't put a sequence-based transaction at the end of the gap. - env(noop(alice), seq(aliceSeq + 18), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq + 18), Ter(telCAN_NOT_QUEUE_FULL)); // But we can still fill the gap from the front. - env(noop(alice), seq(aliceSeq + 17), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 17), Ter(terQUEUED)); // Finally we can fill in the entire gap. - env(noop(alice), seq(aliceSeq + 18), ter(terQUEUED)); + env(noop(alice), Seq(aliceSeq + 18), Ter(terQUEUED)); checkMetrics(*this, env, 14, 40, 5, 4); // Verify that nothing can be added now that the gap is filled. - env(noop(alice), seq(aliceSeq + 20), ter(telCAN_NOT_QUEUE_FULL)); + env(noop(alice), Seq(aliceSeq + 20), Ter(telCAN_NOT_QUEUE_FULL)); // Close ledger 6. That removes some of alice's transactions, // but alice adds some more transaction(s) so expectedCount @@ -2786,7 +2775,7 @@ public: using namespace jtx; Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "6"}})); auto const baseFee = env.current()->fees().base.drops(); - Env_ss envs(env); + EnvSs envs(env); auto const& txQ = env.app().getTxQ(); auto const alice = Account("alice"); @@ -2800,21 +2789,21 @@ public: auto const aliceSeq = env.seq(alice); auto const lastLedgerSeq = env.current()->header().seq + 2; - auto submitParams = Json::Value(Json::objectValue); + auto submitParams = json::Value(json::ObjectValue); for (int i = 0; i < 5; ++i) { if (i == 2) { envs( noop(alice), - fee(baseFee * 100), - seq(none), - json(jss::LastLedgerSequence, lastLedgerSeq), - ter(terQUEUED))(submitParams); + Fee(baseFee * 100), + Seq(kNONE), + Json(jss::LastLedgerSequence, lastLedgerSeq), + Ter(terQUEUED))(submitParams); } else { - envs(noop(alice), fee(baseFee * 100), seq(none), ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 100), Seq(kNONE), Ter(terQUEUED))(submitParams); } } checkMetrics(*this, env, 5, std::nullopt, 7, 6); @@ -2825,7 +2814,7 @@ public: for (auto const& tx : aliceStat) { BEAST_EXPECT(tx.seqProxy == seq); - BEAST_EXPECT(tx.feeLevel == FeeLevel64{baseFeeLevel.fee() * 100}); + BEAST_EXPECT(tx.feeLevel == FeeLevel64{kBASE_FEE_LEVEL.fee() * 100}); if (seq.value() == aliceSeq + 2) { BEAST_EXPECT(tx.lastValid && *tx.lastValid == lastLedgerSeq); @@ -2840,7 +2829,7 @@ public: // Put some txs in the queue for bob. // Give them a higher fee so they'll beat alice's. for (int i = 0; i < 8; ++i) - envs(noop(bob), fee(baseFee * 200), seq(none), ter(terQUEUED))(); + envs(noop(bob), Fee(baseFee * 200), Seq(kNONE), Ter(terQUEUED))(); checkMetrics(*this, env, 13, std::nullopt, 7, 6); env.close(); @@ -2849,14 +2838,14 @@ public: // Give them a higher fee so they'll beat alice's. fillQueue(env, bob); for (int i = 0; i < 9; ++i) - envs(noop(bob), fee(baseFee * 200), seq(none), ter(terQUEUED))(); + envs(noop(bob), Fee(baseFee * 200), Seq(kNONE), Ter(terQUEUED))(); checkMetrics(*this, env, 14, 14, 8, 7, 25601); env.close(); // Put some more txs in the queue for bob. // Give them a higher fee so they'll beat alice's. fillQueue(env, bob); for (int i = 0; i < 10; ++i) - envs(noop(bob), fee(baseFee * 200), seq(none), ter(terQUEUED))(); + envs(noop(bob), Fee(baseFee * 200), Seq(kNONE), Ter(terQUEUED))(); checkMetrics(*this, env, 15, 16, 9, 8); env.close(); checkMetrics(*this, env, 4, 18, 10, 9); @@ -2878,13 +2867,13 @@ public: ++seq; BEAST_EXPECT(tx.seqProxy.isSeq() && tx.seqProxy.value() == seq); - BEAST_EXPECT(tx.feeLevel == FeeLevel64{baseFeeLevel.fee() * 100}); + BEAST_EXPECT(tx.feeLevel == FeeLevel64{kBASE_FEE_LEVEL.fee() * 100}); BEAST_EXPECT(!tx.lastValid); ++seq; } } // Now, fill the gap. - envs(noop(alice), fee(baseFee * 100), seq(none), ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 100), Seq(kNONE), Ter(terQUEUED))(submitParams); checkMetrics(*this, env, 5, 18, 10, 9); { auto aliceStat = txQ.getAccountTxs(alice.id()); @@ -2893,7 +2882,7 @@ public: for (auto const& tx : aliceStat) { BEAST_EXPECT(tx.seqProxy.isSeq() && tx.seqProxy.value() == seq); - BEAST_EXPECT(tx.feeLevel == FeeLevel64{baseFeeLevel * 100}); + BEAST_EXPECT(tx.feeLevel == FeeLevel64{kBASE_FEE_LEVEL * 100}); BEAST_EXPECT(!tx.lastValid); ++seq; } @@ -2920,20 +2909,20 @@ public: Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); - Env_ss envs(env); + EnvSs envs(env); Account const alice{"alice"}; env.fund(XRP(1000000), alice); env.close(); - Json::Value withQueue; + json::Value withQueue; withQueue[jss::account] = alice.human(); withQueue[jss::queue] = true; - Json::Value withoutQueue; + json::Value withoutQueue; withoutQueue[jss::account] = alice.human(); - Json::Value prevLedgerWithQueue; + json::Value prevLedgerWithQueue; prevLedgerWithQueue[jss::account] = alice.human(); prevLedgerWithQueue[jss::queue] = true; prevLedgerWithQueue[jss::ledger_index] = 3; @@ -2953,15 +2942,15 @@ public: info.isMember(jss::result) && info[jss::result].isMember(jss::account_data)); auto const& result = info[jss::result]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 0); - BEAST_EXPECT(!queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::highest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(!queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(!queue_data.isMember(jss::transactions)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 0); + BEAST_EXPECT(!queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::highest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(!queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(!queueData.isMember(jss::transactions)); } checkMetrics(*this, env, 0, 6, 0, 3); @@ -2974,22 +2963,22 @@ public: info.isMember(jss::result) && info[jss::result].isMember(jss::account_data)); auto const& result = info[jss::result]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 0); - BEAST_EXPECT(!queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::highest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(!queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(!queue_data.isMember(jss::transactions)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 0); + BEAST_EXPECT(!queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::highest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(!queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(!queueData.isMember(jss::transactions)); } - auto submitParams = Json::Value(Json::objectValue); - envs(noop(alice), fee(baseFee * 10), seq(none), ter(terQUEUED))(submitParams); - envs(noop(alice), fee(baseFee * 10), seq(none), ter(terQUEUED))(submitParams); - envs(noop(alice), fee(baseFee * 10), seq(none), ter(terQUEUED))(submitParams); - envs(noop(alice), fee(baseFee * 10), seq(none), ter(terQUEUED))(submitParams); + auto submitParams = json::Value(json::ObjectValue); + envs(noop(alice), Fee(baseFee * 10), Seq(kNONE), Ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 10), Seq(kNONE), Ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 10), Seq(kNONE), Ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 10), Seq(kNONE), Ter(terQUEUED))(submitParams); checkMetrics(*this, env, 4, 6, 4, 3); { @@ -2999,28 +2988,28 @@ public: auto const& result = info[jss::result]; auto const& data = result[jss::account_data]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 4); - BEAST_EXPECT(queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(queue_data[jss::lowest_sequence] == data[jss::Sequence]); - BEAST_EXPECT(queue_data.isMember(jss::highest_sequence)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 4); + BEAST_EXPECT(queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(queueData[jss::lowest_sequence] == data[jss::Sequence]); + BEAST_EXPECT(queueData.isMember(jss::highest_sequence)); BEAST_EXPECT( - queue_data[jss::highest_sequence] == - data[jss::Sequence].asUInt() + queue_data[jss::txn_count].asUInt() - 1); - BEAST_EXPECT(queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(queue_data[jss::auth_change_queued] == false); - BEAST_EXPECT(queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(queue_data[jss::max_spend_drops_total] == std::to_string(baseFee * 40)); - BEAST_EXPECT(queue_data.isMember(jss::transactions)); - auto const& queued = queue_data[jss::transactions]; - BEAST_EXPECT(queued.size() == queue_data[jss::txn_count]); + queueData[jss::highest_sequence] == + data[jss::Sequence].asUInt() + queueData[jss::txn_count].asUInt() - 1); + BEAST_EXPECT(queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(queueData[jss::auth_change_queued] == false); + BEAST_EXPECT(queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(queueData[jss::max_spend_drops_total] == std::to_string(baseFee * 40)); + BEAST_EXPECT(queueData.isMember(jss::transactions)); + auto const& queued = queueData[jss::transactions]; + BEAST_EXPECT(queued.size() == queueData[jss::txn_count]); for (unsigned i = 0; i < queued.size(); ++i) { auto const& item = queued[i]; BEAST_EXPECT(item[jss::seq] == data[jss::Sequence].asInt() + i); - BEAST_EXPECT(item[jss::fee_level] == std::to_string(baseFeeLevel.fee() * 10)); + BEAST_EXPECT(item[jss::fee_level] == std::to_string(kBASE_FEE_LEVEL.fee() * 10)); BEAST_EXPECT(!item.isMember(jss::LastLedgerSequence)); BEAST_EXPECT(item.isMember(jss::fee)); @@ -3037,14 +3026,14 @@ public: checkMetrics(*this, env, 0, 8, 4, 4); // Fill the ledger and then queue up a blocker. - envs(noop(alice), seq(none))(submitParams); + envs(noop(alice), Seq(kNONE))(submitParams); envs( fset(alice, asfAccountTxnID), - fee(baseFee * 10), - seq(none), - json(jss::LastLedgerSequence, 10), - ter(terQUEUED))(submitParams); + Fee(baseFee * 10), + Seq(kNONE), + Json(jss::LastLedgerSequence, 10), + Ter(terQUEUED))(submitParams); checkMetrics(*this, env, 1, 8, 5, 4); { @@ -3054,28 +3043,28 @@ public: auto const& result = info[jss::result]; auto const& data = result[jss::account_data]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 1); - BEAST_EXPECT(queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(queue_data[jss::lowest_sequence] == data[jss::Sequence]); - BEAST_EXPECT(queue_data.isMember(jss::highest_sequence)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 1); + BEAST_EXPECT(queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(queueData[jss::lowest_sequence] == data[jss::Sequence]); + BEAST_EXPECT(queueData.isMember(jss::highest_sequence)); BEAST_EXPECT( - queue_data[jss::highest_sequence] == - data[jss::Sequence].asUInt() + queue_data[jss::txn_count].asUInt() - 1); - BEAST_EXPECT(queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(queue_data[jss::auth_change_queued] == true); - BEAST_EXPECT(queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(queue_data[jss::max_spend_drops_total] == std::to_string(baseFee * 10)); - BEAST_EXPECT(queue_data.isMember(jss::transactions)); - auto const& queued = queue_data[jss::transactions]; - BEAST_EXPECT(queued.size() == queue_data[jss::txn_count]); + queueData[jss::highest_sequence] == + data[jss::Sequence].asUInt() + queueData[jss::txn_count].asUInt() - 1); + BEAST_EXPECT(queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(queueData[jss::auth_change_queued] == true); + BEAST_EXPECT(queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(queueData[jss::max_spend_drops_total] == std::to_string(baseFee * 10)); + BEAST_EXPECT(queueData.isMember(jss::transactions)); + auto const& queued = queueData[jss::transactions]; + BEAST_EXPECT(queued.size() == queueData[jss::txn_count]); for (unsigned i = 0; i < queued.size(); ++i) { auto const& item = queued[i]; BEAST_EXPECT(item[jss::seq] == data[jss::Sequence].asInt() + i); - BEAST_EXPECT(item[jss::fee_level] == std::to_string(baseFeeLevel.fee() * 10)); + BEAST_EXPECT(item[jss::fee_level] == std::to_string(kBASE_FEE_LEVEL.fee() * 10)); BEAST_EXPECT(item.isMember(jss::fee)); BEAST_EXPECT(item[jss::fee] == std::to_string(baseFee * 10)); BEAST_EXPECT(item.isMember(jss::max_spend_drops)); @@ -3096,8 +3085,8 @@ public: } } - envs( - noop(alice), fee(baseFee * 10), seq(none), ter(telCAN_NOT_QUEUE_BLOCKED))(submitParams); + envs(noop(alice), Fee(baseFee * 10), Seq(kNONE), Ter(telCAN_NOT_QUEUE_BLOCKED))( + submitParams); checkMetrics(*this, env, 1, 8, 5, 4); { @@ -3107,28 +3096,28 @@ public: auto const& result = info[jss::result]; auto const& data = result[jss::account_data]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 1); - BEAST_EXPECT(queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(queue_data[jss::lowest_sequence] == data[jss::Sequence]); - BEAST_EXPECT(queue_data.isMember(jss::highest_sequence)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 1); + BEAST_EXPECT(queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(queueData[jss::lowest_sequence] == data[jss::Sequence]); + BEAST_EXPECT(queueData.isMember(jss::highest_sequence)); BEAST_EXPECT( - queue_data[jss::highest_sequence] == - data[jss::Sequence].asUInt() + queue_data[jss::txn_count].asUInt() - 1); - BEAST_EXPECT(queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(queue_data[jss::auth_change_queued].asBool()); - BEAST_EXPECT(queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(queue_data[jss::max_spend_drops_total] == std::to_string(baseFee * 10)); - BEAST_EXPECT(queue_data.isMember(jss::transactions)); - auto const& queued = queue_data[jss::transactions]; - BEAST_EXPECT(queued.size() == queue_data[jss::txn_count]); + queueData[jss::highest_sequence] == + data[jss::Sequence].asUInt() + queueData[jss::txn_count].asUInt() - 1); + BEAST_EXPECT(queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(queueData[jss::auth_change_queued].asBool()); + BEAST_EXPECT(queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(queueData[jss::max_spend_drops_total] == std::to_string(baseFee * 10)); + BEAST_EXPECT(queueData.isMember(jss::transactions)); + auto const& queued = queueData[jss::transactions]; + BEAST_EXPECT(queued.size() == queueData[jss::txn_count]); for (unsigned i = 0; i < queued.size(); ++i) { auto const& item = queued[i]; BEAST_EXPECT(item[jss::seq] == data[jss::Sequence].asInt() + i); - BEAST_EXPECT(item[jss::fee_level] == std::to_string(baseFeeLevel.fee() * 10)); + BEAST_EXPECT(item[jss::fee_level] == std::to_string(kBASE_FEE_LEVEL.fee() * 10)); if (i == queued.size() - 1) { @@ -3156,7 +3145,7 @@ public: { auto const info = env.rpc("json", "account_info", to_string(prevLedgerWithQueue)); - BEAST_EXPECT(info.isMember(jss::result) && RPC::contains_error(info[jss::result])); + BEAST_EXPECT(info.isMember(jss::result) && RPC::containsError(info[jss::result])); } env.close(); @@ -3170,15 +3159,15 @@ public: info.isMember(jss::result) && info[jss::result].isMember(jss::account_data)); auto const& result = info[jss::result]; BEAST_EXPECT(result.isMember(jss::queue_data)); - auto const& queue_data = result[jss::queue_data]; - BEAST_EXPECT(queue_data.isObject()); - BEAST_EXPECT(queue_data.isMember(jss::txn_count)); - BEAST_EXPECT(queue_data[jss::txn_count] == 0); - BEAST_EXPECT(!queue_data.isMember(jss::lowest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::highest_sequence)); - BEAST_EXPECT(!queue_data.isMember(jss::auth_change_queued)); - BEAST_EXPECT(!queue_data.isMember(jss::max_spend_drops_total)); - BEAST_EXPECT(!queue_data.isMember(jss::transactions)); + auto const& queueData = result[jss::queue_data]; + BEAST_EXPECT(queueData.isObject()); + BEAST_EXPECT(queueData.isMember(jss::txn_count)); + BEAST_EXPECT(queueData[jss::txn_count] == 0); + BEAST_EXPECT(!queueData.isMember(jss::lowest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::highest_sequence)); + BEAST_EXPECT(!queueData.isMember(jss::auth_change_queued)); + BEAST_EXPECT(!queueData.isMember(jss::max_spend_drops_total)); + BEAST_EXPECT(!queueData.isMember(jss::transactions)); } } @@ -3190,17 +3179,17 @@ public: Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); - Env_ss envs(env); + EnvSs envs(env); Account const alice{"alice"}; env.fund(XRP(1000000), alice); env.close(); { - auto const server_info = env.rpc("server_info"); + auto const serverInfo = env.rpc("server_info"); BEAST_EXPECT( - server_info.isMember(jss::result) && server_info[jss::result].isMember(jss::info)); - auto const& info = server_info[jss::result][jss::info]; + serverInfo.isMember(jss::result) && serverInfo[jss::result].isMember(jss::info)); + auto const& info = serverInfo[jss::result][jss::info]; BEAST_EXPECT(info.isMember(jss::load_factor) && info[jss::load_factor] == 1); BEAST_EXPECT(!info.isMember(jss::load_factor_server)); BEAST_EXPECT(!info.isMember(jss::load_factor_local)); @@ -3208,8 +3197,8 @@ public: BEAST_EXPECT(!info.isMember(jss::load_factor_fee_escalation)); } { - auto const server_state = env.rpc("server_state"); - auto const& state = server_state[jss::result][jss::state]; + auto const serverState = env.rpc("server_state"); + auto const& state = serverState[jss::result][jss::state]; BEAST_EXPECT(state.isMember(jss::load_factor) && state[jss::load_factor] == 256); BEAST_EXPECT(state.isMember(jss::load_base) && state[jss::load_base] == 256); BEAST_EXPECT( @@ -3231,16 +3220,16 @@ public: checkMetrics(*this, env, 0, 6, 4, 3); auto aliceSeq = env.seq(alice); - auto submitParams = Json::Value(Json::objectValue); + auto submitParams = json::Value(json::ObjectValue); for (auto i = 0; i < 4; ++i) - envs(noop(alice), fee(baseFee * 10), seq(aliceSeq + i), ter(terQUEUED))(submitParams); + envs(noop(alice), Fee(baseFee * 10), Seq(aliceSeq + i), Ter(terQUEUED))(submitParams); checkMetrics(*this, env, 4, 6, 4, 3); { - auto const server_info = env.rpc("server_info"); + auto const serverInfo = env.rpc("server_info"); BEAST_EXPECT( - server_info.isMember(jss::result) && server_info[jss::result].isMember(jss::info)); - auto const& info = server_info[jss::result][jss::info]; + serverInfo.isMember(jss::result) && serverInfo[jss::result].isMember(jss::info)); + auto const& info = serverInfo[jss::result][jss::info]; // Avoid double rounding issues by comparing to a range. BEAST_EXPECT( info.isMember(jss::load_factor) && info[jss::load_factor] > 888.88 && @@ -3255,8 +3244,8 @@ public: info[jss::load_factor_fee_escalation] < 888.89); } { - auto const server_state = env.rpc("server_state"); - auto const& state = server_state[jss::result][jss::state]; + auto const serverState = env.rpc("server_state"); + auto const& state = serverState[jss::result][jss::state]; BEAST_EXPECT(state.isMember(jss::load_factor) && state[jss::load_factor] == 227555); BEAST_EXPECT(state.isMember(jss::load_base) && state[jss::load_base] == 256); BEAST_EXPECT( @@ -3275,10 +3264,10 @@ public: env.app().getFeeTrack().setRemoteFee(256000); { - auto const server_info = env.rpc("server_info"); + auto const serverInfo = env.rpc("server_info"); BEAST_EXPECT( - server_info.isMember(jss::result) && server_info[jss::result].isMember(jss::info)); - auto const& info = server_info[jss::result][jss::info]; + serverInfo.isMember(jss::result) && serverInfo[jss::result].isMember(jss::info)); + auto const& info = serverInfo[jss::result][jss::info]; // Avoid double rounding issues by comparing to a range. BEAST_EXPECT(info.isMember(jss::load_factor) && info[jss::load_factor] == 1000); BEAST_EXPECT(!info.isMember(jss::load_factor_server)); @@ -3290,8 +3279,8 @@ public: info[jss::load_factor_fee_escalation] < 888.89); } { - auto const server_state = env.rpc("server_state"); - auto const& state = server_state[jss::result][jss::state]; + auto const serverState = env.rpc("server_state"); + auto const& state = serverState[jss::result][jss::state]; BEAST_EXPECT(state.isMember(jss::load_factor) && state[jss::load_factor] == 256000); BEAST_EXPECT(state.isMember(jss::load_base) && state[jss::load_base] == 256); BEAST_EXPECT( @@ -3316,10 +3305,10 @@ public: BEAST_EXPECT(env.app().getFeeTrack().getLoadFactor() == 625); { - auto const server_info = env.rpc("server_info"); + auto const serverInfo = env.rpc("server_info"); BEAST_EXPECT( - server_info.isMember(jss::result) && server_info[jss::result].isMember(jss::info)); - auto const& info = server_info[jss::result][jss::info]; + serverInfo.isMember(jss::result) && serverInfo[jss::result].isMember(jss::info)); + auto const& info = serverInfo[jss::result][jss::info]; // Avoid double rounding issues by comparing to a range. BEAST_EXPECT( info.isMember(jss::load_factor) && info[jss::load_factor] > 888.88 && @@ -3340,8 +3329,8 @@ public: info[jss::load_factor_fee_escalation] < 888.89); } { - auto const server_state = env.rpc("server_state"); - auto const& state = server_state[jss::result][jss::state]; + auto const serverState = env.rpc("server_state"); + auto const& state = serverState[jss::result][jss::state]; BEAST_EXPECT(state.isMember(jss::load_factor) && state[jss::load_factor] == 227555); BEAST_EXPECT(state.isMember(jss::load_base) && state[jss::load_base] == 256); // There can be a race between LoadManager lowering the fee, @@ -3364,10 +3353,10 @@ public: env.close(); { - auto const server_info = env.rpc("server_info"); + auto const serverInfo = env.rpc("server_info"); BEAST_EXPECT( - server_info.isMember(jss::result) && server_info[jss::result].isMember(jss::info)); - auto const& info = server_info[jss::result][jss::info]; + serverInfo.isMember(jss::result) && serverInfo[jss::result].isMember(jss::info)); + auto const& info = serverInfo[jss::result][jss::info]; // Avoid double rounding issues by comparing to a range. // There can be a race between LoadManager lowering the fee, @@ -3384,8 +3373,8 @@ public: BEAST_EXPECT(!info.isMember(jss::load_factor_fee_escalation)); } { - auto const server_state = env.rpc("server_state"); - auto const& state = server_state[jss::result][jss::state]; + auto const serverState = env.rpc("server_state"); + auto const& state = serverState[jss::result][jss::state]; BEAST_EXPECT( state.isMember(jss::load_factor) && state[jss::load_factor] >= 320 && state[jss::load_factor] <= 625); @@ -3417,8 +3406,8 @@ public: Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}})); auto const baseFee = env.current()->fees().base.drops(); - Json::Value stream; - stream[jss::streams] = Json::arrayValue; + json::Value stream; + stream[jss::streams] = json::ArrayValue; stream[jss::streams].append("server"); auto wsc = makeWSClient(env.app().config()); { @@ -3480,14 +3469,14 @@ public: env.fund(XRP(50000), noripple(e, f, g, h, i)); // Extra transactions with low fee are queued - auto queued = ter(terQUEUED); - env(noop(a), fee(baseFee), queued); - env(noop(b), fee(baseFee), queued); - env(noop(c), fee(baseFee), queued); - env(noop(d), fee(baseFee), queued); - env(noop(e), fee(baseFee), queued); - env(noop(f), fee(baseFee), queued); - env(noop(g), fee(baseFee), queued); + auto queued = Ter(terQUEUED); + env(noop(a), Fee(baseFee), queued); + env(noop(b), Fee(baseFee), queued); + env(noop(c), Fee(baseFee), queued); + env(noop(d), Fee(baseFee), queued); + env(noop(e), Fee(baseFee), queued); + env(noop(f), Fee(baseFee), queued); + env(noop(g), Fee(baseFee), queued); checkMetrics(*this, env, 7, 8, 5, 4); // Last transaction escalates the fee @@ -3596,7 +3585,7 @@ public: std::uint64_t totalPaid = 0; for (int i = 0; i < 2; ++i) { - env(noop(alice), fee(baseFee * 10), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(baseFee * 10), Seq(aliceSeq++), Ter(terQUEUED)); totalPaid += baseFee * 10; } @@ -3604,7 +3593,7 @@ public: // This will be the first tx to call the operative function, // but it won't succeed. totalPaid += openLedgerCost(env).drops(); - env(noop(alice), fee(openLedgerCost(env)), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(openLedgerCost(env)), Seq(aliceSeq++), Ter(terQUEUED)); checkMetrics(*this, env, 3, std::nullopt, 4, 3); @@ -3616,7 +3605,7 @@ public: // Submit a transaction with that fee. It will get queued // because the fee level calculation rounds down. This is // the edge case test. - env(noop(alice), fee(totalFee), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(totalFee), Seq(aliceSeq++), Ter(terQUEUED)); checkMetrics(*this, env, 4, std::nullopt, 4, 3); @@ -3626,7 +3615,7 @@ public: totalFee = calcTotalFee(totalPaid); // Submit a transaction with that fee. It will succeed. - env(noop(alice), fee(totalFee), seq(aliceSeq++)); + env(noop(alice), Fee(totalFee), Seq(aliceSeq++)); checkMetrics(*this, env, 0, std::nullopt, 9, 3); } @@ -3638,14 +3627,14 @@ public: uint64_t totalPaid = 0; for (int i = 0; i < 2; ++i) { - env(noop(alice), fee(baseFee * 10), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(baseFee * 10), Seq(aliceSeq++), Ter(terQUEUED)); totalPaid += baseFee * 10; } // Queue up a transaction paying the open ledger fee // This will be the first tx to call the operative function, // but it won't succeed. - env(noop(alice), fee(openLedgerCost(env)), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(openLedgerCost(env)), Seq(aliceSeq++), Ter(terQUEUED)); checkMetrics(*this, env, 3, std::nullopt, 9, 3); @@ -3655,7 +3644,7 @@ public: std::uint64_t const totalFee = calcTotalFee(totalPaid, metrics.txCount); // Replacing the last tx with the large fee succeeds. --aliceSeq; - env(noop(alice), fee(totalFee), seq(aliceSeq++)); + env(noop(alice), Fee(totalFee), Seq(aliceSeq++)); // The queue is clear checkMetrics(*this, env, 0, std::nullopt, 12, 3); @@ -3671,7 +3660,7 @@ public: auto aliceSeq = env.seq(alice); for (int i = 0; i < 5; ++i) { - env(noop(alice), fee(baseFee * 10), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(baseFee * 10), Seq(aliceSeq++), Ter(terQUEUED)); } checkMetrics(*this, env, 5, 24, 13, 12); @@ -3680,7 +3669,7 @@ public: uint64_t const totalFee = calcTotalFee(baseFee * 10 * 2, 3); // Replacing the last tx with the large fee succeeds. aliceSeq -= 3; - env(noop(alice), fee(totalFee), seq(aliceSeq++)); + env(noop(alice), Fee(totalFee), Seq(aliceSeq++)); checkMetrics(*this, env, 2, 24, 16, 12); auto const aliceQueue = env.app().getTxQ().getAccountTxs(alice.id()); @@ -3689,7 +3678,7 @@ public: for (auto const& tx : aliceQueue) { BEAST_EXPECT(tx.seqProxy == seq); - BEAST_EXPECT(tx.feeLevel == FeeLevel64{baseFeeLevel.fee() * 10}); + BEAST_EXPECT(tx.feeLevel == FeeLevel64{kBASE_FEE_LEVEL.fee() * 10}); seq.advanceBy(1); } @@ -3706,12 +3695,12 @@ public: uint64_t totalPaid = 0; for (int i = 0; i < 2; ++i) { - env(noop(alice), fee(baseFee * 20), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(baseFee * 20), Seq(aliceSeq++), Ter(terQUEUED)); totalPaid += baseFee * 20; } for (int i = 0; i < 2; ++i) { - env(noop(alice), fee(baseFee * 2.2), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(baseFee * 2.2), Seq(aliceSeq++), Ter(terQUEUED)); totalPaid += baseFee * 2.2; } @@ -3726,7 +3715,7 @@ public: feeTrack.setRemoteFee(origFee * 5); // Instead the tx gets queued, and all of the queued // txs stay in the queue. - env(noop(alice), fee(totalFee), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(totalFee), Seq(aliceSeq++), Ter(terQUEUED)); // The original last transaction is still in the queue checkMetrics(*this, env, 5, 32, 17, 16); @@ -3743,7 +3732,7 @@ public: fillQueue(env, bob); checkMetrics(*this, env, 3, 34, 18, 17); - env(noop(alice), fee(XRP(1)), seq(aliceSeq++), ter(terQUEUED)); + env(noop(alice), Fee(XRP(1)), Seq(aliceSeq++), Ter(terQUEUED)); checkMetrics(*this, env, 4, 34, 18, 17); // With normal load, those txs get into the ledger @@ -3778,7 +3767,7 @@ public: auto seqAlice = env.seq(alice); auto txCount = 140; for (int i = 0; i < txCount; ++i) - env(noop(alice), seq(seqAlice++), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Ter(terQUEUED)); checkMetrics(*this, env, txCount, std::nullopt, 4, 3); // Close a few ledgers successfully, so the limit grows @@ -3864,7 +3853,7 @@ public: auto seqAlice = env.seq(alice); auto txCount = 43; for (int i = 0; i < txCount; ++i) - env(noop(alice), seq(seqAlice++), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Ter(terQUEUED)); checkMetrics(*this, env, txCount, std::nullopt, 4, 3); // Close a few ledgers successfully, so the limit grows @@ -3910,7 +3899,7 @@ public: auto const alice = Account("alice"); - auto const queued = ter(terQUEUED); + auto const queued = Ter(terQUEUED); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -3932,8 +3921,8 @@ public: // which won't work if unit tests are separated to only // be callable via RPC.) env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const tx = env.jt(noop(alice), seq(aliceSeq), fee(openLedgerCost(env))); - auto const result = xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j); + auto const tx = env.jt(noop(alice), Seq(aliceSeq), Fee(openLedgerCost(env))); + auto const result = xrpl::apply(env.app(), view, *tx.stx, TapUnlimited, j); BEAST_EXPECT(isTesSuccess(result.ter) && result.applied); return result.applied; }); @@ -3943,12 +3932,12 @@ public: // The next transaction should be able to go into the open // ledger, even though aliceSeq is queued. In earlier incarnations // of the TxQ this would cause an assert. - env(noop(alice), seq(aliceSeq + 1), fee(openLedgerCost(env))); + env(noop(alice), Seq(aliceSeq + 1), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, std::nullopt, 6, 3); // Now queue a couple more transactions to make sure // they succeed despite aliceSeq being queued - env(noop(alice), seq(aliceSeq + 2), queued); - env(noop(alice), seq(aliceSeq + 3), queued); + env(noop(alice), Seq(aliceSeq + 2), queued); + env(noop(alice), Seq(aliceSeq + 3), queued); checkMetrics(*this, env, 3, std::nullopt, 6, 3); // Now close the ledger. One of the queued transactions @@ -3973,7 +3962,7 @@ public: auto alice = Account("alice"); - auto queued = ter(terQUEUED); + auto queued = Ter(terQUEUED); checkMetrics(*this, env, 0, std::nullopt, 0, 3); @@ -3991,7 +3980,7 @@ public: // Queue a transaction with a ticket. Leave an unused ticket // on either side. - env(noop(alice), ticket::use(tktSeq0 + 1), queued); + env(noop(alice), ticket::Use(tktSeq0 + 1), queued); checkMetrics(*this, env, 1, std::nullopt, 4, 3); // Now, apply a (different) transaction directly @@ -4000,8 +3989,8 @@ public: // which won't work if unit tests are separated to only // be callable via RPC.) env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) { - auto const tx = env.jt(noop(alice), ticket::use(tktSeq0 + 1), fee(openLedgerCost(env))); - auto const result = xrpl::apply(env.app(), view, *tx.stx, tapUNLIMITED, j); + auto const tx = env.jt(noop(alice), ticket::Use(tktSeq0 + 1), Fee(openLedgerCost(env))); + auto const result = xrpl::apply(env.app(), view, *tx.stx, TapUnlimited, j); BEAST_EXPECT(isTesSuccess(result.ter) && result.applied); return result.applied; }); @@ -4012,18 +4001,18 @@ public: // the open ledger, even though tktSeq0 is queued. Note that this // sequence-based transaction goes in front of the queued // transaction, so the queued transaction is left in the queue. - env(noop(alice), fee(openLedgerCost(env))); + env(noop(alice), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, std::nullopt, 6, 3); // We should be able to do the same thing with a ticket that goes // if front of the queued transaction. This one too will leave // the queued transaction in place. - env(noop(alice), ticket::use(tktSeq0 + 0), fee(openLedgerCost(env))); + env(noop(alice), ticket::Use(tktSeq0 + 0), Fee(openLedgerCost(env))); checkMetrics(*this, env, 1, std::nullopt, 7, 3); // We have one ticketed transaction in the queue. We should able // to add another to the queue. - env(noop(alice), ticket::use(tktSeq0 + 2), queued); + env(noop(alice), ticket::Use(tktSeq0 + 2), queued); checkMetrics(*this, env, 2, std::nullopt, 7, 3); // Here we try to force the queued transactions into the ledger by @@ -4039,7 +4028,7 @@ public: // Fee averaging does not make sense with tickets. Every ticketed // transaction is equally capable of going into the ledger independent // of all other ticket- or sequence-based transactions. - env(noop(alice), ticket::use(tktSeq0 + 3), fee(XRP(10))); + env(noop(alice), ticket::Use(tktSeq0 + 3), Fee(XRP(10))); checkMetrics(*this, env, 2, std::nullopt, 8, 3); // Now close the ledger. One of the queued transactions @@ -4068,10 +4057,10 @@ public: Account const ellie("ellie"); Account const fiona("fiona"); - constexpr int ledgersInQueue = 30; + constexpr int kLEDGERS_IN_QUEUE = 30; auto cfg = makeConfig( {{"minimum_txn_in_ledger_standalone", "1"}, - {"ledgers_in_queue", std::to_string(ledgersInQueue)}, + {"ledgers_in_queue", std::to_string(kLEDGERS_IN_QUEUE)}, {"maximum_txn_per_account", "10"}}, {{"account_reserve", "1000"}, {"owner_reserve", "50"}}); @@ -4096,7 +4085,7 @@ public: env.close(); auto const metrics = env.app().getTxQ().getMetrics(*env.current()); - checkMetrics(*this, env, 0, ledgersInQueue * metrics.txPerLedger, 0, 2); + checkMetrics(*this, env, 0, kLEDGERS_IN_QUEUE * metrics.txPerLedger, 0, 2); // Close ledgers until the amendments show up. int i = 0; @@ -4107,7 +4096,7 @@ public: break; } auto expectedPerLedger = xrpl::detail::numUpVotedAmendments() + 1; - checkMetrics(*this, env, 0, ledgersInQueue * expectedPerLedger, 0, expectedPerLedger); + checkMetrics(*this, env, 0, kLEDGERS_IN_QUEUE * expectedPerLedger, 0, expectedPerLedger); // Now wait 2 weeks modulo 256 ledgers for the amendments to be // enabled. Speed the process by closing ledgers every 80 minutes, @@ -4126,7 +4115,7 @@ public: *this, env, 0, - ledgersInQueue * expectedPerLedger, + kLEDGERS_IN_QUEUE * expectedPerLedger, expectedPerLedger + 1, expectedPerLedger); @@ -4141,25 +4130,25 @@ public: // Use fees to guarantee order int txFee{static_cast(baseFee * 9)}; auto prepareFee = [&](uint64_t multiplier) { - return fee(txFee - (multiplier * baseFee / 10)); + return Fee(txFee - (multiplier * baseFee / 10)); }; uint64_t multiplier = 0; for (int i = 0; i < 10; ++i) { - env(noop(alice), seq(seqAlice++), prepareFee(++multiplier), ter(terQUEUED)); - env(noop(bob), seq(seqBob++), prepareFee(++multiplier), ter(terQUEUED)); - env(noop(carol), seq(seqCarol++), prepareFee(++multiplier), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), prepareFee(++multiplier), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), prepareFee(++multiplier), ter(terQUEUED)); - env(noop(fiona), seq(seqFiona++), prepareFee(++multiplier), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), prepareFee(++multiplier), Ter(terQUEUED)); + env(noop(bob), Seq(seqBob++), prepareFee(++multiplier), Ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), prepareFee(++multiplier), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), prepareFee(++multiplier), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), prepareFee(++multiplier), Ter(terQUEUED)); + env(noop(fiona), Seq(seqFiona++), prepareFee(++multiplier), Ter(terQUEUED)); } std::size_t expectedInQueue = multiplier; checkMetrics( *this, env, expectedInQueue, - ledgersInQueue * expectedPerLedger, + kLEDGERS_IN_QUEUE * expectedPerLedger, expectedPerLedger + 1, expectedPerLedger); @@ -4185,7 +4174,7 @@ public: *this, env, expectedInQueue, - ledgersInQueue * expectedPerLedger, + kLEDGERS_IN_QUEUE * expectedPerLedger, expectedInLedger, expectedPerLedger); { @@ -4270,16 +4259,16 @@ public: auto seqAlice = env.seq(alice); auto const seqSaveAlice = seqAlice; int feeDrops = baseFee * 4; - env(noop(alice), seq(seqAlice++), fee(--feeDrops), last_ledger_seq(7), ter(terQUEUED)); - env(noop(alice), seq(seqAlice++), fee(--feeDrops), ter(terQUEUED)); - env(noop(alice), seq(seqAlice++), fee(--feeDrops), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Fee(--feeDrops), LastLedgerSeq(7), Ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Fee(--feeDrops), Ter(terQUEUED)); BEAST_EXPECT(env.seq(alice) == seqSaveAlice); // Similarly for bob, but bob uses tickets in his transactions. // The drop penalty works a little differently with tickets. - env(noop(bob), ticket::use(bobTicketSeq + 0), last_ledger_seq(7), ter(terQUEUED)); - env(noop(bob), ticket::use(bobTicketSeq + 1), fee(--feeDrops), ter(terQUEUED)); - env(noop(bob), ticket::use(bobTicketSeq + 2), fee(--feeDrops), ter(terQUEUED)); + env(noop(bob), ticket::Use(bobTicketSeq + 0), LastLedgerSeq(7), Ter(terQUEUED)); + env(noop(bob), ticket::Use(bobTicketSeq + 1), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(bob), ticket::Use(bobTicketSeq + 2), Fee(--feeDrops), Ter(terQUEUED)); // Fill the queue with higher fee transactions so alice's and // bob's transactions are stuck in the queue. @@ -4290,10 +4279,10 @@ public: feeDrops = medFee; for (int i = 0; i < 7; ++i) { - env(noop(carol), seq(seqCarol++), fee(--feeDrops), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), fee(--feeDrops), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), fee(--feeDrops), ter(terQUEUED)); - env(noop(fiona), seq(seqFiona++), fee(--feeDrops), ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(fiona), Seq(seqFiona++), Fee(--feeDrops), Ter(terQUEUED)); } checkMetrics(*this, env, 34, 50, 7, 6); @@ -4304,10 +4293,10 @@ public: feeDrops = medFee; for (int i = 0; i < 3; ++i) { - env(noop(carol), seq(seqCarol++), fee(--feeDrops), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), fee(--feeDrops), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), fee(--feeDrops), ter(terQUEUED)); - env(noop(fiona), seq(seqFiona++), fee(--feeDrops), ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(fiona), Seq(seqFiona++), Fee(--feeDrops), Ter(terQUEUED)); } checkMetrics(*this, env, 38, 50, 8, 7); env.close(); @@ -4317,10 +4306,10 @@ public: feeDrops = medFee; for (int i = 0; i < 3; ++i) { - env(noop(carol), seq(seqCarol++), fee(--feeDrops), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), fee(--feeDrops), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), fee(--feeDrops), ter(terQUEUED)); - env(noop(fiona), seq(seqFiona++), fee(--feeDrops), ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(fiona), Seq(seqFiona++), Fee(--feeDrops), Ter(terQUEUED)); } checkMetrics(*this, env, 41, 50, 9, 8); env.close(); @@ -4332,20 +4321,20 @@ public: // // This also means that alice has a sequence gap in her transactions, // and thus can't queue any more. - env(noop(alice), seq(seqAlice), fee(hiFee), ter(telCAN_NOT_QUEUE)); + env(noop(alice), Seq(seqAlice), Fee(hiFee), Ter(telCAN_NOT_QUEUE)); // Once again, fill the queue almost to the brim. feeDrops = medFee; for (int i = 0; i < 4; ++i) { - env(noop(carol), seq(seqCarol++), fee(--feeDrops), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), fee(--feeDrops), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), fee(--feeDrops), ter(terQUEUED)); - env(noop(fiona), seq(seqFiona++), fee(--feeDrops), ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(fiona), Seq(seqFiona++), Fee(--feeDrops), Ter(terQUEUED)); } - env(noop(carol), seq(seqCarol++), fee(--feeDrops), ter(terQUEUED)); - env(noop(daria), seq(seqDaria++), fee(--feeDrops), ter(terQUEUED)); - env(noop(ellie), seq(seqEllie++), fee(--feeDrops), ter(terQUEUED)); + env(noop(carol), Seq(seqCarol++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(daria), Seq(seqDaria++), Fee(--feeDrops), Ter(terQUEUED)); + env(noop(ellie), Seq(seqEllie++), Fee(--feeDrops), Ter(terQUEUED)); checkMetrics(*this, env, 48, 50, 10, 9); // Now induce a fee jump which should cause all the transactions @@ -4389,22 +4378,22 @@ public: // b) For just now having a queued transaction fail on apply() // because of the sequence gap. // - // Verify that none of alice's queued transactions actually applied to + // Verify that kNONE of alice's queued transactions actually applied to // her account. BEAST_EXPECT(env.seq(alice) == seqSaveAlice); seqAlice = seqSaveAlice; // Verify that there's a gap at the front of alice's queue by // queuing another low fee transaction into that spot. - env(noop(alice), seq(seqAlice++), fee(baseFee * 1.1), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Fee(baseFee * 1.1), Ter(terQUEUED)); // Verify that the first entry in alice's queue is still there // by trying to replace it and having that fail. - env(noop(alice), seq(seqAlice++), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(alice), Seq(seqAlice++), Ter(telCAN_NOT_QUEUE_FEE)); // Verify that the last transaction in alice's queue was removed by // appending to her queue with a very low fee. - env(noop(alice), seq(seqAlice++), ter(terQUEUED)); + env(noop(alice), Seq(seqAlice++), Ter(terQUEUED)); // Before the close() bob had two transactions in his queue. // We now expect him to have one. Here's the state of bob's queue. @@ -4422,15 +4411,15 @@ public: // Verify that bob's first transaction was removed from the queue // by queueing another low fee transaction into that spot. - env(noop(bob), ticket::use(bobTicketSeq + 0), fee(baseFee * 1.2), ter(terQUEUED)); + env(noop(bob), ticket::Use(bobTicketSeq + 0), Fee(baseFee * 1.2), Ter(terQUEUED)); // Verify that bob's second transaction was removed from the queue // by queueing another low fee transaction into that spot. - env(noop(bob), ticket::use(bobTicketSeq + 1), fee(baseFee * 1.1), ter(terQUEUED)); + env(noop(bob), ticket::Use(bobTicketSeq + 1), Fee(baseFee * 1.1), Ter(terQUEUED)); // Verify that the last entry in bob's queue is still there // by trying to replace it and having that fail. - env(noop(bob), ticket::use(bobTicketSeq + 2), ter(telCAN_NOT_QUEUE_FEE)); + env(noop(bob), ticket::Use(bobTicketSeq + 2), Ter(telCAN_NOT_QUEUE_FEE)); } void @@ -4441,7 +4430,7 @@ public: Account const alice("alice"); auto gw = Account("gw"); - auto USD = gw["USD"]; + auto usd = gw["USD"]; auto cfg = makeConfig( {{"minimum_txn_in_ledger_standalone", "5"}, @@ -4462,18 +4451,18 @@ public: // Alice creates a couple offers auto const aliceSeq = env.seq(alice); - env(offer(alice, USD(1000), XRP(1000)), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1000)), Ter(terQUEUED)); - env(offer(alice, USD(1000), XRP(1001)), seq(aliceSeq + 1), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1001)), Seq(aliceSeq + 1), Ter(terQUEUED)); // Alice creates transactions that cancel the first set of // offers, one through another offer, and one cancel - env(offer(alice, USD(1000), XRP(1002)), - seq(aliceSeq + 2), - json(jss::OfferSequence, aliceSeq), - ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1002)), + Seq(aliceSeq + 2), + Json(jss::OfferSequence, aliceSeq), + Ter(terQUEUED)); - env(offer_cancel(alice, aliceSeq + 1), seq(aliceSeq + 3), ter(terQUEUED)); + env(offerCancel(alice, aliceSeq + 1), Seq(aliceSeq + 3), Ter(terQUEUED)); env.close(); @@ -4493,9 +4482,9 @@ public: // Alice creates a couple offers using tickets, consuming the // tickets in reverse order auto const aliceSeq = env.seq(alice); - env(offer(alice, USD(1000), XRP(1000)), ticket::use(aliceTkt + 4), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1000)), ticket::Use(aliceTkt + 4), Ter(terQUEUED)); - env(offer(alice, USD(1000), XRP(1001)), ticket::use(aliceTkt + 3), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1001)), ticket::Use(aliceTkt + 3), Ter(terQUEUED)); // Alice creates a couple more transactions that cancel the first // set of offers, also in reverse order. This allows Alice to submit @@ -4503,25 +4492,25 @@ public: // These transactions succeed because Ticket ordering is arbitrary // and it's up to the user to ensure they don't step on their own // feet. - env(offer(alice, USD(1000), XRP(1002)), - ticket::use(aliceTkt + 2), - json(jss::OfferSequence, aliceTkt + 4), - ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1002)), + ticket::Use(aliceTkt + 2), + Json(jss::OfferSequence, aliceTkt + 4), + Ter(terQUEUED)); - env(offer_cancel(alice, aliceTkt + 3), ticket::use(aliceTkt + 1), ter(terQUEUED)); + env(offerCancel(alice, aliceTkt + 3), ticket::Use(aliceTkt + 1), Ter(terQUEUED)); // Create a couple more offers using sequences - env(offer(alice, USD(1000), XRP(1000)), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1000)), Ter(terQUEUED)); - env(offer(alice, USD(1000), XRP(1001)), seq(aliceSeq + 1), ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1001)), Seq(aliceSeq + 1), Ter(terQUEUED)); // And try to cancel those using tickets - env(offer(alice, USD(1000), XRP(1002)), - ticket::use(aliceTkt + 5), - json(jss::OfferSequence, aliceSeq), - ter(terQUEUED)); + env(offer(alice, usd(1000), XRP(1002)), + ticket::Use(aliceTkt + 5), + Json(jss::OfferSequence, aliceSeq), + Ter(terQUEUED)); - env(offer_cancel(alice, aliceSeq + 1), ticket::use(aliceTkt + 6), ter(terQUEUED)); + env(offerCancel(alice, aliceSeq + 1), ticket::Use(aliceTkt + 6), Ter(terQUEUED)); env.close(); @@ -4539,7 +4528,7 @@ public: using namespace jtx; Account const alice("alice"); - auto const queued = ter(terQUEUED); + auto const queued = Ter(terQUEUED); Env env( *this, @@ -4558,7 +4547,7 @@ public: auto const fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; @@ -4599,7 +4588,7 @@ public: checkMetrics(*this, env, 0, 6, 4, 3); - env(noop(alice), fee(openLedgerCost(env))); + env(noop(alice), Fee(openLedgerCost(env))); checkMetrics(*this, env, 0, 6, 5, 3); @@ -4608,7 +4597,7 @@ public: checkMetrics(*this, env, 1, 6, 5, 3); - env(noop(alice), seq(aliceSeq + 1), fee(10), queued); + env(noop(alice), Seq(aliceSeq + 1), Fee(10), queued); checkMetrics(*this, env, 2, 6, 5, 3); @@ -4616,7 +4605,7 @@ public: auto const fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::contains_error(fee[jss::result]))) + BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index bbc77671bc..fa8ec7ea3d 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -22,15 +22,15 @@ namespace xrpl::test { -class ValidatorKeys_test : public beast::unit_test::suite +class ValidatorKeys_test : public beast::unit_test::Suite { // Used with [validation_seed] - std::string const seed = "shUwVw52ofnCUX5m7kPTKzJdr4HEH"; + std::string const seed_ = "shUwVw52ofnCUX5m7kPTKzJdr4HEH"; // Used with [validation_token] - std::string const tokenSecretStr = "paQmjZ37pKKPMrgadBLsuf9ab7Y7EUNzh27LQrZqoexpAs31nJi"; + std::string const tokenSecretStr_ = "paQmjZ37pKKPMrgadBLsuf9ab7Y7EUNzh27LQrZqoexpAs31nJi"; - std::vector const tokenBlob = { + std::vector const tokenBlob_ = { " eyJ2YWxpZGF0aW9uX3NlY3JldF9rZXkiOiI5ZWQ0NWY4NjYyNDFjYzE4YTI3NDdiNT\n", " \tQzODdjMDYyNTkwNzk3MmY0ZTcxOTAyMzFmYWE5Mzc0NTdmYTlkYWY2IiwibWFuaWZl \n", "\tc3QiOiJKQUFBQUFGeEllMUZ0d21pbXZHdEgyaUNjTUpxQzlnVkZLaWxHZncxL3ZDeE\n", @@ -41,7 +41,7 @@ class ValidatorKeys_test : public beast::unit_test::suite "VUSmEydzBpMjFlcTNNWXl3TFZKWm5GT3I3QzBrdzJBaVR6U0NqSXpkaXRROD0ifQ==\n", }; - std::string const tokenManifest = + std::string const tokenManifest_ = "JAAAAAFxIe1FtwmimvGtH2iCcMJqC9gVFKilGfw1/vCxHXXLplc2GnMhAkE1agqXxBwD" "wDbID6OMSYuM0FDAlpAgNk8SKFn7MO2fdkcwRQIhAOngu9sAKqXYouJ+l2V0W+sAOkVB" "+ZRS6PShlJAfUsXfAiBsVJGesaadOJc/aAZokS1vymGmVrlHPKWX3Yywu6in8HASQKPu" @@ -49,7 +49,7 @@ class ValidatorKeys_test : public beast::unit_test::suite "2AiTzSCjIzditQ8="; // Manifest does not match private key - std::vector const invalidTokenBlob = { + std::vector const invalidTokenBlob_ = { "eyJtYW5pZmVzdCI6IkpBQUFBQVZ4SWUyOVVBdzViZFJudHJ1elVkREk4aDNGV1JWZl\n", "k3SXVIaUlKQUhJd3MxdzZzM01oQWtsa1VXQWR2RnFRVGRlSEpvS1pNY0hlS0RzOExo\n", "b3d3bDlHOEdkVGNJbmFka1l3UkFJZ0h2Q01lQU1aSzlqQnV2aFhlaFRLRzVDQ3BBR1\n", @@ -66,23 +66,24 @@ public: { // We're only using Env for its Journal. That Journal gives better // coverage in unit tests. - test::jtx::Env env{*this, test::jtx::envconfig(), nullptr, beast::severities::kDisabled}; + test::jtx::Env env{*this, test::jtx::envconfig(), nullptr, beast::severities::KDisabled}; beast::Journal const journal{env.app().getJournal("ValidatorKeys_test")}; // Keys/ID when using [validation_seed] SecretKey const seedSecretKey = // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - generateSecretKey(KeyType::secp256k1, *parseBase58(seed)); - PublicKey const seedPublicKey = derivePublicKey(KeyType::secp256k1, seedSecretKey); + generateSecretKey(KeyType::Secp256k1, *parseBase58(seed_)); + PublicKey const seedPublicKey = derivePublicKey(KeyType::Secp256k1, seedSecretKey); NodeID const seedNodeID = calcNodeID(seedPublicKey); // Keys when using [validation_token] - // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const tokenSecretKey = *parseBase58(TokenType::NodePrivate, tokenSecretStr); + auto const tokenSecretKey = + // NOLINTNEXTLINE(bugprone-unchecked-optional-access) + *parseBase58(TokenType::NodePrivate, tokenSecretStr_); - auto const tokenPublicKey = derivePublicKey(KeyType::secp256k1, tokenSecretKey); + auto const tokenPublicKey = derivePublicKey(KeyType::Secp256k1, tokenSecretKey); - auto const m = deserializeManifest(base64_decode(tokenManifest)); + auto const m = deserializeManifest(base64Decode(tokenManifest_)); BEAST_EXPECT(m); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -99,7 +100,7 @@ public: { // validation seed section -> empty manifest and valid seeds Config c; - c.section(SECTION_VALIDATION_SEED).append(seed); + c.section(SECTION_VALIDATION_SEED).append(seed_); ValidatorKeys k{c, journal}; if (BEAST_EXPECT(k.keys); k.keys.has_value()) @@ -126,7 +127,7 @@ public: { // validator token Config c; - c.section(SECTION_VALIDATOR_TOKEN).append(tokenBlob); + c.section(SECTION_VALIDATOR_TOKEN).append(tokenBlob_); ValidatorKeys k{c, journal}; if (BEAST_EXPECT(k.keys); k.keys.has_value()) @@ -135,7 +136,7 @@ public: BEAST_EXPECT(test::equal(k.keys->secretKey, tokenSecretKey)); } BEAST_EXPECT(k.nodeID == tokenNodeID); - BEAST_EXPECT(k.manifest == tokenManifest); + BEAST_EXPECT(k.manifest == tokenManifest_); BEAST_EXPECT(!k.configInvalid()); } { @@ -151,8 +152,8 @@ public: { // Cannot specify both Config c; - c.section(SECTION_VALIDATION_SEED).append(seed); - c.section(SECTION_VALIDATOR_TOKEN).append(tokenBlob); + c.section(SECTION_VALIDATION_SEED).append(seed_); + c.section(SECTION_VALIDATOR_TOKEN).append(tokenBlob_); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); @@ -163,7 +164,7 @@ public: { // Token manifest and private key must match Config c; - c.section(SECTION_VALIDATOR_TOKEN).append(invalidTokenBlob); + c.section(SECTION_VALIDATOR_TOKEN).append(invalidTokenBlob_); ValidatorKeys const k{c, journal}; BEAST_EXPECT(k.configInvalid()); diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index 63c2ca37d8..52ab2e69aa 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -51,7 +51,7 @@ namespace xrpl::test { -class ValidatorList_test : public beast::unit_test::suite +class ValidatorList_test : public beast::unit_test::Suite { private: struct Validator @@ -64,13 +64,13 @@ private: static PublicKey randomNode() { - return derivePublicKey(KeyType::secp256k1, randomSecretKey()); + return derivePublicKey(KeyType::Secp256k1, randomSecretKey()); } static PublicKey randomMasterKey() { - return derivePublicKey(KeyType::ed25519, randomSecretKey()); + return derivePublicKey(KeyType::Ed25519, randomSecretKey()); } static std::string @@ -81,7 +81,7 @@ private: SecretKey const& ssk, int seq) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = seq; st[sfPublicKey] = pk; @@ -89,11 +89,11 @@ private: { st[sfSigningPubKey] = spk; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - sign(st, HashPrefix::manifest, *publicKeyType(spk), ssk); + sign(st, HashPrefix::Manifest, *publicKeyType(spk), ssk); } // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - sign(st, HashPrefix::manifest, *publicKeyType(pk), sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, *publicKeyType(pk), sk, sfMasterSignature); Serializer s; st.add(s); @@ -104,12 +104,12 @@ private: static std::string makeRevocationString(PublicKey const& pk, SecretKey const& sk) { - STObject st(sfGeneric); + STObject st(kSF_GENERIC); st[sfSequence] = std::numeric_limits::max(); st[sfPublicKey] = pk; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - sign(st, HashPrefix::manifest, *publicKeyType(pk), sk, sfMasterSignature); + sign(st, HashPrefix::Manifest, *publicKeyType(pk), sk, sfMasterSignature); Serializer s; st.add(s); @@ -121,12 +121,12 @@ private: randomValidator() { auto const secret = randomSecretKey(); - auto const masterPublic = derivePublicKey(KeyType::ed25519, secret); - auto const signingKeys = randomKeyPair(KeyType::secp256k1); + auto const masterPublic = derivePublicKey(KeyType::Ed25519, secret); + auto const signingKeys = randomKeyPair(KeyType::Secp256k1); return { .masterPublic = masterPublic, .signingPublic = signingKeys.first, - .manifest = base64_encode(makeManifestString( + .manifest = base64Encode(makeManifestString( masterPublic, secret, signingKeys.first, signingKeys.second, 1))}; } @@ -151,13 +151,13 @@ private: data.pop_back(); data += "]}"; - return base64_encode(data); + return base64Encode(data); } static std::string signList(std::string const& blob, std::pair const& keys) { - auto const data = base64_decode(blob); + auto const data = base64Decode(blob); return strHex(sign(keys.first, keys.second, makeSlice(data))); } @@ -179,7 +179,7 @@ private: ListDisposition expectedBest) { BEAST_EXPECT( - result.bestDisposition() > ListDisposition::same_sequence || + result.bestDisposition() > ListDisposition::SameSequence || (result.publisherKey && *result.publisherKey == pubKey)); BEAST_EXPECT(result.bestDisposition() == expectedBest); BEAST_EXPECT(result.worstDisposition() == expectedWorst); @@ -220,16 +220,16 @@ private: { testcase("Config Load"); - jtx::Env env(*this, jtx::envconfig(), nullptr, beast::severities::kDisabled); + jtx::Env env(*this, jtx::envconfig(), nullptr, beast::severities::KDisabled); auto& app = env.app(); std::vector const emptyCfgKeys; std::vector const emptyCfgPublishers; - auto const localSigningKeys = randomKeyPair(KeyType::secp256k1); + auto const localSigningKeys = randomKeyPair(KeyType::Secp256k1); auto const localSigningPublicOuter = localSigningKeys.first; auto const localSigningSecret = localSigningKeys.second; auto const localMasterSecret = randomSecretKey(); - auto const localMasterPublic = derivePublicKey(KeyType::ed25519, localMasterSecret); + auto const localMasterPublic = derivePublicKey(KeyType::Ed25519, localMasterSecret); std::string const cfgManifest(makeManifestString( localMasterPublic, localMasterSecret, localSigningPublicOuter, localSigningSecret, 1)); @@ -450,8 +450,8 @@ private: env.journal); auto const pubRevokedSecret = randomSecretKey(); - auto const pubRevokedPublic = derivePublicKey(KeyType::ed25519, pubRevokedSecret); - auto const pubRevokedSigning = randomKeyPair(KeyType::secp256k1); + auto const pubRevokedPublic = derivePublicKey(KeyType::Ed25519, pubRevokedSecret); + auto const pubRevokedSigning = randomKeyPair(KeyType::Secp256k1); // make this manifest revoked (seq num = max) // -- thus should not be loaded // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -489,8 +489,8 @@ private: env.journal); auto const pubRevokedSecret = randomSecretKey(); - auto const pubRevokedPublic = derivePublicKey(KeyType::ed25519, pubRevokedSecret); - auto const pubRevokedSigning = randomKeyPair(KeyType::secp256k1); + auto const pubRevokedPublic = derivePublicKey(KeyType::Ed25519, pubRevokedSecret); + auto const pubRevokedSigning = randomKeyPair(KeyType::Secp256k1); // make this manifest revoked (seq num = max) // -- thus should not be loaded // NOLINTNEXTLINE(bugprone-unchecked-optional-access) @@ -552,13 +552,13 @@ private: { BEAST_EXPECT(!a.isMember(jss::blob)); BEAST_EXPECT(!a.isMember(jss::signature)); - auto const& blobs_v2 = a[jss::blobs_v2]; - BEAST_EXPECT(blobs_v2.isArray() && blobs_v2.size() == expected.size()); + auto const& blobsV2 = a[jss::blobs_v2]; + BEAST_EXPECT(blobsV2.isArray() && blobsV2.size() == expected.size()); for (unsigned int i = 0; i < expected.size(); ++i) { - BEAST_EXPECT(blobs_v2[i][jss::blob] == expected[i].first); - BEAST_EXPECT(blobs_v2[i][jss::signature] == expected[i].second); + BEAST_EXPECT(blobsV2[i][jss::blob] == expected[i].first); + BEAST_EXPECT(blobsV2[i][jss::signature] == expected[i].second); } } } @@ -591,10 +591,10 @@ private: }; auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); auto const hexPublic = strHex(publisherPublic.begin(), publisherPublic.end()); - auto const pubSigningKeys1 = randomKeyPair(KeyType::secp256k1); - auto const manifest1 = base64_encode(makeManifestString( + auto const pubSigningKeys1 = randomKeyPair(KeyType::Secp256k1); + auto const manifest1 = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys1.first, pubSigningKeys1.second, 1)); std::vector const cfgPublisherKeys({strHex(publisherPublic)}); @@ -603,15 +603,15 @@ private: BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgPublisherKeys)); std::map> const lists = []() { - auto constexpr listSize = 20; - auto constexpr numLists = 9; + auto constexpr kLIST_SIZE = 20; + auto constexpr kNUM_LISTS = 9; std::map> lists; // 1-based to correspond with the individually named blobs below. - for (auto i = 1; i <= numLists; ++i) + for (auto i = 1; i <= kNUM_LISTS; ++i) { auto& list = lists[i]; - list.reserve(listSize); - while (list.size() < listSize) + list.reserve(kLIST_SIZE); + while (list.size() < kLIST_SIZE) list.push_back(randomValidator()); } return lists; @@ -634,8 +634,8 @@ private: trustedKeys->applyLists( manifest1, version, {{expiredblob, expiredSig, {}}, {blob2, sig2, {}}}, siteUri), publisherPublic, - ListDisposition::expired, - ListDisposition::accepted); + ListDisposition::Expired, + ListDisposition::Accepted); expectTrusted(lists.at(2)); @@ -667,8 +667,8 @@ private: trustedKeys->applyLists( manifest1, version2, {{blob7, sig7, {}}, {blob8, sig8, {}}}, siteUri), publisherPublic, - ListDisposition::pending, - ListDisposition::pending); + ListDisposition::Pending, + ListDisposition::Pending); expectUntrusted(lists.at(7)); expectUntrusted(lists.at(8)); @@ -699,8 +699,8 @@ private: trustedKeys->applyLists( manifest1, version, {{blob6a, sig6a, {}}, {blob6, sig6, {}}}, siteUri), publisherPublic, - ListDisposition::pending, - ListDisposition::pending); + ListDisposition::Pending, + ListDisposition::Pending); expectUntrusted(lists.at(6)); expectTrusted(lists.at(2)); @@ -711,8 +711,8 @@ private: trustedKeys->applyLists( manifest1, version, {{blob7, sig7, {}}, {blob6, sig6, {}}}, siteUri), publisherPublic, - ListDisposition::known_sequence, - ListDisposition::known_sequence); + ListDisposition::KnownSequence, + ListDisposition::KnownSequence); expectUntrusted(lists.at(6)); expectUntrusted(lists.at(7)); @@ -722,36 +722,36 @@ private: checkResult( trustedKeys->applyLists("", version, {{blob7, sig7, {}}, {blob6, sig6, {}}}, siteUri), publisherPublic, - ListDisposition::invalid, - ListDisposition::invalid); + ListDisposition::Invalid, + ListDisposition::Invalid); checkResult( trustedKeys->applyLists( - base64_encode("not a manifest"), + base64Encode("not a manifest"), version, {{blob7, sig7, {}}, {blob6, sig6, {}}}, siteUri), publisherPublic, - ListDisposition::invalid, - ListDisposition::invalid); + ListDisposition::Invalid, + ListDisposition::Invalid); // do not use list from untrusted publisher - auto const untrustedManifest = base64_encode(makeManifestString( + auto const untrustedManifest = base64Encode(makeManifestString( randomMasterKey(), publisherSecret, pubSigningKeys1.first, pubSigningKeys1.second, 1)); checkResult( trustedKeys->applyLists(untrustedManifest, version, {{blob2, sig2, {}}}, siteUri), publisherPublic, - ListDisposition::untrusted, - ListDisposition::untrusted); + ListDisposition::Untrusted, + ListDisposition::Untrusted); // do not use list with unhandled version auto const badVersion = 666; checkResult( trustedKeys->applyLists(manifest1, badVersion, {{blob2, sig2, {}}}, siteUri), publisherPublic, - ListDisposition::unsupported_version, - ListDisposition::unsupported_version); + ListDisposition::UnsupportedVersion, + ListDisposition::UnsupportedVersion); // apply list with highest sequence number auto const sequence3 = 3; @@ -761,8 +761,8 @@ private: checkResult( trustedKeys->applyLists(manifest1, version, {{blob3, sig3, {}}}, siteUri), publisherPublic, - ListDisposition::accepted, - ListDisposition::accepted); + ListDisposition::Accepted, + ListDisposition::Accepted); expectUntrusted(lists.at(1)); expectUntrusted(lists.at(2)); @@ -782,13 +782,13 @@ private: trustedKeys->applyLists( manifest1, version, {{blob2, sig2, {}}, {blob3, sig3, {}}}, siteUri), publisherPublic, - ListDisposition::stale, - ListDisposition::same_sequence); + ListDisposition::Stale, + ListDisposition::SameSequence); // apply list with new publisher key updated by manifest. Also send some // old lists along with the old manifest - auto const pubSigningKeys2 = randomKeyPair(KeyType::secp256k1); - auto manifest2 = base64_encode(makeManifestString( + auto const pubSigningKeys2 = randomKeyPair(KeyType::Secp256k1); + auto manifest2 = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys2.first, pubSigningKeys2.second, 2)); auto const sequence4 = 4; @@ -802,8 +802,8 @@ private: {{blob2, sig2, manifest1}, {blob3, sig3, manifest1}, {blob4, sig4, {}}}, siteUri), publisherPublic, - ListDisposition::stale, - ListDisposition::accepted); + ListDisposition::Stale, + ListDisposition::Accepted); expectUntrusted(lists.at(2)); expectUntrusted(lists.at(3)); @@ -822,8 +822,8 @@ private: checkResult( trustedKeys->applyLists(manifest1, version, {{blob5, badSig, {}}}, siteUri), publisherPublic, - ListDisposition::invalid, - ListDisposition::invalid); + ListDisposition::Invalid, + ListDisposition::Invalid); expectUntrusted(lists.at(2)); expectUntrusted(lists.at(3)); @@ -835,8 +835,8 @@ private: trustedKeys->applyLists( manifest1, version, {{blob7, sig7, {}}, {blob8, sig8, {}}}, siteUri), publisherPublic, - ListDisposition::invalid, - ListDisposition::invalid); + ListDisposition::Invalid, + ListDisposition::Invalid); expectTrusted(lists.at(4)); expectUntrusted(lists.at(7)); @@ -880,14 +880,14 @@ private: // already valid Also try reprocessing the pending list with an // explicit manifest // - it is still invalid - auto const sig8_2 = signList(blob8, pubSigningKeys2); + auto const sig82 = signList(blob8, pubSigningKeys2); checkResult( trustedKeys->applyLists( - manifest2, version, {{blob8, sig8, manifest1}, {blob8, sig8_2, {}}}, siteUri), + manifest2, version, {{blob8, sig8, manifest1}, {blob8, sig82, {}}}, siteUri), publisherPublic, - ListDisposition::invalid, - ListDisposition::same_sequence); + ListDisposition::Invalid, + ListDisposition::SameSequence); expectTrusted(lists.at(8)); @@ -895,8 +895,8 @@ private: // do not apply list with revoked publisher key // applied list is removed due to revoked publisher key - auto const signingKeysMax = randomKeyPair(KeyType::secp256k1); - auto maxManifest = base64_encode(makeRevocationString(publisherPublic, publisherSecret)); + auto const signingKeysMax = randomKeyPair(KeyType::Secp256k1); + auto maxManifest = base64Encode(makeRevocationString(publisherPublic, publisherSecret)); auto const sequence9 = 9; auto const blob9 = makeList(lists.at(9), sequence9, validUntil.time_since_epoch().count()); @@ -905,8 +905,8 @@ private: checkResult( trustedKeys->applyLists(maxManifest, version, {{blob9, sig9, {}}}, siteUri), publisherPublic, - ListDisposition::untrusted, - ListDisposition::untrusted); + ListDisposition::Untrusted, + ListDisposition::Untrusted); BEAST_EXPECT(!trustedKeys->trustedPublisher(publisherPublic)); for (auto const& [num, list] : lists) @@ -937,10 +937,10 @@ private: env.journal); auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); auto const hexPublic = strHex(publisherPublic.begin(), publisherPublic.end()); - auto const pubSigningKeys1 = randomKeyPair(KeyType::secp256k1); - auto const manifest = base64_encode(makeManifestString( + auto const pubSigningKeys1 = randomKeyPair(KeyType::Secp256k1); + auto const manifest = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys1.first, pubSigningKeys1.second, 1)); std::vector const cfgPublisherKeys({strHex(publisherPublic)}); @@ -949,10 +949,10 @@ private: BEAST_EXPECT(trustedKeys->load({}, emptyCfgKeys, cfgPublisherKeys)); std::vector const list = []() { - auto constexpr listSize = 20; + auto constexpr kLIST_SIZE = 20; std::vector list; - list.reserve(listSize); - while (list.size() < listSize) + list.reserve(kLIST_SIZE); + while (list.size() < kLIST_SIZE) list.push_back(randomValidator()); return list; }(); @@ -971,7 +971,7 @@ private: BEAST_EXPECT( trustedKeys->applyLists(manifest, 1, {{blob, sig, {}}}, siteUri).bestDisposition() == - ListDisposition::accepted); + ListDisposition::Accepted); { // invalid public key @@ -982,7 +982,7 @@ private: { // unknown public key auto const badSecret = randomSecretKey(); - auto const badPublic = derivePublicKey(KeyType::ed25519, badSecret); + auto const badPublic = derivePublicKey(KeyType::Ed25519, badSecret); auto const hexBad = strHex(badPublic.begin(), badPublic.end()); auto const available = trustedKeys->getAvailable(hexBad, 1); @@ -1040,11 +1040,11 @@ private: { BEAST_EXPECT(!a.isMember(jss::blob)); BEAST_EXPECT(!a.isMember(jss::signature)); - auto const& blobs_v2 = a[jss::blobs_v2]; - BEAST_EXPECT(blobs_v2.isArray() && blobs_v2.size() == 1); + auto const& blobsV2 = a[jss::blobs_v2]; + BEAST_EXPECT(blobsV2.isArray() && blobsV2.size() == 1); - BEAST_EXPECT(blobs_v2[0u][jss::blob] == blob); - BEAST_EXPECT(blobs_v2[0u][jss::signature] == sig); + BEAST_EXPECT(blobsV2[0u][jss::blob] == blob); + BEAST_EXPECT(blobsV2[0u][jss::signature] == sig); } } } @@ -1133,13 +1133,13 @@ private: { // update with manifests auto const masterPrivate = randomSecretKey(); - auto const masterPublic = derivePublicKey(KeyType::ed25519, masterPrivate); + auto const masterPublic = derivePublicKey(KeyType::Ed25519, masterPrivate); std::vector const cfgKeys({toBase58(TokenType::NodePublic, masterPublic)}); BEAST_EXPECT(trustedKeysOuter->load({}, cfgKeys, cfgPublishersOuter)); - auto const signingKeys1 = randomKeyPair(KeyType::secp256k1); + auto const signingKeys1 = randomKeyPair(KeyType::Secp256k1); auto const signingPublic1 = signingKeys1.first; activeValidatorsOuter.emplace(calcNodeID(masterPublic)); @@ -1164,7 +1164,7 @@ private: BEAST_EXPECT( // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - manifestsOuter.applyManifest(std::move(*m1)) == ManifestDisposition::accepted); + manifestsOuter.applyManifest(std::move(*m1)) == ManifestDisposition::Accepted); BEAST_EXPECT(trustedKeysOuter->listed(masterPublic)); BEAST_EXPECT(trustedKeysOuter->trusted(masterPublic)); BEAST_EXPECT(trustedKeysOuter->listed(signingPublic1)); @@ -1172,13 +1172,13 @@ private: // Should only trust the ephemeral signing key // from the newest applied manifest - auto const signingKeys2 = randomKeyPair(KeyType::secp256k1); + auto const signingKeys2 = randomKeyPair(KeyType::Secp256k1); auto const signingPublic2 = signingKeys2.first; auto m2 = deserializeManifest(makeManifestString( masterPublic, masterPrivate, signingPublic2, signingKeys2.second, 2)); BEAST_EXPECT( // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - manifestsOuter.applyManifest(std::move(*m2)) == ManifestDisposition::accepted); + manifestsOuter.applyManifest(std::move(*m2)) == ManifestDisposition::Accepted); BEAST_EXPECT(trustedKeysOuter->listed(masterPublic)); BEAST_EXPECT(trustedKeysOuter->trusted(masterPublic)); BEAST_EXPECT(trustedKeysOuter->listed(signingPublic2)); @@ -1187,15 +1187,15 @@ private: BEAST_EXPECT(!trustedKeysOuter->trusted(signingPublic1)); // Should not trust keys from revoked master public key - auto const signingKeysMax = randomKeyPair(KeyType::secp256k1); + auto const signingKeysMax = randomKeyPair(KeyType::Secp256k1); auto const signingPublicMax = signingKeysMax.first; activeValidatorsOuter.emplace(calcNodeID(signingPublicMax)); - auto mMax = deserializeManifest(makeRevocationString(masterPublic, masterPrivate)); + auto max = deserializeManifest(makeRevocationString(masterPublic, masterPrivate)); // NOLINTBEGIN(bugprone-unchecked-optional-access) - BEAST_EXPECT(mMax->revoked()); + BEAST_EXPECT(max->revoked()); BEAST_EXPECT( - manifestsOuter.applyManifest(std::move(*mMax)) == ManifestDisposition::accepted); + manifestsOuter.applyManifest(std::move(*max)) == ManifestDisposition::Accepted); // NOLINTEND(bugprone-unchecked-optional-access) BEAST_EXPECT(manifestsOuter.getSigningKey(masterPublic) == masterPublic); @@ -1233,7 +1233,7 @@ private: app.config().legacy("database_path"), env.journal); auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); std::vector const cfgPublishers({strHex(publisherPublic)}); std::vector const emptyCfgKeys; @@ -1260,13 +1260,13 @@ private: app.config().legacy("database_path"), env.journal); auto const masterPrivate = randomSecretKey(); - auto const masterPublic = derivePublicKey(KeyType::ed25519, masterPrivate); + auto const masterPublic = derivePublicKey(KeyType::Ed25519, masterPrivate); std::vector const cfgKeys({toBase58(TokenType::NodePublic, masterPublic)}); auto const publisher1Secret = randomSecretKey(); - auto const publisher1Public = derivePublicKey(KeyType::ed25519, publisher1Secret); + auto const publisher1Public = derivePublicKey(KeyType::Ed25519, publisher1Secret); auto const publisher2Secret = randomSecretKey(); - auto const publisher2Public = derivePublicKey(KeyType::ed25519, publisher2Secret); + auto const publisher2Public = derivePublicKey(KeyType::Ed25519, publisher2Secret); std::vector const cfgPublishers( {strHex(publisher1Public), strHex(publisher2Public)}); @@ -1351,9 +1351,9 @@ private: env.journal); std::vector const emptyCfgKeys; - auto const publisherKeys = randomKeyPair(KeyType::secp256k1); - auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); - auto const manifest = base64_encode(makeManifestString( + auto const publisherKeys = randomKeyPair(KeyType::Secp256k1); + auto const pubSigningKeys = randomKeyPair(KeyType::Secp256k1); + auto const manifest = base64Encode(makeManifestString( publisherKeys.first, publisherKeys.second, pubSigningKeys.first, @@ -1377,7 +1377,7 @@ private: auto const sig = signList(blob, pubSigningKeys); BEAST_EXPECT( - ListDisposition::accepted == + ListDisposition::Accepted == trustedKeys->applyLists(manifest, version, {{blob, sig, {}}}, siteUri) .bestDisposition()); @@ -1418,7 +1418,7 @@ private: auto const sig2 = signList(blob2, pubSigningKeys); BEAST_EXPECT( - ListDisposition::accepted == + ListDisposition::Accepted == trustedKeys->applyLists(manifest, version, {{blob2, sig2, {}}}, siteUri) .bestDisposition()); @@ -1545,10 +1545,10 @@ private: // locals[0]: from 0 to maxKeys - 4 // locals[1]: from 1 to maxKeys - 2 // locals[2]: from 2 to maxKeys - constexpr static int publishers = 3; + constexpr static int kPUBLISHERS = 3; std::array< std::pair, - publishers> + kPUBLISHERS> locals = { std::make_pair(valKeys.cbegin(), valKeys.cend() - 4), std::make_pair(valKeys.cbegin() + 1, valKeys.cend() - 2), @@ -1557,9 +1557,9 @@ private: auto addPublishedList = [&, this](int i) { auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); - auto const manifest = base64_encode(makeManifestString( + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); + auto const pubSigningKeys = randomKeyPair(KeyType::Secp256k1); + auto const manifest = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys.first, @@ -1582,13 +1582,13 @@ private: auto const sig = signList(blob, pubSigningKeys); BEAST_EXPECT( - ListDisposition::accepted == + ListDisposition::Accepted == trustedKeys->applyLists(manifest, version, {{blob, sig, {}}}, siteUri) .bestDisposition()); }; // Apply multiple published lists - for (auto i = 0; i < publishers; ++i) + for (auto i = 0; i < kPUBLISHERS; ++i) addPublishedList(i); BEAST_EXPECT(trustedKeys->getListThreshold() == 1); @@ -1635,10 +1635,10 @@ private: // locals[2]: from 2 to maxKeys // intersection of at least 2: same as locals[1] // intersection when 1 is dropped: from 2 to maxKeys - 4 - constexpr static int publishers = 3; + constexpr static int kPUBLISHERS = 3; std::array< std::pair, - publishers> + kPUBLISHERS> locals = { std::make_pair(valKeys.cbegin(), valKeys.cend() - 4), std::make_pair(valKeys.cbegin() + 1, valKeys.cend() - 2), @@ -1649,9 +1649,9 @@ private: [&, this]( int i, NetClock::time_point& validUntil1, NetClock::time_point& validUntil2) { auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); - auto const manifest = base64_encode(makeManifestString( + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); + auto const pubSigningKeys = randomKeyPair(KeyType::Secp256k1); + auto const manifest = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys.first, @@ -1695,7 +1695,7 @@ private: auto const sig = signList(blob, pubSigningKeys); BEAST_EXPECT( - ListDisposition::accepted == + ListDisposition::Accepted == trustedKeys->applyLists(manifest, version, {{blob, sig, {}}}, siteUri) .bestDisposition()); }; @@ -1703,7 +1703,7 @@ private: // Apply multiple published lists // validUntil1 is expiration time for locals[1] NetClock::time_point validUntil1, validUntil2; - for (auto i = 0; i < publishers; ++i) + for (auto i = 0; i < kPUBLISHERS; ++i) addPublishedList(i, validUntil1, validUntil2); BEAST_EXPECT(trustedKeys->getListThreshold() == 2); @@ -1866,9 +1866,9 @@ private: using namespace std::chrono_literals; auto addPublishedList = [this, &env, &trustedKeys, &validators]() { auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); - auto const manifest = base64_encode(makeManifestString( + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); + auto const pubSigningKeys = randomKeyPair(KeyType::Secp256k1); + auto const manifest = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys.first, @@ -1917,8 +1917,8 @@ private: checkResult( trustedKeys->applyLists(prep1.manifest, prep1.version, prep1.blobs, siteUri), prep1.publisherPublic, - ListDisposition::pending, - ListDisposition::accepted); + ListDisposition::Pending, + ListDisposition::Accepted); // One list still hasn't published, so expiration is still // unknown @@ -1928,8 +1928,8 @@ private: checkResult( trustedKeys->applyLists(prep2.manifest, prep2.version, prep2.blobs, siteUri), prep2.publisherPublic, - ListDisposition::pending, - ListDisposition::accepted); + ListDisposition::Pending, + ListDisposition::Accepted); // We now have loaded both lists, so expiration is known BEAST_EXPECT( trustedKeys->expires() && @@ -2087,10 +2087,10 @@ private: ++it; } validators->setNegativeUNL(nUnl); - auto nUnl_temp = validators->getNegativeUNL(); - if (nUnl_temp.size() == nUnl.size()) + auto nUnlTemp = validators->getNegativeUNL(); + if (nUnlTemp.size() == nUnl.size()) { - for (auto& n : nUnl_temp) + for (auto& n : nUnlTemp) { if (!nUnl.contains(n)) return false; @@ -2548,10 +2548,10 @@ private: jtx::Env env(*this); auto& app = env.app(); - constexpr std::size_t maxKeys = 20; + constexpr std::size_t kMAX_KEYS = 20; hash_set activeValidators; std::vector valKeys; - while (valKeys.size() != maxKeys) + while (valKeys.size() != kMAX_KEYS) { valKeys.push_back(randomValidator()); activeValidators.emplace(calcNodeID(valKeys.back().masterPublic)); @@ -2588,17 +2588,17 @@ private: for (std::size_t i = 0; i < countTotal; ++i) { auto const publisherSecret = randomSecretKey(); - auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - auto const pubSigningKeys = randomKeyPair(KeyType::secp256k1); + auto const publisherPublic = derivePublicKey(KeyType::Ed25519, publisherSecret); + auto const pubSigningKeys = randomKeyPair(KeyType::Secp256k1); cfgPublishers.push_back(strHex(publisherPublic)); - constexpr auto revoked = std::numeric_limits::max(); - auto const manifest = base64_encode(makeManifestString( + constexpr auto kREVOKED = std::numeric_limits::max(); + auto const manifest = base64Encode(makeManifestString( publisherPublic, publisherSecret, pubSigningKeys.first, pubSigningKeys.second, - i < countRevoked ? revoked : 1)); + i < countRevoked ? kREVOKED : 1)); publishers.push_back( Publisher{ .revoked = i < countRevoked, @@ -2612,7 +2612,7 @@ private: auto threshold = listThreshold > 0 ? std::optional(listThreshold) : std::nullopt; if (self) { - valManifests.applyManifest(*deserializeManifest(base64_decode(self->manifest))); + valManifests.applyManifest(*deserializeManifest(base64Decode(self->manifest))); BEAST_EXPECT( result->load(self->signingPublic, emptyCfgKeys, cfgPublishers, threshold)); } @@ -2632,15 +2632,15 @@ private: BEAST_EXPECT( result->applyLists(publishers[i].manifest, 1, {{blob, sig, {}}}, siteUri) .bestDisposition() == - (publishers[i].revoked ? ListDisposition::untrusted - : ListDisposition::accepted)); + (publishers[i].revoked ? ListDisposition::Untrusted + : ListDisposition::Accepted)); } return result; }; // Test cases use 5 publishers. - constexpr auto quorumDisabled = std::numeric_limits::max(); + constexpr auto kQUORUM_DISABLED = std::numeric_limits::max(); { // List threshold = 5 (same as number of trusted publishers) ManifestCache pubManifests; @@ -2688,7 +2688,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -2746,7 +2746,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty()); hash_set removed; @@ -2811,7 +2811,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -2881,7 +2881,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -2947,7 +2947,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3014,7 +3014,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty()); hash_set removed; @@ -3080,7 +3080,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); BEAST_EXPECT(trustedKeys->trusted(self.masterPublic)); @@ -3139,7 +3139,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); BEAST_EXPECT(trustedKeys->trusted(self.masterPublic)); @@ -3197,7 +3197,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); BEAST_EXPECT(trustedKeys->trusted(self.masterPublic)); @@ -3253,7 +3253,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); for (auto const& val : valKeys) @@ -3298,7 +3298,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); hash_set added; @@ -3319,7 +3319,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3365,7 +3365,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); hash_set added; @@ -3385,7 +3385,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3432,7 +3432,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == keysTotal); hash_set added; @@ -3452,7 +3452,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty()); hash_set removed; @@ -3512,7 +3512,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3573,7 +3573,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3634,7 +3634,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty()); hash_set removed; @@ -3696,7 +3696,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3843,7 +3843,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; @@ -3911,7 +3911,7 @@ private: env.app().getOPs(), env.app().getOverlay(), env.app().getHashRouter()); - BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled); + BEAST_EXPECT(trustedKeys->quorum() == kQUORUM_DISABLED); BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 1); hash_set removed; diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index f652689b2b..4145b4f8b1 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -45,12 +45,12 @@ realValidatorContents() )vl"; } -auto constexpr default_expires = std::chrono::seconds{3600}; -auto constexpr default_effective_overlap = std::chrono::seconds{30}; +auto constexpr kDEFAULT_EXPIRES = std::chrono::seconds{3600}; +auto constexpr kDEFAULT_EFFECTIVE_OVERLAP = std::chrono::seconds{30}; } // namespace detail namespace test { -class ValidatorSite_test : public beast::unit_test::suite +class ValidatorSite_test : public beast::unit_test::Suite { private: using Validator = TrustedPublisherServer::Validator; @@ -62,7 +62,7 @@ private: using namespace jtx; - Env env(*this, envconfig(), nullptr, beast::severities::kDisabled); + Env env(*this, envconfig(), nullptr, beast::severities::KDisabled); auto trustedSites = std::make_unique(env.app(), env.journal); // load should accept empty sites list @@ -129,8 +129,8 @@ private: bool failFetch = false; bool failApply = false; int serverVersion = 1; - std::chrono::seconds expiresFromNow = detail::default_expires; - std::chrono::seconds effectiveOverlap = detail::default_effective_overlap; + std::chrono::seconds expiresFromNow = detail::kDEFAULT_EXPIRES; + std::chrono::seconds effectiveOverlap = detail::kDEFAULT_EFFECTIVE_OVERLAP; int expectedRefreshMin = 0; }; void @@ -159,9 +159,9 @@ private: beast::Journal journal{sink}; std::vector const emptyCfgKeys; - struct publisher + struct Publisher { - publisher(FetchListConfig const& c) : cfg{c} + Publisher(FetchListConfig const& c) : cfg{c} { } std::shared_ptr server; @@ -170,9 +170,9 @@ private: FetchListConfig const& cfg; bool isRetry{}; }; - std::vector servers; + std::vector servers; - auto constexpr listSize = 20; + auto constexpr kLIST_SIZE = 20; std::vector cfgPublishers; for (auto const& cfg : paths) @@ -180,14 +180,14 @@ private: servers.emplace_back(cfg); auto& item = servers.back(); item.isRetry = cfg.path == "/bad-resource"; - item.list.reserve(listSize); - while (item.list.size() < listSize) + item.list.reserve(kLIST_SIZE); + while (item.list.size() < kLIST_SIZE) item.list.push_back(TrustedPublisherServer::randomValidator()); NetClock::time_point const expires = env.timeKeeper().now() + cfg.expiresFromNow; NetClock::time_point const effective2 = expires - cfg.effectiveOverlap; NetClock::time_point const expires2 = effective2 + cfg.expiresFromNow; - item.server = make_TrustedPublisherServer( + item.server = makeTrustedPublisherServer( env.app().getIOContext(), item.list, expires, @@ -206,7 +206,7 @@ private: } std::stringstream uri; - uri << (cfg.ssl ? "https://" : "http://") << item.server->local_endpoint() << cfg.path; + uri << (cfg.ssl ? "https://" : "http://") << item.server->localEndpoint() << cfg.path; item.uri = uri.str(); } @@ -236,7 +236,7 @@ private: BEAST_EXPECT(trustedKeys.listed(val.signingPublic) != u.cfg.failApply); } - Json::Value myStatus; + json::Value myStatus; for (auto const& vs : jv[jss::validator_sites]) { if (vs[jss::uri].asString().find(u.uri) != std::string::npos) @@ -288,13 +288,13 @@ private: test::StreamSink sink; beast::Journal journal{sink}; - struct publisher + struct Publisher { std::string uri; std::string expectMsg; bool shouldFail; }; - std::vector servers; + std::vector servers; for (auto const& cfg : paths) { @@ -321,7 +321,7 @@ private: for (auto const& u : servers) { auto const jv = sites->getJson(); - Json::Value myStatus; + json::Value myStatus; for (auto const& vs : jv[jss::validator_sites]) { if (vs[jss::uri].asString().find(u.uri) != std::string::npos) @@ -405,7 +405,7 @@ public: false, false, 1, - detail::default_expires, + detail::kDEFAULT_EXPIRES, std::chrono::seconds{-90}}}); // fetch single site with unending redirect (fails to load) testFetchList( @@ -495,7 +495,7 @@ public: false, true, 1, - std::chrono::seconds{Json::Value::minInt}}}); + std::chrono::seconds{json::Value::kMIN_INT}}}); // force an out-of-range validUntil value on the future list // The first list is accepted. The second fails. The parser // returns the "best" result, so this looks like a success. @@ -507,7 +507,7 @@ public: false, false, 1, - std::chrono::seconds{Json::Value::maxInt - 300}, + std::chrono::seconds{json::Value::kMAX_INT - 300}, 299s}}); // force an out-of-range validFrom value // The first list is accepted. The second fails. The parser @@ -520,7 +520,7 @@ public: false, false, 1, - std::chrono::seconds{Json::Value::maxInt - 300}, + std::chrono::seconds{json::Value::kMAX_INT - 300}, 301s}}); // force an out-of-range validUntil value on _both_ lists testFetchList( @@ -531,8 +531,8 @@ public: false, true, 1, - std::chrono::seconds{Json::Value::minInt}, - std::chrono::seconds{Json::Value::maxInt - 6000}}}); + std::chrono::seconds{json::Value::kMIN_INT}, + std::chrono::seconds{json::Value::kMAX_INT - 6000}}}); // verify refresh intervals are properly clamped testFetchList( good, @@ -542,8 +542,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 1}}); // minimum of 1 minute testFetchList( good, @@ -553,8 +553,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 1}}); // minimum of 1 minute testFetchList( good, @@ -564,8 +564,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 10}}); // 10 minutes is fine testFetchList( good, @@ -575,8 +575,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 10}}); // 10 minutes is fine testFetchList( good, @@ -586,8 +586,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 60 * 24}}); // max of 24 hours testFetchList( good, @@ -597,8 +597,8 @@ public: false, false, 1, - detail::default_expires, - detail::default_effective_overlap, + detail::kDEFAULT_EXPIRES, + detail::kDEFAULT_EFFECTIVE_OVERLAP, 60 * 24}}); // max of 24 hours } using namespace boost::filesystem; diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index 775d579b9b..b0b93e0b3f 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -64,13 +64,13 @@ namespace xrpl { -class Vault_test : public beast::unit_test::suite +class Vault_test : public beast::unit_test::Suite { using PrettyAsset = xrpl::test::jtx::PrettyAsset; using PrettyAmount = xrpl::test::jtx::PrettyAmount; - static auto constexpr negativeAmount = [](PrettyAsset const& asset) -> PrettyAmount { - return {STAmount{asset.raw(), 1ul, 0, true, STAmount::unchecked{}}, ""}; + static auto constexpr kNEGATIVE_AMOUNT = [](PrettyAsset const& asset) -> PrettyAmount { + return {STAmount{asset.raw(), 1ul, 0, true, STAmount::Unchecked{}}, ""}; }; void @@ -134,7 +134,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to deposit more than assets held"); auto tx = vault.deposit( {.depositor = depositor, .id = keylet.key, .amount = asset(10000)}); - env(tx, ter(tecINSUFFICIENT_FUNDS)); + env(tx, Ter(tecINSUFFICIENT_FUNDS)); env.close(); } @@ -159,7 +159,7 @@ class Vault_test : public beast::unit_test::suite { testcase(prefix + " fail to delete non-empty vault"); auto tx = vault.del({.owner = owner, .id = keylet.key}); - env(tx, ter(tecHAS_OBLIGATIONS)); + env(tx, Ter(tecHAS_OBLIGATIONS)); env.close(); } @@ -167,7 +167,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to update because wrong owner"); auto tx = vault.set({.owner = issuer, .id = keylet.key}); tx[sfAssetsMaximum] = asset(50).number(); - env(tx, ter(tecNO_PERMISSION)); + env(tx, Ter(tecNO_PERMISSION)); env.close(); } @@ -175,7 +175,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to set maximum lower than current amount"); auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[sfAssetsMaximum] = asset(50).number(); - env(tx, ter(tecLIMIT_EXCEEDED)); + env(tx, Ter(tecLIMIT_EXCEEDED)); env.close(); } @@ -206,8 +206,8 @@ class Vault_test : public beast::unit_test::suite { testcase(prefix + " fail to set domain on public vault"); auto tx = vault.set({.owner = owner, .id = keylet.key}); - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{tecNO_PERMISSION}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{tecNO_PERMISSION}); env.close(); } @@ -215,7 +215,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to deposit more than maximum"); auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecLIMIT_EXCEEDED)); + env(tx, Ter(tecLIMIT_EXCEEDED)); env.close(); } @@ -231,7 +231,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to withdraw more than assets held"); auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(1000)}); - env(tx, ter(tecINSUFFICIENT_FUNDS)); + env(tx, Ter(tecINSUFFICIENT_FUNDS)); env.close(); } @@ -246,7 +246,7 @@ class Vault_test : public beast::unit_test::suite { testcase(prefix + " clawback some"); - auto code = asset.raw().native() ? ter(temMALFORMED) : ter(tesSUCCESS); + auto code = asset.raw().native() ? Ter(temMALFORMED) : Ter(tesSUCCESS); auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = depositor, .amount = asset(10)}); env(tx, code); @@ -259,7 +259,7 @@ class Vault_test : public beast::unit_test::suite { testcase(prefix + " clawback all"); - auto code = asset.raw().native() ? ter(tecNO_PERMISSION) : ter(tesSUCCESS); + auto code = asset.raw().native() ? Ter(tecNO_PERMISSION) : Ter(tesSUCCESS); auto tx = vault.clawback({.issuer = issuer, .id = keylet.key, .holder = depositor}); env(tx, code); env.close(); @@ -273,14 +273,14 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .holder = depositor, .amount = asset(10)}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); env.close(); } { auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); env.close(); } } @@ -335,7 +335,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); tx[sfDestination] = alice.human(); - env(tx, ter{tecNO_PERMISSION}); + env(tx, Ter{tecNO_PERMISSION}); env.close(); } @@ -344,7 +344,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(1000)}); tx[sfDestination] = "0"; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); env.close(); } @@ -354,7 +354,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); tx[sfDestination] = erin.human(); - env(tx, ter{asset.raw().holds() ? tecNO_LINE : tecNO_AUTH}); + env(tx, Ter{asset.raw().holds() ? tecNO_LINE : tecNO_AUTH}); env.close(); } @@ -363,7 +363,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); tx[sfDestination] = dave.human(); - env(tx, ter{tecDST_TAG_NEEDED}); + env(tx, Ter{tecDST_TAG_NEEDED}); env.close(); } @@ -388,7 +388,7 @@ class Vault_test : public beast::unit_test::suite testcase(prefix + " fail to withdraw lsfRequireDestTag"); auto tx = vault.withdraw({.depositor = dave, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecDST_TAG_NEEDED}); + env(tx, Ter{tecDST_TAG_NEEDED}); env.close(); } @@ -453,14 +453,14 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .holder = depositor, .amount = asset(0)}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); env.close(); } { auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = share(10)}); - env(tx, ter{tecINSUFFICIENT_FUNDS}); + env(tx, Ter{tecINSUFFICIENT_FUNDS}); env.close(); } } @@ -480,7 +480,7 @@ class Vault_test : public beast::unit_test::suite auto tx = pay(erin, depositor, share(10 * scale)); // depositor no longer has MPToken for shares - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); // depositor will gain MPToken for shares again @@ -509,7 +509,7 @@ class Vault_test : public beast::unit_test::suite env.close(); // Erin has MPToken but is no longer authorized to hold assets - env(pay(depositor, erin, share(1)), ter{tecNO_LINE}); + env(pay(depositor, erin, share(1)), Ter{tecNO_LINE}); env.close(); // Depositor withdraws remaining single asset @@ -521,7 +521,7 @@ class Vault_test : public beast::unit_test::suite { testcase(prefix + " fail to delete because wrong owner"); auto tx = vault.del({.owner = issuer, .id = keylet.key}); - env(tx, ter(tecNO_PERMISSION)); + env(tx, Ter(tecNO_PERMISSION)); env.close(); } @@ -536,7 +536,7 @@ class Vault_test : public beast::unit_test::suite auto testCases = [&, this]( std::string prefix, std::function setup) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Vault vault{env}; env.fund(XRP(1000), issuer, owner, depositor, charlie, dave); @@ -545,8 +545,8 @@ class Vault_test : public beast::unit_test::suite env(fset(issuer, asfRequireAuth)); env(fset(dave, asfRequireDest)); env.close(); - env.require(flags(issuer, asfAllowTrustLineClawback)); - env.require(flags(issuer, asfRequireAuth)); + env.require(Flags(issuer, asfAllowTrustLineClawback)); + env.require(Flags(issuer, asfRequireAuth)); PrettyAsset const asset = setup(env); testSequence(prefix, env, vault, asset); @@ -570,7 +570,7 @@ class Vault_test : public beast::unit_test::suite }); testCases("MPT", [&](Env& env) -> Asset { - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); PrettyAsset const asset = mptt.issuanceID(); mptt.authorize({.account = depositor}); @@ -589,7 +589,7 @@ class Vault_test : public beast::unit_test::suite struct CaseArgs { - FeatureBitset features = testable_amendments(); + FeatureBitset features = testableAmendments(); }; auto testCase = [&, this]( @@ -630,42 +630,41 @@ class Vault_test : public beast::unit_test::suite testcase("disabled single asset vault"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter{temDISABLED}); + env(tx, Ter{temDISABLED}); { auto tx = vault.set({.owner = owner, .id = keylet.key}); - env(tx, data("test"), ter{resultAfterCreate}); + env(tx, kDATA("test"), Ter{resultAfterCreate}); } { auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{resultAfterCreate}); + env(tx, Ter{resultAfterCreate}); } { auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{resultAfterCreate}); + env(tx, Ter{resultAfterCreate}); } { auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = owner, .amount = asset(10)}); - env(tx, ter{resultAfterCreate}); + env(tx, Ter{resultAfterCreate}); } { auto tx = vault.del({.owner = owner, .id = keylet.key}); - env(tx, ter{resultAfterCreate}); + env(tx, Ter{resultAfterCreate}); } }; }; - testCase(testDisabled(), {.features = testable_amendments() - featureSingleAssetVault}); + testCase(testDisabled(), {.features = testableAmendments() - featureSingleAssetVault}); - testCase( - testDisabled(tecNO_ENTRY), {.features = testable_amendments() - featureMPTokensV1}); + testCase(testDisabled(tecNO_ENTRY), {.features = testableAmendments() - featureMPTokensV1}); testCase( [&](Env& env, @@ -679,18 +678,18 @@ class Vault_test : public beast::unit_test::suite env(tx); tx[sfFlags] = tx[sfFlags].asUInt() | tfVaultPrivate; - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{temDISABLED}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{temDISABLED}); { auto tx = vault.set({.owner = owner, .id = keylet.key}); - env(tx, data("Test")); + env(tx, kDATA("Test")); - tx[sfDomainID] = to_string(base_uint<256>(13ul)); - env(tx, ter{temDISABLED}); + tx[sfDomainID] = to_string(BaseUint<256>(13ul)); + env(tx, Ter{temDISABLED}); } }, - {.features = testable_amendments() - featurePermissionedDomains}); + {.features = testableAmendments() - featurePermissionedDomains}); testCase([&](Env& env, Account const& issuer, @@ -701,39 +700,39 @@ class Vault_test : public beast::unit_test::suite auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); { auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); } { auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(10)}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); } { auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); } { auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = owner, .amount = asset(10)}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); } { auto tx = vault.del({.owner = owner, .id = keylet.key}); tx[sfFlags] = tfClearDeepFreeze; - env(tx, ter{temINVALID_FLAG}); + env(tx, Ter{temINVALID_FLAG}); } }); @@ -746,39 +745,39 @@ class Vault_test : public beast::unit_test::suite auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); { auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); } { auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(10)}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); } { auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); } { auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = owner, .amount = asset(10)}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); } { auto tx = vault.del({.owner = owner, .id = keylet.key}); tx[jss::Fee] = "-1"; - env(tx, ter{temBAD_FEE}); + env(tx, Ter{temBAD_FEE}); } }); @@ -787,22 +786,22 @@ class Vault_test : public beast::unit_test::suite testcase("disabled permissioned domain"); auto [tx, keylet] = vault.create({.owner = owner, .asset = xrpIssue()}); - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{temDISABLED}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{temDISABLED}); { auto tx = vault.set({.owner = owner, .id = keylet.key}); - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{temDISABLED}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{temDISABLED}); } { auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[sfDomainID] = "0"; - env(tx, ter{temDISABLED}); + env(tx, Ter{temDISABLED}); } }, - {.features = (testable_amendments()) - featurePermissionedDomains}); + {.features = (testableAmendments()) - featurePermissionedDomains}); testCase([&](Env& env, Account const& issuer, @@ -816,35 +815,35 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.set({ .owner = owner, - .id = beast::zero, + .id = beast::kZERO, }); - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } { auto tx = - vault.deposit({.depositor = owner, .id = beast::zero, .amount = asset(10)}); - env(tx, ter(temMALFORMED)); + vault.deposit({.depositor = owner, .id = beast::kZERO, .amount = asset(10)}); + env(tx, Ter(temMALFORMED)); } { auto tx = - vault.withdraw({.depositor = owner, .id = beast::zero, .amount = asset(10)}); - env(tx, ter{temMALFORMED}); + vault.withdraw({.depositor = owner, .id = beast::kZERO, .amount = asset(10)}); + env(tx, Ter{temMALFORMED}); } { auto tx = vault.clawback( - {.issuer = issuer, .id = beast::zero, .holder = owner, .amount = asset(10)}); - env(tx, ter{temMALFORMED}); + {.issuer = issuer, .id = beast::kZERO, .holder = owner, .amount = asset(10)}); + env(tx, Ter{temMALFORMED}); } { auto tx = vault.del({ .owner = owner, - .id = beast::zero, + .id = beast::kZERO, }); - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } }); @@ -858,7 +857,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); tx[jss::Destination] = "0"; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } }); @@ -869,13 +868,13 @@ class Vault_test : public beast::unit_test::suite { auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 255; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 19; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } // accepted range from 0 to 18 @@ -918,27 +917,27 @@ class Vault_test : public beast::unit_test::suite { auto tx = tx1; tx[sfData] = ""; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { auto tx = tx1; // A hexadecimal string of 257 bytes. tx[sfData] = std::string(514, 'A'); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[sfData] = ""; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } { auto tx = vault.set({.owner = owner, .id = keylet.key}); // A hexadecimal string of 257 bytes. tx[sfData] = std::string(514, 'A'); - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } }); @@ -950,7 +949,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.set({.owner = owner, .id = keylet.key}); - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } }); @@ -963,7 +962,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = tx1; tx[sfMPTokenMetadata] = ""; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { @@ -971,7 +970,7 @@ class Vault_test : public beast::unit_test::suite // This metadata is for the share token. // A hexadecimal string of 1025 bytes. tx[sfMPTokenMetadata] = std::string(2050, 'B'); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } }); @@ -983,8 +982,8 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.set({.owner = owner, .id = keylet.key}); - tx[sfAssetsMaximum] = negativeAmount(asset).number(); - env(tx, ter{temMALFORMED}); + tx[sfAssetsMaximum] = kNEGATIVE_AMOUNT(asset).number(); + env(tx, Ter{temMALFORMED}); } }); @@ -996,14 +995,14 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.deposit( - {.depositor = owner, .id = keylet.key, .amount = negativeAmount(asset)}); - env(tx, ter(temBAD_AMOUNT)); + {.depositor = owner, .id = keylet.key, .amount = kNEGATIVE_AMOUNT(asset)}); + env(tx, Ter(temBAD_AMOUNT)); } { auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(0)}); - env(tx, ter(temBAD_AMOUNT)); + env(tx, Ter(temBAD_AMOUNT)); } }); @@ -1016,7 +1015,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.set({.owner = owner, .id = keylet.key}); tx[sfFlags] = tfVaultPrivate; - env(tx, ter(temINVALID_FLAG)); + env(tx, Ter(temINVALID_FLAG)); } }); @@ -1028,14 +1027,14 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.withdraw( - {.depositor = owner, .id = keylet.key, .amount = negativeAmount(asset)}); - env(tx, ter(temBAD_AMOUNT)); + {.depositor = owner, .id = keylet.key, .amount = kNEGATIVE_AMOUNT(asset)}); + env(tx, Ter(temBAD_AMOUNT)); } { auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(0)}); - env(tx, ter(temBAD_AMOUNT)); + env(tx, Ter(temBAD_AMOUNT)); } }); @@ -1053,7 +1052,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = owner, .amount = asset(50)}); - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { @@ -1061,8 +1060,8 @@ class Vault_test : public beast::unit_test::suite {.issuer = issuer, .id = keylet.key, .holder = owner, - .amount = negativeAmount(asset)}); - env(tx, ter(temBAD_AMOUNT)); + .amount = kNEGATIVE_AMOUNT(asset)}); + env(tx, Ter(temBAD_AMOUNT)); } }); @@ -1075,26 +1074,26 @@ class Vault_test : public beast::unit_test::suite { auto tx = tx1; tx[sfWithdrawalPolicy] = 0; - env(tx, ter(temMALFORMED)); + env(tx, Ter(temMALFORMED)); } { auto tx = tx1; - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{temMALFORMED}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{temMALFORMED}); } { auto tx = tx1; - tx[sfAssetsMaximum] = negativeAmount(asset).number(); - env(tx, ter{temMALFORMED}); + tx[sfAssetsMaximum] = kNEGATIVE_AMOUNT(asset).number(); + env(tx, Ter{temMALFORMED}); } { auto tx = tx1; tx[sfFlags] = tfVaultPrivate; tx[sfDomainID] = "0"; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); } }); } @@ -1113,7 +1112,7 @@ class Vault_test : public beast::unit_test::suite Account const& depositor, Asset const& asset, Vault& vault)> test) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -1136,7 +1135,7 @@ class Vault_test : public beast::unit_test::suite testcase("nothing to set"); auto tx = vault.set({.owner = owner, .id = keylet::skip().key}); tx[sfAssetsMaximum] = asset(0).number(); - env(tx, ter(tecNO_ENTRY)); + env(tx, Ter(tecNO_ENTRY)); }); testCase([this]( @@ -1149,7 +1148,7 @@ class Vault_test : public beast::unit_test::suite testcase("nothing to deposit to"); auto tx = vault.deposit( {.depositor = depositor, .id = keylet::skip().key, .amount = asset(10)}); - env(tx, ter(tecNO_ENTRY)); + env(tx, Ter(tecNO_ENTRY)); }); testCase([this]( @@ -1162,7 +1161,7 @@ class Vault_test : public beast::unit_test::suite testcase("nothing to withdraw from"); auto tx = vault.withdraw( {.depositor = depositor, .id = keylet::skip().key, .amount = asset(10)}); - env(tx, ter(tecNO_ENTRY)); + env(tx, Ter(tecNO_ENTRY)); }); testCase([this]( @@ -1174,7 +1173,7 @@ class Vault_test : public beast::unit_test::suite Vault& vault) { testcase("nothing to delete"); auto tx = vault.del({.owner = owner, .id = keylet::skip().key}); - env(tx, ter(tecNO_ENTRY)); + env(tx, Ter(tecNO_ENTRY)); }); testCase([this]( @@ -1211,7 +1210,7 @@ class Vault_test : public beast::unit_test::suite Vault& vault) { auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); testcase("insufficient fee"); - env(tx, fee(env.current()->fees().base - 1), ter(telINSUF_FEE_P)); + env(tx, Fee(env.current()->fees().base - 1), Ter(telINSUF_FEE_P)); }); testCase([this]( @@ -1227,7 +1226,7 @@ class Vault_test : public beast::unit_test::suite // expression for this amount, but it is sadly not easy. env(pay(owner, issuer, XRP(775))); env.close(); - env(tx, ter(tecINSUFFICIENT_RESERVE)); + env(tx, Ter(tecINSUFFICIENT_RESERVE)); }); testCase([this]( @@ -1239,9 +1238,9 @@ class Vault_test : public beast::unit_test::suite Vault& vault) { auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfFlags] = tfVaultPrivate; - tx[sfDomainID] = to_string(base_uint<256>(42ul)); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); testcase("non-existing domain"); - env(tx, ter{tecOBJECT_NOT_FOUND}); + env(tx, Ter{tecOBJECT_NOT_FOUND}); }); testCase([this]( @@ -1254,7 +1253,7 @@ class Vault_test : public beast::unit_test::suite testcase("cannot set Scale=0"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 0; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); }); testCase([this]( @@ -1267,7 +1266,7 @@ class Vault_test : public beast::unit_test::suite testcase("cannot set Scale=1"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 1; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); }); } @@ -1278,7 +1277,7 @@ class Vault_test : public beast::unit_test::suite { { testcase("IOU fail because MPT is disabled"); - Env env{*this, (testable_amendments() - featureMPTokensV1)}; + Env env{*this, (testableAmendments() - featureMPTokensV1)}; Account const issuer{"issuer"}; Account const owner{"owner"}; env.fund(XRP(1000), issuer, owner); @@ -1288,13 +1287,13 @@ class Vault_test : public beast::unit_test::suite Asset const asset = issuer["IOU"].asset(); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(temDISABLED)); + env(tx, Ter(temDISABLED)); env.close(); } { testcase("IOU fail create frozen"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; env.fund(XRP(1000), issuer, owner); @@ -1306,13 +1305,13 @@ class Vault_test : public beast::unit_test::suite Asset const asset = issuer["IOU"].asset(); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tecFROZEN)); + env(tx, Ter(tecFROZEN)); env.close(); } { testcase("IOU fail create no ripling"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; env.fund(XRP(1000), issuer, owner); @@ -1323,13 +1322,13 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; Asset const asset = issuer["IOU"].asset(); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(terNO_RIPPLE)); + env(tx, Ter(terNO_RIPPLE)); env.close(); } { testcase("IOU no issuer"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; env.fund(XRP(1000), owner); @@ -1339,7 +1338,7 @@ class Vault_test : public beast::unit_test::suite Asset const asset = issuer["IOU"].asset(); { auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(terNO_ACCOUNT)); + env(tx, Ter(terNO_ACCOUNT)); env.close(); } } @@ -1347,13 +1346,13 @@ class Vault_test : public beast::unit_test::suite { testcase("IOU fail create vault for AMM LPToken"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const gw("gateway"); Account const alice("alice"); Account const carol("carol"); - IOU const USD = gw["USD"]; + IOU const usd = gw["USD"]; - auto const [asset1, asset2] = std::pair(XRP(10000), USD(10000)); + auto const [asset1, asset2] = std::pair(XRP(10000), usd(10000)); auto toFund = [&](STAmount const& a) -> STAmount { if (a.native()) { @@ -1391,7 +1390,7 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; auto [tx, k] = vault.create({.owner = owner, .asset = ammAlice.lptIssue()}); - env(tx, ter{tecWRONG_ASSET}); + env(tx, Ter{tecWRONG_ASSET}); env.close(); } } @@ -1409,14 +1408,14 @@ class Vault_test : public beast::unit_test::suite Account const& depositor, Asset const& asset, Vault& vault)> test) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; Account const depositor{"depositor"}; env.fund(XRP(1000), issuer, owner, depositor); env.close(); Vault vault{env}; - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; // Locked because that is the default flag. mptt.create(); Asset const asset = mptt.issuanceID(); @@ -1433,7 +1432,7 @@ class Vault_test : public beast::unit_test::suite Vault& vault) { testcase("MPT no authorization"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tecNO_AUTH)); + env(tx, Ter(tecNO_AUTH)); }); testCase([this]( @@ -1446,7 +1445,7 @@ class Vault_test : public beast::unit_test::suite testcase("MPT cannot set Scale=0"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 0; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); }); testCase([this]( @@ -1459,7 +1458,7 @@ class Vault_test : public beast::unit_test::suite testcase("MPT cannot set Scale=1"); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); tx[sfScale] = 1; - env(tx, ter{temMALFORMED}); + env(tx, Ter{temMALFORMED}); }); } @@ -1468,7 +1467,7 @@ class Vault_test : public beast::unit_test::suite { using namespace test::jtx; - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -1512,13 +1511,13 @@ class Vault_test : public beast::unit_test::suite .value(); }(); - auto const MptID = makeMptID(1, vaultAccount); - Asset const shares = MptID; + auto const mptId = makeMptID(1, vaultAccount); + Asset const shares = mptId; { testcase("nontransferable shares cannot be moved"); - env(pay(owner, depositor, shares(10)), ter{tecNO_AUTH}); - env(pay(depositor, owner, shares(10)), ter{tecNO_AUTH}); + env(pay(owner, depositor, shares(10)), Ter{tecNO_AUTH}); + env(pay(depositor, owner, shares(10)), Ter{tecNO_AUTH}); } { @@ -1581,7 +1580,7 @@ class Vault_test : public beast::unit_test::suite Vault& vault, MPTTester& mptt)> test, CaseArgs args = {}) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -1589,12 +1588,12 @@ class Vault_test : public beast::unit_test::suite env.close(); Vault vault{env}; - MPTTester mptt{env, issuer, mptInitNoFund}; - auto const none = LedgerSpecificFlags(0); + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; + auto const kNONE = LedgerSpecificFlags(0); mptt.create( {.flags = tfMPTCanTransfer | tfMPTCanLock | - (args.enableClawback ? tfMPTCanClawback : none) | - (args.requireAuth ? tfMPTRequireAuth : none), + (args.enableClawback ? tfMPTCanClawback : kNONE) | + (args.requireAuth ? tfMPTRequireAuth : kNONE), .mutableFlags = tmfMPTCanMutateCanTransfer}); PrettyAsset const asset = mptt.issuanceID(); mptt.authorize({.account = owner}); @@ -1625,7 +1624,7 @@ class Vault_test : public beast::unit_test::suite .id = keylet::skip().key, .holder = depositor, .amount = asset(10)}); - env(tx, ter(tecNO_ENTRY)); + env(tx, Ter(tecNO_ENTRY)); }); testCase([this]( @@ -1639,7 +1638,7 @@ class Vault_test : public beast::unit_test::suite testcase("MPT global lock blocks create"); mptt.set({.account = issuer, .flags = tfMPTLock}); auto [tx, keylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tecLOCKED)); + env(tx, Ter(tecLOCKED)); }); testCase([this]( @@ -1659,7 +1658,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecLOCKED}); + env(tx, Ter{tecLOCKED}); env.close(); // Can delete empty vault, even if global lock @@ -1697,10 +1696,10 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecLOCKED)); + env(tx, Ter(tecLOCKED)); tx[sfDestination] = issuer.human(); - env(tx, ter(tecLOCKED)); + env(tx, Ter(tecLOCKED)); // Clawback is still permitted, even with global lock tx = vault.clawback( @@ -1741,7 +1740,7 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .holder = depositor, }); - env(tx, ter(tecNO_PERMISSION)); + env(tx, Ter(tecNO_PERMISSION)); } { @@ -1750,7 +1749,7 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .holder = depositor, }); - env(tx, ter(tecNO_PERMISSION)); + env(tx, Ter(tecNO_PERMISSION)); } }); @@ -1785,7 +1784,7 @@ class Vault_test : public beast::unit_test::suite tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); auto const sleMPT2 = env.le(mptoken); @@ -1801,7 +1800,7 @@ class Vault_test : public beast::unit_test::suite tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); tx[sfDestination] = charlie.human(); - env(tx, ter(tecNO_AUTH)); + env(tx, Ter(tecNO_AUTH)); } }, {.requireAuth = true}); @@ -1861,7 +1860,7 @@ class Vault_test : public beast::unit_test::suite tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); tx[sfDestination] = owner.human(); - env(tx, ter(tecNO_AUTH)); + env(tx, Ter(tecNO_AUTH)); env.close(); auto const sleMPT2 = env.le(mptoken); @@ -1871,10 +1870,10 @@ class Vault_test : public beast::unit_test::suite {.requireAuth = false}); auto const [acctReserve, incReserve] = [this]() -> std::pair { - Env const env{*this, testable_amendments()}; + Env const env{*this, testableAmendments()}; return { - env.current()->fees().accountReserve(0).drops() / DROPS_PER_XRP.drops(), - env.current()->fees().increment.drops() / DROPS_PER_XRP.drops()}; + env.current()->fees().accountReserve(0).drops() / kDROPS_PER_XRP.drops(), + env.current()->fees().increment.drops() / kDROPS_PER_XRP.drops()}; }(); testCase( @@ -1920,7 +1919,7 @@ class Vault_test : public beast::unit_test::suite // No reserve to create MPToken for asset in VaultWithdraw tx = vault.withdraw( {.depositor = owner, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecINSUFFICIENT_RESERVE}); + env(tx, Ter{tecINSUFFICIENT_RESERVE}); env.close(); env(pay(depositor, owner, XRP(incReserve))); @@ -1962,25 +1961,25 @@ class Vault_test : public beast::unit_test::suite { auto [tx, keylet] = vault.create({.owner = depositor, .asset = asset}); - env(tx, ter{tecOBJECT_NOT_FOUND}); + env(tx, Ter{tecOBJECT_NOT_FOUND}); } { auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecOBJECT_NOT_FOUND}); + env(tx, Ter{tecOBJECT_NOT_FOUND}); } { auto tx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecOBJECT_NOT_FOUND}); + env(tx, Ter{tecOBJECT_NOT_FOUND}); } { auto tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = depositor, .amount = asset(0)}); - env(tx, ter{tecOBJECT_NOT_FOUND}); + env(tx, Ter{tecOBJECT_NOT_FOUND}); } env(vault.del({.owner = owner, .id = keylet.key})); @@ -2038,7 +2037,7 @@ class Vault_test : public beast::unit_test::suite { // explicitly destroy vault owners MPToken with zero balance - Json::Value jv; + json::Value jv; jv[sfAccount] = owner.human(); jv[sfMPTokenIssuanceID] = to_string(issuanceId); jv[sfFlags] = tfMPTUnauthorize; @@ -2049,7 +2048,7 @@ class Vault_test : public beast::unit_test::suite // owner no longer has MPToken for vault shares tx = pay(depositor, owner, shares(1)); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); // destroy all remaining shares, so we can delete vault @@ -2090,7 +2089,7 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .holder = depositor, .amount = asset(0)}); - env(tx, ter{tecNO_PERMISSION}); + env(tx, Ter{tecNO_PERMISSION}); } }, {.enableClawback = false}); @@ -2117,7 +2116,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = vault.withdraw( {.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecNO_AUTH)); + env(tx, Ter(tecNO_AUTH)); // Withdrawal to other (authorized) accounts works tx[sfDestination] = issuer.human(); @@ -2133,14 +2132,14 @@ class Vault_test : public beast::unit_test::suite // Cannot deposit some more auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecNO_AUTH)); + env(tx, Ter(tecNO_AUTH)); } { // Cannot clawback if issuer is the holder tx = vault.clawback( {.issuer = issuer, .id = keylet.key, .holder = issuer, .amount = asset(800)}); - env(tx, ter(tecNO_PERMISSION)); + env(tx, Ter(tecNO_PERMISSION)); } // Clawback works tx = vault.clawback( @@ -2175,7 +2174,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = [&]() { - Json::Value jv; + json::Value jv; jv[jss::Account] = issuer.human(); jv[sfMPTokenIssuanceID] = to_string(asset.get().getMptID()); jv[jss::Holder] = toBase58(vaultAccount); @@ -2187,10 +2186,10 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecLOCKED)); + env(tx, Ter(tecLOCKED)); tx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter(tecLOCKED)); + env(tx, Ter(tecLOCKED)); // Clawback works, even when locked tx = vault.clawback( @@ -2205,14 +2204,14 @@ class Vault_test : public beast::unit_test::suite { testcase("MPT shares to a vault"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const issuer{"issuer"}; env.fund(XRP(1000000), owner, issuer); env.close(); Vault const vault{env}; - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create( {.flags = tfMPTCanTransfer | tfMPTCanLock | lsfMPTCanClawback | tfMPTRequireAuth}); mptt.authorize({.account = owner}); @@ -2230,7 +2229,7 @@ class Vault_test : public beast::unit_test::suite }(); auto [tx2, k2] = vault.create({.owner = owner, .asset = shares}); - env(tx2, ter{tecWRONG_ASSET}); + env(tx2, Ter{tecWRONG_ASSET}); env.close(); } @@ -2256,12 +2255,12 @@ class Vault_test : public beast::unit_test::suite mptt.set({.mutableFlags = tmfMPTClearCanTransfer}); env.close(); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); tx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); // Restore CanTransfer @@ -2278,35 +2277,35 @@ class Vault_test : public beast::unit_test::suite { testcase("MPT OutstandingAmount > MaximumAmount"); - Env env{*this, testable_amendments() | featureSingleAssetVault}; + Env env{*this, testableAmendments() | featureSingleAssetVault}; Account const alice{"alice"}; Account const issuer{"issuer"}; env.fund(XRP(1'000), alice, issuer); env.close(); Vault const vault{env}; - MPTTester const BTC({.env = env, .issuer = issuer, .holders = {alice}, .maxAmt = 100}); + MPTTester const btc({.env = env, .issuer = issuer, .holders = {alice}, .maxAmt = 100}); - auto [tx, k] = vault.create({.owner = issuer, .asset = BTC}); + auto [tx, k] = vault.create({.owner = issuer, .asset = btc}); env(tx); env.close(); - tx = vault.deposit({.depositor = issuer, .id = k.key, .amount = BTC(110)}); + tx = vault.deposit({.depositor = issuer, .id = k.key, .amount = btc(110)}); // accountHolds is the first check and the issuer has only BTC(100) // available - env(tx, ter{tecINSUFFICIENT_FUNDS}); + env(tx, Ter{tecINSUFFICIENT_FUNDS}); env.close(); // OutstandingAmount == MaximumAmount - env(pay(issuer, alice, BTC(100))); + env(pay(issuer, alice, btc(100))); env.close(); - tx = vault.deposit({.depositor = issuer, .id = k.key, .amount = BTC(100)}); + tx = vault.deposit({.depositor = issuer, .id = k.key, .amount = btc(100)}); // the issuer has BTC(0) available - env(tx, ter{tecINSUFFICIENT_FUNDS}); + env(tx, Ter{tecINSUFFICIENT_FUNDS}); env.close(); - tx = vault.deposit({.depositor = alice, .id = k.key, .amount = BTC(100)}); + tx = vault.deposit({.depositor = alice, .id = k.key, .amount = btc(100)}); // alice transfers BTC(100), OutstandingAmount is 100 env(tx); env.close(); @@ -2337,7 +2336,7 @@ class Vault_test : public beast::unit_test::suite PrettyAsset const& asset, std::function issuanceId)> test, CaseArgs args = {}) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const issuer{"issuer"}; Account const charlie{"charlie"}; @@ -2397,30 +2396,31 @@ class Vault_test : public beast::unit_test::suite { // Cannot create new trustline to a vault auto tx = [&, account = vaultAccount(keylet)]() { - Json::Value jv; + json::Value jv; jv[jss::Account] = issuer.human(); { - auto& ja = jv[jss::LimitAmount] = foo(0).value().getJson(JsonOptions::none); + auto& ja = jv[jss::LimitAmount] = + foo(0).value().getJson(JsonOptions::KNone); ja[jss::issuer] = toBase58(account); } jv[jss::TransactionType] = jss::TrustSet; jv[jss::Flags] = tfSetFreeze; return jv; }(); - env(tx, ter{tecNO_PERMISSION}); + env(tx, Ter{tecNO_PERMISSION}); env.close(); } { auto tx = vault.deposit({.depositor = issuer, .id = keylet.key, .amount = foo(20)}); - env(tx, ter{tecWRONG_ASSET}); + env(tx, Ter{tecWRONG_ASSET}); env.close(); } { auto tx = vault.withdraw({.depositor = issuer, .id = keylet.key, .amount = foo(20)}); - env(tx, ter{tecWRONG_ASSET}); + env(tx, Ter{tecWRONG_ASSET}); env.close(); } @@ -2450,10 +2450,10 @@ class Vault_test : public beast::unit_test::suite // Freeze the trustline to the vault auto trustSet = [&, account = vaultAccount(keylet)]() { - Json::Value jv; + json::Value jv; jv[jss::Account] = issuer.human(); { - auto& ja = jv[jss::LimitAmount] = asset(0).value().getJson(JsonOptions::none); + auto& ja = jv[jss::LimitAmount] = asset(0).value().getJson(JsonOptions::KNone); ja[jss::issuer] = toBase58(account); } jv[jss::TransactionType] = jss::TrustSet; @@ -2470,17 +2470,17 @@ class Vault_test : public beast::unit_test::suite // isFrozen. auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(80)}); - env(tx, ter{tecLOCKED}); + env(tx, Ter{tecLOCKED}); } { auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecLOCKED}); + env(tx, Ter{tecLOCKED}); // also when trying to withdraw to a 3rd party tx[sfDestination] = charlie.human(); - env(tx, ter{tecLOCKED}); + env(tx, Ter{tecLOCKED}); env.close(); } @@ -2599,17 +2599,17 @@ class Vault_test : public beast::unit_test::suite // Cannot withdraw auto const withdraw = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(withdraw, ter{tecFROZEN}); + env(withdraw, Ter{tecFROZEN}); // Cannot withdraw to 3rd party - env(withdrawToCharlie, ter{tecLOCKED}); + env(withdrawToCharlie, Ter{tecLOCKED}); env.close(); { // Cannot deposit some more auto tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecFROZEN}); + env(tx, Ter{tecFROZEN}); } { @@ -2653,7 +2653,7 @@ class Vault_test : public beast::unit_test::suite tx[sfDestination] = erin.human(); return tx; }(keylet); - env(tx1, ter{tecNO_LINE}); + env(tx1, Ter{tecNO_LINE}); }); testCase([&, this]( @@ -2715,7 +2715,7 @@ class Vault_test : public beast::unit_test::suite // Charlie cannot deposit auto tx = vault.deposit( {.depositor = charlie, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{terNO_RIPPLE}); + env(tx, Ter{terNO_RIPPLE}); env.close(); } @@ -2730,12 +2730,12 @@ class Vault_test : public beast::unit_test::suite auto tx2 = vault.withdraw( {.depositor = owner, .id = keylet.key, .amount = shares(100)}); tx2[sfDestination] = charlie.human(); - env(tx2, ter{terNO_RIPPLE}); + env(tx2, Ter{terNO_RIPPLE}); env.close(); { // Create MPToken for shares held by Charlie - Json::Value tx{Json::objectValue}; + json::Value tx{json::ObjectValue}; tx[sfAccount] = charlie.human(); tx[sfMPTokenIssuanceID] = to_string(shares.raw().get().getMptID()); @@ -2749,7 +2749,7 @@ class Vault_test : public beast::unit_test::suite // Charlie cannot withdraw auto tx3 = vault.withdraw( {.depositor = charlie, .id = keylet.key, .amount = shares(100)}); - env(tx3, ter{terNO_RIPPLE}); + env(tx3, Ter{terNO_RIPPLE}); env.close(); env(pay(charlie, owner, shares(100))); @@ -2819,10 +2819,10 @@ class Vault_test : public beast::unit_test::suite { BEAST_EXPECT(env.balance(owner, asset) == startingOwnerBalance.value()); - BEAST_EXPECT(env.balance(vaultAccount(keylet), asset) == beast::zero); + BEAST_EXPECT(env.balance(vaultAccount(keylet), asset) == beast::kZERO); auto const vault = env.le(keylet); - BEAST_EXPECT(vault->at(sfAssetsAvailable) == beast::zero); - BEAST_EXPECT(vault->at(sfAssetsTotal) == beast::zero); + BEAST_EXPECT(vault->at(sfAssetsAvailable) == beast::kZERO); + BEAST_EXPECT(vault->at(sfAssetsTotal) == beast::kZERO); } env(vault.del({.owner = owner, .id = keylet.key})); @@ -2831,10 +2831,10 @@ class Vault_test : public beast::unit_test::suite {.initialIOU = Number(11875, -2)}); auto const [acctReserve, incReserve] = [this]() -> std::pair { - Env const env{*this, testable_amendments()}; + Env const env{*this, testableAmendments()}; return { - env.current()->fees().accountReserve(0).drops() / DROPS_PER_XRP.drops(), - env.current()->fees().increment.drops() / DROPS_PER_XRP.drops()}; + env.current()->fees().accountReserve(0).drops() / kDROPS_PER_XRP.drops(), + env.current()->fees().increment.drops() / kDROPS_PER_XRP.drops()}; }(); testCase( @@ -2868,7 +2868,7 @@ class Vault_test : public beast::unit_test::suite // Fail because not enough reserve to create trust line tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecNO_LINE_INSUF_RESERVE}); + env(tx, Ter{tecNO_LINE_INSUF_RESERVE}); env.close(); env(pay(charlie, owner, XRP(incReserve))); @@ -2903,7 +2903,7 @@ class Vault_test : public beast::unit_test::suite // Fail because not enough reserve to create MPToken for shares tx = vault.deposit({.depositor = charlie, .id = keylet.key, .amount = asset(100)}); - env(tx, ter{tecINSUFFICIENT_RESERVE}); + env(tx, Ter{tecINSUFFICIENT_RESERVE}); env.close(); env(pay(issuer, charlie, XRP(incReserve))); @@ -2953,7 +2953,7 @@ class Vault_test : public beast::unit_test::suite env.close(); // Cannot withdraw to 3rd party - env(withdrawToCharlie, ter{tecFROZEN}); + env(withdrawToCharlie, Ter{tecFROZEN}); env.close(); env(vault.clawback( @@ -2989,17 +2989,17 @@ class Vault_test : public beast::unit_test::suite // Cannot withdraw auto tx = vault.withdraw({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecFROZEN}); + env(tx, Ter{tecFROZEN}); // Cannot withdraw to 3rd party tx[sfDestination] = charlie.human(); - env(tx, ter{tecFROZEN}); + env(tx, Ter{tecFROZEN}); env.close(); // Cannot deposit some more tx = vault.deposit({.depositor = owner, .id = keylet.key, .amount = asset(10)}); - env(tx, ter{tecFROZEN}); + env(tx, Ter{tecFROZEN}); } // Clawback is permitted @@ -3019,7 +3019,7 @@ class Vault_test : public beast::unit_test::suite testcase("private vault"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const issuer{"issuer"}; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -3033,7 +3033,7 @@ class Vault_test : public beast::unit_test::suite env.close(); env(fset(issuer, asfAllowTrustLineClawback)); env.close(); - env.require(flags(issuer, asfAllowTrustLineClawback)); + env.require(Flags(issuer, asfAllowTrustLineClawback)); PrettyAsset const asset = issuer["IOU"]; env.trust(asset(1000), owner); @@ -3059,14 +3059,14 @@ class Vault_test : public beast::unit_test::suite testcase("private vault depositor not authorized yet"); auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); } { testcase("private vault cannot set non-existing domain"); auto tx = vault.set({.owner = owner, .id = keylet.key}); - tx[sfDomainID] = to_string(base_uint<256>(42ul)); - env(tx, ter{tecOBJECT_NOT_FOUND}); + tx[sfDomainID] = to_string(BaseUint<256>(42ul)); + env(tx, Ter{tecOBJECT_NOT_FOUND}); } { @@ -3078,7 +3078,7 @@ class Vault_test : public beast::unit_test::suite env(pdomain::setTx(pdOwner, credentials1)); auto const domainId1 = [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); @@ -3099,7 +3099,7 @@ class Vault_test : public beast::unit_test::suite env(pdomain::setTx(pdOwner, credentials)); auto const domainId = [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); @@ -3120,7 +3120,7 @@ class Vault_test : public beast::unit_test::suite testcase("private vault depositor still not authorized"); auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); } @@ -3141,7 +3141,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = vault.deposit({.depositor = charlie, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); } @@ -3155,7 +3155,7 @@ class Vault_test : public beast::unit_test::suite auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); } @@ -3205,7 +3205,7 @@ class Vault_test : public beast::unit_test::suite auto tx2 = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(1)}); - env(tx2, ter{tecEXPIRED}); + env(tx2, Ter{tecEXPIRED}); env.close(); BEAST_EXPECT(env.le(credsKeylet) == nullptr); @@ -3220,7 +3220,7 @@ class Vault_test : public beast::unit_test::suite auto tx3 = vault.deposit({.depositor = charlie, .id = keylet.key, .amount = asset(2)}); - env(tx3, ter{tecEXPIRED}); + env(tx3, Ter{tecEXPIRED}); env.close(); BEAST_EXPECT(env.le(credsKeylet) == nullptr); @@ -3236,7 +3236,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); env.close(); tx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); @@ -3261,13 +3261,13 @@ class Vault_test : public beast::unit_test::suite } void - testWithDomainCheckXRP() + testWithDomainChecXRP() { using namespace test::jtx; testcase("private XRP vault"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const depositor{"depositor"}; Account const alice{"charlie"}; @@ -3300,14 +3300,14 @@ class Vault_test : public beast::unit_test::suite { testcase("private XRP vault cannot pay shares to depositor yet"); - env(pay(owner, depositor, shares(1)), ter{tecNO_AUTH}); + env(pay(owner, depositor, shares(1)), Ter{tecNO_AUTH}); } { testcase("private XRP vault depositor not authorized yet"); auto tx = vault.deposit({.depositor = depositor, .id = keylet.key, .amount = asset(50)}); - env(tx, ter{tecNO_AUTH}); + env(tx, Ter{tecNO_AUTH}); } { @@ -3316,7 +3316,7 @@ class Vault_test : public beast::unit_test::suite env(pdomain::setTx(owner, credentials)); auto const domainId = [&]() { - auto tx = env.tx()->getJson(JsonOptions::none); + auto tx = env.tx()->getJson(JsonOptions::KNone); return pdomain::getNewDomain(env.meta()); }(); @@ -3347,14 +3347,14 @@ class Vault_test : public beast::unit_test::suite { testcase("private XRP vault cannot pay shares to 3rd party"); - Json::Value jv; + json::Value jv; jv[sfAccount] = alice.human(); jv[sfTransactionType] = jss::MPTokenAuthorize; jv[sfMPTokenIssuanceID] = to_string(issuanceId); env(jv); env.close(); - env(pay(owner, alice, shares(1)), ter{tecNO_AUTH}); + env(pay(owner, alice, shares(1)), Ter{tecNO_AUTH}); } } @@ -3364,7 +3364,7 @@ class Vault_test : public beast::unit_test::suite using namespace test::jtx; testcase("fail pseudo-account allocation"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Vault const vault{env}; env.fund(XRP(1000), owner); @@ -3375,14 +3375,14 @@ class Vault_test : public beast::unit_test::suite AccountID const accountId = xrpl::pseudoAccountAddress(*env.current(), keylet.key); env(pay(env.master.id(), accountId, XRP(1000)), - seq(autofill), - fee(autofill), - sig(autofill)); + Seq(kAUTOFILL), + Fee(kAUTOFILL), + Sig(kAUTOFILL)); } auto [tx, keylet1] = vault.create({.owner = owner, .asset = xrpIssue()}); BEAST_EXPECT(keylet.key == keylet1.key); - env(tx, ter{terADDRESS_COLLISION}); + env(tx, Ter{terADDRESS_COLLISION}); } void @@ -3407,7 +3407,7 @@ class Vault_test : public beast::unit_test::suite auto testCase = [&, this]( std::uint8_t scale, std::function test) { - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const issuer{"issuer"}; Account const depositor{"depositor"}; @@ -3438,7 +3438,7 @@ class Vault_test : public beast::unit_test::suite auto const peek = [keylet, &env, this](std::function fn) -> bool { return env.app().getOpenLedger().modify( [&](OpenView& view, beast::Journal j) -> bool { - Sandbox sb(&view, tapNONE); + Sandbox sb(&view, TapNone); auto vault = sb.peek(keylet::vault(keylet.key)); if (!BEAST_EXPECT(vault)) return false; @@ -3475,7 +3475,7 @@ class Vault_test : public beast::unit_test::suite testcase("Scale deposit overflow on first deposit"); auto tx = d.vault.deposit( {.depositor = d.depositor, .id = d.keylet.key, .amount = d.asset(10)}); - env(tx, ter{tecPATH_DRY}); + env(tx, Ter{tecPATH_DRY}); env.close(); }); @@ -3492,7 +3492,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = d.vault.deposit( {.depositor = d.depositor, .id = d.keylet.key, .amount = d.asset(10)}); - env(tx, ter{tecPATH_DRY}); + env(tx, Ter{tecPATH_DRY}); env.close(); } }); @@ -3510,7 +3510,7 @@ class Vault_test : public beast::unit_test::suite { auto tx = d.vault.deposit( {.depositor = d.depositor, .id = d.keylet.key, .amount = d.asset(5)}); - env(tx, ter{tecPATH_DRY}); + env(tx, Ter{tecPATH_DRY}); env.close(); } }); @@ -3534,7 +3534,7 @@ class Vault_test : public beast::unit_test::suite {.depositor = d.depositor, .id = d.keylet.key, .amount = STAmount(d.asset, Number(9, -2))}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); }); testCase(1, [&, this](Env& env, Data d) { @@ -3717,7 +3717,7 @@ class Vault_test : public beast::unit_test::suite {.depositor = d.depositor, .id = d.keylet.key, .amount = STAmount(d.share, Number(25, 0))}); - env(tx, ter{tecINSUFFICIENT_FUNDS}); + env(tx, Ter{tecINSUFFICIENT_FUNDS}); env.close(); BEAST_EXPECT(env.balance(d.depositor, d.shares) == d.share(900 - 25)); BEAST_EXPECT( @@ -3788,7 +3788,7 @@ class Vault_test : public beast::unit_test::suite {.depositor = d.depositor, .id = d.keylet.key, .amount = STAmount(d.asset, Number(10, 0))}); - env(tx, ter{tecPATH_DRY}); + env(tx, Ter{tecPATH_DRY}); env.close(); } }); @@ -3841,7 +3841,7 @@ class Vault_test : public beast::unit_test::suite {.depositor = d.depositor, .id = d.keylet.key, .amount = STAmount(d.asset, Number(4, -2))}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); } { @@ -3867,7 +3867,7 @@ class Vault_test : public beast::unit_test::suite {.depositor = d.depositor, .id = d.keylet.key, .amount = STAmount(d.asset, Number(25, -1))}); - env(tx, ter{tecINSUFFICIENT_FUNDS}); + env(tx, Ter{tecINSUFFICIENT_FUNDS}); env.close(); BEAST_EXPECT(env.balance(d.depositor, d.shares) == d.share(900 - 25)); BEAST_EXPECT( @@ -3990,7 +3990,7 @@ class Vault_test : public beast::unit_test::suite .id = d.keylet.key, .holder = d.depositor, .amount = STAmount(d.asset, Number(10, 0))}); - env(tx, ter{tecPATH_DRY}); + env(tx, Ter{tecPATH_DRY}); env.close(); } }); @@ -4043,7 +4043,7 @@ class Vault_test : public beast::unit_test::suite .id = d.keylet.key, .holder = d.depositor, .amount = STAmount(d.asset, Number(4, -2))}); - env(tx, ter{tecPRECISION_LOSS}); + env(tx, Ter{tecPRECISION_LOSS}); } { @@ -4197,13 +4197,13 @@ class Vault_test : public beast::unit_test::suite // Borrow 40: assetsAvailable=60, assetsTotal=100 env(set(d.depositor, brokerKeylet.key, STAmount(d.asset, Number(40, 0))), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, d.owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, d.owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { @@ -4219,7 +4219,7 @@ class Vault_test : public beast::unit_test::suite .id = d.keylet.key, .holder = d.depositor, .amount = STAmount(d.asset, Number(80, 0))}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); { @@ -4240,7 +4240,7 @@ class Vault_test : public beast::unit_test::suite using namespace test::jtx; testcase("RPC"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const issuer{"issuer"}; Vault const vault{env}; @@ -4275,58 +4275,59 @@ class Vault_test : public beast::unit_test::suite }(); auto const check = [&, keylet = keylet, sle = sleVault, this]( - Json::Value const& vault, - Json::Value const& issuance = Json::nullValue) { + json::Value const& vault, + json::Value const& issuance = json::NullValue) { BEAST_EXPECT(vault.isObject()); - constexpr auto checkString = + constexpr auto kCHECK_STRING = [](auto& node, SField const& field, std::string v) -> bool { return node.isMember(field.fieldName) && node[field.fieldName].isString() && node[field.fieldName] == v; }; - constexpr auto checkObject = - [](auto& node, SField const& field, Json::Value v) -> bool { + constexpr auto kCHECK_OBJECT = + [](auto& node, SField const& field, json::Value v) -> bool { return node.isMember(field.fieldName) && node[field.fieldName].isObject() && node[field.fieldName] == v; }; - constexpr auto checkInt = [](auto& node, SField const& field, int v) -> bool { + constexpr auto kCHECK_INT = [](auto& node, SField const& field, int v) -> bool { return node.isMember(field.fieldName) && - ((node[field.fieldName].isInt() && node[field.fieldName] == Json::Int(v)) || - (node[field.fieldName].isUInt() && node[field.fieldName] == Json::UInt(v))); + ((node[field.fieldName].isInt() && node[field.fieldName] == json::Int(v)) || + (node[field.fieldName].isUInt() && node[field.fieldName] == json::UInt(v))); }; BEAST_EXPECT(vault["LedgerEntryType"].asString() == "Vault"); BEAST_EXPECT(vault[jss::index].asString() == strHex(keylet.key)); - BEAST_EXPECT(checkInt(vault, sfFlags, 0)); + BEAST_EXPECT(kCHECK_INT(vault, sfFlags, 0)); // Ignore all other standard fields, this test doesn't care - BEAST_EXPECT(checkString(vault, sfAccount, toBase58(sle->at(sfAccount)))); - BEAST_EXPECT(checkObject(vault, sfAsset, to_json(sle->at(sfAsset)))); - BEAST_EXPECT(checkString(vault, sfAssetsAvailable, "50")); - BEAST_EXPECT(checkString(vault, sfAssetsMaximum, "1000")); - BEAST_EXPECT(checkString(vault, sfAssetsTotal, "50")); + BEAST_EXPECT(kCHECK_STRING(vault, sfAccount, toBase58(sle->at(sfAccount)))); + BEAST_EXPECT(kCHECK_OBJECT(vault, sfAsset, toJson(sle->at(sfAsset)))); + BEAST_EXPECT(kCHECK_STRING(vault, sfAssetsAvailable, "50")); + BEAST_EXPECT(kCHECK_STRING(vault, sfAssetsMaximum, "1000")); + BEAST_EXPECT(kCHECK_STRING(vault, sfAssetsTotal, "50")); BEAST_EXPECT(!vault.isMember(sfLossUnrealized.getJsonName())); auto const strShareID = strHex(sle->at(sfShareMPTID)); - BEAST_EXPECT(checkString(vault, sfShareMPTID, strShareID)); - BEAST_EXPECT(checkString(vault, sfOwner, toBase58(owner.id()))); - BEAST_EXPECT(checkInt(vault, sfSequence, sequence)); - BEAST_EXPECT(checkInt(vault, sfWithdrawalPolicy, vaultStrategyFirstComeFirstServe)); + BEAST_EXPECT(kCHECK_STRING(vault, sfShareMPTID, strShareID)); + BEAST_EXPECT(kCHECK_STRING(vault, sfOwner, toBase58(owner.id()))); + BEAST_EXPECT(kCHECK_INT(vault, sfSequence, sequence)); + BEAST_EXPECT( + kCHECK_INT(vault, sfWithdrawalPolicy, kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE)); if (issuance.isObject()) { BEAST_EXPECT(issuance["LedgerEntryType"].asString() == "MPTokenIssuance"); BEAST_EXPECT(issuance[jss::mpt_issuance_id].asString() == strShareID); - BEAST_EXPECT(checkInt(issuance, sfSequence, 1)); - BEAST_EXPECT(checkInt( + BEAST_EXPECT(kCHECK_INT(issuance, sfSequence, 1)); + BEAST_EXPECT(kCHECK_INT( issuance, sfFlags, int(lsfMPTCanEscrow | lsfMPTCanTrade | lsfMPTCanTransfer))); - BEAST_EXPECT(checkString(issuance, sfOutstandingAmount, "50000000")); + BEAST_EXPECT(kCHECK_STRING(issuance, sfOutstandingAmount, "50000000")); } }; { testcase("RPC ledger_entry selected by key"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault] = strHex(keylet.key); auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams)); @@ -4338,7 +4339,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry selected by owner and seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = owner.human(); jvParams[jss::vault][jss::seq] = sequence; @@ -4351,7 +4352,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry cannot find vault by key"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault] = to_string(uint256(42)); auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams)); @@ -4360,7 +4361,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry cannot find vault by owner and seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = issuer.human(); jvParams[jss::vault][jss::seq] = 1'000'000; @@ -4370,7 +4371,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry malformed key"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault] = 42; auto jvVault = env.rpc("json", "ledger_entry", to_string(jvParams)); @@ -4379,7 +4380,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry malformed owner"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = 42; jvParams[jss::vault][jss::seq] = sequence; @@ -4389,7 +4390,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry malformed seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = issuer.human(); jvParams[jss::vault][jss::seq] = "foo"; @@ -4399,7 +4400,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry negative seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = issuer.human(); jvParams[jss::vault][jss::seq] = -1; @@ -4409,7 +4410,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry oversized seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = issuer.human(); jvParams[jss::vault][jss::seq] = 1e20; @@ -4419,7 +4420,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_entry bool seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault][jss::owner] = issuer.human(); jvParams[jss::vault][jss::seq] = true; @@ -4430,7 +4431,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC account_objects"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::account] = owner.human(); jvParams[jss::type] = jss::vault; auto jv = env.rpc("json", "account_objects", to_string(jvParams))[jss::result]; @@ -4442,18 +4443,18 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC ledger_data"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::binary] = false; jvParams[jss::type] = jss::vault; - Json::Value jv = env.rpc("json", "ledger_data", to_string(jvParams)); + json::Value jv = env.rpc("json", "ledger_data", to_string(jvParams)); BEAST_EXPECT(jv[jss::result][jss::state].size() == 1); check(jv[jss::result][jss::state][0u]); } { testcase("RPC vault_info command line"); - Json::Value jv = env.rpc("vault_info", strHex(keylet.key), "validated"); + json::Value jv = env.rpc("vault_info", strHex(keylet.key), "validated"); BEAST_EXPECT(!jv[jss::result].isMember(jss::error)); BEAST_EXPECT(jv[jss::result].isMember(jss::vault)); @@ -4462,7 +4463,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = strHex(keylet.key); auto jv = env.rpc("json", "vault_info", to_string(jvParams)); @@ -4474,7 +4475,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info invalid vault_id"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = "foobar"; auto jv = env.rpc("json", "vault_info", to_string(jvParams)); @@ -4483,7 +4484,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid index"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = 0; auto jv = env.rpc("json", "vault_info", to_string(jvParams)); @@ -4492,7 +4493,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json by owner and sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = sequence; @@ -4505,7 +4506,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json malformed sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = "foobar"; @@ -4515,7 +4516,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = 0; @@ -4525,7 +4526,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json negative sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = -1; @@ -4535,7 +4536,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json oversized sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = 1e20; @@ -4545,7 +4546,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json bool sequence"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); jvParams[jss::seq] = true; @@ -4555,7 +4556,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json malformed owner"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = "foobar"; jvParams[jss::seq] = sequence; @@ -4565,7 +4566,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid combination only owner"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::owner] = owner.human(); auto jv = env.rpc("json", "vault_info", to_string(jvParams)); @@ -4574,7 +4575,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid combination only seq"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::seq] = sequence; auto jv = env.rpc("json", "vault_info", to_string(jvParams)); @@ -4583,7 +4584,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid combination seq vault_id"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = strHex(keylet.key); jvParams[jss::seq] = sequence; @@ -4593,7 +4594,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json invalid combination owner vault_id"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = strHex(keylet.key); jvParams[jss::owner] = owner.human(); @@ -4605,7 +4606,7 @@ class Vault_test : public beast::unit_test::suite testcase( "RPC vault_info json invalid combination owner seq " "vault_id"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; jvParams[jss::vault_id] = strHex(keylet.key); jvParams[jss::seq] = sequence; @@ -4616,7 +4617,7 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info json no input"); - Json::Value jvParams; + json::Value jvParams; jvParams[jss::ledger_index] = jss::validated; auto jv = env.rpc("json", "vault_info", to_string(jvParams)); BEAST_EXPECT(jv[jss::result][jss::error].asString() == "malformedRequest"); @@ -4624,25 +4625,25 @@ class Vault_test : public beast::unit_test::suite { testcase("RPC vault_info command line invalid index"); - Json::Value jv = env.rpc("vault_info", "foobar", "validated"); + json::Value jv = env.rpc("vault_info", "foobar", "validated"); BEAST_EXPECT(jv[jss::error].asString() == "invalidParams"); } { testcase("RPC vault_info command line invalid index"); - Json::Value jv = env.rpc("vault_info", "0", "validated"); + json::Value jv = env.rpc("vault_info", "0", "validated"); BEAST_EXPECT(jv[jss::result][jss::error].asString() == "malformedRequest"); } { testcase("RPC vault_info command line invalid index"); - Json::Value jv = env.rpc("vault_info", strHex(uint256(42)), "validated"); + json::Value jv = env.rpc("vault_info", strHex(uint256(42)), "validated"); BEAST_EXPECT(jv[jss::result][jss::error].asString() == "entryNotFound"); } { testcase("RPC vault_info command line invalid ledger"); - Json::Value jv = env.rpc("vault_info", strHex(keylet.key), "0"); + json::Value jv = env.rpc("vault_info", strHex(keylet.key), "0"); BEAST_EXPECT(jv[jss::result][jss::error].asString() == "lgrNotFound"); } } @@ -4653,7 +4654,7 @@ class Vault_test : public beast::unit_test::suite using namespace test::jtx; using namespace loanBroker; using namespace loan; - Env env(*this, beast::severities::kWarning); + Env env(*this, beast::severities::KWarning); auto const vaultAssetBalance = [&](Keylet const& vaultKeylet) { auto const sleVault = env.le(vaultKeylet); @@ -4678,7 +4679,7 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; auto const& [tx, vaultKeylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); auto const& vaultSle = env.le(vaultKeylet); @@ -4688,7 +4689,7 @@ class Vault_test : public beast::unit_test::suite env(vault.deposit( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); auto const& [availablePreDefault, totalPreDefault] = vaultAssetBalance(vaultKeylet); @@ -4701,7 +4702,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, .amount = share(0).value()}), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); auto const& sharesAvailable = vaultShareBalance(vaultKeylet); @@ -4714,13 +4715,13 @@ class Vault_test : public beast::unit_test::suite // Create a simple Loan for the full amount of Vault assets env(set(depositor, brokerKeylet.key, asset(100).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); // attempt to clawback shares while there assetsAvailable == 0 and @@ -4730,12 +4731,12 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, .amount = share(0).value()}), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); env.close(std::chrono::seconds{120 + 60}); - env(manage(owner, loanKeylet.key, tfLoanDefault), ter(tesSUCCESS)); + env(manage(owner, loanKeylet.key, tfLoanDefault), Ter(tesSUCCESS)); auto const& [availablePostDefault, totalPostDefault] = vaultAssetBalance(vaultKeylet); @@ -4758,10 +4759,10 @@ class Vault_test : public beast::unit_test::suite // empty auto const expectedTer = [&]() { if (asset.native()) - return ter(temMALFORMED); + return Ter(temMALFORMED); if (asset.raw().getIssuer() != owner.id()) - return ter(tecNO_PERMISSION); - return ter(tecPRECISION_LOSS); + return Ter(tecNO_PERMISSION); + return Ter(tecPRECISION_LOSS); }(); env(vault.clawback({ .issuer = owner, @@ -4787,7 +4788,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = share(1).value(), }), - ter(tecLIMIT_EXCEEDED)); + Ter(tecLIMIT_EXCEEDED)); env.close(); } @@ -4802,8 +4803,8 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, }), // when owner is issuer implicit clawback fails - asset.native() || asset.raw().getIssuer() != owner.id() ? ter(tesSUCCESS) - : ter(tecWRONG_ASSET)); + asset.native() || asset.raw().getIssuer() != owner.id() ? Ter(tesSUCCESS) + : Ter(tecWRONG_ASSET)); env.close(); } @@ -4822,7 +4823,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = share(vaultShareBalance(vaultKeylet)).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); } { @@ -4838,7 +4839,7 @@ class Vault_test : public beast::unit_test::suite .holder = owner, .amount = share(vaultShareBalance(vaultKeylet)).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); } @@ -4855,7 +4856,7 @@ class Vault_test : public beast::unit_test::suite .holder = owner, .amount = share(vaultShareBalance(vaultKeylet)).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); // Now the vault is empty, clawback again fails env(vault.clawback({ @@ -4864,7 +4865,7 @@ class Vault_test : public beast::unit_test::suite .holder = owner, .amount = share(vaultShareBalance(vaultKeylet)).value(), }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env.close(); } }; @@ -4882,29 +4883,29 @@ class Vault_test : public beast::unit_test::suite testCase(xrp, "XRP (depositor is owner)", owner, owner); // Test IOU - PrettyAsset const IOU = issuer["IOU"]; + PrettyAsset const iou = issuer["IOU"]; env(fset(issuer, asfAllowTrustLineClawback)); env.close(); - env.trust(IOU(1000), owner); - env.trust(IOU(1000), depositor); - env(pay(issuer, owner, IOU(100))); - env(pay(issuer, depositor, IOU(100))); + env.trust(iou(1000), owner); + env.trust(iou(1000), depositor); + env(pay(issuer, owner, iou(100))); + env(pay(issuer, depositor, iou(100))); env.close(); - testCase(IOU, "IOU", owner, depositor); - testCase(IOU, "IOU (owner is issuer)", issuer, depositor); + testCase(iou, "IOU", owner, depositor); + testCase(iou, "IOU (owner is issuer)", issuer, depositor); // Test MPT - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); - PrettyAsset const MPT = mptt.issuanceID(); + PrettyAsset const mpt = mptt.issuanceID(); mptt.authorize({.account = owner}); mptt.authorize({.account = depositor}); - env(pay(issuer, owner, MPT(1000))); - env(pay(issuer, depositor, MPT(1000))); + env(pay(issuer, owner, mpt(1000))); + env(pay(issuer, depositor, mpt(1000))); env.close(); - testCase(MPT, "MPT", owner, depositor); - testCase(MPT, "MPT (owner is issuer)", issuer, depositor); + testCase(mpt, "MPT", owner, depositor); + testCase(mpt, "MPT (owner is issuer)", issuer, depositor); } void @@ -4923,7 +4924,7 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; auto const& [tx, vaultKeylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); auto const& vaultSle = env.le(vaultKeylet); @@ -4931,7 +4932,7 @@ class Vault_test : public beast::unit_test::suite env.memoize(Account("vault", vaultSle->at(sfAccount))); env(vault.deposit( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); return std::make_pair(vault, vaultKeylet); @@ -4954,14 +4955,14 @@ class Vault_test : public beast::unit_test::suite .holder = issuer, .amount = asset(1).value(), }), - ter(temMALFORMED)); + Ter(temMALFORMED)); // When asset is implicit, clawback fails as no permission. env(vault.clawback({ .issuer = issuer, .id = vaultKeylet.key, .holder = issuer, }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); return; } @@ -4978,7 +4979,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset2(1).value(), }), - ter(tecWRONG_ASSET)); + Ter(tecWRONG_ASSET)); } { @@ -4991,7 +4992,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = issuer, }), - ter(tecWRONG_ASSET)); + Ter(tecWRONG_ASSET)); } { @@ -5003,7 +5004,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); env(vault.clawback({ .issuer = owner, @@ -5011,7 +5012,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(1).value(), }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); } { @@ -5022,7 +5023,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = issuer, }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); } { @@ -5039,7 +5040,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = share(1).value(), }), - ter(tecNO_PERMISSION)); + Ter(tecNO_PERMISSION)); } { @@ -5054,7 +5055,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(1).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); } { @@ -5068,7 +5069,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(100).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); } { @@ -5082,7 +5083,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); } { @@ -5105,13 +5106,13 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows 40 units, reducing assetsAvailable to 60 // while assetsTotal stays at 100 env(set(depositor, brokerKeylet.key, asset(40).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { @@ -5128,7 +5129,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); // Only 60 assets clawed back; loan's 40 still outstanding @@ -5162,13 +5163,13 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows 40 units env(set(depositor, brokerKeylet.key, asset(40).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { @@ -5184,7 +5185,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(100).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5217,13 +5218,13 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows 40 units: assetsAvailable=60, assetsTotal=100 env(set(depositor, brokerKeylet.key, asset(40).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { @@ -5239,7 +5240,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(30).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5271,13 +5272,13 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows 40 units: assetsAvailable=60, assetsTotal=100 env(set(depositor, brokerKeylet.key, asset(40).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); // Clawback exactly 60 — at the boundary, no clamping needed @@ -5287,7 +5288,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(60).value(), }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5319,13 +5320,13 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows all 100 units: assetsAvailable=0, assetsTotal=100 env(set(depositor, brokerKeylet.key, asset(100).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { @@ -5343,7 +5344,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tecPRECISION_LOSS)); + Ter(tecPRECISION_LOSS)); env.close(); // Explicit amount clawback — also nothing available @@ -5353,7 +5354,7 @@ class Vault_test : public beast::unit_test::suite .holder = depositor, .amount = asset(50).value(), }), - ter(tecPRECISION_LOSS)); + Ter(tecPRECISION_LOSS)); env.close(); { @@ -5380,25 +5381,26 @@ class Vault_test : public beast::unit_test::suite testCase(xrp, "XRP", owner, depositor, issuer); // Test IOU - PrettyAsset const IOU = issuer["IOU"]; + PrettyAsset const iou = issuer["IOU"]; env(fset(issuer, asfAllowTrustLineClawback)); env.close(); - env.trust(IOU(2000), owner); - env.trust(IOU(2000), depositor); - env(pay(issuer, owner, IOU(2000))); - env(pay(issuer, depositor, IOU(2000))); + env.trust(iou(2000), owner); + env.trust(iou(2000), depositor); + env(pay(issuer, owner, iou(2000))); + env(pay(issuer, depositor, iou(2000))); env.close(); - testCase(IOU, "IOU", owner, depositor, issuer); + testCase(iou, "IOU", owner, depositor, issuer); // Test MPT - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); - PrettyAsset const MPT = mptt.issuanceID(); + + PrettyAsset const mpt = mptt.issuanceID(); mptt.authorize({.account = owner}); mptt.authorize({.account = depositor}); - env(pay(issuer, depositor, MPT(2000))); + env(pay(issuer, depositor, mpt(2000))); env.close(); - testCase(MPT, "MPT", owner, depositor, issuer); + testCase(mpt, "MPT", owner, depositor, issuer); // Test pre-fixSecurity3_1_3 legacy path: zero-amount clawback // returns early without clamping to assetsAvailable. @@ -5409,7 +5411,7 @@ class Vault_test : public beast::unit_test::suite env.disableFeature(fixSecurity3_1_3); - auto [vault, vaultKeylet] = setupVault(IOU, owner, depositor, issuer); + auto [vault, vaultKeylet] = setupVault(iou, owner, depositor, issuer); auto const vaultSle = env.le(vaultKeylet); BEAST_EXPECT(vaultSle != nullptr); @@ -5425,20 +5427,20 @@ class Vault_test : public beast::unit_test::suite // Depositor borrows 40 units, reducing assetsAvailable to 60 // while assetsTotal stays at 100 - env(set(depositor, brokerKeylet.key, IOU(40).value()), - loan::interestRate(TenthBips32(0)), - gracePeriod(60), - paymentInterval(120), - paymentTotal(10), - sig(sfCounterpartySignature, owner), - fee(env.current()->fees().base * 2), - ter(tesSUCCESS)); + env(set(depositor, brokerKeylet.key, iou(40).value()), + loan::kINTEREST_RATE(TenthBips32(0)), + kGRACE_PERIOD(60), + kPAYMENT_INTERVAL(120), + kPAYMENT_TOTAL(10), + Sig(sfCounterpartySignature, owner), + Fee(env.current()->fees().base * 2), + Ter(tesSUCCESS)); env.close(); { auto const sle = env.le(vaultKeylet); - BEAST_EXPECT(sle->at(sfAssetsAvailable) == IOU(60).value()); - BEAST_EXPECT(sle->at(sfAssetsTotal) == IOU(100).value()); + BEAST_EXPECT(sle->at(sfAssetsAvailable) == iou(60).value()); + BEAST_EXPECT(sle->at(sfAssetsTotal) == iou(100).value()); } auto const sharesBefore = env.balance(depositor, shares); @@ -5452,15 +5454,15 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tefINTERNAL)); + Ter(tefINTERNAL)); env.close(); { // Transaction rolled back — vault and shares unchanged auto const sle = env.le(vaultKeylet); BEAST_EXPECT(sle != nullptr); - BEAST_EXPECT(sle->at(sfAssetsAvailable) == IOU(60).value()); - BEAST_EXPECT(sle->at(sfAssetsTotal) == IOU(100).value()); + BEAST_EXPECT(sle->at(sfAssetsAvailable) == iou(60).value()); + BEAST_EXPECT(sle->at(sfAssetsTotal) == iou(100).value()); auto const sharesAfter = env.balance(depositor, shares); BEAST_EXPECT(sharesAfter == sharesBefore); } @@ -5476,7 +5478,7 @@ class Vault_test : public beast::unit_test::suite using namespace test::jtx; - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; Account const owner{"owner"}; Account const issuer{"issuer"}; @@ -5492,10 +5494,10 @@ class Vault_test : public beast::unit_test::suite static_cast(std::numeric_limits::max()) + 1); BEAST_EXPECT(maxInt64Plus1 == "9223372036854775808"); - auto const initialXRP = to_string(INITIAL_XRP); + auto const initialXRP = to_string(kINITIAL_XRP); BEAST_EXPECT(initialXRP == "100000000000000000"); - auto const initialXRPPlus1 = to_string(INITIAL_XRP + 1); + auto const initialXRPPlus1 = to_string(kINITIAL_XRP + 1); BEAST_EXPECT(initialXRPPlus1 == "100000000000000001"); { @@ -5507,11 +5509,11 @@ class Vault_test : public beast::unit_test::suite tx[sfData] = "4D65746144617461"; tx[sfAssetsMaximum] = maxInt64; - env(tx, ter(tefEXCEPTION)); + env(tx, Ter(tefEXCEPTION)); env.close(); tx[sfAssetsMaximum] = initialXRPPlus1; - env(tx, ter(tefEXCEPTION)); + env(tx, Ter(tefEXCEPTION)); env.close(); tx[sfAssetsMaximum] = initialXRP; @@ -5519,7 +5521,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx[sfAssetsMaximum] = maxInt64Plus1; - env(tx, ter(tefEXCEPTION)); + env(tx, Ter(tefEXCEPTION)); env.close(); // This value will be rounded @@ -5543,7 +5545,7 @@ class Vault_test : public beast::unit_test::suite testcase("Assets Maximum: MPT"); PrettyAsset const mptAsset = [&]() { - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock}); env.close(); PrettyAsset const mptAsset = mptt["MPT"]; @@ -5571,7 +5573,7 @@ class Vault_test : public beast::unit_test::suite env.close(); tx[sfAssetsMaximum] = maxInt64Plus1; - env(tx, ter(tefEXCEPTION)); + env(tx, Ter(tefEXCEPTION)); env.close(); // This value will be rounded @@ -5642,7 +5644,7 @@ class Vault_test : public beast::unit_test::suite BEAST_EXPECT( (vaultSle->at(sfAssetsMaximum) == - Number{9223372036854776, 2, Number::normalized{}})); + Number{9223372036854776, 2, Number::Normalized{}})); } { tx[sfAssetsMaximum] = "9223372036854775807e40"; // max int64 * 10^40 @@ -5656,7 +5658,7 @@ class Vault_test : public beast::unit_test::suite BEAST_EXPECT( (vaultSle->at(sfAssetsMaximum) == - Number{9223372036854776, 43, Number::normalized{}})); + Number{9223372036854776, 43, Number::Normalized{}})); } { tx[sfAssetsMaximum] = "9223372036854775807e-40"; // max int64 * 10^-40 @@ -5670,7 +5672,7 @@ class Vault_test : public beast::unit_test::suite BEAST_EXPECT( (vaultSle->at(sfAssetsMaximum) == - Number{9223372036854776, -37, Number::normalized{}})); + Number{9223372036854776, -37, Number::Normalized{}})); } { tx[sfAssetsMaximum] = "9223372036854775807e-100"; // max int64 * 10^-100 @@ -5683,30 +5685,30 @@ class Vault_test : public beast::unit_test::suite if (!BEAST_EXPECT(vaultSle)) return; - BEAST_EXPECT(vaultSle->at(sfAssetsMaximum) == numZero); + BEAST_EXPECT(vaultSle->at(sfAssetsMaximum) == kNUM_ZERO); } // What _can't_ IOUs do? // 1. Exceed maximum exponent / offset tx[sfAssetsMaximum] = "1000000000000000e81"; - env(tx, ter(tefEXCEPTION)); + env(tx, Ter(tefEXCEPTION)); env.close(); // 2. Mantissa larger than uint64 max - env.set_parse_failure_expected(true); + env.setParseFailureExpected(true); try { tx[sfAssetsMaximum] = "18446744073709551617e5"; // uint64 max + 1 env(tx); BEAST_EXPECTS(false, "Expected parse_error for mantissa larger than uint64 max"); } - catch (parse_error const& e) + catch (ParseError const& e) { using namespace std::string_literals; BEAST_EXPECT( e.what() == "invalidParamsField 'tx_json.AssetsMaximum' has invalid data."s); } - env.set_parse_failure_expected(false); + env.setParseFailureExpected(false); } } @@ -5725,7 +5727,7 @@ class Vault_test : public beast::unit_test::suite { testcase("Vault deposit fails when MPT asset is escrowed"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; auto const baseFee = env.current()->fees().base; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -5735,7 +5737,7 @@ class Vault_test : public beast::unit_test::suite env.fund(XRP(10000), issuer, owner, depositor, bob); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create( {.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock | tfMPTCanEscrow}); mptt.authorize({.account = owner}); @@ -5748,26 +5750,26 @@ class Vault_test : public beast::unit_test::suite // Escrow 60 of 100 MPT tokens: sfMPTAmount drops to 40 auto const escrowSeq = env.seq(depositor); env(escrow::create(depositor, bob, asset(60)), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); Vault const vault{env}; auto [tx, vaultKeylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); // Deposit 100 should fail — only 40 spendable env(vault.deposit( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); env.close(); // Deposit 40 (the unlocked balance) should succeed env(vault.deposit({.depositor = depositor, .id = vaultKeylet.key, .amount = asset(40)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5777,17 +5779,17 @@ class Vault_test : public beast::unit_test::suite // Clean up escrow env(escrow::finish(bob, depositor, escrowSeq), - escrow::condition(escrow::cb1), - escrow::fulfillment(escrow::fb1), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFULFILLMENT(escrow::kFB1), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); } { testcase("Vault withdraw respects escrowed shares"); - Env env{*this, testable_amendments()}; + Env env{*this, testableAmendments()}; auto const baseFee = env.current()->fees().base; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -5797,7 +5799,7 @@ class Vault_test : public beast::unit_test::suite env.fund(XRP(10000), issuer, owner, depositor, bob); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create( {.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock | tfMPTCanEscrow}); mptt.authorize({.account = owner}); @@ -5808,13 +5810,13 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; auto [tx, vaultKeylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); // Deposit 100 → get shares env(vault.deposit( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); auto const vaultSle = env.le(vaultKeylet); @@ -5826,33 +5828,33 @@ class Vault_test : public beast::unit_test::suite // Authorize bob for share MPT so he can receive escrowed shares auto const shareMPTID = vaultSle->at(sfShareMPTID); { - Json::Value jv; + json::Value jv; jv[jss::Account] = bob.human(); jv[sfMPTokenIssuanceID] = to_string(shareMPTID); jv[jss::TransactionType] = jss::MPTokenAuthorize; - env(jv, ter(tesSUCCESS)); + env(jv, Ter(tesSUCCESS)); env.close(); } // Escrow 60% of shares auto const escrowAmount = shares(Number{6, vaultSle->at(sfScale) + 1}); env(escrow::create(depositor, bob, escrowAmount), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // Withdraw all 100 should fail — only 40% of shares are unlocked env(vault.withdraw( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tecINSUFFICIENT_FUNDS)); + Ter(tecINSUFFICIENT_FUNDS)); env.close(); // Withdraw 40 (matching unlocked shares) should succeed env(vault.withdraw( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(40)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5864,7 +5866,7 @@ class Vault_test : public beast::unit_test::suite { testcase("Vault clawback only recovers unlocked shares"); - Env env{*this, testable_amendments() | fixSecurity3_1_3}; + Env env{*this, testableAmendments() | fixSecurity3_1_3}; auto const baseFee = env.current()->fees().base; Account const owner{"owner"}; Account const depositor{"depositor"}; @@ -5874,7 +5876,7 @@ class Vault_test : public beast::unit_test::suite env.fund(XRP(10000), issuer, owner, depositor, bob); env.close(); - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create( {.flags = tfMPTCanClawback | tfMPTCanTransfer | tfMPTCanLock | tfMPTCanEscrow}); mptt.authorize({.account = owner}); @@ -5885,13 +5887,13 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; auto [tx, vaultKeylet] = vault.create({.owner = owner, .asset = asset}); - env(tx, ter(tesSUCCESS)); + env(tx, Ter(tesSUCCESS)); env.close(); // Deposit 100 → get shares env(vault.deposit( {.depositor = depositor, .id = vaultKeylet.key, .amount = asset(100)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); auto const vaultSle = env.le(vaultKeylet); @@ -5903,21 +5905,21 @@ class Vault_test : public beast::unit_test::suite // Authorize bob for share MPT so he can receive escrowed shares auto const shareMPTID = vaultSle->at(sfShareMPTID); { - Json::Value jv; + json::Value jv; jv[jss::Account] = bob.human(); jv[sfMPTokenIssuanceID] = to_string(shareMPTID); jv[jss::TransactionType] = jss::MPTokenAuthorize; - env(jv, ter(tesSUCCESS)); + env(jv, Ter(tesSUCCESS)); env.close(); } // Escrow 60% of shares auto const escrowAmount = shares(Number{6, vaultSle->at(sfScale) + 1}); env(escrow::create(depositor, bob, escrowAmount), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // Zero-amount clawback ("all") — should only recover assets @@ -5927,7 +5929,7 @@ class Vault_test : public beast::unit_test::suite .id = vaultKeylet.key, .holder = depositor, }), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); { @@ -5947,12 +5949,12 @@ class Vault_test : public beast::unit_test::suite // Reproduction: canWithdraw IOU limit check bypassed when // withdrawal amount is specified in shares (MPT) rather than in assets. void - testBug6_LimitBypassWithShares() + testBug6LimitBypassWithShares() { using namespace test::jtx; testcase("Bug6 - limit bypass with share-denominated withdrawal"); - auto const allAmendments = testable_amendments() | featureSingleAssetVault; + auto const allAmendments = testableAmendments() | featureSingleAssetVault; for (auto const& features : {allAmendments, allAmendments - fixSecurity3_1_3}) { @@ -6004,7 +6006,7 @@ class Vault_test : public beast::unit_test::suite auto withdrawTx = vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(10)}); withdrawTx[sfDestination] = charlie.human(); - env(withdrawTx, ter{tecNO_LINE}); + env(withdrawTx, Ter{tecNO_LINE}); env.close(); } auto const charlieBalanceBefore = env.balance(charlie, asset.raw().get()); @@ -6020,7 +6022,7 @@ class Vault_test : public beast::unit_test::suite .id = keylet.key, .amount = STAmount(share, 10'000'000)}); withdrawTx[sfDestination] = charlie.human(); - env(withdrawTx, ter{withFix ? TER{tecNO_LINE} : TER{tesSUCCESS}}); + env(withdrawTx, Ter{withFix ? TER{tecNO_LINE} : TER{tesSUCCESS}}); env.close(); auto const charlieBalanceAfter = env.balance(charlie, asset.raw().get()); @@ -6047,7 +6049,7 @@ class Vault_test : public beast::unit_test::suite using namespace test::jtx; using namespace std::literals; - auto const amendments = testable_amendments(); + auto const amendments = testableAmendments(); auto runTest = [&](FeatureBitset f) { Env env{*this, f}; auto const baseFee = env.current()->fees().base; @@ -6063,7 +6065,7 @@ class Vault_test : public beast::unit_test::suite Vault const vault{env}; // Create an MPT asset for the vault - MPTTester mptt{env, issuer, mptInitNoFund}; + MPTTester mptt{env, issuer, kMPT_INIT_NO_FUND}; mptt.create({.flags = tfMPTCanTransfer | tfMPTCanLock}); PrettyAsset const asset = mptt.issuanceID(); mptt.authorize({.account = owner}); @@ -6094,10 +6096,10 @@ class Vault_test : public beast::unit_test::suite // Escrow 500 of those shares env(escrow::create(depositor, bob, STAmount{shareIssue, 500}), - escrow::condition(escrow::cb1), - escrow::finish_time(env.now() + 1s), - fee(baseFee * 150), - ter(tesSUCCESS)); + escrow::kCONDITION(escrow::kCB1), + escrow::kFINISH_TIME(env.now() + 1s), + Fee(baseFee * 150), + Ter(tesSUCCESS)); env.close(); // Verify: sfMPTAmount=500, sfLockedAmount=500 @@ -6110,7 +6112,7 @@ class Vault_test : public beast::unit_test::suite // Withdraw remaining spendable shares — triggers removeEmptyHolding env(vault.withdraw({.depositor = depositor, .id = keylet.key, .amount = asset(500)}), - ter(tesSUCCESS)); + Ter(tesSUCCESS)); env.close(); auto const sleMptAfter = env.le(keylet::mptoken(shareMptID, depositor)); @@ -6150,7 +6152,7 @@ public: testWithMPT(); testWithIOU(); testWithDomainCheck(); - testWithDomainCheckXRP(); + testWithDomainChecXRP(); testNonTransferableShares(); testFailedPseudoAccount(); testScaleIOU(); @@ -6159,7 +6161,7 @@ public: testVaultClawbackAssets(); testVaultEscrowedMPT(); testAssetsMaximum(); - testBug6_LimitBypassWithShares(); + testBug6LimitBypassWithShares(); testRemoveEmptyHoldingLockedAmount(); } }; diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index c790895921..a8899e4e43 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -62,36 +62,36 @@ namespace xrpl::test { template struct SEnv { - jtx::Env env_; + jtx::Env env; SEnv( T& s, std::unique_ptr config, FeatureBitset features, std::unique_ptr logs = nullptr, - beast::severities::Severity thresh = beast::severities::kError) - : env_(s, std::move(config), features, std::move(logs), thresh) + beast::severities::Severity thresh = beast::severities::KError) + : env(s, std::move(config), features, std::move(logs), thresh) { } SEnv& close() { - env_.close(); + env.close(); return *this; } SEnv& enableFeature(uint256 const feature) { - env_.enableFeature(feature); + env.enableFeature(feature); return *this; } SEnv& disableFeature(uint256 const feature) { - env_.app().config().features.erase(feature); + env.app().config().features.erase(feature); return *this; } @@ -99,7 +99,7 @@ struct SEnv SEnv& fund(STAmount const& amount, Arg const& arg, Args const&... args) { - env_.fund(amount, arg, args...); + env.fund(amount, arg, args...); return *this; } @@ -107,7 +107,7 @@ struct SEnv SEnv& tx(JsonValue&& jv, FN const&... fN) { - env_(std::forward(jv), fN...); + env(std::forward(jv), fN...); return *this; } @@ -116,86 +116,86 @@ struct SEnv multiTx(jtx::JValueVec const& jvv, FN const&... fN) { for (auto const& jv : jvv) - env_(jv, fN...); + env(jv, fN...); return *this; } [[nodiscard]] TER ter() const { - return env_.ter(); + return env.ter(); } [[nodiscard]] STAmount balance(jtx::Account const& account) const { - return env_.balance(account).value(); + return env.balance(account).value(); } [[nodiscard]] STAmount balance(jtx::Account const& account, Issue const& issue) const { - return env_.balance(account, issue).value(); + return env.balance(account, issue).value(); } XRPAmount reserve(std::uint32_t count) { - return env_.current()->fees().accountReserve(count); + return env.current()->fees().accountReserve(count); } XRPAmount txFee() { - return env_.current()->fees().base; + return env.current()->fees().base; } std::shared_ptr account(jtx::Account const& account) { - return env_.le(account); + return env.le(account); } std::shared_ptr - bridge(Json::Value const& jvb) + bridge(json::Value const& jvb) { STXChainBridge const b(jvb); auto tryGet = [&](STXChainBridge::ChainType ct) -> std::shared_ptr { - if (auto r = env_.le(keylet::bridge(b, ct))) + if (auto r = env.le(keylet::bridge(b, ct))) { if ((*r)[sfXChainBridge] == b) return r; } return nullptr; }; - if (auto r = tryGet(STXChainBridge::ChainType::locking)) + if (auto r = tryGet(STXChainBridge::ChainType::Locking)) return r; - return tryGet(STXChainBridge::ChainType::issuing); + return tryGet(STXChainBridge::ChainType::Issuing); } std::uint64_t - claimCount(Json::Value const& jvb) + claimCount(json::Value const& jvb) { return (*bridge(jvb))[sfXChainAccountClaimCount]; } std::uint64_t - claimID(Json::Value const& jvb) + claimID(json::Value const& jvb) { return (*bridge(jvb))[sfXChainClaimID]; } std::shared_ptr - claimID(Json::Value const& jvb, std::uint64_t seq) + claimID(json::Value const& jvb, std::uint64_t seq) { - return env_.le(keylet::xChainClaimID(STXChainBridge(jvb), seq)); + return env.le(keylet::xChainClaimID(STXChainBridge(jvb), seq)); } std::shared_ptr - caClaimID(Json::Value const& jvb, std::uint64_t seq) + caClaimID(json::Value const& jvb, std::uint64_t seq) { - return env_.le(keylet::xChainCreateAccountClaimID(STXChainBridge(jvb), seq)); + return env.le(keylet::xChainCreateAccountClaimID(STXChainBridge(jvb), seq)); } }; @@ -209,29 +209,29 @@ struct XEnv : public jtx::XChainBridgeObjects, public SEnv XEnv(T& s, bool side = false) : SEnv(s, jtx::envconfig(), features) { using namespace jtx; - STAmount const xrp_funds{XRP(10000)}; + STAmount const xrpFunds{XRP(10000)}; if (!side) { - this->fund(xrp_funds, mcDoor, mcAlice, mcBob, mcCarol, mcGw); + this->fund(xrpFunds, mcDoor, mcAlice, mcBob, mcCarol, mcGw); // Signer's list must match the attestation signers // env_(jtx::signers(mcDoor, quorum, signers)); for (auto& s : signers) - this->fund(xrp_funds, s.account); + this->fund(xrpFunds, s.account); } else { - this->fund(xrp_funds, scDoor, scAlice, scBob, scCarol, scGw, scAttester, scReward); + this->fund(xrpFunds, scDoor, scAlice, scBob, scCarol, scGw, scAttester, scReward); for (auto& ra : payees) - this->fund(xrp_funds, ra); + this->fund(xrpFunds, ra); for (auto& s : signers) - this->fund(xrp_funds, s.account); + this->fund(xrpFunds, s.account); // Signer's list must match the attestation signers - // env_(jtx::signers(Account::master, quorum, signers)); + // env_(jtx::signers(Account::kMASTER, quorum, signers)); } this->close(); } @@ -241,19 +241,19 @@ struct XEnv : public jtx::XChainBridgeObjects, public SEnv template struct Balance { - jtx::Account const& account_; - T& env_; + jtx::Account const& account; + T& env; STAmount startAmount; - Balance(T& env, jtx::Account const& account) : account_(account), env_(env) + Balance(T& env, jtx::Account const& account) : account(account), env(env) { - startAmount = env_.balance(account_); + startAmount = env.balance(account); } [[nodiscard]] STAmount diff() const { - return env_.balance(account_) - startAmount; + return env.balance(account) - startAmount; } }; @@ -264,47 +264,47 @@ struct BalanceTransfer { using balance = Balance; - balance from_; - balance to_; - balance payer_; // pays the rewards + balance from; + balance to; + balance payer; // pays the rewards std::vector reward_accounts; // receives the reward - XRPAmount txFees_; + XRPAmount txFees; BalanceTransfer( T& env, - jtx::Account const& from_acct, - jtx::Account const& to_acct, + jtx::Account const& fromAcct, + jtx::Account const& toAcct, jtx::Account const& payer, jtx::Account const* payees, - size_t num_payees, + size_t numPayees, bool withClaim) - : from_(env, from_acct) - , to_(env, to_acct) - , payer_(env, payer) + : from(env, fromAcct) + , to(env, toAcct) + , payer(env, payer) , reward_accounts([&]() { std::vector r; - r.reserve(num_payees); - for (size_t i = 0; i < num_payees; ++i) + r.reserve(numPayees); + for (size_t i = 0; i < numPayees; ++i) r.emplace_back(env, payees[i]); return r; }()) - , txFees_(withClaim ? env.env_.current()->fees().base : XRPAmount(0)) + , txFees(withClaim ? env.env.current()->fees().base : XRPAmount(0)) { } BalanceTransfer( T& env, - jtx::Account const& from_acct, - jtx::Account const& to_acct, + jtx::Account const& fromAcct, + jtx::Account const& toAcct, jtx::Account const& payer, std::vector const& payees, bool withClaim) - : BalanceTransfer(env, from_acct, to_acct, payer, &payees[0], payees.size(), withClaim) + : BalanceTransfer(env, fromAcct, toAcct, payer, &payees[0], payees.size(), withClaim) { } [[nodiscard]] bool - payees_received(STAmount const& reward) const + payeesReceived(STAmount const& reward) const { return std::all_of(reward_accounts.begin(), reward_accounts.end(), [&](balance const& b) { return b.diff() == reward; @@ -312,24 +312,24 @@ struct BalanceTransfer } bool - check_most_balances(STAmount const& amt, STAmount const& reward) + checkMostBalances(STAmount const& amt, STAmount const& reward) { - return from_.diff() == -amt && to_.diff() == amt && payees_received(reward); + return from.diff() == -amt && to.diff() == amt && payeesReceived(reward); } bool - has_happened(STAmount const& amt, STAmount const& reward, bool check_payer = true) + hasHappened(STAmount const& amt, STAmount const& reward, bool checkPayer = true) { - auto reward_cost = multiply(reward, STAmount(reward_accounts.size()), reward.asset()); - return check_most_balances(amt, reward) && - (!check_payer || payer_.diff() == -(reward_cost + txFees_)); + auto rewardCost = multiply(reward, STAmount(reward_accounts.size()), reward.asset()); + return checkMostBalances(amt, reward) && + (!checkPayer || payer.diff() == -(rewardCost + txFees)); } bool - has_not_happened() + hasNotHappened() { - return check_most_balances(STAmount(0), STAmount(0)) && - payer_.diff() <= txFees_; // could have paid fee for failed claim + return checkMostBalances(STAmount(0), STAmount(0)) && + payer.diff() <= txFees; // could have paid fee for failed claim } }; @@ -342,8 +342,8 @@ struct BridgeDef STAmount reward; STAmount minAccountCreate; uint32_t quorum; - std::vector const& signers; - Json::Value jvb; + std::vector const& signers; + json::Value jvb; template void @@ -356,34 +356,34 @@ struct BridgeDef return {}; return minAccountCreate; }(); - mcEnv.tx(bridge_create(doorA, jvb, reward, optAccountCreate)) + mcEnv.tx(bridgeCreate(doorA, jvb, reward, optAccountCreate)) .tx(jtx::signers(doorA, quorum, signers)) .close(); - scEnv.tx(bridge_create(doorB, jvb, reward, optAccountCreate)) + scEnv.tx(bridgeCreate(doorB, jvb, reward, optAccountCreate)) .tx(jtx::signers(doorB, quorum, signers)) .close(); } }; -struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObjects +struct XChain_test : public beast::unit_test::Suite, public jtx::XChainBridgeObjects { XRPAmount reserve(std::uint32_t count) { - return XEnv(*this).env_.current()->fees().accountReserve(count); + return XEnv(*this).env.current()->fees().accountReserve(count); } XRPAmount txFee() { - return XEnv(*this).env_.current()->fees().base; + return XEnv(*this).env.current()->fees().base; } void testXChainBridgeExtraFields() { - auto jBridge = create_bridge(mcDoor)[sfXChainBridge.jsonName]; + auto jBridge = createBridge(mcDoor)[sfXChainBridge.jsonName]; bool exceptionPresent = false; try { @@ -420,38 +420,38 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj testcase("Create Bridge"); // Normal create_bridge => should succeed - XEnv(*this).tx(create_bridge(mcDoor)).close(); + XEnv(*this).tx(createBridge(mcDoor)).close(); // Bridge not owned by one of the door account. - XEnv(*this).tx(create_bridge(mcBob), ter(temXCHAIN_BRIDGE_NONDOOR_OWNER)); + XEnv(*this).tx(createBridge(mcBob), Ter(temXCHAIN_BRIDGE_NONDOOR_OWNER)); // Create twice on the same account - XEnv(*this).tx(create_bridge(mcDoor)).close().tx(create_bridge(mcDoor), ter(tecDUPLICATE)); + XEnv(*this).tx(createBridge(mcDoor)).close().tx(createBridge(mcDoor), Ter(tecDUPLICATE)); // Create USD bridge Alice -> Bob ... should succeed XEnv(*this).tx( - create_bridge(mcAlice, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"])), - ter(tesSUCCESS)); + createBridge(mcAlice, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"])), + Ter(tesSUCCESS)); // Create USD bridge, Alice is both the locking door and locking issue, // ... should fail. XEnv(*this).tx( - create_bridge(mcAlice, bridge(mcAlice, mcAlice["USD"], mcBob, mcBob["USD"])), - ter(temXCHAIN_BRIDGE_BAD_ISSUES)); + createBridge(mcAlice, bridge(mcAlice, mcAlice["USD"], mcBob, mcBob["USD"])), + Ter(temXCHAIN_BRIDGE_BAD_ISSUES)); // Bridge where the two door accounts are equal. XEnv(*this).tx( - create_bridge(mcBob, bridge(mcBob, mcGw["USD"], mcBob, mcGw["USD"])), - ter(temXCHAIN_EQUAL_DOOR_ACCOUNTS)); + createBridge(mcBob, bridge(mcBob, mcGw["USD"], mcBob, mcGw["USD"])), + Ter(temXCHAIN_EQUAL_DOOR_ACCOUNTS)); // Both door accounts are on the same chain. This is not allowed. // Although it doesn't violate any invariants, it's not a useful thing // to do and it complicates the "add claim" transactions. XEnv(*this) - .tx(create_bridge(mcAlice, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"]))) + .tx(createBridge(mcAlice, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"]))) .close() - .tx(create_bridge(mcBob, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"])), - ter(tecDUPLICATE)) + .tx(createBridge(mcBob, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"])), + Ter(tecDUPLICATE)) .close(); // Create a bridge on an account with exactly enough balance to @@ -459,63 +459,62 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv(*this) .fund(res1, mcuDoor) // exact reserve for account + 1 object .close() - .tx(create_bridge(mcuDoor, jvub), ter(tesSUCCESS)); + .tx(createBridge(mcuDoor, jvub), Ter(tesSUCCESS)); // Create a bridge on an account with no enough balance to meet the // new reserve XEnv(*this) .fund(res1 - 1, mcuDoor) // just short of required reserve .close() - .tx(create_bridge(mcuDoor, jvub), ter(tecINSUFFICIENT_RESERVE)); + .tx(createBridge(mcuDoor, jvub), Ter(tecINSUFFICIENT_RESERVE)); // Reward amount is non-xrp XEnv(*this).tx( - create_bridge(mcDoor, jvb, mcUSD(1)), ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); + createBridge(mcDoor, jvb, mcUSD(1)), Ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); // Reward amount is XRP and negative - XEnv(*this).tx( - create_bridge(mcDoor, jvb, XRP(-1)), ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); + XEnv(*this).tx(createBridge(mcDoor, jvb, XRP(-1)), Ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); // Reward amount is 1 xrp => should succeed - XEnv(*this).tx(create_bridge(mcDoor, jvb, XRP(1)), ter(tesSUCCESS)); + XEnv(*this).tx(createBridge(mcDoor, jvb, XRP(1)), Ter(tesSUCCESS)); // Min create amount is 1 xrp, mincreate is 1 xrp => should succeed - XEnv(*this).tx(create_bridge(mcDoor, jvb, XRP(1), XRP(1)), ter(tesSUCCESS)); + XEnv(*this).tx(createBridge(mcDoor, jvb, XRP(1), XRP(1)), Ter(tesSUCCESS)); // Min create amount is non-xrp XEnv(*this).tx( - create_bridge(mcDoor, jvb, XRP(1), mcUSD(100)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + createBridge(mcDoor, jvb, XRP(1), mcUSD(100)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // Min create amount is zero (should fail, currently succeeds) XEnv(*this).tx( - create_bridge(mcDoor, jvb, XRP(1), XRP(0)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + createBridge(mcDoor, jvb, XRP(1), XRP(0)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // Min create amount is negative XEnv(*this).tx( - create_bridge(mcDoor, jvb, XRP(1), XRP(-1)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + createBridge(mcDoor, jvb, XRP(1), XRP(-1)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // coverage test: BridgeCreate::preflight() - create bridge when feature // disabled. { - Env env(*this, testable_amendments() - featureXChainBridge); - env(create_bridge(Account::master, jvb), ter(temDISABLED)); + Env env(*this, testableAmendments() - featureXChainBridge); + env(createBridge(Account::kMASTER, jvb), Ter(temDISABLED)); } // coverage test: BridgeCreate::preclaim() returns tecNO_ISSUER. XEnv(*this).tx( - create_bridge(mcAlice, bridge(mcAlice, mcuAlice["USD"], mcBob, mcBob["USD"])), - ter(tecNO_ISSUER)); + createBridge(mcAlice, bridge(mcAlice, mcuAlice["USD"], mcBob, mcBob["USD"])), + Ter(tecNO_ISSUER)); // coverage test: create_bridge transaction with incorrect flag - XEnv(*this).tx(create_bridge(mcAlice, jvb), txflags(tfFillOrKill), ter(temINVALID_FLAG)); + XEnv(*this).tx(createBridge(mcAlice, jvb), Txflags(tfFillOrKill), Ter(temINVALID_FLAG)); // coverage test: create_bridge transaction with xchain feature disabled XEnv(*this) .disableFeature(featureXChainBridge) - .tx(create_bridge(mcAlice, jvb), ter(temDISABLED)); + .tx(createBridge(mcAlice, jvb), Ter(temDISABLED)); } void @@ -569,17 +568,17 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj using namespace jtx; testcase("Bridge create constraints"); XEnv env(*this, true); - auto& A = scAlice; - auto& B = scBob; - auto& C = scCarol; - auto AUSD = A["USD"]; - auto BUSD = B["USD"]; - auto CUSD = C["USD"]; - auto GUSD = scGw["USD"]; - auto AEUR = A["EUR"]; - auto BEUR = B["EUR"]; - auto CEUR = C["EUR"]; - auto GEUR = scGw["EUR"]; + auto& a = scAlice; + auto& b = scBob; + auto& c = scCarol; + auto ausd = a["USD"]; + auto busd = b["USD"]; + auto cusd = c["USD"]; + auto gusd = scGw["USD"]; + auto aeur = a["EUR"]; + auto beur = b["EUR"]; + auto ceur = c["EUR"]; + auto geur = scGw["EUR"]; // Accounts to own single bridges Account const a1("a1"); @@ -594,51 +593,51 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // Add a bridge on two different accounts with the same locking and // issuing assets - env.tx(create_bridge(a1, bridge(a1, GUSD, B, BUSD))).close(); - env.tx(create_bridge(a2, bridge(a2, GUSD, B, BUSD))).close(); + env.tx(createBridge(a1, bridge(a1, gusd, b, busd))).close(); + env.tx(createBridge(a2, bridge(a2, gusd, b, busd))).close(); // Add the exact same bridge to two different accounts (one locking // account and one issuing) - env.tx(create_bridge(a3, bridge(a3, GUSD, a4, a4["USD"]))).close(); - env.tx(create_bridge(a4, bridge(a3, GUSD, a4, a4["USD"])), ter(tecDUPLICATE)).close(); + env.tx(createBridge(a3, bridge(a3, gusd, a4, a4["USD"]))).close(); + env.tx(createBridge(a4, bridge(a3, gusd, a4, a4["USD"])), Ter(tecDUPLICATE)).close(); // Add the exact same bridge to two different accounts (one issuing // account and one locking - opposite order from the test above) - env.tx(create_bridge(a5, bridge(a6, GUSD, a5, a5["USD"]))).close(); - env.tx(create_bridge(a6, bridge(a6, GUSD, a5, a5["USD"])), ter(tecDUPLICATE)).close(); + env.tx(createBridge(a5, bridge(a6, gusd, a5, a5["USD"]))).close(); + env.tx(createBridge(a6, bridge(a6, gusd, a5, a5["USD"])), Ter(tecDUPLICATE)).close(); // Test case 1 ~ 5, create bridges - auto const goodBridge1 = bridge(A, GUSD, B, BUSD); - auto const goodBridge2 = bridge(A, BUSD, C, CUSD); - env.tx(create_bridge(B, goodBridge1)).close(); + auto const goodBridge1 = bridge(a, gusd, b, busd); + auto const goodBridge2 = bridge(a, busd, c, cusd); + env.tx(createBridge(b, goodBridge1)).close(); // Issuing asset is the same, this is a duplicate - env.tx(create_bridge(B, bridge(A, GEUR, B, BUSD)), ter(tecDUPLICATE)).close(); - env.tx(create_bridge(A, goodBridge2), ter(tesSUCCESS)).close(); + env.tx(createBridge(b, bridge(a, geur, b, busd)), Ter(tecDUPLICATE)).close(); + env.tx(createBridge(a, goodBridge2), Ter(tesSUCCESS)).close(); // Locking asset is the same - this is a duplicate - env.tx(create_bridge(A, bridge(A, BUSD, B, BEUR)), ter(tecDUPLICATE)).close(); + env.tx(createBridge(a, bridge(a, busd, b, beur)), Ter(tecDUPLICATE)).close(); // Locking asset is USD - this is a duplicate even tho it has a // different issuer - env.tx(create_bridge(A, bridge(A, CUSD, B, BEUR)), ter(tecDUPLICATE)).close(); + env.tx(createBridge(a, bridge(a, cusd, b, beur)), Ter(tecDUPLICATE)).close(); // Test case 6 and 7, commits - env.tx(trust(C, BUSD(1000))) - .tx(trust(A, BUSD(1000))) + env.tx(trust(c, busd(1000))) + .tx(trust(a, busd(1000))) .close() - .tx(pay(B, C, BUSD(1000))) + .tx(pay(b, c, busd(1000))) .close(); - auto const aBalanceStart = env.balance(A, BUSD); - auto const cBalanceStart = env.balance(C, BUSD); - env.tx(xchain_commit(C, goodBridge1, 1, BUSD(50))).close(); - BEAST_EXPECT(env.balance(A, BUSD) - aBalanceStart == BUSD(0)); - BEAST_EXPECT(env.balance(C, BUSD) - cBalanceStart == BUSD(-50)); - env.tx(xchain_commit(C, goodBridge2, 1, BUSD(60))).close(); - BEAST_EXPECT(env.balance(A, BUSD) - aBalanceStart == BUSD(60)); - BEAST_EXPECT(env.balance(C, BUSD) - cBalanceStart == BUSD(-50 - 60)); + auto const aBalanceStart = env.balance(a, busd); + auto const cBalanceStart = env.balance(c, busd); + env.tx(xchainCommit(c, goodBridge1, 1, busd(50))).close(); + BEAST_EXPECT(env.balance(a, busd) - aBalanceStart == busd(0)); + BEAST_EXPECT(env.balance(c, busd) - cBalanceStart == busd(-50)); + env.tx(xchainCommit(c, goodBridge2, 1, busd(60))).close(); + BEAST_EXPECT(env.balance(a, busd) - aBalanceStart == busd(60)); + BEAST_EXPECT(env.balance(c, busd) - cBalanceStart == busd(-50 - 60)); // bridge modify test cases - env.tx(bridge_modify(B, goodBridge1, XRP(33), std::nullopt)).close(); + env.tx(bridgeModify(b, goodBridge1, XRP(33), std::nullopt)).close(); BEAST_EXPECT((*env.bridge(goodBridge1))[sfSignatureReward] == XRP(33)); - env.tx(bridge_modify(A, goodBridge2, XRP(44), std::nullopt)).close(); + env.tx(bridgeModify(a, goodBridge2, XRP(44), std::nullopt)).close(); BEAST_EXPECT((*env.bridge(goodBridge2))[sfSignatureReward] == XRP(44)); } @@ -773,11 +772,11 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj "Issuing chain is XRP and issuing chain door account is " "the root account ", [&](auto& env, bool) { - b = Account::master; + b = Account::kMASTER; ib = xrpIssue(); })}; - std::vector> expected_result{ + std::vector> expectedResult{ {temXCHAIN_BRIDGE_BAD_ISSUES, temXCHAIN_BRIDGE_BAD_ISSUES}, {temXCHAIN_BRIDGE_BAD_ISSUES, temXCHAIN_BRIDGE_BAD_ISSUES}, {temXCHAIN_BRIDGE_BAD_ISSUES, temXCHAIN_BRIDGE_BAD_ISSUES}, @@ -821,7 +820,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj {temXCHAIN_BRIDGE_BAD_ISSUES, temXCHAIN_BRIDGE_BAD_ISSUES}, {tesSUCCESS, tesSUCCESS}}; - std::vector> test_result; + std::vector> testResult; auto testcase = [&](auto const& lc, auto const& ic) { XEnv mcEnv(*this); @@ -833,24 +832,24 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj ic.second(mcEnv, false); ic.second(scEnv, true); - auto const& expected = expected_result[test_result.size()]; + auto const& expected = expectedResult[testResult.size()]; - mcEnv.tx(create_bridge(a, bridge(a, ia, b, ib)), ter(TER::fromInt(expected.first))); - TER const mcTER = mcEnv.env_.ter(); + mcEnv.tx(createBridge(a, bridge(a, ia, b, ib)), Ter(TER::fromInt(expected.first))); + TER const mcTER = mcEnv.env.ter(); - scEnv.tx(create_bridge(b, bridge(a, ia, b, ib)), ter(TER::fromInt(expected.second))); - TER const scTER = scEnv.env_.ter(); + scEnv.tx(createBridge(b, bridge(a, ia, b, ib)), Ter(TER::fromInt(expected.second))); + TER const scTER = scEnv.env.ter(); bool const pass = isTesSuccess(mcTER) && isTesSuccess(scTER); - test_result.emplace_back(mcTER, scTER, pass); + testResult.emplace_back(mcTER, scTER, pass); }; - auto apply_ics = [&](auto const& lc, auto const& ics) { + auto applyIcs = [&](auto const& lc, auto const& ics) { std::apply([&](auto const&... ic) { (testcase(lc, ic), ...); }, ics); }; - std::apply([&](auto const&... lc) { (apply_ics(lc, ics), ...); }, lcs); + std::apply([&](auto const&... lc) { (applyIcs(lc, ics), ...); }, lcs); #if GENERATE_MTX_OUTPUT // optional output of matrix results in markdown format @@ -928,44 +927,44 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // Changing a non-existent bridge should fail XEnv(*this).tx( - bridge_modify( + bridgeModify( mcAlice, bridge(mcAlice, mcGw["USD"], mcBob, mcBob["USD"]), XRP(2), std::nullopt), - ter(tecNO_ENTRY)); + Ter(tecNO_ENTRY)); // must change something // XEnv(*this) // .tx(create_bridge(mcDoor, jvb, XRP(1), XRP(1))) // .tx(bridge_modify(mcDoor, jvb, XRP(1), XRP(1)), - // ter(temMALFORMED)); + // Ter(temMALFORMED)); // must change something XEnv(*this) - .tx(create_bridge(mcDoor, jvb, XRP(1), XRP(1))) + .tx(createBridge(mcDoor, jvb, XRP(1), XRP(1))) .close() - .tx(bridge_modify(mcDoor, jvb, {}, {}), ter(temMALFORMED)); + .tx(bridgeModify(mcDoor, jvb, {}, {}), Ter(temMALFORMED)); // Reward amount is non-xrp XEnv(*this).tx( - bridge_modify(mcDoor, jvb, mcUSD(2), XRP(10)), ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); + bridgeModify(mcDoor, jvb, mcUSD(2), XRP(10)), Ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); // Reward amount is XRP and negative XEnv(*this).tx( - bridge_modify(mcDoor, jvb, XRP(-2), XRP(10)), ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); + bridgeModify(mcDoor, jvb, XRP(-2), XRP(10)), Ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)); // Min create amount is non-xrp XEnv(*this).tx( - bridge_modify(mcDoor, jvb, XRP(2), mcUSD(10)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + bridgeModify(mcDoor, jvb, XRP(2), mcUSD(10)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // Min create amount is zero XEnv(*this).tx( - bridge_modify(mcDoor, jvb, XRP(2), XRP(0)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + bridgeModify(mcDoor, jvb, XRP(2), XRP(0)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // Min create amount is negative XEnv(*this).tx( - bridge_modify(mcDoor, jvb, XRP(2), XRP(-10)), - ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); + bridgeModify(mcDoor, jvb, XRP(2), XRP(-10)), + Ter(temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT)); // First check the regular claim process (without bridge_modify) for (auto withClaim : {false, true}) @@ -973,42 +972,42 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); } // Check that the reward paid from a claim Id was the reward when @@ -1019,48 +1018,48 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); // Now modify the reward on the bridge - mcEnv.tx(bridge_modify(mcDoor, jvb, XRP(2), XRP(10))).close(); - scEnv.tx(bridge_modify(Account::master, jvb, XRP(2), XRP(10))).close(); + mcEnv.tx(bridgeModify(mcDoor, jvb, XRP(2), XRP(10))).close(); + scEnv.tx(bridgeModify(Account::kMASTER, jvb, XRP(2), XRP(10))).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } // make sure the reward accounts indeed received the original // split reward (1 split 5 ways) instead of the updated 2 XRP. - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); } // Check that the signatures used to verify attestations and decide @@ -1072,91 +1071,91 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); // change signers - claim should not be processed is the batch // is signed by original signers - scEnv.tx(jtx::signers(Account::master, quorum, alt_signers)).close(); + scEnv.tx(jtx::signers(Account::kMASTER, quorum, alt_signers)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); // submit claim using outdated signers - should fail scEnv .multiTx( - claim_attestations( + claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers), - ter(tecNO_PERMISSION)) + Ter(tecNO_PERMISSION)) .close(); if (withClaim) { // need to submit a claim transactions scEnv - .tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } // make sure transfer has not happened as we sent attestations // using outdated signers - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // submit claim using current signers - should succeed scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, alt_signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } // make sure the transfer went through as we sent attestations // using new signers - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum, false)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum, false)); } // coverage test: bridge_modify transaction with incorrect flag XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .close() - .tx(bridge_modify(mcDoor, jvb, XRP(1), XRP(2)), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)); + .tx(bridgeModify(mcDoor, jvb, XRP(1), XRP(2)), + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)); // coverage test: bridge_modify transaction with xchain feature // disabled XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .disableFeature(featureXChainBridge) .close() - .tx(bridge_modify(mcDoor, jvb, XRP(1), XRP(2)), ter(temDISABLED)); + .tx(bridgeModify(mcDoor, jvb, XRP(1), XRP(2)), Ter(temDISABLED)); // coverage test: bridge_modify return temSIDECHAIN_NONDOOR_OWNER; XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .close() - .tx(bridge_modify(mcAlice, jvb, XRP(1), XRP(2)), ter(temXCHAIN_BRIDGE_NONDOOR_OWNER)); + .tx(bridgeModify(mcAlice, jvb, XRP(1), XRP(2)), Ter(temXCHAIN_BRIDGE_NONDOOR_OWNER)); /** * test tfClearAccountCreateAmount flag in BridgeModify tx @@ -1165,18 +1164,18 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj * -- XChainCreateAccountCommit tx fail after previous step */ XEnv(*this) - .tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))) + .tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))) .close() - .tx(sidechain_xchain_account_create(mcAlice, jvb, scuAlice, XRP(100), reward)) + .tx(sidechainXchainAccountCreate(mcAlice, jvb, scuAlice, XRP(100), reward)) .close() - .tx(bridge_modify(mcDoor, jvb, {}, XRP(2)), - txflags(tfClearAccountCreateAmount), - ter(temMALFORMED)) + .tx(bridgeModify(mcDoor, jvb, {}, XRP(2)), + Txflags(tfClearAccountCreateAmount), + Ter(temMALFORMED)) .close() - .tx(bridge_modify(mcDoor, jvb, XRP(3), {}), txflags(tfClearAccountCreateAmount)) + .tx(bridgeModify(mcDoor, jvb, XRP(3), {}), Txflags(tfClearAccountCreateAmount)) .close() - .tx(sidechain_xchain_account_create(mcAlice, jvb, scuBob, XRP(100), XRP(3)), - ter(tecXCHAIN_CREATE_ACCOUNT_DISABLED)) + .tx(sidechainXchainAccountCreate(mcAlice, jvb, scuBob, XRP(100), XRP(3)), + Ter(tecXCHAIN_CREATE_ACCOUNT_DISABLED)) .close(); } @@ -1185,83 +1184,82 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { using namespace jtx; XRPAmount const res1 = reserve(1); - XRPAmount const tx_fee = txFee(); + XRPAmount const fee = txFee(); testcase("Create ClaimID"); // normal bridge create for sanity check with the exact necessary // account balance XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .fund(res1, scuAlice) // acct reserve + 1 object .close() - .tx(xchain_create_claim_id(scuAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scuAlice, jvb, reward, mcAlice)) .close(); // check reward not deducted when claim id is created { XEnv xenv(*this, true); - Balance const scAlice_bal(xenv, scAlice); + test::Balance const scAliceBal(xenv, scAlice); - xenv.tx(create_bridge(Account::master, jvb)) - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + xenv.tx(createBridge(Account::kMASTER, jvb)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); - BEAST_EXPECT(scAlice_bal.diff() == -tx_fee); + BEAST_EXPECT(scAliceBal.diff() == -fee); } // Non-existent bridge XEnv(*this, true) - .tx(xchain_create_claim_id( + .tx(xchainCreateClaimId( scAlice, bridge(mcAlice, mcAlice["USD"], scBob, scBob["USD"]), reward, mcAlice), - ter(tecNO_ENTRY)) + Ter(tecNO_ENTRY)) .close(); // Creating the new object would put the account below the reserve XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .fund(res1 - xrp_dust, scuAlice) // barely not enough .close() - .tx(xchain_create_claim_id(scuAlice, jvb, reward, mcAlice), - ter(tecINSUFFICIENT_RESERVE)) + .tx(xchainCreateClaimId(scuAlice, jvb, reward, mcAlice), Ter(tecINSUFFICIENT_RESERVE)) .close(); // The specified reward doesn't match the reward on the bridge (test // by giving the reward amount for the other side, as well as a // completely non-matching reward) XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, split_reward_quorum, mcAlice), - ter(tecXCHAIN_REWARD_MISMATCH)) + .tx(xchainCreateClaimId(scAlice, jvb, split_reward_quorum, mcAlice), + Ter(tecXCHAIN_REWARD_MISMATCH)) .close(); // A reward amount that isn't XRP XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, mcUSD(1), mcAlice), - ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)) + .tx(xchainCreateClaimId(scAlice, jvb, mcUSD(1), mcAlice), + Ter(temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT)) .close(); // coverage test: xchain_create_claim_id transaction with incorrect // flag XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice), + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)) .close(); // coverage test: xchain_create_claim_id transaction with xchain // feature disabled XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .disableFeature(featureXChainBridge) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice), ter(temDISABLED)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice), Ter(temDISABLED)) .close(); } @@ -1270,98 +1268,98 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { using namespace jtx; XRPAmount const res0 = reserve(0); - XRPAmount const tx_fee = txFee(); + XRPAmount const fee = txFee(); testcase("Commit"); // Commit to a non-existent bridge - XEnv(*this).tx(xchain_commit(mcAlice, jvb, 1, one_xrp, scBob), ter(tecNO_ENTRY)); + XEnv(*this).tx(xchainCommit(mcAlice, jvb, 1, one_xrp, scBob), Ter(tecNO_ENTRY)); // check that reward not deducted when doing the commit { XEnv xenv(*this); - Balance const alice_bal(xenv, mcAlice); + test::Balance const aliceBal(xenv, mcAlice); auto const amt = XRP(1000); - xenv.tx(create_bridge(mcDoor, jvb)) + xenv.tx(createBridge(mcDoor, jvb)) .close() - .tx(xchain_commit(mcAlice, jvb, 1, amt, scBob)) + .tx(xchainCommit(mcAlice, jvb, 1, amt, scBob)) .close(); - STAmount const claim_cost = amt; - BEAST_EXPECT(alice_bal.diff() == -(claim_cost + tx_fee)); + STAmount const claimCost = amt; + BEAST_EXPECT(aliceBal.diff() == -(claimCost + fee)); } // Commit a negative amount XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .close() - .tx(xchain_commit(mcAlice, jvb, 1, XRP(-1), scBob), ter(temBAD_AMOUNT)); + .tx(xchainCommit(mcAlice, jvb, 1, XRP(-1), scBob), Ter(temBAD_AMOUNT)); // Commit an amount whose issue that does not match the expected // issue on the bridge (either LockingChainIssue or // IssuingChainIssue, depending on the chain). XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .close() - .tx(xchain_commit(mcAlice, jvb, 1, mcUSD(100), scBob), ter(temBAD_ISSUER)); + .tx(xchainCommit(mcAlice, jvb, 1, mcUSD(100), scBob), Ter(temBAD_ISSUER)); // Commit an amount that would put the sender below the required // reserve (if XRP) XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .fund(res0 + one_xrp - xrp_dust, mcuAlice) // barely not enough .close() - .tx(xchain_commit(mcuAlice, jvb, 1, one_xrp, scBob), ter(tecUNFUNDED_PAYMENT)); + .tx(xchainCommit(mcuAlice, jvb, 1, one_xrp, scBob), Ter(tecUNFUNDED_PAYMENT)); XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .fund( res0 + one_xrp + xrp_dust, // "xrp_dust" for tx fees mcuAlice) // exactly enough => should succeed .close() - .tx(xchain_commit(mcuAlice, jvb, 1, one_xrp, scBob)); + .tx(xchainCommit(mcuAlice, jvb, 1, one_xrp, scBob)); // Commit an amount above the account's balance (for both XRP and // IOUs) XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .fund(res0, mcuAlice) // barely not enough .close() - .tx(xchain_commit(mcuAlice, jvb, 1, res0 + one_xrp, scBob), ter(tecUNFUNDED_PAYMENT)); + .tx(xchainCommit(mcuAlice, jvb, 1, res0 + one_xrp, scBob), Ter(tecUNFUNDED_PAYMENT)); - auto jvb_USD = bridge(mcDoor, mcUSD, scGw, scUSD); + auto jvbUsd = bridge(mcDoor, mcUSD, scGw, scUSD); // commit sent from iou issuer (mcGw) succeeds - should it? XEnv(*this) .tx(trust(mcDoor, mcUSD(10000))) // door needs to have a trustline - .tx(create_bridge(mcDoor, jvb_USD)) + .tx(createBridge(mcDoor, jvbUsd)) .close() - .tx(xchain_commit(mcGw, jvb_USD, 1, mcUSD(1), scBob)); + .tx(xchainCommit(mcGw, jvbUsd, 1, mcUSD(1), scBob)); // commit to a door account from the door account. This should fail. XEnv(*this) .tx(trust(mcDoor, mcUSD(10000))) // door needs to have a trustline - .tx(create_bridge(mcDoor, jvb_USD)) + .tx(createBridge(mcDoor, jvbUsd)) .close() - .tx(xchain_commit(mcDoor, jvb_USD, 1, mcUSD(1), scBob), ter(tecXCHAIN_SELF_COMMIT)); + .tx(xchainCommit(mcDoor, jvbUsd, 1, mcUSD(1), scBob), Ter(tecXCHAIN_SELF_COMMIT)); // commit sent from mcAlice which has no IOU balance => should fail XEnv(*this) .tx(trust(mcDoor, mcUSD(10000))) // door needs to have a trustline - .tx(create_bridge(mcDoor, jvb_USD)) + .tx(createBridge(mcDoor, jvbUsd)) .close() - .tx(xchain_commit(mcAlice, jvb_USD, 1, mcUSD(1), scBob), ter(terNO_LINE)); + .tx(xchainCommit(mcAlice, jvbUsd, 1, mcUSD(1), scBob), Ter(terNO_LINE)); // commit sent from mcAlice which has no IOU balance => should fail // just changed the destination to scGw (which is the door account // and may not make much sense) XEnv(*this) .tx(trust(mcDoor, mcUSD(10000))) // door needs to have a trustline - .tx(create_bridge(mcDoor, jvb_USD)) + .tx(createBridge(mcDoor, jvbUsd)) .close() - .tx(xchain_commit(mcAlice, jvb_USD, 1, mcUSD(1), scGw), ter(terNO_LINE)); + .tx(xchainCommit(mcAlice, jvbUsd, 1, mcUSD(1), scGw), Ter(terNO_LINE)); // commit sent from mcAlice which has a IOU balance => should // succeed @@ -1370,26 +1368,26 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj .tx(trust(mcAlice, mcUSD(10000))) .close() .tx(pay(mcGw, mcAlice, mcUSD(10))) - .tx(create_bridge(mcDoor, jvb_USD)) + .tx(createBridge(mcDoor, jvbUsd)) .close() //.tx(pay(mcAlice, mcDoor, mcUSD(10))); - .tx(xchain_commit(mcAlice, jvb_USD, 1, mcUSD(10), scAlice)); + .tx(xchainCommit(mcAlice, jvbUsd, 1, mcUSD(10), scAlice)); // coverage test: xchain_commit transaction with incorrect flag XEnv(*this) - .tx(create_bridge(mcDoor)) + .tx(createBridge(mcDoor)) .close() - .tx(xchain_commit(mcAlice, jvb, 1, one_xrp, scBob), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)); + .tx(xchainCommit(mcAlice, jvb, 1, one_xrp, scBob), + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)); // coverage test: xchain_commit transaction with xchain feature // disabled XEnv(*this) - .tx(create_bridge(mcDoor)) + .tx(createBridge(mcDoor)) .disableFeature(featureXChainBridge) .close() - .tx(xchain_commit(mcAlice, jvb, 1, one_xrp, scBob), ter(temDISABLED)); + .tx(xchainCommit(mcAlice, jvb, 1, one_xrp, scBob), Ter(temDISABLED)); } void @@ -1399,10 +1397,10 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj testcase("Add Attestation"); XRPAmount const res0 = reserve(0); - XRPAmount tx_fee = txFee(); + XRPAmount fee = txFee(); auto multiTtxFee = [&](std::uint32_t m) -> STAmount { - return multiply(tx_fee, STAmount(m), xrpIssue()); + return multiply(fee, STAmount(m), xrpIssue()); }; // Add an attestation to a claim id that has already reached quorum. @@ -1417,24 +1415,24 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv scEnv(*this, true); std::uint32_t const claimID = 1; - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id present auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, @@ -1444,32 +1442,32 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj claimID, dst, signers, - UT_XCHAIN_DEFAULT_QUORUM)) + kUT_XCHAIN_DEFAULT_QUORUM)) .close(); scEnv - .tx(claim_attestation( + .tx(claimAttestation( scAttester, jvb, mcAlice, amt, - payees[UT_XCHAIN_DEFAULT_QUORUM], + payees[kUT_XCHAIN_DEFAULT_QUORUM], true, claimID, dst, - signers[UT_XCHAIN_DEFAULT_QUORUM])) + signers[kUT_XCHAIN_DEFAULT_QUORUM])) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); BEAST_EXPECT(!scEnv.claimID(jvb, claimID)); // claim id deleted BEAST_EXPECT(scEnv.claimID(jvb) == claimID); } - BEAST_EXPECT(transfer.has_happened(amt, split_reward_everyone)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_everyone)); } // Test that signature weights are correctly handled. Assign @@ -1483,14 +1481,14 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - std::uint32_t const quorum_7 = 7; - std::vector const signers_ = [] { - constexpr int numSigners = 4; + std::uint32_t const quorum7 = 7; + std::vector const signers = [] { + constexpr int kNUM_SIGNERS = 4; std::uint32_t const weights[] = {1, 2, 4, 4}; - std::vector result; - result.reserve(numSigners); - for (int i = 0; i < numSigners; ++i) + std::vector result; + result.reserve(kNUM_SIGNERS); + for (int i = 0; i < kNUM_SIGNERS; ++i) { using namespace std::literals; auto const a = Account("signer_"s + std::to_string(i)); @@ -1499,12 +1497,12 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj return result; }(); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum_7, signers_)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum7, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); std::uint32_t const claimID = 1; BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id present @@ -1512,27 +1510,27 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[0], 3, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[0], 3, withClaim); scEnv - .multiTx(claim_attestations( - scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers_, 3)) + .multiTx(claimAttestations( + scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers, 3)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } BEAST_EXPECT(!scEnv.claimID(jvb, 1)); // claim id deleted - BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(3), reward.asset()))); + BEAST_EXPECT(transfer.hasHappened(amt, divide(reward, STAmount(3), reward.asset()))); } // 4,4 => should succeed @@ -1541,14 +1539,14 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - std::uint32_t const quorum_7 = 7; - std::vector const signers_ = [] { - constexpr int numSigners = 4; + std::uint32_t const quorum7 = 7; + std::vector const signers = [] { + constexpr int kNUM_SIGNERS = 4; std::uint32_t const weights[] = {1, 2, 4, 4}; - std::vector result; - result.reserve(numSigners); - for (int i = 0; i < numSigners; ++i) + std::vector result; + result.reserve(kNUM_SIGNERS); + for (int i = 0; i < kNUM_SIGNERS; ++i) { using namespace std::literals; auto const a = Account("signer_"s + std::to_string(i)); @@ -1556,15 +1554,14 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj } return result; }(); - STAmount const split_reward_ = - divide(reward, STAmount(signers_.size()), reward.asset()); + STAmount const splitReward = divide(reward, STAmount(signers.size()), reward.asset()); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum_7, signers_)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum7, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); std::uint32_t const claimID = 1; BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id present @@ -1572,27 +1569,27 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[2], 2, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[2], 2, withClaim); scEnv - .multiTx(claim_attestations( - scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers_, 2, 2)) + .multiTx(claimAttestations( + scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers, 2, 2)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } BEAST_EXPECT(!scEnv.claimID(jvb, claimID)); // claim id deleted - BEAST_EXPECT(transfer.has_happened(amt, divide(reward, STAmount(2), reward.asset()))); + BEAST_EXPECT(transfer.hasHappened(amt, divide(reward, STAmount(2), reward.asset()))); } // 1,2 => should fail @@ -1601,14 +1598,14 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - std::uint32_t const quorum_7 = 7; - std::vector const signers_ = [] { - constexpr int numSigners = 4; + std::uint32_t const quorum7 = 7; + std::vector const signers = [] { + constexpr int kNUM_SIGNERS = 4; std::uint32_t const weights[] = {1, 2, 4, 4}; - std::vector result; - result.reserve(numSigners); - for (int i = 0; i < numSigners; ++i) + std::vector result; + result.reserve(kNUM_SIGNERS); + for (int i = 0; i < kNUM_SIGNERS; ++i) { using namespace std::literals; auto const a = Account("signer_"s + std::to_string(i)); @@ -1617,12 +1614,12 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj return result; }(); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum_7, signers_)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum7, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); std::uint32_t const claimID = 1; @@ -1630,28 +1627,28 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[0], 2, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[0], 2, withClaim); scEnv - .multiTx(claim_attestations( - scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers_, 2)) + .multiTx(claimAttestations( + scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers, 2)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions scEnv - .tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id still present - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // 2,4 => should fail @@ -1660,14 +1657,14 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - std::uint32_t const quorum_7 = 7; - std::vector const signers_ = [] { - constexpr int numSigners = 4; + std::uint32_t const quorum7 = 7; + std::vector const signers = [] { + constexpr int kNUM_SIGNERS = 4; std::uint32_t const weights[] = {1, 2, 4, 4}; - std::vector result; - result.reserve(numSigners); - for (int i = 0; i < numSigners; ++i) + std::vector result; + result.reserve(kNUM_SIGNERS); + for (int i = 0; i < kNUM_SIGNERS; ++i) { using namespace std::literals; auto const a = Account("signer_"s + std::to_string(i)); @@ -1676,12 +1673,12 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj return result; }(); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum_7, signers_)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum7, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); std::uint32_t const claimID = 1; @@ -1690,29 +1687,29 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[1], 2, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[1], 2, withClaim); scEnv - .multiTx(claim_attestations( - scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers_, 2, 1)) + .multiTx(claimAttestations( + scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers, 2, 1)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions scEnv - .tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id still present - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Confirm that account create transactions happen in the correct @@ -1723,37 +1720,37 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); auto const amt = XRP(1000); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; { - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); - mcEnv.tx(create_bridge(mcDoor, jvb, reward, XRP(20))) + mcEnv.tx(createBridge(mcDoor, jvb, reward, XRP(20))) .close() - .tx(sidechain_xchain_account_create(mcAlice, jvb, scuAlice, amt, reward)) - .tx(sidechain_xchain_account_create(mcBob, jvb, scuBob, amt, reward)) - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuCarol, amt, reward)) + .tx(sidechainXchainAccountCreate(mcAlice, jvb, scuAlice, amt, reward)) + .tx(sidechainXchainAccountCreate(mcBob, jvb, scuBob, amt, reward)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuCarol, amt, reward)) .close(); BEAST_EXPECT( - door.diff() == (multiply(amt_plus_reward, STAmount(3), xrpIssue()) - tx_fee)); - BEAST_EXPECT(carol.diff() == -(amt + reward + tx_fee)); + door.diff() == (multiply(amtPlusReward, STAmount(3), xrpIssue()) - fee)); + BEAST_EXPECT(carol.diff() == -(amt + reward + fee)); } - scEnv.tx(create_bridge(Account::master, jvb, reward, XRP(20))) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, reward, XRP(20))) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); { // send first batch of account create attest for all 3 // account create - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 2)) - .multiTx(att_create_acct_vec(3, amt, scuCarol, 2)) - .multiTx(att_create_acct_vec(2, amt, scuBob, 2)) + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 2)) + .multiTx(attCreateAcctVec(3, amt, scuCarol, 2)) + .multiTx(attCreateAcctVec(2, amt, scuBob, 2)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -1769,10 +1766,10 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // complete attestations for 2nd account create => should // not complete - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(2, amt, scuBob, 3, 2)).close(); + scEnv.multiTx(attCreateAcctVec(2, amt, scuBob, 3, 2)).close(); BEAST_EXPECT(door.diff() == STAmount(0)); // att_create_acct_vec return vectors of size 3, so 3 txns @@ -1785,10 +1782,10 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // complete attestations for 3rd account create => should // not complete - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(3, amt, scuCarol, 3, 2)).close(); + scEnv.multiTx(attCreateAcctVec(3, amt, scuCarol, 3, 2)).close(); BEAST_EXPECT(door.diff() == STAmount(0)); // att_create_acct_vec return vectors of size 3, so 3 txns @@ -1801,12 +1798,12 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // complete attestations for 1st account create => account // should be created - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 3, 1)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 3, 1)).close(); - BEAST_EXPECT(door.diff() == -amt_plus_reward); + BEAST_EXPECT(door.diff() == -amtPlusReward); // att_create_acct_vec return vectors of size 3, so 3 txns BEAST_EXPECT(attester.diff() == -multiTtxFee(3)); BEAST_EXPECT(scEnv.balance(scuAlice) == amt); @@ -1820,10 +1817,10 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // resend attestations for 3rd account create => still // should not complete - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(3, amt, scuCarol, 3, 2)).close(); + scEnv.multiTx(attCreateAcctVec(3, amt, scuCarol, 3, 2)).close(); BEAST_EXPECT(door.diff() == STAmount(0)); // att_create_acct_vec return vectors of size 3, so 3 txns @@ -1837,13 +1834,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // resend attestations for 2nd account create => account // should be created - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(2, amt, scuBob, 1)).close(); + scEnv.multiTx(attCreateAcctVec(2, amt, scuBob, 1)).close(); - BEAST_EXPECT(door.diff() == -amt_plus_reward); - BEAST_EXPECT(attester.diff() == -tx_fee); + BEAST_EXPECT(door.diff() == -amtPlusReward); + BEAST_EXPECT(attester.diff() == -fee); BEAST_EXPECT(scEnv.balance(scuBob) == amt); BEAST_EXPECT(!scEnv.caClaimID(jvb, 2)); // claim id 2 deleted @@ -1853,13 +1850,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // resend attestations for 3rc account create => account // should be created - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(3, amt, scuCarol, 1)).close(); + scEnv.multiTx(attCreateAcctVec(3, amt, scuCarol, 1)).close(); - BEAST_EXPECT(door.diff() == -amt_plus_reward); - BEAST_EXPECT(attester.diff() == -tx_fee); + BEAST_EXPECT(door.diff() == -amtPlusReward); + BEAST_EXPECT(attester.diff() == -fee); BEAST_EXPECT(scEnv.balance(scuCarol) == amt); BEAST_EXPECT(!scEnv.caClaimID(jvb, 3)); // claim id 3 deleted @@ -1874,33 +1871,32 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv scEnv(*this, true); auto const amt = res0 - XRP(1); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; - mcEnv.tx(create_bridge(mcDoor, jvb, reward, XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, reward, XRP(20))).close(); { - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); - mcEnv.tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, amt, reward)) - .close(); + mcEnv.tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, amt, reward)).close(); - BEAST_EXPECT(door.diff() == amt_plus_reward); - BEAST_EXPECT(carol.diff() == -(amt_plus_reward + tx_fee)); + BEAST_EXPECT(door.diff() == amtPlusReward); + BEAST_EXPECT(carol.diff() == -(amtPlusReward + fee)); } - scEnv.tx(create_bridge(Account::master, jvb, reward, XRP(20))) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, reward, XRP(20))) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 2)).close(); BEAST_EXPECT(!!scEnv.caClaimID(jvb, 1)); // claim id present BEAST_EXPECT(scEnv.claimCount(jvb) == 0); // claim count is one less - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 2, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 2, 2)).close(); BEAST_EXPECT(!scEnv.caClaimID(jvb, 1)); // claim id deleted BEAST_EXPECT(scEnv.claimCount(jvb) == 1); // claim count was incremented @@ -1916,38 +1912,37 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv scEnv(*this, true); auto const amt = XRP(111); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; - mcEnv.tx(create_bridge(mcDoor, jvb, reward, XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, reward, XRP(20))).close(); { - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); - mcEnv.tx(sidechain_xchain_account_create(mcCarol, jvb, scAlice, amt, reward)) - .close(); + mcEnv.tx(sidechainXchainAccountCreate(mcCarol, jvb, scAlice, amt, reward)).close(); - BEAST_EXPECT(door.diff() == amt_plus_reward); - BEAST_EXPECT(carol.diff() == -(amt_plus_reward + tx_fee)); + BEAST_EXPECT(door.diff() == amtPlusReward); + BEAST_EXPECT(carol.diff() == -(amtPlusReward + fee)); } - scEnv.tx(create_bridge(Account::master, jvb, reward, XRP(20))) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, reward, XRP(20))) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); - Balance const alice(scEnv, scAlice); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); + test::Balance const alice(scEnv, scAlice); - scEnv.multiTx(att_create_acct_vec(1, amt, scAlice, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scAlice, 2)).close(); BEAST_EXPECT(!!scEnv.caClaimID(jvb, 1)); // claim id present BEAST_EXPECT(scEnv.claimCount(jvb) == 0); // claim count is one less - scEnv.multiTx(att_create_acct_vec(1, amt, scAlice, 2, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scAlice, 2, 2)).close(); BEAST_EXPECT(!scEnv.caClaimID(jvb, 1)); // claim id deleted BEAST_EXPECT(scEnv.claimCount(jvb) == 1); // claim count was incremented - BEAST_EXPECT(door.diff() == -amt_plus_reward); + BEAST_EXPECT(door.diff() == -amtPlusReward); BEAST_EXPECT(attester.diff() == -multiTtxFee(4)); BEAST_EXPECT(alice.diff() == amt); } @@ -1959,35 +1954,34 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv scEnv(*this, true); auto const amt = XRP(1000); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; - mcEnv.tx(create_bridge(mcDoor, jvb, reward, XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, reward, XRP(20))).close(); { - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); - mcEnv.tx(sidechain_xchain_account_create(mcCarol, jvb, scAlice, amt, reward)) - .close(); + mcEnv.tx(sidechainXchainAccountCreate(mcCarol, jvb, scAlice, amt, reward)).close(); - BEAST_EXPECT(door.diff() == amt_plus_reward); - BEAST_EXPECT(carol.diff() == -(amt_plus_reward + tx_fee)); + BEAST_EXPECT(door.diff() == amtPlusReward); + BEAST_EXPECT(carol.diff() == -(amtPlusReward + fee)); } - scEnv.tx(create_bridge(Account::master, jvb, reward, XRP(20))) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, reward, XRP(20))) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .tx(fset("scAlice", asfDepositAuth)) // set deposit auth .close(); - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); - Balance const alice(scEnv, scAlice); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); + test::Balance const alice(scEnv, scAlice); - scEnv.multiTx(att_create_acct_vec(1, amt, scAlice, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scAlice, 2)).close(); BEAST_EXPECT(!!scEnv.caClaimID(jvb, 1)); // claim id present BEAST_EXPECT(scEnv.claimCount(jvb) == 0); // claim count is one less - scEnv.multiTx(att_create_acct_vec(1, amt, scAlice, 2, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scAlice, 2, 2)).close(); BEAST_EXPECT(!scEnv.caClaimID(jvb, 1)); // claim id deleted BEAST_EXPECT(scEnv.claimCount(jvb) == 1); // claim count was incremented @@ -2005,42 +1999,42 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); auto const amt = XRP(1000); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; { - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); - mcEnv.tx(create_bridge(mcDoor, jvb, reward, XRP(20))) + mcEnv.tx(createBridge(mcDoor, jvb, reward, XRP(20))) .close() - .tx(sidechain_xchain_account_create(mcAlice, jvb, scuAlice, amt, reward)) + .tx(sidechainXchainAccountCreate(mcAlice, jvb, scuAlice, amt, reward)) .close() // make sure Alice gets claim #1 - .tx(sidechain_xchain_account_create(mcBob, jvb, scuBob, amt, reward)) + .tx(sidechainXchainAccountCreate(mcBob, jvb, scuBob, amt, reward)) .close() // make sure Bob gets claim #2 - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuCarol, amt, reward)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuCarol, amt, reward)) .close(); // and Carol will get claim #3 BEAST_EXPECT( - door.diff() == (multiply(amt_plus_reward, STAmount(3), xrpIssue()) - tx_fee)); - BEAST_EXPECT(carol.diff() == -(amt + reward + tx_fee)); + door.diff() == (multiply(amtPlusReward, STAmount(3), xrpIssue()) - fee)); + BEAST_EXPECT(carol.diff() == -(amt + reward + fee)); } - std::uint32_t const red_quorum = 2; - scEnv.tx(create_bridge(Account::master, jvb, reward, XRP(20))) - .tx(jtx::signers(Account::master, red_quorum, signers)) + std::uint32_t const redQuorum = 2; + scEnv.tx(createBridge(Account::kMASTER, jvb, reward, XRP(20))) + .tx(jtx::signers(Account::kMASTER, redQuorum, signers)) .close(); { - Balance const attester(scEnv, scAttester); - Balance const door(scEnv, Account::master); - auto const bad_amt = XRP(10); + test::Balance const attester(scEnv, scAttester); + test::Balance const door(scEnv, Account::kMASTER); + auto const badAmt = XRP(10); std::uint32_t txCount = 0; // send attestations with incorrect amounts to for all 3 // AccountCreate. They will be replaced later - scEnv.multiTx(att_create_acct_vec(1, bad_amt, scuAlice, 1)) - .multiTx(att_create_acct_vec(2, bad_amt, scuBob, 1, 2)) - .multiTx(att_create_acct_vec(3, bad_amt, scuCarol, 1, 1)) + scEnv.multiTx(attCreateAcctVec(1, badAmt, scuAlice, 1)) + .multiTx(attCreateAcctVec(2, badAmt, scuBob, 1, 2)) + .multiTx(attCreateAcctVec(3, badAmt, scuCarol, 1, 1)) .close(); txCount += 3; @@ -2052,9 +2046,9 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // batch, the transaction errors. // from now on we send correct attestations - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 1, 0)) - .multiTx(att_create_acct_vec(2, amt, scuBob, 1, 2)) - .multiTx(att_create_acct_vec(3, amt, scuCarol, 1, 4)) + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 1, 0)) + .multiTx(attCreateAcctVec(2, amt, scuBob, 1, 2)) + .multiTx(attCreateAcctVec(3, amt, scuCarol, 1, 4)) .close(); txCount += 3; @@ -2063,22 +2057,22 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj BEAST_EXPECTS(!!scEnv.caClaimID(jvb, 3), "claim id 3 still there"); BEAST_EXPECTS(scEnv.claimCount(jvb) == 0, "No account created yet"); - scEnv.multiTx(att_create_acct_vec(3, amt, scuCarol, 1, 1)).close(); + scEnv.multiTx(attCreateAcctVec(3, amt, scuCarol, 1, 1)).close(); txCount += 1; BEAST_EXPECTS(!!scEnv.caClaimID(jvb, 3), "claim id 3 still there"); BEAST_EXPECTS(scEnv.claimCount(jvb) == 0, "No account created yet"); - scEnv.multiTx(att_create_acct_vec(1, amt, scuAlice, 1, 2)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, scuAlice, 1, 2)).close(); txCount += 1; BEAST_EXPECTS(!scEnv.caClaimID(jvb, 1), "claim id 1 deleted"); BEAST_EXPECTS(scEnv.claimCount(jvb) == 1, "scuAlice created"); - scEnv.multiTx(att_create_acct_vec(2, amt, scuBob, 1, 3)) + scEnv.multiTx(attCreateAcctVec(2, amt, scuBob, 1, 3)) .multiTx( - att_create_acct_vec(1, amt, scuAlice, 1, 3), - ter(tecXCHAIN_ACCOUNT_CREATE_PAST)) + attCreateAcctVec(1, amt, scuAlice, 1, 3), + Ter(tecXCHAIN_ACCOUNT_CREATE_PAST)) .close(); txCount += 2; @@ -2086,7 +2080,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj BEAST_EXPECTS(!scEnv.caClaimID(jvb, 1), "claim id 1 not added"); BEAST_EXPECTS(scEnv.claimCount(jvb) == 2, "scuAlice & scuBob created"); - scEnv.multiTx(att_create_acct_vec(3, amt, scuCarol, 1, 0)).close(); + scEnv.multiTx(attCreateAcctVec(3, amt, scuCarol, 1, 0)).close(); txCount += 1; BEAST_EXPECTS(!scEnv.caClaimID(jvb, 3), "claim id 3 deleted"); @@ -2096,7 +2090,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // sometimes a couple drops are left over unspent in the // door account (here 2 drops) BEAST_EXPECT( - multiply(amt_plus_reward, STAmount(3), xrpIssue()) + door.diff() < drops(3)); + multiply(amtPlusReward, STAmount(3), xrpIssue()) + door.diff() < drops(3)); BEAST_EXPECT(attester.diff() == -multiTtxFee(txCount)); BEAST_EXPECT(scEnv.balance(scuAlice) == amt); BEAST_EXPECT(scEnv.balance(scuBob) == amt); @@ -2111,13 +2105,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // coverage test: add_attestation transaction with incorrect flag { XEnv scEnv(*this, true); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(claim_attestation( + .tx(claimAttestation( scAttester, jvb, mcAlice, XRP(1000), payees[0], true, 1, {}, signers[0]), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)) + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)) .close(); } @@ -2125,13 +2119,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // disabled { XEnv scEnv(*this, true); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .disableFeature(featureXChainBridge) .close() - .tx(claim_attestation( + .tx(claimAttestation( scAttester, jvb, mcAlice, XRP(1000), payees[0], true, 1, {}, signers[0]), - ter(temDISABLED)) + Ter(temDISABLED)) .close(); } } @@ -2148,47 +2142,47 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv scEnv(*this, true); std::uint32_t const claimID = 1; - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); BEAST_EXPECT(!!scEnv.claimID(jvb, claimID)); // claim id present Account const dst{scBob}; auto const amt = XRP(1000); - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - auto const dstStartBalance = scEnv.env_.balance(dst); + auto const dstStartBalance = scEnv.env.balance(dst); for (int i = 0; i < signers.size(); ++i) { - auto const att = claim_attestation( + auto const att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[i], true, claimID, dst, signers[i]); TER const expectedTER = i < quorum ? tesSUCCESS : TER{tecXCHAIN_NO_CLAIM_ID}; if (i + 1 == quorum) { - scEnv.tx(att, ter(expectedTER)).close(); + scEnv.tx(att, Ter(expectedTER)).close(); } else { - scEnv.tx(att, ter(expectedTER)).close(); + scEnv.tx(att, Ter(expectedTER)).close(); } if (i + 1 < quorum) { - BEAST_EXPECT(dstStartBalance == scEnv.env_.balance(dst)); + BEAST_EXPECT(dstStartBalance == scEnv.env.balance(dst)); } else { - BEAST_EXPECT(dstStartBalance + amt == scEnv.env_.balance(dst)); + BEAST_EXPECT(dstStartBalance + amt == scEnv.env.balance(dst)); } } - BEAST_EXPECT(dstStartBalance + amt == scEnv.env_.balance(dst)); + BEAST_EXPECT(dstStartBalance + amt == scEnv.env.balance(dst)); } { @@ -2213,24 +2207,24 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj auto const amt = XRP(1000); std::uint32_t const claimID = 1; - for (auto i = 0; i < UT_XCHAIN_DEFAULT_NUM_SIGNERS - 2; ++i) + for (auto i = 0; i < kUT_XCHAIN_DEFAULT_NUM_SIGNERS - 2; ++i) scEnv.fund(amt, alt_signers[i].account); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, alt_signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, alt_signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); Account const dst{scBob}; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); - auto const dstStartBalance = scEnv.env_.balance(dst); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); + auto const dstStartBalance = scEnv.env.balance(dst); { // G1: master key - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[0], true, claimID, dst, alt_signers[0]); scEnv.tx(att).close(); } @@ -2239,7 +2233,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // alt_signers[0] is the regular key of alt_signers[1] // There should be 2 attestations after the transaction scEnv.tx(jtx::regkey(alt_signers[1].account, alt_signers[0].account)).close(); - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[1], true, claimID, dst, alt_signers[0]); att[sfAttestationSignerAccount.getJsonName()] = alt_signers[1].account.human(); scEnv.tx(att).close(); @@ -2247,28 +2241,28 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { // B3: public key and non-exist (unfunded) account mismatch // G3: public key and non-exist (unfunded) account match - auto const unfundedSigner1 = alt_signers[UT_XCHAIN_DEFAULT_NUM_SIGNERS - 1]; - auto const unfundedSigner2 = alt_signers[UT_XCHAIN_DEFAULT_NUM_SIGNERS - 2]; - auto att = claim_attestation( + auto const unfundedSigner1 = alt_signers[kUT_XCHAIN_DEFAULT_NUM_SIGNERS - 1]; + auto const unfundedSigner2 = alt_signers[kUT_XCHAIN_DEFAULT_NUM_SIGNERS - 2]; + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, - payees[UT_XCHAIN_DEFAULT_NUM_SIGNERS - 1], + payees[kUT_XCHAIN_DEFAULT_NUM_SIGNERS - 1], true, claimID, dst, unfundedSigner1); att[sfAttestationSignerAccount.getJsonName()] = unfundedSigner2.account.human(); - scEnv.tx(att, ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); + scEnv.tx(att, Ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); att[sfAttestationSignerAccount.getJsonName()] = unfundedSigner1.account.human(); scEnv.tx(att).close(); } { // B2: single item signer list - std::vector tempSignerList = {signers[0]}; + std::vector tempSignerList = {signers[0]}; scEnv.tx(jtx::signers(alt_signers[2].account, 1, tempSignerList)); - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, @@ -2279,32 +2273,32 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj dst, tempSignerList.front()); att[sfAttestationSignerAccount.getJsonName()] = alt_signers[2].account.human(); - scEnv.tx(att, ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); + scEnv.tx(att, Ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); } { // B1: disabled master key scEnv.tx(fset(alt_signers[2].account, asfDisableMaster, 0)).close(); - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[2], true, claimID, dst, alt_signers[2]); - scEnv.tx(att, ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); + scEnv.tx(att, Ter(tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR)).close(); } { // --B4: not on signer list - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[0], true, claimID, dst, signers[0]); - scEnv.tx(att, ter(tecNO_PERMISSION)).close(); + scEnv.tx(att, Ter(tecNO_PERMISSION)).close(); } { // --B5: missing sfAttestationSignerAccount field // Then submit the one with the field. Should reach quorum. - auto att = claim_attestation( + auto att = claimAttestation( scAttester, jvb, mcAlice, amt, payees[3], true, claimID, dst, alt_signers[3]); att.removeMember(sfAttestationSignerAccount.getJsonName()); - scEnv.tx(att, ter(temMALFORMED)).close(); - BEAST_EXPECT(dstStartBalance == scEnv.env_.balance(dst)); + scEnv.tx(att, Ter(temMALFORMED)).close(); + BEAST_EXPECT(dstStartBalance == scEnv.env.balance(dst)); att[sfAttestationSignerAccount.getJsonName()] = alt_signers[3].account.human(); scEnv.tx(att).close(); - BEAST_EXPECT(dstStartBalance + amt == scEnv.env_.balance(dst)); + BEAST_EXPECT(dstStartBalance + amt == scEnv.env.balance(dst)); } } } @@ -2319,7 +2313,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - XRPAmount const tx_fee = mcEnv.txFee(); + XRPAmount const txFee = mcEnv.txFee(); Account const a{"a"}; Account const doorA{"doorA"}; @@ -2330,58 +2324,58 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj Account const ua{"ua"}; // unfunded account we want to create - BridgeDef xrp_b{ + BridgeDef xrpB{ .doorA = doorA, .issueA = xrpIssue(), - .doorB = Account::master, + .doorB = Account::kMASTER, .issueB = xrpIssue(), .reward = XRP(1), // reward .minAccountCreate = XRP(20), // minAccountCreate .quorum = 4, // quorum .signers = signers, - .jvb = Json::nullValue}; + .jvb = json::NullValue}; - xrp_b.initBridge(mcEnv, scEnv); + xrpB.initBridge(mcEnv, scEnv); auto const amt = XRP(777); - auto const amt_plus_reward = amt + xrp_b.reward; + auto const amtPlusReward = amt + xrpB.reward; { - Balance const bal_doorA(mcEnv, doorA); - Balance const bal_a(mcEnv, a); + test::Balance const balDoorA(mcEnv, doorA); + test::Balance const balA(mcEnv, a); - mcEnv.tx(sidechain_xchain_account_create(a, xrp_b.jvb, ua, amt, xrp_b.reward)).close(); + mcEnv.tx(sidechainXchainAccountCreate(a, xrpB.jvb, ua, amt, xrpB.reward)).close(); - BEAST_EXPECT(bal_doorA.diff() == amt_plus_reward); - BEAST_EXPECT(bal_a.diff() == -(amt_plus_reward + tx_fee)); + BEAST_EXPECT(balDoorA.diff() == amtPlusReward); + BEAST_EXPECT(balA.diff() == -(amtPlusReward + txFee)); } for (int i = 0; i < signers.size(); ++i) { - auto const att = create_account_attestation( + auto const att = createAccountAttestation( signers[0].account, - xrp_b.jvb, + xrpB.jvb, a, amt, - xrp_b.reward, + xrpB.reward, signers[i].account, true, 1, ua, signers[i]); TER const expectedTER = - i < xrp_b.quorum ? tesSUCCESS : TER{tecXCHAIN_ACCOUNT_CREATE_PAST}; + i < xrpB.quorum ? tesSUCCESS : TER{tecXCHAIN_ACCOUNT_CREATE_PAST}; - scEnv.tx(att, ter(expectedTER)).close(); - if (i + 1 < xrp_b.quorum) + scEnv.tx(att, Ter(expectedTER)).close(); + if (i + 1 < xrpB.quorum) { - BEAST_EXPECT(!scEnv.env_.le(ua)); + BEAST_EXPECT(!scEnv.env.le(ua)); } else { - BEAST_EXPECT(scEnv.env_.le(ua)); + BEAST_EXPECT(scEnv.env.le(ua)); } } - BEAST_EXPECT(scEnv.env_.le(ua)); + BEAST_EXPECT(scEnv.env.le(ua)); } void @@ -2390,7 +2384,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj using namespace jtx; XRPAmount const res0 = reserve(0); - XRPAmount const tx_fee = txFee(); + XRPAmount const fee = txFee(); testcase("Claim"); @@ -2403,41 +2397,41 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); } // Claim with just one attestation signed by the Master key @@ -2448,39 +2442,31 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); scEnv - .tx(create_bridge(Account::master, jvb)) - //.tx(jtx::signers(Account::master, quorum, signers)) + .tx(createBridge(Account::kMASTER, jvb)) + //.tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[0], 1, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[0], 1, withClaim); - jtx::signer const master_signer(Account::master); + jtx::Signer const masterSigner(Account::kMASTER); scEnv - .tx(claim_attestation( - scAttester, - jvb, - mcAlice, - amt, - payees[0], - true, - claimID, - dst, - master_signer), - ter(tecXCHAIN_NO_SIGNERS_LIST)) + .tx(claimAttestation( + scAttester, jvb, mcAlice, amt, payees[0], true, claimID, dst, masterSigner), + Ter(tecXCHAIN_NO_SIGNERS_LIST)) .close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim with just one attestation signed by a regular key @@ -2492,40 +2478,32 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); scEnv - .tx(create_bridge(Account::master, jvb)) - //.tx(jtx::signers(Account::master, quorum, signers)) - .tx(jtx::regkey(Account::master, payees[0])) + .tx(createBridge(Account::kMASTER, jvb)) + //.tx(jtx::signers(Account::kMASTER, quorum, signers)) + .tx(jtx::regkey(Account::kMASTER, payees[0])) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( - scEnv, Account::master, scBob, scAlice, &payees[0], 1, withClaim); + scEnv, Account::kMASTER, scBob, scAlice, &payees[0], 1, withClaim); - jtx::signer const master_signer(payees[0]); + jtx::Signer const masterSigner(payees[0]); scEnv - .tx(claim_attestation( - scAttester, - jvb, - mcAlice, - amt, - payees[0], - true, - claimID, - dst, - master_signer), - ter(tecXCHAIN_NO_SIGNERS_LIST)) + .tx(claimAttestation( + scAttester, jvb, mcAlice, amt, payees[0], true, claimID, dst, masterSigner), + Ter(tecXCHAIN_NO_SIGNERS_LIST)) .close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim against non-existent bridge @@ -2535,27 +2513,27 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - auto jvb_unknown = bridge(mcBob, xrpIssue(), Account::master, xrpIssue()); + auto jvbUnknown = bridge(mcBob, xrpIssue(), Account::kMASTER, xrpIssue()); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb_unknown, reward, mcAlice), ter(tecNO_ENTRY)) + .tx(xchainCreateClaimId(scAlice, jvbUnknown, reward, mcAlice), Ter(tecNO_ENTRY)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb_unknown, claimID, amt, dst), ter(tecNO_ENTRY)) + mcEnv.tx(xchainCommit(mcAlice, jvbUnknown, claimID, amt, dst), Ter(tecNO_ENTRY)) .close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); scEnv - .tx(claim_attestation( + .tx(claimAttestation( scAttester, - jvb_unknown, + jvbUnknown, mcAlice, amt, payees[0], @@ -2563,19 +2541,19 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj claimID, dst, signers[0]), - ter(tecNO_ENTRY)) + Ter(tecNO_ENTRY)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb_unknown, claimID, amt, scBob), ter(tecNO_ENTRY)) + scEnv.tx(xchainClaim(scAlice, jvbUnknown, claimID, amt, scBob), Ter(tecNO_ENTRY)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim against non-existent claim id @@ -2585,37 +2563,37 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); // attest using non-existent claim id scEnv - .tx(claim_attestation( + .tx(claimAttestation( scAttester, jvb, mcAlice, amt, payees[0], true, 999, dst, signers[0]), - ter(tecXCHAIN_NO_CLAIM_ID)) + Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // claim using non-existent claim id - scEnv.tx(xchain_claim(scAlice, jvb, 999, amt, scBob), ter(tecXCHAIN_NO_CLAIM_ID)) + scEnv.tx(xchainClaim(scAlice, jvb, 999, amt, scBob), Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim against a claim id owned by another account @@ -2625,45 +2603,45 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // submit a claim transaction with the wrong account (scGw // instead of scAlice) - scEnv.tx(xchain_claim(scGw, jvb, claimID, amt, scBob), ter(tecXCHAIN_BAD_CLAIM_ID)) + scEnv.tx(xchainClaim(scGw, jvb, claimID, amt, scBob), Ter(tecXCHAIN_BAD_CLAIM_ID)) .close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } else { - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); } } @@ -2674,35 +2652,35 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); // don't send any attestations if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions scEnv - .tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim against a claim id with attestations, but not enough to @@ -2713,38 +2691,38 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); auto tooFew = quorum - 1; scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers, tooFew)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions scEnv - .tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim id of zero @@ -2754,37 +2732,36 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scAlice, payees, withClaim); scEnv .multiTx( - claim_attestations( - scAttester, jvb, mcAlice, amt, payees, true, 0, dst, signers), - ter(tecXCHAIN_NO_CLAIM_ID)) + claimAttestations(scAttester, jvb, mcAlice, amt, payees, true, 0, dst, signers), + Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, 0, amt, scBob), ter(tecXCHAIN_NO_CLAIM_ID)) + scEnv.tx(xchainClaim(scAlice, jvb, 0, amt, scBob), Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim issue that does not match the expected issue on the bridge @@ -2797,44 +2774,43 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv - .tx(xchain_claim(scAlice, jvb, claimID, scUSD(1000), scBob), ter(temBAD_AMOUNT)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, scUSD(1000), scBob), Ter(temBAD_AMOUNT)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim to a destination that does not already exist on the chain @@ -2844,41 +2820,41 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scuBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scuBob), ter(tecNO_DST)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scuBob), Ter(tecNO_DST)).close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim where the claim id owner does not have enough XRP to pay @@ -2889,47 +2865,47 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); - STAmount const huge_reward{XRP(20000)}; - BEAST_EXPECT(huge_reward > scEnv.balance(scAlice)); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); + STAmount const hugeReward{XRP(20000)}; + BEAST_EXPECT(hugeReward > scEnv.balance(scAlice)); - scEnv.tx(create_bridge(Account::master, jvb, huge_reward)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, hugeReward)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, huge_reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, hugeReward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); if (withClaim) { scEnv - .multiTx(claim_attestations( + .multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)) .close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecUNFUNDED_PAYMENT)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecUNFUNDED_PAYMENT)) .close(); } else { - auto txns = claim_attestations( + auto txns = claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers); - for (int i = 0; i < UT_XCHAIN_DEFAULT_QUORUM - 1; ++i) + for (int i = 0; i < kUT_XCHAIN_DEFAULT_QUORUM - 1; ++i) { scEnv.tx(txns[i]).close(); } @@ -2938,11 +2914,11 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // The attestation should succeed, because it adds an // attestation, but the claim should fail with insufficient // funds - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecUNFUNDED_PAYMENT)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecUNFUNDED_PAYMENT)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Claim where the claim id owner has enough XRP to pay the reward, @@ -2953,42 +2929,41 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .fund( res0 + reward, scuAlice) // just not enough because of fees .close() - .tx(xchain_create_claim_id(scuAlice, jvb, reward, mcAlice), - ter(tecINSUFFICIENT_RESERVE)) + .tx(xchainCreateClaimId(scuAlice, jvb, reward, mcAlice), + Ter(tecINSUFFICIENT_RESERVE)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); - BalanceTransfer transfer(scEnv, Account::master, scBob, scuAlice, payees, withClaim); + BalanceTransfer transfer(scEnv, Account::kMASTER, scBob, scuAlice, payees, withClaim); scEnv - .tx(claim_attestation( + .tx(claimAttestation( scAttester, jvb, mcAlice, amt, payees[0], true, claimID, dst, signers[0]), - ter(tecXCHAIN_NO_CLAIM_ID)) + Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions scEnv - .tx(xchain_claim(scuAlice, jvb, claimID, amt, scBob), - ter(tecXCHAIN_NO_CLAIM_ID)) + .tx(xchainClaim(scuAlice, jvb, claimID, amt, scBob), Ter(tecXCHAIN_NO_CLAIM_ID)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Pay to an account with deposit auth set @@ -2998,31 +2973,31 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .tx(fset("scBob", asfDepositAuth)) // set deposit auth .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); - auto txns = claim_attestations( + auto txns = claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers); - for (int i = 0; i < UT_XCHAIN_DEFAULT_QUORUM - 1; ++i) + for (int i = 0; i < kUT_XCHAIN_DEFAULT_QUORUM - 1; ++i) { scEnv.tx(txns[i]).close(); } @@ -3030,23 +3005,23 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { scEnv.tx(txns.back()).close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecNO_PERMISSION)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecNO_PERMISSION)) .close(); // the transfer failed, but check that we can still use the // claimID with a different account - Balance const scCarol_bal(scEnv, scCarol); + test::Balance const scCarolBal(scEnv, scCarol); - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scCarol)).close(); - BEAST_EXPECT(scCarol_bal.diff() == amt); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scCarol)).close(); + BEAST_EXPECT(scCarolBal.diff() == amt); } else { scEnv.tx(txns.back()).close(); - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecNO_PERMISSION)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecNO_PERMISSION)) .close(); // A way would be to remove deposit auth and resubmit the // attestations (even though the witness servers won't do @@ -3055,9 +3030,9 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj .tx(fset("scBob", 0, asfDepositAuth)) // clear deposit auth .close(); - Balance const scBob_bal(scEnv, scBob); + test::Balance const scBobBal(scEnv, scBob); scEnv.tx(txns.back()).close(); - BEAST_EXPECT(scBob_bal.diff() == amt); + BEAST_EXPECT(scBobBal.diff() == amt); } } @@ -3068,54 +3043,54 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .tx(fset("scBob", asfRequireDest)) // set dest tag .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); - auto txns = claim_attestations( + auto txns = claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers); - for (int i = 0; i < UT_XCHAIN_DEFAULT_QUORUM - 1; ++i) + for (int i = 0; i < kUT_XCHAIN_DEFAULT_QUORUM - 1; ++i) { scEnv.tx(txns[i]).close(); } if (withClaim) { scEnv.tx(txns.back()).close(); - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecDST_TAG_NEEDED)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecDST_TAG_NEEDED)) .close(); // the transfer failed, but check that we can still use the // claimID with a different account - Balance const scCarol_bal(scEnv, scCarol); + test::Balance const scCarolBal(scEnv, scCarol); - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scCarol)).close(); - BEAST_EXPECT(scCarol_bal.diff() == amt); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scCarol)).close(); + BEAST_EXPECT(scCarolBal.diff() == amt); } else { scEnv.tx(txns.back()).close(); - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob), ter(tecDST_TAG_NEEDED)) + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob), Ter(tecDST_TAG_NEEDED)) .close(); // A way would be to remove the destination tag requirement // and resubmit the attestations (even though the witness @@ -3124,10 +3099,10 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj .tx(fset("scBob", 0, asfRequireDest)) // clear dest tag .close(); - Balance const scBob_bal(scEnv, scBob); + test::Balance const scBobBal(scEnv, scBob); scEnv.tx(txns.back()).close(); - BEAST_EXPECT(scBob_bal.diff() == amt); + BEAST_EXPECT(scBobBal.diff() == amt); } } @@ -3139,34 +3114,34 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .tx(fset("scBob", asfDepositAuth)) // set deposit auth .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); // we should be able to submit the attestations, but the transfer // should not occur because dest account has deposit auth set - Balance const scBob_bal(scEnv, scBob); + test::Balance const scBobBal(scEnv, scBob); - scEnv.multiTx(claim_attestations( + scEnv.multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)); - BEAST_EXPECT(scBob_bal.diff() == STAmount(0)); + BEAST_EXPECT(scBobBal.diff() == STAmount(0)); // Check that check that we still can use the claimID to transfer // the amount to a different account - Balance const scCarol_bal(scEnv, scCarol); + test::Balance const scCarolBal(scEnv, scCarol); - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scCarol)).close(); - BEAST_EXPECT(scCarol_bal.diff() == amt); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scCarol)).close(); + BEAST_EXPECT(scCarolBal.diff() == amt); } // Claim where the amount different from what is attested to @@ -3176,41 +3151,41 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); - scEnv.multiTx(claim_attestations( + scEnv.multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // claim wrong amount scEnv - .tx(xchain_claim(scAlice, jvb, claimID, one_xrp, scBob), - ter(tecXCHAIN_CLAIM_NO_QUORUM)) + .tx(xchainClaim(scAlice, jvb, claimID, one_xrp, scBob), + Ter(tecXCHAIN_CLAIM_NO_QUORUM)) .close(); } - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); } // Verify that rewards are paid from the account that owns the claim @@ -3221,44 +3196,44 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); - Balance const scAlice_bal(scEnv, scAlice); - scEnv.multiTx(claim_attestations( + test::Balance const scAliceBal(scEnv, scAlice); + scEnv.multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)); - STAmount claim_cost = reward; + STAmount claimCost = reward; if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); - claim_cost += tx_fee; + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); + claimCost += fee; } - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); - BEAST_EXPECT(scAlice_bal.diff() == -claim_cost); // because reward % 4 == 0 + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); + BEAST_EXPECT(scAliceBal.diff() == -claimCost); // because reward % 4 == 0 } // Verify that if a reward is not evenly divisible among the reward @@ -3269,43 +3244,43 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb, tiny_reward)).close(); + mcEnv.tx(createBridge(mcDoor, jvb, tiny_reward)).close(); - scEnv.tx(create_bridge(Account::master, jvb, tiny_reward)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb, tiny_reward)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, tiny_reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, tiny_reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM, + kUT_XCHAIN_DEFAULT_QUORUM, withClaim); - Balance const scAlice_bal(scEnv, scAlice); - scEnv.multiTx(claim_attestations( + test::Balance const scAliceBal(scEnv, scAlice); + scEnv.multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)); - STAmount claim_cost = tiny_reward; + STAmount claimCost = tiny_reward; if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); - claim_cost += tx_fee; + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); + claimCost += fee; } - BEAST_EXPECT(transfer.has_happened(amt, tiny_reward_split)); - BEAST_EXPECT(scAlice_bal.diff() == -(claim_cost - tiny_reward_remainder)); + BEAST_EXPECT(transfer.hasHappened(amt, tiny_reward_split)); + BEAST_EXPECT(scAliceBal.diff() == -(claimCost - tiny_reward_remainder)); } // If a reward distribution fails for one of the reward accounts @@ -3318,45 +3293,45 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); + mcEnv.tx(createBridge(mcDoor, jvb)).close(); - std::vector alt_payees{payees.begin(), payees.end() - 1}; - alt_payees.back() = Account("inexistent"); + std::vector altPayees{payees.begin(), payees.end() - 1}; + altPayees.back() = Account("inexistent"); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM - 1, + kUT_XCHAIN_DEFAULT_QUORUM - 1, withClaim); - scEnv.multiTx(claim_attestations( - scAttester, jvb, mcAlice, amt, alt_payees, true, claimID, dst, signers)); + scEnv.multiTx(claimAttestations( + scAttester, jvb, mcAlice, amt, altPayees, true, claimID, dst, signers)); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } // this also checks that only 3 * split_reward was deducted from // scAlice (the payer account), since we passed alt_payees to // BalanceTransfer - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); } for (auto withClaim : {false, true}) @@ -3364,77 +3339,77 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj XEnv mcEnv(*this); XEnv scEnv(*this, true); - mcEnv.tx(create_bridge(mcDoor, jvb)).close(); - auto& unpaid = payees[UT_XCHAIN_DEFAULT_QUORUM - 1]; - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + mcEnv.tx(createBridge(mcDoor, jvb)).close(); + auto& unpaid = payees[kUT_XCHAIN_DEFAULT_QUORUM - 1]; + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .tx(fset(unpaid, asfDepositAuth)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); auto dst(withClaim ? std::nullopt : std::optional{scBob}); auto const amt = XRP(1000); std::uint32_t const claimID = 1; - mcEnv.tx(xchain_commit(mcAlice, jvb, claimID, amt, dst)).close(); + mcEnv.tx(xchainCommit(mcAlice, jvb, claimID, amt, dst)).close(); // balance of last signer should not change (has deposit auth) - Balance const last_signer(scEnv, unpaid); + test::Balance const lastSigner(scEnv, unpaid); // make sure all signers except the last one get the // split_reward BalanceTransfer transfer( scEnv, - Account::master, + Account::kMASTER, scBob, scAlice, &payees[0], - UT_XCHAIN_DEFAULT_QUORUM - 1, + kUT_XCHAIN_DEFAULT_QUORUM - 1, withClaim); - scEnv.multiTx(claim_attestations( + scEnv.multiTx(claimAttestations( scAttester, jvb, mcAlice, amt, payees, true, claimID, dst, signers)); if (withClaim) { - BEAST_EXPECT(transfer.has_not_happened()); + BEAST_EXPECT(transfer.hasNotHappened()); // need to submit a claim transactions - scEnv.tx(xchain_claim(scAlice, jvb, claimID, amt, scBob)).close(); + scEnv.tx(xchainClaim(scAlice, jvb, claimID, amt, scBob)).close(); } // this also checks that only 3 * split_reward was deducted from // scAlice (the payer account), since we passed payees.size() - // 1 to BalanceTransfer - BEAST_EXPECT(transfer.has_happened(amt, split_reward_quorum)); + BEAST_EXPECT(transfer.hasHappened(amt, split_reward_quorum)); // and make sure the account with deposit auth received nothing - BEAST_EXPECT(last_signer.diff() == STAmount(0)); + BEAST_EXPECT(lastSigner.diff() == STAmount(0)); } // coverage test: xchain_claim transaction with incorrect flag XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .close() - .tx(xchain_claim(scAlice, jvb, 1, XRP(1000), scBob), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)) + .tx(xchainClaim(scAlice, jvb, 1, XRP(1000), scBob), + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)) .close(); // coverage test: xchain_claim transaction with xchain feature // disabled XEnv(*this, true) - .tx(create_bridge(Account::master, jvb)) + .tx(createBridge(Account::kMASTER, jvb)) .disableFeature(featureXChainBridge) .close() - .tx(xchain_claim(scAlice, jvb, 1, XRP(1000), scBob), ter(temDISABLED)) + .tx(xchainClaim(scAlice, jvb, 1, XRP(1000), scBob), Ter(temDISABLED)) .close(); // coverage test: XChainClaim::preclaim - isLockingChain = true; XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .close() - .tx(xchain_claim(mcAlice, jvb, 1, XRP(1000), mcBob), ter(tecXCHAIN_NO_CLAIM_ID)); + .tx(xchainClaim(mcAlice, jvb, 1, XRP(1000), mcBob), Ter(tecXCHAIN_NO_CLAIM_ID)); } void @@ -3443,30 +3418,30 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj using namespace jtx; testcase("Bridge Create Account"); - XRPAmount const tx_fee = txFee(); + XRPAmount const fee = txFee(); // coverage test: transferHelper() - dst == src { XEnv scEnv(*this, true); auto const amt = XRP(111); - auto const amt_plus_reward = amt + reward; + auto const amtPlusReward = amt + reward; - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); - Balance const door(scEnv, Account::master); + test::Balance const door(scEnv, Account::kMASTER); // scEnv.tx(att_create_acct_batch1(1, amt, - // Account::master)).close(); - scEnv.multiTx(att_create_acct_vec(1, amt, Account::master, 2)).close(); + // Account::kMASTER)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, Account::kMASTER, 2)).close(); BEAST_EXPECT(!!scEnv.caClaimID(jvb, 1)); // claim id present BEAST_EXPECT(scEnv.claimCount(jvb) == 0); // claim count is one less // scEnv.tx(att_create_acct_batch2(1, amt, - // Account::master)).close(); - scEnv.multiTx(att_create_acct_vec(1, amt, Account::master, 2, 2)).close(); + // Account::kMASTER)).close(); + scEnv.multiTx(attCreateAcctVec(1, amt, Account::kMASTER, 2, 2)).close(); BEAST_EXPECT(!scEnv.caClaimID(jvb, 1)); // claim id deleted BEAST_EXPECT(scEnv.claimCount(jvb) == 1); // claim count was incremented @@ -3478,32 +3453,32 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); - Balance const carol(mcEnv, mcCarol); + test::Balance const door(mcEnv, mcDoor); + test::Balance const carol(mcEnv, mcCarol); mcEnv - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(19), reward), - ter(tecXCHAIN_INSUFF_CREATE_AMOUNT)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(19), reward), + Ter(tecXCHAIN_INSUFF_CREATE_AMOUNT)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); - BEAST_EXPECT(carol.diff() == -tx_fee); + BEAST_EXPECT(carol.diff() == -fee); } // Check that creating an account with invalid flags fails. { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(20), reward), - txflags(tfFillOrKill), - ter(temINVALID_FLAG)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(20), reward), + Txflags(tfFillOrKill), + Ter(temINVALID_FLAG)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -3514,13 +3489,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv.disableFeature(featureXChainBridge) - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(20), reward), - ter(temDISABLED)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(20), reward), + Ter(temDISABLED)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -3530,13 +3505,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(-20), reward), - ter(temBAD_AMOUNT)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(-20), reward), + Ter(temBAD_AMOUNT)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -3546,13 +3521,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(20), XRP(-1)), - ter(temBAD_AMOUNT)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(20), XRP(-1)), + Ter(temBAD_AMOUNT)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -3562,29 +3537,29 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv - .tx(sidechain_xchain_account_create(mcDoor, jvb, scuAlice, XRP(20), XRP(1)), - ter(tecXCHAIN_SELF_COMMIT)) + .tx(sidechainXchainAccountCreate(mcDoor, jvb, scuAlice, XRP(20), XRP(1)), + Ter(tecXCHAIN_SELF_COMMIT)) .close(); - BEAST_EXPECT(door.diff() == -tx_fee); + BEAST_EXPECT(door.diff() == -fee); } // Check that reward matches the amount specified in bridge { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(20))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(20))).close(); - Balance const door(mcEnv, mcDoor); + test::Balance const door(mcEnv, mcDoor); mcEnv - .tx(sidechain_xchain_account_create(mcCarol, jvb, scuAlice, XRP(20), XRP(2)), - ter(tecXCHAIN_REWARD_MISMATCH)) + .tx(sidechainXchainAccountCreate(mcCarol, jvb, scuAlice, XRP(20), XRP(2)), + Ter(tecXCHAIN_REWARD_MISMATCH)) .close(); BEAST_EXPECT(door.diff() == STAmount(0)); @@ -3596,44 +3571,44 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj { using namespace jtx; XRPAmount const res0 = reserve(0); - XRPAmount const tx_fee = txFee(); + XRPAmount const fee = txFee(); testcase("Fee dips into reserve"); // commit where the fee dips into the reserve, this should succeed XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) - .fund(res0 + one_xrp + tx_fee - drops(1), mcuAlice) + .tx(createBridge(mcDoor, jvb)) + .fund(res0 + one_xrp + fee - drops(1), mcuAlice) .close() - .tx(xchain_commit(mcuAlice, jvb, 1, one_xrp, scBob), ter(tesSUCCESS)); + .tx(xchainCommit(mcuAlice, jvb, 1, one_xrp, scBob), Ter(tesSUCCESS)); // commit where the commit amount drips into the reserve, this should // fail XEnv(*this) - .tx(create_bridge(mcDoor, jvb)) + .tx(createBridge(mcDoor, jvb)) .fund(res0 + one_xrp - drops(1), mcuAlice) .close() - .tx(xchain_commit(mcuAlice, jvb, 1, one_xrp, scBob), ter(tecUNFUNDED_PAYMENT)); + .tx(xchainCommit(mcuAlice, jvb, 1, one_xrp, scBob), Ter(tecUNFUNDED_PAYMENT)); auto const minAccountCreate = XRP(20); // account create commit where the fee dips into the reserve, // this should succeed XEnv(*this) - .tx(create_bridge(mcDoor, jvb, reward, minAccountCreate)) - .fund(res0 + tx_fee + minAccountCreate + reward - drops(1), mcuAlice) + .tx(createBridge(mcDoor, jvb, reward, minAccountCreate)) + .fund(res0 + fee + minAccountCreate + reward - drops(1), mcuAlice) .close() - .tx(sidechain_xchain_account_create(mcuAlice, jvb, scuAlice, minAccountCreate, reward), - ter(tesSUCCESS)); + .tx(sidechainXchainAccountCreate(mcuAlice, jvb, scuAlice, minAccountCreate, reward), + Ter(tesSUCCESS)); // account create commit where the commit dips into the reserve, // this should fail XEnv(*this) - .tx(create_bridge(mcDoor, jvb, reward, minAccountCreate)) + .tx(createBridge(mcDoor, jvb, reward, minAccountCreate)) .fund(res0 + minAccountCreate + reward - drops(1), mcuAlice) .close() - .tx(sidechain_xchain_account_create(mcuAlice, jvb, scuAlice, minAccountCreate, reward), - ter(tecUNFUNDED_PAYMENT)); + .tx(sidechainXchainAccountCreate(mcuAlice, jvb, scuAlice, minAccountCreate, reward), + Ter(tecUNFUNDED_PAYMENT)); } void @@ -3643,13 +3618,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj testcase("Bridge Delete Door Account"); - auto const acctDelFee{drops(XEnv(*this).env_.current()->fees().increment)}; + auto const acctDelFee{drops(XEnv(*this).env.current()->fees().increment)}; // Deleting an account that owns bridge should fail { XEnv mcEnv(*this); - mcEnv.tx(create_bridge(mcDoor, jvb, XRP(1), XRP(1))).close(); + mcEnv.tx(createBridge(mcDoor, jvb, XRP(1), XRP(1))).close(); // We don't allow an account to be deleted if its sequence // number is within 256 of the current ledger. @@ -3657,16 +3632,16 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj mcEnv.close(); // try to delete mcDoor, send funds to mcAlice - mcEnv.tx(acctdelete(mcDoor, mcAlice), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + mcEnv.tx(acctdelete(mcDoor, mcAlice), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); } // Deleting an account that owns a claim id should fail { XEnv scEnv(*this, true); - scEnv.tx(create_bridge(Account::master, jvb)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) .close() - .tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)) + .tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)) .close(); // We don't allow an account to be deleted if its sequence @@ -3675,7 +3650,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj scEnv.close(); // try to delete scAlice, send funds to scBob - scEnv.tx(acctdelete(scAlice, scBob), fee(acctDelFee), ter(tecHAS_OBLIGATIONS)); + scEnv.tx(acctdelete(scAlice, scBob), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS)); } } @@ -3691,27 +3666,27 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj std::uint32_t const claimID = 1; std::optional const dst{scBob}; auto const amt = XRP(1000); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); - scEnv.tx(xchain_create_claim_id(scAlice, jvb, reward, mcAlice)).close(); - auto jvAtt = claim_attestation( + scEnv.tx(xchainCreateClaimId(scAlice, jvb, reward, mcAlice)).close(); + auto jvAtt = claimAttestation( scAttester, jvb, mcAlice, amt, - payees[UT_XCHAIN_DEFAULT_QUORUM], + payees[kUT_XCHAIN_DEFAULT_QUORUM], true, claimID, dst, - signers[UT_XCHAIN_DEFAULT_QUORUM]); + signers[kUT_XCHAIN_DEFAULT_QUORUM]); { // Change to an invalid keytype auto k = jvAtt["PublicKey"].asString(); k.at(1) = '9'; jvAtt["PublicKey"] = k; } - scEnv.tx(jvAtt, ter(temMALFORMED)).close(); + scEnv.tx(jvAtt, Ter(temMALFORMED)).close(); } { // Create a bridge and add an create account attestation with a bad @@ -3721,27 +3696,27 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj Account const dst{scBob}; auto const amt = XRP(1000); auto const rewardAmt = XRP(1); - scEnv.tx(create_bridge(Account::master, jvb)) - .tx(jtx::signers(Account::master, quorum, signers)) + scEnv.tx(createBridge(Account::kMASTER, jvb)) + .tx(jtx::signers(Account::kMASTER, quorum, signers)) .close(); - auto jvAtt = create_account_attestation( + auto jvAtt = createAccountAttestation( scAttester, jvb, mcAlice, amt, rewardAmt, - payees[UT_XCHAIN_DEFAULT_QUORUM], + payees[kUT_XCHAIN_DEFAULT_QUORUM], true, createCount, dst, - signers[UT_XCHAIN_DEFAULT_QUORUM]); + signers[kUT_XCHAIN_DEFAULT_QUORUM]); { // Change to an invalid keytype auto k = jvAtt["PublicKey"].asString(); k.at(1) = '9'; jvAtt["PublicKey"] = k; } - scEnv.tx(jvAtt, ter(temMALFORMED)).close(); + scEnv.tx(jvAtt, Ter(temMALFORMED)).close(); } } @@ -3768,13 +3743,13 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj // ----------------------------------------------------------- // ----------------------------------------------------------- -struct XChainSim_test : public beast::unit_test::suite, public jtx::XChainBridgeObjects +struct XChainSim_test : public beast::unit_test::Suite, public jtx::XChainBridgeObjects { private: - static constexpr size_t num_signers = 5; + static constexpr size_t kNUM_SIGNERS = 5; // -------------------------------------------------- - enum class WithClaim { no, yes }; + enum class WithClaim { No, Yes }; struct Transfer { jtx::Account from; @@ -3782,9 +3757,9 @@ private: jtx::Account finaldest; STAmount amt; bool a2b; // direction of transfer - WithClaim with_claim{WithClaim::no}; + WithClaim with_claim{WithClaim::No}; uint32_t claim_id{0}; - std::array attested{}; + std::array attested{}; }; struct AccountCreate @@ -3795,7 +3770,7 @@ private: STAmount reward; bool a2b; uint32_t claim_id{0}; - std::array attested{}; + std::array attested{}; }; using ENV = XEnv; @@ -3831,50 +3806,50 @@ private: using CreateClaimVec = jtx::JValueVec; using CreateClaimMap = std::map; - ChainStateTrack(ENV& env) : env(env), tx_fee(env.env_.current()->fees().base) + ChainStateTrack(ENV& env) : env(env), tx_fee(env.env.current()->fees().base) { } void - sendAttestations(size_t signer_idx, BridgeID bridge, ClaimVec& claims) + sendAttestations(size_t signerIdx, BridgeID bridge, ClaimVec& claims) { for (auto const& c : claims) { env.tx(c).close(); - spendFee(bridge->signers[signer_idx].account); + spendFee(bridge->signers[signerIdx].account); } claims.clear(); } uint32_t - sendCreateAttestations(size_t signer_idx, BridgeID bridge, CreateClaimVec& claims) + sendCreateAttestations(size_t signerIdx, BridgeID bridge, CreateClaimVec& claims) { - size_t num_successful = 0; + size_t numSuccessful = 0; for (auto const& c : claims) { env.tx(c).close(); if (env.ter() == tesSUCCESS) { - counters[bridge].signers.push_back(signer_idx); - num_successful++; + counters[bridge].signers.push_back(signerIdx); + numSuccessful++; } - spendFee(bridge->signers[signer_idx].account); + spendFee(bridge->signers[signerIdx].account); } claims.clear(); - return num_successful; + return numSuccessful; } void sendAttestations() { - bool callback_called = false; + bool callbackCalled = false; // we have this "do {} while" loop because we want to process // all the account create which can reach quorum at this time // stamp. do { - callback_called = false; + callbackCalled = false; // cspell: ignore attns for (size_t i = 0; i < signers_attns.size(); ++i) { @@ -3883,12 +3858,12 @@ private: sendAttestations(i, bridge, claims.xfer_claims); auto& c = counters[bridge]; - auto& create_claims = claims.create_claims[c.claim_count]; - auto num_attns = create_claims.size(); - if (num_attns != 0u) + auto& createClaims = claims.create_claims[c.claim_count]; + auto numAttns = createClaims.size(); + if (numAttns != 0u) { c.num_create_attn_sent += - sendCreateAttestations(i, bridge, create_claims); + sendCreateAttestations(i, bridge, createClaims); } assert(claims.create_claims[c.claim_count].empty()); } @@ -3897,14 +3872,14 @@ private: { if (c.num_create_attn_sent >= bridge->quorum) { - callback_called = true; + callbackCalled = true; c.create_callbacks[c.claim_count](c.signers); ++c.claim_count; c.num_create_attn_sent = 0; c.signers.clear(); } } - } while (callback_called); + } while (callbackCalled); } void @@ -3986,7 +3961,7 @@ private: }; using SignerAttns = std::unordered_map; - using SignersAttns = std::array; + using SignersAttns = std::array; ENV& env; std::map accounts; @@ -3997,43 +3972,45 @@ private: struct ChainStateTracker { - ChainStateTracker(ENV& a_env, ENV& b_env) : a_(a_env), b_(b_env) + ChainStateTracker(ENV& aEnv, ENV& bEnv) : a(aEnv), b(bEnv) { } [[nodiscard]] bool verify() const { - return a_.verify() && b_.verify(); + return a.verify() && b.verify(); } void sendAttestations() { - a_.sendAttestations(); - b_.sendAttestations(); + a.sendAttestations(); + b.sendAttestations(); } void init(jtx::Account const& acct) { - a_.init(acct); - b_.init(acct); + a.init(acct); + b.init(acct); } - ChainStateTrack a_; - ChainStateTrack b_; + ChainStateTrack a; + ChainStateTrack b; }; enum class SmState { - st_initial, - st_claim_id_created, - st_attesting, - st_attested, - st_completed, - st_closed, + Initial, + ClaimIdCreated, + Attesting, + Attested, + Completed, + Closed, }; + enum class ActFlags { A2b = 1 << 0 }; + // -------------------------------------------------- template class SmBase @@ -4047,13 +4024,13 @@ private: ChainStateTrack& srcState() { - return static_cast(*this).a2b() ? st_->a_ : st_->b_; + return static_cast(*this).a2b() ? st_->a : st_->b; } ChainStateTrack& destState() { - return static_cast(*this).a2b() ? st_->b_ : st_->a_; + return static_cast(*this).a2b() ? st_->b : st_->a; } jtx::Account const& @@ -4085,28 +4062,29 @@ private: std::shared_ptr const& chainstate, BridgeDef const& bridge, AccountCreate create) - : Base(chainstate, bridge), cr(std::move(create)) + : Base(chainstate, bridge), cr_(std::move(create)) { } [[nodiscard]] bool a2b() const { - return cr.a2b; + return cr_.a2b; } uint32_t - issue_account_create() + issueAccountCreate() { ChainStateTrack& st = srcState(); jtx::Account const& srcdoor = srcDoor(); st.env - .tx(sidechain_xchain_account_create(cr.from, bridge_.jvb, cr.to, cr.amt, cr.reward)) + .tx(sidechainXchainAccountCreate( + cr_.from, bridge_.jvb, cr_.to, cr_.amt, cr_.reward)) .close(); // needed for claim_id sequence to be correct' - st.spendFee(cr.from); - st.transfer(cr.from, srcdoor, cr.amt); - st.transfer(cr.from, srcdoor, cr.reward); + st.spendFee(cr_.from); + st.transfer(cr_.from, srcdoor, cr_.amt); + st.transfer(cr_.from, srcdoor, cr_.reward); return ++st.counters[&bridge_].create_count; } @@ -4118,72 +4096,72 @@ private: // check all signers, but start at a random one size_t i = 0; - for (i = 0; i < num_signers; ++i) + for (i = 0; i < kNUM_SIGNERS; ++i) { - size_t const signer_idx = (rnd + i) % num_signers; + size_t const signerIdx = (rnd + i) % kNUM_SIGNERS; - if (!(cr.attested[signer_idx])) + if (!(cr_.attested[signerIdx])) { // enqueue one attestation for this signer - cr.attested[signer_idx] = true; + cr_.attested[signerIdx] = true; - st.signers_attns[signer_idx][&bridge_] - .create_claims[cr.claim_id - 1] - .emplace_back(create_account_attestation( - bridge_.signers[signer_idx].account, + st.signers_attns[signerIdx][&bridge_] + .create_claims[cr_.claim_id - 1] + .emplace_back(createAccountAttestation( + bridge_.signers[signerIdx].account, bridge_.jvb, - cr.from, - cr.amt, - cr.reward, - bridge_.signers[signer_idx].account, - cr.a2b, - cr.claim_id, - cr.to, - bridge_.signers[signer_idx])); + cr_.from, + cr_.amt, + cr_.reward, + bridge_.signers[signerIdx].account, + cr_.a2b, + cr_.claim_id, + cr_.to, + bridge_.signers[signerIdx])); break; } } - if (i == num_signers) + if (i == kNUM_SIGNERS) return; // did not attest auto& counters = st.counters[&bridge_]; - if (counters.create_callbacks.size() < cr.claim_id) - counters.create_callbacks.resize(cr.claim_id); + if (counters.create_callbacks.size() < cr_.claim_id) + counters.create_callbacks.resize(cr_.claim_id); - auto complete_cb = [&](std::vector const& signers) { - auto num_attestors = signers.size(); + auto completeCb = [&](std::vector const& signers) { + auto numAttestors = signers.size(); st.env.close(); - assert(num_attestors <= std::count(cr.attested.begin(), cr.attested.end(), true)); - assert(num_attestors >= bridge_.quorum); - assert(cr.claim_id - 1 == counters.claim_count); + assert(numAttestors <= std::count(cr_.attested.begin(), cr_.attested.end(), true)); + assert(numAttestors >= bridge_.quorum); + assert(cr_.claim_id - 1 == counters.claim_count); - auto r = cr.reward; - auto reward = divide(r, STAmount(num_attestors), r.asset()); + auto r = cr_.reward; + auto reward = divide(r, STAmount(numAttestors), r.asset()); for (auto i : signers) st.receive(bridge_.signers[i].account, reward); - st.spend(dstDoor(), reward, num_attestors); - st.transfer(dstDoor(), cr.to, cr.amt); - st.env.env_.memoize(cr.to); - sm_state = SmState::st_completed; + st.spend(dstDoor(), reward, numAttestors); + st.transfer(dstDoor(), cr_.to, cr_.amt); + st.env.env.memoize(cr_.to); + sm_state_ = SmState::Completed; }; - counters.create_callbacks[cr.claim_id - 1] = std::move(complete_cb); + counters.create_callbacks[cr_.claim_id - 1] = std::move(completeCb); } SmState advance(uint64_t time, uint32_t rnd) { - switch (sm_state) + switch (sm_state_) { - case SmState::st_initial: - cr.claim_id = issue_account_create(); - sm_state = SmState::st_attesting; + case SmState::Initial: + cr_.claim_id = issueAccountCreate(); + sm_state_ = SmState::Attesting; break; - case SmState::st_attesting: + case SmState::Attesting: attest(time, rnd); break; @@ -4191,15 +4169,15 @@ private: assert(0); break; - case SmState::st_completed: + case SmState::Completed: break; // will get this once } - return sm_state; + return sm_state_; } private: - SmState sm_state{SmState::st_initial}; - AccountCreate cr; + SmState sm_state_{SmState::Initial}; + AccountCreate cr_; }; // -------------------------------------------------- @@ -4212,25 +4190,25 @@ private: std::shared_ptr const& chainstate, BridgeDef const& bridge, Transfer xfer) - : Base(chainstate, bridge), xfer(std::move(xfer)) + : Base(chainstate, bridge), xfer_(std::move(xfer)) { } [[nodiscard]] bool a2b() const { - return xfer.a2b; + return xfer_.a2b; } uint32_t - create_claim_id() + createClaimId() { ChainStateTrack& st = destState(); - st.env.tx(xchain_create_claim_id(xfer.to, bridge_.jvb, bridge_.reward, xfer.from)) + st.env.tx(xchainCreateClaimId(xfer_.to, bridge_.jvb, bridge_.reward, xfer_.from)) .close(); // needed for claim_id sequence to be // correct' - st.spendFee(xfer.to); + st.spendFee(xfer_.to); return ++st.counters[&bridge_].claim_id; } @@ -4240,34 +4218,34 @@ private: ChainStateTrack& st = srcState(); jtx::Account const& srcdoor = srcDoor(); - if (xfer.amt.asset() != xrpIssue()) + if (xfer_.amt.asset() != xrpIssue()) { - st.env.tx(pay(srcdoor, xfer.from, xfer.amt)); + st.env.tx(pay(srcdoor, xfer_.from, xfer_.amt)); st.spendFee(srcdoor); } - st.env.tx(xchain_commit( - xfer.from, + st.env.tx(xchainCommit( + xfer_.from, bridge_.jvb, - xfer.claim_id, - xfer.amt, - xfer.with_claim == WithClaim::yes ? std::nullopt - : std::optional(xfer.finaldest))); - st.spendFee(xfer.from); - st.transfer(xfer.from, srcdoor, xfer.amt); + xfer_.claim_id, + xfer_.amt, + xfer_.with_claim == WithClaim::Yes ? std::nullopt + : std::optional(xfer_.finaldest))); + st.spendFee(xfer_.from); + st.transfer(xfer_.from, srcdoor, xfer_.amt); } void - distribute_reward(ChainStateTrack& st) + distributeReward(ChainStateTrack& st) { auto r = bridge_.reward; auto reward = divide(r, STAmount(bridge_.quorum), r.asset()); - for (size_t i = 0; i < num_signers; ++i) + for (size_t i = 0; i < kNUM_SIGNERS; ++i) { - if (xfer.attested[i]) + if (xfer_.attested[i]) st.receive(bridge_.signers[i].account, reward); } - st.spend(xfer.to, reward, bridge_.quorum); + st.spend(xfer_.to, reward, bridge_.quorum); } bool @@ -4276,38 +4254,37 @@ private: ChainStateTrack& st = destState(); // check all signers, but start at a random one - for (size_t i = 0; i < num_signers; ++i) + for (size_t i = 0; i < kNUM_SIGNERS; ++i) { - size_t const signer_idx = (rnd + i) % num_signers; - if (!(xfer.attested[signer_idx])) + size_t const signerIdx = (rnd + i) % kNUM_SIGNERS; + if (!(xfer_.attested[signerIdx])) { // enqueue one attestation for this signer - xfer.attested[signer_idx] = true; + xfer_.attested[signerIdx] = true; - st.signers_attns[signer_idx][&bridge_].xfer_claims.emplace_back( - claim_attestation( - bridge_.signers[signer_idx].account, - bridge_.jvb, - xfer.from, - xfer.amt, - bridge_.signers[signer_idx].account, - xfer.a2b, - xfer.claim_id, - xfer.with_claim == WithClaim::yes - ? std::nullopt - : std::optional(xfer.finaldest), - bridge_.signers[signer_idx])); + st.signers_attns[signerIdx][&bridge_].xfer_claims.emplace_back(claimAttestation( + bridge_.signers[signerIdx].account, + bridge_.jvb, + xfer_.from, + xfer_.amt, + bridge_.signers[signerIdx].account, + xfer_.a2b, + xfer_.claim_id, + xfer_.with_claim == WithClaim::Yes + ? std::nullopt + : std::optional(xfer_.finaldest), + bridge_.signers[signerIdx])); break; } } // return true if quorum was reached, false otherwise bool const quorum = - std::count(xfer.attested.begin(), xfer.attested.end(), true) >= bridge_.quorum; - if (quorum && xfer.with_claim == WithClaim::no) + std::count(xfer_.attested.begin(), xfer_.attested.end(), true) >= bridge_.quorum; + if (quorum && xfer_.with_claim == WithClaim::No) { - distribute_reward(st); - st.transfer(dstDoor(), xfer.finaldest, xfer.amt); + distributeReward(st); + st.transfer(dstDoor(), xfer_.finaldest, xfer_.amt); } return quorum; } @@ -4316,56 +4293,57 @@ private: claim() { ChainStateTrack& st = destState(); - st.env.tx(xchain_claim(xfer.to, bridge_.jvb, xfer.claim_id, xfer.amt, xfer.finaldest)); - distribute_reward(st); - st.transfer(dstDoor(), xfer.finaldest, xfer.amt); - st.spendFee(xfer.to); + st.env.tx( + xchainClaim(xfer_.to, bridge_.jvb, xfer_.claim_id, xfer_.amt, xfer_.finaldest)); + distributeReward(st); + st.transfer(dstDoor(), xfer_.finaldest, xfer_.amt); + st.spendFee(xfer_.to); } SmState advance(uint64_t time, uint32_t rnd) { - switch (sm_state) + switch (sm_state_) { - case SmState::st_initial: - xfer.claim_id = create_claim_id(); - sm_state = SmState::st_claim_id_created; + case SmState::Initial: + xfer_.claim_id = createClaimId(); + sm_state_ = SmState::ClaimIdCreated; break; - case SmState::st_claim_id_created: + case SmState::ClaimIdCreated: commit(); - sm_state = SmState::st_attesting; + sm_state_ = SmState::Attesting; break; - case SmState::st_attesting: + case SmState::Attesting: if (attest(time, rnd)) { - sm_state = xfer.with_claim == WithClaim::yes ? SmState::st_attested - : SmState::st_completed; + sm_state_ = xfer_.with_claim == WithClaim::Yes ? SmState::Attested + : SmState::Completed; } else { - sm_state = SmState::st_attesting; + sm_state_ = SmState::Attesting; } break; - case SmState::st_attested: - assert(xfer.with_claim == WithClaim::yes); + case SmState::Attested: + assert(xfer_.with_claim == WithClaim::Yes); claim(); - sm_state = SmState::st_completed; + sm_state_ = SmState::Completed; break; default: - case SmState::st_completed: + case SmState::Completed: assert(0); // should have been removed break; } - return sm_state; + return sm_state_; } private: - Transfer xfer; - SmState sm_state{SmState::st_initial}; + Transfer xfer_; + SmState sm_state_{SmState::Initial}; }; // -------------------------------------------------- @@ -4395,7 +4373,7 @@ private: public: void - runSimulation(std::shared_ptr const& st, bool verify_balances = true) + runSimulation(std::shared_ptr const& st, bool verifyBalances = true) { using namespace jtx; uint64_t time = 0; @@ -4412,7 +4390,7 @@ public: return sm.advance(time, rnd); }; auto& [t, sm] = *it; - if (t <= time && std::visit(vis, sm) == SmState::st_completed) + if (t <= time && std::visit(vis, sm) == SmState::Completed) { it = sm_.erase(it); } @@ -4426,10 +4404,10 @@ public: st->sendAttestations(); // make sure all transactions have been applied - st->a_.env.close(); - st->b_.env.close(); + st->a.env.close(); + st->b.env.close(); - if (verify_balances) + if (verifyBalances) { BEAST_EXPECT(st->verify()); } @@ -4453,15 +4431,15 @@ public: Account doorXRPLocking("doorXRPLocking"), doorUSDLocking("doorUSDLocking"), doorUSDIssuing("doorUSDIssuing"); - constexpr size_t num_acct = 10; + constexpr size_t kNUM_ACCT = 10; auto a = [&doorXRPLocking, &doorUSDLocking, &doorUSDIssuing]() { using namespace std::literals; std::vector result; - result.reserve(num_acct); - for (int i = 0; i < num_acct; ++i) + result.reserve(kNUM_ACCT); + for (int i = 0; i < kNUM_ACCT; ++i) { result.emplace_back( - "a"s + std::to_string(i), (i % 2) ? KeyType::ed25519 : KeyType::secp256k1); + "a"s + std::to_string(i), (i % 2) ? KeyType::Ed25519 : KeyType::Secp256k1); } result.emplace_back("doorXRPLocking"); doorXRPLocking = result.back(); @@ -4479,20 +4457,20 @@ public: mcEnv.fund(amt, acct); scEnv.fund(amt, acct); } - Account const USDLocking{"USDLocking"}; - IOU const usdLocking{USDLocking["USD"]}; + Account const usdLockingAcc{"USDLocking"}; + IOU const usdLocking{usdLockingAcc["USD"]}; IOU const usdIssuing{doorUSDIssuing["USD"]}; - mcEnv.fund(XRP(100000), USDLocking); + mcEnv.fund(XRP(100000), usdLockingAcc); mcEnv.close(); mcEnv.tx(trust(doorUSDLocking, usdLocking(100000))); mcEnv.close(); - mcEnv.tx(pay(USDLocking, doorUSDLocking, usdLocking(50000))); + mcEnv.tx(pay(usdLockingAcc, doorUSDLocking, usdLocking(50000))); for (int i = 0; i < a.size(); ++i) { auto& acct{a[i]}; - if (i < num_acct) + if (i < kNUM_ACCT) { mcEnv.tx(trust(acct, usdLocking(100000))); scEnv.tx(trust(acct, usdIssuing(100000))); @@ -4502,18 +4480,18 @@ public: for (auto& s : signers) st->init(s.account); - st->b_.init(Account::master); + st->b.init(Account::kMASTER); // also create some unfunded accounts - constexpr size_t num_ua = 20; + constexpr size_t kNUM_UA = 20; auto ua = []() { using namespace std::literals; std::vector result; - result.reserve(num_ua); - for (int i = 0; i < num_ua; ++i) + result.reserve(kNUM_UA); + for (int i = 0; i < kNUM_UA; ++i) { result.emplace_back( - "ua"s + std::to_string(i), (i % 2) ? KeyType::ed25519 : KeyType::secp256k1); + "ua"s + std::to_string(i), (i % 2) ? KeyType::Ed25519 : KeyType::Secp256k1); } return result; }(); @@ -4521,28 +4499,28 @@ public: // initialize a bridge from a BridgeDef auto initBridge = [&mcEnv, &scEnv, &st](BridgeDef& bd) { bd.initBridge(mcEnv, scEnv); - st->a_.spendFee(bd.doorA, 2); - st->b_.spendFee(bd.doorB, 2); + st->a.spendFee(bd.doorA, 2); + st->b.spendFee(bd.doorB, 2); }; // create XRP -> XRP bridge // ------------------------ - BridgeDef xrp_b{ + BridgeDef xrpB{ .doorA = doorXRPLocking, .issueA = xrpIssue(), - .doorB = Account::master, + .doorB = Account::kMASTER, .issueB = xrpIssue(), .reward = XRP(1), .minAccountCreate = XRP(20), .quorum = quorum, .signers = signers, - .jvb = Json::nullValue}; + .jvb = json::NullValue}; - initBridge(xrp_b); + initBridge(xrpB); // create USD -> USD bridge // ------------------------ - BridgeDef usd_b{ + BridgeDef usdB{ .doorA = doorUSDLocking, .issueA = usdLocking, .doorB = doorUSDIssuing, @@ -4551,9 +4529,9 @@ public: .minAccountCreate = XRP(20), .quorum = quorum, .signers = signers, - .jvb = Json::nullValue}; + .jvb = json::NullValue}; - initBridge(usd_b); + initBridge(usdB); // try a single account create + transfer to validate the simulation // engine. Do the transfer 8 time steps after the account create, to @@ -4562,12 +4540,12 @@ public: // ----------------------------------------------------------------- ac(0, st, - xrp_b, - {.from = a[0], .to = ua[0], .amt = XRP(777), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[0], .amt = XRP(777), .reward = xrpB.reward, .a2b = true}); xfer( 8, st, - xrp_b, + xrpB, {.from = a[0], .to = ua[0], .finaldest = a[2], .amt = XRP(3), .a2b = true}); runSimulation(st); @@ -4575,12 +4553,12 @@ public: // ----------------------------------------- ac(0, st, - xrp_b, - {.from = a[0], .to = ua[0], .amt = XRP(777), .reward = xrp_b.reward, .a2b = false}); + xrpB, + {.from = a[0], .to = ua[0], .amt = XRP(777), .reward = xrpB.reward, .a2b = false}); xfer( 8, st, - xrp_b, + xrpB, {.from = a[0], .to = ua[0], .finaldest = a[2], .amt = XRP(3), .a2b = false}); runSimulation(st); @@ -4589,53 +4567,47 @@ public: xfer( 0, st, - xrp_b, + xrpB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = XRP(6), .a2b = true, - .with_claim = WithClaim::no}); + .with_claim = WithClaim::No}); xfer( 1, st, - xrp_b, + xrpB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = XRP(8), .a2b = false, - .with_claim = WithClaim::no}); + .with_claim = WithClaim::No}); xfer( - 1, - st, - xrp_b, - {.from = a[1], .to = a[1], .finaldest = a[1], .amt = XRP(1), .a2b = true}); + 1, st, xrpB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = XRP(1), .a2b = true}); xfer( 2, st, - xrp_b, + xrpB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = XRP(3), .a2b = false}); xfer( 2, st, - xrp_b, + xrpB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = XRP(5), .a2b = false}); xfer( 2, st, - xrp_b, + xrpB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = XRP(7), .a2b = false, - .with_claim = WithClaim::no}); + .with_claim = WithClaim::No}); xfer( - 2, - st, - xrp_b, - {.from = a[1], .to = a[1], .finaldest = a[1], .amt = XRP(9), .a2b = true}); + 2, st, xrpB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = XRP(9), .a2b = true}); runSimulation(st); // run one USD transfer @@ -4643,7 +4615,7 @@ public: xfer( 0, st, - usd_b, + usdB, {.from = a[0], .to = a[1], .finaldest = a[2], .amt = usdLocking(3), .a2b = true}); runSimulation(st); @@ -4652,93 +4624,81 @@ public: xfer( 0, st, - usd_b, + usdB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = usdLocking(6), .a2b = true}); xfer( 1, st, - usd_b, + usdB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = usdIssuing(8), .a2b = false}); xfer( 1, st, - usd_b, + usdB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = usdLocking(1), .a2b = true}); xfer( 2, st, - usd_b, + usdB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = usdIssuing(3), .a2b = false}); xfer( 2, st, - usd_b, + usdB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = usdIssuing(5), .a2b = false}); xfer( 2, st, - usd_b, + usdB, {.from = a[0], .to = a[0], .finaldest = a[1], .amt = usdIssuing(7), .a2b = false}); xfer( 2, st, - usd_b, + usdB, {.from = a[1], .to = a[1], .finaldest = a[1], .amt = usdLocking(9), .a2b = true}); runSimulation(st); // run mixed transfers // ------------------- xfer( - 0, - st, - xrp_b, - {.from = a[0], .to = a[0], .finaldest = a[0], .amt = XRP(1), .a2b = true}); + 0, st, xrpB, {.from = a[0], .to = a[0], .finaldest = a[0], .amt = XRP(1), .a2b = true}); xfer( 0, st, - usd_b, + usdB, {.from = a[1], .to = a[3], .finaldest = a[3], .amt = usdIssuing(3), .a2b = false}); xfer( 0, st, - usd_b, + usdB, {.from = a[3], .to = a[2], .finaldest = a[1], .amt = usdIssuing(5), .a2b = false}); xfer( 1, st, - xrp_b, + xrpB, {.from = a[0], .to = a[0], .finaldest = a[0], .amt = XRP(4), .a2b = false}); xfer( - 1, - st, - xrp_b, - {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(8), .a2b = true}); + 1, st, xrpB, {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(8), .a2b = true}); xfer( 1, st, - usd_b, + usdB, {.from = a[4], .to = a[1], .finaldest = a[1], .amt = usdLocking(7), .a2b = true}); xfer( - 3, - st, - xrp_b, - {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(7), .a2b = true}); + 3, st, xrpB, {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(7), .a2b = true}); xfer( 3, st, - xrp_b, + xrpB, {.from = a[0], .to = a[4], .finaldest = a[3], .amt = XRP(2), .a2b = false}); xfer( - 3, - st, - xrp_b, - {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(9), .a2b = true}); + 3, st, xrpB, {.from = a[1], .to = a[1], .finaldest = a[0], .amt = XRP(9), .a2b = true}); xfer( 3, st, - usd_b, + usdB, {.from = a[3], .to = a[1], .finaldest = a[1], .amt = usdIssuing(11), .a2b = false}); runSimulation(st); @@ -4746,76 +4706,76 @@ public: // ---------------------------------------------------------- ac(0, st, - xrp_b, - {.from = a[0], .to = ua[1], .amt = XRP(301), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[1], .amt = XRP(301), .reward = xrpB.reward, .a2b = true}); ac(0, st, - xrp_b, - {.from = a[1], .to = ua[2], .amt = XRP(302), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[1], .to = ua[2], .amt = XRP(302), .reward = xrpB.reward, .a2b = true}); ac(1, st, - xrp_b, - {.from = a[0], .to = ua[3], .amt = XRP(303), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[3], .amt = XRP(303), .reward = xrpB.reward, .a2b = true}); ac(2, st, - xrp_b, - {.from = a[1], .to = ua[4], .amt = XRP(304), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[1], .to = ua[4], .amt = XRP(304), .reward = xrpB.reward, .a2b = true}); ac(3, st, - xrp_b, - {.from = a[0], .to = ua[5], .amt = XRP(305), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[5], .amt = XRP(305), .reward = xrpB.reward, .a2b = true}); ac(4, st, - xrp_b, - {.from = a[1], .to = ua[6], .amt = XRP(306), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[1], .to = ua[6], .amt = XRP(306), .reward = xrpB.reward, .a2b = true}); ac(6, st, - xrp_b, - {.from = a[0], .to = ua[7], .amt = XRP(307), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[7], .amt = XRP(307), .reward = xrpB.reward, .a2b = true}); ac(7, st, - xrp_b, - {.from = a[2], .to = ua[8], .amt = XRP(308), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[2], .to = ua[8], .amt = XRP(308), .reward = xrpB.reward, .a2b = true}); ac(9, st, - xrp_b, - {.from = a[0], .to = ua[9], .amt = XRP(309), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[9], .amt = XRP(309), .reward = xrpB.reward, .a2b = true}); ac(9, st, - xrp_b, - {.from = a[0], .to = ua[9], .amt = XRP(309), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[9], .amt = XRP(309), .reward = xrpB.reward, .a2b = true}); ac(10, st, - xrp_b, - {.from = a[0], .to = ua[10], .amt = XRP(310), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[10], .amt = XRP(310), .reward = xrpB.reward, .a2b = true}); ac(12, st, - xrp_b, - {.from = a[0], .to = ua[11], .amt = XRP(311), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[0], .to = ua[11], .amt = XRP(311), .reward = xrpB.reward, .a2b = true}); ac(12, st, - xrp_b, - {.from = a[3], .to = ua[12], .amt = XRP(312), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[3], .to = ua[12], .amt = XRP(312), .reward = xrpB.reward, .a2b = true}); ac(12, st, - xrp_b, - {.from = a[4], .to = ua[13], .amt = XRP(313), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[4], .to = ua[13], .amt = XRP(313), .reward = xrpB.reward, .a2b = true}); ac(12, st, - xrp_b, - {.from = a[3], .to = ua[14], .amt = XRP(314), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[3], .to = ua[14], .amt = XRP(314), .reward = xrpB.reward, .a2b = true}); ac(12, st, - xrp_b, - {.from = a[6], .to = ua[15], .amt = XRP(315), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[6], .to = ua[15], .amt = XRP(315), .reward = xrpB.reward, .a2b = true}); ac(13, st, - xrp_b, - {.from = a[7], .to = ua[16], .amt = XRP(316), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[7], .to = ua[16], .amt = XRP(316), .reward = xrpB.reward, .a2b = true}); ac(15, st, - xrp_b, - {.from = a[3], .to = ua[17], .amt = XRP(317), .reward = xrp_b.reward, .a2b = true}); + xrpB, + {.from = a[3], .to = ua[17], .amt = XRP(317), .reward = xrpB.reward, .a2b = true}); runSimulation(st, true); // balances verification working now. } diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index ffacc0a563..8f71d47fcf 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -14,7 +14,7 @@ namespace xrpl { -class Apply_test : public beast::unit_test::suite +class Apply_test : public beast::unit_test::Suite { public: void @@ -28,7 +28,7 @@ public: testFullyCanonicalSigs() { // Construct a payments w/out a fully-canonical tx - std::string const non_fully_canonical_tx = + std::string const nonFullyCanonicalTx = "12000022000000002400000001201B00497D9C6140000000000F6950684000000" "00000000C732103767C7B2C13AD90050A4263745E4BAB2B975417FA22E87780E1" "506DDAF21139BE74483046022100E95670988A34C4DB0FA73A8BFD6383872AF43" @@ -36,16 +36,16 @@ public: "2C2DC3AFEDBED37BBCCD97BC8C40E08F8114E25A26437D923EEF4D6D815DF9336" "8B62E6440848314BB85996936E4F595287774684DC2AC6266024BEF"; - auto ret = strUnHex(non_fully_canonical_tx); + auto ret = strUnHex(nonFullyCanonicalTx); SerialIter sitTrans(makeSlice(*ret)); // NOLINT(bugprone-unchecked-optional-access) STTx const tx = *std::make_shared(std::ref(sitTrans)); { - test::jtx::Env fully_canonical(*this, test::jtx::testable_amendments()); + test::jtx::Env fullyCanonical(*this, test::jtx::testableAmendments()); Validity const valid = checkValidity( - fully_canonical.app().getHashRouter(), tx, fully_canonical.current()->rules()) + fullyCanonical.app().getHashRouter(), tx, fullyCanonical.current()->rules()) .first; if (valid == Validity::Valid) fail("Non-Fully canonical signature was permitted"); diff --git a/src/test/basics/Buffer_test.cpp b/src/test/basics/Buffer_test.cpp index 1fd0ed9e09..816a697ca4 100644 --- a/src/test/basics/Buffer_test.cpp +++ b/src/test/basics/Buffer_test.cpp @@ -10,7 +10,7 @@ namespace xrpl::test { -struct Buffer_test : beast::unit_test::suite +struct Buffer_test : beast::unit_test::Suite { static bool sane(Buffer const& b) diff --git a/src/test/basics/DetectCrash_test.cpp b/src/test/basics/DetectCrash_test.cpp index b47975873e..311ab960ec 100644 --- a/src/test/basics/DetectCrash_test.cpp +++ b/src/test/basics/DetectCrash_test.cpp @@ -4,7 +4,7 @@ namespace xrpl::test { -struct DetectCrash_test : public beast::unit_test::suite +struct DetectCrash_test : public beast::unit_test::Suite { void testDetectCrash() diff --git a/src/test/basics/Expected_test.cpp b/src/test/basics/Expected_test.cpp index b76955f53a..c8e570835b 100644 --- a/src/test/basics/Expected_test.cpp +++ b/src/test/basics/Expected_test.cpp @@ -16,7 +16,7 @@ namespace xrpl::test { -struct Expected_test : beast::unit_test::suite +struct Expected_test : beast::unit_test::Suite { void run() override diff --git a/src/test/basics/FileUtilities_test.cpp b/src/test/basics/FileUtilities_test.cpp index b427e800ec..959d3ca695 100644 --- a/src/test/basics/FileUtilities_test.cpp +++ b/src/test/basics/FileUtilities_test.cpp @@ -9,7 +9,7 @@ namespace xrpl { -class FileUtilities_test : public beast::unit_test::suite +class FileUtilities_test : public beast::unit_test::Suite { public: void @@ -18,7 +18,7 @@ public: using namespace xrpl::detail; using namespace boost::system; - constexpr char const* expectedContents = "This file is very short. That's all we need."; + constexpr char const* kEXPECTED_CONTENTS = "This file is very short. That's all we need."; FileDirGuard const file( *this, "test_file", "test.txt", "This is temporary text that should get overwritten"); @@ -26,21 +26,21 @@ public: error_code ec; auto const path = file.file(); - writeFileContents(ec, path, expectedContents); + writeFileContents(ec, path, kEXPECTED_CONTENTS); BEAST_EXPECT(!ec); { // Test with no max auto const good = getFileContents(ec, path); BEAST_EXPECT(!ec); - BEAST_EXPECT(good == expectedContents); + BEAST_EXPECT(good == kEXPECTED_CONTENTS); } { // Test with large max auto const good = getFileContents(ec, path, kilobytes(1)); BEAST_EXPECT(!ec); - BEAST_EXPECT(good == expectedContents); + BEAST_EXPECT(good == kEXPECTED_CONTENTS); } { diff --git a/src/test/basics/IOUAmount_test.cpp b/src/test/basics/IOUAmount_test.cpp index 5c01445e31..738990aac2 100644 --- a/src/test/basics/IOUAmount_test.cpp +++ b/src/test/basics/IOUAmount_test.cpp @@ -9,7 +9,7 @@ namespace xrpl { -class IOUAmount_test : public beast::unit_test::suite +class IOUAmount_test : public beast::unit_test::Suite { public: void @@ -23,18 +23,18 @@ public: BEAST_EXPECT(z.exponent() == -100); BEAST_EXPECT(!z); BEAST_EXPECT(z.signum() == 0); - BEAST_EXPECT(z == beast::zero); + BEAST_EXPECT(z == beast::kZERO); BEAST_EXPECT((z + z) == z); BEAST_EXPECT((z - z) == z); BEAST_EXPECT(z == -z); - IOUAmount const zz(beast::zero); + IOUAmount const zz(beast::kZERO); BEAST_EXPECT(z == zz); // https://github.com/XRPLF/rippled/issues/5170 IOUAmount const zzz{}; - BEAST_EXPECT(zzz == beast::zero); + BEAST_EXPECT(zzz == beast::kZERO); // BEAST_EXPECT(zzz == zz); } @@ -58,32 +58,32 @@ public: { testcase("beast::Zero Comparisons"); - using beast::zero; + using beast::kZERO; { - IOUAmount const z(zero); - BEAST_EXPECT(z == zero); - BEAST_EXPECT(z >= zero); - BEAST_EXPECT(z <= zero); - unexpected(z != zero); - unexpected(z > zero); - unexpected(z < zero); + IOUAmount const z(kZERO); + BEAST_EXPECT(z == kZERO); + BEAST_EXPECT(z >= kZERO); + BEAST_EXPECT(z <= kZERO); + unexpected(z != kZERO); + unexpected(z > kZERO); + unexpected(z < kZERO); } { IOUAmount const neg(-2, 0); - BEAST_EXPECT(neg < zero); - BEAST_EXPECT(neg <= zero); - BEAST_EXPECT(neg != zero); - unexpected(neg == zero); + BEAST_EXPECT(neg < kZERO); + BEAST_EXPECT(neg <= kZERO); + BEAST_EXPECT(neg != kZERO); + unexpected(neg == kZERO); } { IOUAmount const pos(2, 0); - BEAST_EXPECT(pos > zero); - BEAST_EXPECT(pos >= zero); - BEAST_EXPECT(pos != zero); - unexpected(pos == zero); + BEAST_EXPECT(pos > kZERO); + BEAST_EXPECT(pos >= kZERO); + BEAST_EXPECT(pos != kZERO); + unexpected(pos == kZERO); } } @@ -157,7 +157,7 @@ public: }; for (auto const mantissaSize : - {MantissaRange::mantissa_scale::small, MantissaRange::mantissa_scale::large}) + {MantissaRange::MantissaScale::Small, MantissaRange::MantissaScale::Large}) { NumberMantissaScaleGuard const mg(mantissaSize); @@ -179,68 +179,68 @@ public: testcase("mulRatio"); /* The range for the mantissa when normalized */ - constexpr std::int64_t minMantissa = 1000000000000000ull; - constexpr std::int64_t maxMantissa = 9999999999999999ull; + constexpr std::int64_t kMIN_MANTISSA = 1000000000000000ull; + constexpr std::int64_t kMAX_MANTISSA = 9999999999999999ull; // log(2,maxMantissa) ~ 53.15 /* The range for the exponent when normalized */ - constexpr int minExponent = -96; - constexpr int maxExponent = 80; - constexpr auto maxUInt = std::numeric_limits::max(); + constexpr int kMIN_EXPONENT = -96; + constexpr int kMAX_EXPONENT = 80; + constexpr auto kMAX_U_INT = std::numeric_limits::max(); { // multiply by a number that would overflow the mantissa, then // divide by the same number, and check we didn't lose any value - IOUAmount const bigMan(maxMantissa, 0); - BEAST_EXPECT(bigMan == mulRatio(bigMan, maxUInt, maxUInt, true)); + IOUAmount const bigMan(kMAX_MANTISSA, 0); + BEAST_EXPECT(bigMan == mulRatio(bigMan, kMAX_U_INT, kMAX_U_INT, true)); // rounding mode shouldn't matter as the result is exact - BEAST_EXPECT(bigMan == mulRatio(bigMan, maxUInt, maxUInt, false)); + BEAST_EXPECT(bigMan == mulRatio(bigMan, kMAX_U_INT, kMAX_U_INT, false)); } { // Similar test as above, but for negative values - IOUAmount const bigMan(-maxMantissa, 0); - BEAST_EXPECT(bigMan == mulRatio(bigMan, maxUInt, maxUInt, true)); + IOUAmount const bigMan(-kMAX_MANTISSA, 0); + BEAST_EXPECT(bigMan == mulRatio(bigMan, kMAX_U_INT, kMAX_U_INT, true)); // rounding mode shouldn't matter as the result is exact - BEAST_EXPECT(bigMan == mulRatio(bigMan, maxUInt, maxUInt, false)); + BEAST_EXPECT(bigMan == mulRatio(bigMan, kMAX_U_INT, kMAX_U_INT, false)); } { // small amounts - IOUAmount const tiny(minMantissa, minExponent); + IOUAmount const tiny(kMIN_MANTISSA, kMIN_EXPONENT); // Round up should give the smallest allowable number - BEAST_EXPECT(tiny == mulRatio(tiny, 1, maxUInt, true)); - BEAST_EXPECT(tiny == mulRatio(tiny, maxUInt - 1, maxUInt, true)); + BEAST_EXPECT(tiny == mulRatio(tiny, 1, kMAX_U_INT, true)); + BEAST_EXPECT(tiny == mulRatio(tiny, kMAX_U_INT - 1, kMAX_U_INT, true)); // rounding down should be zero - BEAST_EXPECT(beast::zero == mulRatio(tiny, 1, maxUInt, false)); - BEAST_EXPECT(beast::zero == mulRatio(tiny, maxUInt - 1, maxUInt, false)); + BEAST_EXPECT(beast::kZERO == mulRatio(tiny, 1, kMAX_U_INT, false)); + BEAST_EXPECT(beast::kZERO == mulRatio(tiny, kMAX_U_INT - 1, kMAX_U_INT, false)); // tiny negative numbers - IOUAmount const tinyNeg(-minMantissa, minExponent); + IOUAmount const tinyNeg(-kMIN_MANTISSA, kMIN_EXPONENT); // Round up should give zero - BEAST_EXPECT(beast::zero == mulRatio(tinyNeg, 1, maxUInt, true)); - BEAST_EXPECT(beast::zero == mulRatio(tinyNeg, maxUInt - 1, maxUInt, true)); + BEAST_EXPECT(beast::kZERO == mulRatio(tinyNeg, 1, kMAX_U_INT, true)); + BEAST_EXPECT(beast::kZERO == mulRatio(tinyNeg, kMAX_U_INT - 1, kMAX_U_INT, true)); // rounding down should be tiny - BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, 1, maxUInt, false)); - BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, maxUInt - 1, maxUInt, false)); + BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, 1, kMAX_U_INT, false)); + BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, kMAX_U_INT - 1, kMAX_U_INT, false)); } { // rounding { IOUAmount const one(1, 0); - auto const rup = mulRatio(one, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(one, maxUInt - 1, maxUInt, false); + auto const rup = mulRatio(one, kMAX_U_INT - 1, kMAX_U_INT, true); + auto const rdown = mulRatio(one, kMAX_U_INT - 1, kMAX_U_INT, false); BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); } { - IOUAmount const big(maxMantissa, maxExponent); - auto const rup = mulRatio(big, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(big, maxUInt - 1, maxUInt, false); + IOUAmount const big(kMAX_MANTISSA, kMAX_EXPONENT); + auto const rup = mulRatio(big, kMAX_U_INT - 1, kMAX_U_INT, true); + auto const rdown = mulRatio(big, kMAX_U_INT - 1, kMAX_U_INT, false); BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); } { IOUAmount const negOne(-1, 0); - auto const rup = mulRatio(negOne, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(negOne, maxUInt - 1, maxUInt, false); + auto const rup = mulRatio(negOne, kMAX_U_INT - 1, kMAX_U_INT, true); + auto const rdown = mulRatio(negOne, kMAX_U_INT - 1, kMAX_U_INT, false); BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); } } @@ -253,7 +253,7 @@ public: { // overflow - IOUAmount big(maxMantissa, maxExponent); + IOUAmount big(kMAX_MANTISSA, kMAX_EXPONENT); except([&] { mulRatio(big, 2, 0, true); }); } } // namespace xrpl diff --git a/src/test/basics/IntrusiveShared_test.cpp b/src/test/basics/IntrusiveShared_test.cpp index 23b0c43499..50d3fab7a2 100644 --- a/src/test/basics/IntrusiveShared_test.cpp +++ b/src/test/basics/IntrusiveShared_test.cpp @@ -59,7 +59,7 @@ struct Barrier } void - arrive_and_wait() + arriveAndWait() { std::unique_lock lock(mtx); if (--count == 0) @@ -76,19 +76,19 @@ struct Barrier namespace { enum class TrackedState : std::uint8_t { - uninitialized, - alive, - partiallyDeletedStarted, - partiallyDeleted, - deletedStarted, - deleted + Uninitialized, + Alive, + PartiallyDeletedStarted, + PartiallyDeleted, + DeletedStarted, + Deleted }; class TIBase : public IntrusiveRefCounts { public: - static constexpr std::size_t maxStates = 128; - static std::array, maxStates> state; + static constexpr std::size_t kMAX_STATES = 128; + static std::array, kMAX_STATES> state; static std::atomic nextId; static TrackedState getState(int id) @@ -99,53 +99,53 @@ public: static void resetStates(bool resetCallback) { - for (int i = 0; i < maxStates; ++i) + for (int i = 0; i < kMAX_STATES; ++i) { - state[i].store(TrackedState::uninitialized, std::memory_order_release); + state[i].store(TrackedState::Uninitialized, std::memory_order_release); } nextId.store(0, std::memory_order_release); if (resetCallback) - TIBase::tracingCallback_ = [](TrackedState, std::optional) {}; + TIBase::tracingCallback = [](TrackedState, std::optional) {}; } struct ResetStatesGuard { - bool resetCallback_{false}; + bool resetCallback{false}; - ResetStatesGuard(bool resetCallback) : resetCallback_{resetCallback} + ResetStatesGuard(bool resetCallback) : resetCallback{resetCallback} { - TIBase::resetStates(resetCallback_); + TIBase::resetStates(resetCallback); } ~ResetStatesGuard() { - TIBase::resetStates(resetCallback_); + TIBase::resetStates(resetCallback); } }; - TIBase() : id_{checkoutID()} + TIBase() : id{checkoutID()} { - assert(state.size() > id_); - state[id_].store(TrackedState::alive, std::memory_order_relaxed); + assert(state.size() > id); + state[id].store(TrackedState::Alive, std::memory_order_relaxed); } ~TIBase() override { using enum TrackedState; - assert(state.size() > id_); - tracingCallback_(state[id_].load(std::memory_order_relaxed), deletedStarted); + assert(state.size() > id); + tracingCallback(state[id].load(std::memory_order_relaxed), DeletedStarted); - assert(state.size() > id_); + assert(state.size() > id); // Use relaxed memory order to try to avoid atomic operations from // adding additional memory synchronizations that may hide threading // errors in the underlying shared pointer class. - state[id_].store(deletedStarted, std::memory_order_relaxed); + state[id].store(DeletedStarted, std::memory_order_relaxed); - tracingCallback_(deletedStarted, deleted); + tracingCallback(DeletedStarted, Deleted); - assert(state.size() > id_); - state[id_].store(TrackedState::deleted, std::memory_order_relaxed); + assert(state.size() > id); + state[id].store(TrackedState::Deleted, std::memory_order_relaxed); - tracingCallback_(TrackedState::deleted, std::nullopt); + tracingCallback(TrackedState::Deleted, std::nullopt); } void @@ -153,23 +153,23 @@ public: { using enum TrackedState; - assert(state.size() > id_); - tracingCallback_(state[id_].load(std::memory_order_relaxed), partiallyDeletedStarted); + assert(state.size() > id); + tracingCallback(state[id].load(std::memory_order_relaxed), PartiallyDeletedStarted); - assert(state.size() > id_); - state[id_].store(partiallyDeletedStarted, std::memory_order_relaxed); + assert(state.size() > id); + state[id].store(PartiallyDeletedStarted, std::memory_order_relaxed); - tracingCallback_(partiallyDeletedStarted, partiallyDeleted); + tracingCallback(PartiallyDeletedStarted, PartiallyDeleted); - assert(state.size() > id_); - state[id_].store(partiallyDeleted, std::memory_order_relaxed); + assert(state.size() > id); + state[id].store(PartiallyDeleted, std::memory_order_relaxed); - tracingCallback_(partiallyDeleted, std::nullopt); + tracingCallback(PartiallyDeleted, std::nullopt); } - static std::function)> tracingCallback_; + static std::function)> tracingCallback; - int id_; + int id; private: static int @@ -179,15 +179,15 @@ private: } }; -std::array, TIBase::maxStates> TIBase::state; +std::array, TIBase::kMAX_STATES> TIBase::state; std::atomic TIBase::nextId{0}; -std::function)> TIBase::tracingCallback_ = +std::function)> TIBase::tracingCallback = [](TrackedState, std::optional) {}; } // namespace -class IntrusiveShared_test : public beast::unit_test::suite +class IntrusiveShared_test : public beast::unit_test::Suite { public: void @@ -199,17 +199,17 @@ public: TIBase::ResetStatesGuard const rsg{true}; TIBase const b; - BEAST_EXPECT(b.use_count() == 1); + BEAST_EXPECT(b.useCount() == 1); b.addWeakRef(); - BEAST_EXPECT(b.use_count() == 1); + BEAST_EXPECT(b.useCount() == 1); auto s = b.releaseStrongRef(); - BEAST_EXPECT(s == ReleaseStrongRefAction::partialDestroy); - BEAST_EXPECT(b.use_count() == 0); + BEAST_EXPECT(s == ReleaseStrongRefAction::PartialDestroy); + BEAST_EXPECT(b.useCount() == 0); TIBase const* pb = &b; partialDestructorFinished(&pb); BEAST_EXPECT(!pb); auto w = b.releaseWeakRef(); - BEAST_EXPECT(w == ReleaseWeakRefAction::destroy); + BEAST_EXPECT(w == ReleaseWeakRefAction::Destroy); } std::vector> strong; @@ -218,109 +218,109 @@ public: TIBase::ResetStatesGuard const rsg{true}; using enum TrackedState; - auto b = make_SharedIntrusive(); - auto id = b->id_; - BEAST_EXPECT(TIBase::getState(id) == alive); - BEAST_EXPECT(b->use_count() == 1); + auto b = makeSharedIntrusive(); + auto id = b->id; + BEAST_EXPECT(TIBase::getState(id) == Alive); + BEAST_EXPECT(b->useCount() == 1); for (int i = 0; i < 10; ++i) { strong.push_back(b); } b.reset(); - BEAST_EXPECT(TIBase::getState(id) == alive); + BEAST_EXPECT(TIBase::getState(id) == Alive); strong.resize(strong.size() - 1); - BEAST_EXPECT(TIBase::getState(id) == alive); + BEAST_EXPECT(TIBase::getState(id) == Alive); strong.clear(); - BEAST_EXPECT(TIBase::getState(id) == deleted); + BEAST_EXPECT(TIBase::getState(id) == Deleted); - b = make_SharedIntrusive(); - id = b->id_; - BEAST_EXPECT(TIBase::getState(id) == alive); - BEAST_EXPECT(b->use_count() == 1); + b = makeSharedIntrusive(); + id = b->id; + BEAST_EXPECT(TIBase::getState(id) == Alive); + BEAST_EXPECT(b->useCount() == 1); for (int i = 0; i < 10; ++i) { weak.emplace_back(b); - BEAST_EXPECT(b->use_count() == 1); + BEAST_EXPECT(b->useCount() == 1); } - BEAST_EXPECT(TIBase::getState(id) == alive); + BEAST_EXPECT(TIBase::getState(id) == Alive); weak.resize(weak.size() - 1); - BEAST_EXPECT(TIBase::getState(id) == alive); + BEAST_EXPECT(TIBase::getState(id) == Alive); b.reset(); - BEAST_EXPECT(TIBase::getState(id) == partiallyDeleted); + BEAST_EXPECT(TIBase::getState(id) == PartiallyDeleted); while (!weak.empty()) { weak.resize(weak.size() - 1); if (!weak.empty()) - BEAST_EXPECT(TIBase::getState(id) == partiallyDeleted); + BEAST_EXPECT(TIBase::getState(id) == PartiallyDeleted); } - BEAST_EXPECT(TIBase::getState(id) == deleted); + BEAST_EXPECT(TIBase::getState(id) == Deleted); } { TIBase::ResetStatesGuard const rsg{true}; using enum TrackedState; - auto b = make_SharedIntrusive(); - auto id = b->id_; - BEAST_EXPECT(TIBase::getState(id) == alive); + auto b = makeSharedIntrusive(); + auto id = b->id; + BEAST_EXPECT(TIBase::getState(id) == Alive); WeakIntrusive w{b}; - BEAST_EXPECT(TIBase::getState(id) == alive); + BEAST_EXPECT(TIBase::getState(id) == Alive); auto s = w.lock(); - BEAST_EXPECT(s && s->use_count() == 2); + BEAST_EXPECT(s && s->useCount() == 2); b.reset(); - BEAST_EXPECT(TIBase::getState(id) == alive); - BEAST_EXPECT(s && s->use_count() == 1); + BEAST_EXPECT(TIBase::getState(id) == Alive); + BEAST_EXPECT(s && s->useCount() == 1); s.reset(); - BEAST_EXPECT(TIBase::getState(id) == partiallyDeleted); + BEAST_EXPECT(TIBase::getState(id) == PartiallyDeleted); BEAST_EXPECT(w.expired()); s = w.lock(); // Cannot convert a weak pointer to a strong pointer if object is // already partially deleted BEAST_EXPECT(!s); w.reset(); - BEAST_EXPECT(TIBase::getState(id) == deleted); + BEAST_EXPECT(TIBase::getState(id) == Deleted); } { TIBase::ResetStatesGuard const rsg{true}; using enum TrackedState; using swu = SharedWeakUnion; - swu b = make_SharedIntrusive(); - BEAST_EXPECT(b.isStrong() && b.use_count() == 1); - auto id = b.get()->id_; - BEAST_EXPECT(TIBase::getState(id) == alive); + swu b = makeSharedIntrusive(); + BEAST_EXPECT(b.isStrong() && b.useCount() == 1); + auto id = b.get()->id; + BEAST_EXPECT(TIBase::getState(id) == Alive); swu w = b; - BEAST_EXPECT(TIBase::getState(id) == alive); - BEAST_EXPECT(w.isStrong() && b.use_count() == 2); + BEAST_EXPECT(TIBase::getState(id) == Alive); + BEAST_EXPECT(w.isStrong() && b.useCount() == 2); w.convertToWeak(); - BEAST_EXPECT(w.isWeak() && b.use_count() == 1); + BEAST_EXPECT(w.isWeak() && b.useCount() == 1); swu s = w; - BEAST_EXPECT(s.isWeak() && b.use_count() == 1); + BEAST_EXPECT(s.isWeak() && b.useCount() == 1); s.convertToStrong(); - BEAST_EXPECT(s.isStrong() && b.use_count() == 2); + BEAST_EXPECT(s.isStrong() && b.useCount() == 2); b.reset(); - BEAST_EXPECT(TIBase::getState(id) == alive); - BEAST_EXPECT(s.use_count() == 1); + BEAST_EXPECT(TIBase::getState(id) == Alive); + BEAST_EXPECT(s.useCount() == 1); BEAST_EXPECT(!w.expired()); s.reset(); - BEAST_EXPECT(TIBase::getState(id) == partiallyDeleted); + BEAST_EXPECT(TIBase::getState(id) == PartiallyDeleted); BEAST_EXPECT(w.expired()); w.convertToStrong(); // Cannot convert a weak pointer to a strong pointer if object is // already partially deleted BEAST_EXPECT(w.isWeak()); w.reset(); - BEAST_EXPECT(TIBase::getState(id) == deleted); + BEAST_EXPECT(TIBase::getState(id) == Deleted); } { // Testing SharedWeakUnion assignment operator TIBase::ResetStatesGuard const rsg{true}; - auto strong1 = make_SharedIntrusive(); - auto strong2 = make_SharedIntrusive(); + auto strong1 = makeSharedIntrusive(); + auto strong2 = makeSharedIntrusive(); - auto id1 = strong1->id_; - auto id2 = strong2->id_; + auto id1 = strong1->id; + auto id2 = strong2->id; BEAST_EXPECT(id1 != id2); @@ -337,20 +337,20 @@ public: BEAST_EXPECT(union1.isStrong()); BEAST_EXPECT(union2.isStrong()); BEAST_EXPECT(union1.get() == union2.get()); - BEAST_EXPECT(TIBase::getState(id1) == TrackedState::alive); - BEAST_EXPECT(TIBase::getState(id2) == TrackedState::alive); + BEAST_EXPECT(TIBase::getState(id1) == TrackedState::Alive); + BEAST_EXPECT(TIBase::getState(id2) == TrackedState::Alive); // 2) Test self-assignment BEAST_EXPECT(union1.isStrong()); - BEAST_EXPECT(TIBase::getState(id1) == TrackedState::alive); - int const initialRefCount = strong1->use_count(); + BEAST_EXPECT(TIBase::getState(id1) == TrackedState::Alive); + int const initialRefCount = strong1->useCount(); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wself-assign-overloaded" union1 = union1; // Self-assignment #pragma clang diagnostic pop BEAST_EXPECT(union1.isStrong()); - BEAST_EXPECT(TIBase::getState(id1) == TrackedState::alive); - BEAST_EXPECT(strong1->use_count() == initialRefCount); + BEAST_EXPECT(TIBase::getState(id1) == TrackedState::Alive); + BEAST_EXPECT(strong1->useCount() == initialRefCount); // 3) Test assignment from null union pointer union1 = SharedWeakUnion(); @@ -361,7 +361,7 @@ public: union2.reset(); union1 = union2; BEAST_EXPECT(union1.get() == nullptr); - BEAST_EXPECT(TIBase::getState(id2) == TrackedState::deleted); + BEAST_EXPECT(TIBase::getState(id2) == TrackedState::Deleted); } } @@ -381,23 +381,23 @@ public: TIBase::ResetStatesGuard const rsg{true}; - auto strong = make_SharedIntrusive(); + auto strong = makeSharedIntrusive(); WeakIntrusive weak{strong}; bool destructorRan = false; bool partialDeleteRan = false; std::latch partialDeleteStartedSyncPoint{2}; - strong->tracingCallback_ = [&](TrackedState cur, std::optional next) { + strong->tracingCallback = [&](TrackedState cur, std::optional next) { using enum TrackedState; - if (next == deletedStarted) + if (next == DeletedStarted) { // strong goes out of scope while weak is still in scope // This checks that partialDelete has run to completion // before the destructor is called. A sleep is inserted // inside the partial delete to make sure the destructor is // given an opportunity to run during partial delete. - BEAST_EXPECT(cur == partiallyDeleted); + BEAST_EXPECT(cur == PartiallyDeleted); } - if (next == partiallyDeletedStarted) + if (next == PartiallyDeletedStarted) { partialDeleteStartedSyncPoint.arrive_and_wait(); using namespace std::chrono_literals; @@ -406,12 +406,12 @@ public: // is running. The test is to make sure that doesn't happen. std::this_thread::sleep_for(800ms); } - if (next == partiallyDeleted) + if (next == PartiallyDeleted) { BEAST_EXPECT(!partialDeleteRan && !destructorRan); partialDeleteRan = true; } - if (next == deleted) + if (next == Deleted) { BEAST_EXPECT(!destructorRan); destructorRan = true; @@ -448,19 +448,19 @@ public: TIBase::ResetStatesGuard const rsg{true}; - auto strong = make_SharedIntrusive(); + auto strong = makeSharedIntrusive(); WeakIntrusive weak{strong}; bool destructorRan = false; bool partialDeleteRan = false; std::latch weakResetSyncPoint{2}; - strong->tracingCallback_ = [&](TrackedState cur, std::optional next) { + strong->tracingCallback = [&](TrackedState cur, std::optional next) { using enum TrackedState; - if (next == partiallyDeleted) + if (next == PartiallyDeleted) { BEAST_EXPECT(!partialDeleteRan && !destructorRan); partialDeleteRan = true; } - if (next == deleted) + if (next == Deleted) { BEAST_EXPECT(!destructorRan); destructorRan = true; @@ -508,12 +508,12 @@ public: auto tracingCallback = [&](TrackedState cur, std::optional next) { using enum TrackedState; auto [destructorRan, partialDeleteRan] = getDestructorState(); - if (next == partiallyDeleted) + if (next == PartiallyDeleted) { BEAST_EXPECT(!partialDeleteRan && !destructorRan); setPartialDeleteRan(); } - if (next == deleted) + if (next == Deleted) { BEAST_EXPECT(!destructorRan); setDestructorRan(); @@ -539,17 +539,17 @@ public: } return result; }; - constexpr int loopIters = 2 * 1024; - constexpr int numThreads = 16; + constexpr int kLOOP_ITERS = 2 * 1024; + constexpr int kNUM_THREADS = 16; std::vector> toClone; - Barrier loopStartSyncPoint{numThreads}; - Barrier postCreateToCloneSyncPoint{numThreads}; - Barrier postCreateVecOfPointersSyncPoint{numThreads}; + Barrier loopStartSyncPoint{kNUM_THREADS}; + Barrier postCreateToCloneSyncPoint{kNUM_THREADS}; + Barrier postCreateVecOfPointersSyncPoint{kNUM_THREADS}; auto engines = [&]() -> std::vector { std::random_device rd; std::vector result; - result.reserve(numThreads); - for (int i = 0; i < numThreads; ++i) + result.reserve(kNUM_THREADS); + for (int i = 0; i < kNUM_THREADS; ++i) result.emplace_back(rd()); return result; }(); @@ -558,10 +558,10 @@ public: // strong and weak pointers and destroys them all at once. // threadId==0 is special. auto cloneAndDestroy = [&](int threadId) { - for (int i = 0; i < loopIters; ++i) + for (int i = 0; i < kLOOP_ITERS; ++i) { // ------ Sync Point ------ - loopStartSyncPoint.arrive_and_wait(); + loopStartSyncPoint.arriveAndWait(); // only thread 0 should reset the state std::optional rsg; @@ -578,31 +578,31 @@ public: destructionState.store(0, std::memory_order_release); toClone.clear(); - toClone.resize(numThreads); - auto strong = make_SharedIntrusive(); - strong->tracingCallback_ = tracingCallback; + toClone.resize(kNUM_THREADS); + auto strong = makeSharedIntrusive(); + strong->tracingCallback = tracingCallback; std::ranges::fill(toClone, strong); } // ------ Sync Point ------ - postCreateToCloneSyncPoint.arrive_and_wait(); + postCreateToCloneSyncPoint.arriveAndWait(); auto v = createVecOfPointers(toClone[threadId], engines[threadId]); toClone[threadId].reset(); // ------ Sync Point ------ - postCreateVecOfPointersSyncPoint.arrive_and_wait(); + postCreateVecOfPointersSyncPoint.arriveAndWait(); v.clear(); } }; std::vector threads; - threads.reserve(numThreads); - for (int i = 0; i < numThreads; ++i) + threads.reserve(kNUM_THREADS); + for (int i = 0; i < kNUM_THREADS; ++i) { threads.emplace_back(cloneAndDestroy, i); } - for (int i = 0; i < numThreads; ++i) + for (int i = 0; i < kNUM_THREADS; ++i) { threads[i].join(); } @@ -642,12 +642,12 @@ public: auto tracingCallback = [&](TrackedState cur, std::optional next) { using enum TrackedState; auto [destructorRan, partialDeleteRan] = getDestructorState(); - if (next == partiallyDeleted) + if (next == PartiallyDeleted) { BEAST_EXPECT(!partialDeleteRan && !destructorRan); setPartialDeleteRan(); } - if (next == deleted) + if (next == Deleted) { BEAST_EXPECT(!destructorRan); setDestructorRan(); @@ -664,19 +664,19 @@ public: result.emplace_back(SharedIntrusive(toClone)); return result; }; - constexpr int loopIters = 2 * 1024; - constexpr int flipPointersLoopIters = 256; - constexpr int numThreads = 16; + constexpr int kLOOP_ITERS = 2 * 1024; + constexpr int kFLIP_POINTERS_LOOP_ITERS = 256; + constexpr int kNUM_THREADS = 16; std::vector> toClone; - Barrier loopStartSyncPoint{numThreads}; - Barrier postCreateToCloneSyncPoint{numThreads}; - Barrier postCreateVecOfPointersSyncPoint{numThreads}; - Barrier postFlipPointersLoopSyncPoint{numThreads}; + Barrier loopStartSyncPoint{kNUM_THREADS}; + Barrier postCreateToCloneSyncPoint{kNUM_THREADS}; + Barrier postCreateVecOfPointersSyncPoint{kNUM_THREADS}; + Barrier postFlipPointersLoopSyncPoint{kNUM_THREADS}; auto engines = [&]() -> std::vector { std::random_device rd; std::vector result; - result.reserve(numThreads); - for (int i = 0; i < numThreads; ++i) + result.reserve(kNUM_THREADS); + for (int i = 0; i < kNUM_THREADS; ++i) result.emplace_back(rd()); return result; }(); @@ -686,10 +686,10 @@ public: // changes strong pointers to weak pointers, and destroys them // all at once. auto cloneAndDestroy = [&](int threadId) { - for (int i = 0; i < loopIters; ++i) + for (int i = 0; i < kLOOP_ITERS; ++i) { // ------ Sync Point ------ - loopStartSyncPoint.arrive_and_wait(); + loopStartSyncPoint.arriveAndWait(); // only thread 0 should reset the state std::optional rsg; @@ -705,23 +705,23 @@ public: destructionState.store(0, std::memory_order_release); toClone.clear(); - toClone.resize(numThreads); - auto strong = make_SharedIntrusive(); - strong->tracingCallback_ = tracingCallback; + toClone.resize(kNUM_THREADS); + auto strong = makeSharedIntrusive(); + strong->tracingCallback = tracingCallback; std::ranges::fill(toClone, strong); } // ------ Sync Point ------ - postCreateToCloneSyncPoint.arrive_and_wait(); + postCreateToCloneSyncPoint.arriveAndWait(); auto v = createVecOfPointers(toClone[threadId], engines[threadId]); toClone[threadId].reset(); // ------ Sync Point ------ - postCreateVecOfPointersSyncPoint.arrive_and_wait(); + postCreateVecOfPointersSyncPoint.arriveAndWait(); std::uniform_int_distribution<> isStrongDist(0, 1); - for (int f = 0; f < flipPointersLoopIters; ++f) + for (int f = 0; f < kFLIP_POINTERS_LOOP_ITERS; ++f) { for (auto& p : v) { @@ -737,18 +737,18 @@ public: } // ------ Sync Point ------ - postFlipPointersLoopSyncPoint.arrive_and_wait(); + postFlipPointersLoopSyncPoint.arriveAndWait(); v.clear(); } }; std::vector threads; - threads.reserve(numThreads); - for (int i = 0; i < numThreads; ++i) + threads.reserve(kNUM_THREADS); + for (int i = 0; i < kNUM_THREADS; ++i) { threads.emplace_back(cloneAndDestroy, i); } - for (int i = 0; i < numThreads; ++i) + for (int i = 0; i < kNUM_THREADS; ++i) { threads[i].join(); } @@ -783,34 +783,34 @@ public: auto tracingCallback = [&](TrackedState cur, std::optional next) { using enum TrackedState; auto [destructorRan, partialDeleteRan] = getDestructorState(); - if (next == partiallyDeleted) + if (next == PartiallyDeleted) { BEAST_EXPECT(!partialDeleteRan && !destructorRan); setPartialDeleteRan(); } - if (next == deleted) + if (next == Deleted) { BEAST_EXPECT(!destructorRan); setDestructorRan(); } }; - constexpr int loopIters = 2 * 1024; - constexpr int lockWeakLoopIters = 256; - constexpr int numThreads = 16; + constexpr int kLOOP_ITERS = 2 * 1024; + constexpr int kLOCK_WEAK_LOOP_ITERS = 256; + constexpr int kNUM_THREADS = 16; std::vector> toLock; - Barrier loopStartSyncPoint{numThreads}; - Barrier postCreateToLockSyncPoint{numThreads}; - Barrier postLockWeakLoopSyncPoint{numThreads}; + Barrier loopStartSyncPoint{kNUM_THREADS}; + Barrier postCreateToLockSyncPoint{kNUM_THREADS}; + Barrier postLockWeakLoopSyncPoint{kNUM_THREADS}; // lockAndDestroy creates weak pointers from the strong pointer // and runs a loop that locks the weak pointer. At the end of the loop // all the pointers are destroyed all at once. auto lockAndDestroy = [&](int threadId) { - for (int i = 0; i < loopIters; ++i) + for (int i = 0; i < kLOOP_ITERS; ++i) { // ------ Sync Point ------ - loopStartSyncPoint.arrive_and_wait(); + loopStartSyncPoint.arriveAndWait(); // only thread 0 should reset the state std::optional rsg; @@ -826,19 +826,19 @@ public: destructionState.store(0, std::memory_order_release); toLock.clear(); - toLock.resize(numThreads); - auto strong = make_SharedIntrusive(); - strong->tracingCallback_ = tracingCallback; + toLock.resize(kNUM_THREADS); + auto strong = makeSharedIntrusive(); + strong->tracingCallback = tracingCallback; std::ranges::fill(toLock, strong); } // ------ Sync Point ------ - postCreateToLockSyncPoint.arrive_and_wait(); + postCreateToLockSyncPoint.arriveAndWait(); // Multiple threads all create a weak pointer from the same // strong pointer WeakIntrusive const weak{toLock[threadId]}; - for (int wi = 0; wi < lockWeakLoopIters; ++wi) + for (int wi = 0; wi < kLOCK_WEAK_LOOP_ITERS; ++wi) { BEAST_EXPECT(!weak.expired()); auto strong = weak.lock(); @@ -846,18 +846,18 @@ public: } // ------ Sync Point ------ - postLockWeakLoopSyncPoint.arrive_and_wait(); + postLockWeakLoopSyncPoint.arriveAndWait(); toLock[threadId].reset(); } }; std::vector threads; - threads.reserve(numThreads); - for (int i = 0; i < numThreads; ++i) + threads.reserve(kNUM_THREADS); + for (int i = 0; i < kNUM_THREADS; ++i) { threads.emplace_back(lockAndDestroy, i); } - for (int i = 0; i < numThreads; ++i) + for (int i = 0; i < kNUM_THREADS; ++i) { threads[i].join(); } diff --git a/src/test/basics/KeyCache_test.cpp b/src/test/basics/KeyCache_test.cpp index 2370f87f5d..e83ae4c277 100644 --- a/src/test/basics/KeyCache_test.cpp +++ b/src/test/basics/KeyCache_test.cpp @@ -10,7 +10,7 @@ namespace xrpl { -class KeyCache_test : public beast::unit_test::suite +class KeyCache_test : public beast::unit_test::Suite { public: void @@ -33,14 +33,14 @@ public: BEAST_EXPECT(c.insert("one")); BEAST_EXPECT(!c.insert("one")); BEAST_EXPECT(c.size() == 1); - BEAST_EXPECT(c.touch_if_exists("one")); + BEAST_EXPECT(c.touchIfExists("one")); ++clock; c.sweep(); BEAST_EXPECT(c.size() == 1); ++clock; c.sweep(); BEAST_EXPECT(c.size() == 0); - BEAST_EXPECT(!c.touch_if_exists("one")); + BEAST_EXPECT(!c.touchIfExists("one")); } // Insert two items, have one expire @@ -54,7 +54,7 @@ public: ++clock; c.sweep(); BEAST_EXPECT(c.size() == 2); - BEAST_EXPECT(c.touch_if_exists("two")); + BEAST_EXPECT(c.touchIfExists("two")); ++clock; c.sweep(); BEAST_EXPECT(c.size() == 1); diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index 607ae004b1..9e06d6de53 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -17,7 +17,7 @@ namespace xrpl { -class Number_test : public beast::unit_test::suite +class Number_test : public beast::unit_test::Suite { public: void @@ -37,7 +37,7 @@ public: } void - test_limits() + testLimits() { auto const scale = Number::getMantissaScale(); testcase << "test_limits " << to_string(scale); @@ -46,7 +46,7 @@ public: try { [[maybe_unused]] Number const x = - Number{false, minMantissa * 10, 32768, Number::normalized{}}; + Number{false, minMantissa * 10, 32768, Number::Normalized{}}; } catch (std::overflow_error const&) { @@ -62,32 +62,32 @@ public: }; test( - Number{false, minMantissa * 10, 32767, Number::normalized{}}, - Number{false, minMantissa, 32768, Number::normalized{}}, + Number{false, minMantissa * 10, 32767, Number::Normalized{}}, + Number{false, minMantissa, 32768, Number::Normalized{}}, __LINE__); - test(Number{false, minMantissa, -32769, Number::normalized{}}, Number{}, __LINE__); + test(Number{false, minMantissa, -32769, Number::Normalized{}}, Number{}, __LINE__); test( - Number{false, minMantissa, 32000, Number::normalized{}} * 1'000 + - Number{false, 1'500, 32000, Number::normalized{}}, - Number{false, minMantissa + 2, 32003, Number::normalized{}}, + Number{false, minMantissa, 32000, Number::Normalized{}} * 1'000 + + Number{false, 1'500, 32000, Number::Normalized{}}, + Number{false, minMantissa + 2, 32003, Number::Normalized{}}, __LINE__); // 9,223,372,036,854,775,808 test( Number{std::numeric_limits::min()}, - scale == MantissaRange::mantissa_scale::small + scale == MantissaRange::MantissaScale::Small ? Number{-9'223'372'036'854'776, 3} - : Number{true, 9'223'372'036'854'775'808ULL, 0, Number::normalized{}}, + : Number{true, 9'223'372'036'854'775'808ULL, 0, Number::Normalized{}}, __LINE__); test( Number{std::numeric_limits::min() + 1}, - scale == MantissaRange::mantissa_scale::small ? Number{-9'223'372'036'854'776, 3} - : Number{-9'223'372'036'854'775'807}, + scale == MantissaRange::MantissaScale::Small ? Number{-9'223'372'036'854'776, 3} + : Number{-9'223'372'036'854'775'807}, __LINE__); test( Number{std::numeric_limits::max()}, Number{ - scale == MantissaRange::mantissa_scale::small + scale == MantissaRange::MantissaScale::Small ? 9'223'372'036'854'776 : std::numeric_limits::max(), 18 - Number::mantissaLog()}, @@ -96,7 +96,7 @@ public: try { [[maybe_unused]] - Number const q = Number{false, minMantissa, 32767, Number::normalized{}} * 100; + Number const q = Number{false, minMantissa, 32767, Number::Normalized{}} * 100; } catch (std::overflow_error const&) { @@ -106,7 +106,7 @@ public: } void - test_add() + testAdd() { auto const scale = Number::getMantissaScale(); testcase << "test_add " << to_string(scale); @@ -146,10 +146,10 @@ public: Number{-1'000'000'000'000'065'556, -18}}, {Number{-1'000'000'000'000'000, -15}, Number{6'555'555'555'555'555, -29}, - Number{true, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{true, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{-6'555'555'555'555'555, -29}, Number{1'000'000'000'000'000, -15}, - Number{false, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{false, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{}, Number{5}, Number{5}}, {Number{5}, Number{}, Number{5}}, {Number{5'555'555'555'555'555'000, -32768}, @@ -167,25 +167,25 @@ public: Number{-1'000'000'000'000'000'066, -18}}, {Number{-1'000'000'000'000'000'000, -18}, Number{6'555'555'555'555'555'555, -35}, - Number{true, 9'999'999'999'999'999'344ULL, -19, Number::normalized{}}}, + Number{true, 9'999'999'999'999'999'344ULL, -19, Number::Normalized{}}}, {Number{-6'555'555'555'555'555'555, -35}, Number{1'000'000'000'000'000'000, -18}, - Number{false, 9'999'999'999'999'999'344ULL, -19, Number::normalized{}}}, + Number{false, 9'999'999'999'999'999'344ULL, -19, Number::Normalized{}}}, {Number{}, Number{5}, Number{5}}, {Number{5'555'555'555'555'555'555, -32768}, Number{-5'555'555'555'555'555'554, -32768}, Number{0}}, - {Number{true, 9'999'999'999'999'999'999ULL, -37, Number::normalized{}}, + {Number{true, 9'999'999'999'999'999'999ULL, -37, Number::Normalized{}}, Number{1'000'000'000'000'000'000, -18}, - Number{false, 9'999'999'999'999'999'990ULL, -19, Number::normalized{}}}, - {Number{Number::maxRep}, Number{6, -1}, Number{Number::maxRep / 10, 1}}, - {Number{Number::maxRep - 1}, Number{1, 0}, Number{Number::maxRep}}, + Number{false, 9'999'999'999'999'999'990ULL, -19, Number::Normalized{}}}, + {Number{Number::kMAX_REP}, Number{6, -1}, Number{Number::kMAX_REP / 10, 1}}, + {Number{Number::kMAX_REP - 1}, Number{1, 0}, Number{Number::kMAX_REP}}, // Test extremes { // Each Number operand rounds up, so the actual mantissa is // minMantissa - Number{false, 9'999'999'999'999'999'999ULL, 0, Number::normalized{}}, - Number{false, 9'999'999'999'999'999'999ULL, 0, Number::normalized{}}, + Number{false, 9'999'999'999'999'999'999ULL, 0, Number::Normalized{}}, + Number{false, 9'999'999'999'999'999'999ULL, 0, Number::Normalized{}}, Number{2, 19}, }, { @@ -194,9 +194,9 @@ public: // With addition using uint128_t, there's no problem. After // normalizing, the resulting mantissa ends up less than // maxRep. - Number{false, 9'999'999'999'999'999'990ULL, 0, Number::normalized{}}, - Number{false, 9'999'999'999'999'999'990ULL, 0, Number::normalized{}}, - Number{false, 1'999'999'999'999'999'998ULL, 1, Number::normalized{}}, + Number{false, 9'999'999'999'999'999'990ULL, 0, Number::Normalized{}}, + Number{false, 9'999'999'999'999'999'990ULL, 0, Number::Normalized{}}, + Number{false, 1'999'999'999'999'999'998ULL, 1, Number::Normalized{}}, }, }); auto test = [this](auto const& c) { @@ -208,7 +208,7 @@ public: BEAST_EXPECTS(result == z, ss.str()); } }; - if (scale == MantissaRange::mantissa_scale::small) + if (scale == MantissaRange::MantissaScale::Small) { test(cSmall); } @@ -220,8 +220,8 @@ public: bool caught = false; try { - Number{false, Number::maxMantissa(), 32768, Number::normalized{}} + - Number{false, Number::minMantissa(), 32767, Number::normalized{}} * 5; + Number{false, Number::maxMantissa(), 32768, Number::Normalized{}} + + Number{false, Number::minMantissa(), 32767, Number::Normalized{}} * 5; } catch (std::overflow_error const&) { @@ -232,7 +232,7 @@ public: } void - test_sub() + testSub() { auto const scale = Number::getMantissaScale(); testcase << "test_sub " << to_string(scale); @@ -259,10 +259,10 @@ public: { {Number{1'000'000'000'000'000, -15}, Number{6'555'555'555'555'555, -29}, - Number{false, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{false, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{6'555'555'555'555'555, -29}, Number{1'000'000'000'000'000, -15}, - Number{true, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{true, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{1'000'000'000'000'000, -15}, Number{1'000'000'000'000'000, -15}, Number{0}}, {Number{1'000'000'000'000'000, -15}, Number{1'000'000'000'000'001, -15}, @@ -273,10 +273,10 @@ public: // Items from cSmall expanded for the larger mantissa {Number{1'000'000'000'000'000'000, -18}, Number{6'555'555'555'555'555'555, -32}, - Number{false, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{false, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{6'555'555'555'555'555'555, -32}, Number{1'000'000'000'000'000'000, -18}, - Number{true, 9'999'999'999'999'344'444ULL, -19, Number::normalized{}}}, + Number{true, 9'999'999'999'999'344'444ULL, -19, Number::Normalized{}}}, {Number{1'000'000'000'000'000'000, -18}, Number{1'000'000'000'000'000'000, -18}, Number{0}}, @@ -286,14 +286,14 @@ public: {Number{1'000'000'000'000'000'001, -18}, Number{1'000'000'000'000'000'000, -18}, Number{1'000'000'000'000'000'000, -36}}, - {Number{Number::maxRep}, Number{6, -1}, Number{Number::maxRep - 1}}, - {Number{false, Number::maxRep + 1, 0, Number::normalized{}}, + {Number{Number::kMAX_REP}, Number{6, -1}, Number{Number::kMAX_REP - 1}}, + {Number{false, Number::kMAX_REP + 1, 0, Number::Normalized{}}, Number{1, 0}, - Number{(Number::maxRep / 10) + 1, 1}}, - {Number{false, Number::maxRep + 1, 0, Number::normalized{}}, + Number{(Number::kMAX_REP / 10) + 1, 1}}, + {Number{false, Number::kMAX_REP + 1, 0, Number::Normalized{}}, Number{3, 0}, - Number{Number::maxRep}}, - {power(2, 63), Number{3, 0}, Number{Number::maxRep}}, + Number{Number::kMAX_REP}}, + {power(2, 63), Number{3, 0}, Number{Number::kMAX_REP}}, }); auto test = [this](auto const& c) { for (auto const& [x, y, z] : c) @@ -304,7 +304,7 @@ public: BEAST_EXPECTS(result == z, ss.str()); } }; - if (scale == MantissaRange::mantissa_scale::small) + if (scale == MantissaRange::MantissaScale::Small) { test(cSmall); } @@ -315,7 +315,7 @@ public: } void - test_mul() + testMul() { auto const scale = Number::getMantissaScale(); testcase << "test_mul " << to_string(scale); @@ -331,7 +331,7 @@ public: } }; auto tests = [&](auto const& cSmall, auto const& cLarge) { - if (scale == MantissaRange::mantissa_scale::small) + if (scale == MantissaRange::MantissaScale::Small) { test(cSmall); } @@ -342,7 +342,7 @@ public: }; auto const maxMantissa = Number::maxMantissa(); - saveNumberRoundMode const save{Number::setround(Number::rounding_mode::to_nearest)}; + SaveNumberRoundMode const save{Number::setround(Number::RoundingMode::ToNearest)}; { auto const cSmall = std::to_array({ {Number{7}, Number{8}, Number{56}}, @@ -380,7 +380,7 @@ public: Number{1999999999999999862, -18}}, {Number{3214285714285706, -15}, Number{3111111111111119, -15}, - Number{false, 9'999'999'999'999'999'579ULL, -18, Number::normalized{}}}, + Number{false, 9'999'999'999'999'999'579ULL, -18, Number::Normalized{}}}, {Number{1000000000000000000, -32768}, Number{1000000000000000000, -32768}, Number{0}}, @@ -398,17 +398,17 @@ public: Number{1999999999999999999, -18}}, {Number{3214285714285714278, -18}, Number{3111111111111111119, -18}, Number{10, 0}}, // Maximum mantissa range - rounds up to 1e19 - {Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1, 38}}, // Maximum int64 range - {Number{Number::maxRep, 0}, - Number{Number::maxRep, 0}, + {Number{Number::kMAX_REP, 0}, + Number{Number::kMAX_REP, 0}, Number{85'070'591'730'234'615'85, 19}}, }); tests(cSmall, cLarge); } - Number::setround(Number::rounding_mode::towards_zero); + Number::setround(Number::RoundingMode::TowardsZero); testcase << "test_mul " << to_string(Number::getMantissaScale()) << " towards_zero"; { auto const cSmall = std::to_array( @@ -443,7 +443,7 @@ public: Number{1999999999999999861, -18}}, {Number{3214285714285706, -15}, Number{3111111111111119, -15}, - Number{false, 9999999999999999579ULL, -18, Number::normalized{}}}, + Number{false, 9999999999999999579ULL, -18, Number::Normalized{}}}, {Number{1000000000000000000, -32768}, Number{1000000000000000000, -32768}, Number{0}}, @@ -464,18 +464,18 @@ public: Number{10, 0}}, // Maximum mantissa range - rounds down to maxMantissa/10e1 // 99'999'999'999'999'999'800'000'000'000'000'000'100 - {Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, (maxMantissa / 10) - 1, 20, Number::normalized{}}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, (maxMantissa / 10) - 1, 20, Number::Normalized{}}}, // Maximum int64 range // 85'070'591'730'234'615'847'396'907'784'232'501'249 - {Number{Number::maxRep, 0}, - Number{Number::maxRep, 0}, + {Number{Number::kMAX_REP, 0}, + Number{Number::kMAX_REP, 0}, Number{85'070'591'730'234'615'84, 19}}, }); tests(cSmall, cLarge); } - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); testcase << "test_mul " << to_string(Number::getMantissaScale()) << " downward"; { auto const cSmall = std::to_array( @@ -510,7 +510,7 @@ public: Number{1999999999999999861, -18}}, {Number{3214285714285706, -15}, Number{3111111111111119, -15}, - Number{false, 9'999'999'999'999'999'579ULL, -18, Number::normalized{}}}, + Number{false, 9'999'999'999'999'999'579ULL, -18, Number::Normalized{}}}, {Number{1000000000000000000, -32768}, Number{1000000000000000000, -32768}, Number{0}}, @@ -531,18 +531,18 @@ public: Number{10, 0}}, // Maximum mantissa range - rounds down to maxMantissa/10e1 // 99'999'999'999'999'999'800'000'000'000'000'000'100 - {Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, (maxMantissa / 10) - 1, 20, Number::normalized{}}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, (maxMantissa / 10) - 1, 20, Number::Normalized{}}}, // Maximum int64 range // 85'070'591'730'234'615'847'396'907'784'232'501'249 - {Number{Number::maxRep, 0}, - Number{Number::maxRep, 0}, + {Number{Number::kMAX_REP, 0}, + Number{Number::kMAX_REP, 0}, Number{85'070'591'730'234'615'84, 19}}, }); tests(cSmall, cLarge); } - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); testcase << "test_mul " << to_string(Number::getMantissaScale()) << " upward"; { auto const cSmall = std::to_array( @@ -598,13 +598,13 @@ public: Number{1000000000000000001, -17}}, // Maximum mantissa range - rounds up to minMantissa*10 // 1e19*1e19=1e38 - {Number{false, maxMantissa, 0, Number::normalized{}}, - Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, + Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1, 38}}, // Maximum int64 range // 85'070'591'730'234'615'847'396'907'784'232'501'249 - {Number{Number::maxRep, 0}, - Number{Number::maxRep, 0}, + {Number{Number::kMAX_REP, 0}, + Number{Number::kMAX_REP, 0}, Number{85'070'591'730'234'615'85, 19}}, }); tests(cSmall, cLarge); @@ -614,8 +614,8 @@ public: bool caught = false; try { - Number{false, maxMantissa, 32768, Number::normalized{}} * - Number{false, Number::minMantissa() * 5, 32767, Number::normalized{}}; + Number{false, maxMantissa, 32768, Number::Normalized{}} * + Number{false, Number::minMantissa() * 5, 32767, Number::Normalized{}}; } catch (std::overflow_error const&) { @@ -626,7 +626,7 @@ public: } void - test_div() + testDiv() { auto const scale = Number::getMantissaScale(); testcase << "test_div " << to_string(scale); @@ -643,7 +643,7 @@ public: }; auto const maxMantissa = Number::maxMantissa(); auto tests = [&](auto const& cSmall, auto const& cLarge) { - if (scale == MantissaRange::mantissa_scale::small) + if (scale == MantissaRange::MantissaScale::Small) { test(cSmall); } @@ -652,7 +652,7 @@ public: test(cLarge); } }; - saveNumberRoundMode const save{Number::setround(Number::rounding_mode::to_nearest)}; + SaveNumberRoundMode const save{Number::setround(Number::RoundingMode::ToNearest)}; { auto const cSmall = std::to_array( {{Number{1}, Number{2}, Number{5, -1}}, @@ -684,13 +684,13 @@ public: // Items from cSmall expanded for the larger mantissa, except // duplicates. {Number{1414213562373095049, -13}, Number{1414213562373095049, -13}, Number{1}}, - {Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1'000'000'000'000'000'000}, - Number{false, maxMantissa, -18, Number::normalized{}}}}); + Number{false, maxMantissa, -18, Number::Normalized{}}}}); tests(cSmall, cLarge); } testcase << "test_div " << to_string(Number::getMantissaScale()) << " towards_zero"; - Number::setround(Number::rounding_mode::towards_zero); + Number::setround(Number::RoundingMode::TowardsZero); { auto const cSmall = std::to_array( {{Number{1}, Number{2}, Number{5, -1}}, @@ -722,13 +722,13 @@ public: // Items from cSmall expanded for the larger mantissa, except // duplicates. {Number{1414213562373095049, -13}, Number{1414213562373095049, -13}, Number{1}}, - {Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1'000'000'000'000'000'000}, - Number{false, maxMantissa, -18, Number::normalized{}}}}); + Number{false, maxMantissa, -18, Number::Normalized{}}}}); tests(cSmall, cLarge); } testcase << "test_div " << to_string(Number::getMantissaScale()) << " downward"; - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); { auto const cSmall = std::to_array( {{Number{1}, Number{2}, Number{5, -1}}, @@ -760,13 +760,13 @@ public: // Items from cSmall expanded for the larger mantissa, except // duplicates. {Number{1414213562373095049, -13}, Number{1414213562373095049, -13}, Number{1}}, - {Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1'000'000'000'000'000'000}, - Number{false, maxMantissa, -18, Number::normalized{}}}}); + Number{false, maxMantissa, -18, Number::Normalized{}}}}); tests(cSmall, cLarge); } testcase << "test_div " << to_string(Number::getMantissaScale()) << " upward"; - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); { auto const cSmall = std::to_array( {{Number{1}, Number{2}, Number{5, -1}}, @@ -798,9 +798,9 @@ public: // Items from cSmall expanded for the larger mantissa, except // duplicates. {Number{1414213562373095049, -13}, Number{1414213562373095049, -13}, Number{1}}, - {Number{false, maxMantissa, 0, Number::normalized{}}, + {Number{false, maxMantissa, 0, Number::Normalized{}}, Number{1'000'000'000'000'000'000}, - Number{false, maxMantissa, -18, Number::normalized{}}}}); + Number{false, maxMantissa, -18, Number::Normalized{}}}}); tests(cSmall, cLarge); } testcase << "test_div " << to_string(Number::getMantissaScale()) << " overflow"; @@ -817,7 +817,7 @@ public: } void - test_root() + testRoot() { auto const scale = Number::getMantissaScale(); testcase << "test_root " << to_string(scale); @@ -851,23 +851,23 @@ public: {Number{0}, 5, Number{0}}, {Number{5625, -4}, 2, Number{75, -2}}}); auto const cLarge = std::to_array({ - {Number{false, Number::maxMantissa() - 9, -1, Number::normalized{}}, + {Number{false, Number::maxMantissa() - 9, -1, Number::Normalized{}}, 2, - Number{false, 999'999'999'999'999'999, -9, Number::normalized{}}}, - {Number{false, Number::maxMantissa() - 9, 0, Number::normalized{}}, + Number{false, 999'999'999'999'999'999, -9, Number::Normalized{}}}, + {Number{false, Number::maxMantissa() - 9, 0, Number::Normalized{}}, 2, - Number{false, 3'162'277'660'168'379'330, -9, Number::normalized{}}}, - {Number{Number::maxRep}, + Number{false, 3'162'277'660'168'379'330, -9, Number::Normalized{}}}, + {Number{Number::kMAX_REP}, 2, - Number{false, 3'037'000'499'976049692, -9, Number::normalized{}}}, - {Number{Number::maxRep}, + Number{false, 3'037'000'499'976049692, -9, Number::Normalized{}}}, + {Number{Number::kMAX_REP}, 4, - Number{false, 55'108'98747006743627, -14, Number::normalized{}}}, + Number{false, 55'108'98747006743627, -14, Number::Normalized{}}}, }); test(cSmall); - if (Number::getMantissaScale() != MantissaRange::mantissa_scale::small) + if (Number::getMantissaScale() != MantissaRange::MantissaScale::Small) { - NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero); + NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); test(cLarge); } bool caught = false; @@ -893,7 +893,7 @@ public: } void - test_root2() + testRoot2() { auto const scale = Number::getMantissaScale(); testcase << "test_root2 " << to_string(scale); @@ -918,7 +918,7 @@ public: Number{5, -1}, Number{0}, Number{5625, -4}, - Number{Number::maxRep}, + Number{Number::kMAX_REP}, }); test(cSmall); bool caught = false; @@ -934,7 +934,7 @@ public: } void - test_power1() + testPower1() { testcase << "test_power1 " << to_string(Number::getMantissaScale()); using Case = std::tuple; @@ -945,14 +945,14 @@ public: {Number{-64}, 2, Number{4096}}, {Number{64}, 3, Number{262144}}, {Number{-64}, 3, Number{-262144}}, - {Number{64}, 11, Number{false, 7378697629483820646ULL, 1, Number::normalized{}}}, - {Number{-64}, 11, Number{true, 7378697629483820646ULL, 1, Number::normalized{}}}}; + {Number{64}, 11, Number{false, 7378697629483820646ULL, 1, Number::Normalized{}}}, + {Number{-64}, 11, Number{true, 7378697629483820646ULL, 1, Number::Normalized{}}}}; for (auto const& [x, y, z] : c) BEAST_EXPECT((power(x, y) == z)); } void - test_power2() + testPower2() { testcase << "test_power2 " << to_string(Number::getMantissaScale()); using Case = std::tuple; @@ -1024,11 +1024,11 @@ public: } void - test_to_integer() + testToInteger() { testcase << "test_to_integer " << to_string(Number::getMantissaScale()); using Case = std::tuple; - saveNumberRoundMode const save{Number::setround(Number::rounding_mode::to_nearest)}; + SaveNumberRoundMode const save{Number::setround(Number::RoundingMode::ToNearest)}; { Case const c[]{ {Number{0}, 0}, @@ -1065,8 +1065,8 @@ public: BEAST_EXPECT(j == y); } } - auto prev_mode = Number::setround(Number::rounding_mode::towards_zero); - BEAST_EXPECT(prev_mode == Number::rounding_mode::to_nearest); + auto prevMode = Number::setround(Number::RoundingMode::TowardsZero); + BEAST_EXPECT(prevMode == Number::RoundingMode::ToNearest); { Case const c[]{ {Number{0}, 0}, @@ -1103,8 +1103,8 @@ public: BEAST_EXPECT(j == y); } } - prev_mode = Number::setround(Number::rounding_mode::downward); - BEAST_EXPECT(prev_mode == Number::rounding_mode::towards_zero); + prevMode = Number::setround(Number::RoundingMode::Downward); + BEAST_EXPECT(prevMode == Number::RoundingMode::TowardsZero); { Case const c[]{ {Number{0}, 0}, @@ -1141,8 +1141,8 @@ public: BEAST_EXPECT(j == y); } } - prev_mode = Number::setround(Number::rounding_mode::upward); - BEAST_EXPECT(prev_mode == Number::rounding_mode::downward); + prevMode = Number::setround(Number::RoundingMode::Upward); + BEAST_EXPECT(prevMode == Number::RoundingMode::Downward); { Case const c[]{ {Number{0}, 0}, @@ -1192,7 +1192,7 @@ public: } void - test_squelch() + testSquelch() { testcase << "test_squelch " << to_string(Number::getMantissaScale()); Number const limit{1, -6}; @@ -1237,21 +1237,21 @@ public: switch (scale) { - case MantissaRange::mantissa_scale::small: + case MantissaRange::MantissaScale::Small: test(Number::min(), "1e-32753"); test(Number::max(), "9999999999999999e32768"); test(Number::lowest(), "-9999999999999999e32768"); { - NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero); + NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); auto const maxMantissa = Number::maxMantissa(); BEAST_EXPECT(maxMantissa == 9'999'999'999'999'999); test( - Number{false, (maxMantissa * 1000) + 999, -3, Number::normalized()}, + Number{false, (maxMantissa * 1000) + 999, -3, Number::Normalized()}, "9999999999999999"); test( - Number{true, (maxMantissa * 1000) + 999, -3, Number::normalized()}, + Number{true, (maxMantissa * 1000) + 999, -3, Number::Normalized()}, "-9999999999999999"); test(Number{std::numeric_limits::max(), -3}, "9223372036854775"); @@ -1266,21 +1266,21 @@ public: "9223372036854775e3"); } break; - case MantissaRange::mantissa_scale::large: + case MantissaRange::MantissaScale::Large: // Test the edges // ((exponent < -(28)) || (exponent > -(8))))) test(Number::min(), "1e-32750"); test(Number::max(), "9223372036854775807e32768"); test(Number::lowest(), "-9223372036854775807e32768"); { - NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero); + NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); auto const maxMantissa = Number::maxMantissa(); BEAST_EXPECT(maxMantissa == 9'999'999'999'999'999'999ULL); test( - Number{false, maxMantissa, 0, Number::normalized{}}, "9999999999999999990"); + Number{false, maxMantissa, 0, Number::Normalized{}}, "9999999999999999990"); test( - Number{true, maxMantissa, 0, Number::normalized{}}, "-9999999999999999990"); + Number{true, maxMantissa, 0, Number::Normalized{}}, "-9999999999999999990"); test( Number{std::numeric_limits::max(), 0}, "9223372036854775807"); @@ -1311,7 +1311,7 @@ public: } void - test_relationals() + testRelationals() { testcase << "test_relationals " << to_string(Number::getMantissaScale()); BEAST_EXPECT(!(Number{100} < Number{10})); @@ -1321,7 +1321,7 @@ public: } void - test_stream() + testStream() { testcase << "test_stream " << to_string(Number::getMantissaScale()); Number const x{100}; @@ -1331,7 +1331,7 @@ public: } void - test_inc_dec() + testIncDec() { testcase << "test_inc_dec " << to_string(Number::getMantissaScale()); Number x{100}; @@ -1344,30 +1344,30 @@ public: } void - test_toSTAmount() + testToStAmount() { NumberSO const stNumberSO{true}; Issue const issue; Number const n{7'518'783'80596, -5}; - saveNumberRoundMode const save{Number::setround(Number::rounding_mode::to_nearest)}; + SaveNumberRoundMode const save{Number::setround(Number::RoundingMode::ToNearest)}; auto res2 = STAmount{issue, n}; BEAST_EXPECT(res2 == STAmount{7518784}); - Number::setround(Number::rounding_mode::towards_zero); + Number::setround(Number::RoundingMode::TowardsZero); res2 = STAmount{issue, n}; BEAST_EXPECT(res2 == STAmount{7518783}); - Number::setround(Number::rounding_mode::downward); + Number::setround(Number::RoundingMode::Downward); res2 = STAmount{issue, n}; BEAST_EXPECT(res2 == STAmount{7518783}); - Number::setround(Number::rounding_mode::upward); + Number::setround(Number::RoundingMode::Upward); res2 = STAmount{issue, n}; BEAST_EXPECT(res2 == STAmount{7518784}); } void - test_truncate() + testTruncate() { BEAST_EXPECT(Number(25, +1).truncate() == Number(250, 0)); BEAST_EXPECT(Number(25, 0).truncate() == Number(25, 0)); @@ -1396,92 +1396,92 @@ public: // Test that rounding works as expected. testcase("Rounding"); - using NumberRoundings = std::map; + using NumberRoundings = std::map; std::map const expected{ // Positive numbers {Number{13, -1}, - {{Number::rounding_mode::to_nearest, 1}, - {Number::rounding_mode::towards_zero, 1}, - {Number::rounding_mode::downward, 1}, - {Number::rounding_mode::upward, 2}}}, + {{Number::RoundingMode::ToNearest, 1}, + {Number::RoundingMode::TowardsZero, 1}, + {Number::RoundingMode::Downward, 1}, + {Number::RoundingMode::Upward, 2}}}, {Number{23, -1}, - {{Number::rounding_mode::to_nearest, 2}, - {Number::rounding_mode::towards_zero, 2}, - {Number::rounding_mode::downward, 2}, - {Number::rounding_mode::upward, 3}}}, + {{Number::RoundingMode::ToNearest, 2}, + {Number::RoundingMode::TowardsZero, 2}, + {Number::RoundingMode::Downward, 2}, + {Number::RoundingMode::Upward, 3}}}, {Number{15, -1}, - {{Number::rounding_mode::to_nearest, 2}, - {Number::rounding_mode::towards_zero, 1}, - {Number::rounding_mode::downward, 1}, - {Number::rounding_mode::upward, 2}}}, + {{Number::RoundingMode::ToNearest, 2}, + {Number::RoundingMode::TowardsZero, 1}, + {Number::RoundingMode::Downward, 1}, + {Number::RoundingMode::Upward, 2}}}, {Number{25, -1}, - {{Number::rounding_mode::to_nearest, 2}, - {Number::rounding_mode::towards_zero, 2}, - {Number::rounding_mode::downward, 2}, - {Number::rounding_mode::upward, 3}}}, + {{Number::RoundingMode::ToNearest, 2}, + {Number::RoundingMode::TowardsZero, 2}, + {Number::RoundingMode::Downward, 2}, + {Number::RoundingMode::Upward, 3}}}, {Number{152, -2}, - {{Number::rounding_mode::to_nearest, 2}, - {Number::rounding_mode::towards_zero, 1}, - {Number::rounding_mode::downward, 1}, - {Number::rounding_mode::upward, 2}}}, + {{Number::RoundingMode::ToNearest, 2}, + {Number::RoundingMode::TowardsZero, 1}, + {Number::RoundingMode::Downward, 1}, + {Number::RoundingMode::Upward, 2}}}, {Number{252, -2}, - {{Number::rounding_mode::to_nearest, 3}, - {Number::rounding_mode::towards_zero, 2}, - {Number::rounding_mode::downward, 2}, - {Number::rounding_mode::upward, 3}}}, + {{Number::RoundingMode::ToNearest, 3}, + {Number::RoundingMode::TowardsZero, 2}, + {Number::RoundingMode::Downward, 2}, + {Number::RoundingMode::Upward, 3}}}, {Number{17, -1}, - {{Number::rounding_mode::to_nearest, 2}, - {Number::rounding_mode::towards_zero, 1}, - {Number::rounding_mode::downward, 1}, - {Number::rounding_mode::upward, 2}}}, + {{Number::RoundingMode::ToNearest, 2}, + {Number::RoundingMode::TowardsZero, 1}, + {Number::RoundingMode::Downward, 1}, + {Number::RoundingMode::Upward, 2}}}, {Number{27, -1}, - {{Number::rounding_mode::to_nearest, 3}, - {Number::rounding_mode::towards_zero, 2}, - {Number::rounding_mode::downward, 2}, - {Number::rounding_mode::upward, 3}}}, + {{Number::RoundingMode::ToNearest, 3}, + {Number::RoundingMode::TowardsZero, 2}, + {Number::RoundingMode::Downward, 2}, + {Number::RoundingMode::Upward, 3}}}, // Negative numbers {Number{-13, -1}, - {{Number::rounding_mode::to_nearest, -1}, - {Number::rounding_mode::towards_zero, -1}, - {Number::rounding_mode::downward, -2}, - {Number::rounding_mode::upward, -1}}}, + {{Number::RoundingMode::ToNearest, -1}, + {Number::RoundingMode::TowardsZero, -1}, + {Number::RoundingMode::Downward, -2}, + {Number::RoundingMode::Upward, -1}}}, {Number{-23, -1}, - {{Number::rounding_mode::to_nearest, -2}, - {Number::rounding_mode::towards_zero, -2}, - {Number::rounding_mode::downward, -3}, - {Number::rounding_mode::upward, -2}}}, + {{Number::RoundingMode::ToNearest, -2}, + {Number::RoundingMode::TowardsZero, -2}, + {Number::RoundingMode::Downward, -3}, + {Number::RoundingMode::Upward, -2}}}, {Number{-15, -1}, - {{Number::rounding_mode::to_nearest, -2}, - {Number::rounding_mode::towards_zero, -1}, - {Number::rounding_mode::downward, -2}, - {Number::rounding_mode::upward, -1}}}, + {{Number::RoundingMode::ToNearest, -2}, + {Number::RoundingMode::TowardsZero, -1}, + {Number::RoundingMode::Downward, -2}, + {Number::RoundingMode::Upward, -1}}}, {Number{-25, -1}, - {{Number::rounding_mode::to_nearest, -2}, - {Number::rounding_mode::towards_zero, -2}, - {Number::rounding_mode::downward, -3}, - {Number::rounding_mode::upward, -2}}}, + {{Number::RoundingMode::ToNearest, -2}, + {Number::RoundingMode::TowardsZero, -2}, + {Number::RoundingMode::Downward, -3}, + {Number::RoundingMode::Upward, -2}}}, {Number{-152, -2}, - {{Number::rounding_mode::to_nearest, -2}, - {Number::rounding_mode::towards_zero, -1}, - {Number::rounding_mode::downward, -2}, - {Number::rounding_mode::upward, -1}}}, + {{Number::RoundingMode::ToNearest, -2}, + {Number::RoundingMode::TowardsZero, -1}, + {Number::RoundingMode::Downward, -2}, + {Number::RoundingMode::Upward, -1}}}, {Number{-252, -2}, - {{Number::rounding_mode::to_nearest, -3}, - {Number::rounding_mode::towards_zero, -2}, - {Number::rounding_mode::downward, -3}, - {Number::rounding_mode::upward, -2}}}, + {{Number::RoundingMode::ToNearest, -3}, + {Number::RoundingMode::TowardsZero, -2}, + {Number::RoundingMode::Downward, -3}, + {Number::RoundingMode::Upward, -2}}}, {Number{-17, -1}, - {{Number::rounding_mode::to_nearest, -2}, - {Number::rounding_mode::towards_zero, -1}, - {Number::rounding_mode::downward, -2}, - {Number::rounding_mode::upward, -1}}}, + {{Number::RoundingMode::ToNearest, -2}, + {Number::RoundingMode::TowardsZero, -1}, + {Number::RoundingMode::Downward, -2}, + {Number::RoundingMode::Upward, -1}}}, {Number{-27, -1}, - {{Number::rounding_mode::to_nearest, -3}, - {Number::rounding_mode::towards_zero, -2}, - {Number::rounding_mode::downward, -3}, - {Number::rounding_mode::upward, -2}}}, + {{Number::RoundingMode::ToNearest, -3}, + {Number::RoundingMode::TowardsZero, -2}, + {Number::RoundingMode::Downward, -3}, + {Number::RoundingMode::Upward, -2}}}, }; for (auto const& [num, roundings] : expected) @@ -1509,45 +1509,45 @@ public: Number const ten{10}; BEAST_EXPECT(ten.exponent() <= 0); - if (scale == MantissaRange::mantissa_scale::small) + if (scale == MantissaRange::MantissaScale::Small) { - BEAST_EXPECT(std::numeric_limits::max() > INITIAL_XRP.drops()); - BEAST_EXPECT(Number::maxMantissa() < INITIAL_XRP.drops()); - Number const initalXrp{INITIAL_XRP}; + BEAST_EXPECT(std::numeric_limits::max() > kINITIAL_XRP.drops()); + BEAST_EXPECT(Number::maxMantissa() < kINITIAL_XRP.drops()); + Number const initalXrp{kINITIAL_XRP}; BEAST_EXPECT(initalXrp.exponent() > 0); - Number const maxInt64{Number::maxRep}; + Number const maxInt64{Number::kMAX_REP}; BEAST_EXPECT(maxInt64.exponent() > 0); // 85'070'591'730'234'615'865'843'651'857'942'052'864 - 38 digits BEAST_EXPECT((power(maxInt64, 2) == Number{85'070'591'730'234'62, 22})); - Number const max = Number{false, Number::maxMantissa(), 0, Number::normalized{}}; + Number const max = Number{false, Number::maxMantissa(), 0, Number::Normalized{}}; BEAST_EXPECT(max.exponent() <= 0); // 99'999'999'999'999'980'000'000'000'000'001 - 32 digits BEAST_EXPECT((power(max, 2) == Number{99'999'999'999'999'98, 16})); } else { - BEAST_EXPECT(std::numeric_limits::max() > INITIAL_XRP.drops()); - BEAST_EXPECT(Number::maxMantissa() > INITIAL_XRP.drops()); - Number const initalXrp{INITIAL_XRP}; + BEAST_EXPECT(std::numeric_limits::max() > kINITIAL_XRP.drops()); + BEAST_EXPECT(Number::maxMantissa() > kINITIAL_XRP.drops()); + Number const initalXrp{kINITIAL_XRP}; BEAST_EXPECT(initalXrp.exponent() <= 0); - Number const maxInt64{Number::maxRep}; + Number const maxInt64{Number::kMAX_REP}; BEAST_EXPECT(maxInt64.exponent() <= 0); // 85'070'591'730'234'615'847'396'907'784'232'501'249 - 38 digits BEAST_EXPECT((power(maxInt64, 2) == Number{85'070'591'730'234'615'85, 19})); - NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero); + NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero); auto const maxMantissa = Number::maxMantissa(); - Number const max = Number{false, maxMantissa, 0, Number::normalized{}}; + Number const max = Number{false, maxMantissa, 0, Number::Normalized{}}; BEAST_EXPECT(max.mantissa() == maxMantissa / 10); BEAST_EXPECT(max.exponent() == 1); // 99'999'999'999'999'999'800'000'000'000'000'000'100 - also 38 // digits BEAST_EXPECT( - (power(max, 2) == Number{false, (maxMantissa / 10) - 1, 20, Number::normalized{}})); + (power(max, 2) == Number{false, (maxMantissa / 10) - 1, 20, Number::Normalized{}})); } } @@ -1555,28 +1555,28 @@ public: run() override { for (auto const scale : - {MantissaRange::mantissa_scale::small, MantissaRange::mantissa_scale::large}) + {MantissaRange::MantissaScale::Small, MantissaRange::MantissaScale::Large}) { NumberMantissaScaleGuard const sg(scale); testZero(); - test_limits(); + testLimits(); testToString(); - test_add(); - test_sub(); - test_mul(); - test_div(); - test_root(); - test_root2(); - test_power1(); - test_power2(); + testAdd(); + testSub(); + testMul(); + testDiv(); + testRoot(); + testRoot2(); + testPower1(); + testPower2(); testConversions(); - test_to_integer(); - test_squelch(); - test_relationals(); - test_stream(); - test_inc_dec(); - test_toSTAmount(); - test_truncate(); + testToInteger(); + testSquelch(); + testRelationals(); + testStream(); + testIncDec(); + testToStAmount(); + testTruncate(); testRounding(); testInt64(); } diff --git a/src/test/basics/PerfLog_test.cpp b/src/test/basics/PerfLog_test.cpp index 9a7d89efce..00b2f90c65 100644 --- a/src/test/basics/PerfLog_test.cpp +++ b/src/test/basics/PerfLog_test.cpp @@ -39,24 +39,24 @@ namespace xrpl { -class PerfLog_test : public beast::unit_test::suite +class PerfLog_test : public beast::unit_test::Suite { - enum class WithFile : bool { no = false, yes = true }; + enum class WithFile : bool { No = false, Yes = true }; using path = boost::filesystem::path; // We're only using Env for its Journal. That Journal gives better // coverage in unit tests. - test::jtx::Env env_{*this, test::jtx::envconfig(), nullptr, beast::severities::kDisabled}; + test::jtx::Env env_{*this, test::jtx::envconfig(), nullptr, beast::severities::KDisabled}; beast::Journal j_{env_.app().getJournal("PerfLog_test")}; struct Fixture { - Application& app_; - beast::Journal j_; + Application& app; + beast::Journal j; bool stopSignaled{false}; - explicit Fixture(Application& app, beast::Journal j) : app_(app), j_(j) + explicit Fixture(Application& app, beast::Journal j) : app(app), j(j) { // Clean up any stale state from a previous test run. On // self-hosted CI runners the temp directory persists between @@ -116,8 +116,8 @@ class PerfLog_test : public beast::unit_test::suite perfLog(WithFile withFile) { perf::PerfLog::Setup const setup{ - .perfLog = withFile == WithFile::no ? "" : logFile(), .logInterval = logInterval()}; - return perf::make_PerfLog(setup, app_, j_, [this]() { + .perfLog = withFile == WithFile::No ? "" : logFile(), .logInterval = logInterval()}; + return perf::makePerfLog(setup, app, j, [this]() { signalStop(); return; }); @@ -154,7 +154,7 @@ class PerfLog_test : public beast::unit_test::suite // Return a uint64 from a JSON string. static std::uint64_t - jsonToUint64(Json::Value const& jsonUintAsString) + jsonToUint64(json::Value const& jsonUintAsString) { return std::stoull(jsonUintAsString.asString()); } @@ -176,11 +176,11 @@ class PerfLog_test : public beast::unit_test::suite // goes from longest to shortest duration. That way stuff that was started // earlier goes to the front. static std::vector - getSortedCurrent(Json::Value const& currentJson) + getSortedCurrent(json::Value const& currentJson) { std::vector currents; currents.reserve(currentJson.size()); - for (Json::Value const& cur : currentJson) + for (json::Value const& cur : currentJson) { currents.emplace_back( jsonToUint64(cur[jss::duration_us]), @@ -208,7 +208,7 @@ public: Fixture fixture{env_.app(), j_}; BEAST_EXPECT(!exists(fixture.logFile())); - auto perfLog{fixture.perfLog(WithFile::yes)}; + auto perfLog{fixture.perfLog(WithFile::Yes)}; BEAST_EXPECT(fixture.stopSignaled == false); BEAST_EXPECT(exists(fixture.logFile())); @@ -233,7 +233,7 @@ public: // Now construct a PerfLog. The PerfLog should attempt to shut // down the server because it can't open its file. BEAST_EXPECT(fixture.stopSignaled == false); - auto perfLog{fixture.perfLog(WithFile::yes)}; + auto perfLog{fixture.perfLog(WithFile::Yes)}; BEAST_EXPECT(fixture.stopSignaled == true); // Start PerfLog and wait long enough for PerfLog::report() @@ -284,7 +284,7 @@ public: // Now construct a PerfLog. The PerfLog should attempt to shut // down the server because it can't open its file. BEAST_EXPECT(fixture.stopSignaled == false); - auto perfLog{fixture.perfLog(WithFile::yes)}; + auto perfLog{fixture.perfLog(WithFile::Yes)}; BEAST_EXPECT(fixture.stopSignaled == true); // Start PerfLog and wait long enough for PerfLog::report() @@ -312,8 +312,8 @@ public: // Get the all the labels we can use for RPC interfaces without // causing an assert. - std::vector labels = test::jtx::make_vector(xrpl::RPC::getHandlerNames()); - std::shuffle(labels.begin(), labels.end(), default_prng()); + std::vector labels = test::jtx::makeVector(xrpl::RPC::getHandlerNames()); + std::shuffle(labels.begin(), labels.end(), defaultPrng()); // Get two IDs to associate with each label. Errors tend to happen at // boundaries, so we pick IDs starting from zero and ending at @@ -328,7 +328,7 @@ public: std::back_inserter(ids), labels.size(), [i = std::numeric_limits::max()]() mutable { return i--; }); - std::shuffle(ids.begin(), ids.end(), default_prng()); + std::shuffle(ids.begin(), ids.end(), defaultPrng()); // Start all of the RPC commands twice to show they can all be tracked // simultaneously. @@ -342,19 +342,19 @@ public: } { // Examine current PerfLog::counterJson() values. - Json::Value const countersJson{perfLog->countersJson()[jss::rpc]}; + json::Value const countersJson{perfLog->countersJson()[jss::rpc]}; BEAST_EXPECT(countersJson.size() == labels.size() + 1); for (auto& label : labels) { // Expect every label in labels to have the same contents. - Json::Value const& counter{countersJson[label]}; + json::Value const& counter{countersJson[label]}; BEAST_EXPECT(counter[jss::duration_us] == "0"); BEAST_EXPECT(counter[jss::errored] == "0"); BEAST_EXPECT(counter[jss::finished] == "0"); BEAST_EXPECT(counter[jss::started] == "2"); } // Expect "total" to have a lot of "started" - Json::Value const& total{countersJson[jss::total]}; + json::Value const& total{countersJson[jss::total]}; BEAST_EXPECT(total[jss::duration_us] == "0"); BEAST_EXPECT(total[jss::errored] == "0"); BEAST_EXPECT(total[jss::finished] == "0"); @@ -389,14 +389,14 @@ public: perfLog->rpcFinish(labels[0], ids[0 + 1]); // Note that label[0] id[0] is intentionally left unfinished. - auto validateFinalCounters = [this, &labels](Json::Value const& countersJson) { + auto validateFinalCounters = [this, &labels](json::Value const& countersJson) { { - Json::Value const& jobQueue = countersJson[jss::job_queue]; + json::Value const& jobQueue = countersJson[jss::job_queue]; BEAST_EXPECT(jobQueue.isObject()); BEAST_EXPECT(jobQueue.size() == 0); } - Json::Value const& rpc = countersJson[jss::rpc]; + json::Value const& rpc = countersJson[jss::rpc]; BEAST_EXPECT(rpc.size() == labels.size() + 1); // Verify that every entry in labels appears in rpc. @@ -404,7 +404,7 @@ public: // their durations with the appropriate labels. { // The first label is special. It should have "errored" : "0". - Json::Value const& first = rpc[labels[0]]; + json::Value const& first = rpc[labels[0]]; BEAST_EXPECT(first[jss::duration_us] != "0"); BEAST_EXPECT(first[jss::errored] == "0"); BEAST_EXPECT(first[jss::finished] == "1"); @@ -415,7 +415,7 @@ public: std::uint64_t prevDur = std::numeric_limits::max(); for (int i = 1; i < labels.size(); ++i) { - Json::Value const& counter{rpc[labels[i]]}; + json::Value const& counter{rpc[labels[i]]}; std::uint64_t const dur{jsonToUint64(counter[jss::duration_us])}; BEAST_EXPECT(dur != 0 && dur < prevDur); prevDur = dur; @@ -425,25 +425,25 @@ public: } // Check "total" - Json::Value const& total{rpc[jss::total]}; + json::Value const& total{rpc[jss::total]}; BEAST_EXPECT(total[jss::duration_us] != "0"); BEAST_EXPECT(jsonToUint64(total[jss::errored]) == labels.size() - 1); BEAST_EXPECT(jsonToUint64(total[jss::finished]) == labels.size()); BEAST_EXPECT(jsonToUint64(total[jss::started]) == labels.size() * 2); }; - auto validateFinalCurrent = [this, &labels](Json::Value const& currentJson) { + auto validateFinalCurrent = [this, &labels](json::Value const& currentJson) { { - Json::Value const& job_queue = currentJson[jss::jobs]; - BEAST_EXPECT(job_queue.isArray()); - BEAST_EXPECT(job_queue.size() == 0); + json::Value const& jobQueue = currentJson[jss::jobs]; + BEAST_EXPECT(jobQueue.isArray()); + BEAST_EXPECT(jobQueue.size() == 0); } - Json::Value const& methods = currentJson[jss::methods]; + json::Value const& methods = currentJson[jss::methods]; BEAST_EXPECT(methods.size() == 1); BEAST_EXPECT(methods.isArray()); - Json::Value const& only = methods[0u]; + json::Value const& only = methods[0u]; BEAST_EXPECT(only.size() == 2); BEAST_EXPECT(only.isObject()); BEAST_EXPECT(only[jss::duration_us] != "0"); @@ -462,7 +462,7 @@ public: auto const fullPath = fixture.logFile(); - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fullPath)); } @@ -481,9 +481,9 @@ public: lastLine = std::move(line); } - Json::Value parsedLastLine; - Json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::contains_error(parsedLastLine))) + json::Value parsedLastLine; + json::Reader().parse(lastLine, parsedLastLine); + if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) { // Avoid cascade of failures return; @@ -527,21 +527,21 @@ public: jobs.emplace_back(job.first, job.second.name()); } } - std::shuffle(jobs.begin(), jobs.end(), default_prng()); + std::shuffle(jobs.begin(), jobs.end(), defaultPrng()); // Walk through all of the jobs, enqueuing every job once. Check // the jobs data with every addition. for (int i = 0; i < jobs.size(); ++i) { perfLog->jobQueue(jobs[i].type); - Json::Value const jq_counters{perfLog->countersJson()[jss::job_queue]}; + json::Value const jqCounters{perfLog->countersJson()[jss::job_queue]}; - BEAST_EXPECT(jq_counters.size() == i + 2); + BEAST_EXPECT(jqCounters.size() == i + 2); for (int j = 0; j <= i; ++j) { // Verify all expected counters are present and contain // expected values. - Json::Value const& counter{jq_counters[jobs[j].typeName]}; + json::Value const& counter{jqCounters[jobs[j].typeName]}; BEAST_EXPECT(counter.size() == 5); BEAST_EXPECT(counter[jss::queued] == "1"); BEAST_EXPECT(counter[jss::started] == "0"); @@ -551,7 +551,7 @@ public: } // Verify jss::total is present and has expected values. - Json::Value const& total{jq_counters[jss::total]}; + json::Value const& total{jqCounters[jss::total]}; BEAST_EXPECT(total.size() == 5); BEAST_EXPECT(jsonToUint64(total[jss::queued]) == i + 1); BEAST_EXPECT(total[jss::started] == "0"); @@ -562,7 +562,7 @@ public: // Even with jobs queued, the perfLog should report nothing current. { - Json::Value current{perfLog->currentJson()}; + json::Value current{perfLog->currentJson()}; BEAST_EXPECT(current.size() == 2); BEAST_EXPECT(current.isMember(jss::jobs)); BEAST_EXPECT(current[jss::jobs].size() == 0); @@ -585,25 +585,25 @@ public: std::this_thread::sleep_for(microseconds(10)); // Check each jobType counter entry. - Json::Value const jq_counters{perfLog->countersJson()[jss::job_queue]}; + json::Value const jqCounters{perfLog->countersJson()[jss::job_queue]}; for (int j = 0; j < jobs.size(); ++j) { - Json::Value const& counter{jq_counters[jobs[j].typeName]}; - std::uint64_t const queued_dur_us{jsonToUint64(counter[jss::queued_duration_us])}; + json::Value const& counter{jqCounters[jobs[j].typeName]}; + std::uint64_t const queuedDurUs{jsonToUint64(counter[jss::queued_duration_us])}; if (j < i) { BEAST_EXPECT(counter[jss::started] == "2"); - BEAST_EXPECT(queued_dur_us == j + 1); + BEAST_EXPECT(queuedDurUs == j + 1); } else if (j == i) { BEAST_EXPECT(counter[jss::started] == "1"); - BEAST_EXPECT(queued_dur_us == j + 1); + BEAST_EXPECT(queuedDurUs == j + 1); } else { BEAST_EXPECT(counter[jss::started] == "0"); - BEAST_EXPECT(queued_dur_us == 0); + BEAST_EXPECT(queuedDurUs == 0); } BEAST_EXPECT(counter[jss::queued] == "1"); @@ -612,7 +612,7 @@ public: } { // Verify values in jss::total are what we expect. - Json::Value const& total{jq_counters[jss::total]}; + json::Value const& total{jqCounters[jss::total]}; BEAST_EXPECT(jsonToUint64(total[jss::queued]) == jobs.size()); BEAST_EXPECT(jsonToUint64(total[jss::started]) == (i * 2) + 1); BEAST_EXPECT(total[jss::finished] == "0"); @@ -654,35 +654,35 @@ public: perfLog->jobFinish(jobs[i].type, microseconds(finished), (i * 2) + 1); std::this_thread::sleep_for(microseconds(10)); - Json::Value const jq_counters{perfLog->countersJson()[jss::job_queue]}; + json::Value const jqCounters{perfLog->countersJson()[jss::job_queue]}; for (int j = 0; j < jobs.size(); ++j) { - Json::Value const& counter{jq_counters[jobs[j].typeName]}; - std::uint64_t const running_dur_us{jsonToUint64(counter[jss::running_duration_us])}; + json::Value const& counter{jqCounters[jobs[j].typeName]}; + std::uint64_t const runningDurUs{jsonToUint64(counter[jss::running_duration_us])}; if (j < i) { BEAST_EXPECT(counter[jss::finished] == "0"); - BEAST_EXPECT(running_dur_us == 0); + BEAST_EXPECT(runningDurUs == 0); } else if (j == i) { BEAST_EXPECT(counter[jss::finished] == "1"); - BEAST_EXPECT(running_dur_us == ((jobs.size() - j) * 2) - 1); + BEAST_EXPECT(runningDurUs == ((jobs.size() - j) * 2) - 1); } else { BEAST_EXPECT(counter[jss::finished] == "2"); - BEAST_EXPECT(running_dur_us == ((jobs.size() - j) * 4) - 1); + BEAST_EXPECT(runningDurUs == ((jobs.size() - j) * 4) - 1); } - std::uint64_t const queued_dur_us{jsonToUint64(counter[jss::queued_duration_us])}; - BEAST_EXPECT(queued_dur_us == j + 1); + std::uint64_t const queuedDurUs{jsonToUint64(counter[jss::queued_duration_us])}; + BEAST_EXPECT(queuedDurUs == j + 1); BEAST_EXPECT(counter[jss::queued] == "1"); BEAST_EXPECT(counter[jss::started] == "2"); } { // Verify values in jss::total are what we expect. - Json::Value const& total{jq_counters[jss::total]}; + json::Value const& total{jqCounters[jss::total]}; BEAST_EXPECT(jsonToUint64(total[jss::queued]) == jobs.size()); BEAST_EXPECT(jsonToUint64(total[jss::started]) == jobs.size() * 2); BEAST_EXPECT(jsonToUint64(total[jss::finished]) == finished); @@ -719,22 +719,22 @@ public: } // Validate the final results. - auto validateFinalCounters = [this, &jobs](Json::Value const& countersJson) { + auto validateFinalCounters = [this, &jobs](json::Value const& countersJson) { { - Json::Value const& rpc = countersJson[jss::rpc]; + json::Value const& rpc = countersJson[jss::rpc]; BEAST_EXPECT(rpc.isObject()); BEAST_EXPECT(rpc.size() == 0); } - Json::Value const& jobQueue = countersJson[jss::job_queue]; + json::Value const& jobQueue = countersJson[jss::job_queue]; for (int i = jobs.size() - 1; i >= 0; --i) { - Json::Value const& counter{jobQueue[jobs[i].typeName]}; - std::uint64_t const running_dur_us{jsonToUint64(counter[jss::running_duration_us])}; - BEAST_EXPECT(running_dur_us == ((jobs.size() - i) * 4) - 1); + json::Value const& counter{jobQueue[jobs[i].typeName]}; + std::uint64_t const runningDurUs{jsonToUint64(counter[jss::running_duration_us])}; + BEAST_EXPECT(runningDurUs == ((jobs.size() - i) * 4) - 1); - std::uint64_t const queued_dur_us{jsonToUint64(counter[jss::queued_duration_us])}; - BEAST_EXPECT(queued_dur_us == i + 1); + std::uint64_t const queuedDurUs{jsonToUint64(counter[jss::queued_duration_us])}; + BEAST_EXPECT(queuedDurUs == i + 1); BEAST_EXPECT(counter[jss::queued] == "1"); BEAST_EXPECT(counter[jss::started] == "2"); @@ -742,7 +742,7 @@ public: } // Verify values in jss::total are what we expect. - Json::Value const& total{jobQueue[jss::total]}; + json::Value const& total{jobQueue[jss::total]}; int const finished = jobs.size() * 2; BEAST_EXPECT(jsonToUint64(total[jss::queued]) == jobs.size()); BEAST_EXPECT(jsonToUint64(total[jss::started]) == finished); @@ -758,14 +758,14 @@ public: BEAST_EXPECT(jsonToUint64(total[jss::running_duration_us]) == runningDur); }; - auto validateFinalCurrent = [this](Json::Value const& currentJson) { + auto validateFinalCurrent = [this](json::Value const& currentJson) { { - Json::Value const& j = currentJson[jss::jobs]; + json::Value const& j = currentJson[jss::jobs]; BEAST_EXPECT(j.isArray()); BEAST_EXPECT(j.size() == 0); } - Json::Value const& methods = currentJson[jss::methods]; + json::Value const& methods = currentJson[jss::methods]; BEAST_EXPECT(methods.size() == 0); BEAST_EXPECT(methods.isArray()); }; @@ -783,7 +783,7 @@ public: // Check file contents if that is appropriate. auto const fullPath = fixture.logFile(); - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fullPath)); } @@ -802,9 +802,9 @@ public: lastLine = std::move(line); } - Json::Value parsedLastLine; - Json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::contains_error(parsedLastLine))) + json::Value parsedLastLine; + json::Reader().parse(lastLine, parsedLastLine); + if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) { // Avoid cascade of failures return; @@ -830,14 +830,14 @@ public: perfLog->start(); // Randomly select a job type and its name. - JobType jobType = jtINVALID; + JobType jobType = JtInvalid; std::string jobTypeName; { auto const& jobTypes = JobTypes::instance(); std::uniform_int_distribution<> dis(0, jobTypes.size() - 1); auto iter{jobTypes.begin()}; - std::advance(iter, dis(default_prng())); + std::advance(iter, dis(defaultPrng())); jobType = iter->second.type(); jobTypeName = iter->second.name(); @@ -848,11 +848,11 @@ public: // Lambda to validate countersJson for this test. auto verifyCounters = [this, jobTypeName]( - Json::Value const& countersJson, + json::Value const& countersJson, int started, int finished, - int queued_us, - int running_us) { + int queuedUs, + int runningUs) { BEAST_EXPECT(countersJson.isObject()); BEAST_EXPECT(countersJson.size() == 2); @@ -864,20 +864,20 @@ public: BEAST_EXPECT(countersJson[jss::job_queue].isObject()); BEAST_EXPECT(countersJson[jss::job_queue].size() == 1); { - Json::Value const& job{countersJson[jss::job_queue][jobTypeName]}; + json::Value const& job{countersJson[jss::job_queue][jobTypeName]}; BEAST_EXPECT(job.isObject()); BEAST_EXPECT(jsonToUint64(job[jss::queued]) == 0); BEAST_EXPECT(jsonToUint64(job[jss::started]) == started); BEAST_EXPECT(jsonToUint64(job[jss::finished]) == finished); - BEAST_EXPECT(jsonToUint64(job[jss::queued_duration_us]) == queued_us); - BEAST_EXPECT(jsonToUint64(job[jss::running_duration_us]) == running_us); + BEAST_EXPECT(jsonToUint64(job[jss::queued_duration_us]) == queuedUs); + BEAST_EXPECT(jsonToUint64(job[jss::running_duration_us]) == runningUs); } }; // Lambda to validate currentJson (always empty) for this test. - auto verifyEmptyCurrent = [this](Json::Value const& currentJson) { + auto verifyEmptyCurrent = [this](json::Value const& currentJson) { BEAST_EXPECT(currentJson.isObject()); BEAST_EXPECT(currentJson.size() == 2); @@ -923,7 +923,7 @@ public: // Check file contents if that is appropriate. auto const fullPath = fixture.logFile(); - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fullPath)); } @@ -942,9 +942,9 @@ public: lastLine = std::move(line); } - Json::Value parsedLastLine; - Json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::contains_error(parsedLastLine))) + json::Value parsedLastLine; + json::Reader().parse(lastLine, parsedLastLine); + if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) { // Avoid cascade of failures return; @@ -970,7 +970,7 @@ public: auto perfLog{fixture.perfLog(withFile)}; BEAST_EXPECT(fixture.stopSignaled == false); - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fixture.logDir())); } @@ -986,7 +986,7 @@ public: fixture.wait(); decltype(file_size(fixture.logFile())) firstFileSize{0}; - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fixture.logDir())); } @@ -1002,7 +1002,7 @@ public: perfLog->stop(); - if (withFile == WithFile::no) + if (withFile == WithFile::No) { BEAST_EXPECT(!exists(fixture.logDir())); } @@ -1016,14 +1016,14 @@ public: run() override { testFileCreation(); - testRPC(WithFile::no); - testRPC(WithFile::yes); - testJobs(WithFile::no); - testJobs(WithFile::yes); - testInvalidID(WithFile::no); - testInvalidID(WithFile::yes); - testRotate(WithFile::no); - testRotate(WithFile::yes); + testRPC(WithFile::No); + testRPC(WithFile::Yes); + testJobs(WithFile::No); + testJobs(WithFile::Yes); + testInvalidID(WithFile::No); + testInvalidID(WithFile::Yes); + testRotate(WithFile::No); + testRotate(WithFile::Yes); } }; diff --git a/src/test/basics/StringUtilities_test.cpp b/src/test/basics/StringUtilities_test.cpp index e566e43c9f..e12bc53857 100644 --- a/src/test/basics/StringUtilities_test.cpp +++ b/src/test/basics/StringUtilities_test.cpp @@ -7,7 +7,7 @@ namespace xrpl { -class StringUtilities_test : public beast::unit_test::suite +class StringUtilities_test : public beast::unit_test::Suite { public: void @@ -53,7 +53,7 @@ public: // Expected passes. { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -68,7 +68,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme:///")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -79,7 +79,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "lower://domain")); BEAST_EXPECT(pUrl.scheme == "lower"); BEAST_EXPECT(pUrl.username.empty()); @@ -90,7 +90,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "UPPER://domain:234/")); BEAST_EXPECT(pUrl.scheme == "upper"); BEAST_EXPECT(pUrl.username.empty()); @@ -101,7 +101,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "Mixed://domain/path")); BEAST_EXPECT(pUrl.scheme == "mixed"); BEAST_EXPECT(pUrl.username.empty()); @@ -112,7 +112,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://[::1]:123/path")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -123,7 +123,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://user:pass@domain:123/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username == "user"); @@ -134,7 +134,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://user@domain:123/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username == "user"); @@ -145,7 +145,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://:pass@domain:123/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -156,7 +156,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://domain:123/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -167,7 +167,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://user:pass@domain/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username == "user"); @@ -178,7 +178,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://user@domain/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username == "user"); @@ -189,7 +189,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://:pass@domain/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -200,7 +200,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://domain/abc:321")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -211,7 +211,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme:///path/to/file")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -222,7 +222,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://user:pass@domain/path/with/an@sign")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username == "user"); @@ -233,7 +233,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://domain/path/with/an@sign")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -244,7 +244,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "scheme://:999/")); BEAST_EXPECT(pUrl.scheme == "scheme"); BEAST_EXPECT(pUrl.username.empty()); @@ -255,7 +255,7 @@ public: } { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(parseUrl(pUrl, "http://::1:1234/validators")); BEAST_EXPECT(pUrl.scheme == "http"); BEAST_EXPECT(pUrl.username.empty()); @@ -267,7 +267,7 @@ public: // Expected fails. { - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(!parseUrl(pUrl, "")); BEAST_EXPECT(!parseUrl(pUrl, "nonsense")); BEAST_EXPECT(!parseUrl(pUrl, "://")); @@ -282,7 +282,7 @@ public: { std::string const strUrl("s://" + std::string(8192, ':')); - parsedURL pUrl; + ParsedUrl pUrl; BEAST_EXPECT(!parseUrl(pUrl, strUrl)); } } diff --git a/src/test/basics/TaggedCache_test.cpp b/src/test/basics/TaggedCache_test.cpp index 9621719803..c728536e08 100644 --- a/src/test/basics/TaggedCache_test.cpp +++ b/src/test/basics/TaggedCache_test.cpp @@ -20,7 +20,7 @@ then canonicalize a new object with the same key, make sure you get the original object. */ -class TaggedCache_test : public beast::unit_test::suite +class TaggedCache_test : public beast::unit_test::Suite { public: void @@ -89,7 +89,7 @@ public: { auto const p1 = c.fetch(3); auto p2 = std::make_shared("three"); - c.canonicalize_replace_client(3, p2); + c.canonicalizeReplaceClient(3, p2); BEAST_EXPECT(p1.get() == p2.get()); } ++clock; @@ -120,7 +120,7 @@ public: BEAST_EXPECT(c.getTrackSize() == 1); // Canonicalize a new object with the same key auto p2 = std::make_shared("four"); - BEAST_EXPECT(c.canonicalize_replace_client(4, p2)); + BEAST_EXPECT(c.canonicalizeReplaceClient(4, p2)); BEAST_EXPECT(c.getCacheSize() == 1); BEAST_EXPECT(c.getTrackSize() == 1); // Make sure we get the original object diff --git a/src/test/basics/Units_test.cpp b/src/test/basics/Units_test.cpp index 8769a0d386..4a224a2708 100644 --- a/src/test/basics/Units_test.cpp +++ b/src/test/basics/Units_test.cpp @@ -11,7 +11,7 @@ namespace xrpl::test { -class units_test : public beast::unit_test::suite +class units_test : public beast::unit_test::Suite { private: void @@ -96,57 +96,57 @@ private: { FeeLevel32 const x{std::numeric_limits::max()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::uintValue); - BEAST_EXPECT(y == Json::Value{x.fee()}); + BEAST_EXPECT(y.type() == json::UintValue); + BEAST_EXPECT(y == json::Value{x.fee()}); } { FeeLevel32 const x{std::numeric_limits::min()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::uintValue); - BEAST_EXPECT(y == Json::Value{x.fee()}); + BEAST_EXPECT(y.type() == json::UintValue); + BEAST_EXPECT(y == json::Value{x.fee()}); } { FeeLevel64 const x{std::numeric_limits::max()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::uintValue); - BEAST_EXPECT(y == Json::Value{std::numeric_limits::max()}); + BEAST_EXPECT(y.type() == json::UintValue); + BEAST_EXPECT(y == json::Value{std::numeric_limits::max()}); } { FeeLevel64 const x{std::numeric_limits::min()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::uintValue); - BEAST_EXPECT(y == Json::Value{0}); + BEAST_EXPECT(y.type() == json::UintValue); + BEAST_EXPECT(y == json::Value{0}); } { FeeLevelDouble const x{std::numeric_limits::max()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::realValue); - BEAST_EXPECT(y == Json::Value{std::numeric_limits::max()}); + BEAST_EXPECT(y.type() == json::RealValue); + BEAST_EXPECT(y == json::Value{std::numeric_limits::max()}); } { FeeLevelDouble const x{std::numeric_limits::min()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::realValue); - BEAST_EXPECT(y == Json::Value{std::numeric_limits::min()}); + BEAST_EXPECT(y.type() == json::RealValue); + BEAST_EXPECT(y == json::Value{std::numeric_limits::min()}); } { XRPAmount const x{std::numeric_limits::max()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::intValue); - BEAST_EXPECT(y == Json::Value{std::numeric_limits::max()}); + BEAST_EXPECT(y.type() == json::IntValue); + BEAST_EXPECT(y == json::Value{std::numeric_limits::max()}); } { XRPAmount const x{std::numeric_limits::min()}; auto y = x.jsonClipped(); - BEAST_EXPECT(y.type() == Json::intValue); - BEAST_EXPECT(y == Json::Value{std::numeric_limits::min()}); + BEAST_EXPECT(y.type() == json::IntValue); + BEAST_EXPECT(y == json::Value{std::numeric_limits::min()}); } } @@ -166,10 +166,10 @@ private: FeeLevel64 test{0}; BEAST_EXPECT(test.fee() == 0); - test = explicitmake(beast::zero); + test = explicitmake(beast::kZERO); BEAST_EXPECT(test.fee() == 0); - test = beast::zero; + test = beast::kZERO; BEAST_EXPECT(test.fee() == 0); test = explicitmake(100u); @@ -251,10 +251,10 @@ private: FeeLevelDouble test{0}; BEAST_EXPECT(test.fee() == 0); - test = explicitmake(beast::zero); + test = explicitmake(beast::kZERO); BEAST_EXPECT(test.fee() == 0); - test = beast::zero; + test = beast::kZERO; BEAST_EXPECT(test.fee() == 0); test = explicitmake(100.0); @@ -330,8 +330,8 @@ public: void run() override { - BEAST_EXPECT(INITIAL_XRP.drops() == 100'000'000'000'000'000); - BEAST_EXPECT(INITIAL_XRP == XRPAmount{100'000'000'000'000'000}); + BEAST_EXPECT(kINITIAL_XRP.drops() == 100'000'000'000'000'000); + BEAST_EXPECT(kINITIAL_XRP == XRPAmount{100'000'000'000'000'000}); testTypes(); testJson(); diff --git a/src/test/basics/XRPAmount_test.cpp b/src/test/basics/XRPAmount_test.cpp index b0e8213b73..50cd17b3bc 100644 --- a/src/test/basics/XRPAmount_test.cpp +++ b/src/test/basics/XRPAmount_test.cpp @@ -7,7 +7,7 @@ namespace xrpl { -class XRPAmount_test : public beast::unit_test::suite +class XRPAmount_test : public beast::unit_test::Suite { public: void @@ -39,25 +39,25 @@ public: { testcase("beast::Zero Comparisons"); - using beast::zero; + using beast::kZERO; for (auto i : {-1, 0, 1}) { XRPAmount const x(i); - BEAST_EXPECT((i == 0) == (x == zero)); - BEAST_EXPECT((i != 0) == (x != zero)); - BEAST_EXPECT((i < 0) == (x < zero)); - BEAST_EXPECT((i > 0) == (x > zero)); - BEAST_EXPECT((i <= 0) == (x <= zero)); - BEAST_EXPECT((i >= 0) == (x >= zero)); + BEAST_EXPECT((i == 0) == (x == kZERO)); + BEAST_EXPECT((i != 0) == (x != kZERO)); + BEAST_EXPECT((i < 0) == (x < kZERO)); + BEAST_EXPECT((i > 0) == (x > kZERO)); + BEAST_EXPECT((i <= 0) == (x <= kZERO)); + BEAST_EXPECT((i >= 0) == (x >= kZERO)); - BEAST_EXPECT((0 == i) == (zero == x)); - BEAST_EXPECT((0 != i) == (zero != x)); - BEAST_EXPECT((0 < i) == (zero < x)); - BEAST_EXPECT((0 > i) == (zero > x)); - BEAST_EXPECT((0 <= i) == (zero <= x)); - BEAST_EXPECT((0 >= i) == (zero >= x)); + BEAST_EXPECT((0 == i) == (kZERO == x)); + BEAST_EXPECT((0 != i) == (kZERO != x)); + BEAST_EXPECT((0 < i) == (kZERO < x)); + BEAST_EXPECT((0 > i) == (kZERO > x)); + BEAST_EXPECT((0 <= i) == (kZERO <= x)); + BEAST_EXPECT((0 >= i) == (kZERO >= x)); } } @@ -109,7 +109,7 @@ public: testDecimal() { // Tautology - BEAST_EXPECT(DROPS_PER_XRP.decimalXRP() == 1); + BEAST_EXPECT(kDROPS_PER_XRP.decimalXRP() == 1); XRPAmount test{1}; BEAST_EXPECT(test.decimalXRP() == 0.000001); @@ -136,10 +136,10 @@ public: XRPAmount test{0}; BEAST_EXPECT(test.drops() == 0); - test = make(beast::zero); + test = make(beast::kZERO); BEAST_EXPECT(test.drops() == 0); - test = beast::zero; + test = beast::kZERO; BEAST_EXPECT(test.drops() == 0); test = make(100); @@ -212,17 +212,17 @@ public: { testcase("mulRatio"); - constexpr auto maxUInt32 = std::numeric_limits::max(); - constexpr auto maxXRP = std::numeric_limits::max(); - constexpr auto minXRP = std::numeric_limits::min(); + constexpr auto kMAX_U_INT32 = std::numeric_limits::max(); + constexpr auto kMAX_XRP = std::numeric_limits::max(); + constexpr auto kMIN_XRP = std::numeric_limits::min(); { // multiply by a number that would overflow then divide by the same // number, and check we didn't lose any value - XRPAmount big(maxXRP); - BEAST_EXPECT(big == mulRatio(big, maxUInt32, maxUInt32, true)); + XRPAmount big(kMAX_XRP); + BEAST_EXPECT(big == mulRatio(big, kMAX_U_INT32, kMAX_U_INT32, true)); // rounding mode shouldn't matter as the result is exact - BEAST_EXPECT(big == mulRatio(big, maxUInt32, maxUInt32, false)); + BEAST_EXPECT(big == mulRatio(big, kMAX_U_INT32, kMAX_U_INT32, false)); // multiply and divide by values that would overflow if done // naively, and check that it gives the correct answer @@ -234,11 +234,10 @@ public: { // Similar test as above, but for negative values - XRPAmount big(minXRP); // NOLINT(misc-const-correctness): const breaks overflow check - // at end of this scope - BEAST_EXPECT(big == mulRatio(big, maxUInt32, maxUInt32, true)); + XRPAmount big(kMIN_XRP); // NOLINT TODO + BEAST_EXPECT(big == mulRatio(big, kMAX_U_INT32, kMAX_U_INT32, true)); // rounding mode shouldn't matter as the result is exact - BEAST_EXPECT(big == mulRatio(big, maxUInt32, maxUInt32, false)); + BEAST_EXPECT(big == mulRatio(big, kMAX_U_INT32, kMAX_U_INT32, false)); // multiply and divide by values that would overflow if done // naively, and check that it gives the correct answer @@ -251,39 +250,39 @@ public: // small amounts XRPAmount const tiny(1); // Round up should give the smallest allowable number - BEAST_EXPECT(tiny == mulRatio(tiny, 1, maxUInt32, true)); + BEAST_EXPECT(tiny == mulRatio(tiny, 1, kMAX_U_INT32, true)); // rounding down should be zero - BEAST_EXPECT(beast::zero == mulRatio(tiny, 1, maxUInt32, false)); - BEAST_EXPECT(beast::zero == mulRatio(tiny, maxUInt32 - 1, maxUInt32, false)); + BEAST_EXPECT(beast::kZERO == mulRatio(tiny, 1, kMAX_U_INT32, false)); + BEAST_EXPECT(beast::kZERO == mulRatio(tiny, kMAX_U_INT32 - 1, kMAX_U_INT32, false)); // tiny negative numbers XRPAmount const tinyNeg(-1); // Round up should give zero - BEAST_EXPECT(beast::zero == mulRatio(tinyNeg, 1, maxUInt32, true)); - BEAST_EXPECT(beast::zero == mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32, true)); + BEAST_EXPECT(beast::kZERO == mulRatio(tinyNeg, 1, kMAX_U_INT32, true)); + BEAST_EXPECT(beast::kZERO == mulRatio(tinyNeg, kMAX_U_INT32 - 1, kMAX_U_INT32, true)); // rounding down should be tiny - BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32, false)); + BEAST_EXPECT(tinyNeg == mulRatio(tinyNeg, kMAX_U_INT32 - 1, kMAX_U_INT32, false)); } { // rounding { XRPAmount const one(1); - auto const rup = mulRatio(one, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(one, maxUInt32 - 1, maxUInt32, false); + auto const rup = mulRatio(one, kMAX_U_INT32 - 1, kMAX_U_INT32, true); + auto const rdown = mulRatio(one, kMAX_U_INT32 - 1, kMAX_U_INT32, false); BEAST_EXPECT(rup.drops() - rdown.drops() == 1); } { - XRPAmount const big(maxXRP); - auto const rup = mulRatio(big, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(big, maxUInt32 - 1, maxUInt32, false); + XRPAmount const big(kMAX_XRP); + auto const rup = mulRatio(big, kMAX_U_INT32 - 1, kMAX_U_INT32, true); + auto const rdown = mulRatio(big, kMAX_U_INT32 - 1, kMAX_U_INT32, false); BEAST_EXPECT(rup.drops() - rdown.drops() == 1); } { XRPAmount const negOne(-1); - auto const rup = mulRatio(negOne, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(negOne, maxUInt32 - 1, maxUInt32, false); + auto const rup = mulRatio(negOne, kMAX_U_INT32 - 1, kMAX_U_INT32, true); + auto const rdown = mulRatio(negOne, kMAX_U_INT32 - 1, kMAX_U_INT32, false); BEAST_EXPECT(rup.drops() - rdown.drops() == 1); } } @@ -296,14 +295,14 @@ public: { // overflow - XRPAmount big(maxXRP); + XRPAmount big(kMAX_XRP); except([&] { mulRatio(big, 2, 1, true); }); } { // underflow - XRPAmount const bigNegative(minXRP + 10); - BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == minXRP); + XRPAmount const bigNegative(kMIN_XRP + 10); + BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == kMIN_XRP); } } // namespace xrpl diff --git a/src/test/basics/base58_test.cpp b/src/test/basics/base58_test.cpp index 948195b424..e0a9433f4e 100644 --- a/src/test/basics/base58_test.cpp +++ b/src/test/basics/base58_test.cpp @@ -31,19 +31,19 @@ namespace { [[nodiscard]] inline auto randEngine() -> std::mt19937& { - static std::mt19937 r = [] { + static std::mt19937 kR = [] { std::random_device rd; return std::mt19937{rd()}; }(); - return r; + return kR; } -constexpr int numTokenTypeIndexes = 9; +constexpr int kNUM_TOKEN_TYPE_INDEXES = 9; [[nodiscard]] inline auto tokenTypeAndSize(int i) -> std::tuple { - assert(i < numTokenTypeIndexes); + assert(i < kNUM_TOKEN_TYPE_INDEXES); switch (i) { @@ -157,7 +157,7 @@ randomBigInt(std::uint8_t minSize = 1, std::uint8_t maxSize = 5) } } // namespace multiprecision_utils -class base58_test : public beast::unit_test::suite +class base58_test : public beast::unit_test::Suite { void testMultiprecision() @@ -166,11 +166,11 @@ class base58_test : public beast::unit_test::suite using namespace boost::multiprecision; - constexpr std::size_t iters = 100000; + constexpr std::size_t kITERS = 100000; auto eng = randEngine(); std::uniform_int_distribution dist; std::uniform_int_distribution dist1(1); - for (int i = 0; i < iters; ++i) + for (int i = 0; i < kITERS; ++i) { std::uint64_t const d = dist(eng); if (d == 0u) @@ -182,13 +182,13 @@ class base58_test : public beast::unit_test::suite auto const refDiv = boostBigInt / d; auto const refMod = boostBigInt % d; - auto const mod = b58_fast::detail::inplace_bigint_div_rem( + auto const mod = b58_fast::detail::inplaceBigintDivRem( std::span(bigInt.data(), bigInt.size()), d); auto const foundDiv = multiprecision_utils::toBoostMP(bigInt); BEAST_EXPECT(refMod.convert_to() == mod); BEAST_EXPECT(foundDiv == refDiv); } - for (int i = 0; i < iters; ++i) + for (int i = 0; i < kITERS; ++i) { std::uint64_t const d = dist(eng); auto bigInt = multiprecision_utils::randomBigInt(/*minSize*/ 2); @@ -201,13 +201,13 @@ class base58_test : public beast::unit_test::suite auto const refAdd = boostBigInt + d; - auto const result = b58_fast::detail::inplace_bigint_add( + auto const result = b58_fast::detail::inplaceBigintAdd( std::span(bigInt.data(), bigInt.size()), d); - BEAST_EXPECT(result == TokenCodecErrc::success); + BEAST_EXPECT(result == TokenCodecErrc::Success); auto const foundAdd = multiprecision_utils::toBoostMP(bigInt); BEAST_EXPECT(refAdd == foundAdd); } - for (int i = 0; i < iters; ++i) + for (int i = 0; i < kITERS; ++i) { std::uint64_t const d = dist1(eng); // Force overflow @@ -218,13 +218,13 @@ class base58_test : public beast::unit_test::suite auto const refAdd = boostBigInt + d; - auto const result = b58_fast::detail::inplace_bigint_add( + auto const result = b58_fast::detail::inplaceBigintAdd( std::span(bigInt.data(), bigInt.size()), d); - BEAST_EXPECT(result == TokenCodecErrc::overflowAdd); + BEAST_EXPECT(result == TokenCodecErrc::OverflowAdd); auto const foundAdd = multiprecision_utils::toBoostMP(bigInt); BEAST_EXPECT(refAdd != foundAdd); } - for (int i = 0; i < iters; ++i) + for (int i = 0; i < kITERS; ++i) { std::uint64_t const d = dist(eng); auto bigInt = multiprecision_utils::randomBigInt(/* minSize */ 2); @@ -236,13 +236,13 @@ class base58_test : public beast::unit_test::suite auto const refMul = boostBigInt * d; - auto const result = b58_fast::detail::inplace_bigint_mul( + auto const result = b58_fast::detail::inplaceBigintMul( std::span(bigInt.data(), bigInt.size()), d); - BEAST_EXPECT(result == TokenCodecErrc::success); + BEAST_EXPECT(result == TokenCodecErrc::Success); auto const foundMul = multiprecision_utils::toBoostMP(bigInt); BEAST_EXPECT(refMul == foundMul); } - for (int i = 0; i < iters; ++i) + for (int i = 0; i < kITERS; ++i) { std::uint64_t const d = dist1(eng); // Force overflow @@ -252,9 +252,9 @@ class base58_test : public beast::unit_test::suite auto const refMul = boostBigInt * d; - auto const result = b58_fast::detail::inplace_bigint_mul( + auto const result = b58_fast::detail::inplaceBigintMul( std::span(bigInt.data(), bigInt.size()), d); - BEAST_EXPECT(result == TokenCodecErrc::inputTooLarge); + BEAST_EXPECT(result == TokenCodecErrc::InputTooLarge); auto const foundMul = multiprecision_utils::toBoostMP(bigInt); BEAST_EXPECT(refMul != foundMul); } @@ -275,7 +275,7 @@ class base58_test : public beast::unit_test::suite std::span const outBuf{b58ResultBuf[i]}; if (i == 0) { - auto const r = xrpl::b58_fast::detail::b256_to_b58_be(b256Data, outBuf); + auto const r = xrpl::b58_fast::detail::b256ToB58Be(b256Data, outBuf); BEAST_EXPECT(r); b58Result[i] = r.value(); } @@ -305,7 +305,7 @@ class base58_test : public beast::unit_test::suite { std::string const in( b58Result[i].data(), b58Result[i].data() + b58Result[i].size()); - auto const r = xrpl::b58_fast::detail::b58_to_b256_be(in, outBuf); + auto const r = xrpl::b58_fast::detail::b58ToB256Be(in, outBuf); BEAST_EXPECT(r); b256Result[i] = r.value(); } @@ -403,7 +403,7 @@ class base58_test : public beast::unit_test::suite // test every token type with data where every byte is the same and the // bytes range from 0-255 - for (int i = 0; i < numTokenTypeIndexes; ++i) + for (int i = 0; i < kNUM_TOKEN_TYPE_INDEXES; ++i) { std::array b256DataBuf{}; auto const [tokType, tokSize] = tokenTypeAndSize(i); @@ -415,8 +415,8 @@ class base58_test : public beast::unit_test::suite } // test with random data - constexpr std::size_t iters = 100000; - for (int i = 0; i < iters; ++i) + constexpr std::size_t kITERS = 100000; + for (int i = 0; i < kITERS; ++i) { std::array b256DataBuf{}; auto const [tokType, b256Data] = randomB256TestData(b256DataBuf); diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 8148f3bdce..cf5ece6240 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -24,32 +24,32 @@ namespace xrpl::test { // a non-hashing Hasher that just copies the bytes. // Used to test hash_append in base_uint template -struct nonhash +struct Nonhash { - static constexpr auto const endian = boost::endian::order::big; - static constexpr std::size_t WIDTH = Bits / 8; + static constexpr auto const kENDIAN = boost::endian::order::big; + static constexpr std::size_t kWIDTH = Bits / 8; - std::array data_; + std::array data; - nonhash() = default; + Nonhash() = default; void operator()(void const* key, std::size_t len) noexcept { - assert(len == WIDTH); - memcpy(data_.data(), key, len); + assert(len == kWIDTH); + memcpy(data.data(), key, len); } explicit operator std::size_t() noexcept { - return WIDTH; + return kWIDTH; } }; -struct base_uint_test : beast::unit_test::suite +struct base_uint_test : beast::unit_test::Suite { - using test96 = base_uint<96>; + using test96 = BaseUint<96>; static_assert(std::is_copy_constructible_v); static_assert(std::is_copy_assignable_v); @@ -57,17 +57,18 @@ struct base_uint_test : beast::unit_test::suite testComparisons() { { - static constexpr std::array, 6> test_args{ - {{"0000000000000000", "0000000000000001"}, - {"0000000000000000", "ffffffffffffffff"}, - {"1234567812345678", "2345678923456789"}, - {"8000000000000000", "8000000000000001"}, - {"aaaaaaaaaaaaaaa9", "aaaaaaaaaaaaaaaa"}, - {"fffffffffffffffe", "ffffffffffffffff"}}}; + static constexpr std::array, 6> + kTEST_ARGS{ + {{"0000000000000000", "0000000000000001"}, + {"0000000000000000", "ffffffffffffffff"}, + {"1234567812345678", "2345678923456789"}, + {"8000000000000000", "8000000000000001"}, + {"aaaaaaaaaaaaaaa9", "aaaaaaaaaaaaaaaa"}, + {"fffffffffffffffe", "ffffffffffffffff"}}}; - for (auto const& arg : test_args) + for (auto const& arg : kTEST_ARGS) { - xrpl::base_uint<64> const u{arg.first}, v{arg.second}; + xrpl::BaseUint<64> const u{arg.first}, v{arg.second}; BEAST_EXPECT(u < v); BEAST_EXPECT(u <= v); BEAST_EXPECT(u != v); @@ -86,8 +87,8 @@ struct base_uint_test : beast::unit_test::suite } { - static constexpr std::array, 6> test_args{ - { + static constexpr std::array, 6> + kTEST_ARGS{{ {"000000000000000000000000", "000000000000000000000001"}, {"000000000000000000000000", "ffffffffffffffffffffffff"}, {"0123456789ab0123456789ab", "123456789abc123456789abc"}, @@ -96,9 +97,9 @@ struct base_uint_test : beast::unit_test::suite {"fffffffffffffffffffffffe", "ffffffffffffffffffffffff"}, }}; - for (auto const& arg : test_args) + for (auto const& arg : kTEST_ARGS) { - xrpl::base_uint<96> const u{arg.first}, v{arg.second}; + xrpl::BaseUint<96> const u{arg.first}, v{arg.second}; BEAST_EXPECT(u < v); BEAST_EXPECT(u <= v); BEAST_EXPECT(u != v); @@ -128,16 +129,16 @@ struct base_uint_test : beast::unit_test::suite testComparisons(); // used to verify set insertion (hashing required) - std::unordered_set> uset; + std::unordered_set> uset; Blob const raw{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - BEAST_EXPECT(test96::bytes == raw.size()); + BEAST_EXPECT(test96::kBYTES == raw.size()); test96 u{raw}; uset.insert(u); BEAST_EXPECT(raw.size() == u.size()); BEAST_EXPECT(to_string(u) == "0102030405060708090A0B0C"); - BEAST_EXPECT(to_short_string(u) == "01020304..."); + BEAST_EXPECT(toShortString(u) == "01020304..."); BEAST_EXPECT(*u.data() == 1); BEAST_EXPECT(u.signum() == 1); BEAST_EXPECT(!!u); @@ -152,15 +153,15 @@ struct base_uint_test : beast::unit_test::suite // Test hash_append by "hashing" with a no-op hasher (h) // and then extracting the bytes that were written during hashing // back into another base_uint (w) for comparison with the original - nonhash<96> h{}; + Nonhash<96> h{}; hash_append(h, u); - test96 const w{std::vector(h.data_.begin(), h.data_.end())}; + test96 const w{std::vector(h.data.begin(), h.data.end())}; BEAST_EXPECT(w == u); test96 v{~u}; uset.insert(v); BEAST_EXPECT(to_string(v) == "FEFDFCFBFAF9F8F7F6F5F4F3"); - BEAST_EXPECT(to_short_string(v) == "FEFDFCFB..."); + BEAST_EXPECT(toShortString(v) == "FEFDFCFB..."); BEAST_EXPECT(*v.data() == 0xfe); BEAST_EXPECT(v.signum() == 1); BEAST_EXPECT(!!v); @@ -178,10 +179,10 @@ struct base_uint_test : beast::unit_test::suite v = u; BEAST_EXPECT(v == u); - test96 z{beast::zero}; + test96 z{beast::kZERO}; uset.insert(z); BEAST_EXPECT(to_string(z) == "000000000000000000000000"); - BEAST_EXPECT(to_short_string(z) == "00000000..."); + BEAST_EXPECT(toShortString(z) == "00000000..."); BEAST_EXPECT(*z.data() == 0); BEAST_EXPECT(*z.begin() == 0); BEAST_EXPECT(*std::prev(z.end(), 1) == 0); @@ -198,12 +199,12 @@ struct base_uint_test : beast::unit_test::suite n++; BEAST_EXPECT(n == test96(1)); n--; - BEAST_EXPECT(n == beast::zero); + BEAST_EXPECT(n == beast::kZERO); BEAST_EXPECT(n == z); n--; BEAST_EXPECT(to_string(n) == "FFFFFFFFFFFFFFFFFFFFFFFF"); - BEAST_EXPECT(to_short_string(n) == "FFFFFFFF..."); - n = beast::zero; + BEAST_EXPECT(toShortString(n) == "FFFFFFFF..."); + n = beast::kZERO; BEAST_EXPECT(n == z); test96 zp1{z}; @@ -213,7 +214,7 @@ struct base_uint_test : beast::unit_test::suite test96 const x{zm1 ^ zp1}; uset.insert(x); BEAST_EXPECTS(to_string(x) == "FFFFFFFFFFFFFFFFFFFFFFFE", to_string(x)); - BEAST_EXPECTS(to_short_string(x) == "FFFFFFFF...", to_short_string(x)); + BEAST_EXPECTS(toShortString(x) == "FFFFFFFF...", toShortString(x)); BEAST_EXPECT(uset.size() == 4); @@ -335,7 +336,7 @@ struct base_uint_test : beast::unit_test::suite { } }; - constexpr StrBaseUint testCases[] = { + constexpr StrBaseUint kTEST_CASES[] = { "000000000000000000000000", "000000000000000000000001", "fedcba9876543210ABCDEF91", @@ -343,7 +344,7 @@ struct base_uint_test : beast::unit_test::suite "800000000000000000000000", "fFfFfFfFfFfFfFfFfFfFfFfF"}; - for (StrBaseUint const& t : testCases) + for (StrBaseUint const& t : kTEST_CASES) { test96 t96; BEAST_EXPECT(t96.parseHex(t.str)); diff --git a/src/test/basics/hardened_hash_test.cpp b/src/test/basics/hardened_hash_test.cpp index 10e9c87309..a4ecdf7081 100644 --- a/src/test/basics/hardened_hash_test.cpp +++ b/src/test/basics/hardened_hash_test.cpp @@ -15,42 +15,44 @@ namespace xrpl::detail { template -class test_user_type_member +class TestUserTypeMember { private: - T t; + T t_; public: - explicit test_user_type_member(T const& t_ = T()) : t(t_) + explicit TestUserTypeMember(T const& t = T()) : t_(t) { } template friend void - hash_append(Hasher& h, test_user_type_member const& a) noexcept + // NOLINTNEXTLINE(readability-identifier-naming) + hash_append(Hasher& h, TestUserTypeMember const& a) noexcept { using beast::hash_append; - hash_append(h, a.t); + hash_append(h, a.t_); } }; template -class test_user_type_free +class TestUserTypeFree { private: - T t; + T t_; public: - explicit test_user_type_free(T const& t_ = T()) : t(t_) + explicit TestUserTypeFree(T const& t = T()) : t_(t) { } template friend void - hash_append(Hasher& h, test_user_type_free const& a) noexcept + // NOLINTNEXTLINE(readability-identifier-naming) + hash_append(Hasher& h, TestUserTypeFree const& a) noexcept { using beast::hash_append; - hash_append(h, a.t); + hash_append(h, a.t_); } }; @@ -63,21 +65,21 @@ namespace xrpl { namespace detail { template -using test_hardened_unordered_set = std::unordered_set>; +using test_hardened_unordered_set = std::unordered_set>; template -using test_hardened_unordered_map = std::unordered_map>; +using test_hardened_unordered_map = std::unordered_map>; template -using test_hardened_unordered_multiset = std::unordered_multiset>; +using test_hardened_unordered_multiset = std::unordered_multiset>; template -using test_hardened_unordered_multimap = std::unordered_multimap>; +using test_hardened_unordered_multimap = std::unordered_multimap>; } // namespace detail template -class unsigned_integer +class UnsignedInteger { private: static_assert( @@ -88,60 +90,60 @@ private: static_assert(Bits >= (8 * sizeof(UInt)), "Bits must be at least 8*sizeof(UInt)"); - static std::size_t const size = Bits / (8 * sizeof(UInt)); + static std::size_t const kSIZE = Bits / (8 * sizeof(UInt)); - std::array m_vec; + std::array vec_; public: using value_type = UInt; - static std::size_t const bits = Bits; - static std::size_t const bytes = bits / 8; + static std::size_t const kBITS = Bits; + static std::size_t const kBYTES = kBITS / 8; template - static unsigned_integer - from_number(Int v) + static UnsignedInteger + fronumber(Int v) { - unsigned_integer result; - for (std::size_t i(1); i < size; ++i) - result.m_vec[i] = 0; - result.m_vec[0] = v; + UnsignedInteger result; + for (std::size_t i(1); i < kSIZE; ++i) + result.vec_[i] = 0; + result.vec_[0] = v; return result; } void* data() noexcept { - return &m_vec[0]; + return &vec_[0]; } [[nodiscard]] void const* data() const noexcept { - return &m_vec[0]; + return &vec_[0]; } template friend void - hash_append(Hasher& h, unsigned_integer const& a) noexcept + hash_append(Hasher& h, UnsignedInteger const& a) noexcept { using beast::hash_append; - hash_append(h, a.m_vec); + hash_append(h, a.vec_); } friend std::ostream& - operator<<(std::ostream& s, unsigned_integer const& v) + operator<<(std::ostream& s, UnsignedInteger const& v) { - for (std::size_t i(0); i < size; ++i) - s << std::hex << std::setfill('0') << std::setw(2 * sizeof(UInt)) << v.m_vec[i]; + for (std::size_t i(0); i < kSIZE; ++i) + s << std::hex << std::setfill('0') << std::setw(2 * sizeof(UInt)) << v.vec_[i]; return s; } }; -using sha256_t = unsigned_integer<256, std::size_t>; +using sha256_t = UnsignedInteger<256, std::size_t>; #ifndef __INTELLISENSE__ -static_assert(sha256_t::bits == 256, "sha256_t must have 256 bits"); +static_assert(sha256_t::kBITS == 256, "sha256_t must have 256 bits"); #endif } // namespace xrpl @@ -150,7 +152,7 @@ static_assert(sha256_t::bits == 256, "sha256_t must have 256 bits"); namespace xrpl { -class hardened_hash_test : public beast::unit_test::suite +class hardened_hash_test : public beast::unit_test::Suite { public: template @@ -158,13 +160,13 @@ public: check() { T t{}; - hardened_hash<>()(t); + HardenedHash<>()(t); pass(); } template