mirror of
https://github.com/Xahau/xahaud.git
synced 2026-01-16 04:35:15 +00:00
Compare commits
1 Commits
fix-releas
...
acctx-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4221267dce |
97
.github/workflows/build-in-docker.yml
vendored
97
.github/workflows/build-in-docker.yml
vendored
@@ -2,104 +2,37 @@ name: Build using Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["dev", "candidate", "release", "jshooks"]
|
||||
branches: [ "dev", "candidate", "release", "jshooks" ]
|
||||
pull_request:
|
||||
branches: ["dev", "candidate", "release", "jshooks"]
|
||||
branches: [ "dev", "candidate", "release", "jshooks" ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
DEBUG_BUILD_CONTAINERS_AFTER_CLEANUP: 1
|
||||
group: ${{ github.workflow }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
checkout:
|
||||
runs-on: [self-hosted, vanity]
|
||||
outputs:
|
||||
checkout_path: ${{ steps.vars.outputs.checkout_path }}
|
||||
steps:
|
||||
- name: Prepare checkout path
|
||||
id: vars
|
||||
run: |
|
||||
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
||||
CHECKOUT_PATH="${SAFE_BRANCH}-${{ github.sha }}"
|
||||
echo "checkout_path=${CHECKOUT_PATH}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
path: ${{ steps.vars.outputs.checkout_path }}
|
||||
clean: true
|
||||
fetch-depth: 2 # Only get the last 2 commits, to avoid fetching all history
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
clean: false
|
||||
checkpatterns:
|
||||
runs-on: [self-hosted, vanity]
|
||||
needs: checkout
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ needs.checkout.outputs.checkout_path }}
|
||||
steps:
|
||||
- name: Check for suspicious patterns
|
||||
run: /bin/bash suspicious_patterns.sh
|
||||
|
||||
- name: Check for suspicious patterns
|
||||
run: /bin/bash suspicious_patterns.sh
|
||||
build:
|
||||
runs-on: [self-hosted, vanity]
|
||||
needs: [checkpatterns, checkout]
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ needs.checkout.outputs.checkout_path }}
|
||||
needs: checkpatterns
|
||||
steps:
|
||||
- name: Set Cleanup Script Path
|
||||
run: |
|
||||
echo "JOB_CLEANUP_SCRIPT=$(mktemp)" >> $GITHUB_ENV
|
||||
|
||||
- name: Build using Docker
|
||||
run: /bin/bash release-builder.sh
|
||||
|
||||
- name: Stop Container (Cleanup)
|
||||
if: always()
|
||||
run: |
|
||||
echo "Running cleanup script: $JOB_CLEANUP_SCRIPT"
|
||||
/bin/bash -e -x "$JOB_CLEANUP_SCRIPT"
|
||||
CLEANUP_EXIT_CODE=$?
|
||||
|
||||
if [[ "$CLEANUP_EXIT_CODE" -eq 0 ]]; then
|
||||
echo "Cleanup script succeeded."
|
||||
rm -f "$JOB_CLEANUP_SCRIPT"
|
||||
echo "Cleanup script removed."
|
||||
else
|
||||
echo "⚠️ Cleanup script failed! Keeping for debugging: $JOB_CLEANUP_SCRIPT"
|
||||
fi
|
||||
|
||||
if [[ "${DEBUG_BUILD_CONTAINERS_AFTER_CLEANUP}" == "1" ]]; then
|
||||
echo "🔍 Checking for leftover containers..."
|
||||
BUILD_CONTAINERS=$(docker ps --format '{{.Names}}' | grep '^xahaud_cached_builder' || echo "")
|
||||
|
||||
if [[ -n "$BUILD_CONTAINERS" ]]; then
|
||||
echo "⚠️ WARNING: Some build containers are still running"
|
||||
echo "$BUILD_CONTAINERS"
|
||||
else
|
||||
echo "✅ No build containers found"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Build using Docker
|
||||
run: /bin/bash release-builder.sh
|
||||
tests:
|
||||
runs-on: [self-hosted, vanity]
|
||||
needs: [build, checkout]
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ needs.checkout.outputs.checkout_path }}
|
||||
needs: build
|
||||
steps:
|
||||
- name: Unit tests
|
||||
run: /bin/bash docker-unit-tests.sh
|
||||
- name: Unit tests
|
||||
run: /bin/bash docker-unit-tests.sh
|
||||
|
||||
cleanup:
|
||||
runs-on: [self-hosted, vanity]
|
||||
needs: [tests, checkout]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Cleanup workspace
|
||||
run: |
|
||||
CHECKOUT_PATH="${{ needs.checkout.outputs.checkout_path }}"
|
||||
echo "Cleaning workspace for ${CHECKOUT_PATH}"
|
||||
rm -rf "${{ github.workspace }}/${CHECKOUT_PATH}"
|
||||
|
||||
@@ -755,7 +755,6 @@ if (tests)
|
||||
src/test/app/Taker_test.cpp
|
||||
src/test/app/TheoreticalQuality_test.cpp
|
||||
src/test/app/Ticket_test.cpp
|
||||
src/test/app/Touch_test.cpp
|
||||
src/test/app/Transaction_ordering_test.cpp
|
||||
src/test/app/TrustAndBalance_test.cpp
|
||||
src/test/app/TxQ_test.cpp
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
#!/bin/bash -u
|
||||
# We use set -e and bash with -u to bail on first non zero exit code of any
|
||||
# processes launched or upon any unbound variable.
|
||||
# We use set -x to print commands before running them to help with
|
||||
# debugging.
|
||||
set -ex
|
||||
|
||||
set -e
|
||||
#!/bin/bash
|
||||
|
||||
echo "START INSIDE CONTAINER - CORE"
|
||||
|
||||
@@ -30,7 +23,7 @@ fi
|
||||
perl -i -pe "s/^(\\s*)-DBUILD_SHARED_LIBS=OFF/\\1-DBUILD_SHARED_LIBS=OFF\\n\\1-DROCKSDB_BUILD_SHARED=OFF/g" Builds/CMake/deps/Rocksdb.cmake &&
|
||||
mv Builds/CMake/deps/WasmEdge.cmake Builds/CMake/deps/WasmEdge.old &&
|
||||
echo "find_package(LLVM REQUIRED CONFIG)
|
||||
message(STATUS \"Found LLVM \${LLVM_PACKAGE_VERSION}\")
|
||||
message(STATUS \"Found LLVM ${LLVM_PACKAGE_VERSION}\")
|
||||
message(STATUS \"Using LLVMConfig.cmake in: \${LLVM_DIR}\")
|
||||
add_library (wasmedge STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(wasmedge PROPERTIES IMPORTED_LOCATION \${WasmEdge_LIB})
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
#!/bin/bash -u
|
||||
# We use set -e and bash with -u to bail on first non zero exit code of any
|
||||
# processes launched or upon any unbound variable.
|
||||
# We use set -x to print commands before running them to help with
|
||||
# debugging.
|
||||
set -ex
|
||||
|
||||
set -e
|
||||
#!/bin/bash
|
||||
|
||||
echo "START INSIDE CONTAINER - FULL"
|
||||
|
||||
@@ -26,7 +19,7 @@ yum-config-manager --disable centos-sclo-sclo
|
||||
####
|
||||
|
||||
cd /io;
|
||||
mkdir -p src/certs;
|
||||
mkdir src/certs;
|
||||
curl --silent -k https://raw.githubusercontent.com/RichardAH/rippled-release-builder/main/ca-bundle/certbundle.h -o src/certs/certbundle.h;
|
||||
if [ "`grep certbundle.h src/ripple/net/impl/RegisterSSLCerts.cpp | wc -l`" -eq "0" ]
|
||||
then
|
||||
@@ -73,8 +66,8 @@ then
|
||||
#endif/g" src/ripple/net/impl/RegisterSSLCerts.cpp &&
|
||||
sed -i "s/#include <ripple\/net\/RegisterSSLCerts.h>/\0\n#include <certs\/certbundle.h>/g" src/ripple/net/impl/RegisterSSLCerts.cpp
|
||||
fi
|
||||
mkdir -p .nih_c;
|
||||
mkdir -p .nih_toolchain;
|
||||
mkdir .nih_c;
|
||||
mkdir .nih_toolchain;
|
||||
cd .nih_toolchain &&
|
||||
yum install -y wget lz4 lz4-devel git llvm13-static.x86_64 llvm13-devel.x86_64 devtoolset-10-binutils zlib-static ncurses-static -y \
|
||||
devtoolset-7-gcc-c++ \
|
||||
@@ -122,7 +115,7 @@ tar -xf libunwind-13.0.1.src.tar.xz &&
|
||||
cp -r libunwind-13.0.1.src/include libunwind-13.0.1.src/src lld-13.0.1.src/ &&
|
||||
cd lld-13.0.1.src &&
|
||||
rm -rf build CMakeCache.txt &&
|
||||
mkdir -p build &&
|
||||
mkdir build &&
|
||||
cd build &&
|
||||
cmake .. -DLLVM_LIBRARY_DIR=/usr/lib64/llvm13/lib/ -DCMAKE_INSTALL_PREFIX=/usr/lib64/llvm13/ -DCMAKE_BUILD_TYPE=Release &&
|
||||
make -j$3 install &&
|
||||
@@ -132,7 +125,7 @@ cd ../../ &&
|
||||
echo "-- Build WasmEdge --" &&
|
||||
( wget -nc -q https://github.com/WasmEdge/WasmEdge/archive/refs/tags/0.11.2.zip; unzip -o 0.11.2.zip; ) &&
|
||||
cd WasmEdge-0.11.2 &&
|
||||
( mkdir -p build; echo "" ) &&
|
||||
( mkdir build; echo "" ) &&
|
||||
cd build &&
|
||||
export BOOST_ROOT="/usr/local/src/boost_1_86_0" &&
|
||||
export Boost_LIBRARY_DIRS="/usr/local/lib" &&
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Mounting $(pwd)/io in ubuntu and running unit tests"
|
||||
docker run --rm -i -v $(pwd):/io ubuntu sh -c '/io/release-build/xahaud -u'
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
#!/bin/bash -u
|
||||
# We use set -e and bash with -u to bail on first non zero exit code of any
|
||||
# processes launched or upon any unbound variable.
|
||||
# We use set -x to print commands before running them to help with
|
||||
# debugging.
|
||||
set -ex
|
||||
#!/bin/bash
|
||||
|
||||
echo "START BUILDING (HOST)"
|
||||
|
||||
@@ -11,37 +6,13 @@ echo "Cleaning previously built binary"
|
||||
rm -f release-build/xahaud
|
||||
|
||||
BUILD_CORES=$(echo "scale=0 ; `nproc` / 1.337" | bc)
|
||||
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-""}
|
||||
GITHUB_SHA=${GITHUB_SHA:-"local"}
|
||||
GITHUB_RUN_NUMBER=${GITHUB_RUN_NUMBER:-"0"}
|
||||
GITHUB_WORKFLOW=${GITHUB_WORKFLOW:-"local"}
|
||||
GITHUB_REF=${GITHUB_REF:-"local"}
|
||||
|
||||
if [[ "$GITHUB_REPOSITORY" == "" ]]; then
|
||||
#Default
|
||||
BUILD_CORES=8
|
||||
fi
|
||||
|
||||
EXIT_IF_CONTAINER_RUNNING=${EXIT_IF_CONTAINER_RUNNING:-1}
|
||||
# Ensure still works outside of GH Actions by setting these to /dev/null
|
||||
# GA will run this script and then delete it at the end of the job
|
||||
JOB_CLEANUP_SCRIPT=${JOB_CLEANUP_SCRIPT:-/dev/null}
|
||||
NORMALIZED_WORKFLOW=$(echo "$GITHUB_WORKFLOW" | tr -c 'a-zA-Z0-9' '-')
|
||||
NORMALIZED_REF=$(echo "$GITHUB_REF" | tr -c 'a-zA-Z0-9' '-')
|
||||
CONTAINER_NAME="xahaud_cached_builder_${NORMALIZED_WORKFLOW}-${NORMALIZED_REF}"
|
||||
|
||||
# Check if the container is already running
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
echo "⚠️ A running container (${CONTAINER_NAME}) was detected."
|
||||
|
||||
if [[ "$EXIT_IF_CONTAINER_RUNNING" -eq 1 ]]; then
|
||||
echo "❌ EXIT_IF_CONTAINER_RUNNING is set. Exiting."
|
||||
exit 1
|
||||
else
|
||||
echo "🛑 Stopping the running container: ${CONTAINER_NAME}"
|
||||
docker stop "${CONTAINER_NAME}"
|
||||
fi
|
||||
fi
|
||||
CONTAINER_NAME=xahaud_cached_builder_$(echo "$GITHUB_ACTOR" | awk '{print tolower($0)}')
|
||||
|
||||
echo "-- BUILD CORES: $BUILD_CORES"
|
||||
echo "-- GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
|
||||
@@ -65,8 +36,7 @@ fi
|
||||
|
||||
STATIC_CONTAINER=$(docker ps -a | grep $CONTAINER_NAME |wc -l)
|
||||
|
||||
#if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then
|
||||
if false; then
|
||||
if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then
|
||||
echo "Static container, execute in static container to have max. cache"
|
||||
docker start $CONTAINER_NAME
|
||||
docker exec -i $CONTAINER_NAME /hbb_exe/activate-exec bash -x /io/build-core.sh "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$BUILD_CORES" "$GITHUB_RUN_NUMBER"
|
||||
@@ -84,8 +54,6 @@ else
|
||||
# GH Action, runner
|
||||
echo "GH Action, runner, clean & re-create create persistent container"
|
||||
docker rm -f $CONTAINER_NAME
|
||||
echo "echo 'Stopping container: $CONTAINER_NAME'" >> "$JOB_CLEANUP_SCRIPT"
|
||||
echo "docker stop --time=15 \"$CONTAINER_NAME\" || echo 'Failed to stop container or container not running'" >> "$JOB_CLEANUP_SCRIPT"
|
||||
docker run -di --user 0:$(id -g) --name $CONTAINER_NAME -v /data/builds:/data/builds -v `pwd`:/io --network host ghcr.io/foobarwidget/holy-build-box-x64 /hbb_exe/activate-exec bash
|
||||
docker exec -i $CONTAINER_NAME /hbb_exe/activate-exec bash -x /io/build-full.sh "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$BUILD_CORES" "$GITHUB_RUN_NUMBER"
|
||||
docker stop $CONTAINER_NAME
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
std::uint32_t offset;
|
||||
std::uint32_t limit;
|
||||
bool bUnlimited;
|
||||
bool strict;
|
||||
};
|
||||
|
||||
struct AccountTxPageOptions
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
std::optional<AccountTxMarker> marker;
|
||||
std::uint32_t limit;
|
||||
bool bAdmin;
|
||||
bool strict;
|
||||
};
|
||||
|
||||
using AccountTx =
|
||||
@@ -101,6 +103,7 @@ public:
|
||||
bool forward = false;
|
||||
uint32_t limit = 0;
|
||||
std::optional<AccountTxMarker> marker;
|
||||
bool strict;
|
||||
};
|
||||
|
||||
struct AccountTxResult
|
||||
|
||||
@@ -43,6 +43,62 @@ private:
|
||||
std::map<uint256, AccountTx> transactionMap_;
|
||||
std::map<AccountID, AccountTxData> accountTxMap_;
|
||||
|
||||
// helper function to scan for an account ID inside the tx and meta blobs
|
||||
// used for strict filtering of account_tx
|
||||
bool
|
||||
isAccountInvolvedInTx(AccountID const& account, AccountTx const& accountTx)
|
||||
{
|
||||
auto const& txn = accountTx.first;
|
||||
auto const& meta = accountTx.second;
|
||||
|
||||
// Search metadata, excluding RegularKey false positives
|
||||
Blob const metaBlob = meta->getAsObject().getSerializer().peekData();
|
||||
if (metaBlob.size() >= account.size())
|
||||
{
|
||||
auto it = metaBlob.begin();
|
||||
while (true)
|
||||
{
|
||||
// Find next occurrence of account
|
||||
it = std::search(
|
||||
it,
|
||||
metaBlob.end(),
|
||||
account.data(),
|
||||
account.data() + account.size());
|
||||
|
||||
if (it == metaBlob.end())
|
||||
break;
|
||||
|
||||
// Check if this is a RegularKey field (0x8814 prefix)
|
||||
if (it >= metaBlob.begin() + 2)
|
||||
{
|
||||
auto prefix = *(it - 2);
|
||||
auto prefix2 = *(it - 1);
|
||||
if (prefix != 0x88 || prefix2 != 0x14)
|
||||
{
|
||||
// Found account not preceded by RegularKey prefix
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Too close to start to be RegularKey
|
||||
return true;
|
||||
}
|
||||
|
||||
++it; // Move past this occurrence
|
||||
}
|
||||
}
|
||||
|
||||
// Search transaction blob
|
||||
Blob const txnBlob = txn->getSTransaction()->getSerializer().peekData();
|
||||
return txnBlob.size() >= account.size() &&
|
||||
std::search(
|
||||
txnBlob.begin(),
|
||||
txnBlob.end(),
|
||||
account.data(),
|
||||
account.data() + account.size()) != txnBlob.end();
|
||||
}
|
||||
|
||||
public:
|
||||
RWDBDatabase(Application& app, Config const& config, JobQueue& jobQueue)
|
||||
: app_(app), useTxTables_(config.useTxTables())
|
||||
@@ -193,7 +249,17 @@ public:
|
||||
std::size_t count = 0;
|
||||
for (const auto& [_, accountData] : accountTxMap_)
|
||||
{
|
||||
count += accountData.transactions.size();
|
||||
for (const auto& tx : accountData.transactions)
|
||||
{
|
||||
// RH NOTE: options isn't provided to this function
|
||||
// but this function is probably only used internally
|
||||
// so make it reflect the true number (unfiltered)
|
||||
|
||||
// if (options.strict &&
|
||||
// !isAccountInvolvedInTx(options.account, tx))
|
||||
// continue;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -607,12 +673,17 @@ public:
|
||||
{
|
||||
for (const auto& [txSeq, txIndex] : txIt->second)
|
||||
{
|
||||
AccountTx const accountTx = accountData.transactions[txIndex];
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
if (skipped < options.offset)
|
||||
{
|
||||
++skipped;
|
||||
continue;
|
||||
}
|
||||
AccountTx const accountTx = accountData.transactions[txIndex];
|
||||
|
||||
std::uint32_t const inLedger = rangeCheckedCast<std::uint32_t>(
|
||||
accountTx.second->getLgrSeq());
|
||||
accountTx.first->setStatus(COMMITTED);
|
||||
@@ -652,13 +723,18 @@ public:
|
||||
innerRIt != rIt->second.rend();
|
||||
++innerRIt)
|
||||
{
|
||||
AccountTx const accountTx =
|
||||
accountData.transactions[innerRIt->second];
|
||||
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
if (skipped < options.offset)
|
||||
{
|
||||
++skipped;
|
||||
continue;
|
||||
}
|
||||
AccountTx const accountTx =
|
||||
accountData.transactions[innerRIt->second];
|
||||
std::uint32_t const inLedger = rangeCheckedCast<std::uint32_t>(
|
||||
accountTx.second->getLgrSeq());
|
||||
accountTx.first->setLedger(inLedger);
|
||||
@@ -694,12 +770,19 @@ public:
|
||||
{
|
||||
for (const auto& [txSeq, txIndex] : txIt->second)
|
||||
{
|
||||
AccountTx const accountTx = accountData.transactions[txIndex];
|
||||
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
const auto& [txn, txMeta] = accountTx;
|
||||
|
||||
if (skipped < options.offset)
|
||||
{
|
||||
++skipped;
|
||||
continue;
|
||||
}
|
||||
const auto& [txn, txMeta] = accountData.transactions[txIndex];
|
||||
result.emplace_back(
|
||||
txn->getSTransaction()->getSerializer().peekData(),
|
||||
txMeta->getAsObject().getSerializer().peekData(),
|
||||
@@ -738,13 +821,20 @@ public:
|
||||
innerRIt != rIt->second.rend();
|
||||
++innerRIt)
|
||||
{
|
||||
AccountTx const accountTx =
|
||||
accountData.transactions[innerRIt->second];
|
||||
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
const auto& [txn, txMeta] = accountTx;
|
||||
|
||||
if (skipped < options.offset)
|
||||
{
|
||||
++skipped;
|
||||
continue;
|
||||
}
|
||||
const auto& [txn, txMeta] =
|
||||
accountData.transactions[innerRIt->second];
|
||||
result.emplace_back(
|
||||
txn->getSTransaction()->getSerializer().peekData(),
|
||||
txMeta->getAsObject().getSerializer().peekData(),
|
||||
@@ -838,18 +928,23 @@ public:
|
||||
return {newmarker, total};
|
||||
}
|
||||
|
||||
Blob rawTxn = accountData.transactions[index]
|
||||
.first->getSTransaction()
|
||||
AccountTx const& accountTx =
|
||||
accountData.transactions[index];
|
||||
|
||||
Blob rawTxn = accountTx.first->getSTransaction()
|
||||
->getSerializer()
|
||||
.peekData();
|
||||
Blob rawMeta = accountData.transactions[index]
|
||||
.second->getAsObject()
|
||||
Blob rawMeta = accountTx.second->getAsObject()
|
||||
.getSerializer()
|
||||
.peekData();
|
||||
|
||||
if (rawMeta.size() == 0)
|
||||
onUnsavedLedger(ledgerSeq);
|
||||
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
onTransaction(
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq),
|
||||
"COMMITTED",
|
||||
@@ -893,18 +988,23 @@ public:
|
||||
return {newmarker, total};
|
||||
}
|
||||
|
||||
Blob rawTxn = accountData.transactions[index]
|
||||
.first->getSTransaction()
|
||||
AccountTx const& accountTx =
|
||||
accountData.transactions[index];
|
||||
|
||||
Blob rawTxn = accountTx.first->getSTransaction()
|
||||
->getSerializer()
|
||||
.peekData();
|
||||
Blob rawMeta = accountData.transactions[index]
|
||||
.second->getAsObject()
|
||||
Blob rawMeta = accountTx.second->getAsObject()
|
||||
.getSerializer()
|
||||
.peekData();
|
||||
|
||||
if (rawMeta.size() == 0)
|
||||
onUnsavedLedger(ledgerSeq);
|
||||
|
||||
if (options.strict &&
|
||||
!isAccountInvolvedInTx(options.account, accountTx))
|
||||
continue;
|
||||
|
||||
onTransaction(
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq),
|
||||
"COMMITTED",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <ripple/app/rdb/backend/detail/Node.h>
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/core/DatabaseCon.h>
|
||||
#include <ripple/core/SociDB.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
@@ -758,14 +759,34 @@ transactionsSQL(
|
||||
options.minLedger);
|
||||
}
|
||||
|
||||
// Convert account ID to hex string for binary search
|
||||
std::string accountHex =
|
||||
strHex(options.account.data(), options.account.size());
|
||||
|
||||
std::string sql;
|
||||
|
||||
// For metadata search:
|
||||
// 1. Look for account ID not preceded by 8814 (RegularKey field)
|
||||
// 2. OR look for account in raw transaction
|
||||
std::string filterClause = options.strict ? "AND (("
|
||||
"hex(TxnMeta) LIKE '%" +
|
||||
accountHex +
|
||||
"%' AND "
|
||||
"hex(TxnMeta) NOT LIKE '%8814" +
|
||||
accountHex +
|
||||
"%'"
|
||||
") OR hex(RawTxn) LIKE '%" +
|
||||
accountHex + "%')"
|
||||
: "";
|
||||
|
||||
if (count)
|
||||
sql = boost::str(
|
||||
boost::format("SELECT %s FROM AccountTransactions "
|
||||
"WHERE Account = '%s' %s %s LIMIT %u, %u;") %
|
||||
selection % toBase58(options.account) % maxClause % minClause %
|
||||
beast::lexicalCastThrow<std::string>(options.offset) %
|
||||
"INNER JOIN Transactions ON Transactions.TransID = "
|
||||
"AccountTransactions.TransID "
|
||||
"WHERE Account = '%s' %s %s %s LIMIT %u, %u;") %
|
||||
selection % toBase58(options.account) % filterClause % maxClause %
|
||||
minClause % beast::lexicalCastThrow<std::string>(options.offset) %
|
||||
beast::lexicalCastThrow<std::string>(numberOfResults));
|
||||
else
|
||||
sql = boost::str(
|
||||
@@ -773,15 +794,16 @@ transactionsSQL(
|
||||
"SELECT %s FROM "
|
||||
"AccountTransactions INNER JOIN Transactions "
|
||||
"ON Transactions.TransID = AccountTransactions.TransID "
|
||||
"WHERE Account = '%s' %s %s "
|
||||
"WHERE Account = '%s' %s %s %s "
|
||||
"ORDER BY AccountTransactions.LedgerSeq %s, "
|
||||
"AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s "
|
||||
"LIMIT %u, %u;") %
|
||||
selection % toBase58(options.account) % maxClause % minClause %
|
||||
selection % toBase58(options.account) % filterClause % maxClause %
|
||||
minClause % (descending ? "DESC" : "ASC") %
|
||||
(descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") %
|
||||
(descending ? "DESC" : "ASC") %
|
||||
beast::lexicalCastThrow<std::string>(options.offset) %
|
||||
beast::lexicalCastThrow<std::string>(numberOfResults));
|
||||
|
||||
JLOG(j.trace()) << "txSQL query: " << sql;
|
||||
return sql;
|
||||
}
|
||||
@@ -1114,6 +1136,21 @@ accountTxPage(
|
||||
if (limit_used > 0)
|
||||
newmarker = options.marker;
|
||||
|
||||
// Convert account ID to hex string for binary search
|
||||
std::string accountHex =
|
||||
strHex(options.account.data(), options.account.size());
|
||||
|
||||
// Add metadata search filter similar to transactionsSQL
|
||||
std::string filterClause = options.strict
|
||||
? " AND ((hex(TxnMeta) LIKE '%" + accountHex +
|
||||
"%' "
|
||||
"AND hex(TxnMeta) NOT LIKE '%8814" +
|
||||
accountHex +
|
||||
"%') "
|
||||
"OR hex(RawTxn) LIKE '%" +
|
||||
accountHex + "%')"
|
||||
: "";
|
||||
|
||||
static std::string const prefix(
|
||||
R"(SELECT AccountTransactions.LedgerSeq,AccountTransactions.TxnSeq,
|
||||
Status,RawTxn,TxnMeta
|
||||
@@ -1132,12 +1169,12 @@ accountTxPage(
|
||||
{
|
||||
sql = boost::str(
|
||||
boost::format(
|
||||
prefix + (R"(AccountTransactions.LedgerSeq BETWEEN %u AND %u
|
||||
prefix + (R"(AccountTransactions.LedgerSeq BETWEEN %u AND %u %s
|
||||
ORDER BY AccountTransactions.LedgerSeq %s,
|
||||
AccountTransactions.TxnSeq %s
|
||||
LIMIT %u;)")) %
|
||||
toBase58(options.account) % options.minLedger % options.maxLedger %
|
||||
order % order % queryLimit);
|
||||
filterClause % order % order % queryLimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1150,25 +1187,25 @@ accountTxPage(
|
||||
auto b58acct = toBase58(options.account);
|
||||
sql = boost::str(
|
||||
boost::format((
|
||||
R"(SELECT AccountTransactions.LedgerSeq,AccountTransactions.TxnSeq,
|
||||
Status,RawTxn,TxnMeta
|
||||
R"(SELECT AccountTransactions.LedgerSeq,AccountTransactions.TxnSeq,Status,RawTxn,TxnMeta
|
||||
FROM AccountTransactions, Transactions WHERE
|
||||
(AccountTransactions.TransID = Transactions.TransID AND
|
||||
AccountTransactions.Account = '%s' AND
|
||||
AccountTransactions.LedgerSeq BETWEEN %u AND %u)
|
||||
AccountTransactions.LedgerSeq BETWEEN %u AND %u) %s
|
||||
UNION
|
||||
SELECT AccountTransactions.LedgerSeq,AccountTransactions.TxnSeq,Status,RawTxn,TxnMeta
|
||||
FROM AccountTransactions, Transactions WHERE
|
||||
(AccountTransactions.TransID = Transactions.TransID AND
|
||||
AccountTransactions.Account = '%s' AND
|
||||
AccountTransactions.LedgerSeq = %u AND
|
||||
AccountTransactions.TxnSeq %s %u)
|
||||
AccountTransactions.TxnSeq %s %u) %s
|
||||
ORDER BY AccountTransactions.LedgerSeq %s,
|
||||
AccountTransactions.TxnSeq %s
|
||||
LIMIT %u;
|
||||
)")) %
|
||||
b58acct % minLedger % maxLedger % b58acct % findLedger % compare %
|
||||
findSeq % order % order % queryLimit);
|
||||
b58acct % minLedger % maxLedger % filterClause % b58acct %
|
||||
findLedger % compare % findSeq % filterClause % order % order %
|
||||
queryLimit);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1079,24 +1079,6 @@ Transactor::checkMultiSign(PreclaimContext const& ctx)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// increment the touch counter on an account
|
||||
static void
|
||||
touchAccount(ApplyView& view, AccountID const& id)
|
||||
{
|
||||
if (!view.rules().enabled(featureTouch))
|
||||
return;
|
||||
|
||||
std::shared_ptr<SLE> sle = view.peek(keylet::account(id));
|
||||
if (!sle)
|
||||
return;
|
||||
|
||||
uint64_t tc =
|
||||
sle->isFieldPresent(sfTouchCount) ? sle->getFieldU64(sfTouchCount) : 0;
|
||||
|
||||
sle->setFieldU64(sfTouchCount, tc + 1);
|
||||
view.update(sle);
|
||||
}
|
||||
|
||||
static void
|
||||
removeUnfundedOffers(
|
||||
ApplyView& view,
|
||||
@@ -1537,8 +1519,6 @@ Transactor::doTSH(
|
||||
if ((!canRollback && strong) || (canRollback && !strong))
|
||||
continue;
|
||||
|
||||
touchAccount(view, tshAccountID);
|
||||
|
||||
auto klTshHook = keylet::hook(tshAccountID);
|
||||
|
||||
auto tshHook = view.read(klTshHook);
|
||||
|
||||
@@ -40,6 +40,17 @@ strHex(FwdIt begin, FwdIt end)
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class FwdIt>
|
||||
std::string
|
||||
strHex(FwdIt begin, std::size_t length)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(2 * length);
|
||||
boost::algorithm::hex(
|
||||
begin, std::next(begin, length), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T, class = decltype(std::declval<T>().begin())>
|
||||
std::string
|
||||
strHex(T const& from)
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace detail {
|
||||
// Feature.cpp. Because it's only used to reserve storage, and determine how
|
||||
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
|
||||
// the actual number of amendments. A LogicError on startup will verify this.
|
||||
static constexpr std::size_t numFeatures = 78;
|
||||
static constexpr std::size_t numFeatures = 77;
|
||||
|
||||
/** Amendments that this server supports and the default voting behavior.
|
||||
Whether they are enabled depends on the Rules defined in the validated
|
||||
@@ -362,7 +362,6 @@ extern uint256 const fix240819;
|
||||
extern uint256 const fixPageCap;
|
||||
extern uint256 const fix240911;
|
||||
extern uint256 const fixFloatDivide;
|
||||
extern uint256 const featureTouch;
|
||||
extern uint256 const fixReduceImport;
|
||||
extern uint256 const fixXahauV3;
|
||||
extern uint256 const fix20250131;
|
||||
|
||||
@@ -433,7 +433,6 @@ extern SF_UINT64 const sfReferenceCount;
|
||||
extern SF_UINT64 const sfRewardAccumulator;
|
||||
extern SF_UINT64 const sfAccountCount;
|
||||
extern SF_UINT64 const sfAccountIndex;
|
||||
extern SF_UINT64 const sfTouchCount;
|
||||
|
||||
// 128-bit
|
||||
extern SF_UINT128 const sfEmailHash;
|
||||
|
||||
@@ -468,7 +468,6 @@ REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::De
|
||||
REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::DefaultYes);
|
||||
REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes);
|
||||
REGISTER_FIX (fixFloatDivide, Supported::yes, VoteBehavior::DefaultYes);
|
||||
REGISTER_FEATURE(Touch, Supported::yes, VoteBehavior::DefaultNo);
|
||||
REGISTER_FIX (fixReduceImport, Supported::yes, VoteBehavior::DefaultYes);
|
||||
REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::DefaultYes);
|
||||
REGISTER_FIX (fix20250131, Supported::yes, VoteBehavior::DefaultYes);
|
||||
|
||||
@@ -66,7 +66,6 @@ LedgerFormats::LedgerFormats()
|
||||
{sfGovernanceFlags, soeOPTIONAL},
|
||||
{sfGovernanceMarks, soeOPTIONAL},
|
||||
{sfAccountIndex, soeOPTIONAL},
|
||||
{sfTouchCount, soeOPTIONAL},
|
||||
},
|
||||
commonFields);
|
||||
|
||||
|
||||
@@ -183,7 +183,6 @@ CONSTRUCT_TYPED_SFIELD(sfEmitBurden, "EmitBurden", UINT64,
|
||||
CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17);
|
||||
CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18);
|
||||
CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19);
|
||||
CONSTRUCT_TYPED_SFIELD(sfTouchCount, "TouchCount", UINT64, 97);
|
||||
CONSTRUCT_TYPED_SFIELD(sfAccountIndex, "AccountIndex", UINT64, 98);
|
||||
CONSTRUCT_TYPED_SFIELD(sfAccountCount, "AccountCount", UINT64, 99);
|
||||
CONSTRUCT_TYPED_SFIELD(sfRewardAccumulator, "RewardAccumulator", UINT64, 100);
|
||||
|
||||
@@ -223,7 +223,8 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args)
|
||||
result.ledgerRange.max,
|
||||
result.marker,
|
||||
args.limit,
|
||||
isUnlimited(context.role)};
|
||||
isUnlimited(context.role),
|
||||
args.strict};
|
||||
|
||||
auto const db =
|
||||
dynamic_cast<SQLiteDatabase*>(&context.app.getRelationalDatabase());
|
||||
@@ -369,6 +370,9 @@ doAccountTxJson(RPC::JsonContext& context)
|
||||
args.forward =
|
||||
params.isMember(jss::forward) && params[jss::forward].asBool();
|
||||
|
||||
args.strict =
|
||||
params.isMember(jss::strict) ? params[jss::strict].asBool() : true;
|
||||
|
||||
if (!params.isMember(jss::account))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
#include <magic/magic_enum.h>
|
||||
#include <sstream>
|
||||
|
||||
#define MAGIC_ENUM(x, _min, _max) \
|
||||
#define MAGIC_ENUM(x) \
|
||||
template <> \
|
||||
struct magic_enum::customize::enum_range<x> \
|
||||
{ \
|
||||
static constexpr int min = _min; \
|
||||
static constexpr int max = _max; \
|
||||
static constexpr int min = -20000; \
|
||||
static constexpr int max = 20000; \
|
||||
};
|
||||
|
||||
#define MAGIC_ENUM_16(x) \
|
||||
@@ -59,14 +59,14 @@
|
||||
static constexpr bool is_flags = true; \
|
||||
};
|
||||
|
||||
MAGIC_ENUM(ripple::SerializedTypeID, -2, 10004);
|
||||
MAGIC_ENUM(ripple::LedgerEntryType, 0, 255);
|
||||
MAGIC_ENUM(ripple::TELcodes, -399, 300);
|
||||
MAGIC_ENUM(ripple::TEMcodes, -299, -200);
|
||||
MAGIC_ENUM(ripple::TEFcodes, -199, -100);
|
||||
MAGIC_ENUM(ripple::TERcodes, -99, -1);
|
||||
MAGIC_ENUM(ripple::TEScodes, 0, 1);
|
||||
MAGIC_ENUM(ripple::TECcodes, 100, 255);
|
||||
MAGIC_ENUM(ripple::SerializedTypeID);
|
||||
MAGIC_ENUM(ripple::LedgerEntryType);
|
||||
MAGIC_ENUM(ripple::TELcodes);
|
||||
MAGIC_ENUM(ripple::TEMcodes);
|
||||
MAGIC_ENUM(ripple::TEFcodes);
|
||||
MAGIC_ENUM(ripple::TERcodes);
|
||||
MAGIC_ENUM(ripple::TEScodes);
|
||||
MAGIC_ENUM(ripple::TECcodes);
|
||||
MAGIC_ENUM_16(ripple::TxType);
|
||||
MAGIC_ENUM_FLAG(ripple::UniversalFlags);
|
||||
MAGIC_ENUM_FLAG(ripple::AccountSetFlags);
|
||||
@@ -464,9 +464,11 @@ public:
|
||||
{
|
||||
if (!defsHash)
|
||||
{
|
||||
static const uint256 fallbackHash(
|
||||
// should be unreachable
|
||||
// if this does happen we don't want 0 xor 0 so use a random value
|
||||
// here
|
||||
return uint256(
|
||||
"DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0");
|
||||
return fallbackHash;
|
||||
}
|
||||
return *defsHash;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@ class Discrepancy_test : public beast::unit_test::suite
|
||||
using namespace test::jtx;
|
||||
Env env{*this, features};
|
||||
|
||||
bool const withTouch = env.current()->rules().enabled(featureTouch);
|
||||
|
||||
Account A1{"A1"};
|
||||
Account A2{"A2"};
|
||||
Account A3{"A3"};
|
||||
@@ -109,8 +107,7 @@ class Discrepancy_test : public beast::unit_test::suite
|
||||
auto meta = jrr[jss::meta];
|
||||
uint64_t sumPrev{0};
|
||||
uint64_t sumFinal{0};
|
||||
BEAST_EXPECT(
|
||||
meta[sfAffectedNodes.fieldName].size() == withTouch ? 11 : 10);
|
||||
BEAST_EXPECT(meta[sfAffectedNodes.fieldName].size() == 9);
|
||||
for (auto const& an : meta[sfAffectedNodes.fieldName])
|
||||
{
|
||||
Json::Value node;
|
||||
@@ -130,17 +127,12 @@ class Discrepancy_test : public beast::unit_test::suite
|
||||
Json::Value finalFields = node.isMember(sfFinalFields.fieldName)
|
||||
? node[sfFinalFields.fieldName]
|
||||
: node[sfNewFields.fieldName];
|
||||
|
||||
// withTouch: "Touched" account does not update Balance
|
||||
if (prevFields.isMember(sfBalance.fieldName))
|
||||
{
|
||||
if (prevFields)
|
||||
sumPrev += beast::lexicalCastThrow<std::uint64_t>(
|
||||
prevFields[sfBalance.fieldName].asString());
|
||||
if (finalFields)
|
||||
sumFinal += beast::lexicalCastThrow<std::uint64_t>(
|
||||
finalFields[sfBalance.fieldName].asString());
|
||||
}
|
||||
if (prevFields)
|
||||
sumPrev += beast::lexicalCastThrow<std::uint64_t>(
|
||||
prevFields[sfBalance.fieldName].asString());
|
||||
if (finalFields)
|
||||
sumFinal += beast::lexicalCastThrow<std::uint64_t>(
|
||||
finalFields[sfBalance.fieldName].asString());
|
||||
}
|
||||
}
|
||||
// the difference in balances (final and prev) should be the
|
||||
@@ -155,7 +147,6 @@ public:
|
||||
using namespace test::jtx;
|
||||
auto const sa = supported_amendments();
|
||||
testXRPDiscrepancy(sa - featureFlowCross);
|
||||
testXRPDiscrepancy(sa - featureTouch);
|
||||
testXRPDiscrepancy(sa);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,6 @@ class Freeze_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
Env env(*this, features);
|
||||
bool const withTouch = env.current()->rules().enabled(featureTouch);
|
||||
|
||||
Account G1{"G1"};
|
||||
Account alice{"alice"};
|
||||
@@ -114,7 +113,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(trust(G1, bob["USD"](0), tfSetFreeze));
|
||||
auto affected = env.meta()->getJson(
|
||||
JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
|
||||
return;
|
||||
auto ff =
|
||||
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
|
||||
@@ -132,10 +131,10 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(offer(bob, G1["USD"](5), XRP(25)));
|
||||
auto affected = env.meta()->getJson(
|
||||
JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 6u : 5u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 5u)))
|
||||
return;
|
||||
auto ff = affected[withTouch ? 4u : 3u][sfModifiedNode.fieldName]
|
||||
[sfFinalFields.fieldName];
|
||||
auto ff =
|
||||
affected[3u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
|
||||
BEAST_EXPECT(
|
||||
ff[sfHighLimit.fieldName] ==
|
||||
bob["USD"](100).value().getJson(JsonOptions::none));
|
||||
@@ -200,7 +199,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(trust(G1, bob["USD"](0), tfClearFreeze));
|
||||
auto affected = env.meta()->getJson(
|
||||
JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
|
||||
return;
|
||||
auto ff =
|
||||
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
|
||||
@@ -378,7 +377,6 @@ class Freeze_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
Env env(*this, features);
|
||||
bool const withTouch = env.current()->rules().enabled(featureTouch);
|
||||
|
||||
Account G1{"G1"};
|
||||
Account A1{"A1"};
|
||||
@@ -419,7 +417,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(trust(G1, A1["USD"](0), tfSetFreeze));
|
||||
auto affected =
|
||||
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 2u : 1u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 1u)))
|
||||
return;
|
||||
|
||||
auto let =
|
||||
@@ -434,7 +432,6 @@ class Freeze_test : public beast::unit_test::suite
|
||||
|
||||
using namespace test::jtx;
|
||||
Env env(*this, features);
|
||||
bool const withTouch = env.current()->rules().enabled(featureTouch);
|
||||
|
||||
Account G1{"G1"};
|
||||
Account A2{"A2"};
|
||||
@@ -478,7 +475,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(trust(G1, A3["USD"](0), tfSetFreeze));
|
||||
auto affected =
|
||||
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
|
||||
return;
|
||||
auto ff =
|
||||
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
|
||||
@@ -508,10 +505,9 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env(trust(G1, A4["USD"](0), tfSetFreeze));
|
||||
affected =
|
||||
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
|
||||
return;
|
||||
ff = affected[withTouch ? 1u : 0u][sfModifiedNode.fieldName]
|
||||
[sfFinalFields.fieldName];
|
||||
ff = affected[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
|
||||
BEAST_EXPECT(
|
||||
ff[sfLowLimit.fieldName] ==
|
||||
G1["USD"](0).value().getJson(JsonOptions::none));
|
||||
@@ -525,7 +521,7 @@ class Freeze_test : public beast::unit_test::suite
|
||||
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
|
||||
if (!BEAST_EXPECT(checkArraySize(affected, 8u)))
|
||||
return;
|
||||
auto created = affected[5u][sfCreatedNode.fieldName];
|
||||
auto created = affected[0u][sfCreatedNode.fieldName];
|
||||
BEAST_EXPECT(
|
||||
created[sfNewFields.fieldName][jss::Account] == A2.human());
|
||||
env.close();
|
||||
@@ -547,9 +543,8 @@ public:
|
||||
testOffersWhenFrozen(features);
|
||||
};
|
||||
using namespace test::jtx;
|
||||
auto const sa = supported_amendments();
|
||||
auto const sa = supported_amendments() - featureXahauGenesis;
|
||||
testAll(sa - featureFlowCross);
|
||||
testAll(sa - featureTouch);
|
||||
testAll(sa);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2102,10 +2102,9 @@ struct Remit_test : public beast::unit_test::suite
|
||||
std::string result;
|
||||
TER code;
|
||||
};
|
||||
// We test only rates that that can fit in a STI_UINT32.
|
||||
// Negative rates can't be serdes so there is no need to test them.
|
||||
std::array<TestRateData, 9> testCases = {{
|
||||
std::array<TestRateData, 10> testCases = {{
|
||||
{0.0, USD(100), "900", tesSUCCESS},
|
||||
{-1.0, USD(100), "900", temBAD_TRANSFER_RATE},
|
||||
{0.9, USD(100), "900", temBAD_TRANSFER_RATE},
|
||||
{1.0, USD(100), "900", tesSUCCESS},
|
||||
{1.1, USD(100), "890", tesSUCCESS},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -245,6 +245,72 @@ class AccountTx_test : public beast::unit_test::suite
|
||||
p[jss::ledger_hash] = to_string(env.closed()->info().parentHash);
|
||||
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
|
||||
}
|
||||
|
||||
// Strict
|
||||
{
|
||||
Account S1{"S1"};
|
||||
Account S2{"S2"};
|
||||
Account S3{"S3"};
|
||||
env.fund(XRP(10000), S1);
|
||||
env.fund(XRP(10000), S2);
|
||||
env.fund(XRP(10000), S3);
|
||||
env.close();
|
||||
|
||||
// Regular key set
|
||||
env(regkey(S1, S2));
|
||||
env.close();
|
||||
|
||||
// we'll make a payment between S1 and S3
|
||||
env(pay(S1, S3, XRP(100)));
|
||||
env.close();
|
||||
|
||||
auto hasTxs = [](Json::Value const& j, bool strict) {
|
||||
if (!j.isMember(jss::result) ||
|
||||
j[jss::result][jss::status] != "success")
|
||||
return false;
|
||||
|
||||
std::cout << "hasTx " << (strict ? "strict" : "not strict")
|
||||
<< ":\n"
|
||||
<< to_string(j) << "\n";
|
||||
|
||||
if (strict)
|
||||
{
|
||||
return (j[jss::result][jss::transactions].size() == 3) &&
|
||||
(j[jss::result][jss::transactions][0u][jss::tx]
|
||||
[jss::TransactionType] == jss::SetRegularKey) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::TransactionType] == jss::AccountSet) &&
|
||||
(j[jss::result][jss::transactions][2u][jss::tx]
|
||||
[jss::TransactionType] == jss::Payment);
|
||||
}
|
||||
|
||||
return (j[jss::result][jss::transactions].size() == 4) &&
|
||||
(j[jss::result][jss::transactions][0u][jss::tx]
|
||||
[jss::TransactionType] == jss::Payment) &&
|
||||
(j[jss::result][jss::transactions][1u][jss::tx]
|
||||
[jss::TransactionType] == jss::SetRegularKey) &&
|
||||
(j[jss::result][jss::transactions][2u][jss::tx]
|
||||
[jss::TransactionType] == jss::AccountSet) &&
|
||||
(j[jss::result][jss::transactions][3u][jss::tx]
|
||||
[jss::TransactionType] == jss::Payment);
|
||||
};
|
||||
|
||||
Json::Value p{jParms};
|
||||
p[jss::account] = S2.human();
|
||||
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p)), true));
|
||||
|
||||
p[jss::strict] = true;
|
||||
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p)), true));
|
||||
|
||||
p[jss::strict] = false;
|
||||
|
||||
BEAST_EXPECT(
|
||||
hasTxs(env.rpc("json", "account_tx", to_string(p)), false));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1138,209 +1138,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<uint8_t> TshHook = {
|
||||
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x28U,
|
||||
0x06U, 0x60U, 0x05U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU,
|
||||
0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x00U,
|
||||
0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U,
|
||||
0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU,
|
||||
0x02U, 0x45U, 0x05U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x05U, 0x74U, 0x72U,
|
||||
0x61U, 0x63U, 0x65U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0AU,
|
||||
0x6FU, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x70U, 0x61U, 0x72U, 0x61U, 0x6DU,
|
||||
0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0AU, 0x68U, 0x6FU, 0x6FU,
|
||||
0x6BU, 0x5FU, 0x61U, 0x67U, 0x61U, 0x69U, 0x6EU, 0x00U, 0x02U, 0x03U,
|
||||
0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U,
|
||||
0x00U, 0x03U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U,
|
||||
0x04U, 0x03U, 0x02U, 0x01U, 0x05U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U,
|
||||
0x06U, 0x2BU, 0x07U, 0x7FU, 0x01U, 0x41U, 0xC0U, 0x8BU, 0x04U, 0x0BU,
|
||||
0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xBCU,
|
||||
0x0BU, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U,
|
||||
0x41U, 0xC0U, 0x8BU, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x00U, 0x0BU,
|
||||
0x7FU, 0x00U, 0x41U, 0x01U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U,
|
||||
0x6FU, 0x6FU, 0x6BU, 0x00U, 0x05U, 0x0AU, 0x8EU, 0x84U, 0x00U, 0x01U,
|
||||
0x8AU, 0x84U, 0x00U, 0x02U, 0x09U, 0x7EU, 0x05U, 0x7FU, 0x02U, 0x40U,
|
||||
0x02U, 0x40U, 0x23U, 0x00U, 0x21U, 0x0AU, 0x20U, 0x0AU, 0x41U, 0x10U,
|
||||
0x6BU, 0x21U, 0x0AU, 0x20U, 0x0AU, 0x24U, 0x00U, 0x20U, 0x0AU, 0x20U,
|
||||
0x00U, 0x36U, 0x02U, 0x0CU, 0x41U, 0x9EU, 0x0BU, 0x41U, 0x0FU, 0x41U,
|
||||
0xC1U, 0x09U, 0x41U, 0x0EU, 0x41U, 0x00U, 0x10U, 0x00U, 0x21U, 0x02U,
|
||||
0x20U, 0x02U, 0x1AU, 0x20U, 0x0AU, 0x41U, 0x0BU, 0x6AU, 0x21U, 0x00U,
|
||||
0x20U, 0x00U, 0x41U, 0x01U, 0x41U, 0xBDU, 0x09U, 0x41U, 0x03U, 0x10U,
|
||||
0x01U, 0x21U, 0x01U, 0x20U, 0x01U, 0x42U, 0x01U, 0x51U, 0x21U, 0x00U,
|
||||
0x20U, 0x00U, 0x41U, 0x01U, 0x71U, 0x21U, 0x00U, 0x20U, 0x00U, 0x45U,
|
||||
0x21U, 0x00U, 0x20U, 0x00U, 0x45U, 0x21U, 0x00U, 0x0BU, 0x20U, 0x00U,
|
||||
0x04U, 0x40U, 0x02U, 0x40U, 0x02U, 0x40U, 0x10U, 0x02U, 0x21U, 0x03U,
|
||||
0x20U, 0x03U, 0x1AU, 0x0BU, 0x01U, 0x0BU, 0x05U, 0x01U, 0x0BU, 0x0BU,
|
||||
0x02U, 0x7EU, 0x02U, 0x40U, 0x20U, 0x0AU, 0x28U, 0x02U, 0x0CU, 0x21U,
|
||||
0x00U, 0x02U, 0x40U, 0x02U, 0x40U, 0x02U, 0x40U, 0x02U, 0x40U, 0x02U,
|
||||
0x40U, 0x20U, 0x00U, 0x0EU, 0x03U, 0x02U, 0x01U, 0x00U, 0x04U, 0x0BU,
|
||||
0x02U, 0x40U, 0x02U, 0x40U, 0x02U, 0x40U, 0x41U, 0xDBU, 0x09U, 0x41U,
|
||||
0xC3U, 0x00U, 0x41U, 0x80U, 0x08U, 0x41U, 0xC2U, 0x00U, 0x41U, 0x00U,
|
||||
0x10U, 0x00U, 0x21U, 0x04U, 0x20U, 0x04U, 0x1AU, 0x0BU, 0x0CU, 0x06U,
|
||||
0x0BU, 0x00U, 0x0BU, 0x00U, 0x0BU, 0x02U, 0x40U, 0x02U, 0x40U, 0x02U,
|
||||
0x40U, 0x41U, 0x9FU, 0x0AU, 0x41U, 0x3DU, 0x41U, 0xC2U, 0x08U, 0x41U,
|
||||
0x3CU, 0x41U, 0x00U, 0x10U, 0x00U, 0x21U, 0x05U, 0x20U, 0x05U, 0x1AU,
|
||||
0x0BU, 0x0CU, 0x05U, 0x0BU, 0x00U, 0x0BU, 0x00U, 0x0BU, 0x02U, 0x40U,
|
||||
0x02U, 0x40U, 0x02U, 0x40U, 0x41U, 0xDDU, 0x0AU, 0x41U, 0xC0U, 0x00U,
|
||||
0x41U, 0xFEU, 0x08U, 0x41U, 0x3FU, 0x41U, 0x00U, 0x10U, 0x00U, 0x21U,
|
||||
0x06U, 0x20U, 0x06U, 0x1AU, 0x0BU, 0x01U, 0x0BU, 0x0BU, 0x0BU, 0x0BU,
|
||||
0x0BU, 0x02U, 0x7EU, 0x02U, 0x7EU, 0x41U, 0xAEU, 0x0BU, 0x41U, 0x0DU,
|
||||
0x41U, 0xCFU, 0x09U, 0x41U, 0x0CU, 0x41U, 0x00U, 0x10U, 0x00U, 0x21U,
|
||||
0x07U, 0x20U, 0x07U, 0x1AU, 0x20U, 0x0AU, 0x41U, 0x07U, 0x6AU, 0x21U,
|
||||
0x0CU, 0x20U, 0x0CU, 0x21U, 0x00U, 0x20U, 0x0AU, 0x20U, 0x00U, 0x36U,
|
||||
0x02U, 0x00U, 0x20U, 0x0AU, 0x28U, 0x02U, 0x0CU, 0x21U, 0x00U, 0x20U,
|
||||
0x00U, 0xADU, 0x21U, 0x01U, 0x20U, 0x01U, 0x42U, 0x18U, 0x88U, 0x21U,
|
||||
0x01U, 0x20U, 0x01U, 0x42U, 0xFFU, 0x01U, 0x83U, 0x21U, 0x01U, 0x20U,
|
||||
0x01U, 0xA7U, 0x21U, 0x00U, 0x20U, 0x0AU, 0x28U, 0x02U, 0x00U, 0x21U,
|
||||
0x0BU, 0x20U, 0x0BU, 0x20U, 0x00U, 0x3AU, 0x00U, 0x00U, 0x20U, 0x0AU,
|
||||
0x28U, 0x02U, 0x0CU, 0x21U, 0x00U, 0x20U, 0x00U, 0xADU, 0x21U, 0x01U,
|
||||
0x20U, 0x01U, 0x42U, 0x10U, 0x88U, 0x21U, 0x01U, 0x20U, 0x01U, 0x42U,
|
||||
0xFFU, 0x01U, 0x83U, 0x21U, 0x01U, 0x20U, 0x01U, 0xA7U, 0x21U, 0x00U,
|
||||
0x20U, 0x0AU, 0x28U, 0x02U, 0x00U, 0x21U, 0x0BU, 0x20U, 0x0BU, 0x20U,
|
||||
0x00U, 0x3AU, 0x00U, 0x01U, 0x20U, 0x0AU, 0x28U, 0x02U, 0x0CU, 0x21U,
|
||||
0x00U, 0x20U, 0x00U, 0xADU, 0x21U, 0x01U, 0x20U, 0x01U, 0x42U, 0x08U,
|
||||
0x88U, 0x21U, 0x01U, 0x20U, 0x01U, 0x42U, 0xFFU, 0x01U, 0x83U, 0x21U,
|
||||
0x01U, 0x20U, 0x01U, 0xA7U, 0x21U, 0x00U, 0x20U, 0x0AU, 0x28U, 0x02U,
|
||||
0x00U, 0x21U, 0x0BU, 0x20U, 0x0BU, 0x20U, 0x00U, 0x3AU, 0x00U, 0x02U,
|
||||
0x20U, 0x0AU, 0x28U, 0x02U, 0x0CU, 0x21U, 0x00U, 0x20U, 0x00U, 0xADU,
|
||||
0x21U, 0x01U, 0x20U, 0x01U, 0x42U, 0x00U, 0x88U, 0x21U, 0x01U, 0x20U,
|
||||
0x01U, 0x42U, 0xFFU, 0x01U, 0x83U, 0x21U, 0x01U, 0x20U, 0x01U, 0xA7U,
|
||||
0x21U, 0x00U, 0x20U, 0x0AU, 0x28U, 0x02U, 0x00U, 0x21U, 0x0BU, 0x20U,
|
||||
0x0BU, 0x20U, 0x00U, 0x3AU, 0x00U, 0x03U, 0x20U, 0x0CU, 0x21U, 0x00U,
|
||||
0x20U, 0x00U, 0x41U, 0x04U, 0x42U, 0x1CU, 0x10U, 0x03U, 0x21U, 0x08U,
|
||||
0x20U, 0x08U, 0x1AU, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x04U, 0x21U,
|
||||
0x0DU, 0x20U, 0x0DU, 0x1AU, 0x20U, 0x0AU, 0x41U, 0x10U, 0x6AU, 0x21U,
|
||||
0x00U, 0x20U, 0x00U, 0x24U, 0x00U, 0x42U, 0x00U, 0x21U, 0x09U, 0x42U,
|
||||
0x00U, 0x0BU, 0x0BU, 0x0BU, 0x0BU, 0x0BU, 0xC3U, 0x03U, 0x01U, 0x00U,
|
||||
0x41U, 0x80U, 0x08U, 0x0BU, 0xBBU, 0x03U, 0x74U, 0x73U, 0x68U, 0x2EU,
|
||||
0x63U, 0x3AU, 0x20U, 0x57U, 0x65U, 0x61U, 0x6BU, 0x20U, 0x41U, 0x67U,
|
||||
0x61U, 0x69U, 0x6EU, 0x2EU, 0x20U, 0x45U, 0x78U, 0x65U, 0x63U, 0x75U,
|
||||
0x74U, 0x65U, 0x20U, 0x41U, 0x46U, 0x54U, 0x45U, 0x52U, 0x20U, 0x74U,
|
||||
0x72U, 0x61U, 0x6EU, 0x73U, 0x61U, 0x63U, 0x74U, 0x69U, 0x6FU, 0x6EU,
|
||||
0x20U, 0x69U, 0x73U, 0x20U, 0x61U, 0x70U, 0x70U, 0x6CU, 0x69U, 0x65U,
|
||||
0x64U, 0x20U, 0x74U, 0x6FU, 0x20U, 0x6CU, 0x65U, 0x64U, 0x67U, 0x65U,
|
||||
0x72U, 0x00U, 0x74U, 0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU, 0x20U, 0x57U,
|
||||
0x65U, 0x61U, 0x6BU, 0x2EU, 0x20U, 0x45U, 0x78U, 0x65U, 0x63U, 0x75U,
|
||||
0x74U, 0x65U, 0x20U, 0x41U, 0x46U, 0x54U, 0x45U, 0x52U, 0x20U, 0x74U,
|
||||
0x72U, 0x61U, 0x6EU, 0x73U, 0x61U, 0x63U, 0x74U, 0x69U, 0x6FU, 0x6EU,
|
||||
0x20U, 0x69U, 0x73U, 0x20U, 0x61U, 0x70U, 0x70U, 0x6CU, 0x69U, 0x65U,
|
||||
0x64U, 0x20U, 0x74U, 0x6FU, 0x20U, 0x6CU, 0x65U, 0x64U, 0x67U, 0x65U,
|
||||
0x72U, 0x00U, 0x74U, 0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU, 0x20U, 0x53U,
|
||||
0x74U, 0x72U, 0x6FU, 0x6EU, 0x67U, 0x2EU, 0x20U, 0x45U, 0x78U, 0x65U,
|
||||
0x63U, 0x75U, 0x74U, 0x65U, 0x20U, 0x42U, 0x45U, 0x46U, 0x4FU, 0x52U,
|
||||
0x45U, 0x20U, 0x74U, 0x72U, 0x61U, 0x6EU, 0x73U, 0x61U, 0x63U, 0x74U,
|
||||
0x69U, 0x6FU, 0x6EU, 0x20U, 0x69U, 0x73U, 0x20U, 0x61U, 0x70U, 0x70U,
|
||||
0x6CU, 0x69U, 0x65U, 0x64U, 0x20U, 0x74U, 0x6FU, 0x20U, 0x6CU, 0x65U,
|
||||
0x64U, 0x67U, 0x65U, 0x72U, 0x00U, 0x41U, 0x41U, 0x57U, 0x00U, 0x74U,
|
||||
0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU, 0x20U, 0x53U, 0x74U, 0x61U, 0x72U,
|
||||
0x74U, 0x2EU, 0x00U, 0x74U, 0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU, 0x20U,
|
||||
0x45U, 0x6EU, 0x64U, 0x2EU, 0x00U, 0x22U, 0x74U, 0x73U, 0x68U, 0x2EU,
|
||||
0x63U, 0x3AU, 0x20U, 0x57U, 0x65U, 0x61U, 0x6BU, 0x20U, 0x41U, 0x67U,
|
||||
0x61U, 0x69U, 0x6EU, 0x2EU, 0x20U, 0x45U, 0x78U, 0x65U, 0x63U, 0x75U,
|
||||
0x74U, 0x65U, 0x20U, 0x41U, 0x46U, 0x54U, 0x45U, 0x52U, 0x20U, 0x74U,
|
||||
0x72U, 0x61U, 0x6EU, 0x73U, 0x61U, 0x63U, 0x74U, 0x69U, 0x6FU, 0x6EU,
|
||||
0x20U, 0x69U, 0x73U, 0x20U, 0x61U, 0x70U, 0x70U, 0x6CU, 0x69U, 0x65U,
|
||||
0x64U, 0x20U, 0x74U, 0x6FU, 0x20U, 0x6CU, 0x65U, 0x64U, 0x67U, 0x65U,
|
||||
0x72U, 0x22U, 0x00U, 0x22U, 0x74U, 0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU,
|
||||
0x20U, 0x57U, 0x65U, 0x61U, 0x6BU, 0x2EU, 0x20U, 0x45U, 0x78U, 0x65U,
|
||||
0x63U, 0x75U, 0x74U, 0x65U, 0x20U, 0x41U, 0x46U, 0x54U, 0x45U, 0x52U,
|
||||
0x20U, 0x74U, 0x72U, 0x61U, 0x6EU, 0x73U, 0x61U, 0x63U, 0x74U, 0x69U,
|
||||
0x6FU, 0x6EU, 0x20U, 0x69U, 0x73U, 0x20U, 0x61U, 0x70U, 0x70U, 0x6CU,
|
||||
0x69U, 0x65U, 0x64U, 0x20U, 0x74U, 0x6FU, 0x20U, 0x6CU, 0x65U, 0x64U,
|
||||
0x67U, 0x65U, 0x72U, 0x22U, 0x00U, 0x22U, 0x74U, 0x73U, 0x68U, 0x2EU,
|
||||
0x63U, 0x3AU, 0x20U, 0x53U, 0x74U, 0x72U, 0x6FU, 0x6EU, 0x67U, 0x2EU,
|
||||
0x20U, 0x45U, 0x78U, 0x65U, 0x63U, 0x75U, 0x74U, 0x65U, 0x20U, 0x42U,
|
||||
0x45U, 0x46U, 0x4FU, 0x52U, 0x45U, 0x20U, 0x74U, 0x72U, 0x61U, 0x6EU,
|
||||
0x73U, 0x61U, 0x63U, 0x74U, 0x69U, 0x6FU, 0x6EU, 0x20U, 0x69U, 0x73U,
|
||||
0x20U, 0x61U, 0x70U, 0x70U, 0x6CU, 0x69U, 0x65U, 0x64U, 0x20U, 0x74U,
|
||||
0x6FU, 0x20U, 0x6CU, 0x65U, 0x64U, 0x67U, 0x65U, 0x72U, 0x22U, 0x00U,
|
||||
0x22U, 0x74U, 0x73U, 0x68U, 0x2EU, 0x63U, 0x3AU, 0x20U, 0x53U, 0x74U,
|
||||
0x61U, 0x72U, 0x74U, 0x2EU, 0x22U, 0x00U, 0x22U, 0x74U, 0x73U, 0x68U,
|
||||
0x2EU, 0x63U, 0x3AU, 0x20U, 0x45U, 0x6EU, 0x64U, 0x2EU, 0x22U};
|
||||
|
||||
void static overrideFlag(Json::Value& jv)
|
||||
{
|
||||
jv[jss::Flags] = 0b00000001U;
|
||||
}
|
||||
|
||||
void
|
||||
setTSHHook(jtx::Env& env, jtx::Account const& account)
|
||||
{
|
||||
using namespace test::jtx;
|
||||
env(hook(account, {{hso(TshHook, overrideFlag)}}, 0),
|
||||
fee(XRP(2)),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
}
|
||||
|
||||
void
|
||||
testAccount(FeatureBitset features)
|
||||
{
|
||||
testcase("AccountWithHookStream");
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace jtx;
|
||||
Env env(*this, features);
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
auto const gw = Account("gw");
|
||||
auto const USD = gw["USD"];
|
||||
|
||||
env.fund(XRP(10000), alice, bob, gw);
|
||||
env.trust(USD(20000), alice, bob);
|
||||
env.close();
|
||||
|
||||
auto wsc = makeWSClient(env.app().config());
|
||||
Json::Value stream;
|
||||
|
||||
bool const withTouch = env.current()->rules().enabled(featureTouch);
|
||||
{
|
||||
// RPC subscribe to account stream
|
||||
stream[jss::accounts] = Json::arrayValue;
|
||||
stream[jss::accounts].append(bob.human());
|
||||
auto jv = wsc->invoke("subscribe", stream);
|
||||
if (wsc->version() == 2)
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
|
||||
BEAST_EXPECT(
|
||||
jv.isMember(jss::ripplerpc) && jv[jss::ripplerpc] == "2.0");
|
||||
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
|
||||
}
|
||||
BEAST_EXPECT(jv[jss::result][jss::status] == "success");
|
||||
}
|
||||
|
||||
// Test Invoke Tx
|
||||
{
|
||||
setTSHHook(env, bob);
|
||||
// Submit and Close
|
||||
env(invoke::invoke(alice),
|
||||
invoke::dest(bob),
|
||||
fee(XRP(1)),
|
||||
ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
// Check stream update
|
||||
BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) {
|
||||
if (jv[jss::transaction][jss::TransactionType] == "Invoke")
|
||||
return true;
|
||||
return withTouch ? false : true;
|
||||
}));
|
||||
}
|
||||
|
||||
// RPC unsubscribe
|
||||
auto jv = wsc->invoke("unsubscribe", stream);
|
||||
if (wsc->version() == 2)
|
||||
{
|
||||
BEAST_EXPECT(
|
||||
jv.isMember(jss::jsonrpc) && jv[jss::jsonrpc] == "2.0");
|
||||
BEAST_EXPECT(
|
||||
jv.isMember(jss::ripplerpc) && jv[jss::ripplerpc] == "2.0");
|
||||
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
|
||||
}
|
||||
BEAST_EXPECT(jv[jss::status] == "success");
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -1358,8 +1155,6 @@ public:
|
||||
testSubErrors(false);
|
||||
testSubByUrl();
|
||||
testHistoryTxStream();
|
||||
testAccount(all);
|
||||
testAccount(all - featureTouch);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user