mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
infinite loop test (#6064)
This commit is contained in:
@@ -467,6 +467,20 @@ struct Wasm_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(countSubstr(s, "exception: <finish> failure") > 0);
|
||||
}
|
||||
|
||||
{ // infinite loop
|
||||
auto const wasmStr = boost::algorithm::unhex(infiniteLoopWasmHex);
|
||||
Bytes wasm(wasmStr.begin(), wasmStr.end());
|
||||
std::string const funcName("loop");
|
||||
TestHostFunctions hfs(env, 0);
|
||||
|
||||
// infinite loop should be caught and fail
|
||||
auto const re = runEscrowWasm(wasm, hfs, funcName, {}, 1'000'000);
|
||||
if (BEAST_EXPECT(!re.has_value()))
|
||||
{
|
||||
BEAST_EXPECT(re.error() == tecFAILED_PROCESSING);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// expected import not provided
|
||||
auto wasmStr = boost::algorithm::unhex(ledgerSqnWasmHex);
|
||||
|
||||
@@ -1208,3 +1208,19 @@ extern std::string const wasiPrintHex =
|
||||
"656d6f727902000666696e69736800010a1d011b01017f4118210041014100410120001000"
|
||||
"45047f410105417f0b0b0b1e030041100b0648656c6c6f0a0041000b04100000000041040b"
|
||||
"0406000000";
|
||||
|
||||
extern std::string const infiniteLoopWasmHex =
|
||||
"0061736d010000000108026000006000017f030302000105030100020638097f004180080b"
|
||||
"7f004180080b7f004180080b7f00418088040b7f004180080b7f00418088040b7f00418080"
|
||||
"080b7f0041000b7f0041010b07a8010c066d656d6f72790200115f5f7761736d5f63616c6c"
|
||||
"5f63746f72730000046c6f6f7000010c5f5f64736f5f68616e646c6503000a5f5f64617461"
|
||||
"5f656e6403010b5f5f737461636b5f6c6f7703020c5f5f737461636b5f6869676803030d5f"
|
||||
"5f676c6f62616c5f6261736503040b5f5f686561705f6261736503050a5f5f686561705f65"
|
||||
"6e6403060d5f5f6d656d6f72795f6261736503070c5f5f7461626c655f6261736503080a27"
|
||||
"0202000b220041fc87044100360200034041fc870441fc870428020041016a3602000c000b"
|
||||
"000b007f0970726f647563657273010c70726f6365737365642d62790105636c616e675f31"
|
||||
"392e312e352d776173692d73646b202868747470733a2f2f6769746875622e636f6d2f6c6c"
|
||||
"766d2f6c6c766d2d70726f6a65637420616234623561326462353832393538616631656533"
|
||||
"303861373930636664623432626432343732302900490f7461726765745f66656174757265"
|
||||
"73042b0f6d757461626c652d676c6f62616c732b087369676e2d6578742b0f726566657265"
|
||||
"6e63652d74797065732b0a6d756c746976616c7565";
|
||||
|
||||
@@ -64,3 +64,5 @@ extern std::string const trapFuncSigMismatchHex;
|
||||
|
||||
extern std::string const wasiGetTimeHex;
|
||||
extern std::string const wasiPrintHex;
|
||||
|
||||
extern std::string const infiniteLoopWasmHex;
|
||||
|
||||
8
src/test/app/wasm_fixtures/infiniteLoop.c
Normal file
8
src/test/app/wasm_fixtures/infiniteLoop.c
Normal file
@@ -0,0 +1,8 @@
|
||||
int
|
||||
loop()
|
||||
{
|
||||
int volatile x = 0;
|
||||
while (1)
|
||||
x++;
|
||||
return x;
|
||||
}
|
||||
Reference in New Issue
Block a user