fix start function loop

This commit is contained in:
pwang200
2026-01-09 11:38:54 -05:00
committed by GitHub
parent 9ed60b45f8
commit 91f3d51f3d
6 changed files with 91 additions and 6 deletions

View File

@@ -850,6 +850,38 @@ struct Wasm_test : public beast::unit_test::suite
runFinishFunction(localVariableBombHex).has_value() == false);
}
void
testStartFunctionLoop()
{
testcase("infinite loop in start function");
using namespace test::jtx;
Env env(*this);
auto wasmStr = boost::algorithm::unhex(startLoopHex);
Bytes wasm(wasmStr.begin(), wasmStr.end());
TestLedgerDataProvider ledgerDataProvider(env);
ImportVec imports;
auto& engine = WasmEngine::instance();
auto checkRes = engine.check(
wasm, "finish", {}, imports, &ledgerDataProvider, env.journal);
BEAST_EXPECTS(
checkRes == tesSUCCESS, std::to_string(TERtoInt(checkRes)));
auto re = engine.run(
wasm,
ESCROW_FUNCTION_NAME,
{},
imports,
&ledgerDataProvider,
1'000'000,
env.journal);
BEAST_EXPECTS(
re.error() == tecFAILED_PROCESSING,
std::to_string(TERtoInt(re.error())));
}
void
run() override
{
@@ -878,6 +910,7 @@ struct Wasm_test : public beast::unit_test::suite
testWasmWasi();
testWasmSectionCorruption();
testStartFunctionLoop();
// perfTest();
}
};