mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-26 21:45:50 +00:00
trace testcase
This commit is contained in:
@@ -9078,7 +9078,52 @@ public:
|
||||
void
|
||||
test_trace()
|
||||
{
|
||||
// TODO
|
||||
testcase("Test trace");
|
||||
using namespace jtx;
|
||||
|
||||
Env env{*this, supported_amendments()};
|
||||
|
||||
auto const alice = Account{"alice"};
|
||||
auto const bob = Account{"bob"};
|
||||
env.fund(XRP(10000), alice);
|
||||
env.fund(XRP(10000), bob);
|
||||
|
||||
TestHook hook = wasm[R"[test.hook](
|
||||
#include <stdint.h>
|
||||
extern int32_t _g (uint32_t id, uint32_t maxiter);
|
||||
#define GUARD(maxiter) _g((1ULL << 31U) + __LINE__, (maxiter)+1)
|
||||
extern int64_t accept (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
|
||||
extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
|
||||
extern int64_t trace (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
#define OUT_OF_BOUNDS -1
|
||||
#define ASSERT(x)\
|
||||
if (!(x))\
|
||||
rollback((uint32_t)#x, sizeof(#x), __LINE__);
|
||||
int64_t hook(uint32_t reservmaed )
|
||||
{
|
||||
_g(1,1);
|
||||
// Test out of bounds check
|
||||
ASSERT(trace(1000000, 10, 0, 10, 0) == OUT_OF_BOUNDS);
|
||||
ASSERT(trace(0, 1000000, 0, 10, 0) == OUT_OF_BOUNDS);
|
||||
ASSERT(trace(0, 10, 1000000, 10, 0) == OUT_OF_BOUNDS);
|
||||
ASSERT(trace(0, 10, 0, 1000000, 0) == OUT_OF_BOUNDS);
|
||||
|
||||
ASSERT(trace(0,0,0,0,0) == 0);
|
||||
ASSERT(trace(0,1,2,3,1) == 0);
|
||||
|
||||
return accept(0,0,0);
|
||||
}
|
||||
)[test.hook]"];
|
||||
|
||||
// install the hook on alice
|
||||
env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0),
|
||||
M("set trace"),
|
||||
HSFEE);
|
||||
env.close();
|
||||
|
||||
// invoke the hook
|
||||
env(pay(bob, alice, XRP(1)), M("test trace"), fee(XRP(1)));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -10974,7 +11019,7 @@ public:
|
||||
test_sto_subfield(); //
|
||||
test_sto_validate(); //
|
||||
|
||||
test_trace();
|
||||
test_trace(); //
|
||||
test_trace_float();
|
||||
test_trace_num();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user