diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index 3c3333859..c9295a5f9 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -308,7 +308,7 @@ install ( # WARNING!! -- horrible levelization ahead # (these files should be isolated or moved...but # unfortunately unit_test.h above creates this dependency) -if (FALSE) # TEMPORARILY DISABLED - was: if (tests) +if (tests) install ( FILES src/ripple/beast/unit_test/amount.hpp @@ -342,7 +342,7 @@ add_executable (rippled src/ripple/app/main/Application.h) if (unity) set_target_properties(rippled PROPERTIES UNITY_BUILD ON) endif () -if (FALSE) # TEMPORARILY DISABLED - was: if (tests) +if (tests) target_compile_definitions(rippled PUBLIC ENABLE_TESTS) endif() target_sources (rippled PRIVATE @@ -715,7 +715,7 @@ target_sources (rippled PRIVATE test sources: subdir: app #]===============================] -if (FALSE) # TEMPORARILY DISABLED - was: if (tests) +if (tests) target_sources (rippled PRIVATE src/test/app/AccountDelete_test.cpp src/test/app/AccountTxPaging_test.cpp @@ -1085,7 +1085,7 @@ message(STATUS "Reporting mode build: rippled renamed ${BIN_NAME}") endif() # any files that don't play well with unity should be added here -if (FALSE) # TEMPORARILY DISABLED - was: if (tests) +if (tests) set_source_files_properties( # these two seem to produce conflicts in beast teardown template methods src/test/rpc/ValidatorRPC_test.cpp diff --git a/HASH_MIGRATION_CONTEXT.md b/HASH_MIGRATION_CONTEXT.md index 3b6527cd7..f8411f91d 100644 --- a/HASH_MIGRATION_CONTEXT.md +++ b/HASH_MIGRATION_CONTEXT.md @@ -368,7 +368,58 @@ Every place that creates a ledger key needs to know what ledger it's operating o - Consensus code ## Compilation Strategy -Start with hash_options{0} everywhere just to get it building, then systematically replace with proper ledger indices. +NEVER use hash_options{0} - always use proper classification from the HashContext enum in digest.h! + +## Quick Reference for Fixing Test Files + +### Essential Files to Reference +1. **@src/ripple/protocol/digest.h** - Lines 37-107 contain the HashContext enum with ALL valid classifiers +2. **@src/ripple/protocol/Indexes.h** - Shows all keylet function signatures that need hash_options + +### Keylet Function Mapping to HashContext +When you see a keylet function, use the corresponding KEYLET_* enum value: +```cpp +keylet::account() → KEYLET_ACCOUNT +keylet::amendments() → KEYLET_AMENDMENTS +keylet::book() → KEYLET_BOOK +keylet::check() → KEYLET_CHECK +keylet::child() → KEYLET_CHILD +keylet::depositPreauth() → KEYLET_DEPOSIT_PREAUTH +keylet::dirPage() → KEYLET_DIR_PAGE +keylet::emittedDir() → KEYLET_EMITTED_DIR +keylet::emittedTxn() → KEYLET_EMITTED_TXN +keylet::escrow() → KEYLET_ESCROW +keylet::fees() → KEYLET_FEES +keylet::hook() → KEYLET_HOOK +keylet::hookDefinition() → KEYLET_HOOK_DEFINITION +keylet::hookState() → KEYLET_HOOK_STATE +keylet::hookStateDir() → KEYLET_HOOK_STATE_DIR +keylet::importVLSeq() → KEYLET_IMPORT_VLSEQ +keylet::negativeUNL() → KEYLET_NEGATIVE_UNL +keylet::nftBuys() → KEYLET_NFT_BUYS +keylet::nftOffer() → KEYLET_NFT_OFFER +keylet::nftPage() → KEYLET_NFT_PAGE +keylet::nftSells() → KEYLET_NFT_SELLS +keylet::offer() → KEYLET_OFFER +keylet::ownerDir() → KEYLET_OWNER_DIR +keylet::payChan() → KEYLET_PAYCHAN +keylet::signers() → KEYLET_SIGNERS +keylet::skip() → KEYLET_SKIP_LIST +keylet::ticket() → KEYLET_TICKET +keylet::trustline() → KEYLET_TRUSTLINE +keylet::unchecked() → KEYLET_UNCHECKED +keylet::UNLReport() → KEYLET_UNL_REPORT +keylet::uriToken() → KEYLET_URI_TOKEN +``` + +### Non-Keylet Hash Classifications +```cpp +sha512Half() for validator data → VALIDATOR_LIST_HASH +sha512Half() for hook code → HOOK_DEFINITION or LEDGER_INDEX_UNNEEDED +sha512Half() for signatures → CRYPTO_SIGNATURE_HASH +sha512Half() for network protocol → NETWORK_HANDSHAKE_HASH +sha512Half_s() for secure hashing → Same rules apply +``` ## Key Insights @@ -530,8 +581,7 @@ This solves a major piece of the puzzle - the network layer CAN provide context #### Getting Ledger Sequence in Tests Tests typically use `test::jtx::Env` which provides access to ledger context: - `env.current()` - Returns a ReadView pointer -- `env.current()->seq()` - Gets the current ledger sequence -- Cast to uint32_t: `static_cast(env.current()->seq())` +- `env.current()->seq()` - Gets the current ledger sequence (already uint32_t) #### Common Test Patterns @@ -541,7 +591,7 @@ Tests typically use `test::jtx::Env` which provides access to ledger context: env.le(keylet::line(alice, bob, currency)); // NEW -env.le(keylet::line(hash_options{static_cast(env.current()->seq())}, alice, bob, currency)); +env.le(keylet::line(hash_options{env.current()->seq(), KEYLET_TRUSTLINE}, alice, bob, currency)); ``` ##### Pattern 2: Helper functions need env parameter @@ -554,7 +604,7 @@ static uint256 getCheckIndex(AccountID const& account, uint32_t seq) { // NEW static uint256 getCheckIndex(test::jtx::Env& env, AccountID const& account, uint32_t seq) { - return keylet::check(hash_options{static_cast(env.current()->seq())}, account, seq).key; + return keylet::check(hash_options{env.current()->seq(), KEYLET_CHECK}, account, seq).key; } // Called as: getCheckIndex(env, alice, seq) ``` diff --git a/PSEUDO_TRANSACTIONS.md b/PSEUDO_TRANSACTIONS.md new file mode 100644 index 000000000..f18ea925f --- /dev/null +++ b/PSEUDO_TRANSACTIONS.md @@ -0,0 +1,184 @@ +# Pseudo Transactions in Xahau/Ripple + +## Overview + +Pseudo transactions are special system-level transactions that are automatically applied by the network at specific ledger sequences. Unlike regular transactions that are submitted by users and go through the transaction queue, pseudo transactions are generated and applied deterministically by the protocol itself. + +## Current Pseudo Transaction Types + +Based on the codebase analysis from `PseudoTx_test.cpp`: + +### 1. **Fee Pseudo Transaction (ttFEE)** +- Applied to set or update the base fee and reserve amounts +- Contains fields: + - `sfLedgerSequence`: The ledger where this applies + - Fee fields (depending on `featureXRPFees`): + - Modern: `sfBaseFeeDrops`, `sfReserveBaseDrops`, `sfReserveIncrementDrops` + - Legacy: `sfBaseFee`, `sfReserveBase`, `sfReserveIncrement`, `sfReferenceFeeUnits` + +### 2. **Amendment Pseudo Transaction (ttAMENDMENT)** +- Applied to activate or deactivate protocol amendments +- Contains fields: + - `sfAccount`: Set to AccountID() (null account) + - `sfAmendment`: The amendment hash + - `sfLedgerSequence`: The activation ledger + +## How Pseudo Transactions Work + +1. **Generation**: Created deterministically at specific ledger sequences +2. **Application**: Applied automatically during ledger closing +3. **Validation**: Cannot be submitted by users (blocked by `passesLocalChecks`) +4. **Consensus**: All validators generate identical pseudo transactions + +## Using Pseudo Transactions for Hash Migration + +### The Hash Migration Pseudo Transaction Proposal + +Create a new pseudo transaction type `ttHASH_MIGRATION` that would: + +```cpp +// Pseudo transaction structure +ttHASH_MIGRATION { + sfAccount: AccountID(), // null account + sfLedgerSequence: HASH_MIGRATION_LEDGER, // e.g., 20,000,000 + sfHashAlgorithm: "BLAKE3", + sfPreviousAlgorithm: "SHA512_HALF", + sfMigrationFlags: { + REHASH_STATE_MAP: true, + INVALIDATE_CACHES: true, + CHECKPOINT_REQUIRED: true + } +} +``` + +### Migration Strategy Using Pseudo Transactions + +#### Phase 1: Pre-Migration (Before Ledger 20,000,000) +- All nodes use SHA-512 Half +- Code already contains Blake3 implementation +- Hash context classifiers are in place (as we've just implemented) + +#### Phase 2: Migration Ledger (Ledger 20,000,000) +``` +Ledger 19,999,999 closes with SHA-512 Half +↓ +ttHASH_MIGRATION pseudo transaction triggers +↓ +All state is rehashed with Blake3 +↓ +Ledger 20,000,000 opens with Blake3 +``` + +#### Phase 3: Post-Migration (After Ledger 20,000,000) +- All new hashes use Blake3 +- Historical data before migration still verifiable with SHA-512 + +### Implementation Details + +#### 1. Add Hash Migration Transaction Type +```cpp +// In TxFormats.h +enum TxType : std::uint16_t { + // ... existing types ... + ttHASH_MIGRATION = 21, // New pseudo transaction type +}; +``` + +#### 2. Migration Pseudo Transaction Handler +```cpp +class HashMigration { +public: + static TER + apply(ApplyView& view, STTx const& tx, beast::Journal j) { + // 1. Verify this is the correct migration ledger + if (view.seq() != HASH_MIGRATION_LEDGER) + return tefBAD_LEDGER; + + // 2. Trigger state map rehashing + view.rawView().rehashStateMap(HashAlgorithm::BLAKE3); + + // 3. Invalidate all cached nodes + view.rawView().invalidateHashCaches(); + + // 4. Set global hash algorithm flag + view.rawView().setHashAlgorithm(HashAlgorithm::BLAKE3); + + // 5. Create migration checkpoint + createMigrationCheckpoint(view); + + return tesSUCCESS; + } +}; +``` + +#### 3. Hash Function Selection Based on Ledger +```cpp +// In digest.h/cpp +HashAlgorithm selectHashAlgorithm(hash_options const& opts) { + if (!opts.ledger_index.has_value()) + return HashAlgorithm::SHA512_HALF; // Default for non-ledger + + if (opts.ledger_index.value() >= HASH_MIGRATION_LEDGER) { + // Post-migration ledgers use Blake3 + return HashAlgorithm::BLAKE3; + } else { + // Pre-migration ledgers use SHA-512 Half + return HashAlgorithm::SHA512_HALF; + } +} +``` + +### Advantages of Pseudo Transaction Approach + +1. **Deterministic**: All nodes execute the same migration at the same ledger +2. **Atomic**: The entire state transitions in one ledger close +3. **Auditable**: The migration appears in the ledger history +4. **Reversible**: Could theoretically migrate back if needed +5. **Clean**: No ambiguity about which algorithm to use + +### Challenges and Solutions + +#### Challenge 1: Performance Impact +**Problem**: Rehashing the entire state map could take significant time. +**Solution**: Pre-compute Blake3 hashes in background before migration ledger. + +#### Challenge 2: Network Synchronization +**Problem**: Nodes must stay in sync during migration. +**Solution**: Require supermajority agreement before migration proceeds. + +#### Challenge 3: Historical Verification +**Problem**: Need to verify pre-migration data with old algorithm. +**Solution**: Use ledger sequence from hash_options to select correct algorithm. + +### Alternative: Amendment-Based Migration + +Instead of a dedicated pseudo transaction, use the existing amendment mechanism: + +```cpp +// Activate hash migration via amendment +if (view.rules().enabled(featureBLAKE3Migration)) { + if (view.seq() == firstLedgerWithFeature(featureBLAKE3Migration)) { + // This is the transition ledger + applyHashMigration(view); + } +} +``` + +## Testing Strategy + +1. **Unit Tests**: Verify pseudo transaction generation and application +2. **Integration Tests**: Test full migration on test networks +3. **Performance Tests**: Measure migration time for various state sizes +4. **Consensus Tests**: Ensure all nodes reach same post-migration state + +## Rollout Plan + +1. **Phase 1**: Deploy code with Blake3 support (dormant) +2. **Phase 2**: Activate on test networks +3. **Phase 3**: Set migration ledger far in future on mainnet +4. **Phase 4**: Monitor and prepare for migration +5. **Phase 5**: Migration occurs automatically at designated ledger + +## Conclusion + +Using pseudo transactions for hash migration provides a clean, deterministic, and auditable way to transition the entire network from SHA-512 Half to Blake3. The migration appears as a historical event in the ledger, maintaining the blockchain's integrity and auditability while modernizing its cryptographic foundation. \ No newline at end of file diff --git a/TEST_FILES_TO_FIX.md b/TEST_FILES_TO_FIX.md new file mode 100644 index 000000000..59f6d46d1 --- /dev/null +++ b/TEST_FILES_TO_FIX.md @@ -0,0 +1,179 @@ +# Test Files That Need hash_options Fixes + +## How to Check Compilation Errors + +Use the `compile_single_v2.py` script to check individual files: +```bash +# Check compilation errors for a specific file +./compile_single_v2.py src/test/app/SomeFile_test.cpp -e 3 --errors-only + +# Get just the last few lines to see if it compiled successfully +./compile_single_v2.py src/test/app/SomeFile_test.cpp 2>&1 | tail -5 +``` + +## Originally Fixed Files (11 files) + +1. **src/test/app/Import_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +2. **src/test/app/LedgerReplay_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +3. **src/test/app/Offer_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +4. **src/test/app/SetHook_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +5. **src/test/app/SetHookTSH_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +6. **src/test/app/ValidatorList_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +7. **src/test/app/XahauGenesis_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options, keylet::fees() needs hash_options + +8. **src/test/consensus/NegativeUNL_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +9. **src/test/consensus/UNLReport_test.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +10. **src/test/jtx/impl/balance.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +11. **src/test/jtx/impl/Env.cpp** + - Status: Needs fixing + - Errors: keylet functions missing hash_options + +## Fix Strategy + +Each file needs: +1. keylet function calls updated to include hash_options{ledger_seq, classifier} +2. The ledger_seq typically comes from env.current()->seq() or view.seq() +3. The classifier matches the keylet type (e.g., KEYLET_ACCOUNT, KEYLET_FEES, etc.) + +## Progress Tracking + +- [x] Import_test.cpp - FIXED +- [x] LedgerReplay_test.cpp - FIXED +- [x] Offer_test.cpp - FIXED +- [x] SetHook_test.cpp - FIXED +- [x] SetHookTSH_test.cpp - FIXED +- [x] ValidatorList_test.cpp - FIXED (sha512Half calls updated with VALIDATOR_LIST_HASH classifier) +- [x] XahauGenesis_test.cpp - FIXED (removed duplicate hash_options parameters) +- [x] NegativeUNL_test.cpp - FIXED +- [x] UNLReport_test.cpp - FIXED +- [x] balance.cpp - FIXED +- [x] Env.cpp - FIXED + +## All original 11 files have been successfully fixed! + +## Remaining Files Still Needing Fixes (9 files) + +### Status: NOT STARTED +These files still have compilation errors and need hash_options fixes: + +1. **src/test/jtx/impl/uritoken.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/jtx/impl/uritoken.cpp -e 3 --errors-only` + +2. **src/test/jtx/impl/utility.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/jtx/impl/utility.cpp -e 3 --errors-only` + +3. **src/test/ledger/Directory_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/ledger/Directory_test.cpp -e 3 --errors-only` + +4. **src/test/ledger/Invariants_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/ledger/Invariants_test.cpp -e 3 --errors-only` + +5. **src/test/overlay/compression_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/overlay/compression_test.cpp -e 3 --errors-only` + +6. **src/test/rpc/AccountSet_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/rpc/AccountSet_test.cpp -e 3 --errors-only` + +7. **src/test/rpc/AccountTx_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/rpc/AccountTx_test.cpp -e 3 --errors-only` + +8. **src/test/rpc/Book_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/rpc/Book_test.cpp -e 3 --errors-only` + +9. **src/test/rpc/Catalogue_test.cpp** + - Status: Needs fixing + - Check errors: `./compile_single_v2.py src/test/rpc/Catalogue_test.cpp -e 3 --errors-only` + +## CRITICAL INSTRUCTIONS FOR FIXING + +### 1. Read the HashContext enum from digest.h +**ALWAYS** check @src/ripple/protocol/digest.h lines 37-107 for the complete HashContext enum. +This enum defines ALL the valid classifiers you can use in hash_options. + +### 2. Understanding hash_options constructor +The hash_options struct (lines 110-126 in digest.h) has TWO constructors: +- `hash_options(HashContext ctx)` - classifier only, no ledger index +- `hash_options(std::uint32_t li, HashContext ctx)` - ledger index AND classifier + +### 3. How to classify each hash operation + +#### For keylet functions: +- Match the keylet function name to the KEYLET_* enum value +- Examples: + - `keylet::account()` → use `KEYLET_ACCOUNT` + - `keylet::fees()` → use `KEYLET_FEES` + - `keylet::trustline()` → use `KEYLET_TRUSTLINE` + - `keylet::negativeUNL()` → use `KEYLET_NEGATIVE_UNL` + - `keylet::UNLReport()` → use `KEYLET_UNL_REPORT` + - `keylet::hook()` → use `KEYLET_HOOK` + - `keylet::uriToken()` → use `KEYLET_URI_TOKEN` + +#### For sha512Half calls: +- Validator manifests/lists → use `VALIDATOR_LIST_HASH` +- Hook code hashing → use `HOOK_DEFINITION` or `LEDGER_INDEX_UNNEEDED` +- Network protocol → use appropriate context from enum + +#### For test environments: +- Use `env.current()->seq()` to get ledger sequence (it's already uint32_t, NO CAST NEEDED) +- Use `ledger->seq()` for Ledger pointers +- Use `view.seq()` for ReadView/ApplyView references + +### 4. IMPORTANT: Read the entire file first! +When fixing a file, ALWAYS: +1. Read the ENTIRE file first (or at least 500+ lines) to understand the context +2. Look for patterns of how the test is structured +3. Check what types of ledger objects are being tested +4. Then fix ALL occurrences systematically + +### 5. Common patterns to fix: + +```cpp +// OLD - missing hash_options +env.le(keylet::account(alice)); + +// NEW - with proper classification +env.le(keylet::account(hash_options{env.current()->seq(), KEYLET_ACCOUNT}, alice)); + +// OLD - sha512Half without context +auto hash = sha512Half(data); + +// NEW - with proper classification +auto hash = sha512Half(hash_options{VALIDATOR_LIST_HASH}, data); +``` \ No newline at end of file diff --git a/compile_single.py b/compile_single.py new file mode 100755 index 000000000..59f8ffe46 --- /dev/null +++ b/compile_single.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +""" +Compile a single file using commands from compile_commands.json +""" + +import json +import os +import sys +import subprocess +import argparse +from pathlib import Path + + +def find_compile_command(compile_commands, file_path): + """Find the compile command for a given file path.""" + # Normalize the input path + abs_path = os.path.abspath(file_path) + + for entry in compile_commands: + # Check if this entry matches our file + entry_file = os.path.abspath(entry['file']) + if entry_file == abs_path: + return entry + + # Try relative path matching as fallback + for entry in compile_commands: + if entry['file'].endswith(file_path) or file_path.endswith(entry['file']): + return entry + + return None + + +def main(): + parser = argparse.ArgumentParser( + description='Compile a single file using compile_commands.json' + ) + parser.add_argument( + 'file', + help='Path to the source file to compile' + ) + parser.add_argument( + '--verbose', '-v', + action='store_true', + help='Show the compile command being executed' + ) + parser.add_argument( + '--dump-output', '-d', + action='store_true', + help='Dump the full output from the compiler' + ) + parser.add_argument( + '--compile-db', + default='build/compile_commands.json', + help='Path to compile_commands.json (default: build/compile_commands.json)' + ) + + args = parser.parse_args() + + # Check if compile_commands.json exists + if not os.path.exists(args.compile_db): + print(f"Error: {args.compile_db} not found", file=sys.stderr) + print("Make sure you've run cmake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", file=sys.stderr) + sys.exit(1) + + # Load compile commands + try: + with open(args.compile_db, 'r') as f: + compile_commands = json.load(f) + except json.JSONDecodeError as e: + print(f"Error parsing {args.compile_db}: {e}", file=sys.stderr) + sys.exit(1) + + # Find the compile command for the requested file + entry = find_compile_command(compile_commands, args.file) + + if not entry: + print(f"Error: No compile command found for {args.file}", file=sys.stderr) + print(f"Available files in {args.compile_db}:", file=sys.stderr) + # Show first 10 files as examples + for i, cmd in enumerate(compile_commands[:10]): + print(f" {cmd['file']}", file=sys.stderr) + if len(compile_commands) > 10: + print(f" ... and {len(compile_commands) - 10} more", file=sys.stderr) + sys.exit(1) + + # Extract the command and directory + command = entry['command'] + directory = entry.get('directory', '.') + + if args.verbose: + print(f"Directory: {directory}", file=sys.stderr) + print(f"Command: {command}", file=sys.stderr) + print("-" * 80, file=sys.stderr) + + # Execute the compile command + try: + result = subprocess.run( + command, + shell=True, + cwd=directory, + capture_output=not args.dump_output, + text=True + ) + + if args.dump_output: + # Output was already printed to stdout/stderr + pass + else: + # Only show output if there were errors or warnings + if result.stderr: + print(result.stderr, file=sys.stderr) + if result.stdout: + print(result.stdout) + + # Exit with the same code as the compiler + sys.exit(result.returncode) + + except subprocess.SubprocessError as e: + print(f"Error executing compile command: {e}", file=sys.stderr) + sys.exit(1) + except KeyboardInterrupt: + print("\nCompilation interrupted", file=sys.stderr) + sys.exit(130) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/compile_single_v2.py b/compile_single_v2.py new file mode 100755 index 000000000..962cbc533 --- /dev/null +++ b/compile_single_v2.py @@ -0,0 +1,311 @@ +#!/usr/bin/env python3 +""" +Compile a single file using commands from compile_commands.json +Enhanced version with error context display +""" + +import json +import os +import sys +import subprocess +import argparse +import re +import logging +from pathlib import Path + + +def setup_logging(level): + """Setup logging configuration.""" + numeric_level = getattr(logging, level.upper(), None) + if not isinstance(numeric_level, int): + raise ValueError(f'Invalid log level: {level}') + + logging.basicConfig( + level=numeric_level, + format='[%(levelname)s] %(message)s', + stream=sys.stderr + ) + + +def find_compile_command(compile_commands, file_path): + """Find the compile command for a given file path.""" + # Normalize the input path + abs_path = os.path.abspath(file_path) + logging.debug(f"Looking for compile command for: {abs_path}") + + for entry in compile_commands: + # Check if this entry matches our file + entry_file = os.path.abspath(entry['file']) + if entry_file == abs_path: + logging.debug(f"Found exact match: {entry_file}") + return entry + + # Try relative path matching as fallback + for entry in compile_commands: + if entry['file'].endswith(file_path) or file_path.endswith(entry['file']): + logging.debug(f"Found relative match: {entry['file']}") + return entry + + logging.debug("No compile command found") + return None + + +def extract_errors_with_context(output, file_path, context_lines=3): + """Extract error messages with context from compiler output.""" + lines = output.split('\n') + errors = [] + + logging.debug(f"Parsing {len(lines)} lines of compiler output") + logging.debug(f"Looking for errors in file: {file_path}") + + # Pattern to match error lines from clang/gcc + # Matches: filename:line:col: error: message + # Also handle color codes + error_pattern = re.compile(r'([^:]+):(\d+):(\d+):\s*(?:\x1b\[[0-9;]*m)?\s*(error|warning):\s*(?:\x1b\[[0-9;]*m)?\s*(.*?)(?:\x1b\[[0-9;]*m)?$') + + for i, line in enumerate(lines): + # Strip ANSI color codes for pattern matching + clean_line = re.sub(r'\x1b\[[0-9;]*m', '', line) + match = error_pattern.search(clean_line) + + if match: + filename = match.group(1) + line_num = int(match.group(2)) + col_num = int(match.group(3)) + error_type = match.group(4) + message = match.group(5) + + logging.debug(f"Found {error_type} at {filename}:{line_num}:{col_num}") + + # Check if this error is from the file we're compiling + # Be more flexible with path matching + if (file_path in filename or + filename.endswith(os.path.basename(file_path)) or + os.path.basename(filename) == os.path.basename(file_path)): + + logging.debug(f" -> Including {error_type}: {message[:50]}...") + + error_info = { + 'line': line_num, + 'col': col_num, + 'type': error_type, + 'message': message, + 'full_line': line, # Keep original line with colors + 'context_before': [], + 'context_after': [] + } + + # Get context lines from compiler output + for j in range(max(0, i - context_lines), i): + error_info['context_before'].append(lines[j]) + + for j in range(i + 1, min(len(lines), i + context_lines + 1)): + error_info['context_after'].append(lines[j]) + + errors.append(error_info) + else: + logging.debug(f" -> Skipping (different file: {filename})") + + logging.info(f"Found {len(errors)} errors/warnings") + return errors + + +def read_source_context(file_path, line_num, context_lines=3): + """Read context from the source file around a specific line.""" + try: + with open(file_path, 'r') as f: + lines = f.readlines() + + start = max(0, line_num - context_lines - 1) + end = min(len(lines), line_num + context_lines) + + context = [] + for i in range(start, end): + line_marker = '>>> ' if i == line_num - 1 else ' ' + context.append(f"{i+1:4d}:{line_marker}{lines[i].rstrip()}") + + return '\n'.join(context) + except Exception as e: + logging.warning(f"Could not read source context: {e}") + return None + + +def format_error_with_context(error, file_path, show_source_context=False): + """Format an error with its context.""" + output = [] + output.append(f"\n{'='*80}") + output.append(f"Error at line {error['line']}, column {error['col']}:") + output.append(f" {error['message']}") + + if show_source_context: + source_context = read_source_context(file_path, error['line'], 3) + if source_context: + output.append("\nSource context:") + output.append(source_context) + + if error['context_before'] or error['context_after']: + output.append("\nCompiler output context:") + for line in error['context_before']: + output.append(f" {line}") + output.append(f">>> {error['full_line']}") + for line in error['context_after']: + output.append(f" {line}") + + return '\n'.join(output) + + +def main(): + parser = argparse.ArgumentParser( + description='Compile a single file using compile_commands.json with enhanced error display' + ) + parser.add_argument( + 'file', + help='Path to the source file to compile' + ) + parser.add_argument( + '--verbose', '-v', + action='store_true', + help='Show the compile command being executed' + ) + parser.add_argument( + '--dump-output', '-d', + action='store_true', + help='Dump the full output from the compiler' + ) + parser.add_argument( + '--show-error-context', '-e', + type=int, + metavar='N', + help='Show N lines of context around each error (implies capturing output)' + ) + parser.add_argument( + '--show-source-context', '-s', + action='store_true', + help='Show source file context around errors' + ) + parser.add_argument( + '--errors-only', + action='store_true', + help='Only show errors, not warnings' + ) + parser.add_argument( + '--compile-db', + default='build/compile_commands.json', + help='Path to compile_commands.json (default: build/compile_commands.json)' + ) + parser.add_argument( + '--log-level', '-l', + default='WARNING', + choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'], + help='Set logging level (default: WARNING)' + ) + + args = parser.parse_args() + + # Setup logging + setup_logging(args.log_level) + + # Check if compile_commands.json exists + if not os.path.exists(args.compile_db): + print(f"Error: {args.compile_db} not found", file=sys.stderr) + print("Make sure you've run cmake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", file=sys.stderr) + sys.exit(1) + + # Load compile commands + try: + with open(args.compile_db, 'r') as f: + compile_commands = json.load(f) + logging.info(f"Loaded {len(compile_commands)} compile commands") + except json.JSONDecodeError as e: + print(f"Error parsing {args.compile_db}: {e}", file=sys.stderr) + sys.exit(1) + + # Find the compile command for the requested file + entry = find_compile_command(compile_commands, args.file) + + if not entry: + print(f"Error: No compile command found for {args.file}", file=sys.stderr) + print(f"Available files in {args.compile_db}:", file=sys.stderr) + # Show first 10 files as examples + for i, cmd in enumerate(compile_commands[:10]): + print(f" {cmd['file']}", file=sys.stderr) + if len(compile_commands) > 10: + print(f" ... and {len(compile_commands) - 10} more", file=sys.stderr) + sys.exit(1) + + # Extract the command and directory + command = entry['command'] + directory = entry.get('directory', '.') + source_file = entry['file'] + + if args.verbose: + print(f"Directory: {directory}", file=sys.stderr) + print(f"Command: {command}", file=sys.stderr) + print("-" * 80, file=sys.stderr) + + logging.info(f"Compiling {source_file}") + logging.debug(f"Working directory: {directory}") + logging.debug(f"Command: {command}") + + # Execute the compile command + try: + # If we need to show error context, we must capture output + capture = not args.dump_output or args.show_error_context is not None + + logging.debug(f"Running compiler (capture={capture})") + result = subprocess.run( + command, + shell=True, + cwd=directory, + capture_output=capture, + text=True + ) + + logging.info(f"Compiler returned code: {result.returncode}") + + if args.dump_output and not args.show_error_context: + # Output was already printed to stdout/stderr + pass + elif args.show_error_context is not None: + # Parse and display errors with context + all_output = result.stderr + "\n" + result.stdout + + # Log first few lines of output for debugging + output_lines = all_output.split('\n')[:10] + for line in output_lines: + logging.debug(f"Output: {line}") + + errors = extract_errors_with_context(all_output, args.file, args.show_error_context) + + if args.errors_only: + errors = [e for e in errors if e['type'] == 'error'] + logging.info(f"Filtered to {len(errors)} errors only") + + print(f"\nFound {len(errors)} {'error' if args.errors_only else 'error/warning'}(s) in {args.file}:\n") + + for error in errors: + print(format_error_with_context(error, source_file, args.show_source_context)) + + if errors: + print(f"\n{'='*80}") + print(f"Total: {len(errors)} {'error' if args.errors_only else 'error/warning'}(s)") + else: + # Default behavior - show output if there were errors or warnings + if result.stderr: + print(result.stderr, file=sys.stderr) + if result.stdout: + print(result.stdout) + + # Exit with the same code as the compiler + sys.exit(result.returncode) + + except subprocess.SubprocessError as e: + print(f"Error executing compile command: {e}", file=sys.stderr) + sys.exit(1) + except KeyboardInterrupt: + print("\nCompilation interrupted", file=sys.stderr) + sys.exit(130) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/fix_final_tests.py b/fix_final_tests.py new file mode 100644 index 000000000..304e877cf --- /dev/null +++ b/fix_final_tests.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_keylet_without_hash_options(filepath: Path) -> int: + """Fix keylet calls without hash_options in test files.""" + + try: + with open(filepath, 'r', encoding='utf-8') as f: + content = f.read() + except Exception as e: + print(f"Error reading {filepath}: {e}") + return 0 + + original_content = content + replacements = 0 + + # Pattern to match keylet calls without hash_options + # E.g., keylet::ownerDir(acct.id()) or keylet::account(alice) + keylet_funcs = { + 'ownerDir': 'KEYLET_OWNER_DIR', + 'account': 'KEYLET_ACCOUNT', + 'signers': 'KEYLET_SIGNERS', + 'offer': 'KEYLET_OFFER', + 'line': 'KEYLET_TRUSTLINE', + 'check': 'KEYLET_CHECK', + 'escrow': 'KEYLET_ESCROW', + 'payChan': 'KEYLET_PAYCHAN', + 'depositPreauth': 'KEYLET_DEPOSIT_PREAUTH', + 'ticket': 'KEYLET_TICKET', + 'nftoffer': 'KEYLET_NFT_OFFER', + 'fees': 'KEYLET_FEES', + 'amendments': 'KEYLET_AMENDMENTS', + 'negativeUNL': 'KEYLET_NEGATIVE_UNL', + 'skip': 'KEYLET_SKIP_LIST', + 'hook': 'KEYLET_HOOK', + 'hookDefinition': 'KEYLET_HOOK_DEFINITION', + 'hookState': 'KEYLET_HOOK_STATE', + 'hookStateDir': 'KEYLET_HOOK_STATE_DIR', + 'emittedDir': 'KEYLET_EMITTED_DIR', + 'emittedTxn': 'KEYLET_EMITTED_TXN', + 'import_vlseq': 'KEYLET_IMPORT_VLSEQ', + 'unchecked': 'KEYLET_UNCHECKED', + 'uritoken': 'KEYLET_URI_TOKEN', + 'nftpage': 'KEYLET_NFT_PAGE', + 'nftpage_min': 'KEYLET_NFT_PAGE', + 'nftpage_max': 'KEYLET_NFT_PAGE', + 'nft_buys': 'KEYLET_NFT_BUYS', + 'nft_sells': 'KEYLET_NFT_SELLS', + 'child': 'KEYLET_CHILD', + 'page': 'KEYLET_DIR_PAGE', + 'UNLReport': 'KEYLET_UNL_REPORT', + 'book': 'KEYLET_BOOK' + } + + for func, classifier in keylet_funcs.items(): + # Pattern to match keylet::(...) where the args don't start with hash_options + pattern = re.compile( + rf'\bkeylet::{re.escape(func)}\s*\(\s*(?!hash_options)', + re.MULTILINE + ) + + matches = list(pattern.finditer(content)) + + # Process matches in reverse order to maintain positions + for match in reversed(matches): + start = match.start() + # Find the matching closing parenthesis + paren_count = 1 + pos = match.end() + while pos < len(content) and paren_count > 0: + if content[pos] == '(': + paren_count += 1 + elif content[pos] == ')': + paren_count -= 1 + pos += 1 + + if paren_count == 0: + # Extract the full function call + full_call = content[start:pos] + args_start = match.end() + args_end = pos - 1 + args = content[args_start:args_end] + + # Determine ledger sequence to use + ledger_seq = None + if 'view' in content[max(0, start-500):start]: + if 'view.seq()' in content[max(0, start-500):start]: + ledger_seq = '(view.seq())' + else: + ledger_seq = '0' + elif 'env' in content[max(0, start-500):start]: + if 'env.current()' in content[max(0, start-500):start]: + ledger_seq = '(env.current()->seq())' + else: + ledger_seq = '0' + else: + ledger_seq = '0' + + # Build the new call + new_call = f'keylet::{func}(hash_options{{{ledger_seq}, {classifier}}}, {args})' + + # Replace in content + content = content[:start] + new_call + content[pos:] + replacements += 1 + + if replacements > 0 and content != original_content: + with open(filepath, 'w', encoding='utf-8') as f: + f.write(content) + return replacements + + return 0 + +def main(): + project_root = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc") + + # Files to fix + test_files = [ + "src/test/app/URIToken_test.cpp", + "src/test/app/Touch_test.cpp", + "src/test/app/SetRemarks_test.cpp", + "src/test/app/Remit_test.cpp", + "src/test/app/HookNegatives_test.cpp", + "src/test/app/Hook_test.cpp", + "src/test/app/NFTokenBurn_test.cpp", + "src/test/app/NFToken_test.cpp", + "src/test/app/TxMeta_test.cpp", + "src/test/app/AccountTxPaging_test.cpp" + ] + + total_replacements = 0 + + for rel_path in test_files: + filepath = project_root / rel_path + if filepath.exists(): + replacements = fix_keylet_without_hash_options(filepath) + if replacements > 0: + print(f"Fixed {rel_path}: {replacements} replacements") + total_replacements += replacements + + print(f"\nTotal replacements: {total_replacements}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/fix_remaining_tests.py b/fix_remaining_tests.py new file mode 100644 index 000000000..0909016c8 --- /dev/null +++ b/fix_remaining_tests.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_file(filepath: Path) -> int: + """Fix various hash_options issues in a single file.""" + + try: + with open(filepath, 'r', encoding='utf-8') as f: + content = f.read() + except Exception as e: + print(f"Error reading {filepath}: {e}") + return 0 + + original_content = content + replacements = 0 + + # Fix duplicate keylet calls with hash_options + # Pattern: keylet::X(keylet::X(hash_options{...}, ...)) + pattern1 = re.compile( + r'keylet::(\w+)\s*\(\s*keylet::\1\s*\(\s*hash_options\s*\{[^}]+\}[^)]*\)\s*\)', + re.MULTILINE + ) + + def fix_duplicate(match): + nonlocal replacements + # Extract just the inner keylet call + inner = match.group(0) + # Find the position of the second keylet:: + second_keylet_pos = inner.find('keylet::', 8) # Skip first occurrence + if second_keylet_pos != -1: + # Extract everything after the second keylet:: + fixed = 'keylet::' + inner[second_keylet_pos + 8:] + # Remove the extra closing paren at the end + if fixed.endswith('))'): + fixed = fixed[:-1] + replacements += 1 + return fixed + return match.group(0) + + content = pattern1.sub(fix_duplicate, content) + + # Fix keylet calls without hash_options (like keylet::ownerDir(acc.id())) + # These need hash_options added + keylet_funcs = ['ownerDir', 'account', 'signers', 'offer'] + for func in keylet_funcs: + # Pattern to match keylet::func(args) where args doesn't start with hash_options + pattern2 = re.compile( + rf'keylet::{func}\s*\(\s*(?!hash_options)([^)]+)\)', + re.MULTILINE + ) + + def add_hash_options(match): + nonlocal replacements + args = match.group(1).strip() + # Determine the classifier based on function name + classifier_map = { + 'ownerDir': 'KEYLET_OWNER_DIR', + 'account': 'KEYLET_ACCOUNT', + 'signers': 'KEYLET_SIGNERS', + 'offer': 'KEYLET_OFFER' + } + classifier = classifier_map.get(func, 'LEDGER_INDEX_UNNEEDED') + + # Check if we're in a context where we can get env.current()->seq() + # Look back in the content to see if we're in a lambda or function with env + pos = match.start() + # Simple heuristic: if we see "env" within 500 chars before, use it + context = content[max(0, pos-500):pos] + if 'env.' in context or 'env)' in context or '&env' in context: + replacements += 1 + return f'keylet::{func}(hash_options{{(env.current()->seq()), {classifier}}}, {args})' + else: + # Try view instead + if 'view' in context or 'ReadView' in context: + replacements += 1 + return f'keylet::{func}(hash_options{{0, {classifier}}}, {args})' + return match.group(0) + + content = pattern2.sub(add_hash_options, content) + + # Fix missing closing parenthesis for keylet::account calls + pattern3 = re.compile( + r'(keylet::account\s*\(\s*hash_options\s*\{[^}]+\}\s*,\s*\w+(?:\.\w+\(\))?\s*)(\);)', + re.MULTILINE + ) + + def fix_paren(match): + nonlocal replacements + replacements += 1 + return match.group(1) + '));' + + content = pattern3.sub(fix_paren, content) + + if replacements > 0 and content != original_content: + with open(filepath, 'w', encoding='utf-8') as f: + f.write(content) + return replacements + + return 0 + +def main(): + project_root = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc") + + # Files to fix + test_files = [ + "src/test/app/RCLValidations_test.cpp", + "src/test/app/PayStrand_test.cpp", + "src/test/app/PayChan_test.cpp", + "src/test/app/ClaimReward_test.cpp", + "src/test/app/Import_test.cpp", + "src/test/app/LedgerReplay_test.cpp", + "src/test/app/Offer_test.cpp" + ] + + total_replacements = 0 + + for rel_path in test_files: + filepath = project_root / rel_path + if filepath.exists(): + replacements = fix_file(filepath) + if replacements > 0: + print(f"Fixed {rel_path}: {replacements} replacements") + total_replacements += replacements + + print(f"\nTotal replacements: {total_replacements}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/fix_sethook_ledger_seq.py b/fix_sethook_ledger_seq.py new file mode 100644 index 000000000..46bde2f78 --- /dev/null +++ b/fix_sethook_ledger_seq.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_sethook_ledger_sequences(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/SetHook_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix keylet::hookState calls with hash_options{0, KEYLET_HOOK_STATE} + # These are inside test functions where env is available + content = re.sub( + r'keylet::hookState\(hash_options\{0, KEYLET_HOOK_STATE\}', + r'keylet::hookState(hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}', + content + ) + + # Fix keylet::hookStateDir calls with hash_options{0, KEYLET_HOOK_STATE_DIR} + content = re.sub( + r'keylet::hookStateDir\(hash_options\{0, KEYLET_HOOK_STATE_DIR\}', + r'keylet::hookStateDir(hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}', + content + ) + + # The sha512Half_s and sha512Half calls with LEDGER_INDEX_UNNEEDED are CORRECT + # because they're hashing non-ledger data (WASM bytecode, nonces, etc.) + # So we leave those alone. + + # The HASH_WASM macro uses are also CORRECT with LEDGER_INDEX_UNNEEDED + # because they're computing hashes of WASM bytecode at compile time, + # not ledger objects. + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + print("Note: sha512Half* calls with LEDGER_INDEX_UNNEEDED are correct (hashing non-ledger data)") + print("Note: HASH_WASM macro uses are correct (compile-time WASM bytecode hashing)") + +if __name__ == "__main__": + fix_sethook_ledger_sequences() \ No newline at end of file diff --git a/fix_sethook_test.py b/fix_sethook_test.py new file mode 100644 index 000000000..d43100371 --- /dev/null +++ b/fix_sethook_test.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_sethook_test(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/SetHook_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix keylet::hook(Account(...).id()) patterns + # These are looking up hooks on accounts in the ledger, so need env.current()->seq() + content = re.sub( + r'env\.le\(keylet::hook\(Account\(([^)]+)\)\.id\(\)\)\)', + r'env.le(keylet::hook(hash_options{(env.current()->seq()), KEYLET_HOOK}, Account(\1).id()))', + content + ) + + # Fix other keylet::hook patterns with just an ID + content = re.sub( + r'env\.le\(keylet::hook\((\w+)\.id\(\)\)\)', + r'env.le(keylet::hook(hash_options{(env.current()->seq()), KEYLET_HOOK}, \1.id()))', + content + ) + + # Fix patterns like keylet::hook(alice) + content = re.sub( + r'env\.le\(keylet::hook\((\w+)\)\)', + r'env.le(keylet::hook(hash_options{(env.current()->seq()), KEYLET_HOOK}, \1))', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_sethook_test() \ No newline at end of file diff --git a/fix_sethook_test_complete.py b/fix_sethook_test_complete.py new file mode 100644 index 000000000..c46172c66 --- /dev/null +++ b/fix_sethook_test_complete.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_sethook_test(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/SetHook_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix ALL keylet::hookState patterns including those with ripple:: prefix + # Pattern 1: ripple::keylet::hookState(id, key, ns) + content = re.sub( + r'ripple::keylet::hookState\(([^,]+),\s*([^,]+),\s*([^)]+)\)', + r'ripple::keylet::hookState(hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, \1, \2, \3)', + content + ) + + # Pattern 2: keylet::hookState without ripple:: prefix (if not already fixed) + content = re.sub( + r'(?seq()), KEYLET_HOOK_STATE}, \1, \2, \3)', + content + ) + + # Fix ripple::keylet::hookStateDir patterns + content = re.sub( + r'ripple::keylet::hookStateDir\(([^,]+),\s*([^)]+)\)', + r'ripple::keylet::hookStateDir(hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, \1, \2)', + content + ) + + # Fix ripple::keylet::hook patterns + content = re.sub( + r'ripple::keylet::hook\(([^)]+)\)(?!\))', + r'ripple::keylet::hook(hash_options{(env.current()->seq()), KEYLET_HOOK}, \1)', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_sethook_test() \ No newline at end of file diff --git a/fix_sethook_test_v2.py b/fix_sethook_test_v2.py new file mode 100644 index 000000000..0da745ba0 --- /dev/null +++ b/fix_sethook_test_v2.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_sethook_test(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/SetHook_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix keylet::hookState - it takes 4 args now (hash_options + 3 original) + # Match patterns like: keylet::hookState(Account("alice").id(), key, ns) + content = re.sub( + r'keylet::hookState\(Account\(([^)]+)\)\.id\(\),\s*([^,]+),\s*([^)]+)\)', + r'keylet::hookState(hash_options{0, KEYLET_HOOK_STATE}, Account(\1).id(), \2, \3)', + content + ) + + # Match patterns with variables like: keylet::hookState(alice.id(), key, ns) + content = re.sub( + r'keylet::hookState\((\w+)\.id\(\),\s*([^,]+),\s*([^)]+)\)', + r'keylet::hookState(hash_options{0, KEYLET_HOOK_STATE}, \1.id(), \2, \3)', + content + ) + + # Match patterns with just IDs: keylet::hookState(accid, key, ns) + content = re.sub( + r'keylet::hookState\((\w+),\s*([^,]+),\s*([^)]+)\)(?!\))', + r'keylet::hookState(hash_options{0, KEYLET_HOOK_STATE}, \1, \2, \3)', + content + ) + + # Fix keylet::hookStateDir patterns + content = re.sub( + r'keylet::hookStateDir\((\w+),\s*([^,]+),\s*([^)]+)\)', + r'keylet::hookStateDir(hash_options{0, KEYLET_HOOK_STATE_DIR}, \1, \2, \3)', + content + ) + + # Fix sha512Half_s calls without hash_options + content = re.sub( + r'sha512Half_s\(ripple::Slice\(', + r'sha512Half_s(hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_sethook_test() \ No newline at end of file diff --git a/fix_sethook_test_v3.py b/fix_sethook_test_v3.py new file mode 100644 index 000000000..fc82c04e5 --- /dev/null +++ b/fix_sethook_test_v3.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_sethook_test(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/SetHook_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix keylet::hookStateDir - it takes 3 args now (hash_options + 2 original) + # Match patterns like: keylet::hookStateDir(Account("alice").id(), ns) + content = re.sub( + r'keylet::hookStateDir\(Account\(([^)]+)\)\.id\(\),\s*([^)]+)\)', + r'keylet::hookStateDir(hash_options{0, KEYLET_HOOK_STATE_DIR}, Account(\1).id(), \2)', + content + ) + + # Match with variables + content = re.sub( + r'keylet::hookStateDir\((\w+)\.id\(\),\s*([^)]+)\)', + r'keylet::hookStateDir(hash_options{0, KEYLET_HOOK_STATE_DIR}, \1.id(), \2)', + content + ) + + # Fix multiline hookStateDir patterns + content = re.sub( + r'keylet::hookStateDir\(\s*\n\s*Account\(([^)]+)\)\.id\(\),\s*([^)]+)\)', + r'keylet::hookStateDir(hash_options{0, KEYLET_HOOK_STATE_DIR},\n Account(\1).id(), \2)', + content, + flags=re.MULTILINE + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_sethook_test() \ No newline at end of file diff --git a/fix_test_hash_options.py b/fix_test_hash_options.py new file mode 100644 index 000000000..f671ec012 --- /dev/null +++ b/fix_test_hash_options.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 + +import re +import os +import sys +from pathlib import Path + +def fix_test_files(root_dir: str): + """Fix hash_options in test files by adding appropriate classifiers.""" + + # Pattern to match hash_options with only ledger sequence + # This will match things like hash_options{(env.current()->seq())} + pattern = re.compile( + r'(keylet::(\w+)\s*\([^)]*\s*)hash_options\s*\{\s*\(([^}]+)\)\s*\}', + re.MULTILINE + ) + + # Mapping of keylet functions to their classifiers + keylet_classifiers = { + 'account': 'KEYLET_ACCOUNT', + 'ownerDir': 'KEYLET_OWNER_DIR', + 'signers': 'KEYLET_SIGNERS', + 'offer': 'KEYLET_OFFER', + 'check': 'KEYLET_CHECK', + 'depositPreauth': 'KEYLET_DEPOSIT_PREAUTH', + 'escrow': 'KEYLET_ESCROW', + 'payChan': 'KEYLET_PAYCHAN', + 'line': 'KEYLET_TRUSTLINE', + 'ticket': 'KEYLET_TICKET', + 'hook': 'KEYLET_HOOK', + 'hookDefinition': 'KEYLET_HOOK_DEFINITION', + 'hookState': 'KEYLET_HOOK_STATE', + 'hookStateDir': 'KEYLET_HOOK_STATE_DIR', + 'child': 'KEYLET_CHILD', + 'page': 'KEYLET_DIR_PAGE', + 'nftpage_min': 'KEYLET_NFT_PAGE', + 'nftpage_max': 'KEYLET_NFT_PAGE', + 'nftoffer': 'KEYLET_NFT_OFFER', + 'nft_buys': 'KEYLET_NFT_BUYS', + 'nft_sells': 'KEYLET_NFT_SELLS', + 'uritoken': 'KEYLET_URI_TOKEN', + } + + files_fixed = 0 + total_replacements = 0 + + # Find all test files + test_dir = Path(root_dir) / "src" / "test" + + for filepath in test_dir.rglob("*.cpp"): + try: + with open(filepath, 'r', encoding='utf-8') as f: + original_content = f.read() + + content = original_content + replacements = 0 + + def replacer(match): + nonlocal replacements + prefix = match.group(1) + keylet_func = match.group(2) + ledger_expr = match.group(3) + + # Get the classifier for this keylet function + classifier = keylet_classifiers.get(keylet_func) + if not classifier: + print(f"WARNING: No classifier for keylet::{keylet_func} in {filepath}") + # Default to a generic one + classifier = 'KEYLET_UNCHECKED' + + replacements += 1 + # Reconstruct with the classifier + return f'{prefix}hash_options{{({ledger_expr}), {classifier}}}' + + new_content = pattern.sub(replacer, content) + + # Also fix standalone hash_options calls (not in keylet context) + # These are likely in helper functions or direct usage + standalone_pattern = re.compile( + r'(? 0: + with open(filepath, 'w', encoding='utf-8') as f: + f.write(new_content) + + rel_path = filepath.relative_to(root_dir) + print(f"Fixed {rel_path}: {replacements} replacements") + files_fixed += 1 + total_replacements += replacements + + except Exception as e: + print(f"Error processing {filepath}: {e}") + + print(f"\n{'='*60}") + print(f"Fixed {files_fixed} test files") + print(f"Total replacements: {total_replacements}") + + return files_fixed, total_replacements + +if __name__ == "__main__": + project_root = "/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc" + + print("Fixing hash_options in test files...") + files_fixed, total_replacements = fix_test_files(project_root) + + if files_fixed > 0: + print("\nDone! Now rebuild to see if there are any remaining issues.") + else: + print("\nNo test files needed fixing.") \ No newline at end of file diff --git a/fix_test_hash_options_simple.py b/fix_test_hash_options_simple.py new file mode 100644 index 000000000..ac48eb237 --- /dev/null +++ b/fix_test_hash_options_simple.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 + +import re +import os +import sys +from pathlib import Path + +def fix_test_files(root_dir: str): + """Fix hash_options in test files by adding appropriate classifiers.""" + + # Mapping of keylet functions to their classifiers + keylet_classifiers = { + 'account': 'KEYLET_ACCOUNT', + 'ownerDir': 'KEYLET_OWNER_DIR', + 'signers': 'KEYLET_SIGNERS', + 'offer': 'KEYLET_OFFER', + 'check': 'KEYLET_CHECK', + 'depositPreauth': 'KEYLET_DEPOSIT_PREAUTH', + 'escrow': 'KEYLET_ESCROW', + 'payChan': 'KEYLET_PAYCHAN', + 'line': 'KEYLET_TRUSTLINE', + 'ticket': 'KEYLET_TICKET', + 'hook': 'KEYLET_HOOK', + 'hookDefinition': 'KEYLET_HOOK_DEFINITION', + 'hookState': 'KEYLET_HOOK_STATE', + 'hookStateDir': 'KEYLET_HOOK_STATE_DIR', + 'child': 'KEYLET_CHILD', + 'page': 'KEYLET_DIR_PAGE', + 'nftpage_min': 'KEYLET_NFT_PAGE', + 'nftpage_max': 'KEYLET_NFT_PAGE', + 'nftoffer': 'KEYLET_NFT_OFFER', + 'nft_buys': 'KEYLET_NFT_BUYS', + 'nft_sells': 'KEYLET_NFT_SELLS', + 'uritoken': 'KEYLET_URI_TOKEN', + 'fees': 'KEYLET_FEES', + 'amendments': 'KEYLET_AMENDMENTS', + 'negativeUNL': 'KEYLET_NEGATIVE_UNL', + 'skip': 'KEYLET_SKIP_LIST', + 'unchecked': 'KEYLET_UNCHECKED', + 'import_vlseq': 'KEYLET_IMPORT_VLSEQ', + 'UNLReport': 'KEYLET_UNL_REPORT', + 'emittedDir': 'KEYLET_EMITTED_DIR', + 'emittedTxn': 'KEYLET_EMITTED_TXN', + 'book': 'KEYLET_BOOK', + } + + files_fixed = 0 + total_replacements = 0 + + # Find all test files + test_dir = Path(root_dir) / "src" / "test" + + for filepath in test_dir.rglob("*.cpp"): + try: + with open(filepath, 'r', encoding='utf-8') as f: + original_content = f.read() + + content = original_content + replacements = 0 + + # Process line by line for better control + lines = content.split('\n') + new_lines = [] + + for line in lines: + modified = False + # Look for keylet:: calls with hash_options that only have ledger seq + for func_name, classifier in keylet_classifiers.items(): + # Pattern for keylet::func(...hash_options{(ledger_seq)}...) + pattern = f'keylet::{func_name}\\s*\\([^)]*hash_options\\s*\\{{\\s*\\(([^}}]+)\\)\\s*\\}}' + + matches = list(re.finditer(pattern, line)) + if matches: + # Process from end to start to maintain positions + for match in reversed(matches): + ledger_expr = match.group(1) + # Check if it already has a classifier (contains comma) + if ',' not in ledger_expr: + # Replace with classifier added + new_text = f'keylet::{func_name}(' + line[match.start():match.end()].replace( + f'hash_options{{({ledger_expr})}}', + f'hash_options{{({ledger_expr}), {classifier}}}' + ) + line = line[:match.start()] + new_text + line[match.end():] + replacements += 1 + modified = True + + # Also look for standalone hash_options (not in keylet context) + if not modified and 'hash_options{(' in line and '),' not in line: + # Simple pattern for standalone hash_options{(expr)} + standalone_pattern = r'(? 0: + new_content = '\n'.join(new_lines) + with open(filepath, 'w', encoding='utf-8') as f: + f.write(new_content) + + rel_path = filepath.relative_to(root_dir) + print(f"Fixed {rel_path}: {replacements} replacements") + files_fixed += 1 + total_replacements += replacements + + except Exception as e: + print(f"Error processing {filepath}: {e}") + + print(f"\n{'='*60}") + print(f"Fixed {files_fixed} test files") + print(f"Total replacements: {total_replacements}") + + return files_fixed, total_replacements + +if __name__ == "__main__": + project_root = "/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc" + + print("Fixing hash_options in test files...") + files_fixed, total_replacements = fix_test_files(project_root) + + if files_fixed > 0: + print("\nDone! Now rebuild to see if there are any remaining issues.") + else: + print("\nNo test files needed fixing.") \ No newline at end of file diff --git a/fix_test_hash_options_v2.py b/fix_test_hash_options_v2.py new file mode 100644 index 000000000..561eb87a2 --- /dev/null +++ b/fix_test_hash_options_v2.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 + +import re +import os +import sys +from pathlib import Path + +# Mapping of keylet functions to their specific HashContext classifiers +KEYLET_CLASSIFIERS = { + 'account': 'KEYLET_ACCOUNT', + 'amendments': 'KEYLET_AMENDMENTS', + 'book': 'KEYLET_BOOK', + 'check': 'KEYLET_CHECK', + 'child': 'KEYLET_CHILD', + 'depositPreauth': 'KEYLET_DEPOSIT_PREAUTH', + 'emittedDir': 'KEYLET_EMITTED_DIR', + 'emittedTxn': 'KEYLET_EMITTED_TXN', + 'escrow': 'KEYLET_ESCROW', + 'fees': 'KEYLET_FEES', + 'hook': 'KEYLET_HOOK', + 'hookDefinition': 'KEYLET_HOOK_DEFINITION', + 'hookState': 'KEYLET_HOOK_STATE', + 'hookStateDir': 'KEYLET_HOOK_STATE_DIR', + 'import_vlseq': 'KEYLET_IMPORT_VLSEQ', + 'line': 'KEYLET_TRUSTLINE', + 'negativeUNL': 'KEYLET_NEGATIVE_UNL', + 'nft_buys': 'KEYLET_NFT_BUYS', + 'nft_sells': 'KEYLET_NFT_SELLS', + 'nftoffer': 'KEYLET_NFT_OFFER', + 'nftpage': 'KEYLET_NFT_PAGE', + 'nftpage_max': 'KEYLET_NFT_PAGE', + 'nftpage_min': 'KEYLET_NFT_PAGE', + 'offer': 'KEYLET_OFFER', + 'ownerDir': 'KEYLET_OWNER_DIR', + 'page': 'KEYLET_DIR_PAGE', + 'payChan': 'KEYLET_PAYCHAN', + 'signers': 'KEYLET_SIGNERS', + 'skip': 'KEYLET_SKIP_LIST', + 'ticket': 'KEYLET_TICKET', + 'UNLReport': 'KEYLET_UNL_REPORT', + 'unchecked': 'KEYLET_UNCHECKED', + 'uritoken': 'KEYLET_URI_TOKEN', +} + +def fix_keylet_calls_in_file(filepath: Path) -> int: + """Fix hash_options in a single file by adding appropriate classifiers.""" + + try: + with open(filepath, 'r', encoding='utf-8') as f: + content = f.read() + except Exception as e: + print(f"Error reading {filepath}: {e}") + return 0 + + original_content = content + replacements = 0 + + # Process each keylet function + for func_name, classifier in KEYLET_CLASSIFIERS.items(): + # Pattern to match keylet::(hash_options{}, ...) + # where ledger_seq doesn't already contain a comma (no classifier yet) + pattern = re.compile( + rf'keylet::{re.escape(func_name)}\s*\(\s*hash_options\s*\{{\s*\(([^,}}]+)\)\s*\}}', + re.MULTILINE + ) + + def replacer(match): + nonlocal replacements + ledger_seq = match.group(1).strip() + replacements += 1 + # Add the classifier + return f'keylet::{func_name}(hash_options{{({ledger_seq}), {classifier}}}' + + content = pattern.sub(replacer, content) + + # Also fix standalone hash_options that aren't in keylet calls + # These might be in test helper functions or other places + standalone_pattern = re.compile( + r'(? 0 and content != original_content: + with open(filepath, 'w', encoding='utf-8') as f: + f.write(content) + return replacements + + return 0 + +def main(): + project_root = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc") + + # Find all test cpp files that might have hash_options + test_files = list((project_root / "src" / "test").rglob("*.cpp")) + + print(f"Found {len(test_files)} test files to check...") + + total_files_fixed = 0 + total_replacements = 0 + + for filepath in test_files: + replacements = fix_keylet_calls_in_file(filepath) + if replacements > 0: + rel_path = filepath.relative_to(project_root) + print(f"Fixed {rel_path}: {replacements} replacements") + total_files_fixed += 1 + total_replacements += replacements + + print(f"\n{'='*60}") + print(f"Fixed {total_files_fixed} test files") + print(f"Total replacements: {total_replacements}") + + if total_files_fixed > 0: + print("\nNow rebuild to see if there are any remaining issues.") + else: + print("\nNo test files needed fixing.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/fix_test_hash_options_v3.py b/fix_test_hash_options_v3.py new file mode 100644 index 000000000..018018f12 --- /dev/null +++ b/fix_test_hash_options_v3.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 + +import re +import os +import sys +from pathlib import Path + +# Mapping of keylet functions to their specific HashContext classifiers +KEYLET_CLASSIFIERS = { + 'account': 'KEYLET_ACCOUNT', + 'amendments': 'KEYLET_AMENDMENTS', + 'book': 'KEYLET_BOOK', + 'check': 'KEYLET_CHECK', + 'child': 'KEYLET_CHILD', + 'depositPreauth': 'KEYLET_DEPOSIT_PREAUTH', + 'emittedDir': 'KEYLET_EMITTED_DIR', + 'emittedTxn': 'KEYLET_EMITTED_TXN', + 'escrow': 'KEYLET_ESCROW', + 'fees': 'KEYLET_FEES', + 'hook': 'KEYLET_HOOK', + 'hookDefinition': 'KEYLET_HOOK_DEFINITION', + 'hookState': 'KEYLET_HOOK_STATE', + 'hookStateDir': 'KEYLET_HOOK_STATE_DIR', + 'import_vlseq': 'KEYLET_IMPORT_VLSEQ', + 'line': 'KEYLET_TRUSTLINE', + 'negativeUNL': 'KEYLET_NEGATIVE_UNL', + 'nft_buys': 'KEYLET_NFT_BUYS', + 'nft_sells': 'KEYLET_NFT_SELLS', + 'nftoffer': 'KEYLET_NFT_OFFER', + 'nftpage': 'KEYLET_NFT_PAGE', + 'nftpage_max': 'KEYLET_NFT_PAGE', + 'nftpage_min': 'KEYLET_NFT_PAGE', + 'offer': 'KEYLET_OFFER', + 'ownerDir': 'KEYLET_OWNER_DIR', + 'page': 'KEYLET_DIR_PAGE', + 'payChan': 'KEYLET_PAYCHAN', + 'signers': 'KEYLET_SIGNERS', + 'skip': 'KEYLET_SKIP_LIST', + 'ticket': 'KEYLET_TICKET', + 'UNLReport': 'KEYLET_UNL_REPORT', + 'unchecked': 'KEYLET_UNCHECKED', + 'uritoken': 'KEYLET_URI_TOKEN', +} + +def fix_keylet_calls_in_file(filepath: Path) -> int: + """Fix hash_options in a single file by adding appropriate classifiers.""" + + try: + with open(filepath, 'r', encoding='utf-8') as f: + content = f.read() + except Exception as e: + print(f"Error reading {filepath}: {e}") + return 0 + + original_content = content + replacements = 0 + + # Process each keylet function + for func_name, classifier in KEYLET_CLASSIFIERS.items(): + # Pattern to match keylet::(hash_options{}, ...) + # where ledger_seq doesn't already contain a comma (no classifier yet) + pattern = re.compile( + rf'keylet::{re.escape(func_name)}\s*\(\s*hash_options\s*\{{\s*\(([^}}]+)\)\s*\}}', + re.MULTILINE + ) + + def replacer(match): + nonlocal replacements + ledger_seq = match.group(1).strip() + # Check if it already has a classifier (contains comma after the ledger expression) + # But be careful - the ledger expression itself might contain commas + # Look for a comma followed by a KEYLET_ or other classifier + if ', KEYLET_' in match.group(0) or ', LEDGER_' in match.group(0): + return match.group(0) + replacements += 1 + # Add the classifier + return f'keylet::{func_name}(hash_options{{({ledger_seq}), {classifier}}}' + + content = pattern.sub(replacer, content) + + if replacements > 0 and content != original_content: + with open(filepath, 'w', encoding='utf-8') as f: + f.write(content) + return replacements + + return 0 + +def main(): + project_root = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc") + + # Find all test cpp files that might have hash_options + test_files = list((project_root / "src" / "test").rglob("*.cpp")) + + print(f"Found {len(test_files)} test files to check...") + + total_files_fixed = 0 + total_replacements = 0 + + for filepath in test_files: + replacements = fix_keylet_calls_in_file(filepath) + if replacements > 0: + rel_path = filepath.relative_to(project_root) + print(f"Fixed {rel_path}: {replacements} replacements") + total_files_fixed += 1 + total_replacements += replacements + + print(f"\n{'='*60}") + print(f"Fixed {total_files_fixed} test files") + print(f"Total replacements: {total_replacements}") + + if total_files_fixed > 0: + print("\nNow rebuild to see if there are any remaining issues.") + else: + print("\nNo test files needed fixing.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/fix_xahau_genesis.py b/fix_xahau_genesis.py new file mode 100644 index 000000000..2eca578d1 --- /dev/null +++ b/fix_xahau_genesis.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_xahau_genesis(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/XahauGenesis_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix sha512Half_s calls - they now need hash_options + content = re.sub( + r'ripple::sha512Half_s\(ripple::Slice\(', + r'ripple::sha512Half_s(hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(', + content + ) + + # Fix keylet::amendments() + content = re.sub( + r'env\.le\(keylet::amendments\(\)\)', + r'env.le(keylet::amendments(hash_options{(env.current()->seq()), KEYLET_AMENDMENTS}))', + content + ) + + # Fix keylet::account(id) calls + content = re.sub( + r'env\.le\(keylet::account\((\w+)\)\)', + r'env.le(keylet::account(hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, \1))', + content + ) + + # Fix keylet::hook(id) calls + content = re.sub( + r'env\.le\(keylet::hook\((\w+)\)\)', + r'env.le(keylet::hook(hash_options{(env.current()->seq()), KEYLET_HOOK}, \1))', + content + ) + + # Fix keylet::hookDefinition calls + content = re.sub( + r'env\.le\(keylet::hookDefinition\(([^)]+)\)\)', + r'env.le(keylet::hookDefinition(hash_options{(env.current()->seq()), KEYLET_HOOK_DEFINITION}, \1))', + content + ) + + # Fix keylet::fees() calls + content = re.sub( + r'env\.le\(keylet::fees\(\)\)', + r'env.le(keylet::fees(hash_options{(env.current()->seq()), KEYLET_FEES}))', + content + ) + + # Fix standalone keylet::account assignments + content = re.sub( + r'(\s+auto\s+const\s+\w+Key\s*=\s*)keylet::account\((\w+)\);', + r'\1keylet::account(hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, \2);', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_xahau_genesis() \ No newline at end of file diff --git a/fix_xahau_genesis_v2.py b/fix_xahau_genesis_v2.py new file mode 100644 index 000000000..9e3ea99be --- /dev/null +++ b/fix_xahau_genesis_v2.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_xahau_genesis(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/XahauGenesis_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix ALL sha512Half_s calls - they now need hash_options + # Match multi-line patterns too + content = re.sub( + r'ripple::sha512Half_s\(', + r'ripple::sha512Half_s(hash_options{0, LEDGER_INDEX_UNNEEDED}, ', + content + ) + + # Fix keylet::hookDefinition without hash_options + content = re.sub( + r'keylet::hookDefinition\(([^,)]+)\)(?!\.)', + r'keylet::hookDefinition(hash_options{0, KEYLET_HOOK_DEFINITION}, \1)', + content + ) + + # Fix env.le(keylet::hookDefinition calls that might have been missed + content = re.sub( + r'env\.le\(keylet::hookDefinition\(hash_options\{0, KEYLET_HOOK_DEFINITION\}, ([^)]+)\)\)', + r'env.le(keylet::hookDefinition(hash_options{(env.current()->seq()), KEYLET_HOOK_DEFINITION}, \1))', + content + ) + + # Fix keylet::account in view.read() calls + content = re.sub( + r'view->read\(keylet::account\((\w+)\)\)', + r'view->read(keylet::account(hash_options{(view->seq()), KEYLET_ACCOUNT}, \1))', + content + ) + + # Fix env.current()->read(keylet::account calls + content = re.sub( + r'env\.current\(\)->read\(keylet::account\((\w+)\)\)', + r'env.current()->read(keylet::account(hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, \1))', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_xahau_genesis() \ No newline at end of file diff --git a/fix_xahau_genesis_v3.py b/fix_xahau_genesis_v3.py new file mode 100644 index 000000000..2631cefe4 --- /dev/null +++ b/fix_xahau_genesis_v3.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import re +from pathlib import Path + +def fix_xahau_genesis(): + filepath = Path("/Users/nicholasdudfield/projects/xahaud-worktrees/xahaud-map-stats-rpc/src/test/app/XahauGenesis_test.cpp") + + with open(filepath, 'r') as f: + content = f.read() + + # Fix keylet::signers without hash_options + content = re.sub( + r'env\.le\(keylet::signers\((\w+)\)\)', + r'env.le(keylet::signers(hash_options{(env.current()->seq()), KEYLET_SIGNERS}, \1))', + content + ) + + # Fix keylet::hookState - it takes 4 arguments now (hash_options + 3 original) + content = re.sub( + r'keylet::hookState\(\s*([^,]+),\s*([^,]+),\s*([^)]+)\)', + r'keylet::hookState(hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, \1, \2, \3)', + content + ) + + # Fix keylet::negativeUNL + content = re.sub( + r'env\.le\(keylet::negativeUNL\(\)\)', + r'env.le(keylet::negativeUNL(hash_options{(env.current()->seq()), KEYLET_NEGATIVE_UNL}))', + content + ) + + with open(filepath, 'w') as f: + f.write(content) + + print(f"Fixed {filepath}") + +if __name__ == "__main__": + fix_xahau_genesis() \ No newline at end of file diff --git a/src/test/app/AccountDelete_test.cpp b/src/test/app/AccountDelete_test.cpp index e9d12bf59..dbd424424 100644 --- a/src/test/app/AccountDelete_test.cpp +++ b/src/test/app/AccountDelete_test.cpp @@ -177,9 +177,11 @@ public: // Verify that alice's account exists but she has no directory. BEAST_EXPECT(env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id()))); env(acctdelete(alice, becky), fee(acctDelFee)); verifyDeliveredAmount(env, aliceOldBalance - acctDelFee); @@ -187,9 +189,11 @@ public: // Verify that alice's account and directory are actually gone. BEAST_EXPECT(!env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id()))); // Verify that alice's XRP, minus the fee, was transferred to becky. BEAST_EXPECT( @@ -225,21 +229,26 @@ public: // Verify that Carol's account, directory, deposit // preauthorization, offer, ticket, and signer list exist. BEAST_EXPECT(env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + carol.id()))); BEAST_EXPECT(env.closed()->exists(keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id()))); BEAST_EXPECT(env.closed()->exists(keylet::depositPreauth( - hash_options{(env.current()->seq())}, carol.id(), becky.id()))); + hash_options{(env.current()->seq()), KEYLET_DEPOSIT_PREAUTH}, + carol.id(), + becky.id()))); BEAST_EXPECT(env.closed()->exists(keylet::offer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_OFFER}, carol.id(), carolOfferSeq))); BEAST_EXPECT(env.closed()->exists(keylet::ticket( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TICKET}, carol.id(), carolTicketSeq))); BEAST_EXPECT(env.closed()->exists(keylet::signers( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), 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. @@ -249,21 +258,26 @@ public: // Verify that Carol's account, directory, and other stuff are gone. BEAST_EXPECT(!env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + carol.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::depositPreauth( - hash_options{(env.current()->seq())}, carol.id(), becky.id()))); + hash_options{(env.current()->seq()), KEYLET_DEPOSIT_PREAUTH}, + carol.id(), + becky.id()))); BEAST_EXPECT(!env.closed()->exists(keylet::offer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_OFFER}, carol.id(), carolOfferSeq))); BEAST_EXPECT(!env.closed()->exists(keylet::ticket( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TICKET}, carol.id(), carolTicketSeq))); BEAST_EXPECT(!env.closed()->exists(keylet::signers( - hash_options{(env.current()->seq())}, carol.id()))); + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, + carol.id()))); // Verify that Carol's XRP, minus the fee, was transferred to becky. BEAST_EXPECT( @@ -305,10 +319,13 @@ public: incLgrSeqForAccDel(env, alice); // Verify that both directory nodes exist. - Keylet const aliceRootKey{ - keylet::ownerDir(hash_options{(env.current()->seq())}, alice.id())}; + Keylet const aliceRootKey{keylet::ownerDir( + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())}; Keylet const alicePageKey{keylet::page( - hash_options{(env.current()->seq())}, aliceRootKey, 1)}; + hash_options{(env.current()->seq()), KEYLET_DIR_PAGE}, + aliceRootKey, + 1)}; BEAST_EXPECT(env.closed()->exists(aliceRootKey)); BEAST_EXPECT(env.closed()->exists(alicePageKey)); @@ -366,7 +383,9 @@ public: // deleted. uint256 const checkId = keylet::check( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_CHECK}, + alice, + env.seq(alice)) .key; env(check::create(alice, becky, XRP(1))); env.close(); @@ -429,7 +448,7 @@ public: env.close(); Keylet const alicePayChanKey{keylet::payChan( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_PAYCHAN}, alice, becky, env.seq(alice))}; @@ -474,7 +493,10 @@ public: // amendment passed this should prevent alice from deleting her // account. Keylet const gwPayChanKey{keylet::payChan( - hash_options{(env.current()->seq())}, gw, alice, env.seq(gw))}; + hash_options{(env.current()->seq()), KEYLET_PAYCHAN}, + gw, + alice, + env.seq(gw))}; env(payChanCreate(gw, alice, XRP(68), 4s, env.now() + 2s, alice.pk())); env.close(); @@ -515,13 +537,13 @@ public: env.close(); // Verify that becky's account root is present. - Keylet const beckyAcctKey{ - keylet::account(hash_options{(env.current()->seq())}, becky.id())}; + Keylet const beckyAcctKey{keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, becky.id())}; BEAST_EXPECT(env.closed()->exists(beckyAcctKey)); using namespace std::chrono_literals; Keylet const payChanKey{keylet::payChan( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_PAYCHAN}, alice, becky, env.seq(alice))}; @@ -599,8 +621,8 @@ public: incLgrSeqForAccDel(env, alice); // Verify that alice's account root is present. - Keylet const aliceAcctKey{ - keylet::account(hash_options{(env.current()->seq())}, alice.id())}; + Keylet const aliceAcctKey{keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, alice.id())}; BEAST_EXPECT(env.closed()->exists(aliceAcctKey)); auto const alicePreDelBal{env.balance(alice)}; @@ -687,25 +709,27 @@ public: incLgrSeqForAccDel(env, alice); // Verify the existence of the expected ledger entries. - Keylet const aliceOwnerDirKey{ - keylet::ownerDir(hash_options{(env.current()->seq())}, alice.id())}; + Keylet const aliceOwnerDirKey{keylet::ownerDir( + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())}; { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(closed->exists(aliceOwnerDirKey)); // alice's directory nodes. for (std::uint32_t i{0}; i < ((offerCount / 32) + 1); ++i) BEAST_EXPECT(closed->exists(keylet::page( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_DIR_PAGE}, aliceOwnerDirKey, i))); // alice's offers. for (std::uint32_t i{0}; i < offerCount; ++i) BEAST_EXPECT(closed->exists(keylet::offer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_OFFER}, alice.id(), offerSeq0 + i))); } @@ -733,20 +757,21 @@ public: { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(!closed->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(!closed->exists(aliceOwnerDirKey)); // alice's former directory nodes. for (std::uint32_t i{0}; i < ((offerCount / 32) + 1); ++i) BEAST_EXPECT(!closed->exists(keylet::page( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_DIR_PAGE}, aliceOwnerDirKey, i))); // alice's former offers. for (std::uint32_t i{0}; i < offerCount; ++i) BEAST_EXPECT(!closed->exists(keylet::offer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_OFFER}, alice.id(), offerSeq0 + i))); } @@ -793,9 +818,11 @@ public: { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, gw.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + gw.id()))); } } @@ -837,7 +864,8 @@ public: { std::shared_ptr const closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(env.balance(env.master) == masterBalance); } @@ -849,7 +877,8 @@ public: { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, alice.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id()))); BEAST_EXPECT(env.balance(env.master) == masterBalance); } } @@ -877,11 +906,12 @@ public: { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(closed->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); for (std::uint32_t i = 0; i < 250; ++i) { BEAST_EXPECT(closed->exists(keylet::ticket( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TICKET}, bob.id(), ticketSeq + i))); } @@ -900,11 +930,12 @@ public: { std::shared_ptr closed{env.closed()}; BEAST_EXPECT(!closed->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); for (std::uint32_t i = 0; i < 250; ++i) { BEAST_EXPECT(!closed->exists(keylet::ticket( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TICKET}, bob.id(), ticketSeq + i))); } diff --git a/src/test/app/BaseFee_test.cpp b/src/test/app/BaseFee_test.cpp index a611eb14a..6251d9570 100644 --- a/src/test/app/BaseFee_test.cpp +++ b/src/test/app/BaseFee_test.cpp @@ -123,7 +123,9 @@ class BaseFee_test : public beast::unit_test::suite std::uint32_t uSequence) { return keylet::check( - hash_options{(env.current()->seq())}, account, uSequence) + hash_options{(env.current()->seq()), KEYLET_CHECK}, + account, + uSequence) .key; } @@ -447,7 +449,10 @@ class BaseFee_test : public beast::unit_test::suite std::uint32_t seqProxyValue) { auto const k = keylet::payChan( - hash_options{(env.current()->seq())}, account, dst, seqProxyValue); + hash_options{(env.current()->seq()), KEYLET_PAYCHAN}, + account, + dst, + seqProxyValue); return k.key; } diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index f2f7cf143..ec3ab28ef 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -94,7 +94,9 @@ class Check_test : public beast::unit_test::suite std::uint32_t uSequence) { return keylet::check( - hash_options{(env.current()->seq())}, account, uSequence) + hash_options{(env.current()->seq()), KEYLET_CHECK}, + account, + uSequence) .key; } @@ -2128,12 +2130,12 @@ class Check_test : public beast::unit_test::suite IOU const& offerIou, IOU const& checkIou) { auto const offerLine = env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, acct1, acct2, offerIou.currency)); auto const checkLine = env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, acct1, acct2, checkIou.currency)); @@ -2219,7 +2221,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, OF1.currency)) == nullptr); @@ -2242,7 +2244,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, CK1.currency)) == nullptr); @@ -2276,7 +2278,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, OF1.currency)) == nullptr); @@ -2305,7 +2307,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, CK1.currency)) == nullptr); @@ -2314,13 +2316,13 @@ class Check_test : public beast::unit_test::suite BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, bob, OF1.currency)) != nullptr); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, bob, CK1.currency)) == nullptr); @@ -2349,7 +2351,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, OF2.currency)) == nullptr); @@ -2372,7 +2374,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, CK2.currency)) == nullptr); @@ -2403,7 +2405,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, OF2.currency)) == nullptr); @@ -2423,7 +2425,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, CK2.currency)) == nullptr); @@ -2460,7 +2462,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, OF3.currency)) == nullptr); @@ -2483,7 +2485,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, CK3.currency)) == nullptr); @@ -2514,7 +2516,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, OF3.currency)) == nullptr); @@ -2534,7 +2536,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, CK3.currency)) == nullptr); @@ -2565,7 +2567,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, OF4.currency)) == nullptr); @@ -2584,7 +2586,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, CK4.currency)) == nullptr); @@ -2600,13 +2602,13 @@ class Check_test : public beast::unit_test::suite // is created. BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, OF4.currency)) == nullptr); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, alice, CK4.currency)) == nullptr); @@ -2623,7 +2625,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, OF4.currency)) == nullptr); @@ -2642,7 +2644,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, CK4.currency)) == nullptr); @@ -2658,13 +2660,13 @@ class Check_test : public beast::unit_test::suite // is created. BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, bob, OF4.currency)) == nullptr); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw1, bob, CK4.currency)) == nullptr); @@ -2693,7 +2695,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, alice, OF5.currency)) == nullptr); @@ -2720,7 +2722,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, alice, CK5.currency)) == nullptr); @@ -2737,13 +2739,13 @@ class Check_test : public beast::unit_test::suite // is created. BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, alice, OF5.currency)) == nullptr); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, alice, CK5.currency)) == nullptr); @@ -2767,7 +2769,7 @@ class Check_test : public beast::unit_test::suite env(offer(bob, OF5(91), XRP(91)), ter(tecNO_LINE)); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, bob, OF5.currency)) == nullptr); @@ -2784,7 +2786,7 @@ class Check_test : public beast::unit_test::suite env.close(); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, alice, bob, CK5.currency)) == nullptr); @@ -2804,13 +2806,13 @@ class Check_test : public beast::unit_test::suite // is created. BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, bob, OF5.currency)) == nullptr); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, gw2, bob, CK5.currency)) == nullptr); diff --git a/src/test/app/ClaimReward_test.cpp b/src/test/app/ClaimReward_test.cpp index 003b518db..be734e66a 100644 --- a/src/test/app/ClaimReward_test.cpp +++ b/src/test/app/ClaimReward_test.cpp @@ -35,8 +35,8 @@ struct ClaimReward_test : public beast::unit_test::suite std::uint64_t accumulator, std::uint32_t time) { - auto const sle = - env.le(keylet::account(hash_options{(env.current()->seq())}, acct)); + auto const sle = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, acct)); if (!sle->isFieldPresent(sfRewardLgrFirst) || sle->getFieldU32(sfRewardLgrFirst) != ledgerFirst) { @@ -63,8 +63,8 @@ struct ClaimReward_test : public beast::unit_test::suite bool expectNoRewards(jtx::Env const& env, jtx::Account const& acct) { - auto const sle = - env.le(keylet::account(hash_options{(env.current()->seq())}, acct)); + auto const sle = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, acct)); if (sle->isFieldPresent(sfRewardLgrFirst)) { return false; diff --git a/src/test/app/Clawback_test.cpp b/src/test/app/Clawback_test.cpp index b009145cc..020953fcc 100644 --- a/src/test/app/Clawback_test.cpp +++ b/src/test/app/Clawback_test.cpp @@ -66,7 +66,10 @@ class Clawback_test : public beast::unit_test::suite Currency const& cur) { if (auto sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, src, dst, cur))) + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + src, + dst, + cur))) { auto const useHigh = src.id() > dst.id(); return sle->isFlag(useHigh ? lsfHighFreeze : lsfLowFreeze); @@ -842,7 +845,10 @@ class Clawback_test : public beast::unit_test::suite test::jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle->isFieldPresent(sfLockedBalance)) return (*sle)[sfLockedBalance]; return STAmount(iou, 0); diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 4eb0125df..d893e9923 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -69,7 +69,10 @@ struct Escrow_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle->isFieldPresent(sfLockedBalance)) return (*sle)[sfLockedBalance]; return STAmount(iou, 0); @@ -82,7 +85,9 @@ struct Escrow_test : public beast::unit_test::suite uint32_t const& seq) { auto const sle = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, account.id(), seq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + account.id(), + seq)); if (sle->isFieldPresent(sfTransferRate)) return ripple::Rate((*sle)[sfTransferRate]); return Rate{0}; @@ -97,7 +102,10 @@ struct Escrow_test : public beast::unit_test::suite { auto const aHigh = account.id() > gw.id(); auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit)) return (*sle)[aHigh ? sfLowLimit : sfHighLimit]; return STAmount(iou, 0); @@ -111,7 +119,10 @@ struct Escrow_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle && sle->isFieldPresent(sfBalance)) return (*sle)[sfBalance]; return STAmount(iou, 0); @@ -327,7 +338,9 @@ struct Escrow_test : public beast::unit_test::suite dtag(2)); auto const sle = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), seq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + seq)); BEAST_EXPECT(sle); BEAST_EXPECT((*sle)[sfSourceTag] == 1); BEAST_EXPECT((*sle)[sfDestinationTag] == 2); @@ -894,7 +907,7 @@ struct Escrow_test : public beast::unit_test::suite // SLE removed on finish BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_ESCROW}, Account("alice").id(), seq))); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -918,7 +931,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance("alice", XRP(5000) - drops(10))); // SLE removed on cancel BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_ESCROW}, Account("alice").id(), seq))); } @@ -1241,14 +1254,17 @@ struct Escrow_test : public beast::unit_test::suite static_cast(tesSUCCESS)); env.close(5s); auto const aa = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq)); BEAST_EXPECT(aa); { ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1); BEAST_EXPECT( std::find(aod.begin(), aod.end(), aa) != aod.end()); @@ -1262,14 +1278,17 @@ struct Escrow_test : public beast::unit_test::suite static_cast(tesSUCCESS)); env.close(5s); auto const bb = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bruce.id(), bseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bruce.id(), + bseq)); BEAST_EXPECT(bb); { ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 1); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) != bod.end()); @@ -1279,7 +1298,9 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::finish(alice, alice, aseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); @@ -1287,7 +1308,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 0); BEAST_EXPECT( std::find(aod.begin(), aod.end(), aa) == aod.end()); @@ -1295,7 +1317,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 1); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) != bod.end()); @@ -1305,7 +1328,9 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::cancel(bruce, bruce, bseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bruce.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bruce.id(), + bseq))); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); @@ -1313,7 +1338,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 0); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) == bod.end()); @@ -1342,18 +1368,23 @@ struct Escrow_test : public beast::unit_test::suite env.close(5s); auto const ab = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq)); BEAST_EXPECT(ab); auto const bc = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bruce.id(), bseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bruce.id(), + bseq)); BEAST_EXPECT(bc); { ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) != aod.end()); @@ -1361,7 +1392,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 2); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) != bod.end()); @@ -1371,7 +1403,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 1); BEAST_EXPECT( std::find(cod.begin(), cod.end(), bc) != cod.end()); @@ -1381,14 +1414,19 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::finish(alice, alice, aseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT(env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bruce.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bruce.id(), + bseq))); ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 0); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) == aod.end()); @@ -1396,7 +1434,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 1); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) == bod.end()); @@ -1406,7 +1445,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 1); } @@ -1414,14 +1454,19 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::cancel(bruce, bruce, bseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bruce.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bruce.id(), + bseq))); ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 0); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) == aod.end()); @@ -1429,7 +1474,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bruce.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bruce.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 0); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) == bod.end()); @@ -1439,7 +1485,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 0); } } @@ -1908,7 +1955,9 @@ struct Escrow_test : public beast::unit_test::suite dtag(2)); auto const sle = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), seq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + seq)); BEAST_EXPECT(sle); BEAST_EXPECT((*sle)[sfSourceTag] == 1); BEAST_EXPECT((*sle)[sfDestinationTag] == 2); @@ -2679,7 +2728,7 @@ struct Escrow_test : public beast::unit_test::suite // SLE removed on finish BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_ESCROW}, Account(alice).id(), seq))); BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 1); @@ -2723,7 +2772,7 @@ struct Escrow_test : public beast::unit_test::suite env.require(balance(alice, USD(5000))); // SLE removed on cancel BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_ESCROW}, Account(alice).id(), seq))); } @@ -3127,13 +3176,16 @@ struct Escrow_test : public beast::unit_test::suite static_cast(tesSUCCESS)); env.close(5s); auto const aa = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq)); BEAST_EXPECT(aa); { ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 2); BEAST_EXPECT( std::find(aod.begin(), aod.end(), aa) != aod.end()); @@ -3147,14 +3199,17 @@ struct Escrow_test : public beast::unit_test::suite static_cast(tesSUCCESS)); env.close(5s); auto const bb = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bob.id(), bseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bob.id(), + bseq)); BEAST_EXPECT(bb); { ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 2); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) != bod.end()); @@ -3164,7 +3219,9 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::finish(alice, alice, aseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); @@ -3172,7 +3229,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1); BEAST_EXPECT( std::find(aod.begin(), aod.end(), aa) == aod.end()); @@ -3180,7 +3238,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 2); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) != bod.end()); @@ -3190,7 +3249,9 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::cancel(bob, bob, bseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bob.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bob.id(), + bseq))); BEAST_EXPECT( (*env.meta())[sfTransactionResult] == static_cast(tesSUCCESS)); @@ -3198,7 +3259,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 1); BEAST_EXPECT( std::find(bod.begin(), bod.end(), bb) == bod.end()); @@ -3234,18 +3296,23 @@ struct Escrow_test : public beast::unit_test::suite env.close(5s); auto const ab = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq)); BEAST_EXPECT(ab); auto const bc = env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bob.id(), bseq)); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bob.id(), + bseq)); BEAST_EXPECT(bc); { ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 2); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) != aod.end()); @@ -3253,7 +3320,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 3); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) != bod.end()); @@ -3263,7 +3331,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 2); BEAST_EXPECT( std::find(cod.begin(), cod.end(), bc) != cod.end()); @@ -3273,14 +3342,19 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::finish(alice, alice, aseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT(env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bob.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bob.id(), + bseq))); ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) == aod.end()); @@ -3288,7 +3362,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 2); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) == bod.end()); @@ -3298,7 +3373,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 2); } @@ -3306,14 +3382,19 @@ struct Escrow_test : public beast::unit_test::suite env(escrow::cancel(bob, bob, bseq)); { BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, alice.id(), aseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice.id(), + aseq))); BEAST_EXPECT(!env.le(keylet::escrow( - hash_options{(env.current()->seq())}, bob.id(), bseq))); + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + bob.id(), + bseq))); ripple::Dir aod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + alice.id())); BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1); BEAST_EXPECT( std::find(aod.begin(), aod.end(), ab) == aod.end()); @@ -3321,7 +3402,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir bod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + bob.id())); BEAST_EXPECT(std::distance(bod.begin(), bod.end()) == 1); BEAST_EXPECT( std::find(bod.begin(), bod.end(), ab) == bod.end()); @@ -3331,7 +3413,8 @@ struct Escrow_test : public beast::unit_test::suite ripple::Dir cod( *env.current(), keylet::ownerDir( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_OWNER_DIR}, + carol.id())); BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 1); } } @@ -4498,7 +4581,9 @@ struct Escrow_test : public beast::unit_test::suite std::uint32_t uSequence) { return keylet::escrow( - hash_options{(env.current()->seq())}, account, uSequence) + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + account, + uSequence) .key; } diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 4e0123d8d..67ebe9c8d 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -39,8 +39,11 @@ getNoRippleFlag( jtx::Account const& dst, Currency const& cur) { - if (auto sle = env.le( - keylet::line(hash_options{(env.current()->seq())}, src, dst, cur))) + if (auto sle = env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + src, + dst, + cur))) { auto const flag = (src.id() > dst.id()) ? lsfHighNoRipple : lsfLowNoRipple; @@ -487,8 +490,8 @@ struct Flow_test : public beast::unit_test::suite return false; Sandbox sb(&view, tapNONE); for (auto const& o : flowResult.removableOffers) - if (auto ok = sb.peek( - keylet::offer(hash_options{(view.seq())}, o))) + if (auto ok = sb.peek(keylet::offer( + hash_options{(view.seq()), KEYLET_OFFER}, o))) offerDelete(sb, ok, flowJournal); sb.apply(view); return true; diff --git a/src/test/app/Freeze_test.cpp b/src/test/app/Freeze_test.cpp index 6589697ee..ae65ee2b5 100644 --- a/src/test/app/Freeze_test.cpp +++ b/src/test/app/Freeze_test.cpp @@ -1891,7 +1891,9 @@ class Freeze_test : public beast::unit_test::suite std::uint32_t uSequence) { return keylet::check( - hash_options{(env.current()->seq())}, account, uSequence) + hash_options{(env.current()->seq()), KEYLET_CHECK}, + account, + uSequence) .key; } @@ -1908,7 +1910,9 @@ class Freeze_test : public beast::unit_test::suite uint256 const sellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, account, env.seq(account)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + account, + env.seq(account)) .key; env(token::createOffer(account, nftID, currency), txflags(tfSellNFToken)); diff --git a/src/test/app/GenesisMint_test.cpp b/src/test/app/GenesisMint_test.cpp index 7308aac35..a7ac3c562 100644 --- a/src/test/app/GenesisMint_test.cpp +++ b/src/test/app/GenesisMint_test.cpp @@ -157,7 +157,8 @@ struct GenesisMint_test : public beast::unit_test::suite auto const initCoins = env.current()->info().drops; { auto acc = env.le(keylet::account( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id())); BEAST_EXPECT( acc->getFieldAmount(sfBalance).xrp().drops() == 10000000000ULL); @@ -182,7 +183,8 @@ struct GenesisMint_test : public beast::unit_test::suite { auto acc = env.le(keylet::account( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id())); BEAST_EXPECT( acc->getFieldAmount(sfBalance).xrp().drops() == 10123000000ULL); @@ -198,10 +200,10 @@ struct GenesisMint_test : public beast::unit_test::suite // creating accounts auto const carol = Account("carol"); auto const david = Account("david"); - BEAST_EXPECT(!env.le( - keylet::account(hash_options{(env.current()->seq())}, carol.id()))); - BEAST_EXPECT(!env.le( - keylet::account(hash_options{(env.current()->seq())}, david.id()))); + BEAST_EXPECT(!env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, carol.id()))); + BEAST_EXPECT(!env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, david.id()))); env(invoke::invoke( invoker, @@ -228,7 +230,8 @@ struct GenesisMint_test : public beast::unit_test::suite { auto acc = env.le(keylet::account( - hash_options{(env.current()->seq())}, carol.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + carol.id())); BEAST_EXPECT( acc->getFieldAmount(sfBalance).xrp().drops() == 67890000000ULL); BEAST_EXPECT(acc->getFieldU32(sfSequence) == 60); @@ -236,7 +239,8 @@ struct GenesisMint_test : public beast::unit_test::suite { auto acc = env.le(keylet::account( - hash_options{(env.current()->seq())}, david.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + david.id())); BEAST_EXPECT( acc->getFieldAmount(sfBalance).xrp().drops() == 12345000000ULL); BEAST_EXPECT(acc->getFieldU32(sfSequence) == 60); @@ -270,8 +274,8 @@ struct GenesisMint_test : public beast::unit_test::suite for (auto const& [acc, amt, _, __] : mints) { - auto const le = env.le( - keylet::account(hash_options{(env.current()->seq())}, *acc)); + auto const le = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, *acc)); BEAST_EXPECT(!!le && le->getFieldAmount(sfBalance) == *amt); } @@ -286,8 +290,8 @@ struct GenesisMint_test : public beast::unit_test::suite for (auto const& [acc, amt, _, __] : mints) { - auto const le = env.le( - keylet::account(hash_options{(env.current()->seq())}, *acc)); + auto const le = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, *acc)); BEAST_EXPECT(!!le && le->getFieldAmount(sfBalance) == *amt * 2); BEAST_EXPECT(le->getAccountID(sfAccount) == acc); } @@ -308,8 +312,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check the amounts didn't change for (auto const& [acc, amt, _, __] : mints) { - auto const le = env.le( - keylet::account(hash_options{(env.current()->seq())}, *acc)); + auto const le = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, *acc)); BEAST_EXPECT(!!le && le->getFieldAmount(sfBalance) == *amt * 2); if (++i == 512) break; @@ -392,7 +396,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check that alice has the right balance, and Governance Flags set { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance) == XRP(10000).value()); BEAST_EXPECT( @@ -419,7 +424,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check that bob has the right balance, and Governance Marks set { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, bob.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance) == XRP(10123).value()); BEAST_EXPECT( @@ -447,7 +453,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, fred.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + fred.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance) == XRP(589).value()); BEAST_EXPECT( @@ -480,7 +487,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 0); } @@ -504,7 +512,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 0); } @@ -528,7 +537,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 0); } @@ -553,7 +563,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 10000000ULL); @@ -608,7 +619,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check { auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == amtResult); @@ -634,7 +646,8 @@ struct GenesisMint_test : public beast::unit_test::suite // check balance wasn't changed auto const le = env.le(keylet::account( - hash_options{(env.current()->seq())}, greg.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + greg.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == amtResult); @@ -662,8 +675,8 @@ struct GenesisMint_test : public beast::unit_test::suite env(genesis::mint(env.master, {genesis::GenMint(bob.id(), XRP(123))}), ter(temMALFORMED)); - auto const le = env.le( - keylet::account(hash_options{(env.current()->seq())}, bob.id())); + auto const le = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, bob.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 10000000000ULL); @@ -685,8 +698,8 @@ struct GenesisMint_test : public beast::unit_test::suite env(genesis::mint(alice, {genesis::GenMint(bob.id(), XRP(123))}), ter(temMALFORMED)); - auto const le = env.le( - keylet::account(hash_options{(env.current()->seq())}, bob.id())); + auto const le = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, bob.id())); BEAST_EXPECT( !!le && le->getFieldAmount(sfBalance).xrp().drops() == 10000000000ULL); diff --git a/src/test/app/Import_test.cpp b/src/test/app/Import_test.cpp index d32a17972..3fdd159ed 100644 --- a/src/test/app/Import_test.cpp +++ b/src/test/app/Import_test.cpp @@ -50,21 +50,23 @@ class Import_test : public beast::unit_test::suite static std::pair> accountKeyAndSle(ReadView const& view, jtx::Account const& account) { - auto const k = keylet::account(hash_options{(view.seq())}, account); + auto const k = keylet::account( + hash_options{(view.seq()), KEYLET_ACCOUNT}, account); return {k.key, view.read(k)}; } static std::pair> feesKeyAndSle(ReadView const& view) { - auto const k = keylet::fees(hash_options{(view.seq())}); + auto const k = keylet::fees(hash_options{(view.seq()), KEYLET_FEES}); return {k.key, view.read(k)}; } static std::pair> signersKeyAndSle(ReadView const& view, jtx::Account const& account) { - auto const k = keylet::signers(hash_options{(view.seq())}, account); + auto const k = keylet::signers( + hash_options{(view.seq()), KEYLET_SIGNERS}, account); return {k.key, view.read(k)}; } @@ -72,15 +74,17 @@ class Import_test : public beast::unit_test::suite ownerDirCount(ReadView const& view, jtx::Account const& acct) { ripple::Dir const ownerDir( - view, keylet::ownerDir(hash_options{(view.seq())}, acct.id())); + view, + keylet::ownerDir( + hash_options{(view.seq()), KEYLET_OWNER_DIR}, acct.id())); return std::distance(ownerDir.begin(), ownerDir.end()); }; static std::uint32_t importVLSequence(jtx::Env const& env, PublicKey const& pk) { - auto const sle = env.le( - keylet::import_vlseq(hash_options{(env.current()->seq())}, pk)); + auto const sle = env.le(keylet::import_vlseq( + hash_options{(env.current()->seq()), KEYLET_IMPORT_VLSEQ}, pk)); if (sle && sle->isFieldPresent(sfImportSequence)) return (*sle)[sfImportSequence]; return 0; @@ -89,8 +93,8 @@ class Import_test : public beast::unit_test::suite bool hasUNLReport(jtx::Env const& env) { - auto const slep = - env.le(keylet::UNLReport(hash_options{(env.current()->seq())})); + auto const slep = env.le(keylet::UNLReport( + hash_options{(env.current()->seq()), KEYLET_UNL_REPORT})); return slep != nullptr; } @@ -3304,8 +3308,8 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(postCoins == preCoins + totalBurn); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); env(noop(alice), msig(bob, carol), @@ -3497,8 +3501,8 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(postCoins == preCoins + totalBurn); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); env(noop(alice), msig(bob, carol), @@ -3765,8 +3769,8 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(postCoins == preCoins + totalBurn); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); // confirm regular key @@ -4056,8 +4060,8 @@ class Import_test : public beast::unit_test::suite env(noop(alice), sig(dave), fee(feeDrops), ter(tesSUCCESS)); // confirm signers list not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); } @@ -4815,8 +4819,8 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(postCoins == preCoins + totalBurn); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); // confirm noop master success @@ -4904,8 +4908,8 @@ class Import_test : public beast::unit_test::suite env(noop(alice), sig(bob), fee(feeDrops), ter(tesSUCCESS)); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); // confirm noop master success @@ -4982,8 +4986,8 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(postCoins == preCoins + totalBurn); // confirm signers not set - auto const k = - keylet::signers(hash_options{(env.current()->seq())}, alice); + auto const k = keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, alice); BEAST_EXPECT(env.current()->read(k) == nullptr); // confirm noop master success diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 85e9dff2f..2a45149ff 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -911,9 +911,9 @@ struct LedgerReplayer_test : public beast::unit_test::suite // request, wrong hash auto request = std::make_shared(); request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE); - request->set_key( - keylet::skip(hash_options{(l->seq())}).key.data(), - keylet::skip(hash_options{(l->seq())}).key.size()); + auto skipKey = + keylet::skip(hash_options{(l->seq()), KEYLET_SKIP_LIST}); + request->set_key(skipKey.key.data(), skipKey.key.size()); uint256 hash(1234567); request->set_ledgerhash(hash.data(), hash.size()); auto reply = std::make_shared( @@ -927,9 +927,9 @@ struct LedgerReplayer_test : public beast::unit_test::suite request->set_ledgerhash( l->info().hash.data(), l->info().hash.size()); request->set_type(protocol::TMLedgerMapType::lmACCOUNT_STATE); - request->set_key( - keylet::skip(hash_options{(l->seq())}).key.data(), - keylet::skip(hash_options{(l->seq())}).key.size()); + auto skipKey = + keylet::skip(hash_options{(l->seq()), KEYLET_SKIP_LIST}); + request->set_key(skipKey.key.data(), skipKey.key.size()); // generate response auto reply = std::make_shared( server.msgHandler.processProofPathRequest(request)); diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index f2005384b..e8a484fb9 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -63,7 +63,9 @@ class NFTokenBurn0_test : public beast::unit_test::suite // Create sell offer offerIndexes.push_back( keylet::nftoffer( - hash_options{(env.current()->seq())}, owner, env.seq(owner)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + owner, + env.seq(owner)) .key); env(token::createOffer(owner, nftokenID, drops(1)), txflags(tfSellNFToken)); @@ -164,7 +166,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite auto xferNFT = [&env, &becky](AcctStat& acct, auto& iter) { uint256 offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, acct.acct, env.seq(acct.acct)) .key; @@ -565,11 +568,12 @@ class NFTokenBurn0_test : public beast::unit_test::suite env.fund(XRP(1000), acct); env.close(); - offerIndexes.push_back(keylet::nftoffer( - hash_options{(env.current()->seq())}, - acct, - env.seq(acct)) - .key); + offerIndexes.push_back( + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + acct, + env.seq(acct)) + .key); env(token::createOffer(acct, nftokenID, drops(1)), token::owner(alice)); env.close(); @@ -579,13 +583,16 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // Create one too many offers. uint256 const beckyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftokenID, drops(1)), token::owner(alice)); @@ -605,7 +612,9 @@ class NFTokenBurn0_test : public beast::unit_test::suite uint256 const aliceOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftokenID, drops(1)), txflags(tfSellNFToken)); @@ -625,7 +634,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // Both alice and becky should have ownerCounts of zero. @@ -657,13 +667,16 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // Becky creates a buy offer uint256 const beckyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftokenID, drops(1)), token::owner(alice)); @@ -678,13 +691,15 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // Burning the token should also remove the one buy offer // that becky created BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, beckyOfferIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + beckyOfferIndex))); // alice and becky should have ownerCounts of zero BEAST_EXPECT(ownerCount(env, alice) == 0); @@ -713,7 +728,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // Burn the token @@ -725,7 +741,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { if (!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))) offerDeletedCount++; } @@ -761,7 +778,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // becky creates 2 buy offers @@ -781,7 +799,8 @@ class NFTokenBurn0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // alice should have ownerCount of zero because all her diff --git a/src/test/app/NFTokenDir_test.cpp b/src/test/app/NFTokenDir_test.cpp index 45c8e8610..7d93d6dec 100644 --- a/src/test/app/NFTokenDir_test.cpp +++ b/src/test/app/NFTokenDir_test.cpp @@ -139,11 +139,12 @@ class NFTokenDir_test : public beast::unit_test::suite std::vector offers; for (uint256 const& nftID : nftIDs) { - offers.emplace_back(keylet::nftoffer( - hash_options{(env.current()->seq())}, - issuer, - env.seq(issuer)) - .key); + offers.emplace_back( + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + issuer, + env.seq(issuer)) + .key); env(token::createOffer(issuer, nftID, XRP(0)), txflags((tfSellNFToken))); env.close(); @@ -220,7 +221,8 @@ class NFTokenDir_test : public beast::unit_test::suite // Create an offer to give the NFT to buyer for free. offers.emplace_back( keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, account, env.seq(account)) .key); @@ -248,7 +250,8 @@ class NFTokenDir_test : public beast::unit_test::suite { uint256 const offerID = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -452,7 +455,8 @@ class NFTokenDir_test : public beast::unit_test::suite // Create an offer to give the NFT to buyer for free. offers.emplace_back( keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, account, env.seq(account)) .key); @@ -494,7 +498,8 @@ class NFTokenDir_test : public beast::unit_test::suite { uint256 const offerID = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -707,11 +712,12 @@ class NFTokenDir_test : public beast::unit_test::suite env.close(); // Create an offer to give the NFT to buyer for free. - offers.emplace_back(keylet::nftoffer( - hash_options{(env.current()->seq())}, - account, - env.seq(account)) - .key); + offers.emplace_back( + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + account, + env.seq(account)) + .key); env(token::createOffer(account, nftID, XRP(0)), token::destination(buyer), txflags((tfSellNFToken))); @@ -750,7 +756,9 @@ class NFTokenDir_test : public beast::unit_test::suite { uint256 const offerID = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftID, XRP(100)), txflags(tfSellNFToken)); @@ -903,11 +911,12 @@ class NFTokenDir_test : public beast::unit_test::suite env.close(); // Create an offer to give the NFT to buyer for free. - offers[i].emplace_back(keylet::nftoffer( - hash_options{(env.current()->seq())}, - account, - env.seq(account)) - .key); + offers[i].emplace_back( + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + account, + env.seq(account)) + .key); env(token::createOffer(account, nftID, XRP(0)), token::destination(buyer), txflags((tfSellNFToken))); diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index f8dbf1ec1..c1758e451 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -111,11 +111,12 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(mintedCount(env, master) == 0); BEAST_EXPECT(burnedCount(env, master) == 0); - uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, - master, - env.seq(master)) - .key; + uint256 const offerIndex = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + master, + env.seq(master)) + .key; env(token::createOffer(master, nftId, XRP(10)), ter(temDISABLED)); env.close(); BEAST_EXPECT(ownerCount(env, master) == 0); @@ -170,7 +171,9 @@ class NFToken0_test : public beast::unit_test::suite env.close(); uint256 const aliceOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId1, XRP(1000)), token::owner(master)); @@ -481,7 +484,8 @@ class NFToken0_test : public beast::unit_test::suite [&alice, &env](OpenView& view, beast::Journal j) { // Get the account root we want to hijack. auto const sle = view.read(keylet::account( - hash_options{(env.current()->seq())}, alice.id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())); if (!sle) return false; // This would be really surprising! @@ -934,7 +938,9 @@ class NFToken0_test : public beast::unit_test::suite // This is the offer we'll try to cancel. uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftAlice0ID, XRP(1)), token::owner(alice), @@ -1005,7 +1011,9 @@ class NFToken0_test : public beast::unit_test::suite // gw attempts to cancel a Check as through it is an NFTokenOffer. auto const gwCheckId = keylet::check( - hash_options{(env.current()->seq())}, gw, env.seq(gw)) + hash_options{(env.current()->seq()), KEYLET_CHECK}, + gw, + env.seq(gw)) .key; env(check::create(gw, env.master, XRP(300))); env.close(); @@ -1075,7 +1083,9 @@ class NFToken0_test : public beast::unit_test::suite // alice creates sell offers for her nfts. uint256 const plainOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftAlice0ID, XRP(10)), txflags(tfSellNFToken)); @@ -1084,7 +1094,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const audOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftAlice0ID, gwAUD(30)), txflags(tfSellNFToken)); @@ -1093,7 +1105,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const xrpOnlyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftXrpOnlyID, XRP(20)), txflags(tfSellNFToken)); @@ -1102,7 +1116,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const noXferOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftNoXferID, XRP(30)), txflags(tfSellNFToken)); @@ -1112,7 +1128,9 @@ class NFToken0_test : public beast::unit_test::suite // alice creates a sell offer that will expire soon. uint256 const aliceExpOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftNoXferID, XRP(40)), txflags(tfSellNFToken), @@ -1184,7 +1202,10 @@ class NFToken0_test : public beast::unit_test::suite // The buy offer must be present in the ledger. uint256 const missingOfferIndex = - keylet::nftoffer(hash_options{(env.current()->seq())}, alice, 1U) + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + 1U) .key; env(token::acceptBuyOffer(buyer, missingOfferIndex), ter(tecOBJECT_NOT_FOUND)); @@ -1232,7 +1253,9 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftAlice0ID, gwAUD(29)), token::owner(alice)); @@ -1267,7 +1290,9 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftAlice0ID, gwAUD(31)), token::owner(alice)); @@ -1308,7 +1333,9 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftAlice0ID, gwAUD(30)), token::owner(alice)); @@ -1340,7 +1367,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, alice, env.seq(alice)) .key; @@ -1371,7 +1398,9 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a buy offer for one of alice's nfts. uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftXrpOnlyID, XRP(30)), token::owner(alice)); @@ -1403,7 +1432,9 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, gw, env.seq(gw)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + gw, + env.seq(gw)) .key; env(token::createOffer(gw, nftAlice0ID, XRP(0)), txflags(tfSellNFToken)); @@ -1460,11 +1491,12 @@ class NFToken0_test : public beast::unit_test::suite env(token::mint(minter1, 0u), token::issuer(alice), txflags(flags)); env.close(); - uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter1, - env.seq(minter1)) - .key; + uint256 const offerIndex = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter1, + env.seq(minter1)) + .key; env(token::createOffer(minter1, nftID, XRP(0)), txflags(tfSellNFToken)); env.close(); @@ -1581,7 +1613,9 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 2); uint256 const aliceOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftIOUsOkayID, gwAUD(50)), txflags(tfSellNFToken)); @@ -1591,7 +1625,9 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 1); uint256 const buyerOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftIOUsOkayID, gwAUD(50)), token::owner(alice)); @@ -1703,7 +1739,7 @@ class NFToken0_test : public beast::unit_test::suite // becky buys the nft for 1 drop. uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, becky, env.seq(becky)) .key; @@ -1718,7 +1754,7 @@ class NFToken0_test : public beast::unit_test::suite xferFee ? TER(tecNO_LINE) : TER(tesSUCCESS); uint256 const beckyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, becky, env.seq(becky)) .key; @@ -1730,7 +1766,7 @@ class NFToken0_test : public beast::unit_test::suite // cheri offers to buy the nft for CAD. uint256 const cheriOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, cheri, env.seq(cheri)) .key; @@ -1774,7 +1810,7 @@ class NFToken0_test : public beast::unit_test::suite // becky buys the nft for 1 drop. uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, becky, env.seq(becky)) .key; @@ -1787,7 +1823,7 @@ class NFToken0_test : public beast::unit_test::suite // becky sells the nft for AUD. uint256 const beckySellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, becky, env.seq(becky)) .key; @@ -1803,7 +1839,7 @@ class NFToken0_test : public beast::unit_test::suite // becky buys the nft back for CAD. uint256 const beckyBuyBackOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, becky, env.seq(becky)) .key; @@ -1831,7 +1867,7 @@ class NFToken0_test : public beast::unit_test::suite // alice sells the nft using AUD. uint256 const aliceSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, alice, env.seq(alice)) .key; @@ -1853,7 +1889,7 @@ class NFToken0_test : public beast::unit_test::suite env.close(); uint256 const cheriSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, cheri, env.seq(cheri)) .key; @@ -1906,7 +1942,9 @@ class NFToken0_test : public beast::unit_test::suite // alice offers to sell the nft and becky accepts the offer. uint256 const aliceSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftAliceNoTransferID, XRP(20)), txflags(tfSellNFToken)); @@ -1938,7 +1976,9 @@ class NFToken0_test : public beast::unit_test::suite // the offer. uint256 const aliceBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftAliceNoTransferID, XRP(22)), token::owner(becky)); @@ -1999,7 +2039,7 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 1); uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2040,7 +2080,9 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); uint256 const aliceBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftMinterNoTransferID, XRP(25)), token::owner(becky)); @@ -2059,7 +2101,7 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == 0); uint256 const minterBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2105,7 +2147,9 @@ class NFToken0_test : public beast::unit_test::suite // Both alice and becky can make offers for alice's nft. uint256 const aliceSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftAliceID, XRP(20)), txflags(tfSellNFToken)); @@ -2114,7 +2158,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftAliceID, XRP(21)), token::owner(alice)); @@ -2130,7 +2176,9 @@ class NFToken0_test : public beast::unit_test::suite // becky offers to sell the nft. uint256 const beckySellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftAliceID, XRP(22)), txflags(tfSellNFToken)); @@ -2149,7 +2197,7 @@ class NFToken0_test : public beast::unit_test::suite // minter offers to sell the nft. uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2237,7 +2285,9 @@ class NFToken0_test : public beast::unit_test::suite // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); @@ -2253,7 +2303,9 @@ class NFToken0_test : public beast::unit_test::suite // becky sells nft to carol. alice's balance should not change. uint256 const beckySellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(10)), txflags(tfSellNFToken)); @@ -2267,7 +2319,7 @@ class NFToken0_test : public beast::unit_test::suite // minter buys nft from carol. alice's balance should not change. uint256 const minterBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2285,7 +2337,7 @@ class NFToken0_test : public beast::unit_test::suite // where they started. uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2319,7 +2371,9 @@ class NFToken0_test : public beast::unit_test::suite // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); @@ -2335,7 +2389,9 @@ class NFToken0_test : public beast::unit_test::suite // becky sells nft to carol. alice's balance goes up. uint256 const beckySellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(10)), txflags(tfSellNFToken)); @@ -2350,7 +2406,7 @@ class NFToken0_test : public beast::unit_test::suite // minter buys nft from carol. alice's balance goes up. uint256 const minterBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2369,7 +2425,7 @@ class NFToken0_test : public beast::unit_test::suite // transaction no tranfer fee is removed. uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2423,7 +2479,9 @@ class NFToken0_test : public beast::unit_test::suite // Becky buys the nft for XAU(10). Check balances. uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(10)), token::owner(alice)); @@ -2439,7 +2497,9 @@ class NFToken0_test : public beast::unit_test::suite // becky sells nft to minter. alice's balance goes up. uint256 const beckySellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, gwXAU(100)), txflags(tfSellNFToken)); @@ -2454,7 +2514,9 @@ class NFToken0_test : public beast::unit_test::suite // carol buys nft from minter. alice's balance goes up. uint256 const carolBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, carol, env.seq(carol)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + carol, + env.seq(carol)) .key; env(token::createOffer(carol, nftID, gwXAU(10)), token::owner(minter)); @@ -2471,7 +2533,9 @@ class NFToken0_test : public beast::unit_test::suite // transaction no tranfer fee is removed. uint256 const carolSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, carol, env.seq(carol)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + carol, + env.seq(carol)) .key; env(token::createOffer(carol, nftID, gwXAU(10)), txflags(tfSellNFToken)); @@ -2524,7 +2588,7 @@ class NFToken0_test : public beast::unit_test::suite STAmount minterBalance = env.balance(minter); uint256 const minterBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2543,7 +2607,7 @@ class NFToken0_test : public beast::unit_test::suite STAmount carolBalance = env.balance(carol); uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2562,7 +2626,9 @@ class NFToken0_test : public beast::unit_test::suite STAmount beckyBalance = env.balance(becky); uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; pmt = NumberSwitchOver ? drops(50001) : drops(100000); env(token::createOffer(becky, nftID, pmt), token::owner(carol)); @@ -2613,7 +2679,7 @@ class NFToken0_test : public beast::unit_test::suite STAmount minterBalance = env.balance(minter, gwXAU); uint256 const minterBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2631,7 +2697,7 @@ class NFToken0_test : public beast::unit_test::suite STAmount carolBalance = env.balance(carol, gwXAU); uint256 const minterSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2656,7 +2722,9 @@ class NFToken0_test : public beast::unit_test::suite STAmount beckyBalance = env.balance(becky, gwXAU); uint256 const beckyBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, becky, env.seq(becky)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + becky, + env.seq(becky)) .key; env(token::createOffer(becky, nftID, cheapNFT), token::owner(carol)); @@ -2893,7 +2961,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerMinterToIssuer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2903,7 +2971,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerMinterToBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -2913,7 +2981,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerIssuerToMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -2923,7 +2991,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerIssuerToBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -2973,7 +3041,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerMinterSellsToBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3007,7 +3075,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerMinterBuysFromBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3040,7 +3108,9 @@ class NFToken0_test : public beast::unit_test::suite // simply accept the offer. uint256 const offerBuyerBuysFromMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID, drops(1)), token::owner(minter), @@ -3067,7 +3137,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerMinterToBroker = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3077,7 +3147,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerBuyerToMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID, drops(1)), token::owner(minter)); @@ -3118,7 +3190,9 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerBuyerToMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID, drops(1)), token::destination(minter), @@ -3126,7 +3200,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerMinterToBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3135,7 +3209,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerIssuerToBuyer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -3200,7 +3274,7 @@ class NFToken0_test : public beast::unit_test::suite { uint256 const offerMinterToBroker = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3210,7 +3284,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerBuyerToBroker = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID, drops(1)), token::owner(minter), @@ -3301,11 +3377,12 @@ class NFToken0_test : public beast::unit_test::suite // create offer (allowed now) then cancel { - uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const offerIndex = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID, drops(1)), token::destination(buyer), @@ -3318,11 +3395,12 @@ class NFToken0_test : public beast::unit_test::suite // create offer, enable flag, then cancel { - uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const offerIndex = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID, drops(1)), token::destination(buyer), @@ -3341,11 +3419,12 @@ class NFToken0_test : public beast::unit_test::suite // create offer then transfer { - uint256 const offerIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const offerIndex = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID, drops(1)), token::destination(buyer), @@ -3421,7 +3500,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerMinterToIssuer = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3432,7 +3511,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerMinterToAnyone = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -3442,7 +3521,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerIssuerToMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -3452,7 +3531,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offerBuyerToMinter = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, drops(1)), token::owner(minter), @@ -3508,20 +3589,22 @@ class NFToken0_test : public beast::unit_test::suite { std::uint32_t const expiration = lastClose(env) + 25; - uint256 const offer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const offer0 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID0, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); - uint256 const offer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const offer1 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID1, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); @@ -3563,7 +3646,9 @@ class NFToken0_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, XRP(0)), txflags(tfSellNFToken), @@ -3584,7 +3669,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, drops(1)), token::owner(minter), @@ -3592,7 +3679,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const offer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID1, drops(1)), token::owner(minter), @@ -3635,7 +3724,9 @@ class NFToken0_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, XRP(0)), txflags(tfSellNFToken), @@ -3654,34 +3745,40 @@ class NFToken0_test : public beast::unit_test::suite { std::uint32_t const expiration = lastClose(env) + 25; - uint256 const sellOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer0 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID0, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); - uint256 const sellOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer1 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID1, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); uint256 const buyOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, drops(1)), token::owner(minter)); uint256 const buyOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID1, drops(1)), token::owner(minter)); @@ -3724,7 +3821,9 @@ class NFToken0_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, XRP(0)), txflags(tfSellNFToken), @@ -3743,25 +3842,29 @@ class NFToken0_test : public beast::unit_test::suite { std::uint32_t const expiration = lastClose(env) + 25; - uint256 const sellOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer0 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID0, drops(1)), txflags(tfSellNFToken)); - uint256 const sellOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer1 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID1, drops(1)), txflags(tfSellNFToken)); uint256 const buyOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, drops(1)), token::expiration(expiration), @@ -3769,7 +3872,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID1, drops(1)), token::expiration(expiration), @@ -3813,7 +3918,9 @@ class NFToken0_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, XRP(0)), txflags(tfSellNFToken), @@ -3833,27 +3940,31 @@ class NFToken0_test : public beast::unit_test::suite { std::uint32_t const expiration = lastClose(env) + 25; - uint256 const sellOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer0 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID0, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); - uint256 const sellOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, - minter, - env.seq(minter)) - .key; + uint256 const sellOffer1 = + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) + .key; env(token::createOffer(minter, nftokenID1, drops(1)), token::expiration(expiration), txflags(tfSellNFToken)); uint256 const buyOffer0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, drops(1)), token::expiration(expiration), @@ -3861,7 +3972,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyOffer1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID1, drops(1)), token::expiration(expiration), @@ -3905,7 +4018,9 @@ class NFToken0_test : public beast::unit_test::suite // a simple place. uint256 const offerSellBack = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftokenID0, XRP(0)), txflags(tfSellNFToken), @@ -3947,7 +4062,9 @@ class NFToken0_test : public beast::unit_test::suite // Anyone can cancel an expired offer. uint256 const expiredOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftokenID, XRP(1000)), @@ -3974,7 +4091,9 @@ class NFToken0_test : public beast::unit_test::suite // should be cancellable by the creator and the destination. uint256 const dest1OfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftokenID, XRP(1000)), @@ -3996,7 +4115,9 @@ class NFToken0_test : public beast::unit_test::suite // alice can cancel her own offer, even if becky is the destination. uint256 const dest2OfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftokenID, XRP(1000)), @@ -4021,7 +4142,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, minter, env.seq(minter)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + minter, + env.seq(minter)) .key; env(token::createOffer(minter, mintersNFTokenID, XRP(1000)), @@ -4087,11 +4210,12 @@ class NFToken0_test : public beast::unit_test::suite txflags(tfTransferable)); env.close(); - offerIndexes.push_back(keylet::nftoffer( - hash_options{(env.current()->seq())}, - offerAcct, - env.seq(offerAcct)) - .key); + offerIndexes.push_back( + keylet::nftoffer( + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerAcct, + env.seq(offerAcct)) + .key); env(token::createOffer(offerAcct, nftokenID, drops(1)), token::owner(nftAcct), token::expiration(lastClose(env) + 5)); @@ -4105,7 +4229,8 @@ class NFToken0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } // alice attempts to cancel all of the expired offers. There is one @@ -4119,7 +4244,8 @@ class NFToken0_test : public beast::unit_test::suite // Verify that offer is gone from the ledger. BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndexes.back()))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndexes.back()))); offerIndexes.pop_back(); // But alice adds a sell offer to the list... @@ -4133,7 +4259,9 @@ class NFToken0_test : public beast::unit_test::suite offerIndexes.push_back( keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key); env(token::createOffer(alice, nftokenID, drops(1)), txflags(tfSellNFToken)); @@ -4166,7 +4294,8 @@ class NFToken0_test : public beast::unit_test::suite for (uint256 const& offerIndex : offerIndexes) { BEAST_EXPECT(!env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, offerIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + offerIndex))); } } @@ -4255,7 +4384,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4267,7 +4396,7 @@ class NFToken0_test : public beast::unit_test::suite // offer zero. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4310,7 +4439,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4322,7 +4451,7 @@ class NFToken0_test : public beast::unit_test::suite // offer zero. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4375,7 +4504,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4387,7 +4516,7 @@ class NFToken0_test : public beast::unit_test::suite // offer zero. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4430,7 +4559,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4442,7 +4571,7 @@ class NFToken0_test : public beast::unit_test::suite // offer zero. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4519,7 +4648,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4532,7 +4661,8 @@ class NFToken0_test : public beast::unit_test::suite // own. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4556,7 +4686,8 @@ class NFToken0_test : public beast::unit_test::suite // asking. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4579,7 +4710,7 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4624,7 +4755,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4636,7 +4767,8 @@ class NFToken0_test : public beast::unit_test::suite // own. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4660,7 +4792,8 @@ class NFToken0_test : public beast::unit_test::suite // asking. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4682,7 +4815,7 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4730,7 +4863,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4741,7 +4874,7 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4780,7 +4913,7 @@ class NFToken0_test : public beast::unit_test::suite // minter creates their offer. uint256 const minterOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, minter, env.seq(minter)) .key; @@ -4791,7 +4924,7 @@ class NFToken0_test : public beast::unit_test::suite // buyer creates a large enough offer. uint256 const buyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, buyer, env.seq(buyer)) .key; @@ -4871,12 +5004,16 @@ class NFToken0_test : public beast::unit_test::suite // Both buyer1 and buyer2 create buy offers for nftId. uint256 const buyer1OfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer1, env.seq(buyer1)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer1, + env.seq(buyer1)) .key; env(token::createOffer(buyer1, nftId, XRP(100)), token::owner(issuer)); uint256 const buyer2OfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer2, env.seq(buyer2)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer2, + env.seq(buyer2)) .key; env(token::createOffer(buyer2, nftId, XRP(100)), token::owner(issuer)); env.close(); @@ -4971,7 +5108,9 @@ class NFToken0_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, buyer) == 10); uint256 const offerIndex0 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, buyerTicketSeq) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + buyerTicketSeq) .key; env(token::createOffer(buyer, nftId, XRP(1)), token::owner(issuer), @@ -4990,7 +5129,9 @@ class NFToken0_test : public beast::unit_test::suite // NFTokenCreateOffer. buyer tries again. uint256 const offerIndex1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, buyerTicketSeq) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + buyerTicketSeq) .key; env(token::createOffer(buyer, nftId, XRP(2)), token::owner(issuer), @@ -5073,7 +5214,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const carlaOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, carla, env.seq(carla)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + carla, + env.seq(carla)) .key; env(token::createOffer(carla, nftId, XRP(3)), token::owner(minter)); env.close(); @@ -5401,7 +5544,7 @@ class NFToken0_test : public beast::unit_test::suite // Make offers with negative amounts for the NFTs uint256 const sellNegXrpOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -5412,7 +5555,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const sellNegIouOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -5423,7 +5566,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyNegXrpOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftID0, XRP(-1)), token::owner(issuer), @@ -5432,7 +5577,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyNegIouOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftID1, gwXAU(-1)), token::owner(issuer), @@ -5517,7 +5664,7 @@ class NFToken0_test : public beast::unit_test::suite // Make offers with negative amounts for the NFTs uint256 const sellNegXrpOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -5527,7 +5674,7 @@ class NFToken0_test : public beast::unit_test::suite uint256 const sellNegIouOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, issuer, env.seq(issuer)) .key; @@ -5537,7 +5684,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyNegXrpOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftID0, XRP(-1)), token::owner(issuer)); @@ -5545,7 +5694,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const buyNegIouOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, buyer, env.seq(buyer)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + buyer, + env.seq(buyer)) .key; env(token::createOffer(buyer, nftID1, gwXAU(-1)), token::owner(issuer)); @@ -5741,7 +5892,8 @@ class NFToken0_test : public beast::unit_test::suite std::optional const terCode = {}) { uint256 const offerID = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, offerer, env.seq(offerer)) .key; @@ -5761,7 +5913,8 @@ class NFToken0_test : public beast::unit_test::suite std::optional const terCode = {}) { uint256 const offerID = keylet::nftoffer( - hash_options{(env.current()->seq())}, + hash_options{ + (env.current()->seq()), KEYLET_NFT_OFFER}, offerer, env.seq(offerer)) .key; @@ -6423,13 +6576,17 @@ class NFToken0_test : public beast::unit_test::suite // for 0 XRP. uint256 const bobBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, bob, env.seq(bob)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + bob, + env.seq(bob)) .key; env(token::createOffer(bob, nftId, XRP(5)), token::owner(alice)); uint256 const aliceSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId, XRP(0)), token::destination(bob), @@ -6442,12 +6599,15 @@ class NFToken0_test : public beast::unit_test::suite // Note that bob still has a buy offer on the books. BEAST_EXPECT(env.le(keylet::nftoffer( - hash_options{(env.current()->seq())}, bobBuyOfferIndex))); + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + bobBuyOfferIndex))); // Bob creates a sell offer for the gift NFT from alice. uint256 const bobSellOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, bob, env.seq(bob)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + bob, + env.seq(bob)) .key; env(token::createOffer(bob, nftId, XRP(4)), txflags(tfSellNFToken)); env.close(); @@ -6555,7 +6715,8 @@ class NFToken0_test : public beast::unit_test::suite // alice's account is deleted Keylet const aliceAcctKey{keylet::account( - hash_options{(env.current()->seq())}, alice.id())}; + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())}; auto const acctDelFee{drops(env.current()->fees().increment)}; env(acctdelete(alice, becky), fee(acctDelFee)); env.close(); @@ -6630,7 +6791,8 @@ class NFToken0_test : public beast::unit_test::suite // Verify that alice's account root is present. Keylet const aliceAcctKey{keylet::account( - hash_options{(env.current()->seq())}, alice.id())}; + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())}; BEAST_EXPECT(env.closed()->exists(aliceAcctKey)); BEAST_EXPECT(env.current()->exists(aliceAcctKey)); @@ -6774,7 +6936,8 @@ class NFToken0_test : public beast::unit_test::suite // Verify that alice's account root is present. Keylet const aliceAcctKey{keylet::account( - hash_options{(env.current()->seq())}, alice.id())}; + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())}; BEAST_EXPECT(env.closed()->exists(aliceAcctKey)); BEAST_EXPECT(env.current()->exists(aliceAcctKey)); @@ -6932,7 +7095,8 @@ class NFToken0_test : public beast::unit_test::suite // Verify that alice's account root is present. Keylet const aliceAcctKey{keylet::account( - hash_options{(env.current()->seq())}, alice.id())}; + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + alice.id())}; BEAST_EXPECT(env.closed()->exists(aliceAcctKey)); BEAST_EXPECT(env.current()->exists(aliceAcctKey)); @@ -7122,7 +7286,9 @@ class NFToken0_test : public beast::unit_test::suite // meta uint256 const aliceOfferIndex1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId1, drops(1)), txflags(tfSellNFToken)); @@ -7131,7 +7297,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const aliceOfferIndex2 = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId2, drops(1)), txflags(tfSellNFToken)); @@ -7150,7 +7318,9 @@ class NFToken0_test : public beast::unit_test::suite // Verify the offer id is correct in the NFTokenCreateOffer tx meta auto const bobBuyOfferIndex = keylet::nftoffer( - hash_options{(env.current()->seq())}, bob, env.seq(bob)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + bob, + env.seq(bob)) .key; env(token::createOffer(bob, nftId1, drops(1)), token::owner(alice)); env.close(); @@ -7175,7 +7345,9 @@ class NFToken0_test : public beast::unit_test::suite // Alice creates sell offer and set broker as destination uint256 const offerAliceToBroker = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId, drops(1)), token::destination(broker), @@ -7186,7 +7358,9 @@ class NFToken0_test : public beast::unit_test::suite // Bob creates buy offer uint256 const offerBobToBroker = keylet::nftoffer( - hash_options{(env.current()->seq())}, bob, env.seq(bob)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + bob, + env.seq(bob)) .key; env(token::createOffer(bob, nftId, drops(1)), token::owner(alice)); env.close(); @@ -7212,7 +7386,9 @@ class NFToken0_test : public beast::unit_test::suite // Alice creates 2 sell offers for the same NFT uint256 const aliceOfferIndex1 = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId, drops(1)), txflags(tfSellNFToken)); @@ -7221,7 +7397,9 @@ class NFToken0_test : public beast::unit_test::suite uint256 const aliceOfferIndex2 = keylet::nftoffer( - hash_options{(env.current()->seq())}, alice, env.seq(alice)) + hash_options{(env.current()->seq()), KEYLET_NFT_OFFER}, + alice, + env.seq(alice)) .key; env(token::createOffer(alice, nftId, drops(1)), txflags(tfSellNFToken)); diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 7feb5e6e9..9854f34b3 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -2236,7 +2236,8 @@ public: payment[jss::tx_json][jss::Sequence] = env.current() ->read(keylet::account( - hash_options{(env.current()->seq())}, bob.id())) + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id())) ->getFieldU32(sfSequence); payment[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base); payment[jss::tx_json][jss::SendMax] = @@ -2277,7 +2278,7 @@ public: jtx::PrettyAmount const& expectBalance) { auto const sleTrust = env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, account.id(), expectBalance.value().issue())); BEAST_EXPECT(sleTrust); @@ -2448,7 +2449,7 @@ public: { // Verify that no trustline was created. auto const sleTrust = env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, acct, USD.issue())); BEAST_EXPECT(!sleTrust); @@ -2639,9 +2640,13 @@ public: // The two trustlines that were generated by offers should be gone. BEAST_EXPECT(!env.le(keylet::line( - hash_options{(env.current()->seq())}, alice.id(), EUR.issue()))); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + alice.id(), + EUR.issue()))); BEAST_EXPECT(!env.le(keylet::line( - hash_options{(env.current()->seq())}, bob.id(), USD.issue()))); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + bob.id(), + USD.issue()))); // Make two more offers that leave one of the offers non-dry. We // need to properly sequence the transactions: @@ -4624,7 +4629,10 @@ public: jtx::Account const& dst, Currency const& cur) -> bool { return bool(env.le(keylet::line( - hash_options{(env.current()->seq())}, src, dst, cur))); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + src, + dst, + cur))); }; Account const alice("alice"); @@ -4680,7 +4688,8 @@ public: // Verify that gw's account root is gone from the ledger. BEAST_EXPECT(!env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, gw.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + gw.id()))); } // alice crosses becky's first offer. The offer create fails because @@ -5076,7 +5085,8 @@ public: static uint256 getOfferIndex(AccountID const& account, std::uint32_t uSequence) { - return keylet::offer(hash_options{1}, account, uSequence).key; + return keylet::offer(hash_options{1, KEYLET_OFFER}, account, uSequence) + .key; } void @@ -5115,7 +5125,9 @@ public: env(tx, ter(tesSUCCESS)); env.close(); auto const offerLE = env.le(keylet::offer( - hash_options{(env.current()->seq())}, alice, offerSeqId)); + hash_options{(env.current()->seq()), KEYLET_OFFER}, + alice, + offerSeqId)); BEAST_EXPECT(!offerLE); } @@ -5128,8 +5140,7 @@ public: auto tx = offer(alice, XRP(50), USD(50)); env(tx, offer_id(offerId), ter(tesSUCCESS)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(!offerLE); } @@ -5141,8 +5152,7 @@ public: env(offer(alice, XRP(50), USD(50))); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } @@ -5157,8 +5167,7 @@ public: tx[sfOfferSequence.jsonName] = offerSeqId; env(tx, offer_id(offerId), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } @@ -5172,8 +5181,7 @@ public: tx[sfOfferSequence.jsonName] = 0; env(tx, offer_id(offerId), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } } @@ -5205,7 +5213,9 @@ public: env(offer_cancel(alice, offerSeqId), ter(tesSUCCESS)); env.close(); auto const offerLE = env.le(keylet::offer( - hash_options{(env.current()->seq())}, alice, offerSeqId)); + hash_options{(env.current()->seq()), KEYLET_OFFER}, + alice, + offerSeqId)); BEAST_EXPECT(!offerLE); } @@ -5221,8 +5231,7 @@ public: offer_id(offerId), ter(tesSUCCESS)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(!offerLE); } else @@ -5231,8 +5240,7 @@ public: offer_id(offerId), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } } @@ -5245,8 +5253,7 @@ public: env(offer_cancel(alice), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } @@ -5263,8 +5270,7 @@ public: offer_id(offerId), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } else @@ -5273,8 +5279,7 @@ public: offer_id(offerId), ter(tesSUCCESS)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(!offerLE); } } @@ -5289,8 +5294,7 @@ public: offer_id(offerId), ter(temBAD_SEQUENCE)); env.close(); - auto const offerLE = env.le(keylet::unchecked( - hash_options{(env.current()->seq())}, offerId)); + auto const offerLE = env.le(keylet::unchecked(offerId)); BEAST_EXPECT(offerLE); } } diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index 653fda921..597ed78ec 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -831,11 +831,12 @@ public: })", jv); - auto const jv_l = env.le(keylet::line( - hash_options{(env.current()->seq())}, - Account("bob").id(), - Account("alice")["USD"].issue())) - ->getJson(JsonOptions::none); + auto const jv_l = + env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + Account("bob").id(), + Account("alice")["USD"].issue())) + ->getJson(JsonOptions::none); for (auto it = jv.begin(); it != jv.end(); ++it) BEAST_EXPECT(*it == jv_l[it.memberName()]); } @@ -875,11 +876,12 @@ public: })", jv); - auto const jv_l = env.le(keylet::line( - hash_options{(env.current()->seq())}, - Account("bob").id(), - Account("alice")["USD"].issue())) - ->getJson(JsonOptions::none); + auto const jv_l = + env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + Account("bob").id(), + Account("alice")["USD"].issue())) + ->getJson(JsonOptions::none); for (auto it = jv.begin(); it != jv.end(); ++it) BEAST_EXPECT(*it == jv_l[it.memberName()]); @@ -887,7 +889,7 @@ public: env.trust(Account("alice")["USD"](0), "bob"); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, Account("bob").id(), Account("alice")["USD"].issue())) == nullptr); } @@ -931,18 +933,19 @@ public: })", jv); - auto const jv_l = env.le(keylet::line( - hash_options{(env.current()->seq())}, - Account("alice").id(), - Account("bob")["USD"].issue())) - ->getJson(JsonOptions::none); + auto const jv_l = + env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + Account("alice").id(), + Account("bob")["USD"].issue())) + ->getJson(JsonOptions::none); for (auto it = jv.begin(); it != jv.end(); ++it) BEAST_EXPECT(*it == jv_l[it.memberName()]); env(pay("alice", "bob", Account("alice")["USD"](50))); BEAST_EXPECT( env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, Account("alice").id(), Account("bob")["USD"].issue())) == nullptr); } diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index 190cfbce2..c2b54746c 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -40,8 +40,8 @@ struct PayChan_test : public beast::unit_test::suite jtx::Account const& dst, std::uint32_t seqProxyValue) { - auto const k = - keylet::payChan(hash_options{1}, account, dst, seqProxyValue); + auto const k = keylet::payChan( + hash_options{1, KEYLET_PAYCHAN}, account, dst, seqProxyValue); return k.key; } @@ -51,12 +51,15 @@ struct PayChan_test : public beast::unit_test::suite jtx::Account const& account, jtx::Account const& dst) { - auto const sle = - view.read(keylet::account(hash_options{(view.seq())}, account)); + auto const sle = view.read(keylet::account( + hash_options{(view.seq()), KEYLET_ACCOUNT}, account)); if (!sle) return {}; auto const k = keylet::payChan( - hash_options{(view.seq())}, account, dst, (*sle)[sfSequence] - 1); + hash_options{(view.seq()), KEYLET_PAYCHAN}, + account, + dst, + (*sle)[sfSequence] - 1); return {k.key, view.read(k)}; } @@ -131,7 +134,10 @@ struct PayChan_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle->isFieldPresent(sfLockedBalance)) return (*sle)[sfLockedBalance]; return STAmount(iou, 0); @@ -146,7 +152,10 @@ struct PayChan_test : public beast::unit_test::suite { auto const aHigh = account.id() > gw.id(); auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit)) return (*sle)[aHigh ? sfLowLimit : sfHighLimit]; return STAmount(iou, 0); @@ -160,7 +169,10 @@ struct PayChan_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle && sle->isFieldPresent(sfBalance)) return (*sle)[sfBalance]; return STAmount(iou, 0); @@ -1664,14 +1676,18 @@ struct PayChan_test : public beast::unit_test::suite auto inOwnerDir = [](ReadView const& view, Account const& acc, std::shared_ptr const& chan) -> bool { - ripple::Dir const ownerDir(view, keylet::ownerDir(acc.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acc.id())); return std::find(ownerDir.begin(), ownerDir.end(), chan) != ownerDir.end(); }; auto ownerDirCount = [](ReadView const& view, Account const& acc) -> std::size_t { - ripple::Dir const ownerDir(view, keylet::ownerDir(acc.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acc.id())); return std::distance(ownerDir.begin(), ownerDir.end()); }; @@ -1780,7 +1796,8 @@ struct PayChan_test : public beast::unit_test::suite this->BEAST_EXPECT( isTesSuccess(expectedTer) == !env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, toRm.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + toRm.id()))); }; auto const alice = Account("alice"); @@ -1901,7 +1918,8 @@ struct PayChan_test : public beast::unit_test::suite // Since `fixPayChanRecipientOwnerDir` is not active, can remove bob rmAccount(env, bob, carol); BEAST_EXPECT(!env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); auto chanBal = channelBalance(*env.current(), chan); auto chanAmt = channelAmount(*env.current(), chan); @@ -1938,7 +1956,8 @@ struct PayChan_test : public beast::unit_test::suite env(pay(alice, bob, XRP(20))); env.close(); BEAST_EXPECT(env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); { // alice should be able to claim @@ -3977,14 +3996,18 @@ struct PayChan_test : public beast::unit_test::suite auto inOwnerDir = [](ReadView const& view, Account const& acc, std::shared_ptr const& chan) -> bool { - ripple::Dir const ownerDir(view, keylet::ownerDir(acc.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acc.id())); return std::find(ownerDir.begin(), ownerDir.end(), chan) != ownerDir.end(); }; auto ownerDirCount = [](ReadView const& view, Account const& acc) -> std::size_t { - ripple::Dir const ownerDir(view, keylet::ownerDir(acc.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acc.id())); return std::distance(ownerDir.begin(), ownerDir.end()); }; @@ -4118,7 +4141,8 @@ struct PayChan_test : public beast::unit_test::suite this->BEAST_EXPECT( isTesSuccess(expectedTer) == !env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, toRm.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + toRm.id()))); }; auto const alice = Account("alice"); @@ -4281,7 +4305,8 @@ struct PayChan_test : public beast::unit_test::suite env.close(); rmAccount(env, bob, carol); BEAST_EXPECT(!env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); auto chanBal = channelBalance(*env.current(), chan); auto chanAmt = channelAmount(*env.current(), chan); @@ -4329,7 +4354,8 @@ struct PayChan_test : public beast::unit_test::suite env(pay(gw, bob, USD(10000))); env.close(); BEAST_EXPECT(env.closed()->exists(keylet::account( - hash_options{(env.current()->seq())}, bob.id()))); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + bob.id()))); { // alice should be able to claim preBob = env.balance(bob, USD.issue()); diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 275512355..89c764453 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -75,8 +75,11 @@ getTrustFlag( Currency const& cur, TrustFlag flag) { - if (auto sle = env.le( - keylet::line(hash_options{(env.current()->seq())}, src, dst, cur))) + if (auto sle = env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + src, + dst, + cur))) { auto const useHigh = src.id() > dst.id(); return sle->isFlag(trustFlag(flag, useHigh)); @@ -500,8 +503,8 @@ struct ExistingElementPool std::uint64_t totalXRP = 0; auto add = [&](auto const& a) { // XRP balance - auto const sle = - v.read(keylet::account(hash_options{(v.seq())}, a)); + auto const sle = v.read( + keylet::account(hash_options{(v.seq()), KEYLET_ACCOUNT}, a)); if (!sle) return; auto const b = (*sle)[sfBalance]; @@ -539,7 +542,8 @@ struct ExistingElementPool { { // XRP balance - auto const ak = keylet::account(hash_options{(v1.seq())}, *ai1); + auto const ak = keylet::account( + hash_options{(v1.seq()), KEYLET_ACCOUNT}, *ai1); auto const b1 = xrpBalance(v1, ak); auto const b2 = xrpBalance(v2, ak); totalXRP[0] += b1.mantissa(); @@ -554,8 +558,11 @@ struct ExistingElementPool for (auto const& c : currencies) { // Line balance - auto const lk = - keylet::line(hash_options{(v1.seq())}, *ai1, *ai2, c); + auto const lk = keylet::line( + hash_options{(v1.seq()), KEYLET_TRUSTLINE}, + *ai1, + *ai2, + c); auto const b1 = lineBalance(v1, lk); auto const b2 = lineBalance(v2, lk); if (b1 != b2) diff --git a/src/test/app/PreviousTxn_test.cpp b/src/test/app/PreviousTxn_test.cpp index 41e04fe27..bb78fe6f4 100644 --- a/src/test/app/PreviousTxn_test.cpp +++ b/src/test/app/PreviousTxn_test.cpp @@ -96,7 +96,10 @@ public: // Now let's check the actual ledger entry to see if PreviousTxnID was // set Get the trustline from the ledger auto const trustlineKey = keylet::line( - hash_options{(env.current()->seq())}, alice, bob, USD.currency); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + alice, + bob, + USD.currency); auto const sleTrustline = env.le(trustlineKey); BEAST_EXPECT(sleTrustline); @@ -275,10 +278,10 @@ public: } // Check account objects were threaded correctly - auto const aliceAccount = env.le( - keylet::account(hash_options{(env.current()->seq())}, alice)); - auto const bobAccount = - env.le(keylet::account(hash_options{(env.current()->seq())}, bob)); + auto const aliceAccount = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, alice)); + auto const bobAccount = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, bob)); BEAST_EXPECT(aliceAccount); BEAST_EXPECT(bobAccount); diff --git a/src/test/app/RCLValidations_test.cpp b/src/test/app/RCLValidations_test.cpp index b04eab244..878cd0953 100644 --- a/src/test/app/RCLValidations_test.cpp +++ b/src/test/app/RCLValidations_test.cpp @@ -106,8 +106,8 @@ class RCLValidations_test : public beast::unit_test::suite *prev, env.app().timeKeeper().closeTime()); // Force a different hash on the first iteration next->updateSkipList(); - BEAST_EXPECT( - next->read(keylet::fees(hash_options{(env.current()->seq())}))); + BEAST_EXPECT(next->read(keylet::fees( + hash_options{(env.current()->seq()), KEYLET_FEES}))); if (forceHash) { next->setImmutable(); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index b5118baee..d160374a2 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -85,7 +85,8 @@ struct Regression_test : public beast::unit_test::suite BEAST_EXPECT(next->info().drops == expectedDrops); { auto const sle = next->read(keylet::account( - hash_options{(env.current()->seq())}, Account("alice").id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + Account("alice").id())); BEAST_EXPECT(sle); auto balance = sle->getFieldAmount(sfBalance); @@ -108,7 +109,8 @@ struct Regression_test : public beast::unit_test::suite } { auto const sle = next->read(keylet::account( - hash_options{(env.current()->seq())}, Account("alice").id())); + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + Account("alice").id())); BEAST_EXPECT(sle); auto balance = sle->getFieldAmount(sfBalance); diff --git a/src/test/app/Remit_test.cpp b/src/test/app/Remit_test.cpp index 381ff1958..5297c1490 100644 --- a/src/test/app/Remit_test.cpp +++ b/src/test/app/Remit_test.cpp @@ -63,7 +63,9 @@ struct Remit_test : public beast::unit_test::suite { auto const uritSle = view.read({ltURI_TOKEN, tid}); ripple::Dir const ownerDir( - view, keylet::ownerDir(hash_options{(view.seq())}, acct.id())); + view, + keylet::ownerDir( + hash_options{(view.seq()), KEYLET_OWNER_DIR}, acct.id())); return std::find(ownerDir.begin(), ownerDir.end(), uritSle) != ownerDir.end(); } @@ -72,7 +74,9 @@ struct Remit_test : public beast::unit_test::suite ownerDirCount(ReadView const& view, jtx::Account const& acct) { ripple::Dir const ownerDir( - view, keylet::ownerDir(hash_options{(view.seq())}, acct.id())); + view, + keylet::ownerDir( + hash_options{(view.seq()), KEYLET_OWNER_DIR}, acct.id())); return std::distance(ownerDir.begin(), ownerDir.end()); }; @@ -102,7 +106,10 @@ struct Remit_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const sle = env.le(keylet::line( - hash_options{(env.current()->seq())}, account, gw, iou.currency)); + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account, + gw, + iou.currency)); if (sle && sle->isFieldPresent(sfBalance)) return (*sle)[sfBalance]; return STAmount(iou, 0); @@ -114,8 +121,8 @@ struct Remit_test : public beast::unit_test::suite jtx::Account const& account, std::uint32_t const& sequence) { - auto const sle = env.le( - keylet::account(hash_options{(env.current()->seq())}, account)); + auto const sle = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, account)); if (sle && sle->isFieldPresent(sfSequence)) return (*sle)[sfSequence] == sequence; return false; @@ -128,7 +135,9 @@ struct Remit_test : public beast::unit_test::suite std::string const& uri) { auto const k = keylet::uritoken( - hash_options{(view.seq())}, account, Blob(uri.begin(), uri.end())); + hash_options{(view.seq()), KEYLET_URI_TOKEN}, + account, + Blob(uri.begin(), uri.end())); return {k.key, view.read(k)}; } diff --git a/src/test/app/SetAuth_test.cpp b/src/test/app/SetAuth_test.cpp index feb55086a..a0ba19e9a 100644 --- a/src/test/app/SetAuth_test.cpp +++ b/src/test/app/SetAuth_test.cpp @@ -58,7 +58,7 @@ struct SetAuth_test : public beast::unit_test::suite env(fset(gw, asfRequireAuth)); env(auth(gw, "alice", "USD")); BEAST_EXPECT(env.le(keylet::line( - hash_options{(env.current()->seq())}, + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, Account("alice").id(), gw.id(), USD.currency))); diff --git a/src/test/app/SetHookTSH_test.cpp b/src/test/app/SetHookTSH_test.cpp index d049c61b6..ba54eccd5 100644 --- a/src/test/app/SetHookTSH_test.cpp +++ b/src/test/app/SetHookTSH_test.cpp @@ -849,7 +849,8 @@ private: static uint256 getCheckIndex(AccountID const& account, std::uint32_t uSequence) { - return keylet::check(hash_options{1}, account, uSequence).key; + return keylet::check(hash_options{1, KEYLET_CHECK}, account, uSequence) + .key; } void @@ -1475,7 +1476,9 @@ private: static uint256 getEscrowIndex(AccountID const& account, std::uint32_t uSequence) { - return keylet::escrow(hash_options{1}, account, uSequence).key; + return keylet::escrow( + hash_options{1, KEYLET_ESCROW}, account, uSequence) + .key; } void @@ -3405,8 +3408,8 @@ private: jtx::Account const& dst, std::uint32_t seqProxyValue) { - auto const k = - keylet::payChan(hash_options{1}, account, dst, seqProxyValue); + auto const k = keylet::payChan( + hash_options{1, KEYLET_PAYCHAN}, account, dst, seqProxyValue); return k.key; } diff --git a/src/test/app/SetHook_test.cpp b/src/test/app/SetHook_test.cpp index 6b441287a..7a3c573c0 100644 --- a/src/test/app/SetHook_test.cpp +++ b/src/test/app/SetHook_test.cpp @@ -69,11 +69,13 @@ using JSSMap = return; \ } -#define HASH_WASM(x) \ - [[maybe_unused]] uint256 const x##_hash = \ - ripple::sha512Half_s(ripple::Slice(x##_wasm.data(), x##_wasm.size())); \ - [[maybe_unused]] std::string const x##_hash_str = to_string(x##_hash); \ - [[maybe_unused]] Keylet const x##_keylet = keylet::hookDefinition(x##_hash); +#define HASH_WASM(x) \ + [[maybe_unused]] uint256 const x##_hash = ripple::sha512Half_s( \ + hash_options{0, LEDGER_INDEX_UNNEEDED}, \ + ripple::Slice(x##_wasm.data(), x##_wasm.size())); \ + [[maybe_unused]] std::string const x##_hash_str = to_string(x##_hash); \ + [[maybe_unused]] Keylet const x##_keylet = keylet::hookDefinition( \ + hash_options{0, KEYLET_HOOK_DEFINITION}, x##_hash); class SetHook0_test : public beast::unit_test::suite { @@ -731,7 +733,9 @@ public: // check to ensure definition is deleted and hooks object too auto const def = env.le(accept_keylet); - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_EXPECT(!def); BEAST_EXPECT(!hook); @@ -777,7 +781,9 @@ public: BEAST_REQUIRE(accept2_def); // check the hooks array is correct - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); auto const& hooks = hook->getFieldArray(sfHooks); @@ -827,7 +833,9 @@ public: BEAST_EXPECT(!accept2_def); // check the hooks object is gone - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_EXPECT(!hook); } } @@ -900,8 +908,11 @@ public: 0xCAU, 0xFEU, 0xCAU, 0xFEU, 0xCAU, 0xFEU, 0xCAU, 0xFEU}) .data()); - auto const stateKeylet = - keylet::hookState(Account("alice").id(), key, ns); + auto const stateKeylet = keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + Account("alice").id(), + key, + ns); // create a namespace std::string ns_str = @@ -945,7 +956,9 @@ public: env.close(); // ensure the hook is still installed - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); @@ -955,8 +968,10 @@ public: BEAST_EXPECT(hooks[0].getFieldH256(sfHookHash) == makestate_hash); // ensure the directory is gone - auto const dirKeylet = - keylet::hookStateDir(Account("alice").id(), ns); + auto const dirKeylet = keylet::hookStateDir( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, + Account("alice").id(), + ns); BEAST_EXPECT(!env.le(dirKeylet)); // ensure the state object is gone @@ -1051,7 +1066,9 @@ public: // ensure the directory is still there auto const dirKeylet = keylet::hookStateDir( - Account("alice").id(), uint256{beast::zero}); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, + Account("alice").id(), + uint256{beast::zero}); if (fixNS) { BEAST_EXPECT(env.le(dirKeylet)); @@ -1081,7 +1098,9 @@ public: // ensure the directory is gone auto const dirKeylet = keylet::hookStateDir( - Account("alice").id(), uint256{beast::zero}); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, + Account("alice").id(), + uint256{beast::zero}); BEAST_EXPECT(!env.le(dirKeylet)); // ensure the owner count is 1 @@ -1357,7 +1376,9 @@ public: env.close(); auto const def = env.le(accept_keylet); - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); // check if the hook definition exists BEAST_EXPECT(!!def); @@ -1375,8 +1396,9 @@ public: // check if the wasm binary was correctly set BEAST_EXPECT(def->isFieldPresent(sfCreateCode)); auto const& wasm = def->getFieldVL(sfCreateCode); - auto const wasm_hash = - sha512Half_s(ripple::Slice(wasm.data(), wasm.size())); + auto const wasm_hash = sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice(wasm.data(), wasm.size())); BEAST_EXPECT(wasm_hash == accept_hash); } @@ -1395,7 +1417,9 @@ public: env.close(); auto const def = env.le(accept_keylet); - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); // check if the hook definition exists BEAST_EXPECT(!!def); @@ -1417,6 +1441,7 @@ public: } auto const rollback_hash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(rollback_wasm.data(), rollback_wasm.size())); // test override @@ -1429,7 +1454,9 @@ public: auto const rollback_def = env.le(rollback_keylet); auto const accept_def = env.le(accept_keylet); - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); // check if the hook definition exists BEAST_EXPECT(rollback_def); @@ -1450,8 +1477,9 @@ public: // check if the wasm binary was correctly set BEAST_EXPECT(rollback_def->isFieldPresent(sfCreateCode)); auto const& wasm = rollback_def->getFieldVL(sfCreateCode); - auto const wasm_hash = - sha512Half_s(ripple::Slice(wasm.data(), wasm.size())); + auto const wasm_hash = sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice(wasm.data(), wasm.size())); BEAST_EXPECT(wasm_hash == rollback_hash); // check if the reference count was correctly incremented @@ -1602,7 +1630,9 @@ public: } // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1678,7 +1708,9 @@ public: } // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1729,7 +1761,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1779,7 +1813,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1835,7 +1871,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1882,7 +1920,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1936,7 +1976,9 @@ public: } // ensure hook still exists and that there was no created new entry - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); auto const& hooks = hook->getFieldArray(sfHooks); @@ -1973,7 +2015,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); @@ -2021,7 +2065,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); @@ -2054,7 +2100,9 @@ public: env.close(); // ensure hook still exists - auto const hook = env.le(keylet::hook(Account("alice").id())); + auto const hook = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + Account("alice").id())); BEAST_REQUIRE(hook); BEAST_REQUIRE(hook->isFieldPresent(sfHooks)); @@ -5667,9 +5715,11 @@ public: // compute the hashes auto computedHash2 = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(hook.data(), hook.size())); auto computedHash1 = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(hook2.data(), hook2.size())); // ensure the computed hashes match @@ -6515,6 +6565,7 @@ public: BEAST_EXPECT(retStr.size() == 64); auto const computed_hash_1 = ripple::sha512Half( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::HashPrefix::hookNonce, seq, llc, @@ -6523,6 +6574,7 @@ public: (uint16_t)0UL, alice.id()); auto const computed_hash_2 = ripple::sha512Half( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::HashPrefix::hookNonce, seq, llc, @@ -8677,7 +8729,10 @@ public: } auto const aliceid = Account("alice").id(); - auto const nsdirkl = keylet::hookStateDir(aliceid, beast::zero); + auto const nsdirkl = keylet::hookStateDir( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, + aliceid, + beast::zero); std::string const invid = std::string(24, '0') + strHex(alice.id()); @@ -8689,8 +8744,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!nsdir); - auto const state1 = - env.le(ripple::keylet::hookState(aliceid, one, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + one, + beast::zero)); BEAST_REQUIRE(!state1); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 2); @@ -8722,8 +8780,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!nsdir); - auto const state1 = env.le( - ripple::keylet::hookState(david.id(), one, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + david.id(), + one, + beast::zero)); BEAST_REQUIRE(!state1); BEAST_EXPECT((*env.le("david"))[sfOwnerCount] == 0); @@ -8745,8 +8806,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!!nsdir); - auto const state1 = - env.le(ripple::keylet::hookState(aliceid, one, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + one, + beast::zero)); BEAST_REQUIRE(!!state1); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 3); @@ -8768,8 +8832,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!nsdir); - auto const state1 = - env.le(ripple::keylet::hookState(aliceid, one, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + one, + beast::zero)); BEAST_REQUIRE(!state1); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 2); @@ -8823,8 +8890,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!!nsdir); - auto const state1 = - env.le(ripple::keylet::hookState(aliceid, one, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + one, + beast::zero)); BEAST_REQUIRE(!!state1); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 3); @@ -9015,15 +9085,21 @@ public: auto const aliceid = Account("alice").id(); - auto const nsdirkl = keylet::hookStateDir(aliceid, beast::zero); + auto const nsdirkl = keylet::hookStateDir( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE_DIR}, + aliceid, + beast::zero); // ensure there's no way the state or directory exist before we start { auto const nsdir = env.le(nsdirkl); BEAST_REQUIRE(!nsdir); - auto const state1 = env.le( - ripple::keylet::hookState(aliceid, beast::zero, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + beast::zero, + beast::zero)); BEAST_REQUIRE(!state1); BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); @@ -9147,8 +9223,11 @@ public: auto const nsdir = env.le(nsdirkl); BEAST_EXPECT(!nsdir); - auto const state1 = env.le( - ripple::keylet::hookState(aliceid, beast::zero, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + beast::zero, + beast::zero)); BEAST_EXPECT(!state1); // invoke the hook from bob to alice, this will work @@ -9166,8 +9245,11 @@ public: BEAST_EXPECT(nsdir->getFieldV256(sfIndexes).size() == 2); - auto const state1 = env.le( - ripple::keylet::hookState(aliceid, beast::zero, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + beast::zero, + beast::zero)); BEAST_REQUIRE(!!state1); BEAST_EXPECT(state1->getFieldH256(sfHookStateKey) == beast::zero); @@ -9182,7 +9264,10 @@ public: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; auto const state2 = env.le(ripple::keylet::hookState( - aliceid, uint256::fromVoid(key2), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + uint256::fromVoid(key2), + beast::zero)); BEAST_REQUIRE(!!state2); @@ -9425,8 +9510,11 @@ public: BEAST_EXPECT(nsdir->getFieldV256(sfIndexes).size() == 1); - auto const state1 = env.le( - ripple::keylet::hookState(aliceid, beast::zero, beast::zero)); + auto const state1 = env.le(ripple::keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + beast::zero, + beast::zero)); BEAST_REQUIRE(!!state1); BEAST_EXPECT(state1->getFieldH256(sfHookStateKey) == beast::zero); @@ -9443,7 +9531,10 @@ public: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; auto const state2 = env.le(ripple::keylet::hookState( - aliceid, uint256::fromVoid(key2), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + uint256::fromVoid(key2), + beast::zero)); BEAST_REQUIRE(!state2); } @@ -9519,7 +9610,10 @@ public: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFU}; auto const state = env.le(ripple::keylet::hookState( - aliceid, uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + uint256::fromVoid(key), + beast::zero)); BEAST_EXPECT(state); @@ -9536,7 +9630,10 @@ public: // check the state is still present { auto const state = env.le(ripple::keylet::hookState( - aliceid, uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + uint256::fromVoid(key), + beast::zero)); BEAST_EXPECT(state); } @@ -9554,7 +9651,10 @@ public: // check the state is still present { auto const state = env.le(ripple::keylet::hookState( - aliceid, uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + aliceid, + uint256::fromVoid(key), + beast::zero)); BEAST_EXPECT(state); } diff --git a/src/test/app/SetRemarks_test.cpp b/src/test/app/SetRemarks_test.cpp index 82b782035..a2c783a81 100644 --- a/src/test/app/SetRemarks_test.cpp +++ b/src/test/app/SetRemarks_test.cpp @@ -29,7 +29,8 @@ namespace ripple { namespace test { struct SetRemarks_test : public beast::unit_test::suite { - // debugRemarks(env, keylet::account(alice).key); + // debugRemarks(env, keylet::account(hash_options{0, KEYLET_ACCOUNT}, + // alice).key); void debugRemarks(jtx::Env& env, uint256 const& id) { @@ -96,7 +97,10 @@ struct SetRemarks_test : public beast::unit_test::suite }; auto const txResult = withRemarks ? ter(tesSUCCESS) : ter(temDISABLED); - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), txResult); env.close(); @@ -129,7 +133,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"CAFE", "DEADBEEF", 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), txflags(tfClose), fee(XRP(1)), ter(temINVALID_FLAG)); @@ -143,7 +150,10 @@ struct SetRemarks_test : public beast::unit_test::suite { marks.push_back({"CAFE", "DEADBEEF", 0}); } - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -156,7 +166,10 @@ struct SetRemarks_test : public beast::unit_test::suite { marks.push_back({"CAFE", "DEADBEEF", 0}); } - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -169,7 +182,8 @@ struct SetRemarks_test : public beast::unit_test::suite Json::Value jv; jv[jss::TransactionType] = jss::SetRemarks; jv[jss::Account] = alice.human(); - jv[sfObjectID.jsonName] = strHex(keylet::account(alice).key); + jv[sfObjectID.jsonName] = strHex( + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key); auto& ja = jv[sfRemarks.getJsonName()]; for (std::size_t i = 0; i < 1; ++i) { @@ -188,7 +202,10 @@ struct SetRemarks_test : public beast::unit_test::suite {"CAFE", "DEADBEEF", 0}, {"CAFE", "DEADBEEF", 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -199,7 +216,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"", "DEADBEEF", 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -211,7 +231,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {name, "DEADBEEF", 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -221,7 +244,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"CAFE", "DEADBEEF", 2}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -232,7 +258,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"CAFE", std::nullopt, 1}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -243,7 +272,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"CAFE", "", 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -255,7 +287,10 @@ struct SetRemarks_test : public beast::unit_test::suite std::vector marks = { {"CAFE", value, 0}, }; - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(temMALFORMED)); env.close(); @@ -291,8 +326,10 @@ struct SetRemarks_test : public beast::unit_test::suite { auto const carol = Account("carol"); env.memoize(carol); - auto tx = - remarks::setRemarks(carol, keylet::account(carol).key, marks); + auto tx = remarks::setRemarks( + carol, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, carol).key, + marks); tx[jss::Sequence] = 0; env(tx, carol, fee(XRP(1)), ter(terNO_ACCOUNT)); env.close(); @@ -300,7 +337,10 @@ struct SetRemarks_test : public beast::unit_test::suite // tecNO_TARGET - object doesnt exist { - env(remarks::setRemarks(alice, keylet::account(carol).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, carol).key, + marks), fee(XRP(1)), ter(tecNO_TARGET)); env.close(); @@ -310,14 +350,21 @@ struct SetRemarks_test : public beast::unit_test::suite { env(deposit::auth(bob, alice)); env(remarks::setRemarks( - alice, keylet::depositPreauth(bob, alice).key, marks), + alice, + keylet::depositPreauth( + hash_options{0, KEYLET_DEPOSIT_PREAUTH}, bob, alice) + .key, + marks), fee(XRP(1)), ter(tecNO_PERMISSION)); env.close(); } // tecNO_PERMISSION: issuer != _account { - env(remarks::setRemarks(alice, keylet::account(bob).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, bob).key, + marks), fee(XRP(1)), ter(tecNO_PERMISSION)); env.close(); @@ -329,7 +376,9 @@ struct SetRemarks_test : public beast::unit_test::suite {"CAFF", "DEAD", tfImmutable}, }; env(remarks::setRemarks( - alice, keylet::account(alice).key, immutableMarks), + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + immutableMarks), fee(XRP(1)), ter(tesSUCCESS)); env.close(); @@ -339,7 +388,9 @@ struct SetRemarks_test : public beast::unit_test::suite {"CAFF", "DEADBEEF", 0}, }; env(remarks::setRemarks( - alice, keylet::account(alice).key, badMarks), + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + badMarks), fee(XRP(1)), ter(tecIMMUTABLE)); env.close(); @@ -357,11 +408,17 @@ struct SetRemarks_test : public beast::unit_test::suite _marks.push_back({ss.str(), "DEADBEEF", 0}); hexValue++; } - env(remarks::setRemarks(alice, keylet::account(alice).key, _marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + _marks), fee(XRP(1)), ter(tesSUCCESS)); env.close(); - env(remarks::setRemarks(alice, keylet::account(alice).key, marks), + env(remarks::setRemarks( + alice, + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key, + marks), fee(XRP(1)), ter(tecTOO_MANY_REMARKS)); env.close(); @@ -394,7 +451,8 @@ struct SetRemarks_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - auto const id = keylet::account(alice).key; + auto const id = + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key; // Set Remarks { @@ -444,14 +502,20 @@ struct SetRemarks_test : public beast::unit_test::suite // ltACCOUNT_ROOT { - auto const id = keylet::account(alice).key; + auto const id = + keylet::account(hash_options{0, KEYLET_ACCOUNT}, alice).key; env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); validateRemarks(*env.current(), id, marks); } // ltOFFER { - auto const id = keylet::offer(alice, env.seq(alice)).key; + auto const id = + keylet::offer( + hash_options{(env.current()->seq()), KEYLET_OFFER}, + alice, + env.seq(alice)) + .key; env(offer(alice, XRP(10), USD(10)), fee(XRP(1))); env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); @@ -460,7 +524,12 @@ struct SetRemarks_test : public beast::unit_test::suite // ltESCROW { using namespace std::literals::chrono_literals; - auto const id = keylet::escrow(alice, env.seq(alice)).key; + auto const id = + keylet::escrow( + hash_options{(env.current()->seq()), KEYLET_ESCROW}, + alice, + env.seq(alice)) + .key; env(escrow::create(alice, bob, XRP(10)), escrow::finish_time(env.now() + 1s), fee(XRP(1))); @@ -470,7 +539,12 @@ struct SetRemarks_test : public beast::unit_test::suite } // ltTICKET { - auto const id = keylet::ticket(alice, env.seq(alice) + 1).key; + auto const id = + keylet::ticket( + hash_options{(env.current()->seq()), KEYLET_TICKET}, + alice, + env.seq(alice) + 1) + .key; env(ticket::create(alice, 10), fee(XRP(1))); env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); @@ -479,7 +553,13 @@ struct SetRemarks_test : public beast::unit_test::suite // ltPAYCHAN { using namespace std::literals::chrono_literals; - auto const id = keylet::payChan(alice, bob, env.seq(alice)).key; + auto const id = + keylet::payChan( + hash_options{(env.current()->seq()), KEYLET_PAYCHAN}, + alice, + bob, + env.seq(alice)) + .key; auto const pk = alice.pk(); auto const settleDelay = 100s; env(paychan::create(alice, bob, XRP(10), settleDelay, pk), @@ -490,7 +570,12 @@ struct SetRemarks_test : public beast::unit_test::suite } // ltCHECK { - auto const id = keylet::check(alice, env.seq(alice)).key; + auto const id = + keylet::check( + hash_options{(env.current()->seq()), KEYLET_CHECK}, + alice, + env.seq(alice)) + .key; env(check::create(alice, bob, XRP(10)), fee(XRP(1))); env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); @@ -499,7 +584,13 @@ struct SetRemarks_test : public beast::unit_test::suite // ltDEPOSIT_PREAUTH { env(fset(bob, asfDepositAuth)); - auto const id = keylet::depositPreauth(alice, bob).key; + auto const id = + keylet::depositPreauth( + hash_options{ + (env.current()->seq()), KEYLET_DEPOSIT_PREAUTH}, + alice, + bob) + .key; env(deposit::auth(alice, bob), fee(XRP(1))); env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); @@ -509,7 +600,11 @@ struct SetRemarks_test : public beast::unit_test::suite { std::string const uri(256, 'A'); auto const id = - keylet::uritoken(alice, Blob(uri.begin(), uri.end())).key; + keylet::uritoken( + hash_options{(env.current()->seq()), KEYLET_URI_TOKEN}, + alice, + Blob(uri.begin(), uri.end())) + .key; env(uritoken::mint(alice, uri), fee(XRP(1))); env(remarks::setRemarks(alice, id, marks), fee(XRP(1))); env.close(); @@ -521,7 +616,12 @@ struct SetRemarks_test : public beast::unit_test::suite env.fund(XRP(1000), alice2); env.close(); env.trust(USD(10000), alice2); - auto const id = keylet::line(alice2, USD).key; + auto const id = + keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + alice2, + USD) + .key; env(pay(gw, alice2, USD(1000))); env(remarks::setRemarks(gw, id, marks), fee(XRP(1))); env.close(); @@ -533,7 +633,12 @@ struct SetRemarks_test : public beast::unit_test::suite env.fund(XRP(1000), carol0); env.close(); env.trust(USD(10000), carol0); - auto const id = keylet::line(carol0, USD).key; + auto const id = + keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + carol0, + USD) + .key; env(pay(gw, carol0, USD(1000))); env(remarks::setRemarks(gw, id, marks), fee(XRP(1))); env.close(); @@ -545,7 +650,12 @@ struct SetRemarks_test : public beast::unit_test::suite env.fund(XRP(1000), dan1); env.close(); env.trust(USD(1000), dan1); - auto const id = keylet::line(dan1, USD).key; + auto const id = + keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + dan1, + USD) + .key; env(remarks::setRemarks(gw, id, marks), fee(XRP(1))); env.close(); validateRemarks(*env.current(), id, marks); @@ -556,7 +666,12 @@ struct SetRemarks_test : public beast::unit_test::suite env.fund(XRP(1000), bob0); env.close(); env.trust(USD(1000), bob0); - auto const id = keylet::line(bob0, USD).key; + auto const id = + keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + bob0, + USD) + .key; env(remarks::setRemarks(gw, id, marks), fee(XRP(1))); env.close(); validateRemarks(*env.current(), id, marks); diff --git a/src/test/app/Touch_test.cpp b/src/test/app/Touch_test.cpp index 2d59a8cd4..5058ba905 100644 --- a/src/test/app/Touch_test.cpp +++ b/src/test/app/Touch_test.cpp @@ -110,7 +110,8 @@ private: static uint256 getCheckIndex(AccountID const& alice, std::uint32_t uSequence) { - return keylet::check(alice, uSequence).key; + return keylet::check(hash_options{0, KEYLET_CHECK}, alice, uSequence) + .key; } void @@ -674,7 +675,8 @@ private: jtx::Account const& dst, std::uint32_t seqProxyValue) { - auto const k = keylet::payChan(alice, dst, seqProxyValue); + auto const k = keylet::payChan( + hash_options{0, KEYLET_PAYCHAN}, alice, dst, seqProxyValue); return k.key; } diff --git a/src/test/app/URIToken_test.cpp b/src/test/app/URIToken_test.cpp index 00f4312bf..826551903 100644 --- a/src/test/app/URIToken_test.cpp +++ b/src/test/app/URIToken_test.cpp @@ -39,7 +39,9 @@ struct URIToken_test : public beast::unit_test::suite uint256 const& tid) { auto const uritSle = view.read({ltURI_TOKEN, tid}); - ripple::Dir const ownerDir(view, keylet::ownerDir(acct.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acct.id())); return std::find(ownerDir.begin(), ownerDir.end(), uritSle) != ownerDir.end(); } @@ -47,7 +49,9 @@ struct URIToken_test : public beast::unit_test::suite static std::size_t ownerDirCount(ReadView const& view, jtx::Account const& acct) { - ripple::Dir const ownerDir(view, keylet::ownerDir(acct.id())); + ripple::Dir const ownerDir( + view, + keylet::ownerDir(hash_options{0, KEYLET_OWNER_DIR}, acct.id())); return std::distance(ownerDir.begin(), ownerDir.end()); }; @@ -57,7 +61,10 @@ struct URIToken_test : public beast::unit_test::suite jtx::Account const& account, std::string const& uri) { - auto const k = keylet::uritoken(account, Blob(uri.begin(), uri.end())); + auto const k = keylet::uritoken( + hash_options{0, KEYLET_URI_TOKEN}, + account, + Blob(uri.begin(), uri.end())); return {k.key, view.read(k)}; } @@ -69,7 +76,8 @@ struct URIToken_test : public beast::unit_test::suite jtx::IOU const& iou) { auto const aHigh = account.id() > gw.id(); - auto const sle = env.le(keylet::line(account, gw, iou.currency)); + auto const sle = env.le(keylet::line( + hash_options{0, KEYLET_TRUSTLINE}, account, gw, iou.currency)); if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit)) return (*sle)[aHigh ? sfLowLimit : sfHighLimit]; return STAmount(iou, 0); @@ -111,7 +119,8 @@ struct URIToken_test : public beast::unit_test::suite jtx::Account const& gw, jtx::IOU const& iou) { - auto const sle = env.le(keylet::line(account, gw, iou.currency)); + auto const sle = env.le(keylet::line( + hash_options{0, KEYLET_TRUSTLINE}, account, gw, iou.currency)); if (sle && sle->isFieldPresent(sfBalance)) return (*sle)[sfBalance]; return STAmount(iou, 0); @@ -1496,7 +1505,9 @@ struct URIToken_test : public beast::unit_test::suite env.close(); this->BEAST_EXPECT( isTesSuccess(expectedTer) == - !env.closed()->exists(keylet::account(toRm.id()))); + !env.closed()->exists(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + toRm.id()))); }; auto const alice = Account("alice"); diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index ff9b57f3c..90a46d9e7 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -2013,20 +2013,46 @@ private: std::string const signature = "This is not really a signature"; std::uint32_t const version = 1; - auto const global = sha512Half(manifest, blob, signature, version); + auto const global = sha512Half( + hash_options{VALIDATOR_LIST_HASH}, + manifest, + blob, + signature, + version); BEAST_EXPECT(!!global); std::vector blobVector(1); blobVector[0].blob = blob; blobVector[0].signature = signature; - BEAST_EXPECT(global == sha512Half(manifest, blobVector, version)); - BEAST_EXPECT(global != sha512Half(signature, blobVector, version)); + BEAST_EXPECT( + global == + sha512Half( + hash_options{VALIDATOR_LIST_HASH}, + manifest, + blobVector, + version)); + BEAST_EXPECT( + global != + sha512Half( + hash_options{VALIDATOR_LIST_HASH}, + signature, + blobVector, + version)); { std::map blobMap{ {99, blobVector[0]}}; - BEAST_EXPECT(global == sha512Half(manifest, blobMap, version)); - BEAST_EXPECT(global != sha512Half(blob, blobMap, version)); + BEAST_EXPECT( + global == + sha512Half( + hash_options{VALIDATOR_LIST_HASH}, + manifest, + blobMap, + version)); + BEAST_EXPECT( + global != + sha512Half( + hash_options{VALIDATOR_LIST_HASH}, blob, blobMap, version)); } { @@ -2035,9 +2061,11 @@ private: msg1.set_blob(blob); msg1.set_signature(signature); msg1.set_version(version); - BEAST_EXPECT(global == sha512Half(msg1)); + BEAST_EXPECT( + global == sha512Half(hash_options{VALIDATOR_LIST_HASH}, msg1)); msg1.set_signature(blob); - BEAST_EXPECT(global != sha512Half(msg1)); + BEAST_EXPECT( + global != sha512Half(hash_options{VALIDATOR_LIST_HASH}, msg1)); } { @@ -2047,9 +2075,11 @@ private: auto& bi = *msg2.add_blobs(); bi.set_blob(blob); bi.set_signature(signature); - BEAST_EXPECT(global == sha512Half(msg2)); + BEAST_EXPECT( + global == sha512Half(hash_options{VALIDATOR_LIST_HASH}, msg2)); bi.set_manifest(manifest); - BEAST_EXPECT(global != sha512Half(msg2)); + BEAST_EXPECT( + global != sha512Half(hash_options{VALIDATOR_LIST_HASH}, msg2)); } } @@ -2164,6 +2194,7 @@ private: BEAST_EXPECT( messageWithHash.hash == sha512Half( + hash_options{VALIDATOR_LIST_HASH}, expectedManifest, expectedBlob.blob, expectedBlob.signature, @@ -2211,7 +2242,11 @@ private: } BEAST_EXPECT( messageWithHash.hash == - sha512Half(manifest, hashingBlobs, version)); + sha512Half( + hash_options{VALIDATOR_LIST_HASH}, + manifest, + hashingBlobs, + version)); } ++msgIter; } @@ -2306,7 +2341,11 @@ private: BEAST_EXPECT( messageWithHash.hash == sha512Half( - *expected.manifest, expected.blob, expected.signature, 1)); + hash_options{VALIDATOR_LIST_HASH}, + *expected.manifest, + expected.blob, + expected.signature, + 1)); } // Version 2 diff --git a/src/test/app/XahauGenesis_test.cpp b/src/test/app/XahauGenesis_test.cpp index 8353a3ce9..b4667fb1e 100644 --- a/src/test/app/XahauGenesis_test.cpp +++ b/src/test/app/XahauGenesis_test.cpp @@ -114,15 +114,21 @@ namespace test { struct XahauGenesis_test : public beast::unit_test::suite { - uint256 const acceptHookHash = ripple::sha512Half_s(ripple::Slice( - jtx::genesis::AcceptHook.data(), - jtx::genesis::AcceptHook.size())); - uint256 const governHookHash = ripple::sha512Half_s(ripple::Slice( - XahauGenesis::GovernanceHook.data(), - XahauGenesis::GovernanceHook.size())); - uint256 const rewardHookHash = ripple::sha512Half_s(ripple::Slice( - XahauGenesis::RewardHook.data(), - XahauGenesis::RewardHook.size())); + uint256 const acceptHookHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice( + jtx::genesis::AcceptHook.data(), + jtx::genesis::AcceptHook.size())); + uint256 const governHookHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice( + XahauGenesis::GovernanceHook.data(), + XahauGenesis::GovernanceHook.size())); + uint256 const rewardHookHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice( + XahauGenesis::RewardHook.data(), + XahauGenesis::RewardHook.size())); AccountID const genesisAccID = calcAccountID( generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")) @@ -144,7 +150,8 @@ struct XahauGenesis_test : public beast::unit_test::suite using namespace jtx; auto isEnabled = [&](void) -> bool { - auto const obj = env.le(keylet::amendments()); + auto const obj = env.le(keylet::amendments( + hash_options{(env.current()->seq()), KEYLET_AMENDMENTS})); if (!obj) return false; STVector256 amendments = obj->getFieldV256(sfAmendments); @@ -203,7 +210,9 @@ struct XahauGenesis_test : public beast::unit_test::suite 100000000000000000ULL == env.app().getLedgerMaster().getClosedLedger()->info().drops); - auto genesisAccRoot = env.le(keylet::account(genesisAccID)); + auto genesisAccRoot = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + genesisAccID)); BEAST_REQUIRE(!!genesisAccRoot); BEAST_EXPECT( genesisAccRoot->getFieldAmount(sfBalance) == @@ -235,14 +244,17 @@ struct XahauGenesis_test : public beast::unit_test::suite total); // is the hook array present - auto genesisHooksLE = env.le(keylet::hook(genesisAccID)); + auto genesisHooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, genesisAccID)); BEAST_REQUIRE(!!genesisHooksLE); auto genesisHookArray = genesisHooksLE->getFieldArray(sfHooks); BEAST_EXPECT(genesisHookArray.size() == 2); // make sure the account root exists and has the correct balance and // ownercount - auto genesisAccRoot = env.le(keylet::account(genesisAccID)); + auto genesisAccRoot = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + genesisAccID)); BEAST_REQUIRE(!!genesisAccRoot); BEAST_EXPECT( genesisAccRoot->getFieldAmount(sfBalance) == @@ -252,8 +264,10 @@ struct XahauGenesis_test : public beast::unit_test::suite // ensure the definitions are correctly set { auto const govHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(GovernanceHook.data(), GovernanceHook.size())); - auto const govKL = keylet::hookDefinition(govHash); + auto const govKL = keylet::hookDefinition( + hash_options{0, KEYLET_HOOK_DEFINITION}, govHash); auto govSLE = env.le(govKL); BEAST_EXPECT(!!govSLE); @@ -263,6 +277,7 @@ struct XahauGenesis_test : public beast::unit_test::suite BEAST_EXPECT( govHash == ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(govVL.data(), govVL.size()))); BEAST_EXPECT( govSLE->getFieldU64(sfReferenceCount) == 1 + testFlag @@ -287,8 +302,10 @@ struct XahauGenesis_test : public beast::unit_test::suite genesisHookArray[0].getFieldH256(sfHookHash) == govHash); auto const rwdHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(RewardHook.data(), RewardHook.size())); - auto const rwdKL = keylet::hookDefinition(rwdHash); + auto const rwdKL = keylet::hookDefinition( + hash_options{0, KEYLET_HOOK_DEFINITION}, rwdHash); auto rwdSLE = env.le(rwdKL); BEAST_EXPECT(!!rwdSLE); @@ -298,6 +315,7 @@ struct XahauGenesis_test : public beast::unit_test::suite BEAST_EXPECT( rwdHash == ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, ripple::Slice(rwdVL.data(), rwdVL.size()))); BEAST_EXPECT(rwdSLE->getFieldU64(sfReferenceCount) == 1); BEAST_EXPECT( @@ -331,7 +349,9 @@ struct XahauGenesis_test : public beast::unit_test::suite if (first == 'r') { AccountID id = *parseBase58(rn); - auto acc = env.le(keylet::account(id)); + auto acc = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + id)); BEAST_EXPECT(!!acc); auto bal = acc->getFieldAmount(sfBalance); BEAST_EXPECT(bal == STAmount(x)); @@ -344,7 +364,8 @@ struct XahauGenesis_test : public beast::unit_test::suite BEAST_EXPECT(!!pk); AccountID id = calcAccountID(*pk); - auto acc = env.le(keylet::account(id)); + auto acc = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, id)); BEAST_EXPECT(!!acc); auto bal = acc->getFieldAmount(sfBalance); BEAST_EXPECT(bal == STAmount(x)); @@ -367,7 +388,9 @@ struct XahauGenesis_test : public beast::unit_test::suite if (first == 'r') { AccountID id = *parseBase58(rn); - auto acc = env.le(keylet::account(id)); + auto acc = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, + id)); BEAST_EXPECT(!!acc); auto bal = acc->getFieldAmount(sfBalance); BEAST_EXPECT(bal == STAmount(x)); @@ -384,7 +407,8 @@ struct XahauGenesis_test : public beast::unit_test::suite BEAST_EXPECT(!!pk); AccountID id = calcAccountID(*pk); - auto acc = env.le(keylet::account(id)); + auto acc = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, id)); BEAST_EXPECT(!!acc); auto bal = acc->getFieldAmount(sfBalance); BEAST_EXPECT(bal == STAmount(x)); @@ -449,14 +473,17 @@ struct XahauGenesis_test : public beast::unit_test::suite } // check fees object correctly recordsed activation seq - auto fees = env.le(keylet::fees()); + auto fees = env.le( + keylet::fees(hash_options{(env.current()->seq()), KEYLET_FEES})); BEAST_REQUIRE(!!fees); BEAST_EXPECT( fees->isFieldPresent(sfXahauActivationLgrSeq) && fees->getFieldU32(sfXahauActivationLgrSeq) == startLgr); // ensure no signerlist - BEAST_EXPECT(!env.le(keylet::signers(genesisAccID))); + BEAST_EXPECT(!env.le(keylet::signers( + hash_options{(env.current()->seq()), KEYLET_SIGNERS}, + genesisAccID))); // ensure correctly blackholed BEAST_EXPECT( @@ -867,7 +894,10 @@ struct XahauGenesis_test : public beast::unit_test::suite // check actioning prior to vote { auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (DEBUG_XGTEST) { std::cout @@ -918,6 +948,7 @@ struct XahauGenesis_test : public beast::unit_test::suite shouldFail ? ter(tecHOOK_REJECTED) : ter(tesSUCCESS)); env.close(); auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), makeStateKey('V', topic1, topic2, 1, acc.id()), beast::zero)); @@ -944,7 +975,10 @@ struct XahauGenesis_test : public beast::unit_test::suite // if the vote count isn't high enough it will be hte old value // if it's high enough it will be the new value auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (!actioned && isOldDataZero) { @@ -1086,8 +1120,8 @@ struct XahauGenesis_test : public beast::unit_test::suite env(tx, M(__LINE__), fee(XRP(100))); env.close(); - BEAST_EXPECT( - !!env.le(ripple::keylet::hookDefinition(acceptHookHash))); + BEAST_EXPECT(!!env.le(ripple::keylet::hookDefinition( + hash_options{0, KEYLET_HOOK_DEFINITION}, acceptHookHash))); uint8_t const* data = acceptHookHash.data(); std::vector accept_data(data, data + 32); @@ -1109,7 +1143,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // check if the hook not was installed because we have not given it // 100% votes yet { - auto const hooks = env.le(keylet::hook(env.master.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() == 2); } @@ -1122,7 +1158,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it was installed { - auto const hooks = env.le(keylet::hook(env.master.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -1140,7 +1178,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it's still installed { - auto const hooks = env.le(keylet::hook(env.master.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -1160,7 +1200,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it's still installed { - auto const hooks = env.le(keylet::hook(env.master.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && !hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -1220,7 +1262,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // nothing ...} { - auto const hooksLE = env.le(keylet::hook(env.master.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 3); @@ -1268,7 +1312,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // check we're back the way we were { - auto const hooksLE = env.le(keylet::hook(env.master.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 2); @@ -1290,7 +1336,9 @@ struct XahauGenesis_test : public beast::unit_test::suite env.close(); env.close(); { - auto const hooksLE = env.le(keylet::hook(env.master.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + env.master.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 2); @@ -1320,6 +1368,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 4 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1344,6 +1393,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 3 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1362,6 +1412,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 2 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1381,6 +1432,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 2 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1399,6 +1451,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 2 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1422,6 +1475,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check the membercount is now 2 { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1462,6 +1516,7 @@ struct XahauGenesis_test : public beast::unit_test::suite if (!shouldFail) { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -1512,7 +1567,10 @@ struct XahauGenesis_test : public beast::unit_test::suite key[i] = m6.id().data()[i - 12]; auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); BEAST_EXPECT( !!entry && entry->getFieldVL(sfHookStateData) == @@ -1770,7 +1828,10 @@ struct XahauGenesis_test : public beast::unit_test::suite { key[31] = seat; auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (!acc) { @@ -1808,7 +1869,10 @@ struct XahauGenesis_test : public beast::unit_test::suite key[i] = acc->id().data()[i - 12]; auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (DEBUG_XGTEST) { @@ -2224,14 +2288,17 @@ struct XahauGenesis_test : public beast::unit_test::suite auto const m20 = Account("m20"); auto const m21 = Account("m21"); - auto const governHookHash = ripple::sha512Half_s(ripple::Slice( - XahauGenesis::GovernanceHook.data(), - XahauGenesis::GovernanceHook.size())); + auto const governHookHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice( + XahauGenesis::GovernanceHook.data(), + XahauGenesis::GovernanceHook.size())); // check tables correctly configured auto checkL2Table = [&](AccountID const& tableID, std::vector members) -> void { - auto const hookLE = env.le(keylet::hook(tableID)); + auto const hookLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, tableID)); BEAST_EXPECT(!!hookLE); uint256 const ns = beast::zero; uint8_t mc = 0; @@ -2251,8 +2318,11 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, mc}; - auto const forward = env.le( - keylet::hookState(tableID, uint256::fromVoid(key), ns)); + auto const forward = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + tableID, + uint256::fromVoid(key), + ns)); BEAST_EXPECT( !!forward && forward->getFieldVL(sfHookStateData) == mVec); @@ -2262,8 +2332,11 @@ struct XahauGenesis_test : public beast::unit_test::suite for (int i = 12; i < 32; ++i) key[i] = mVec[i - 12]; - auto const reverse = env.le( - keylet::hookState(tableID, uint256::fromVoid(key), ns)); + auto const reverse = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + tableID, + uint256::fromVoid(key), + ns)); BEAST_EXPECT( !!reverse && reverse->getFieldVL(sfHookStateData) == @@ -2277,8 +2350,11 @@ struct XahauGenesis_test : public beast::unit_test::suite uint8_t key[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'M', 'C'}; - auto const mcLE = env.le( - keylet::hookState(tableID, uint256::fromVoid(key), ns)); + auto const mcLE = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + tableID, + uint256::fromVoid(key), + ns)); BEAST_EXPECT( !!mcLE && mcLE->getFieldVL(sfHookStateData) == @@ -2291,20 +2367,27 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'R', 'R'}; { - auto const le = env.le( - keylet::hookState(tableID, uint256::fromVoid(key), ns)); + auto const le = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + tableID, + uint256::fromVoid(key), + ns)); BEAST_EXPECT(!le); } key[31] = 'D'; { - auto const le = env.le( - keylet::hookState(tableID, uint256::fromVoid(key), ns)); + auto const le = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + tableID, + uint256::fromVoid(key), + ns)); BEAST_EXPECT(!le); } } // check account has correct ownercount and is blackholed - auto const root = env.le(keylet::account(tableID)); + auto const root = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, tableID)); BEAST_EXPECT(!!root); if (root) { @@ -2377,7 +2460,10 @@ struct XahauGenesis_test : public beast::unit_test::suite // check actioning prior to vote { auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (DEBUG_XGTEST) { std::cout @@ -2428,6 +2514,7 @@ struct XahauGenesis_test : public beast::unit_test::suite shouldFail ? ter(tecHOOK_REJECTED) : ter(tesSUCCESS)); env.close(); auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), makeStateKey('V', topic1, topic2, 1, acc.id()), beast::zero)); @@ -2446,7 +2533,10 @@ struct XahauGenesis_test : public beast::unit_test::suite // if the vote count isn't high enough it will be hte old value // if it's high enough it will be the new value auto entry = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(key), beast::zero)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(key), + beast::zero)); if (!actioned && isOldDataZero) { @@ -2556,6 +2646,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // check actioning prior to vote { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, layer == 1 ? env.master.id() : table.id(), uint256::fromVoid(key), beast::zero)); @@ -2611,6 +2702,7 @@ struct XahauGenesis_test : public beast::unit_test::suite shouldFail ? ter(tecHOOK_REJECTED) : ter(tesSUCCESS)); env.close(); auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, table.id(), makeStateKey('V', topic1, topic2, layer, acc.id()), beast::zero)); @@ -2629,6 +2721,7 @@ struct XahauGenesis_test : public beast::unit_test::suite // if the vote count isn't high enough it will be hte old value // if it's high enough it will be the new value auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, layer == 1 ? env.master.id() : table.id(), uint256::fromVoid(key), beast::zero)); @@ -2713,6 +2806,7 @@ struct XahauGenesis_test : public beast::unit_test::suite if (!shouldFail) { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -2768,6 +2862,7 @@ struct XahauGenesis_test : public beast::unit_test::suite if (!shouldFail) { auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, layer == 1 ? env.master.id() : table.id(), uint256::fromVoid(member_count_key), beast::zero)); @@ -2864,7 +2959,10 @@ struct XahauGenesis_test : public beast::unit_test::suite 0x00U, 0x80U, 0xC6U, 0xA4U, 0x7EU, 0x8DU, 0x03U, 0x54U}; uint256 ns = beast::zero; auto const counterLE = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(counter_key), ns)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(counter_key), + ns)); if (DEBUG_XGTEST) { @@ -2979,7 +3077,10 @@ struct XahauGenesis_test : public beast::unit_test::suite 0x00U, 0x80U, 0xC6U, 0xA4U, 0x7EU, 0x8DU, 0x03U, 0x55U}; uint256 ns = beast::zero; auto const counterLE = env.le(keylet::hookState( - env.master.id(), uint256::fromVoid(counter_key), ns)); + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, + env.master.id(), + uint256::fromVoid(counter_key), + ns)); if (DEBUG_XGTEST) { @@ -3099,6 +3200,7 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x04U}; auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(key.data()), beast::zero)); @@ -3112,6 +3214,7 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'M', 'C'}; auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(key.data()), beast::zero)); @@ -3148,6 +3251,7 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x04U}; auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(key.data()), beast::zero)); @@ -3159,6 +3263,7 @@ struct XahauGenesis_test : public beast::unit_test::suite 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'M', 'C'}; auto entry = env.le(keylet::hookState( + hash_options{(env.current()->seq()), KEYLET_HOOK_STATE}, env.master.id(), uint256::fromVoid(key.data()), beast::zero)); @@ -3254,8 +3359,8 @@ struct XahauGenesis_test : public beast::unit_test::suite env(tx, M(__LINE__), fee(XRP(100))); env.close(); - BEAST_EXPECT( - !!env.le(ripple::keylet::hookDefinition(acceptHookHash))); + BEAST_EXPECT(!!env.le(ripple::keylet::hookDefinition( + hash_options{0, KEYLET_HOOK_DEFINITION}, acceptHookHash))); uint8_t const* data = acceptHookHash.data(); std::vector accept_data(data, data + 32); @@ -3281,7 +3386,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // check if the hook not was installed because we have not given it // 100% votes yet { - auto const hooks = env.le(keylet::hook(t2.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() == 1); } @@ -3295,7 +3402,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it was installed { - auto const hooks = env.le(keylet::hook(t2.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -3313,7 +3422,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it's still installed { - auto const hooks = env.le(keylet::hook(t2.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -3333,7 +3444,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // now check it's still installed { - auto const hooks = env.le(keylet::hook(t2.id())); + auto const hooks = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooks && hooks->getFieldArray(sfHooks).size() > 7 && !hooks->getFieldArray(sfHooks)[7].isFieldPresent( @@ -3421,7 +3534,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // ...} { - auto const hooksLE = env.le(keylet::hook(t2.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 3); @@ -3479,7 +3594,9 @@ struct XahauGenesis_test : public beast::unit_test::suite // check we're back the way we were { - auto const hooksLE = env.le(keylet::hook(t2.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 2); @@ -3502,7 +3619,9 @@ struct XahauGenesis_test : public beast::unit_test::suite env.close(); env.close(); { - auto const hooksLE = env.le(keylet::hook(t2.id())); + auto const hooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + t2.id())); BEAST_EXPECT( !!hooksLE && hooksLE->getFieldArray(sfHooks).size() >= 2); @@ -3576,13 +3695,17 @@ struct XahauGenesis_test : public beast::unit_test::suite // probably multiple emitted txns settling // check it was actioned correctly - auto genesisHooksLE = env.le(keylet::hook(genesisAccID)); + auto genesisHooksLE = env.le(keylet::hook( + hash_options{(env.current()->seq()), KEYLET_HOOK}, + genesisAccID)); BEAST_REQUIRE(!!genesisHooksLE); auto genesisHookArray = genesisHooksLE->getFieldArray(sfHooks); BEAST_EXPECT(genesisHookArray.size() >= 3); - auto const acceptHash = ripple::sha512Half_s(ripple::Slice( - jtx::genesis::AcceptHook.data(), - jtx::genesis::AcceptHook.size())); + auto const acceptHash = ripple::sha512Half_s( + hash_options{0, LEDGER_INDEX_UNNEEDED}, + ripple::Slice( + jtx::genesis::AcceptHook.data(), + jtx::genesis::AcceptHook.size())); BEAST_EXPECT( genesisHookArray.size() >= 3 && genesisHookArray[2].isFieldPresent(sfHookHash) && @@ -3611,7 +3734,8 @@ struct XahauGenesis_test : public beast::unit_test::suite static std::pair> accountKeyAndSle(ReadView const& view, jtx::Account const& account) { - auto const k = keylet::account(account); + auto const k = keylet::account( + hash_options{(view.seq()), KEYLET_ACCOUNT}, account); return {k.key, view.read(k)}; } @@ -3678,7 +3802,8 @@ struct XahauGenesis_test : public beast::unit_test::suite bool hasUNLReport(jtx::Env const& env) { - auto const slep = env.le(keylet::UNLReport()); + auto const slep = env.le(keylet::UNLReport( + hash_options{(env.current()->seq()), KEYLET_UNL_REPORT})); return slep != nullptr; } @@ -3717,7 +3842,8 @@ struct XahauGenesis_test : public beast::unit_test::suite STAmount const& accumulator, NetClock::time_point const& timePoint) { - auto const sle = env.le(keylet::account(acct)); + auto const sle = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, acct)); auto const time = timePoint.time_since_epoch().count(); if (!sle->isFieldPresent(sfRewardLgrFirst) || @@ -3747,7 +3873,8 @@ struct XahauGenesis_test : public beast::unit_test::suite bool expectNoAccountFields(jtx::Env const& env, jtx::Account const& acct) { - auto const sle = env.le(keylet::account(acct)); + auto const sle = env.le(keylet::account( + hash_options{(env.current()->seq()), KEYLET_ACCOUNT}, acct)); if (sle->isFieldPresent(sfRewardLgrFirst)) { return false; diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 7ec04cea1..866ebb5c1 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -1884,7 +1884,8 @@ VerifyPubKeyAndSeq( std::shared_ptr const& l, hash_map nUnlLedgerSeq) { - auto sle = l->read(keylet::negativeUNL()); + auto sle = l->read( + keylet::negativeUNL(hash_options{l->seq(), KEYLET_NEGATIVE_UNL})); if (!sle) return false; if (!sle->isFieldPresent(sfDisabledValidators)) diff --git a/src/test/consensus/UNLReport_test.cpp b/src/test/consensus/UNLReport_test.cpp index e2a3021bd..7759e7d1b 100644 --- a/src/test/consensus/UNLReport_test.cpp +++ b/src/test/consensus/UNLReport_test.cpp @@ -1211,7 +1211,8 @@ VerifyUNLRPubKeyAndSeq( std::shared_ptr const& l, hash_map nUnlLedgerSeq) { - auto sle = l->read(keylet::negativeUNL()); + auto sle = l->read( + keylet::negativeUNL(hash_options{l->seq(), KEYLET_NEGATIVE_UNL})); if (!sle) return false; if (!sle->isFieldPresent(sfDisabledValidators)) @@ -1259,14 +1260,16 @@ countUNLRTx(std::shared_ptr const& txSet) bool hasUNLReport(jtx::Env const& env) { - auto const slep = env.le(keylet::UNLReport()); + auto const slep = env.le(keylet::UNLReport( + hash_options{env.current()->seq(), KEYLET_UNL_REPORT})); return slep != nullptr; } bool isImportVL(jtx::Env const& env, PublicKey const& pk) { - auto const slep = env.le(keylet::UNLReport()); + auto const slep = env.le(keylet::UNLReport( + hash_options{env.current()->seq(), KEYLET_UNL_REPORT})); auto const& vlKeys = slep->getFieldArray(sfImportVLKeys); for (auto const& k : vlKeys) if (PublicKey(k[sfPublicKey]) == pk) @@ -1277,7 +1280,8 @@ isImportVL(jtx::Env const& env, PublicKey const& pk) bool isActiveValidator(jtx::Env const& env, PublicKey const& pk) { - auto const slep = env.le(keylet::UNLReport()); + auto const slep = env.le(keylet::UNLReport( + hash_options{env.current()->seq(), KEYLET_UNL_REPORT})); auto const& activeVLs = slep->getFieldArray(sfActiveValidators); for (auto const& k : activeVLs) if (PublicKey(k[sfPublicKey]) == pk) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 8a25ed3c7..c969edf2e 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -193,7 +193,10 @@ Env::balance(Account const& account, Issue const& issue) const { if (isXRP(issue.currency)) return balance(account); - auto const sle = le(keylet::line(account.id(), issue)); + auto const sle = le(keylet::line( + hash_options{(current()->seq()), KEYLET_TRUSTLINE}, + account.id(), + issue)); if (!sle) return {STAmount(issue, 0), account.name()}; auto amount = sle->getFieldAmount(sfBalance); @@ -224,7 +227,8 @@ Env::seq(Account const& account) const std::shared_ptr Env::le(Account const& account) const { - return le(keylet::account(account.id())); + return le(keylet::account( + hash_options{(current()->seq()), KEYLET_ACCOUNT}, account.id())); } std::shared_ptr diff --git a/src/test/jtx/impl/balance.cpp b/src/test/jtx/impl/balance.cpp index 42330658e..dbed2b1b6 100644 --- a/src/test/jtx/impl/balance.cpp +++ b/src/test/jtx/impl/balance.cpp @@ -40,7 +40,10 @@ balance::operator()(Env& env) const } else { - auto const sle = env.le(keylet::line(account_.id(), value_.issue())); + auto const sle = env.le(keylet::line( + hash_options{(env.current()->seq()), KEYLET_TRUSTLINE}, + account_.id(), + value_.issue())); if (none_) { env.test.expect(!sle); diff --git a/src/test/jtx/impl/uritoken.cpp b/src/test/jtx/impl/uritoken.cpp index f1a91aec6..7daf9cc63 100644 --- a/src/test/jtx/impl/uritoken.cpp +++ b/src/test/jtx/impl/uritoken.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include @@ -28,7 +29,8 @@ namespace uritoken { uint256 tokenid(jtx::Account const& account, std::string const& uri) { - auto const k = keylet::uritoken(account, Blob(uri.begin(), uri.end())); + auto const k = keylet::uritoken( + hash_options{KEYLET_URI_TOKEN}, account, Blob(uri.begin(), uri.end())); return k.key; } diff --git a/src/test/jtx/impl/utility.cpp b/src/test/jtx/impl/utility.cpp index a2acdd87b..94981e10d 100644 --- a/src/test/jtx/impl/utility.cpp +++ b/src/test/jtx/impl/utility.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,8 @@ fill_seq(Json::Value& jv, ReadView const& view) auto const account = parseBase58(jv[jss::Account].asString()); if (!account) Throw("unexpected invalid Account"); - auto const ar = view.read(keylet::account(*account)); + auto const ar = view.read( + keylet::account(hash_options{view.seq(), KEYLET_ACCOUNT}, *account)); if (!ar) Throw("unexpected missing account root"); jv[jss::Sequence] = ar->getFieldU32(sfSequence); diff --git a/src/test/ledger/Directory_test.cpp b/src/test/ledger/Directory_test.cpp index 8274cecd2..7d9b36188 100644 --- a/src/test/ledger/Directory_test.cpp +++ b/src/test/ledger/Directory_test.cpp @@ -55,7 +55,8 @@ struct Directory_test : public beast::unit_test::suite { for (std::uint64_t i = 0; i < n; ++i) { - auto p = std::make_shared(keylet::page(base, i)); + auto p = std::make_shared( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, i)); p->setFieldV256(sfIndexes, STVector256{}); @@ -103,8 +104,12 @@ struct Directory_test : public beast::unit_test::suite do { - auto p = - view->read(keylet::page(keylet::ownerDir(alice), page)); + auto p = view->read(keylet::page( + hash_options{env.current()->seq(), KEYLET_DIR_PAGE}, + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice), + page)); // Ensure that the entries in the page are sorted auto const& v = p->getFieldV256(sfIndexes); @@ -118,7 +123,8 @@ struct Directory_test : public beast::unit_test::suite for (auto const& e : v) { - auto c = view->read(keylet::child(e)); + auto c = view->read(keylet::child( + hash_options{env.current()->seq(), KEYLET_CHILD}, e)); BEAST_EXPECT(c); BEAST_EXPECT(c->getFieldU32(sfSequence) >= minSeq); BEAST_EXPECT(c->getFieldU32(sfSequence) < maxSeq); @@ -158,16 +164,25 @@ struct Directory_test : public beast::unit_test::suite env.close(); // alice should have an empty directory. - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, alice))); // Give alice a signer list, then there will be stuff in the directory. env(signers(alice, 1, {{bob, 1}})); env.close(); - BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(!dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, alice))); env(signers(alice, jtx::none)); env.close(); - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, alice))); std::vector const currencies = [this, &gw]() { std::vector c; @@ -191,7 +206,11 @@ struct Directory_test : public beast::unit_test::suite env.close(); } - BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(!dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); std::shuffle(cl.begin(), cl.end(), default_prng()); @@ -201,7 +220,11 @@ struct Directory_test : public beast::unit_test::suite env.close(); } - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); } // Now, Alice creates offers to buy currency, creating @@ -209,7 +232,11 @@ struct Directory_test : public beast::unit_test::suite { auto cl = currencies; - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); for (auto c : currencies) { @@ -221,7 +248,11 @@ struct Directory_test : public beast::unit_test::suite env.close(); } - BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(!dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); // Now fill the offers in a random order. Offer // entries will drop, and be replaced by trust @@ -233,7 +264,11 @@ struct Directory_test : public beast::unit_test::suite env(offer(charlie, XRP(50), c(50))); env.close(); } - BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(!dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); // Finally, Alice now sends the funds back to // Charlie. The implicitly created trust lines // should drop away: @@ -245,7 +280,11 @@ struct Directory_test : public beast::unit_test::suite env.close(); } - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); } } @@ -289,9 +328,15 @@ struct Directory_test : public beast::unit_test::suite // should have no entries and be empty: { Sandbox sb(env.closed().get(), tapNONE); - uint256 const bookBase = getBookBase({xrpIssue(), USD.issue()}); + uint256 const bookBase = getBookBase( + hash_options{env.current()->seq(), KEYLET_BOOK_BASE}, + {xrpIssue(), USD.issue()}); - BEAST_EXPECT(dirIsEmpty(sb, keylet::page(bookBase))); + BEAST_EXPECT(dirIsEmpty( + sb, + keylet::page( + hash_options{env.current()->seq(), KEYLET_DIR_PAGE}, + bookBase))); BEAST_EXPECT(!sb.succ(bookBase, getQualityNext(bookBase))); } @@ -302,7 +347,11 @@ struct Directory_test : public beast::unit_test::suite env.trust(USD(0), alice); env(pay(alice, gw, alice["USD"](1000))); env.close(); - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.current()->seq(), KEYLET_OWNER_DIR}, + alice))); } } @@ -334,7 +383,8 @@ struct Directory_test : public beast::unit_test::suite // Insert an item in the middle page: { - auto p = sb.peek(keylet::page(base, 1)); + auto p = sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 1)); BEAST_EXPECT(p); STVector256 v; @@ -346,10 +396,16 @@ struct Directory_test : public beast::unit_test::suite // Now, try to delete the item from the middle // page. This should cause all pages to be deleted: BEAST_EXPECT(sb.dirRemove( - keylet::page(base, 0), 1, keylet::unchecked(item), false)); - BEAST_EXPECT(!sb.peek(keylet::page(base, 2))); - BEAST_EXPECT(!sb.peek(keylet::page(base, 1))); - BEAST_EXPECT(!sb.peek(keylet::page(base, 0))); + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 0), + 1, + keylet::unchecked(item), + false)); + BEAST_EXPECT(!sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 2))); + BEAST_EXPECT(!sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 1))); + BEAST_EXPECT(!sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 0))); } { @@ -359,7 +415,8 @@ struct Directory_test : public beast::unit_test::suite // Now add items on pages 1 and 2: { - auto p1 = sb.peek(keylet::page(base, 1)); + auto p1 = sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 1)); BEAST_EXPECT(p1); STVector256 v1; @@ -367,7 +424,8 @@ struct Directory_test : public beast::unit_test::suite p1->setFieldV256(sfIndexes, v1); sb.update(p1); - auto p2 = sb.peek(keylet::page(base, 2)); + auto p2 = sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 2)); BEAST_EXPECT(p2); STVector256 v2; @@ -380,16 +438,23 @@ struct Directory_test : public beast::unit_test::suite // This should cause pages 2 and 3 to be // deleted: BEAST_EXPECT(sb.dirRemove( - keylet::page(base, 0), 2, keylet::unchecked(item), false)); - BEAST_EXPECT(!sb.peek(keylet::page(base, 3))); - BEAST_EXPECT(!sb.peek(keylet::page(base, 2))); + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 0), + 2, + keylet::unchecked(item), + false)); + BEAST_EXPECT(!sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 3))); + BEAST_EXPECT(!sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 2))); - auto p1 = sb.peek(keylet::page(base, 1)); + auto p1 = sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 1)); BEAST_EXPECT(p1); BEAST_EXPECT(p1->getFieldU64(sfIndexNext) == 0); BEAST_EXPECT(p1->getFieldU64(sfIndexPrevious) == 0); - auto p0 = sb.peek(keylet::page(base, 0)); + auto p0 = sb.peek( + keylet::page(hash_options{0, KEYLET_DIR_PAGE}, base, 0)); BEAST_EXPECT(p0); BEAST_EXPECT(p0->getFieldU64(sfIndexNext) == 1); BEAST_EXPECT(p0->getFieldU64(sfIndexPrevious) == 1); diff --git a/src/test/ledger/Invariants_test.cpp b/src/test/ledger/Invariants_test.cpp index 2e5c2f402..152855e43 100644 --- a/src/test/ledger/Invariants_test.cpp +++ b/src/test/ledger/Invariants_test.cpp @@ -115,7 +115,8 @@ class Invariants_test : public beast::unit_test::suite {{"XRP net change was positive: 500"}}, [](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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; auto amt = sle->getFieldAmount(sfBalance); @@ -136,7 +137,8 @@ class Invariants_test : public beast::unit_test::suite {{"an account root was deleted"}}, [](Account const& A1, Account const&, ApplyContext& ac) { // remove an account from the view - auto const sle = ac.view().peek(keylet::account(A1.id())); + auto const sle = ac.view().peek(keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; ac.view().erase(sle); @@ -162,8 +164,10 @@ class Invariants_test : public beast::unit_test::suite {{"account deletion succeeded but deleted multiple accounts"}}, [](Account const& A1, Account const& A2, ApplyContext& ac) { // remove two accounts from the view - auto const sleA1 = ac.view().peek(keylet::account(A1.id())); - auto const sleA2 = ac.view().peek(keylet::account(A2.id())); + auto const sleA1 = ac.view().peek(keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); + auto const sleA2 = ac.view().peek(keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A2.id())); if (!sleA1 || !sleA2) return false; ac.view().erase(sleA1); @@ -184,7 +188,8 @@ class Invariants_test : public beast::unit_test::suite {"XRP net change of -1000000000 doesn't match fee 0"}}, [](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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; auto sleNew = std::make_shared(ltTICKET, sle->key()); @@ -196,15 +201,18 @@ class Invariants_test : public beast::unit_test::suite {{"invalid ledger entry type added"}}, [](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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; // make a dummy escrow ledger entry, then change the type to an // unsupported value so that the valid type invariant check // will fail. - auto sleNew = std::make_shared( - keylet::escrow(A1, (*sle)[sfSequence] + 2)); + auto sleNew = std::make_shared(keylet::escrow( + hash_options{ac.view().seq(), KEYLET_ESCROW}, + A1, + (*sle)[sfSequence] + 2)); // We don't use ltNICKNAME directly since it's marked deprecated // to prevent accidental use elsewhere. @@ -223,8 +231,11 @@ class Invariants_test : public beast::unit_test::suite {{"an XRP trust line was created"}}, [](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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + xrpIssue().currency)); ac.view().insert(sleNew); return true; }); @@ -240,8 +251,11 @@ class Invariants_test : public beast::unit_test::suite {{"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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + A1["USD"].currency)); sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); @@ -256,8 +270,11 @@ class Invariants_test : public beast::unit_test::suite {{"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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + A1["USD"].currency)); sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); std::uint32_t uFlags = 0u; @@ -271,8 +288,11 @@ class Invariants_test : public beast::unit_test::suite {{"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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + A1["USD"].currency)); sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); std::uint32_t uFlags = 0u; @@ -286,8 +306,11 @@ class Invariants_test : public beast::unit_test::suite {{"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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + A1["USD"].currency)); sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); std::uint32_t uFlags = 0u; @@ -301,8 +324,11 @@ class Invariants_test : public beast::unit_test::suite {{"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)); + auto const sleNew = std::make_shared(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + A2, + A1["USD"].currency)); sleNew->setFieldAmount(sfLowLimit, A1["USD"](0)); sleNew->setFieldAmount(sfHighLimit, A1["USD"](0)); std::uint32_t uFlags = 0u; @@ -360,8 +386,14 @@ class Invariants_test : public beast::unit_test::suite 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"])); + auto const sleA1 = ac.view().peek(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A1, + G1["USD"])); + auto const sleA2 = ac.view().peek(keylet::line( + hash_options{ac.view().seq(), KEYLET_TRUSTLINE}, + A2, + G1["USD"])); sleA1->setFieldAmount(sfBalance, G1["USD"](A1Balance)); sleA2->setFieldAmount(sfBalance, G1["USD"](A2Balance)); @@ -417,7 +449,8 @@ class Invariants_test : public beast::unit_test::suite {{"Cannot return non-native STAmount as XRPAmount"}}, [](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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; STAmount nonNative(A2["USD"](51)); @@ -431,7 +464,8 @@ class Invariants_test : public beast::unit_test::suite {"XRP net change was positive: 99999999000000001"}}, [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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; // Use `drops(1)` to bypass a call to STAmount::canonicalize @@ -447,7 +481,8 @@ class Invariants_test : public beast::unit_test::suite {"XRP net change of -1000000001 doesn't match fee 0"}}, [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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; sle->setFieldAmount(sfBalance, STAmount{1, true}); @@ -497,11 +532,14 @@ class Invariants_test : public beast::unit_test::suite {{"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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; - auto sleNew = std::make_shared( - keylet::offer(A1.id(), (*sle)[sfSequence])); + auto sleNew = std::make_shared(keylet::offer( + hash_options{ac.view().seq(), KEYLET_OFFER}, + A1.id(), + (*sle)[sfSequence])); sleNew->setAccountID(sfAccount, A1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); sleNew->setFieldAmount(sfTakerPays, XRP(-1)); @@ -513,11 +551,14 @@ class Invariants_test : public beast::unit_test::suite {{"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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; - auto sleNew = std::make_shared( - keylet::offer(A1.id(), (*sle)[sfSequence])); + auto sleNew = std::make_shared(keylet::offer( + hash_options{ac.view().seq(), KEYLET_OFFER}, + A1.id(), + (*sle)[sfSequence])); sleNew->setAccountID(sfAccount, A1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); sleNew->setFieldAmount(sfTakerPays, A1["USD"](10)); @@ -530,11 +571,14 @@ class Invariants_test : public beast::unit_test::suite {{"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( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A1.id())); if (!sle) return false; - auto sleNew = std::make_shared( - keylet::offer(A1.id(), (*sle)[sfSequence])); + auto sleNew = std::make_shared(keylet::offer( + hash_options{ac.view().seq(), KEYLET_OFFER}, + A1.id(), + (*sle)[sfSequence])); sleNew->setAccountID(sfAccount, A1.id()); sleNew->setFieldU32(sfSequence, (*sle)[sfSequence]); sleNew->setFieldAmount(sfTakerPays, XRP(10)); @@ -555,11 +599,14 @@ class Invariants_test : public beast::unit_test::suite {"escrow specifies invalid amount"}}, [](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( + hash_options{ac.view().seq(), 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( + hash_options{ac.view().seq(), KEYLET_ESCROW}, + A1, + (*sle)[sfSequence] + 2)); sleNew->setFieldAmount(sfAmount, XRP(-1)); ac.view().insert(sleNew); return true; @@ -570,11 +617,14 @@ class Invariants_test : public beast::unit_test::suite {"escrow specifies invalid amount"}}, [](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( + hash_options{ac.view().seq(), 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( + hash_options{ac.view().seq(), 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)); @@ -595,7 +645,8 @@ class Invariants_test : public beast::unit_test::suite // Insert a new account root created by a non-payment into // the view. const Account A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Keylet const acctKeylet = keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A3); auto const sleNew = std::make_shared(acctKeylet); ac.view().insert(sleNew); return true; @@ -607,13 +658,15 @@ class Invariants_test : public beast::unit_test::suite // Insert two new account roots into the view. { const Account A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Keylet const acctKeylet = keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A3); auto const sleA3 = std::make_shared(acctKeylet); ac.view().insert(sleA3); } { const Account A4{"A4"}; - Keylet const acctKeylet = keylet::account(A4); + Keylet const acctKeylet = keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A4); auto const sleA4 = std::make_shared(acctKeylet); ac.view().insert(sleA4); } @@ -625,7 +678,8 @@ class Invariants_test : public beast::unit_test::suite [](Account const&, Account const&, ApplyContext& ac) { // Insert a new account root with the wrong starting sequence. const Account A3{"A3"}; - Keylet const acctKeylet = keylet::account(A3); + Keylet const acctKeylet = keylet::account( + hash_options{ac.view().seq(), KEYLET_ACCOUNT}, A3); auto const sleNew = std::make_shared(acctKeylet); sleNew->setFieldU32(sfSequence, ac.view().seq() + 1); ac.view().insert(sleNew); diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index e24cb09f9..911e4f1b9 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -57,6 +57,7 @@ static uint256 ledgerHash(LedgerInfo const& info) { return ripple::sha512Half( + hash_options{LEDGER_HEADER_HASH}, HashPrefix::ledgerMaster, std::uint32_t(info.seq), std::uint64_t(info.drops.drops()), @@ -240,7 +241,8 @@ public: auto getLedger = std::make_shared(); getLedger->set_itype(protocol::liTS_CANDIDATE); getLedger->set_ltype(protocol::TMLedgerType::ltACCEPTED); - uint256 const hash(ripple::sha512Half(123456789)); + uint256 const hash( + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, 123456789)); getLedger->set_ledgerhash(hash.begin(), hash.size()); getLedger->set_ledgerseq(123456789); ripple::SHAMapNodeID sha(64, hash); @@ -255,7 +257,8 @@ public: buildLedgerData(uint32_t n, Logs& logs) { auto ledgerData = std::make_shared(); - uint256 const hash(ripple::sha512Half(12356789)); + uint256 const hash( + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, 12356789)); ledgerData->set_ledgerhash(hash.data(), hash.size()); ledgerData->set_ledgerseq(123456789); ledgerData->set_type(protocol::TMLedgerInfoType::liAS_NODE); @@ -269,9 +272,12 @@ public: auto tk = make_TimeKeeper(logs.journal("TimeKeeper")); info.seq = i; info.parentCloseTime = tk->now(); - info.hash = ripple::sha512Half(i); - info.txHash = ripple::sha512Half(i + 1); - info.accountHash = ripple::sha512Half(i + 2); + info.hash = + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, i); + info.txHash = + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, i + 1); + info.accountHash = + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, i + 2); info.parentHash = parentHash; info.drops = XRPAmount(10); info.closeTimeResolution = tk->now().time_since_epoch(); @@ -295,12 +301,14 @@ public: TMGetObjectByHash_ObjectType_otTRANSACTION); getObject->set_query(true); getObject->set_seq(123456789); - uint256 hash(ripple::sha512Half(123456789)); + uint256 hash( + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, 123456789)); getObject->set_ledgerhash(hash.data(), hash.size()); getObject->set_fat(true); for (int i = 0; i < 100; i++) { - uint256 hash(ripple::sha512Half(i)); + uint256 hash( + ripple::sha512Half(hash_options{LEDGER_INDEX_UNNEEDED}, i)); auto object = getObject->add_objects(); object->set_hash(hash.data(), hash.size()); ripple::SHAMapNodeID sha(64, hash); diff --git a/src/test/rpc/AccountSet_test.cpp b/src/test/rpc/AccountSet_test.cpp index 19a5a12dd..17df9b9f6 100644 --- a/src/test/rpc/AccountSet_test.cpp +++ b/src/test/rpc/AccountSet_test.cpp @@ -442,7 +442,8 @@ public: env.app().openLedger().modify( [&gw, transferRate](OpenView& view, beast::Journal j) { // Get the account root we want to hijack. - auto const sle = view.read(keylet::account(gw.id())); + auto const sle = view.read(keylet::account( + hash_options{view.seq(), KEYLET_ACCOUNT}, gw.id())); if (!sle) return false; // This would be really surprising! @@ -524,19 +525,28 @@ public: env.close(); // alice should have an empty directory. - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.closed()->seq(), KEYLET_OWNER_DIR}, alice))); // Give alice a signer list, then there will be stuff in the directory. env(signers(alice, 1, {{bob, 1}})); env.close(); - BEAST_EXPECT(!dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(!dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.closed()->seq(), KEYLET_OWNER_DIR}, alice))); env(fset(alice, asfRequireAuth), ter(tecOWNERS)); // Remove the signer list. After that asfRequireAuth should succeed. env(signers(alice, test::jtx::none)); env.close(); - BEAST_EXPECT(dirIsEmpty(*env.closed(), keylet::ownerDir(alice))); + BEAST_EXPECT(dirIsEmpty( + *env.closed(), + keylet::ownerDir( + hash_options{env.closed()->seq(), KEYLET_OWNER_DIR}, alice))); env(fset(alice, asfRequireAuth)); } diff --git a/src/test/rpc/AccountTx_test.cpp b/src/test/rpc/AccountTx_test.cpp index 85dd2978d..d4c07a06d 100644 --- a/src/test/rpc/AccountTx_test.cpp +++ b/src/test/rpc/AccountTx_test.cpp @@ -358,7 +358,12 @@ class AccountTx_test : public beast::unit_test::suite env.close(); std::string const payChanIndex{ - strHex(keylet::payChan(alice, gw, payChanSeq).key)}; + strHex(keylet::payChan( + hash_options{env.current()->seq(), KEYLET_PAYCHAN}, + alice, + gw, + payChanSeq) + .key)}; { Json::Value payChanFund; @@ -385,10 +390,20 @@ class AccountTx_test : public beast::unit_test::suite // Check { - auto const aliceCheckId = keylet::check(alice, env.seq(alice)).key; + auto const aliceCheckId = + keylet::check( + hash_options{env.current()->seq(), KEYLET_CHECK}, + alice, + env.seq(alice)) + .key; env(check::create(alice, gw, XRP(300)), sig(alie)); - auto const gwCheckId = keylet::check(gw, env.seq(gw)).key; + auto const gwCheckId = + keylet::check( + hash_options{env.current()->seq(), KEYLET_CHECK}, + gw, + env.seq(gw)) + .key; env(check::create(gw, alice, XRP(200))); env.close(); @@ -426,12 +441,14 @@ class AccountTx_test : public beast::unit_test::suite env(mintURI(alice, uri), sig(alie)); env.close(); - auto tokenid = [](jtx::Account const& account, - std::string const& uri) { - auto const k = - keylet::uritoken(account, Blob(uri.begin(), uri.end())); - return k.key; - }; + auto tokenid = + [&env](jtx::Account const& account, std::string const& uri) { + auto const k = keylet::uritoken( + hash_options{env.current()->seq(), KEYLET_URI_TOKEN}, + account, + Blob(uri.begin(), uri.end())); + return k.key; + }; auto const tid = tokenid(alice, uri); std::string const hexid{strHex(tid)}; @@ -533,7 +550,9 @@ class AccountTx_test : public beast::unit_test::suite // Install Hook - Hash auto hh = [&](jtx::Env const& env, jtx::Account const& account) -> uint256 { - auto const hook = env.le(keylet::hook(account.id())); + auto const hook = env.le(keylet::hook( + hash_options{env.current()->seq(), KEYLET_HOOK}, + account.id())); if (hook) { auto const& hooks = hook->getFieldArray(sfHooks); @@ -660,7 +679,8 @@ class AccountTx_test : public beast::unit_test::suite env.close(); // Verify that becky's account root is present. - Keylet const beckyAcctKey{keylet::account(becky.id())}; + Keylet const beckyAcctKey{keylet::account( + hash_options{env.current()->seq(), KEYLET_ACCOUNT}, becky.id())}; BEAST_EXPECT(env.closed()->exists(beckyAcctKey)); // becky does an AccountSet . diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index dc6a57723..c83c6d341 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -31,18 +31,21 @@ class Book_test : public beast::unit_test::suite getBookDir(jtx::Env& env, Issue const& in, Issue const& out) { std::string dir; - auto uBookBase = getBookBase({in, out}); + auto uBookBase = getBookBase( + hash_options{env.current()->seq(), KEYLET_BOOK_BASE}, {in, out}); auto uBookEnd = getQualityNext(uBookBase); auto view = env.closed(); auto key = view->succ(uBookBase, uBookEnd); if (key) { - auto sleOfferDir = view->read(keylet::page(key.value())); + auto sleOfferDir = view->read(keylet::page( + hash_options{view->seq(), KEYLET_DIR_PAGE}, key.value())); uint256 offerIndex; unsigned int bookEntry; cdirFirst( *view, sleOfferDir->key(), sleOfferDir, bookEntry, offerIndex); - auto sleOffer = view->read(keylet::offer(offerIndex)); + auto sleOffer = view->read(keylet::offer( + hash_options{view->seq(), KEYLET_OFFER}, offerIndex)); dir = to_string(sleOffer->getFieldH256(sfBookDirectory)); } return dir; diff --git a/src/test/rpc/Catalogue_test.cpp b/src/test/rpc/Catalogue_test.cpp index 9cafebd07..ce84e4a76 100644 --- a/src/test/rpc/Catalogue_test.cpp +++ b/src/test/rpc/Catalogue_test.cpp @@ -267,9 +267,14 @@ class Catalogue_test : public beast::unit_test::suite // Store some key state information before catalogue creation auto const sourceLedger = env.closed(); - auto const bobKeylet = keylet::account(Account("bob").id()); - auto const charlieKeylet = keylet::account(Account("charlie").id()); + auto const bobKeylet = keylet::account( + hash_options{env.current()->seq(), KEYLET_ACCOUNT}, + Account("bob").id()); + auto const charlieKeylet = keylet::account( + hash_options{env.current()->seq(), KEYLET_ACCOUNT}, + Account("charlie").id()); auto const eurTrustKeylet = keylet::line( + hash_options{env.current()->seq(), KEYLET_TRUSTLINE}, Account("charlie").id(), Account("bob").id(), Currency(to_currency("EUR"))); diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index e6f766916..53db76d16 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -384,7 +384,10 @@ public: env.fund(XRP(10000), alice); env.close(); - auto const checkId = keylet::check(env.master, env.seq(env.master)); + auto const checkId = keylet::check( + hash_options{env.current()->seq(), KEYLET_CHECK}, + env.master, + env.seq(env.master)); env(check::create(env.master, alice, XRP(100))); env.close(); @@ -1063,7 +1066,8 @@ public: std::string const ledgerHash{to_string(env.closed()->info().hash)}; - auto const hook = env.le(keylet::hook(alice.id())); + auto const hook = env.le(keylet::hook( + hash_options{env.current()->seq(), KEYLET_HOOK}, alice.id())); auto const& hooks = hook->getFieldArray(sfHooks); uint256 hookHash = hooks[0].getFieldH256(sfHookHash); @@ -1351,7 +1355,12 @@ public: std::string const ledgerHash{to_string(env.closed()->info().hash)}; uint256 const payChanIndex{ - keylet::payChan(alice, env.master, env.seq(alice) - 1).key}; + keylet::payChan( + hash_options{env.current()->seq(), KEYLET_PAYCHAN}, + alice, + env.master, + env.seq(alice) - 1) + .key}; { // Request the payment channel using its index. Json::Value jvParams; @@ -1569,8 +1578,10 @@ public: { // Not a valid ticket requested by index. Json::Value jvParams; - jvParams[jss::ticket] = - to_string(getTicketIndex(env.master, tkt1 - 1)); + jvParams[jss::ticket] = to_string(getTicketIndex( + hash_options{env.current()->seq(), KEYLET_TICKET}, + env.master, + tkt1 - 1)); jvParams[jss::ledger_hash] = ledgerHash; Json::Value const jrr = env.rpc( "json", "ledger_entry", to_string(jvParams))[jss::result]; @@ -1579,7 +1590,10 @@ public: { // First real ticket requested by index. Json::Value jvParams; - jvParams[jss::ticket] = to_string(getTicketIndex(env.master, tkt1)); + jvParams[jss::ticket] = to_string(getTicketIndex( + hash_options{env.current()->seq(), KEYLET_TICKET}, + env.master, + tkt1)); jvParams[jss::ledger_hash] = ledgerHash; Json::Value const jrr = env.rpc( "json", "ledger_entry", to_string(jvParams))[jss::result]; @@ -1598,7 +1612,10 @@ public: "json", "ledger_entry", to_string(jvParams))[jss::result]; BEAST_EXPECT( jrr[jss::node][jss::index] == - to_string(getTicketIndex(env.master, tkt1 + 1))); + to_string(getTicketIndex( + hash_options{env.current()->seq(), KEYLET_TICKET}, + env.master, + tkt1 + 1))); } { // Not a valid ticket requested by account and sequence. @@ -1614,7 +1631,11 @@ public: { // Request a ticket using an account root entry. Json::Value jvParams; - jvParams[jss::ticket] = to_string(keylet::account(env.master).key); + jvParams[jss::ticket] = to_string( + keylet::account( + hash_options{env.current()->seq(), KEYLET_ACCOUNT}, + env.master) + .key); jvParams[jss::ledger_hash] = ledgerHash; Json::Value const jrr = env.rpc( "json", "ledger_entry", to_string(jvParams))[jss::result]; @@ -1696,7 +1717,11 @@ public: std::string const ledgerHash{to_string(env.closed()->info().hash)}; uint256 const uritokenIndex{ - keylet::uritoken(alice, Blob(uri.begin(), uri.end())).key}; + keylet::uritoken( + hash_options{env.current()->seq(), KEYLET_URI_TOKEN}, + alice, + Blob(uri.begin(), uri.end())) + .key}; { // Request the uritoken using its index. Json::Value jvParams; @@ -1779,7 +1804,10 @@ public: std::string const ledgerHash{to_string(env.closed()->info().hash)}; auto const pk = PublicKey(makeSlice(*strUnHex(keys[0u]))); - uint256 const importvlIndex{keylet::import_vlseq(pk).key}; + uint256 const importvlIndex{ + keylet::import_vlseq( + hash_options{env.current()->seq(), KEYLET_IMPORT_VLSEQ}, pk) + .key}; { // Request the import vl using its index. Json::Value jvParams; diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index f15f3163e..eefa830c5 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -109,7 +109,10 @@ public: void on_fetch(Map& map, SHAMapHash const& hash, Blob const& blob) { - BEAST_EXPECT(sha512Half(makeSlice(blob)) == hash.as_uint256()); + BEAST_EXPECT( + sha512Half( + hash_options{FETCH_PACK_CACHE_KEY_HASH}, makeSlice(blob)) == + hash.as_uint256()); map.emplace(hash, blob); } diff --git a/src/test/shamap/SHAMap_test.cpp b/src/test/shamap/SHAMap_test.cpp index 83bbc1325..dcea928b5 100644 --- a/src/test/shamap/SHAMap_test.cpp +++ b/src/test/shamap/SHAMap_test.cpp @@ -356,12 +356,12 @@ class SHAMapPathProof_test : public beast::unit_test::suite BEAST_EXPECT(path); if (!path) break; - BEAST_EXPECT(map.verifyProofPath(root, k, *path)); + BEAST_EXPECT(map.verifyProofPath(root, k, *path, 0)); if (c == 1) { // extra node path->insert(path->begin(), path->front()); - BEAST_EXPECT(!map.verifyProofPath(root, k, *path)); + BEAST_EXPECT(!map.verifyProofPath(root, k, *path, 0)); // wrong key uint256 wrongKey(c + 1); BEAST_EXPECT(!map.getProofPath(wrongKey)); @@ -375,28 +375,28 @@ class SHAMapPathProof_test : public beast::unit_test::suite } // still good - BEAST_EXPECT(map.verifyProofPath(rootHash, key, goodPath)); + BEAST_EXPECT(map.verifyProofPath(rootHash, key, goodPath, 0)); // empty path std::vector badPath; - BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath)); + BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath, 0)); // too long badPath = goodPath; badPath.push_back(goodPath.back()); - BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath)); + BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath, 0)); // bad node badPath.clear(); badPath.emplace_back(100, 100); - BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath)); + BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath, 0)); // bad node type badPath.clear(); badPath.push_back(goodPath.front()); badPath.front().back()--; // change node type - BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath)); + BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath, 0)); // all inner badPath.clear(); badPath = goodPath; badPath.erase(badPath.begin()); - BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath)); + BEAST_EXPECT(!map.verifyProofPath(rootHash, key, badPath, 0)); } };