-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use constructor to construct action
instead of assigning members after the fact.
#951
base: main
Are you sure you want to change the base?
Changes from all commits
816535a
986562e
e57cc43
c569d7e
97254ff
b158e5b
84dc44c
ad8ed8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,10 +11,7 @@ BOOST_DATA_TEST_CASE(address_0_check_throw, boost::unit_test::data::xrange(0,11) | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_0); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we found no way to regenerate these files properly? I think if anything should update the generator, spring/unittests/wasm-spec-tests/generator/eosio_wasm_spec_test_generator.cpp Lines 39 to 43 in f45de1f
btw it sure looks like AntelopeIO/wasm-spec-tests@026fb4b found a way to regenerate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the generator b158e5b. |
||||||||||||
|
||||||||||||
BOOST_CHECK_THROW(push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()), wasm_execution_error); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -28,10 +25,7 @@ BOOST_DATA_TEST_CASE(address_0_pass, boost::unit_test::data::xrange(11,12), inde | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_0); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -49,10 +43,7 @@ BOOST_DATA_TEST_CASE(address_2_check_throw, boost::unit_test::data::xrange(0,15) | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_2); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
BOOST_CHECK_THROW(push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()), wasm_execution_error); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -66,10 +57,7 @@ BOOST_DATA_TEST_CASE(address_2_pass, boost::unit_test::data::xrange(15,17), inde | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_2); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -87,10 +75,7 @@ BOOST_DATA_TEST_CASE(address_3_check_throw, boost::unit_test::data::xrange(0,3), | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_3); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
BOOST_CHECK_THROW(push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()), wasm_execution_error); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -104,10 +89,7 @@ BOOST_DATA_TEST_CASE(address_3_pass, boost::unit_test::data::xrange(3,4), index) | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_3); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -125,10 +107,7 @@ BOOST_DATA_TEST_CASE(address_4_check_throw, boost::unit_test::data::xrange(0,3), | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_4); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
BOOST_CHECK_THROW(push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()), wasm_execution_error); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
@@ -142,10 +121,7 @@ BOOST_DATA_TEST_CASE(address_4_pass, boost::unit_test::data::xrange(3,4), index) | |||||||||||
tester.set_code("wasmtest"_n, wasm_address_4); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
||||||||||||
action test; | ||||||||||||
test.account = "wasmtest"_n; | ||||||||||||
test.name = account_name((uint64_t)index); | ||||||||||||
test.authorization = {{"wasmtest"_n, config::active_name}}; | ||||||||||||
action test({{"wasmtest"_n, config::active_name}}, "wasmtest"_n, account_name((uint64_t)index), {}); | ||||||||||||
|
||||||||||||
push_action(tester, std::move(test), "wasmtest"_n.to_uint64_t()); | ||||||||||||
tester.produce_block(); | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the original way of initializing individual fields explicitly clearer and more readable.
action
is a data class and used most locally. It is probably appropriate to be astruct
without const.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very much disagree. Because
action
has constructors, it implies that the object should be constructed using the provided constructors.The direct member initialization forgoes any hope to ensure that objects are always constructed in a consistent fashion, and that some internal members (possibly dependent on the constructors parameters) are always initialized correctly. This is not the case for
action
, but I feel it is a better pattern to follow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arhag do you have an opinion on whether it is worthwhile to merge this PR?