From 45f674de475da14922547f592af893fb246c0c72 Mon Sep 17 00:00:00 2001 From: TimothyBanks Date: Fri, 17 Jul 2026 09:22:55 -0400 Subject: [PATCH] feat: Wasm Module Versioning --- src/libxrpl/tx/wasm/WasmiVM.cpp | 2 +- src/test/app/Wasm_test.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libxrpl/tx/wasm/WasmiVM.cpp b/src/libxrpl/tx/wasm/WasmiVM.cpp index 437c0fe7d7..4d41c537ef 100644 --- a/src/libxrpl/tx/wasm/WasmiVM.cpp +++ b/src/libxrpl/tx/wasm/WasmiVM.cpp @@ -854,7 +854,7 @@ filterCustomSections(Bytes const& wasmCode, Filter&& filter) auto sectionSize = readLEB128(wasmCode, offset); auto nextSection = offset + sectionSize; - if (nextSection >= wasmCode.size()) + if (nextSection > wasmCode.size()) { break; } diff --git a/src/test/app/Wasm_test.cpp b/src/test/app/Wasm_test.cpp index 2ecb2e6aa6..8cf99fb735 100644 --- a/src/test/app/Wasm_test.cpp +++ b/src/test/app/Wasm_test.cpp @@ -1,8 +1,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -238,14 +240,20 @@ struct Wasm_test : public beast::unit_test::Suite "010b0018127872706c2d657363726f772d7374646c6962342e352e360018127872706c2d636f6d6d6f6e2d" "7374646c6962312e322e33"); + StreamSink sink{beast::Severity::Debug}; + beast::Journal const journal{sink}; + auto& vm = WasmEngine::instance(); auto hfs = HostFunctions{}; auto imports = ImportVec{}; WasmImpFunc(imports, "func-add", reinterpret_cast(&add), &hfs); - auto _ = vm.run(kWasmModule, hfs, 10'000'000, "finish", wasmParams(1234), imports); - BEAST_EXPECT(true); + auto _ = vm.run(kWasmModule, hfs, 10'000'000, "finish", wasmParams(1234), imports, journal); + + auto const logged = sink.messages().str(); + BEAST_EXPECT(logged.find("Module version: xrpl-escrow-stdlib 4.5.6") != std::string::npos); + BEAST_EXPECT(logged.find("Module version: xrpl-common-stdlib 1.2.3") != std::string::npos); } void