Commit Graph

13558 Commits

Author SHA1 Message Date
Ed Hennis
71de1a0d93 Refactor issuance validity check in VaultCreate
- Utility function: canAddHolding
- Call canAddHolding from any transactor that call addEmptyHolding
  (LoanBrokerSet, LoanSet)
2025-05-07 12:30:59 -04:00
Ed Hennis
c3d420e49e Fix a couple of conversions in tests that were lost in recent rebase 2025-05-07 12:11:56 -04:00
Ed Hennis
196b08fc72 Add unit tests to create a Loan successfully
- Fix a few field initializations in LoanSet
2025-05-07 12:11:56 -04:00
Ed Hennis
2013e7e64d Remove the new TenthBips serialized type
- It was a neat idea, but more trouble than it's worth. The conversion
  functions are sufficient for what I need.
- Partially reverts
  - d7357d3eca0b70c36b5665fdf23ee5e7a3cea0d7
  - cbb4dbcbe7023cb8a8d30f0e794acf9d1d9a458a
  - 396b981fc0da0d2d248b8c68bd3fac68c5f0b64c
2025-05-07 12:11:56 -04:00
Ed Hennis
ceeb11aee0 Ensure that an account is not deleted with a non-zero owner count
- Updates the AccountRootsDeletedClean invariant
2025-05-07 12:11:56 -04:00
Ed Hennis
b97811d45c Change Loan object indexing, fix several broken LoanSet unit tests
- Loan objects will now only be indexed by LoanBrokerID and
  LoanSequence, which is a new field in LoanBroker. Also changes
  Loan.Sequence to Loan.LoanSequence to match up.
- Several tests weren't working because of `PrettyAsset` scaling. Also,
  `PrettyAsset` calculations could overflow. Made that less likely by
  changing the type of `scale_`.
- LoanSet will fail if an account tries to loan to itself.
2025-05-07 12:11:55 -04:00
Ed Hennis
01538ef108 Fix build errors 2025-05-07 12:11:55 -04:00
Ed Hennis
70155a5ac2 Add more LoanSet unit tests, added LoanBroker LoanSequence field
- LoanSequence will prevent loan key collisions
2025-05-07 12:11:55 -04:00
Ed Hennis
0a4c0a555d Get Counterparty signing working 2025-05-07 12:11:55 -04:00
Ed Hennis
7823c8b186 Start writing Loan tests
- Required adding support for counterparty signature to jtx framework:
  arbitrary signature field destination, multiple signer callbacks
2025-05-07 12:11:55 -04:00
Ed Hennis
d6353e593f Get arithmetic operators working for typed-values 2025-05-07 12:11:55 -04:00
Ed Hennis
c3fef1b9ad Get that strong Bips field type working (mostly) 2025-05-07 12:11:54 -04:00
Ed Hennis
a5376c7d76 [WIP] Turns out that adding a new serialized type is harder than it looks 2025-05-07 12:11:54 -04:00
Ed Hennis
939d3d4446 Fix formatting 2025-05-07 12:11:54 -04:00
Ed Hennis
89f0b3b9e4 [WIP] Continue implementing LoanSet Transactor
- Needs tests
- Started trying to add strong typing to the fields used as bips or 1/10
  bips.
2025-05-07 12:11:54 -04:00
Ed Hennis
cbb14627ea Generalize the check*Sign functions to support CounterParty
- checkSign, checkSingleSign, and checkMultiSign in STTx and Transactor
2025-05-07 12:11:54 -04:00
Ed Hennis
5bed1d94e6 [WIP] Start implementing LoanSet transactor
- Add some more values and functions to make it easier to work with
  basis point values / bips.
- Fix several earlier mistakes.
2025-05-07 12:11:54 -04:00
Ed Hennis
a01ce0ad00 Fix a couple of cross-platform build errors 2025-05-07 12:11:54 -04:00
Ed Hennis
327d576d7e Move inclusion of Transactor headers to transactions.macro
- Only need to update in one place when adding a new transaction.
2025-05-07 12:11:53 -04:00
Ed Hennis
4326b5941c Finish up the Loan Broker tests 2025-05-07 12:11:53 -04:00
Ed Hennis
1798be0ba9 Ensure that an account is not deleted with an XRP balance
- Updates the AccountRootsDeletedClean invariant
2025-05-07 12:11:53 -04:00
Ed Hennis
56ff345a99 Add Asset and MPTIssue support to more jtx objects / functions
- Unfortunately, to work around some ambiguous symbol compilation
  errors, I had to change the implicit conversion from IOU to Asset to
  a conversion from IOU to PrettyAsset, and add a more explicit
  `asset()` function. This workaround only required changing two
  existing tests, so seems acceptable.
2025-05-07 12:11:53 -04:00
Ed Hennis
79a1a8a9c6 Finish(?) unit tests for Loan Broker Cover amounts. Untested.
- Add support for `Asset` and `MPTIssue` to some `jtx` helper classes
  and functions (`balance`, `expectLine`)
