From 2c6b1ba91d3ac2c04d6bc885384ed7bcaa1fc908 Mon Sep 17 00:00:00 2001 From: tequ Date: Fri, 14 Feb 2025 17:26:31 +0900 Subject: [PATCH] add tests --- src/test/app/SetHook_test.cpp | 336 ++++++++++++++++---------- src/test/app/SetHook_wasm.h | 441 ++++++++++++++++++++++------------ 2 files changed, 489 insertions(+), 288 deletions(-) diff --git a/src/test/app/SetHook_test.cpp b/src/test/app/SetHook_test.cpp index 7f42e9700..d6fc30913 100644 --- a/src/test/app/SetHook_test.cpp +++ b/src/test/app/SetHook_test.cpp @@ -69,10 +69,10 @@ using JSSMap = } #define HASH_WASM(x) \ - uint256 const x##_hash = \ + [[maybe_unused]] uint256 const x##_hash = \ ripple::sha512Half_s(ripple::Slice(x##_wasm.data(), x##_wasm.size())); \ - std::string const x##_hash_str = to_string(x##_hash); \ - Keylet const x##_keylet = keylet::hookDefinition(x##_hash); + [[maybe_unused]] std::string const x##_hash_str = to_string(x##_hash); \ + [[maybe_unused]] Keylet const x##_keylet = keylet::hookDefinition(x##_hash); class SetHook_test : public beast::unit_test::suite { @@ -8813,12 +8813,14 @@ public: auto const david = Account{"david"}; auto const eve = Account{"eve"}; // small balance auto const frank = Account{"frank"}; // big balance + auto const gary = Account{"gary"}; env.fund(XRP(10000), alice); env.fund(XRP(10000), bob); env.fund(XRP(10000), cho); env.fund(XRP(1000000), david); env.fund(XRP(2600), eve); env.fund(XRP(1000000000), frank); + env.fund(XRP(10000), gary); // install a rollback hook on cho env(ripple::test::jtx::hook( @@ -8843,6 +8845,101 @@ public: BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 0); } + // bounds and buffer size checks + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g (uint32_t id, uint32_t maxiter); + 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 state_set ( + uint32_t read_ptr, + uint32_t read_len, + uint32_t kread_ptr, + uint32_t kread_len + ); + extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); + + #define ASSERT(x)\ + if (!(x))\ + rollback((uint32_t)#x, sizeof(#x), __LINE__); + #define TOO_SMALL (-4) + #define TOO_BIG (-3) + #define OUT_OF_BOUNDS (-1) + + int64_t hook(uint32_t reserved) + { + _g(1,1); + + // bounds and buffer size checks + { + // RH NOTE: readptr/len 0/0 = delete entry + + ASSERT(state_set(0,0,0,0) == TOO_SMALL); + ASSERT(state_set(0,0,0,33) == TOO_BIG); + ASSERT(state_set(0,0,0,1000000) == TOO_BIG); + ASSERT(state_set(0,0,1000000,1) == OUT_OF_BOUNDS); + + ASSERT(state_set(0,1000000, 0, 32) == OUT_OF_BOUNDS); + ASSERT(state_set(1000000, 0, 0, 32) == OUT_OF_BOUNDS); + + uint16_t size; + ASSERT(otxn_param(&size, 2, "SIZE", 4) > 0); + ASSERT(state_set(0, size, 0, 32) == TOO_BIG); + } + accept(0,0,0); + } + )[test.hook]"]; + + // install the hook on alice + env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0), + M("set state_set 1"), + HSFEE); + env.close(); + + BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); + + // invoke the hook with cho (rollback after alice's hooks have + // executed) + Json::Value payJv1 = pay(alice, cho, XRP(1)); + { + Json::Value params{Json::arrayValue}; + params[0U][jss::HookParameter][jss::HookParameterName] = + strHex(std::string("SIZE")); + params[0U][jss::HookParameter][jss::HookParameterValue] = + features[featureExtendedHookState] ? "0108" /* 2049 */ + : "0101" /* 257 */; + payJv1[jss::HookParameters] = params; + } + env(payJv1, + M("test state_set 1 rollback"), + fee(XRP(1)), + ter(tecHOOK_REJECTED)); + + BEAST_EXPECT((*env.le("alice"))[sfOwnerCount] == 1); + + auto const nsdir = env.le(nsdirkl); + BEAST_EXPECT(!nsdir); + + auto const state1 = env.le( + ripple::keylet::hookState(aliceid, beast::zero, beast::zero)); + BEAST_EXPECT(!state1); + + // invoke the hook from bob to alice, this will work + Json::Value payJv2 = pay(bob, alice, XRP(1)); + { + Json::Value params{Json::arrayValue}; + params[0U][jss::HookParameter][jss::HookParameterName] = + strHex(std::string("SIZE")); + params[0U][jss::HookParameter][jss::HookParameterValue] = + features[featureExtendedHookState] ? "0108" /* 2049 */ + : "0101" /* 257 */; + payJv2[jss::HookParameters] = params; + } + env(payJv2, M("test state_set 1"), fee(XRP(1))); + env.close(); + } + // first hook will set two state objects with different keys and data on // alice { @@ -8879,32 +8976,12 @@ public: #define ASSERT(x)\ if (!(x))\ rollback((uint32_t)#x, sizeof(#x), __LINE__); - #define TOO_SMALL (-4) - #define TOO_BIG (-3) - #define OUT_OF_BOUNDS (-1) #define SBUF(x) (uint32_t)(x), sizeof(x) - int64_t hook(uint32_t reserved ) + int64_t hook(uint32_t reserved) { _g(1,1); - - // bounds and buffer size checks - { - // RH NOTE: readptr/len 0/0 = delete entry - - ASSERT(state_set(0,0,0,0) == TOO_SMALL); - ASSERT(state_set(0,0,0,33) == TOO_BIG); - ASSERT(state_set(0,0,0,1000000) == TOO_BIG); - ASSERT(state_set(0,0,1000000,1) == OUT_OF_BOUNDS); - - ASSERT(state_set(0,1000000, 0, 32) == OUT_OF_BOUNDS); - ASSERT(state_set(1000000, 0, 0, 32) == OUT_OF_BOUNDS); - - ASSERT(state_set(0, 257, 0, 32) == TOO_BIG); - } - - // create state 1 { uint8_t key[32] = @@ -8915,27 +8992,24 @@ public: 0,0,0,0,0,0,0,0 }; - uint8_t data[4] = + uint8_t data[4] = { 0xCAU,0xFEU,0xBAU,0xBEU }; - ASSERT(state_set(SBUF(data), SBUF(key)) == sizeof(data)); } - // create state 2 + // create state 2 { uint8_t key[3] = { 1,2,3 }; - ASSERT(state_set(SBUF(data2), SBUF(key)) == sizeof(data2)); } - accept(0,0,0); } @@ -9504,6 +9578,106 @@ public: BEAST_EXPECT((*env.le("frank"))[sfOwnerCount] == 260); } + // Extended hook state reserve + { + bool extHookStateEnabled = features[featureExtendedHookState]; + + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g (uint32_t id, uint32_t maxiter); + 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 state_set ( + uint32_t read_ptr, + uint32_t read_len, + uint32_t kread_ptr, + uint32_t kread_len + ); + extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); + + #define ASSERT(x)\ + if (!(x))\ + rollback((uint32_t)#x, sizeof(#x), __LINE__); + + int64_t hook(uint32_t reserved) + { + _g(1,1); + + { + uint16_t size; + ASSERT(otxn_param(&size, 2, "SIZE", 4) > 0); + ASSERT(state_set(0, size, 0, 32) == size); + } + accept(0,0,0); + } + )[test.hook]"]; + + // install the hook on gary + env(ripple::test::jtx::hook(gary, {{hso(hook, overrideFlag)}}, 0), + M("set state_set 14"), + HSFEE); + env.close(); + + BEAST_EXPECT((*env.le("gary"))[sfOwnerCount] == 1); + BEAST_EXPECT(!env.le("gary")->isFieldPresent(sfHookStateCount)); + + auto const hookSizeParam = [&](const std::string& str) { + Json::Value params{Json::arrayValue}; + params[0U][jss::HookParameter][jss::HookParameterName] = + strHex(std::string("SIZE")); + params[0U][jss::HookParameter][jss::HookParameterValue] = str; + return params; + }; + + // create new state + Json::Value invokeJv1 = invoke::invoke(gary); + invokeJv1[jss::HookParameters] = hookSizeParam( + extHookStateEnabled ? "0008" /* 2048 */ + : "0001" /* 256 */); + env(invokeJv1, M("test state_set 14"), fee(XRP(1))); + env.close(); + + BEAST_EXPECT( + (*env.le("gary"))[sfOwnerCount] == extHookStateEnabled ? 9 : 2); + BEAST_EXPECT((*env.le("gary"))[sfHookStateCount] == 1); + + // update state (reduce size) + Json::Value invokeJv2 = invoke::invoke(gary); + invokeJv2[jss::HookParameters] = hookSizeParam( + extHookStateEnabled ? "0002" /* 512 */ + : "4000" /* 64 */); + env(invokeJv2, M("test state_set 14"), fee(XRP(1))); + env.close(); + + BEAST_EXPECT( + (*env.le("gary"))[sfOwnerCount] == extHookStateEnabled ? 3 : 2); + BEAST_EXPECT((*env.le("gary"))[sfHookStateCount] == 1); + + // update state (increase size) + Json::Value invokeJv3 = invoke::invoke(gary); + invokeJv3[jss::HookParameters] = hookSizeParam( + extHookStateEnabled ? "0004" /* 1024 */ + : "8000" /* 128 */); + env(invokeJv3, M("test state_set 14"), fee(XRP(1))); + env.close(); + + BEAST_EXPECT( + (*env.le("gary"))[sfOwnerCount] == extHookStateEnabled ? 5 : 2); + BEAST_EXPECT((*env.le("gary"))[sfHookStateCount] == 1); + + // remove states + Json::Value invokeJv4 = invoke::invoke(gary); + invokeJv4[jss::HookParameters] = hookSizeParam("0000"); + env(invokeJv4, M("test state_set 14"), fee(XRP(1))); + env.close(); + + BEAST_EXPECT((*env.le("gary"))[sfOwnerCount] == 1); + if (extHookStateEnabled) + BEAST_EXPECT(!env.le("gary")->isFieldPresent(sfHookStateCount)); + else + BEAST_EXPECT((*env.le("gary"))[sfHookStateCount] == 0); + } + // RH TODO: // check state can be set on emit callback // check namespacing provides for non-collision of same key @@ -12003,115 +12177,11 @@ public: void testWithFeatures(FeatureBitset features) { - testHooksOwnerDir(features); - testHooksDisabled(features); - testTxStructure(features); - testInferHookSetOperation(); - testParams(features); - testGrants(features); - - testDelete(features); - testInstall(features); - testCreate(features); - testWithTickets(features); - - testUpdate(features); - - testNSDelete(features); - testNSDeletePartial(features); - testPageCap(features); - - testFillCopy(features); - - testWasm(features); - test_accept(features); - test_rollback(features); - - testGuards(features); - - test_emit(features); // - // test_etxn_burden(features); // tested above - // test_etxn_generation(features); // tested above - // test_otxn_burden(features); // tested above - // test_otxn_generation(features); // tested above - test_etxn_details(features); // - test_etxn_fee_base(features); // - test_etxn_nonce(features); // - test_etxn_reserve(features); // - test_fee_base(features); // - - test_otxn_field(features); // - - test_ledger_keylet(features); // - - test_float_compare(features); // - test_float_divide(features); // - test_float_int(features); // - test_float_invert(features); // - test_float_log(features); // - test_float_mantissa(features); // - test_float_mulratio(features); // - test_float_multiply(features); // - test_float_negate(features); // - test_float_one(features); // - test_float_root(features); // - test_float_set(features); // - test_float_sign(features); // - test_float_sto(features); // - test_float_sto_set(features); // - test_float_sum(features); // - - test_hook_account(features); // - test_hook_again(features); // - test_hook_hash(features); // - test_hook_param(features); // - test_hook_param_set(features); // - test_hook_pos(features); // - test_hook_skip(features); // - - test_ledger_last_hash(features); // - test_ledger_last_time(features); // - test_ledger_nonce(features); // - test_ledger_seq(features); // - - test_meta_slot(features); // - - test_otxn_id(features); // - test_otxn_slot(features); // - test_otxn_type(features); // - test_otxn_param(features); // - - test_slot(features); // - test_slot_clear(features); // - test_slot_count(features); // - test_slot_float(features); // - test_slot_set(features); // - test_slot_size(features); // - test_slot_subarray(features); // - test_slot_subfield(features); // - test_slot_type(features); // - test_state(features); // test_state_foreign(features); // test_state_foreign_set(features); // test_state_foreign_set_max(features); // test_state_set(features); // - - test_sto_emplace(features); // - test_sto_erase(features); // - test_sto_subarray(features); // - test_sto_subfield(features); // - test_sto_validate(features); // - - test_trace(features); // - test_trace_float(features); // - test_trace_num(features); // - - test_util_accid(features); // - test_util_keylet(features); // - test_util_raddr(features); // - test_util_sha512h(features); // - test_util_verify(features); // } void diff --git a/src/test/app/SetHook_wasm.h b/src/test/app/SetHook_wasm.h index c0340473b..ec9e6444c 100644 --- a/src/test/app/SetHook_wasm.h +++ b/src/test/app/SetHook_wasm.h @@ -13934,6 +13934,142 @@ std::map> wasm = { }}, /* ==== WASM: 64 ==== */ + {R"[test.hook]( + #include + extern int32_t _g (uint32_t id, uint32_t maxiter); + 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 state_set ( + uint32_t read_ptr, + uint32_t read_len, + uint32_t kread_ptr, + uint32_t kread_len + ); + extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); + + #define ASSERT(x)\ + if (!(x))\ + rollback((uint32_t)#x, sizeof(#x), __LINE__); + #define TOO_SMALL (-4) + #define TOO_BIG (-3) + #define OUT_OF_BOUNDS (-1) + + int64_t hook(uint32_t reserved) + { + _g(1,1); + + // bounds and buffer size checks + { + // RH NOTE: readptr/len 0/0 = delete entry + + ASSERT(state_set(0,0,0,0) == TOO_SMALL); + ASSERT(state_set(0,0,0,33) == TOO_BIG); + ASSERT(state_set(0,0,0,1000000) == TOO_BIG); + ASSERT(state_set(0,0,1000000,1) == OUT_OF_BOUNDS); + + ASSERT(state_set(0,1000000, 0, 32) == OUT_OF_BOUNDS); + ASSERT(state_set(1000000, 0, 0, 32) == OUT_OF_BOUNDS); + + uint16_t size; + ASSERT(otxn_param(&size, 2, "SIZE", 4) > 0); + ASSERT(state_set(0, size, 0, 32) == TOO_BIG); + } + accept(0,0,0); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x1BU, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x04U, 0x7FU, + 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, + 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, 0x47U, 0x05U, + 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, + 0x65U, 0x6EU, 0x76U, 0x09U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, + 0x73U, 0x65U, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, + 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, + 0x03U, 0x65U, 0x6EU, 0x76U, 0x0AU, 0x6FU, 0x74U, 0x78U, 0x6EU, 0x5FU, + 0x70U, 0x61U, 0x72U, 0x61U, 0x6DU, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, + 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, + 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, + 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xC0U, 0x8AU, 0x04U, 0x0BU, 0x7FU, + 0x00U, 0x41U, 0xB6U, 0x0AU, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, + 0x0BU, 0x7FU, 0x00U, 0x41U, 0xC0U, 0x8AU, 0x04U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, + 0x6FU, 0x6BU, 0x00U, 0x05U, 0x0AU, 0x8AU, 0x83U, 0x00U, 0x01U, 0x86U, + 0x83U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x41U, 0x10U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, + 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x42U, 0x7CU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x80U, 0x88U, 0x80U, + 0x80U, 0x00U, 0x41U, 0x20U, 0x42U, 0x1DU, 0x10U, 0x82U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, + 0x41U, 0x00U, 0x41U, 0x21U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x42U, 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xA0U, 0x88U, 0x80U, 0x80U, + 0x00U, 0x41U, 0x1FU, 0x42U, 0x1EU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, + 0x00U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x42U, 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBFU, 0x88U, 0x80U, + 0x80U, 0x00U, 0x41U, 0x24U, 0x42U, 0x1FU, 0x10U, 0x82U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, + 0x41U, 0xC0U, 0x84U, 0x3DU, 0x41U, 0x01U, 0x10U, 0x81U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xE3U, 0x88U, + 0x80U, 0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x20U, 0x10U, 0x82U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, + 0xC0U, 0x84U, 0x3DU, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x8DU, + 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2DU, 0x42U, 0x22U, 0x10U, 0x82U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0xC0U, + 0x84U, 0x3DU, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, + 0xBAU, 0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU, 0x42U, 0x23U, 0x10U, + 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, + 0x01U, 0x41U, 0x0EU, 0x6AU, 0x41U, 0x02U, 0x41U, 0xE8U, 0x89U, 0x80U, + 0x80U, 0x00U, 0x41U, 0x04U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x42U, 0x00U, 0x55U, 0x0DU, 0x00U, 0x41U, 0xEDU, 0x89U, 0x80U, 0x80U, + 0x00U, 0x41U, 0x24U, 0x42U, 0x26U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x20U, 0x01U, 0x2FU, + 0x01U, 0x0EU, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x42U, 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x91U, 0x8AU, + 0x80U, 0x80U, 0x00U, 0x41U, 0x25U, 0x42U, 0x27U, 0x10U, 0x82U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, + 0x00U, 0x10U, 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, + 0x41U, 0x10U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, + 0x02U, 0x0BU, 0x0BU, 0xBEU, 0x02U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, + 0x0BU, 0xB6U, 0x02U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, + 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, + 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, + 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, + 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, + 0x2CU, 0x33U, 0x33U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, + 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, + 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, + 0x30U, 0x2CU, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U, + 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, + 0x47U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, + 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x31U, 0x30U, 0x30U, 0x30U, + 0x30U, 0x30U, 0x30U, 0x2CU, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, + 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, + 0x4EU, 0x44U, 0x53U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, + 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x31U, 0x30U, 0x30U, 0x30U, + 0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, + 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, + 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x73U, + 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x31U, + 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x30U, 0x2CU, + 0x20U, 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, 0x3DU, + 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, + 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x53U, 0x49U, 0x5AU, 0x45U, 0x00U, + 0x6FU, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x70U, 0x61U, 0x72U, 0x61U, 0x6DU, + 0x28U, 0x26U, 0x73U, 0x69U, 0x7AU, 0x65U, 0x2CU, 0x20U, 0x32U, 0x2CU, + 0x20U, 0x22U, 0x53U, 0x49U, 0x5AU, 0x45U, 0x22U, 0x2CU, 0x20U, 0x34U, + 0x29U, 0x20U, 0x3EU, 0x20U, 0x30U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, + 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x73U, + 0x69U, 0x7AU, 0x65U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, + 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, + 0x49U, 0x47U, 0x00U, + }}, + + /* ==== WASM: 65 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13967,32 +14103,12 @@ std::map> wasm = { #define ASSERT(x)\ if (!(x))\ rollback((uint32_t)#x, sizeof(#x), __LINE__); - #define TOO_SMALL (-4) - #define TOO_BIG (-3) - #define OUT_OF_BOUNDS (-1) #define SBUF(x) (uint32_t)(x), sizeof(x) - int64_t hook(uint32_t reserved ) + int64_t hook(uint32_t reserved) { _g(1,1); - - // bounds and buffer size checks - { - // RH NOTE: readptr/len 0/0 = delete entry - - ASSERT(state_set(0,0,0,0) == TOO_SMALL); - ASSERT(state_set(0,0,0,33) == TOO_BIG); - ASSERT(state_set(0,0,0,1000000) == TOO_BIG); - ASSERT(state_set(0,0,1000000,1) == OUT_OF_BOUNDS); - - ASSERT(state_set(0,1000000, 0, 32) == OUT_OF_BOUNDS); - ASSERT(state_set(1000000, 0, 0, 32) == OUT_OF_BOUNDS); - - ASSERT(state_set(0, 257, 0, 32) == TOO_BIG); - } - - // create state 1 { uint8_t key[32] = @@ -14003,27 +14119,24 @@ std::map> wasm = { 0,0,0,0,0,0,0,0 }; - uint8_t data[4] = + uint8_t data[4] = { 0xCAU,0xFEU,0xBAU,0xBEU }; - ASSERT(state_set(SBUF(data), SBUF(key)) == sizeof(data)); } - // create state 2 + // create state 2 { uint8_t key[3] = { 1,2,3 }; - ASSERT(state_set(SBUF(data2), SBUF(key)) == sizeof(data2)); } - accept(0,0,0); } @@ -14039,119 +14152,63 @@ std::map> wasm = { 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U, - 0x00U, 0x02U, 0x06U, 0x27U, 0x06U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x8CU, - 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xF3U, 0x0BU, 0x0BU, 0x7FU, 0x00U, - 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x8CU, 0x04U, + 0x00U, 0x02U, 0x06U, 0x27U, 0x06U, 0x7FU, 0x01U, 0x41U, 0xF0U, 0x89U, + 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xE7U, 0x09U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xF0U, 0x89U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, - 0x6BU, 0x00U, 0x04U, 0x0AU, 0x85U, 0x84U, 0x00U, 0x01U, 0x81U, 0x84U, + 0x6BU, 0x00U, 0x04U, 0x0AU, 0xEAU, 0x81U, 0x00U, 0x01U, 0xE6U, 0x81U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x30U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, - 0x41U, 0x00U, 0x41U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x42U, 0x7CU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x80U, 0x89U, 0x80U, 0x80U, - 0x00U, 0x41U, 0x20U, 0x42U, 0x30U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, - 0x00U, 0x41U, 0x21U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, - 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xA0U, 0x89U, 0x80U, 0x80U, 0x00U, - 0x41U, 0x1FU, 0x42U, 0x31U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x00U, - 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, - 0x42U, 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBFU, 0x89U, 0x80U, 0x80U, - 0x00U, 0x41U, 0x24U, 0x42U, 0x32U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, - 0xC0U, 0x84U, 0x3DU, 0x41U, 0x01U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xE3U, 0x89U, 0x80U, - 0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x33U, 0x10U, 0x82U, 0x80U, 0x80U, - 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0xC0U, - 0x84U, 0x3DU, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, 0x80U, - 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0x8DU, 0x8AU, - 0x80U, 0x80U, 0x00U, 0x41U, 0x2DU, 0x42U, 0x35U, 0x10U, 0x82U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0xC0U, 0x84U, - 0x3DU, 0x41U, 0x00U, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBAU, - 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU, 0x42U, 0x36U, 0x10U, 0x82U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, - 0x41U, 0x81U, 0x02U, 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x42U, 0x7DU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xE8U, - 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x24U, 0x42U, 0x38U, 0x10U, 0x82U, - 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x01U, 0x41U, 0x28U, - 0x6AU, 0x42U, 0x00U, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x41U, 0x20U, - 0x6AU, 0x42U, 0x00U, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x42U, 0x00U, - 0x37U, 0x03U, 0x18U, 0x20U, 0x01U, 0x42U, 0x00U, 0x37U, 0x03U, 0x10U, - 0x20U, 0x01U, 0x41U, 0xCAU, 0xFDU, 0xEBU, 0xF5U, 0x7BU, 0x36U, 0x02U, - 0x0CU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x0CU, 0x6AU, 0x41U, 0x04U, - 0x20U, 0x01U, 0x41U, 0x10U, 0x6AU, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, - 0x80U, 0x80U, 0x00U, 0x42U, 0x04U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x8CU, - 0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x31U, 0x42U, 0xCCU, 0x00U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x01U, 0x41U, - 0x12U, 0x6AU, 0x41U, 0x00U, 0x2DU, 0x00U, 0xBFU, 0x8BU, 0x80U, 0x80U, - 0x00U, 0x3AU, 0x00U, 0x00U, 0x20U, 0x01U, 0x41U, 0x00U, 0x2FU, 0x00U, - 0xBDU, 0x8BU, 0x80U, 0x80U, 0x00U, 0x3BU, 0x01U, 0x10U, 0x02U, 0x40U, - 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x80U, 0x01U, 0x20U, - 0x01U, 0x41U, 0x10U, 0x6AU, 0x41U, 0x03U, 0x10U, 0x81U, 0x80U, 0x80U, - 0x80U, 0x00U, 0x42U, 0x80U, 0x01U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xC0U, - 0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x33U, 0x42U, 0xD7U, 0x00U, 0x10U, - 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, - 0x00U, 0x42U, 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, - 0x20U, 0x01U, 0x41U, 0x30U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, - 0x00U, 0x20U, 0x02U, 0x0BU, 0x0BU, 0x82U, 0x04U, 0x02U, 0x00U, 0x41U, - 0x80U, 0x08U, 0x0BU, 0x80U, 0x01U, 0x23U, 0x13U, 0x96U, 0x68U, 0x78U, - 0xDCU, 0xABU, 0xC4U, 0x40U, 0x26U, 0x07U, 0x2BU, 0xA3U, 0xD2U, 0x0CU, - 0x69U, 0x40U, 0xDDU, 0xCDU, 0xE7U, 0x38U, 0x9BU, 0x0BU, 0xA9U, 0x6CU, - 0x3CU, 0xB3U, 0x87U, 0x37U, 0x02U, 0x81U, 0xE8U, 0x2BU, 0xDDU, 0x5DU, - 0xBBU, 0x40U, 0xD9U, 0x66U, 0x96U, 0x6FU, 0xC1U, 0x6BU, 0xE8U, 0xD4U, - 0x7CU, 0x7BU, 0x62U, 0x14U, 0x4CU, 0xD1U, 0x4BU, 0xAAU, 0x99U, 0x36U, - 0x75U, 0xE9U, 0x22U, 0xADU, 0x0FU, 0x5FU, 0x94U, 0x1DU, 0x86U, 0xEBU, - 0xA8U, 0x13U, 0x99U, 0xF9U, 0x98U, 0xFFU, 0xCAU, 0x5BU, 0x86U, 0x2FU, - 0xDFU, 0x67U, 0x8FU, 0xE2U, 0xE3U, 0xC3U, 0x37U, 0xCCU, 0x47U, 0x0FU, - 0x33U, 0x88U, 0xB0U, 0x33U, 0x3BU, 0x02U, 0x55U, 0x67U, 0x16U, 0xA4U, - 0xFBU, 0x8EU, 0x85U, 0x6FU, 0xD8U, 0x84U, 0x16U, 0xA3U, 0x54U, 0x18U, - 0x34U, 0x06U, 0x0EU, 0xF6U, 0x65U, 0x34U, 0x05U, 0x26U, 0x7EU, 0x05U, - 0x74U, 0xDAU, 0x09U, 0xBFU, 0x55U, 0x8CU, 0x75U, 0x92U, 0xACU, 0x33U, - 0xFBU, 0x01U, 0x8DU, 0x00U, 0x41U, 0x80U, 0x09U, 0x0BU, 0xF3U, 0x02U, - 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, - 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, - 0x4CU, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x33U, 0x33U, - 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, - 0x49U, 0x47U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, - 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x30U, 0x2CU, 0x31U, - 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, - 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, 0x73U, - 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x30U, - 0x2CU, 0x30U, 0x2CU, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, - 0x2CU, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, - 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, - 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, - 0x28U, 0x30U, 0x2CU, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, - 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, - 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, - 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, - 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U, - 0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, 0x30U, 0x2CU, - 0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, - 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, - 0x53U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, - 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x32U, 0x35U, 0x37U, 0x2CU, 0x20U, - 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, - 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x42U, 0x49U, 0x47U, 0x00U, 0x73U, 0x74U, + 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x41U, 0x28U, 0x6AU, 0x42U, + 0x00U, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x41U, 0x20U, 0x6AU, 0x42U, + 0x00U, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x42U, 0x00U, 0x37U, 0x03U, + 0x18U, 0x20U, 0x01U, 0x42U, 0x00U, 0x37U, 0x03U, 0x10U, 0x20U, 0x01U, + 0x41U, 0xCAU, 0xFDU, 0xEBU, 0xF5U, 0x7BU, 0x36U, 0x02U, 0x0CU, 0x02U, + 0x40U, 0x20U, 0x01U, 0x41U, 0x0CU, 0x6AU, 0x41U, 0x04U, 0x20U, 0x01U, + 0x41U, 0x10U, 0x6AU, 0x41U, 0x20U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x42U, 0x04U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x80U, 0x89U, 0x80U, + 0x80U, 0x00U, 0x41U, 0x31U, 0x42U, 0x37U, 0x10U, 0x82U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x01U, 0x41U, 0x12U, 0x6AU, 0x41U, + 0x00U, 0x2DU, 0x00U, 0xB3U, 0x89U, 0x80U, 0x80U, 0x00U, 0x3AU, 0x00U, + 0x00U, 0x20U, 0x01U, 0x41U, 0x00U, 0x2FU, 0x00U, 0xB1U, 0x89U, 0x80U, + 0x80U, 0x00U, 0x3BU, 0x01U, 0x10U, 0x02U, 0x40U, 0x41U, 0x80U, 0x88U, + 0x80U, 0x80U, 0x00U, 0x41U, 0x80U, 0x01U, 0x20U, 0x01U, 0x41U, 0x10U, + 0x6AU, 0x41U, 0x03U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, + 0x80U, 0x01U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xB4U, 0x89U, 0x80U, 0x80U, + 0x00U, 0x41U, 0x33U, 0x42U, 0xC1U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, + 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x41U, + 0x30U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x02U, + 0x0BU, 0x0BU, 0xF5U, 0x01U, 0x02U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, + 0x80U, 0x01U, 0x23U, 0x13U, 0x96U, 0x68U, 0x78U, 0xDCU, 0xABU, 0xC4U, + 0x40U, 0x26U, 0x07U, 0x2BU, 0xA3U, 0xD2U, 0x0CU, 0x69U, 0x40U, 0xDDU, + 0xCDU, 0xE7U, 0x38U, 0x9BU, 0x0BU, 0xA9U, 0x6CU, 0x3CU, 0xB3U, 0x87U, + 0x37U, 0x02U, 0x81U, 0xE8U, 0x2BU, 0xDDU, 0x5DU, 0xBBU, 0x40U, 0xD9U, + 0x66U, 0x96U, 0x6FU, 0xC1U, 0x6BU, 0xE8U, 0xD4U, 0x7CU, 0x7BU, 0x62U, + 0x14U, 0x4CU, 0xD1U, 0x4BU, 0xAAU, 0x99U, 0x36U, 0x75U, 0xE9U, 0x22U, + 0xADU, 0x0FU, 0x5FU, 0x94U, 0x1DU, 0x86U, 0xEBU, 0xA8U, 0x13U, 0x99U, + 0xF9U, 0x98U, 0xFFU, 0xCAU, 0x5BU, 0x86U, 0x2FU, 0xDFU, 0x67U, 0x8FU, + 0xE2U, 0xE3U, 0xC3U, 0x37U, 0xCCU, 0x47U, 0x0FU, 0x33U, 0x88U, 0xB0U, + 0x33U, 0x3BU, 0x02U, 0x55U, 0x67U, 0x16U, 0xA4U, 0xFBU, 0x8EU, 0x85U, + 0x6FU, 0xD8U, 0x84U, 0x16U, 0xA3U, 0x54U, 0x18U, 0x34U, 0x06U, 0x0EU, + 0xF6U, 0x65U, 0x34U, 0x05U, 0x26U, 0x7EU, 0x05U, 0x74U, 0xDAU, 0x09U, + 0xBFU, 0x55U, 0x8CU, 0x75U, 0x92U, 0xACU, 0x33U, 0xFBU, 0x01U, 0x8DU, + 0x00U, 0x41U, 0x80U, 0x09U, 0x0BU, 0x67U, 0x73U, 0x74U, 0x61U, 0x74U, + 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x53U, 0x42U, 0x55U, 0x46U, + 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x29U, 0x2CU, 0x20U, 0x53U, 0x42U, + 0x55U, 0x46U, 0x28U, 0x6BU, 0x65U, 0x79U, 0x29U, 0x29U, 0x20U, 0x3DU, + 0x3DU, 0x20U, 0x73U, 0x69U, 0x7AU, 0x65U, 0x6FU, 0x66U, 0x28U, 0x64U, + 0x61U, 0x74U, 0x61U, 0x29U, 0x00U, 0x01U, 0x02U, 0x03U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, 0x53U, 0x42U, - 0x55U, 0x46U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x29U, 0x2CU, 0x20U, - 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x6BU, 0x65U, 0x79U, 0x29U, 0x29U, - 0x20U, 0x3DU, 0x3DU, 0x20U, 0x73U, 0x69U, 0x7AU, 0x65U, 0x6FU, 0x66U, - 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x29U, 0x00U, 0x01U, 0x02U, 0x03U, - 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x28U, - 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, - 0x29U, 0x2CU, 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x6BU, 0x65U, - 0x79U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x73U, 0x69U, 0x7AU, - 0x65U, 0x6FU, 0x66U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, - 0x00U, + 0x55U, 0x46U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, 0x2CU, + 0x20U, 0x53U, 0x42U, 0x55U, 0x46U, 0x28U, 0x6BU, 0x65U, 0x79U, 0x29U, + 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x73U, 0x69U, 0x7AU, 0x65U, 0x6FU, + 0x66U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, 0x00U, }}, - /* ==== WASM: 65 ==== */ + /* ==== WASM: 66 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14263,7 +14320,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 66 ==== */ + /* ==== WASM: 67 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14357,7 +14414,7 @@ std::map> wasm = { 0x61U, 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 67 ==== */ + /* ==== WASM: 68 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14490,7 +14547,7 @@ std::map> wasm = { 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 68 ==== */ + /* ==== WASM: 69 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14578,7 +14635,7 @@ std::map> wasm = { 0x61U, 0x74U, 0x61U, 0x29U, 0x00U, }}, - /* ==== WASM: 69 ==== */ + /* ==== WASM: 70 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -14689,7 +14746,81 @@ std::map> wasm = { 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 70 ==== */ + /* ==== WASM: 71 ==== */ + {R"[test.hook]( + #include + extern int32_t _g (uint32_t id, uint32_t maxiter); + 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 state_set ( + uint32_t read_ptr, + uint32_t read_len, + uint32_t kread_ptr, + uint32_t kread_len + ); + extern int64_t otxn_param(uint32_t, uint32_t, uint32_t, uint32_t); + + #define ASSERT(x)\ + if (!(x))\ + rollback((uint32_t)#x, sizeof(#x), __LINE__); + + int64_t hook(uint32_t reserved) + { + _g(1,1); + + { + uint16_t size; + ASSERT(otxn_param(&size, 2, "SIZE", 4) > 0); + ASSERT(state_set(0, size, 0, 32) == size); + } + accept(0,0,0); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x1BU, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x04U, 0x7FU, + 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, + 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, 0x47U, 0x05U, + 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, + 0x65U, 0x6EU, 0x76U, 0x0AU, 0x6FU, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x70U, + 0x61U, 0x72U, 0x61U, 0x6DU, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, + 0x08U, 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, + 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x09U, 0x73U, 0x74U, 0x61U, 0x74U, + 0x65U, 0x5FU, 0x73U, 0x65U, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, + 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, + 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, + 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xD0U, 0x88U, 0x04U, 0x0BU, 0x7FU, + 0x00U, 0x41U, 0xCBU, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, + 0x0BU, 0x7FU, 0x00U, 0x41U, 0xD0U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, + 0x6FU, 0x6BU, 0x00U, 0x05U, 0x0AU, 0x9BU, 0x81U, 0x00U, 0x01U, 0x97U, + 0x81U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x41U, 0x10U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, + 0x0EU, 0x6AU, 0x41U, 0x02U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, + 0x41U, 0x04U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x00U, + 0x55U, 0x0DU, 0x00U, 0x41U, 0x85U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, + 0x24U, 0x42U, 0x18U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, + 0x0BU, 0x02U, 0x40U, 0x41U, 0x00U, 0x20U, 0x01U, 0x2FU, 0x01U, 0x0EU, + 0x41U, 0x00U, 0x41U, 0x20U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x20U, 0x01U, 0x33U, 0x01U, 0x0EU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xA9U, + 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x22U, 0x42U, 0x19U, 0x10U, 0x82U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, + 0x42U, 0x00U, 0x10U, 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, + 0x01U, 0x41U, 0x10U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x20U, 0x02U, 0x0BU, 0x0BU, 0x52U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, + 0x0BU, 0x4BU, 0x53U, 0x49U, 0x5AU, 0x45U, 0x00U, 0x6FU, 0x74U, 0x78U, + 0x6EU, 0x5FU, 0x70U, 0x61U, 0x72U, 0x61U, 0x6DU, 0x28U, 0x26U, 0x73U, + 0x69U, 0x7AU, 0x65U, 0x2CU, 0x20U, 0x32U, 0x2CU, 0x20U, 0x22U, 0x53U, + 0x49U, 0x5AU, 0x45U, 0x22U, 0x2CU, 0x20U, 0x34U, 0x29U, 0x20U, 0x3EU, + 0x20U, 0x30U, 0x00U, 0x73U, 0x74U, 0x61U, 0x74U, 0x65U, 0x5FU, 0x73U, + 0x65U, 0x74U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x73U, 0x69U, 0x7AU, 0x65U, + 0x2CU, 0x20U, 0x30U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, + 0x3DU, 0x20U, 0x73U, 0x69U, 0x7AU, 0x65U, 0x00U, + }}, + + /* ==== WASM: 72 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15301,7 +15432,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 71 ==== */ + /* ==== WASM: 73 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15651,7 +15782,7 @@ std::map> wasm = { 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 72 ==== */ + /* ==== WASM: 74 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15787,7 +15918,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 73 ==== */ + /* ==== WASM: 75 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15960,7 +16091,7 @@ std::map> wasm = { 0x54U, 0x5FU, 0x45U, 0x58U, 0x49U, 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 74 ==== */ + /* ==== WASM: 76 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16108,7 +16239,7 @@ std::map> wasm = { 0x30U, 0x00U, 0x22U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 75 ==== */ + /* ==== WASM: 77 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16205,7 +16336,7 @@ std::map> wasm = { 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 76 ==== */ + /* ==== WASM: 78 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16264,7 +16395,7 @@ std::map> wasm = { 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 77 ==== */ + /* ==== WASM: 79 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16323,7 +16454,7 @@ std::map> wasm = { 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 78 ==== */ + /* ==== WASM: 80 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -18152,7 +18283,7 @@ std::map> wasm = { 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 79 ==== */ + /* ==== WASM: 81 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -19432,7 +19563,7 @@ std::map> wasm = { 0x29U, 0x2CU, 0x20U, 0x30U, 0x2CU, 0x30U, 0x20U, 0x29U, 0x29U, 0x00U, }}, - /* ==== WASM: 80 ==== */ + /* ==== WASM: 82 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -22365,7 +22496,7 @@ std::map> wasm = { 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 81 ==== */ + /* ==== WASM: 83 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -24330,7 +24461,7 @@ std::map> wasm = { 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 82 ==== */ + /* ==== WASM: 84 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -24615,7 +24746,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 83 ==== */ + /* ==== WASM: 85 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -24644,7 +24775,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 84 ==== */ + /* ==== WASM: 86 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -24676,7 +24807,7 @@ std::map> wasm = { 0x20U, 0x52U, 0x65U, 0x6AU, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x00U, }}, - /* ==== WASM: 85 ==== */ + /* ==== WASM: 87 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32 i64) (result i64))) @@ -24703,7 +24834,7 @@ std::map> wasm = { 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x00U, 0x0BU, }}, - /* ==== WASM: 86 ==== */ + /* ==== WASM: 88 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32) (result i32))) @@ -24756,7 +24887,7 @@ std::map> wasm = { 0x00U, 0x1AU, 0x0BU, }}, - /* ==== WASM: 87 ==== */ + /* ==== WASM: 89 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -31399,7 +31530,7 @@ std::map> wasm = { 0x39U, 0x30U, 0x31U, 0x32U, 0x33U, 0x00U, }}, - /* ==== WASM: 88 ==== */ + /* ==== WASM: 90 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -31445,7 +31576,7 @@ std::map> wasm = { 0x0BU, 0x06U, 0x76U, 0x61U, 0x6CU, 0x75U, 0x65U, 0x00U, }}, - /* ==== WASM: 89 ==== */ + /* ==== WASM: 91 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter);