fix proposal authority

This commit is contained in:
Daniel Larimer 2015-07-09 15:14:44 -04:00
parent a41384d4b1
commit a164fbe8fa
3 changed files with 33 additions and 0 deletions

View file

@ -105,6 +105,9 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return fee_paying_account; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_required_authorities( vector<authority>& )const;
void get_required_active_authorities( flat_set<account_id_type>& )const;
void get_required_owner_authorities( flat_set<account_id_type>& )const;
};
/**

View file

@ -63,4 +63,26 @@ void proposal_create_operation::get_impacted_accounts( flat_set<account_id_type>
for( auto& o : other )
add_authority_accounts( i, o );
}
void proposal_update_operation::get_required_authorities( vector<authority>& o )const
{
authority auth;
for( const auto& k : key_approvals_to_add )
auth.key_auths[k] = 1;
for( const auto& k : key_approvals_to_remove )
auth.key_auths[k] = 1;
auth.weight_threshold = auth.key_auths.size();
o.emplace_back( std::move(auth) );
}
void proposal_update_operation::get_required_active_authorities( flat_set<account_id_type>& a )const
{
for( const auto& i : active_approvals_to_add ) a.insert(i);
for( const auto& i : active_approvals_to_remove ) a.insert(i);
}
void proposal_update_operation::get_required_owner_authorities( flat_set<account_id_type>& a )const
{
for( const auto& i : owner_approvals_to_add ) a.insert(i);
for( const auto& i : owner_approvals_to_remove ) a.insert(i);
}
} } // graphene::chain

View file

@ -642,6 +642,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
p.parameters.committee_proposal_review_period = fc::hours(1).to_seconds();
});
BOOST_TEST_MESSAGE( "Creating a proposal to change the block_interval to 1 second" );
{
proposal_create_operation cop = proposal_create_operation::genesis_proposal(db.get_global_properties().parameters, db.head_block_time());
cop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
@ -652,6 +653,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
trx.operations.push_back(cop);
db.push_transaction(trx);
}
BOOST_TEST_MESSAGE( "Updating proposal by signing with the delegate private key" );
{
proposal_update_operation uop;
uop.fee_paying_account = GRAPHENE_TEMP_ACCOUNT;
@ -673,6 +675,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
db.push_transaction(trx);
BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db));
}
BOOST_TEST_MESSAGE( "Verifying that the interval didn't change immediately" );
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5);
auto past_time = db.head_block_time().sec_since_epoch();
@ -681,10 +684,15 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
generate_block();
BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 10);
BOOST_TEST_MESSAGE( "Generating blocks until proposal expires" );
generate_blocks(proposal_id_type()(db).expiration_time + 5);
BOOST_TEST_MESSAGE( "Verify that the block interval is still 5 seconds" );
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5);
BOOST_TEST_MESSAGE( "Generating blocks until next maintenance interval" );
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
BOOST_TEST_MESSAGE( "Verify that the new block interval is 1 second" );
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 1);
past_time = db.head_block_time().sec_since_epoch();
generate_block();