- Add support for pseudo-accounts to `jtx::Account` by allowing directly
  setting the AccountID without a matching key.
2025-05-07 12:11:53 -04:00
Ed Hennis
2bcc8cedfd Start writing tests for LoanBrokerCover* 2025-05-07 12:11:53 -04:00
Ed Hennis
1bb1992cf0 Add LoanBrokerCoverWithdraw transaction
- Untested
2025-05-07 12:11:52 -04:00
Ed Hennis
ffbc068dc8 Add LoanBrokerCoverDeposit transaction
- Untested. Will need Withdraw to do a good test.
2025-05-07 12:11:52 -04:00
Ed Hennis
fc66227f69 Move all detail namespaces to be under ripple
- Avoids problems with namespace collisions / ambiguous symbol issues
  with unity builds, especially when adding or removing files.
2025-05-07 12:11:52 -04:00
Ed Hennis
27fbf2db8e Start writing Loan Broker invariants and tests
- Specifically those mentioned for LoanBrokerDelete
2025-05-07 12:11:52 -04:00
Ed Hennis
7ab5bdbf3d Refactor ApplyView::dirAdd to give access to low-level operations
- Takes a page from #5362, which may turn out to be useful!
2025-05-07 12:11:52 -04:00
Ed Hennis
7d6155cc99 Clean ups 2025-05-07 12:11:52 -04:00
Ed Hennis
17a970d80c Continue updating LoanBroker tests
- It builds now
2025-05-07 12:11:51 -04:00
Ed Hennis
da10ba6fd0 Start adding tests for LoanBrokerDelete
- Start fixing the inevitable problems found along the way
- Generalize the LoanBroker lifecycle test
2025-05-07 12:11:51 -04:00
Ed Hennis
853c42fb9e Initial implementation of LoanBrokerDelete
- Completely untested
2025-05-07 12:11:51 -04:00
Ed Hennis
cc0fe0db07 LoanBrokerSet will charge a reserve increment when creating
- Refactor: Add a Transactor base function to make it easier to get the
  owner reserve increment as a fee.
- Refactor: Add an overload jtx::fee(increment) to pay an owner reserve.
2025-05-07 12:11:51 -04:00
Ed Hennis
781136ed2e Clang wants an explicit ctor to emplace in a vector 2025-05-07 12:11:51 -04:00
Ed Hennis
5db3c5e023 Fix a few build errors 2025-05-07 12:11:51 -04:00
Ed Hennis
a8118ff582 Add unit tests for new invariants:
- NoModifiedUnmodifiableFields and ValidPseudoAccounts
- Move the Invariants_test class into the test namespace
2025-05-07 12:11:51 -04:00
Ed Hennis
e3241dc143 Clean up more Invariant privilege checking
- Change more "failed" messages. The goal here is to be able to search
  the log for "failed" and ONLY get test failures.
2025-05-07 12:11:50 -04:00
Ed Hennis
c63cc88dc6 Fix a couple more build errors 2025-05-07 12:11:50 -04:00
Ed Hennis
ed27377435 Add a validity range for sfDebtMaximum
- Fix several test and build errors
2025-05-07 12:11:50 -04:00
Ed Hennis
41d83a4b24 Fix account creation to check both amendments 2025-05-07 12:11:50 -04:00
Ed Hennis
b7152496c1 Add LoanBroker update tests
- Move some helper functions.
- Check the regular key in the pseudo-transaction invariant check.
- Transactor::checkSign will always fail for a pseudo-account, so even
  if someone figures out how to get a good signature, it won't work.
2025-05-07 12:11:50 -04:00
Ed Hennis
1db5e9b4d3 Pseudo-account improvements
- Define pseudo-account fields with an sfield flag
- Pseudo-account invariant checks rules whenever a pseudo-account is
  created or modified.
2025-05-07 12:11:50 -04:00
Ed Hennis
1bbe5383ca Reserve a few values between Vault and Lending for future use
- Ledger objects and transactions
2025-05-07 12:11:49 -04:00
Ed Hennis
33e666bfff Enumerate transaction privileges for invariants
- Allows them to be defined in transactions.macro instead of needing to
  scrutinize every existing Invariant class.
- List is not necessarily comprehensive, but does cover every check
  where more than one transaction type is involved.
2025-05-07 12:11:49 -04:00
Ed Hennis
3b59817952 Generalize some of the Invariant checks using macro files
- Valid ledger entry type
- Valid new account root and pseudo account check
2025-05-07 12:11:49 -04:00
Ed Hennis
d4c2d46984 Update tests, update pseudo-account checking 2025-05-07 12:11:49 -04:00
Ed Hennis
47fa8ff59f Fix formatting 2025-05-07 12:11:49 -04:00
Ed Hennis
0d26065321 Start writing LoanBrokerSet tests 2025-05-07 12:11:49 -04:00
Ed Hennis
943a52cf2e Fix some build errors and typos 2025-05-07 12:11:48 -04:00