Skip to content

Commit 9c3b5df

Browse files
tests: Make CTransaction and CMutableTransaction share the same corpus. Verify that they are (de)serialized in the same way.
1 parent 47ccb20 commit 9c3b5df

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

src/Makefile.test.include

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ FUZZ_TARGETS = \
3030
test/fuzz/key_origin_info_deserialize \
3131
test/fuzz/merkle_block_deserialize \
3232
test/fuzz/messageheader_deserialize \
33-
test/fuzz/mutable_transaction_deserialize \
3433
test/fuzz/netaddr_deserialize \
3534
test/fuzz/out_point_deserialize \
3635
test/fuzz/partial_merkle_tree_deserialize \
@@ -411,12 +410,6 @@ test_fuzz_merkle_block_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
411410
test_fuzz_merkle_block_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
412411
test_fuzz_merkle_block_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
413412

414-
test_fuzz_mutable_transaction_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
415-
test_fuzz_mutable_transaction_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMUTABLE_TRANSACTION_DESERIALIZE=1
416-
test_fuzz_mutable_transaction_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
417-
test_fuzz_mutable_transaction_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
418-
test_fuzz_mutable_transaction_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
419-
420413
test_fuzz_out_point_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
421414
test_fuzz_out_point_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DOUT_POINT_DESERIALIZE=1
422415
test_fuzz_out_point_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

src/test/fuzz/deserialize.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ void test_one_input(const std::vector<uint8_t>& buffer)
8888
ds >> merkle_block;
8989
} catch (const std::ios_base::failure&) {
9090
}
91-
#elif MUTABLE_TRANSACTION_DESERIALIZE
92-
try {
93-
CMutableTransaction mutable_transaction;
94-
ds >> mutable_transaction;
95-
} catch (const std::ios_base::failure&) {
96-
}
9791
#elif OUT_POINT_DESERIALIZE
9892
try {
9993
COutPoint out_point;

src/test/fuzz/transaction.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,31 @@ void test_one_input(const std::vector<uint8_t>& buffer)
2626
int nVersion;
2727
ds >> nVersion;
2828
ds.SetVersion(nVersion);
29-
} catch (const std::ios_base::failure& e) {
29+
} catch (const std::ios_base::failure&) {
3030
return;
3131
}
32-
bool valid = true;
32+
bool valid_tx = true;
3333
const CTransaction tx = [&] {
3434
try {
3535
return CTransaction(deserialize, ds);
36-
} catch (const std::ios_base::failure& e) {
37-
valid = false;
36+
} catch (const std::ios_base::failure&) {
37+
valid_tx = false;
3838
return CTransaction();
3939
}
4040
}();
41-
if (!valid) {
41+
bool valid_mutable_tx = true;
42+
CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION);
43+
CMutableTransaction mutable_tx;
44+
try {
45+
int nVersion;
46+
ds_mtx >> nVersion;
47+
ds_mtx.SetVersion(nVersion);
48+
ds_mtx >> mutable_tx;
49+
} catch (const std::ios_base::failure&) {
50+
valid_mutable_tx = false;
51+
}
52+
assert(valid_tx == valid_mutable_tx);
53+
if (!valid_tx) {
4254
return;
4355
}
4456

test/fuzz/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"flat_file_pos_deserialize",
2525
"key_origin_info_deserialize",
2626
"merkle_block_deserialize",
27-
"mutable_transaction_deserialize",
2827
"out_point_deserialize",
2928
"partial_merkle_tree_deserialize",
3029
"partially_signed_transaction_deserialize",

0 commit comments

Comments
 (0)