Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_data_handlers.cpp File Reference
#include <boost/test/included/unit_test.hpp>
#include <sysio/trace_api/abi_data_handler.hpp>
#include <sysio/trace_api/test_common.hpp>
Include dependency graph for test_data_handlers.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   trace_data_handlers
 

Functions

 BOOST_AUTO_TEST_CASE (empty_data)
 
 BOOST_AUTO_TEST_CASE (empty_data_v1)
 
 BOOST_AUTO_TEST_CASE (no_abi)
 
 BOOST_AUTO_TEST_CASE (no_abi_v1)
 
 BOOST_AUTO_TEST_CASE (basic_abi)
 
 BOOST_AUTO_TEST_CASE (basic_abi_v1)
 
 BOOST_AUTO_TEST_CASE (basic_abi_wrong_type)
 
 BOOST_AUTO_TEST_CASE (basic_abi_wrong_type_v1)
 
 BOOST_AUTO_TEST_CASE (basic_abi_insufficient_data)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   trace_data_handlers

Definition at line 1 of file test_data_handlers.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/9]

BOOST_AUTO_TEST_CASE ( basic_abi )

Definition at line 71 of file test_data_handlers.cpp.

72 {
73 auto action = action_trace_v0 {
74 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}
75 };
76
77 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
78
79 auto abi = chain::abi_def ( {},
80 {
81 { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } }
82 },
83 {
84 { "foo"_n, "foo", ""}
85 },
86 {}, {}, {}
87 );
88 abi.version = "sysio::abi/1.";
89
91 handler.add_abi("alice"_n, abi);
92
94 ("a", 0)
95 ("b", 1)
96 ("c", 2)
97 ("d", 3);
98
99 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
100
101 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
102 }
An order-preserving dictionary of variants.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
void add_abi(const chain::name &name, const chain::abi_def &abi)
auto to_kv(const fc::variant &v)
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/9]

BOOST_AUTO_TEST_CASE ( basic_abi_insufficient_data )

Definition at line 196 of file test_data_handlers.cpp.

197 {
198 auto action = action_trace_v0 {
199 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02}
200 };
201
202 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
203
204 auto abi = chain::abi_def ( {},
205 {
206 { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } }
207 },
208 {
209 { "foo"_n, "foo", ""}
210 },
211 {}, {}, {}
212 );
213 abi.version = "sysio::abi/1.";
214
215 bool log_called = false;
216 abi_data_handler handler([&log_called](const exception_with_context& ){log_called = true;});
217 handler.add_abi("alice"_n, abi);
218
219 auto expected = fc::variant();
220
221 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
222
223 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
224 BOOST_TEST(log_called);
225 }
std::tuple< const std::exception_ptr &, char const *, uint64_t, char const * > exception_with_context
Definition common.hpp:40
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/9]

BOOST_AUTO_TEST_CASE ( basic_abi_v1 )

Definition at line 104 of file test_data_handlers.cpp.

105 {
106 auto action = action_trace_v1 {
107 { 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}},
108 {0x04, 0x05, 0x06, 0x07}
109 };
110
111 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
112
113 auto abi = chain::abi_def ( {},
114 {
115 { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } }
116 },
117 {
118 { "foo"_n, "foo", ""}
119 },
120 {}, {}, {}
121 );
122 abi.version = "sysio::abi/1.";
123
125 handler.add_abi("alice"_n, abi);
126
128 ("a", 0)
129 ("b", 1)
130 ("c", 2)
131 ("d", 3);
132
133 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
134
135 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
136 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/9]

BOOST_AUTO_TEST_CASE ( basic_abi_wrong_type )

Definition at line 138 of file test_data_handlers.cpp.

139 {
140 auto action = action_trace_v0 {
141 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}
142 };
143
144 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
145
146 auto abi = chain::abi_def ( {},
147 {
148 { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } }
149 },
150 {
151 { "bar"_n, "foo", ""}
152 },
153 {}, {}, {}
154 );
155 abi.version = "sysio::abi/1.";
156
158 handler.add_abi("alice"_n, abi);
159
160 auto expected = fc::variant();
161
162 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
163
164 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
165 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/9]

BOOST_AUTO_TEST_CASE ( basic_abi_wrong_type_v1 )

Definition at line 167 of file test_data_handlers.cpp.

168 {
169 auto action = action_trace_v1 {
170 { 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}},
171 {0x04, 0x05, 0x06, 0x07}
172 };
173 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
174
175 auto abi = chain::abi_def ( {},
176 {
177 { "foo", "", { {"a", "varuint32"}, {"b", "varuint32"}, {"c", "varuint32"}, {"d", "varuint32"} } }
178 },
179 {
180 { "bar"_n, "foo", ""}
181 },
182 {}, {}, {}
183 );
184 abi.version = "sysio::abi/1.";
185
187 handler.add_abi("alice"_n, abi);
188
189 auto expected = fc::variant();
190
191 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
192
193 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
194 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/9]

BOOST_AUTO_TEST_CASE ( empty_data )

Definition at line 13 of file test_data_handlers.cpp.

14 {
15 auto action = action_trace_v0 {
16 0, "alice"_n, "alice"_n, "foo"_n, {}, {}
17 };
18 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
20
21 auto expected = fc::variant();
22 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
23
24 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
25 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/9]

BOOST_AUTO_TEST_CASE ( empty_data_v1 )

Definition at line 27 of file test_data_handlers.cpp.

28 {
29 auto action = action_trace_v1 {
30 {0, "alice"_n, "alice"_n, "foo"_n, {}, {}},
31 {}
32 };
33 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
35
36 auto expected = fc::variant();
37 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
38
39 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
40 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/9]

BOOST_AUTO_TEST_CASE ( no_abi )

Definition at line 42 of file test_data_handlers.cpp.

43 {
44 auto action = action_trace_v0 {
45 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}
46 };
47 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
49
50 auto expected = fc::variant();
51 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
52
53 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
54 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/9]

BOOST_AUTO_TEST_CASE ( no_abi_v1 )

Definition at line 56 of file test_data_handlers.cpp.

57 {
58 auto action = action_trace_v1 {
59 { 0, "alice"_n, "alice"_n, "foo"_n, {}, {0x00, 0x01, 0x02, 0x03}},
60 {0x04, 0x05, 0x06, 0x07}
61 };
62 std::variant<action_trace_v0, action_trace_v1> action_trace_t = action;
64
65 auto expected = fc::variant();
66 auto actual = handler.serialize_to_variant(action_trace_t, [](){});
67
68 BOOST_TEST(to_kv(expected) == to_kv(std::get<0>(actual)), boost::test_tools::per_element());
69 }
Here is the call graph for this function: