Skip to content

Commit 9cee419

Browse files
UdjinM6schinzelh
authored andcommitted
Separate .h generation from .json/.raw for different modules (dashpay#1870)
1 parent 83957f2 commit 9cee419

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/Makefile.bench.include

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ bench: $(BENCH_BINARY) FORCE
6868
bitcoin_bench_clean : FORCE
6969
rm -f $(CLEAN_BITCOIN_BENCH) $(bench_bench_dash_OBJECTS) $(BENCH_BINARY)
7070

71-
%.raw.h: %.raw
71+
bench/data/%.raw.h: bench/data/%.raw
7272
@$(MKDIR_P) $(@D)
7373
@{ \
74+
echo "namespace raw_bench{" && \
7475
echo "static unsigned const char $(*F)[] = {" && \
7576
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
76-
echo "};"; \
77+
echo "};};"; \
7778
} > "$@.new" && mv -f "$@.new" "$@"
7879
@echo "Generated $@"

src/Makefile.test.include

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ if EMBEDDED_UNIVALUE
183183
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
184184
endif
185185

186-
%.json.h: %.json
186+
test/data/%.json.h: test/data/%.json
187187
@$(MKDIR_P) $(@D)
188188
@{ \
189189
echo "namespace json_tests{" && \
@@ -193,11 +193,12 @@ endif
193193
} > "$@.new" && mv -f "$@.new" "$@"
194194
@echo "Generated $@"
195195

196-
test/data/alertTests.raw.h: test/data/alertTests.raw
196+
test/data/%.raw.h: test/data/%.raw
197197
@$(MKDIR_P) $(@D)
198198
@{ \
199+
echo "namespace raw_tests{" && \
199200
echo "static unsigned const char $(*F)[] = {" && \
200-
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
201-
echo "};"; \
201+
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
202+
echo "};};"; \
202203
} > "$@.new" && mv -f "$@.new" "$@"
203204
@echo "Generated $@"

src/bench/checkblock.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@
99
#include "streams.h"
1010
#include "consensus/validation.h"
1111

12-
namespace block_bench {
1312
#include "bench/data/block413567.raw.h"
14-
}
1513

1614
// These are the two major time-sinks which happen after we have fully received
1715
// a block off the wire, but before we can relay the block on to peers using
1816
// compact block relay.
1917

2018
static void DeserializeBlockTest(benchmark::State& state)
2119
{
22-
CDataStream stream((const char*)block_bench::block413567,
23-
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
20+
CDataStream stream((const char*)raw_bench::block413567,
21+
(const char*)&raw_bench::block413567[sizeof(raw_bench::block413567)],
2422
SER_NETWORK, PROTOCOL_VERSION);
2523
char a;
2624
stream.write(&a, 1); // Prevent compaction
2725

2826
while (state.KeepRunning()) {
2927
CBlock block;
3028
stream >> block;
31-
assert(stream.Rewind(sizeof(block_bench::block413567)));
29+
assert(stream.Rewind(sizeof(raw_bench::block413567)));
3230
}
3331
}
3432

3533
static void DeserializeAndCheckBlockTest(benchmark::State& state)
3634
{
37-
CDataStream stream((const char*)block_bench::block413567,
38-
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
35+
CDataStream stream((const char*)raw_bench::block413567,
36+
(const char*)&raw_bench::block413567[sizeof(raw_bench::block413567)],
3937
SER_NETWORK, PROTOCOL_VERSION);
4038
char a;
4139
stream.write(&a, 1); // Prevent compaction
@@ -45,7 +43,7 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state)
4543
while (state.KeepRunning()) {
4644
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
4745
stream >> block;
48-
assert(stream.Rewind(sizeof(block_bench::block413567)));
46+
assert(stream.Rewind(sizeof(raw_bench::block413567)));
4947

5048
CValidationState validationState;
5149
assert(CheckBlock(block, validationState, params, block.GetBlockTime()));

src/test/alert_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct ReadAlerts : public TestingSetup
110110
{
111111
ReadAlerts()
112112
{
113-
std::vector<unsigned char> vch(alertTests, alertTests + sizeof(alertTests));
113+
std::vector<unsigned char> vch(raw_tests::alertTests, raw_tests::alertTests + sizeof(raw_tests::alertTests));
114114
CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
115115
try {
116116
while (!stream.eof())

0 commit comments

Comments
 (0)