Skip to content

Commit

Permalink
Add basic REST tests and fix a few bugs (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnerd authored Apr 6, 2024
1 parent de7268f commit 4c22059
Show file tree
Hide file tree
Showing 7 changed files with 633 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/rest_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ namespace lws
MONERO_CHECK((*tclient)->send(std::move(msg), std::chrono::seconds{10}));
}

if ((req.use_dust && req.use_dust) || !req.dust_threshold)
if ((req.use_dust && *req.use_dust) || !req.dust_threshold)
req.dust_threshold = rpc::safe_uint64(0);

if (!req.mixin)
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/light_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ namespace lws
wire::field("coinbase", is_coinbase),
wire::field("mempool", false),
wire::field("mixin", self.value().info.spend_meta.mixin_count),
wire::field("recipient", self.value().info.recipient),
wire::field("spent_outputs", std::cref(self.value().spends))
);
}
Expand Down Expand Up @@ -316,7 +317,7 @@ namespace lws
WIRE_FIELD_COPY(per_byte_fee),
WIRE_FIELD_COPY(fee_mask),
WIRE_FIELD_COPY(amount),
wire::field("outputs", wire::array(boost::adaptors::transform(self.outputs, expand)))
wire::optional_field("outputs", wire::array(boost::adaptors::transform(self.outputs, expand)))
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/wire/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace wire
static constexpr bool optional_on_empty() noexcept
{ return is_optional_on_empty<value_type>::value; }

static constexpr bool is_required() noexcept { return Required; }
static constexpr bool is_required() noexcept { return Required && !optional_on_empty(); }
static constexpr std::size_t count() noexcept { return 1; }
static constexpr unsigned id() noexcept { return I; }

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ add_subdirectory(db)
add_subdirectory(rpc)
add_subdirectory(wire)

add_executable(monero-lws-unit main.cpp scanner.test.cpp)
add_executable(monero-lws-unit main.cpp rest.test.cpp scanner.test.cpp)
target_link_libraries(monero-lws-unit
monero::libraries
monero-lws-daemon-common
Expand Down
Loading

0 comments on commit 4c22059

Please sign in to comment.