Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
hive
hive
Commits
00efa447
Commit
00efa447
authored
Aug 21, 2020
by
Bartek Wrona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dedicated testcase to show correctly working unpacking of bip::vector container.
parent
c55963c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
tests/unit/tests/serialization_tests.cpp
tests/unit/tests/serialization_tests.cpp
+50
-0
No files found.
tests/unit/tests/serialization_tests.cpp
View file @
00efa447
...
...
@@ -46,6 +46,56 @@ using namespace hive::protocol;
BOOST_FIXTURE_TEST_SUITE
(
serialization_tests
,
clean_database_fixture
)
BOOST_AUTO_TEST_CASE
(
transaction_object_test
)
{
ACTORS
((
alice
)(
bob
))
transfer_operation
op
;
op
.
from
=
"alice"
;
op
.
to
=
"bob"
;
op
.
amount
=
asset
(
100
,
HIVE_SYMBOL
);
trx
.
operations
.
push_back
(
op
);
auto
&
index
=
db
->
get_mutable_index
<
hive
::
chain
::
transaction_index
>
();
const
auto
&
txo
=
db
->
create
<
hive
::
chain
::
transaction_object
>
([
&
](
chain
::
transaction_object
&
transaction
)
{
transaction
.
trx_id
=
trx
.
id
();
transaction
.
expiration
=
trx
.
expiration
;
fc
::
raw
::
pack_to_buffer
(
transaction
.
packed_trx
,
trx
);
ilog
(
"TRX packed into vector having ${s} bytes lentgh"
,
(
"s"
,
transaction
.
packed_trx
.
size
()));
});
std
::
vector
<
char
>
packed_trx_copy
(
txo
.
packed_trx
.
cbegin
(),
txo
.
packed_trx
.
cend
());
auto
packed
=
fc
::
raw
::
pack_to_vector
(
txo
);
ilog
(
"Generated vector size: ${s}"
,
(
"s"
,
packed
.
size
()));
std
::
string
s
=
fc
::
json
::
to_pretty_string
(
txo
);
ilog
(
"transaction_object dump: ${o}"
,
(
"o"
,
s
));
index
.
modify
(
txo
,
[](
chain
::
transaction_object
&
transaction
)
{
transaction
.
packed_trx
.
clear
();
}
);
s
=
fc
::
json
::
to_pretty_string
(
txo
);
ilog
(
"transaction_object dump: ${o}"
,
(
"o"
,
s
));
index
.
modify
(
txo
,
[
&
packed
](
chain
::
transaction_object
&
transaction
)
{
fc
::
raw
::
unpack_from_buffer
(
packed
,
transaction
);
});
s
=
fc
::
json
::
to_pretty_string
(
txo
);
ilog
(
"transaction_object dump: ${o}"
,
(
"o"
,
s
));
BOOST_CHECK
(
packed_trx_copy
.
size
()
==
txo
.
packed_trx
.
size
());
BOOST_CHECK
(
std
::
equal
(
packed_trx_copy
.
cbegin
(),
packed_trx_copy
.
cend
(),
txo
.
packed_trx
.
cbegin
()));
}
BOOST_AUTO_TEST_CASE
(
serialization_raw_test
)
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment