From cb73eae8450b6c4cceed2aee1db6cd6740f1f2c9 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Thu, 7 Dec 2023 16:33:09 -0500 Subject: [PATCH] Update set_finalizers_tests * Fixed breaking strict-aliasing rules * Added public key check --- tests/integration/set_finalizers_tests.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/integration/set_finalizers_tests.cpp b/tests/integration/set_finalizers_tests.cpp index bb8ab4e22..871e35280 100644 --- a/tests/integration/set_finalizers_tests.cpp +++ b/tests/integration/set_finalizers_tests.cpp @@ -23,25 +23,12 @@ BOOST_FIXTURE_TEST_CASE(set_finalizers_test, tester) try { produce_block(); - const std::vector G1 = {0x22, 0x0e, 0xf5, 0xc4, 0x9c, 0x18, 0x68, 0xe8, - 0x5b, 0x82, 0x65, 0x8d, 0xf9, 0x76, 0x6f, 0xc2, - 0xce, 0xe4, 0xbd, 0x0b, 0x5d, 0x98, 0x80, 0xd4, - 0xcd, 0xee, 0x91, 0x39, 0xed, 0xd3, 0xc4, 0xeb, - 0xda, 0xe4, 0x07, 0x4f, 0x1d, 0x3d, 0xb3, 0xf3, - 0xc9, 0x21, 0x39, 0x62, 0x94, 0x2e, 0xef, 0x09, - 0x1b, 0x00, 0xd9, 0xf2, 0xa9, 0xb8, 0x37, 0x01, - 0x5c, 0x8d, 0xbe, 0x50, 0x7f, 0x24, 0x2a, 0xee, - 0x45, 0x92, 0x72, 0x58, 0x9b, 0x6b, 0x29, 0x73, - 0xbc, 0xf3, 0x3e, 0xb4, 0x60, 0x87, 0x22, 0xc7, - 0x0c, 0x1a, 0xc3, 0xd1, 0xad, 0xe4, 0x0c, 0x84, - 0x5b, 0x9e, 0x15, 0xea, 0x63, 0x80, 0x08, 0x0a}; // 12x8 = 96 bytes - push_action(config::system_account_name, "setfinal"_n, "test"_n, mvo() ("fin_set", mvo()("fthreshold", 1) ("finalizers", std::vector{mvo() ("description", "test_desc") ("fweight", 1) - ("public_key_g1_affine_le", *reinterpret_cast*>(&G1))}))); + ("public_key_g1_affine_le", "220ef5c49c1868e85b82658df9766fc2cee4bd0b5d9880d4cdee9139edd3c4ebdae4074f1d3db3f3c9213962942eef091b00d9f2a9b837015c8dbe507f242aee459272589b6b2973bcf33eb4608722c70c1ac3d1ade40c845b9e15ea6380080a")}))); signed_block_ptr cur_block = produce_block(); fc::variant pretty_output; abi_serializer::to_variant( *cur_block, pretty_output, get_resolver(), fc::microseconds::maximum() ); @@ -51,7 +38,7 @@ BOOST_FIXTURE_TEST_CASE(set_finalizers_test, tester) try { BOOST_REQUIRE_EQUAL(pretty_output["proposed_finalizer_policy"]["finalizers"].size(), 1u); BOOST_REQUIRE_EQUAL(pretty_output["proposed_finalizer_policy"]["finalizers"][size_t(0)]["description"], "test_desc"); BOOST_REQUIRE_EQUAL(pretty_output["proposed_finalizer_policy"]["finalizers"][size_t(0)]["fweight"], 1); - //TODO: add key check here after base64 support will be added + BOOST_REQUIRE_EQUAL(pretty_output["proposed_finalizer_policy"]["finalizers"][size_t(0)]["public_key"], "PUB_BLS_Ig71xJwYaOhbgmWN+XZvws7kvQtdmIDUze6ROe3TxOva5AdPHT2z88khOWKULu8JGwDZ8qm4NwFcjb5QfyQq7kWSclibaylzvPM+tGCHIscMGsPRreQMhFueFepjgAgKXjOb8g=="); // testing wrong public key size BOOST_CHECK_THROW(push_action(config::system_account_name, "setfinal"_n, "test"_n, mvo()