diff --git a/include/xrpl/tx/wasm/WasmiVM.h b/include/xrpl/tx/wasm/WasmiVM.h index 61bbedfd1a..daa139cad6 100644 --- a/include/xrpl/tx/wasm/WasmiVM.h +++ b/include/xrpl/tx/wasm/WasmiVM.h @@ -77,9 +77,9 @@ using WasmImporttypeVec = WasmVec< struct WasmiResult { WasmValVec r; - bool f; // failure flag + bool f{false}; // failure flag - WasmiResult(unsigned N = 0) : r(N), f(false) + WasmiResult(unsigned N = 0) : r(N) { } diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 7077030ccc..dbdb40e94f 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -1013,7 +1013,7 @@ log10(Number const& x, int iterations) // (1 <= normalX < 10) // ln(x) = ln(normalX * 10^norm) = ln(normalX) + norm * ln(10) - int diffExp = 15 + x.exponent(); + int const diffExp = 15 + x.exponent(); Number const normalX = x / Number(1, diffExp); auto const lnX = ln(normalX, iterations) + diffExp * LN10; auto const lgX = lnX / LN10; diff --git a/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp b/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp index 0b31bcd6ce..627d3b7d3f 100644 --- a/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp +++ b/src/libxrpl/tx/wasm/HostFuncImplFloat.cpp @@ -52,7 +52,7 @@ public: if (m == 0) return; - Number x(makeNumber(m, decodedExponent)); + Number const x(makeNumber(m, decodedExponent)); if (m != x.mantissa() || decodedExponent != x.exponent()) return; // not canonical *static_cast(this) = x; @@ -194,7 +194,7 @@ std::string floatToString(Slice const& data) { // set default mode as we don't expect it will be used here - detail::FloatState rm(Number::rounding_mode::to_nearest); + detail::FloatState const rm(Number::rounding_mode::to_nearest); detail::Number2 const num(data); if (!num) { @@ -213,11 +213,11 @@ floatFromIntImpl(int64_t x, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 num(x); + detail::Number2 const num(x); return num.toBytes(); } // LCOV_EXCL_START @@ -234,11 +234,11 @@ floatFromUintImpl(uint64_t x, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 num(x); + detail::Number2 const num(x); auto r = num.toBytes(); return r; } @@ -256,10 +256,10 @@ floatSetImpl(int64_t mantissa, int32_t exponent, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 num(mantissa, exponent); + detail::Number2 const num(mantissa, exponent); if (!num) return Unexpected(HostFunctionError::FLOAT_COMPUTATION_ERROR); return num.toBytes(); @@ -277,11 +277,11 @@ floatCompareImpl(Slice const& x, Slice const& y) try { // set default mode as we don't expect it will be used here - detail::FloatState rm(Number::rounding_mode::to_nearest); - detail::Number2 xx(x); + detail::FloatState const rm(Number::rounding_mode::to_nearest); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 yy(y); + detail::Number2 const yy(y); if (!yy) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); if (xx < yy) @@ -304,17 +304,17 @@ floatAddImpl(Slice const& x, Slice const& y, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 yy(y); + detail::Number2 const yy(y); if (!yy) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res = xx + yy; + detail::Number2 const res = xx + yy; return res.toBytes(); } @@ -332,16 +332,16 @@ floatSubtractImpl(Slice const& x, Slice const& y, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 yy(y); + detail::Number2 const yy(y); if (!yy) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res = xx - yy; + detail::Number2 const res = xx - yy; return res.toBytes(); } @@ -359,16 +359,16 @@ floatMultiplyImpl(Slice const& x, Slice const& y, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 yy(y); + detail::Number2 const yy(y); if (!yy) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res = xx * yy; + detail::Number2 const res = xx * yy; return res.toBytes(); } @@ -386,16 +386,16 @@ floatDivideImpl(Slice const& x, Slice const& y, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 yy(y); + detail::Number2 const yy(y); if (!yy) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res = xx / yy; + detail::Number2 const res = xx / yy; return res.toBytes(); } @@ -414,15 +414,15 @@ floatRootImpl(Slice const& x, int32_t n, int32_t mode) if (n < 1) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res(root(xx, n)); + detail::Number2 const res(root(xx, n)); return res.toBytes(); } @@ -443,17 +443,17 @@ floatPowerImpl(Slice const& x, int32_t n, int32_t mode) if ((n < 0) || (n > wasmMaxExponent)) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); if (xx == Number() && (n == 0)) return Unexpected(HostFunctionError::INVALID_PARAMS); - detail::Number2 res(power(xx, n, 1)); + detail::Number2 const res(power(xx, n, 1)); return res.toBytes(); } @@ -471,15 +471,15 @@ floatLogImpl(Slice const& x, int32_t mode) { try { - detail::FloatState rm(mode); + detail::FloatState const rm(mode); if (!rm) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 xx(x); + detail::Number2 const xx(x); if (!xx) return Unexpected(HostFunctionError::FLOAT_INPUT_MALFORMED); - detail::Number2 res(log10(xx)); + detail::Number2 const res(log10(xx)); return res.toBytes(); } diff --git a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp index 6003aefd84..88598469e0 100644 --- a/src/libxrpl/tx/wasm/HostFuncWrapper.cpp +++ b/src/libxrpl/tx/wasm/HostFuncWrapper.cpp @@ -76,7 +76,7 @@ getDataUnsigned(IW const* runtime, wasm_val_vec_t const* params, int32_t& i) return Unexpected(HostFunctionError::INVALID_PARAMS); T x; - uintptr_t p = reinterpret_cast(r->data()); + uintptr_t const p = reinterpret_cast(r->data()); if (p & (alignof(T) - 1)) // unaligned { memcpy(&x, r->data(), sizeof(T)); @@ -328,7 +328,7 @@ static inline HostFunctions* getHF(void* env) { auto const* udata = reinterpret_cast(env); - HostFunctions* hf = reinterpret_cast(udata->first); + HostFunctions const* hf = reinterpret_cast(udata->first); return hf; } @@ -336,12 +336,12 @@ static inline Expected checkGas(void* env) { auto const* udata = reinterpret_cast(env); - HostFunctions* hf = reinterpret_cast(udata->first); + HostFunctions const* hf = reinterpret_cast(udata->first); auto const* runtime = reinterpret_cast(hf->getRT()); if (runtime == nullptr) { - wasm_trap_t* trap = reinterpret_cast( + wasm_trap_t const* trap = reinterpret_cast( WasmEngine::instance().newTrap("hf no runtime")); // LCOV_EXCL_LINE return Unexpected(trap); // LCOV_EXCL_LINE } @@ -352,14 +352,14 @@ checkGas(void* env) if (runtime->setGas(x) < 0) { - wasm_trap_t* trap = reinterpret_cast( + wasm_trap_t const* trap = reinterpret_cast( WasmEngine::instance().newTrap("can't set gas")); // LCOV_EXCL_LINE return Unexpected(trap); // LCOV_EXCL_LINE } if (gas < impFunc.gas) { - wasm_trap_t* trap = + wasm_trap_t const* trap = reinterpret_cast(WasmEngine::instance().newTrap("hf out of gas")); return Unexpected(trap); } @@ -375,7 +375,7 @@ getLedgerSqn_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* resul return g.error(); // LCOV_EXCL_LINE auto* hf = getHF(env); auto const* runtime = reinterpret_cast(hf->getRT()); - int index = 0; + int const index = 0; return returnResult(runtime, params, results, hf->getLedgerSqn(), index); } @@ -387,7 +387,7 @@ getParentLedgerTime_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t return g.error(); // LCOV_EXCL_LINE auto* hf = getHF(env); auto const* runtime = reinterpret_cast(hf->getRT()); - int index = 0; + int const index = 0; return returnResult(runtime, params, results, hf->getParentLedgerTime(), index); } @@ -399,7 +399,7 @@ getParentLedgerHash_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t return g.error(); // LCOV_EXCL_LINE auto* hf = getHF(env); auto const* runtime = reinterpret_cast(hf->getRT()); - int index = 0; + int const index = 0; return returnResult(runtime, params, results, hf->getParentLedgerHash(), index); } @@ -411,7 +411,7 @@ getBaseFee_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results return g.error(); // LCOV_EXCL_LINE auto* hf = getHF(env); auto const* runtime = reinterpret_cast(hf->getRT()); - int index = 0; + int const index = 0; return returnResult(runtime, params, results, hf->getBaseFee(), index); } @@ -1818,11 +1818,11 @@ testGetDataIncrement() wasm_val_t values[4]; std::array buffer = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; - MockInstanceWrapper runtime(wmem{buffer.data(), buffer.size()}); + MockInstanceWrapper const runtime(wmem{buffer.data(), buffer.size()}); { // test int32_t - wasm_val_vec_t params = {1, &values[0]}; + wasm_val_vec_t const params = {1, &values[0]}; values[0] = WASM_I32_VAL(42); @@ -1834,7 +1834,7 @@ testGetDataIncrement() { // test int64_t - wasm_val_vec_t params = {1, &values[0]}; + wasm_val_vec_t const params = {1, &values[0]}; values[0] = WASM_I64_VAL(1234); @@ -1846,7 +1846,7 @@ testGetDataIncrement() { // test SFieldCRef - wasm_val_vec_t params = {1, &values[0]}; + wasm_val_vec_t const params = {1, &values[0]}; values[0] = WASM_I32_VAL(sfAccount.fieldCode); @@ -1858,7 +1858,7 @@ testGetDataIncrement() { // test Slice - wasm_val_vec_t params = {2, &values[0]}; + wasm_val_vec_t const params = {2, &values[0]}; values[0] = WASM_I32_VAL(0); values[1] = WASM_I32_VAL(3); @@ -1871,7 +1871,7 @@ testGetDataIncrement() { // test string - wasm_val_vec_t params = {2, &values[0]}; + wasm_val_vec_t const params = {2, &values[0]}; values[0] = WASM_I32_VAL(0); values[1] = WASM_I32_VAL(5); @@ -1889,7 +1889,7 @@ testGetDataIncrement() AccountID const id( calcAccountID(generateKeyPair(KeyType::secp256k1, generateSeed("alice")).first)); - wasm_val_vec_t params = {2, &values[0]}; + wasm_val_vec_t const params = {2, &values[0]}; values[0] = WASM_I32_VAL(0); values[1] = WASM_I32_VAL(id.bytes); @@ -1905,7 +1905,7 @@ testGetDataIncrement() // test uint256 Hash h1 = sha512Half(Slice(buffer.data(), 8)); - wasm_val_vec_t params = {2, &values[0]}; + wasm_val_vec_t const params = {2, &values[0]}; values[0] = WASM_I32_VAL(0); values[1] = WASM_I32_VAL(h1.bytes); @@ -1921,7 +1921,7 @@ testGetDataIncrement() // test Currency Currency const c = xrpCurrency(); - wasm_val_vec_t params = {2, &values[0]}; + wasm_val_vec_t const params = {2, &values[0]}; values[0] = WASM_I32_VAL(0); values[1] = WASM_I32_VAL(c.bytes); diff --git a/src/libxrpl/tx/wasm/WasmiVM.cpp b/src/libxrpl/tx/wasm/WasmiVM.cpp index 8147f84588..622311540a 100644 --- a/src/libxrpl/tx/wasm/WasmiVM.cpp +++ b/src/libxrpl/tx/wasm/WasmiVM.cpp @@ -376,7 +376,7 @@ ModuleWrapper::buildImports(StorePtr& s, ImportVec const& imports) const WasmValtypeVec params(makeImpParams(imp)); WasmValtypeVec results(makeImpReturn(imp)); - std::unique_ptr ftype( + std::unique_ptr const ftype( wasm_functype_new(¶ms.vec_, &results.vec_), &wasm_functype_delete); params.release(); @@ -769,7 +769,7 @@ WasmiEngine::runHlp( ImportVec const& imports) { // currently only 1 module support, possible parallel UT run - std::lock_guard lg(m_); + std::lock_guard const lg(m_); if (wasmCode.empty()) throw std::runtime_error("empty module"); @@ -866,7 +866,7 @@ WasmiEngine::checkHlp( ImportVec const& imports) { // currently only 1 module support, possible parallel UT run - std::lock_guard lg(m_); + std::lock_guard const lg(m_); // Create and instantiate the module. if (wasmCode.empty()) @@ -918,7 +918,7 @@ WasmiEngine::newTrap(std::string const& txt) if (!txt.empty()) wasm_name_new(&msg, txt.size() + 1, txt.c_str()); // include 0 - wasm_trap_t* trap = wasm_trap_new(store_.get(), &msg); + wasm_trap_t const* trap = wasm_trap_new(store_.get(), &msg); if (!txt.empty()) wasm_byte_vec_delete(&msg); diff --git a/src/test/app/HostFuncImpl_test.cpp b/src/test/app/HostFuncImpl_test.cpp index e77c3ded0c..e46634ca44 100644 --- a/src/test/app/HostFuncImpl_test.cpp +++ b/src/test/app/HostFuncImpl_test.cpp @@ -95,7 +95,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const result = hfs.getLedgerSqn(); if (BEAST_EXPECT(result.has_value())) @@ -114,7 +114,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const result = hfs.getParentLedgerTime(); if (BEAST_EXPECT(result.has_value())) { @@ -135,7 +135,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const result = hfs.getParentLedgerHash(); if (BEAST_EXPECT(result.has_value())) @@ -153,7 +153,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const result = hfs.getBaseFee(); if (BEAST_EXPECT(result.has_value())) @@ -170,7 +170,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); // Use featureTokenEscrow for testing auto const amendmentId = featureTokenEscrow; @@ -191,7 +191,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite } // Test with a fake amendment id (all zeros) - uint256 fakeId; + uint256 const fakeId; { auto const result = hfs.isAmendmentEnabled(fakeId); BEAST_EXPECT(result.has_value()); @@ -199,7 +199,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite } // Test with a fake amendment name - std::string fakeName = "FakeAmendment"; + std::string const fakeName = "FakeAmendment"; { auto const result = hfs.isAmendmentEnabled(fakeName); BEAST_EXPECT(result.has_value()); @@ -280,7 +280,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); { - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const account = hfs.getTxField(sfAccount); BEAST_EXPECT(account && std::ranges::equal(*account, env.master.id())); @@ -326,10 +326,10 @@ struct HostFuncImpl_test : public beast::unit_test::suite obj.setFieldIssue(sfAsset2, STIssue{sfAsset2, iouAsset.issue()}); }); ApplyContext ac2 = createApplyContext(env, ov, stx2); - WasmHostFunctionsImpl hfs(ac2, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac2, dummyEscrow); auto const asset = hfs.getTxField(sfAsset); - std::vector expectedAsset(20, 0); + std::vector const expectedAsset(20, 0); BEAST_EXPECT(asset && *asset == expectedAsset); auto const asset2 = hfs.getTxField(sfAsset2); @@ -345,7 +345,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite obj.setFieldIssue(sfAsset2, STIssue{sfAsset2, MPTIssue{mptId}}); }); ApplyContext ac2 = createApplyContext(env, ov, stx2); - WasmHostFunctionsImpl hfs(ac2, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac2, dummyEscrow); auto const asset = hfs.getTxField(sfAsset); if (BEAST_EXPECT(asset.has_value())) @@ -367,7 +367,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite obj.setFieldU8(sfAssetScale, expectedScale); }); ApplyContext ac2 = createApplyContext(env, ov, stx2); - WasmHostFunctionsImpl hfs(ac2, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac2, dummyEscrow); auto const actualScale = hfs.getTxField(sfAssetScale); if (BEAST_EXPECT(actualScale.has_value())) @@ -397,7 +397,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite auto const escrowKeylet = keylet::escrow(env.master, env.seq(env.master) - 1); BEAST_EXPECT(env.le(escrowKeylet)); - WasmHostFunctionsImpl hfs(ac, escrowKeylet); + WasmHostFunctionsImpl const hfs(ac, escrowKeylet); // Should return the Account field from the escrow ledger object auto const account = hfs.getCurrentLedgerObjField(sfAccount); @@ -425,7 +425,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master) + 5); - WasmHostFunctionsImpl hfs2(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs2(ac, dummyEscrow); auto const account = hfs2.getCurrentLedgerObjField(sfAccount); if (BEAST_EXPECT(!account.has_value())) { @@ -524,14 +524,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator is a sequence of int32_t codes: // [sfMemos.fieldCode, 0, sfMemoData.fieldCode] std::vector locatorVec = {sfMemos.fieldCode, 0, sfMemoData.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const result = hfs.getTxNestedField(locator); if (BEAST_EXPECTS(result.has_value(), std::to_string(static_cast(result.error())))) { - std::string memoData(result.value().begin(), result.value().end()); + std::string const memoData(result.value().begin(), result.value().end()); BEAST_EXPECT(memoData == "hello"); } } @@ -539,14 +539,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite { // Locator for sfCredentialIDs[0] std::vector locatorVec = {sfCredentialIDs.fieldCode, 0}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const result = hfs.getTxNestedField(locator); if (BEAST_EXPECTS(result.has_value(), std::to_string(static_cast(result.error())))) { - std::string credIdResult(result.value().begin(), result.value().end()); + std::string const credIdResult(result.value().begin(), result.value().end()); BEAST_EXPECT(strHex(credIdResult) == credIdHex); } } @@ -554,7 +554,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { // can use the nested locator for base fields too std::vector locatorVec = {sfAccount.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); @@ -570,7 +570,8 @@ struct HostFuncImpl_test : public beast::unit_test::suite // unaligned locator std::vector locatorVec(sizeof(int32_t) + 1); memcpy(locatorVec.data() + 1, &sfAccount.fieldCode, sizeof(int32_t)); - Slice locator(reinterpret_cast(locatorVec.data() + 1), sizeof(int32_t)); + Slice const locator( + reinterpret_cast(locatorVec.data() + 1), sizeof(int32_t)); auto const account = hfs.getTxNestedField(locator); if (BEAST_EXPECTS( @@ -582,7 +583,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite auto expectError = [&](std::vector const& locatorVec, HostFunctionError expectedError) { - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const result = hfs.getTxNestedField(locator); @@ -687,7 +688,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for malformed locator (not multiple of 4) { std::vector locatorVec = {sfMemos.fieldCode}; - Slice malformedLocator(reinterpret_cast(locatorVec.data()), 3); + Slice const malformedLocator(reinterpret_cast(locatorVec.data()), 3); auto const malformedResult = hfs.getTxNestedField(malformedLocator); BEAST_EXPECT( !malformedResult.has_value() && @@ -718,7 +719,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for base field std::vector baseLocator = {sfSignerQuorum.fieldCode}; - Slice baseLocatorSlice( + Slice const baseLocatorSlice( reinterpret_cast(baseLocator.data()), baseLocator.size() * sizeof(int32_t)); auto const signerQuorum = hfs.getCurrentLedgerObjNestedField(baseLocatorSlice); @@ -730,7 +731,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite auto expectError = [&](std::vector const& locatorVec, HostFunctionError expectedError) { - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const result = hfs.getCurrentLedgerObjNestedField(locator); @@ -755,7 +756,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite HostFunctionError::LOCATOR_MALFORMED); // Locator for empty locator - Slice emptyLocator(nullptr, 0); + Slice const emptyLocator(nullptr, 0); auto const emptyResult = hfs.getCurrentLedgerObjNestedField(emptyLocator); BEAST_EXPECT( !emptyResult.has_value() && @@ -763,7 +764,8 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for malformed locator (not multiple of 4) std::vector malformedLocatorVec = {sfMemos.fieldCode}; - Slice malformedLocator(reinterpret_cast(malformedLocatorVec.data()), 3); + Slice const malformedLocator( + reinterpret_cast(malformedLocatorVec.data()), 3); auto const malformedResult = hfs.getCurrentLedgerObjNestedField(malformedLocator); BEAST_EXPECT( !malformedResult.has_value() && @@ -771,9 +773,9 @@ struct HostFuncImpl_test : public beast::unit_test::suite { auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master) + 5); - WasmHostFunctionsImpl dummyHfs(ac, dummyEscrow); + WasmHostFunctionsImpl const dummyHfs(ac, dummyEscrow); std::vector const locatorVec = {sfAccount.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const result = dummyHfs.getCurrentLedgerObjNestedField(locator); @@ -814,7 +816,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { std::vector const locatorVec = { sfSignerEntries.fieldCode, 0, sfAccount.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); @@ -963,7 +965,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; // Transaction with an array field - STTx stx = STTx(ttESCROW_FINISH, [&](auto& obj) { + STTx const stx = STTx(ttESCROW_FINISH, [&](auto& obj) { obj.setAccountID(sfAccount, env.master.id()); STArray memos; { @@ -984,7 +986,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov, stx); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); // Should return 1 for sfMemos auto const memosLen = hfs.getTxArrayLen(sfMemos); @@ -1024,7 +1026,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const signerKeylet = keylet::signers(env.master.id()); - WasmHostFunctionsImpl hfs(ac, signerKeylet); + WasmHostFunctionsImpl const hfs(ac, signerKeylet); auto const entriesLen = hfs.getCurrentLedgerObjArrayLen(sfSignerEntries); if (BEAST_EXPECT(entriesLen.has_value())) @@ -1041,7 +1043,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master) + 5); - WasmHostFunctionsImpl dummyHfs(ac, dummyEscrow); + WasmHostFunctionsImpl const dummyHfs(ac, dummyEscrow); auto const len = dummyHfs.getCurrentLedgerObjArrayLen(sfMemos); if (BEAST_EXPECT(!len.has_value())) BEAST_EXPECT(len.error() == HostFunctionError::LEDGER_OBJ_NOT_FOUND); @@ -1116,7 +1118,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env{*this}; OpenView ov{*env.current()}; - STTx stx = STTx(ttESCROW_FINISH, [&](auto& obj) { + STTx const stx = STTx(ttESCROW_FINISH, [&](auto& obj) { STArray memos; STObject memoObj(sfMemo); memoObj.setFieldVL(sfMemoData, Slice("hello", 5)); @@ -1147,7 +1149,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for sfMemos { std::vector locatorVec = {sfMemos.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const arrLen = hfs.getTxNestedArrayLen(locator); @@ -1199,7 +1201,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for sfSignerEntries { std::vector locatorVec = {sfSignerEntries.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const arrLen = hfs.getCurrentLedgerObjNestedArrayLen(locator); @@ -1214,7 +1216,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite { auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master) + 5); - WasmHostFunctionsImpl dummyHfs(ac, dummyEscrow); + WasmHostFunctionsImpl const dummyHfs(ac, dummyEscrow); std::vector locatorVec = {sfAccount.fieldCode}; Slice const locator( reinterpret_cast(locatorVec.data()), @@ -1253,7 +1255,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite // Locator for sfSignerEntries std::vector locatorVec = {sfSignerEntries.fieldCode}; - Slice locator( + Slice const locator( reinterpret_cast(locatorVec.data()), locatorVec.size() * sizeof(int32_t)); auto const arrLen = hfs.getLedgerObjNestedArrayLen(1, locator); @@ -1293,7 +1295,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite expectError({}, HostFunctionError::LOCATOR_MALFORMED); // Error: locator malformed (not multiple of 4) - Slice malformedLocator(reinterpret_cast(locator.data()), 3); + Slice const malformedLocator(reinterpret_cast(locator.data()), 3); auto const malformed = hfs.getLedgerObjNestedArrayLen(1, malformedLocator); BEAST_EXPECT( !malformed.has_value() && malformed.error() == HostFunctionError::LOCATOR_MALFORMED); @@ -1344,7 +1346,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); // Generate a keypair and sign a message auto const kp = generateKeyPair(KeyType::secp256k1, randomSeed()); @@ -1425,7 +1427,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); std::string data = "hello world"; auto const result = hfs.computeSha512HalfHash(Slice(data.data(), data.size())); @@ -1447,7 +1449,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto compareKeylet = [](std::vector const& bytes, Keylet const& kl) { return std::ranges::equal(bytes, kl.key); @@ -1549,7 +1551,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite COMPARE_KEYLET(escrowKeylet, keylet::escrow, env.master.id(), 1); COMPARE_KEYLET_FAIL(escrowKeylet, HostFunctionError::INVALID_ACCOUNT, xrpAccount(), 1); - Currency usd = to_currency("USD"); + Currency const usd = to_currency("USD"); COMPARE_KEYLET(lineKeylet, keylet::line, env.master.id(), alice.id(), usd); COMPARE_KEYLET_FAIL( lineKeylet, HostFunctionError::INVALID_PARAMS, env.master.id(), env.master.id(), usd); @@ -1639,7 +1641,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(alice, env.seq(alice)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); // Should succeed for valid NFT { @@ -1694,7 +1696,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); // Should succeed for valid NFT id { @@ -1728,7 +1730,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const result = hfs.getNFTTaxon(nftId); if (BEAST_EXPECT(result.has_value())) @@ -1752,7 +1754,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.getNFTFlags(nftId); @@ -1785,7 +1787,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.getNFTTransferFee(nftId); @@ -1819,7 +1821,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.getNFTSerial(nftId); @@ -1845,13 +1847,13 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kTrace}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "test trace"; + std::string const msg = "test trace"; std::string data = "abc"; auto const slice = Slice(data.data(), data.size()); auto const result = hfs.trace(msg, slice, false); @@ -1881,13 +1883,13 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kError}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "test trace"; + std::string const msg = "test trace"; std::string data = "abc"; auto const slice = Slice(data.data(), data.size()); auto const result = hfs.trace(msg, slice, false); @@ -1907,14 +1909,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kTrace}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace number"; - int64_t num = 123456789; + std::string const msg = "trace number"; + int64_t const num = 123456789; auto const result = hfs.traceNum(msg, num); if (BEAST_EXPECT(result.has_value())) { @@ -1930,14 +1932,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kError}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace number"; - int64_t num = 123456789; + std::string const msg = "trace number"; + int64_t const num = 123456789; auto const result = hfs.traceNum(msg, num); BEAST_EXPECT(result && *result == 0); auto const messages = sink.messages().str(); @@ -1955,13 +1957,13 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kTrace}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace account"; + std::string const msg = "trace account"; auto const result = hfs.traceAccount(msg, env.master.id()); if (BEAST_EXPECT(result.has_value())) { @@ -1977,12 +1979,12 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kError}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); - std::string msg = "trace account"; + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); + std::string const msg = "trace account"; auto const result = hfs.traceAccount(msg, env.master.id()); BEAST_EXPECT(result && *result == 0); auto const messages = sink.messages().str(); @@ -2000,14 +2002,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kTrace}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace amount"; - STAmount amount = XRP(12345); + std::string const msg = "trace amount"; + STAmount const amount = XRP(12345); { auto const result = hfs.traceAmount(msg, amount); if (BEAST_EXPECT(result.has_value())) @@ -2023,7 +2025,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite Account const alice("alice"); env.fund(XRP(1000), alice); env.close(); - STAmount iouAmount = env.master["USD"](100); + STAmount const iouAmount = env.master["USD"](100); { auto const result = hfs.traceAmount(msg, iouAmount); if (BEAST_EXPECT(result.has_value())) @@ -2033,8 +2035,8 @@ struct HostFuncImpl_test : public beast::unit_test::suite // MPT amount { auto const mptId = makeMptID(42, env.master.id()); - Asset mptAsset = Asset(mptId); - STAmount mptAmount(mptAsset, 123456); + Asset const mptAsset = Asset(mptId); + STAmount const mptAmount(mptAsset, 123456); auto const result = hfs.traceAmount(msg, mptAmount); if (BEAST_EXPECT(result.has_value())) BEAST_EXPECT(*result == 0); @@ -2046,14 +2048,14 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kError}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace amount"; - STAmount amount = XRP(12345); + std::string const msg = "trace amount"; + STAmount const amount = XRP(12345); auto const result = hfs.traceAmount(msg, amount); BEAST_EXPECT(result && *result == 0); auto const messages = sink.messages().str(); @@ -2098,9 +2100,9 @@ struct HostFuncImpl_test : public beast::unit_test::suite ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace float"; + std::string const msg = "trace float"; { auto const result = hfs.traceFloat(msg, makeSlice(invalid)); @@ -2118,13 +2120,13 @@ struct HostFuncImpl_test : public beast::unit_test::suite Env env(*this); OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kError}; - beast::Journal jlog{sink}; + beast::Journal const jlog{sink}; ApplyContext ac = createApplyContext(env, ov, jlog); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); - std::string msg = "trace float"; + std::string const msg = "trace float"; auto const result = hfs.traceFloat(msg, makeSlice(invalid)); BEAST_EXPECT(result && *result == 0); @@ -2143,7 +2145,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatFromInt(std::numeric_limits::min(), -1); @@ -2183,7 +2185,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatFromUint(std::numeric_limits::min(), -1); @@ -2219,7 +2221,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatSet(1, 0, -1); @@ -2291,7 +2293,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatCompare(Slice(), Slice()); @@ -2345,7 +2347,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatAdd(Slice(), Slice(), -1); @@ -2392,7 +2394,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatSubtract(Slice(), Slice(), -1); @@ -2441,7 +2443,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatMultiply(Slice(), Slice(), -1); @@ -2494,7 +2496,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatDivide(Slice(), Slice(), -1); @@ -2551,7 +2553,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatRoot(Slice(), 2, -1); @@ -2620,7 +2622,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatPower(Slice(), 2, -1); @@ -2698,7 +2700,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); { auto const result = hfs.floatLog(Slice(), -1); @@ -2801,7 +2803,7 @@ struct HostFuncImpl_test : public beast::unit_test::suite OpenView ov{*env.current()}; ApplyContext ac = createApplyContext(env, ov); auto const dummyEscrow = keylet::escrow(env.master, env.seq(env.master)); - WasmHostFunctionsImpl hfs(ac, dummyEscrow); + WasmHostFunctionsImpl const hfs(ac, dummyEscrow); auto const y = hfs.floatSet(20, 0, 0); if (!BEAST_EXPECT(y)) diff --git a/src/test/app/Wasm_test.cpp b/src/test/app/Wasm_test.cpp index 93add98f3a..b875eaef50 100644 --- a/src/test/app/Wasm_test.cpp +++ b/src/test/app/Wasm_test.cpp @@ -18,8 +18,8 @@ using Add_proto = int32_t(int32_t, int32_t); static wasm_trap_t* Add(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results) { - int32_t Val1 = params->data[0].of.i32; - int32_t Val2 = params->data[1].of.i32; + int32_t const Val1 = params->data[0].of.i32; + int32_t const Val2 = params->data[1].of.i32; // printf("Host function \"Add\": %d + %d\n", Val1, Val2); results->data[0] = WASM_I32_VAL(Val1 + Val2); return nullptr; @@ -204,12 +204,12 @@ struct Wasm_test : public beast::unit_test::suite using namespace test::jtx; - Env env{*this}; + Env const env{*this}; HostFunctions hfs(env.journal); { auto wasm = hexToBytes("00000000"); - std::string funcName("mock_escrow"); + std::string const funcName("mock_escrow"); auto re = runEscrowWasm(wasm, hfs, 15, funcName, {}); BEAST_EXPECT(!re); @@ -217,7 +217,7 @@ struct Wasm_test : public beast::unit_test::suite { auto wasm = hexToBytes("00112233445566778899AA"); - std::string funcName("mock_escrow"); + std::string const funcName("mock_escrow"); auto const re = preflightEscrowWasm(wasm, hfs, funcName); BEAST_EXPECT(!isTesSuccess(re)); @@ -503,7 +503,7 @@ struct Wasm_test : public beast::unit_test::suite auto const deepWasm = hexToBytes(deepRecursionHex); TestHostFunctionsSink hfs(env); - std::string funcName("finish"); + std::string const funcName("finish"); auto re = runEscrowWasm(deepWasm, hfs, 1'000'000'000, funcName, {}); BEAST_EXPECT(!re && re.error()); // std::cout << "bad case (deep recursion) result " << re.error() @@ -755,7 +755,7 @@ struct Wasm_test : public beast::unit_test::suite auto const startLoopWasm = hexToBytes(startLoopHex); TestLedgerDataProvider hfs(env); - ImportVec imports; + ImportVec const imports; auto& engine = WasmEngine::instance(); auto checkRes = engine.check(startLoopWasm, hfs, "finish", {}, imports, env.journal); @@ -971,6 +971,7 @@ struct Wasm_test : public beast::unit_test::suite // add 1k parameter (max that wasmi support) std::vector params; + params.reserve(1000); for (int i = 0; i < 1000; ++i) params.push_back({.type = WT_I32, .of = {.i32 = 2 * i}}); @@ -1012,7 +1013,7 @@ struct Wasm_test : public beast::unit_test::suite using namespace test::jtx; unsigned const RESERVED = 64; - std::uint8_t nop = 0x01; + std::uint8_t const nop = 0x01; std::array const codeMarker = { nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop}; auto const opcReserved = hexToBytes(opcReservedHex); diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index 71b4b388db..0079b540b0 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -1582,7 +1582,7 @@ public: } else { - NumberRoundModeGuard mg(Number::towards_zero); + NumberRoundModeGuard const mg(Number::towards_zero); test(cLarge); }