Skip to content

Commit e86d9f4

Browse files
author
ABW
committed
fix problem with detecting necessary signatures in posting+active mixed transaction
Also added part of unit test that illustrates the bug.
1 parent cfceee3 commit e86d9f4

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

libraries/protocol/transaction.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ set<public_key_type> signed_transaction::get_required_signatures(
168168
}
169169

170170
s.change_current_authority( get_active );
171+
s.init_approved();
171172

172173
for( const auto& auth : other )
173174
s.check_authority( auth );

tests/unit/tests/basic_tests.cpp

+31-3
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,8 @@ BOOST_AUTO_TEST_CASE( authorization_speed )
17061706

17071707
BOOST_AUTO_TEST_CASE( authorization_redirections )
17081708
{
1709+
BOOST_REQUIRE( db->has_hardfork( HIVE_HARDFORK_1_28_ALLOW_STRICT_AND_MIXED_AUTHORITIES ) );
1710+
17091711
auto fee = db->get_witness_schedule_object().median_props.account_creation_fee;
17101712
auto keygen = [&]( const account_name_type& name, authority::classification role )
17111713
{
@@ -1757,9 +1759,7 @@ BOOST_AUTO_TEST_CASE( authorization_redirections )
17571759

17581760
auto has_authorization = [&]( const fc::flat_set< public_key_type >& keys, bool expected )
17591761
{
1760-
bool result = hive::protocol::has_authorization(
1761-
db->has_hardfork( HIVE_HARDFORK_1_28_ALLOW_STRICT_AND_MIXED_AUTHORITIES ),
1762-
false/*db->has_hardfork(HIVE_HARDFORK_1_28_ALLOW_REDUNDANT_SIGNATURES)*/, // enforce no redundancy, since test should have none
1762+
bool result = hive::protocol::has_authorization( true, false, // enforce no redundancy, since test should have none
17631763
required_authorities, keys, get_active, get_owner, get_posting, get_witness_key );
17641764
BOOST_CHECK_EQUAL( result, expected );
17651765
return result ? "true" : "false";
@@ -1822,6 +1822,34 @@ BOOST_AUTO_TEST_CASE( authorization_redirections )
18221822
required_authorities.required_posting.clear();
18231823
required_authorities.required_active.clear();
18241824

1825+
// also test auto detection of signatures in above situation
1826+
{
1827+
ilog( "" );
1828+
ilog( "check necessary signature detection when alice.pay@posting and alice.pay@active is required" );
1829+
1830+
signed_transaction tx;
1831+
comment_operation comment;
1832+
comment.author = "alice.pay";
1833+
comment.permlink = "stealing";
1834+
comment.parent_permlink = "stealing";
1835+
comment.title = "stealing";
1836+
comment.body = "got your money, haha!";
1837+
tx.operations.emplace_back( comment );
1838+
transfer_operation transfer;
1839+
transfer.from = "alice.pay";
1840+
transfer.to = "bob";
1841+
transfer.amount = ASSET( "100000.000 TBD" );
1842+
tx.operations.emplace_back( transfer );
1843+
auto signature_set = tx.get_required_signatures( true, false, HIVE_CHAIN_ID,
1844+
{ bob_auth.posting.key_auths.begin()->first, carol_auth.active.key_auths.begin()->first,
1845+
dan_auth.active.key_auths.begin()->first },
1846+
get_active, get_owner, get_posting, get_witness_key,
1847+
HIVE_MAX_SIG_CHECK_DEPTH, HIVE_MAX_AUTHORITY_MEMBERSHIP, HIVE_MAX_SIG_CHECK_ACCOUNTS );
1848+
BOOST_REQUIRE_EQUAL( signature_set.size(), 2 );
1849+
BOOST_REQUIRE( signature_set.find( bob_auth.posting.key_auths.begin()->first ) != signature_set.end() );
1850+
BOOST_REQUIRE( signature_set.find( carol_auth.active.key_auths.begin()->first ) != signature_set.end() );
1851+
}
1852+
18251853
#undef CREATE_ACCOUNT
18261854
}
18271855

0 commit comments

Comments
 (0)