Compare commits

...

15 Commits

Author SHA1 Message Date
Denis Angell
8e4d75ec39 fix local building 2025-03-28 14:21:53 +01:00
Niq Dudfield
0b675465b4 Fix ServerDefinitions_test regression intro in #475 (#477) 2025-03-19 12:32:27 +10:00
Niq Dudfield
d088ad61a9 Prevent dangling reference in getHash() (#475)
Replace temporary uint256 with static variable when returning fallback hash
to avoid returning a const reference to a local temporary object.
2025-03-18 18:37:18 +10:00
Niq Dudfield
ef77b02d7f CI Release Builder (#455) 2025-03-11 13:19:28 +01:00
RichardAH
7385828983 Touch Amendment (#294) 2025-03-06 08:25:42 +01:00
Niq Dudfield
88b01514c1 fix: remove negative rate test failing on MacOS (#452) 2025-03-03 13:12:13 +01:00
Denis Angell
aeece15096 [fix] github runner (#451)
Co-authored-by: Niq Dudfield <ndudfield@gmail.com>
2025-03-03 09:55:51 +01:00
tequ
89cacb1258 Enhance shell script error handling and debugging on GHA (#447) 2025-02-24 10:33:21 +01:00
tequ
8ccff44e8c Fix Error handling on build action (#412) 2025-02-24 18:16:21 +10:00
tequ
420240a2ab Fixed not to use a large fixed range in the magic_enum. (#436) 2025-02-24 17:46:42 +10:00
Richard Holland
230873f196 debug gh builds 2025-02-06 15:21:37 +11:00
Wietse Wind
1fb1a99ea2 Update build-in-docker.yml 2025-02-05 08:23:49 +01:00
Richard Holland
e0b63ac70e Revert "debug account tx tests under release builder"
This reverts commit da8df63be3.

Revert "add strict filtering to account_tx api (#429)"

This reverts commit 317bd4bc6e.
2025-02-05 14:59:33 +11:00
Richard Holland
da8df63be3 debug account tx tests under release builder 2025-02-04 17:02:17 +11:00
RichardAH
317bd4bc6e add strict filtering to account_tx api (#429) 2025-02-03 17:56:08 +10:00
18 changed files with 1831 additions and 63 deletions

View File

@@ -2,37 +2,104 @@ name: Build using Docker
on: on:
push: push:
branches: [ "dev", "candidate", "release", "jshooks" ] branches: ["dev", "candidate", "release", "jshooks"]
pull_request: pull_request:
branches: [ "dev", "candidate", "release", "jshooks" ] branches: ["dev", "candidate", "release", "jshooks"]
concurrency: concurrency:
group: ${{ github.workflow }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false cancel-in-progress: true
env:
DEBUG_BUILD_CONTAINERS_AFTER_CLEANUP: 1
jobs: jobs:
checkout: checkout:
runs-on: [self-hosted, vanity] runs-on: [self-hosted, vanity]
outputs:
checkout_path: ${{ steps.vars.outputs.checkout_path }}
steps: steps:
- uses: actions/checkout@v3 - name: Prepare checkout path
with: id: vars
clean: false 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
checkpatterns: checkpatterns:
runs-on: [self-hosted, vanity] runs-on: [self-hosted, vanity]
needs: checkout needs: checkout
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps: steps:
- name: Check for suspicious patterns - name: Check for suspicious patterns
run: /bin/bash suspicious_patterns.sh run: /bin/bash suspicious_patterns.sh
build: build:
runs-on: [self-hosted, vanity] runs-on: [self-hosted, vanity]
needs: checkpatterns needs: [checkpatterns, checkout]
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps: steps:
- name: Build using Docker - name: Set Cleanup Script Path
run: /bin/bash release-builder.sh 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
tests: tests:
runs-on: [self-hosted, vanity] runs-on: [self-hosted, vanity]
needs: build needs: [build, checkout]
defaults:
run:
working-directory: ${{ needs.checkout.outputs.checkout_path }}
steps: steps:
- name: Unit tests - name: Unit tests
run: /bin/bash docker-unit-tests.sh 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}"

View File

@@ -755,6 +755,7 @@ if (tests)
src/test/app/Taker_test.cpp src/test/app/Taker_test.cpp
src/test/app/TheoreticalQuality_test.cpp src/test/app/TheoreticalQuality_test.cpp
src/test/app/Ticket_test.cpp src/test/app/Ticket_test.cpp
src/test/app/Touch_test.cpp
src/test/app/Transaction_ordering_test.cpp src/test/app/Transaction_ordering_test.cpp
src/test/app/TrustAndBalance_test.cpp src/test/app/TrustAndBalance_test.cpp
src/test/app/TxQ_test.cpp src/test/app/TxQ_test.cpp

View File

@@ -1,4 +1,11 @@
#!/bin/bash #!/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
echo "START INSIDE CONTAINER - CORE" echo "START INSIDE CONTAINER - CORE"
@@ -23,7 +30,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 && 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 && mv Builds/CMake/deps/WasmEdge.cmake Builds/CMake/deps/WasmEdge.old &&
echo "find_package(LLVM REQUIRED CONFIG) 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}\") message(STATUS \"Using LLVMConfig.cmake in: \${LLVM_DIR}\")
add_library (wasmedge STATIC IMPORTED GLOBAL) add_library (wasmedge STATIC IMPORTED GLOBAL)
set_target_properties(wasmedge PROPERTIES IMPORTED_LOCATION \${WasmEdge_LIB}) set_target_properties(wasmedge PROPERTIES IMPORTED_LOCATION \${WasmEdge_LIB})

View File

@@ -1,4 +1,11 @@
#!/bin/bash #!/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
echo "START INSIDE CONTAINER - FULL" echo "START INSIDE CONTAINER - FULL"
@@ -19,7 +26,7 @@ yum-config-manager --disable centos-sclo-sclo
#### ####
cd /io; cd /io;
mkdir src/certs; mkdir -p src/certs;
curl --silent -k https://raw.githubusercontent.com/RichardAH/rippled-release-builder/main/ca-bundle/certbundle.h -o src/certs/certbundle.h; 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" ] if [ "`grep certbundle.h src/ripple/net/impl/RegisterSSLCerts.cpp | wc -l`" -eq "0" ]
then then
@@ -66,8 +73,8 @@ then
#endif/g" src/ripple/net/impl/RegisterSSLCerts.cpp && #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 sed -i "s/#include <ripple\/net\/RegisterSSLCerts.h>/\0\n#include <certs\/certbundle.h>/g" src/ripple/net/impl/RegisterSSLCerts.cpp
fi fi
mkdir .nih_c; mkdir -p .nih_c;
mkdir .nih_toolchain; mkdir -p .nih_toolchain;
cd .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 \ 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++ \ devtoolset-7-gcc-c++ \
@@ -115,7 +122,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/ && 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 && cd lld-13.0.1.src &&
rm -rf build CMakeCache.txt && rm -rf build CMakeCache.txt &&
mkdir build && mkdir -p build &&
cd build && cd build &&
cmake .. -DLLVM_LIBRARY_DIR=/usr/lib64/llvm13/lib/ -DCMAKE_INSTALL_PREFIX=/usr/lib64/llvm13/ -DCMAKE_BUILD_TYPE=Release && cmake .. -DLLVM_LIBRARY_DIR=/usr/lib64/llvm13/lib/ -DCMAKE_INSTALL_PREFIX=/usr/lib64/llvm13/ -DCMAKE_BUILD_TYPE=Release &&
make -j$3 install && make -j$3 install &&
@@ -125,7 +132,7 @@ cd ../../ &&
echo "-- Build WasmEdge --" && echo "-- Build WasmEdge --" &&
( wget -nc -q https://github.com/WasmEdge/WasmEdge/archive/refs/tags/0.11.2.zip; unzip -o 0.11.2.zip; ) && ( 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 && cd WasmEdge-0.11.2 &&
( mkdir build; echo "" ) && ( mkdir -p build; echo "" ) &&
cd build && cd build &&
export BOOST_ROOT="/usr/local/src/boost_1_86_0" && export BOOST_ROOT="/usr/local/src/boost_1_86_0" &&
export Boost_LIBRARY_DIRS="/usr/local/lib" && export Boost_LIBRARY_DIRS="/usr/local/lib" &&

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/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' docker run --rm -i -v $(pwd):/io ubuntu sh -c '/io/release-build/xahaud -u'

View File

@@ -1,4 +1,9 @@
#!/bin/bash #!/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
echo "START BUILDING (HOST)" echo "START BUILDING (HOST)"
@@ -6,13 +11,37 @@ echo "Cleaning previously built binary"
rm -f release-build/xahaud rm -f release-build/xahaud
BUILD_CORES=$(echo "scale=0 ; `nproc` / 1.337" | bc) 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 if [[ "$GITHUB_REPOSITORY" == "" ]]; then
#Default #Default
BUILD_CORES=8 BUILD_CORES=8
fi fi
CONTAINER_NAME=xahaud_cached_builder_$(echo "$GITHUB_ACTOR" | awk '{print tolower($0)}') 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
echo "-- BUILD CORES: $BUILD_CORES" echo "-- BUILD CORES: $BUILD_CORES"
echo "-- GITHUB_REPOSITORY: $GITHUB_REPOSITORY" echo "-- GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
@@ -36,7 +65,8 @@ fi
STATIC_CONTAINER=$(docker ps -a | grep $CONTAINER_NAME |wc -l) STATIC_CONTAINER=$(docker ps -a | grep $CONTAINER_NAME |wc -l)
if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then #if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then
if false; then
echo "Static container, execute in static container to have max. cache" echo "Static container, execute in static container to have max. cache"
docker start $CONTAINER_NAME 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" docker exec -i $CONTAINER_NAME /hbb_exe/activate-exec bash -x /io/build-core.sh "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$BUILD_CORES" "$GITHUB_RUN_NUMBER"
@@ -54,6 +84,8 @@ else
# GH Action, runner # GH Action, runner
echo "GH Action, runner, clean & re-create create persistent container" echo "GH Action, runner, clean & re-create create persistent container"
docker rm -f $CONTAINER_NAME 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 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 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 docker stop $CONTAINER_NAME

View File

@@ -1079,6 +1079,24 @@ 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 static void
removeUnfundedOffers( removeUnfundedOffers(
ApplyView& view, ApplyView& view,
@@ -1519,6 +1537,8 @@ Transactor::doTSH(
if ((!canRollback && strong) || (canRollback && !strong)) if ((!canRollback && strong) || (canRollback && !strong))
continue; continue;
touchAccount(view, tshAccountID);
auto klTshHook = keylet::hook(tshAccountID); auto klTshHook = keylet::hook(tshAccountID);
auto tshHook = view.read(klTshHook); auto tshHook = view.read(klTshHook);

View File

@@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how // 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 // 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. // the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 77; static constexpr std::size_t numFeatures = 78;
/** Amendments that this server supports and the default voting behavior. /** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated Whether they are enabled depends on the Rules defined in the validated
@@ -362,6 +362,7 @@ extern uint256 const fix240819;
extern uint256 const fixPageCap; extern uint256 const fixPageCap;
extern uint256 const fix240911; extern uint256 const fix240911;
extern uint256 const fixFloatDivide; extern uint256 const fixFloatDivide;
extern uint256 const featureTouch;
extern uint256 const fixReduceImport; extern uint256 const fixReduceImport;
extern uint256 const fixXahauV3; extern uint256 const fixXahauV3;
extern uint256 const fix20250131; extern uint256 const fix20250131;

View File

@@ -433,6 +433,7 @@ extern SF_UINT64 const sfReferenceCount;
extern SF_UINT64 const sfRewardAccumulator; extern SF_UINT64 const sfRewardAccumulator;
extern SF_UINT64 const sfAccountCount; extern SF_UINT64 const sfAccountCount;
extern SF_UINT64 const sfAccountIndex; extern SF_UINT64 const sfAccountIndex;
extern SF_UINT64 const sfTouchCount;
// 128-bit // 128-bit
extern SF_UINT128 const sfEmailHash; extern SF_UINT128 const sfEmailHash;

View File

@@ -468,6 +468,7 @@ REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::De
REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixFloatDivide, 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 (fixReduceImport, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fix20250131, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FIX (fix20250131, Supported::yes, VoteBehavior::DefaultYes);

View File

@@ -66,6 +66,7 @@ LedgerFormats::LedgerFormats()
{sfGovernanceFlags, soeOPTIONAL}, {sfGovernanceFlags, soeOPTIONAL},
{sfGovernanceMarks, soeOPTIONAL}, {sfGovernanceMarks, soeOPTIONAL},
{sfAccountIndex, soeOPTIONAL}, {sfAccountIndex, soeOPTIONAL},
{sfTouchCount, soeOPTIONAL},
}, },
commonFields); commonFields);

View File

@@ -183,6 +183,7 @@ CONSTRUCT_TYPED_SFIELD(sfEmitBurden, "EmitBurden", UINT64,
CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17); CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17);
CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18); CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18);
CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19); CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19);
CONSTRUCT_TYPED_SFIELD(sfTouchCount, "TouchCount", UINT64, 97);
CONSTRUCT_TYPED_SFIELD(sfAccountIndex, "AccountIndex", UINT64, 98); CONSTRUCT_TYPED_SFIELD(sfAccountIndex, "AccountIndex", UINT64, 98);
CONSTRUCT_TYPED_SFIELD(sfAccountCount, "AccountCount", UINT64, 99); CONSTRUCT_TYPED_SFIELD(sfAccountCount, "AccountCount", UINT64, 99);
CONSTRUCT_TYPED_SFIELD(sfRewardAccumulator, "RewardAccumulator", UINT64, 100); CONSTRUCT_TYPED_SFIELD(sfRewardAccumulator, "RewardAccumulator", UINT64, 100);

View File

@@ -36,12 +36,12 @@
#include <magic/magic_enum.h> #include <magic/magic_enum.h>
#include <sstream> #include <sstream>
#define MAGIC_ENUM(x) \ #define MAGIC_ENUM(x, _min, _max) \
template <> \ template <> \
struct magic_enum::customize::enum_range<x> \ struct magic_enum::customize::enum_range<x> \
{ \ { \
static constexpr int min = -20000; \ static constexpr int min = _min; \
static constexpr int max = 20000; \ static constexpr int max = _max; \
}; };
#define MAGIC_ENUM_16(x) \ #define MAGIC_ENUM_16(x) \
@@ -59,14 +59,14 @@
static constexpr bool is_flags = true; \ static constexpr bool is_flags = true; \
}; };
MAGIC_ENUM(ripple::SerializedTypeID); MAGIC_ENUM(ripple::SerializedTypeID, -2, 10004);
MAGIC_ENUM(ripple::LedgerEntryType); MAGIC_ENUM(ripple::LedgerEntryType, 0, 255);
MAGIC_ENUM(ripple::TELcodes); MAGIC_ENUM(ripple::TELcodes, -399, 300);
MAGIC_ENUM(ripple::TEMcodes); MAGIC_ENUM(ripple::TEMcodes, -299, -200);
MAGIC_ENUM(ripple::TEFcodes); MAGIC_ENUM(ripple::TEFcodes, -199, -100);
MAGIC_ENUM(ripple::TERcodes); MAGIC_ENUM(ripple::TERcodes, -99, -1);
MAGIC_ENUM(ripple::TEScodes); MAGIC_ENUM(ripple::TEScodes, 0, 1);
MAGIC_ENUM(ripple::TECcodes); MAGIC_ENUM(ripple::TECcodes, 100, 255);
MAGIC_ENUM_16(ripple::TxType); MAGIC_ENUM_16(ripple::TxType);
MAGIC_ENUM_FLAG(ripple::UniversalFlags); MAGIC_ENUM_FLAG(ripple::UniversalFlags);
MAGIC_ENUM_FLAG(ripple::AccountSetFlags); MAGIC_ENUM_FLAG(ripple::AccountSetFlags);
@@ -464,11 +464,9 @@ public:
{ {
if (!defsHash) if (!defsHash)
{ {
// should be unreachable static const uint256 fallbackHash(
// if this does happen we don't want 0 xor 0 so use a random value
// here
return uint256(
"DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0"); "DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0");
return fallbackHash;
} }
return *defsHash; return *defsHash;
} }

View File

@@ -42,6 +42,8 @@ class Discrepancy_test : public beast::unit_test::suite
using namespace test::jtx; using namespace test::jtx;
Env env{*this, features}; Env env{*this, features};
bool const withTouch = env.current()->rules().enabled(featureTouch);
Account A1{"A1"}; Account A1{"A1"};
Account A2{"A2"}; Account A2{"A2"};
Account A3{"A3"}; Account A3{"A3"};
@@ -107,7 +109,8 @@ class Discrepancy_test : public beast::unit_test::suite
auto meta = jrr[jss::meta]; auto meta = jrr[jss::meta];
uint64_t sumPrev{0}; uint64_t sumPrev{0};
uint64_t sumFinal{0}; uint64_t sumFinal{0};
BEAST_EXPECT(meta[sfAffectedNodes.fieldName].size() == 9); BEAST_EXPECT(
meta[sfAffectedNodes.fieldName].size() == withTouch ? 11 : 10);
for (auto const& an : meta[sfAffectedNodes.fieldName]) for (auto const& an : meta[sfAffectedNodes.fieldName])
{ {
Json::Value node; Json::Value node;
@@ -127,12 +130,17 @@ class Discrepancy_test : public beast::unit_test::suite
Json::Value finalFields = node.isMember(sfFinalFields.fieldName) Json::Value finalFields = node.isMember(sfFinalFields.fieldName)
? node[sfFinalFields.fieldName] ? node[sfFinalFields.fieldName]
: node[sfNewFields.fieldName]; : node[sfNewFields.fieldName];
if (prevFields)
sumPrev += beast::lexicalCastThrow<std::uint64_t>( // withTouch: "Touched" account does not update Balance
prevFields[sfBalance.fieldName].asString()); if (prevFields.isMember(sfBalance.fieldName))
if (finalFields) {
sumFinal += beast::lexicalCastThrow<std::uint64_t>( if (prevFields)
finalFields[sfBalance.fieldName].asString()); 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 // the difference in balances (final and prev) should be the
@@ -147,6 +155,7 @@ public:
using namespace test::jtx; using namespace test::jtx;
auto const sa = supported_amendments(); auto const sa = supported_amendments();
testXRPDiscrepancy(sa - featureFlowCross); testXRPDiscrepancy(sa - featureFlowCross);
testXRPDiscrepancy(sa - featureTouch);
testXRPDiscrepancy(sa); testXRPDiscrepancy(sa);
} }
}; };

View File

@@ -60,6 +60,7 @@ class Freeze_test : public beast::unit_test::suite
using namespace test::jtx; using namespace test::jtx;
Env env(*this, features); Env env(*this, features);
bool const withTouch = env.current()->rules().enabled(featureTouch);
Account G1{"G1"}; Account G1{"G1"};
Account alice{"alice"}; Account alice{"alice"};
@@ -113,7 +114,7 @@ class Freeze_test : public beast::unit_test::suite
env(trust(G1, bob["USD"](0), tfSetFreeze)); env(trust(G1, bob["USD"](0), tfSetFreeze));
auto affected = env.meta()->getJson( auto affected = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName]; JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
return; return;
auto ff = auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
@@ -131,10 +132,10 @@ class Freeze_test : public beast::unit_test::suite
env(offer(bob, G1["USD"](5), XRP(25))); env(offer(bob, G1["USD"](5), XRP(25)));
auto affected = env.meta()->getJson( auto affected = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName]; JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 5u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 6u : 5u)))
return; return;
auto ff = auto ff = affected[withTouch ? 4u : 3u][sfModifiedNode.fieldName]
affected[3u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; [sfFinalFields.fieldName];
BEAST_EXPECT( BEAST_EXPECT(
ff[sfHighLimit.fieldName] == ff[sfHighLimit.fieldName] ==
bob["USD"](100).value().getJson(JsonOptions::none)); bob["USD"](100).value().getJson(JsonOptions::none));
@@ -199,7 +200,7 @@ class Freeze_test : public beast::unit_test::suite
env(trust(G1, bob["USD"](0), tfClearFreeze)); env(trust(G1, bob["USD"](0), tfClearFreeze));
auto affected = env.meta()->getJson( auto affected = env.meta()->getJson(
JsonOptions::none)[sfAffectedNodes.fieldName]; JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
return; return;
auto ff = auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
@@ -377,6 +378,7 @@ class Freeze_test : public beast::unit_test::suite
using namespace test::jtx; using namespace test::jtx;
Env env(*this, features); Env env(*this, features);
bool const withTouch = env.current()->rules().enabled(featureTouch);
Account G1{"G1"}; Account G1{"G1"};
Account A1{"A1"}; Account A1{"A1"};
@@ -417,7 +419,7 @@ class Freeze_test : public beast::unit_test::suite
env(trust(G1, A1["USD"](0), tfSetFreeze)); env(trust(G1, A1["USD"](0), tfSetFreeze));
auto affected = auto affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 1u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 2u : 1u)))
return; return;
auto let = auto let =
@@ -432,6 +434,7 @@ class Freeze_test : public beast::unit_test::suite
using namespace test::jtx; using namespace test::jtx;
Env env(*this, features); Env env(*this, features);
bool const withTouch = env.current()->rules().enabled(featureTouch);
Account G1{"G1"}; Account G1{"G1"};
Account A2{"A2"}; Account A2{"A2"};
@@ -475,7 +478,7 @@ class Freeze_test : public beast::unit_test::suite
env(trust(G1, A3["USD"](0), tfSetFreeze)); env(trust(G1, A3["USD"](0), tfSetFreeze));
auto affected = auto affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
return; return;
auto ff = auto ff =
affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
@@ -505,9 +508,10 @@ class Freeze_test : public beast::unit_test::suite
env(trust(G1, A4["USD"](0), tfSetFreeze)); env(trust(G1, A4["USD"](0), tfSetFreeze));
affected = affected =
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 2u))) if (!BEAST_EXPECT(checkArraySize(affected, withTouch ? 3u : 2u)))
return; return;
ff = affected[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName]; ff = affected[withTouch ? 1u : 0u][sfModifiedNode.fieldName]
[sfFinalFields.fieldName];
BEAST_EXPECT( BEAST_EXPECT(
ff[sfLowLimit.fieldName] == ff[sfLowLimit.fieldName] ==
G1["USD"](0).value().getJson(JsonOptions::none)); G1["USD"](0).value().getJson(JsonOptions::none));
@@ -521,7 +525,7 @@ class Freeze_test : public beast::unit_test::suite
env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName]; env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
if (!BEAST_EXPECT(checkArraySize(affected, 8u))) if (!BEAST_EXPECT(checkArraySize(affected, 8u)))
return; return;
auto created = affected[0u][sfCreatedNode.fieldName]; auto created = affected[5u][sfCreatedNode.fieldName];
BEAST_EXPECT( BEAST_EXPECT(
created[sfNewFields.fieldName][jss::Account] == A2.human()); created[sfNewFields.fieldName][jss::Account] == A2.human());
env.close(); env.close();
@@ -543,8 +547,9 @@ public:
testOffersWhenFrozen(features); testOffersWhenFrozen(features);
}; };
using namespace test::jtx; using namespace test::jtx;
auto const sa = supported_amendments() - featureXahauGenesis; auto const sa = supported_amendments();
testAll(sa - featureFlowCross); testAll(sa - featureFlowCross);
testAll(sa - featureTouch);
testAll(sa); testAll(sa);
} }
}; };

View File

@@ -2102,9 +2102,10 @@ struct Remit_test : public beast::unit_test::suite
std::string result; std::string result;
TER code; TER code;
}; };
std::array<TestRateData, 10> testCases = {{ // 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 = {{
{0.0, USD(100), "900", tesSUCCESS}, {0.0, USD(100), "900", tesSUCCESS},
{-1.0, USD(100), "900", temBAD_TRANSFER_RATE},
{0.9, USD(100), "900", temBAD_TRANSFER_RATE}, {0.9, USD(100), "900", temBAD_TRANSFER_RATE},
{1.0, USD(100), "900", tesSUCCESS}, {1.0, USD(100), "900", tesSUCCESS},
{1.1, USD(100), "890", tesSUCCESS}, {1.1, USD(100), "890", tesSUCCESS},

1411
src/test/app/Touch_test.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1138,6 +1138,209 @@ 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 void
run() override run() override
{ {
@@ -1155,6 +1358,8 @@ public:
testSubErrors(false); testSubErrors(false);
testSubByUrl(); testSubByUrl();
testHistoryTxStream(); testHistoryTxStream();
testAccount(all);
testAccount(all - featureTouch);
} }
}; };