Skip to content

Commit a2192ec

Browse files
committed
fix htlc fee tests
1 parent 5c7a9e8 commit a2192ec

File tree

3 files changed

+255
-151
lines changed

3 files changed

+255
-151
lines changed

libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp

+30-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ namespace graphene { namespace chain {
113113
}
114114
};
115115

116-
/*
117116
template<>
118117
class fee_helper<htlc_create_operation> {
119118
public:
@@ -126,15 +125,34 @@ namespace graphene { namespace chain {
126125
static htlc_create_operation::fee_parameters_type htlc_create_operation_fee_dummy;
127126
return htlc_create_operation_fee_dummy;
128127
}
129-
typename htlc_create_operation::fee_parameters_type& get(flat_set<fee_parameters>& parameters)const
128+
};
129+
130+
template<>
131+
class fee_helper<htlc_redeem_operation> {
132+
public:
133+
const htlc_redeem_operation::fee_parameters_type& cget(const flat_set<fee_parameters>& parameters)const
130134
{
131-
auto itr = parameters.find( htlc_create_operation::fee_parameters_type() );
132-
FC_ASSERT( itr != parameters.end() );
133-
return itr->get<htlc_create_operation::fee_parameters_type>();
135+
auto itr = parameters.find( htlc_redeem_operation::fee_parameters_type() );
136+
if ( itr != parameters.end() )
137+
return itr->get<htlc_redeem_operation::fee_parameters_type>();
138+
139+
static htlc_redeem_operation::fee_parameters_type htlc_redeem_operation_fee_dummy;
140+
return htlc_redeem_operation_fee_dummy;
134141
}
135142
};
136-
*/
143+
template<>
144+
class fee_helper<htlc_extend_operation> {
145+
public:
146+
const htlc_extend_operation::fee_parameters_type& cget(const flat_set<fee_parameters>& parameters)const
147+
{
148+
auto itr = parameters.find( htlc_extend_operation::fee_parameters_type() );
149+
if ( itr != parameters.end() )
150+
return itr->get<htlc_extend_operation::fee_parameters_type>();
137151

152+
static htlc_extend_operation::fee_parameters_type htlc_extend_operation_fee_dummy;
153+
return htlc_extend_operation_fee_dummy;
154+
}
155+
};
138156
/**
139157
* @brief contains all of the parameters necessary to calculate the fee for any operation
140158
*/
@@ -168,6 +186,12 @@ namespace graphene { namespace chain {
168186
{
169187
return fee_helper<Operation>().get(parameters);
170188
}
189+
template<typename Operation>
190+
const bool exists()const
191+
{
192+
auto itr = parameters.find(typename Operation::fee_parameters_type());
193+
return itr != parameters.end();
194+
}
171195

172196
/**
173197
* @note must be sorted by fee_parameters.which() and have no duplicates

libraries/chain/proposal_evaluator.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ struct proposal_operation_hardfork_visitor
9797
void operator()(const graphene::chain::committee_member_update_global_parameters_operation &op) const {
9898
if (block_time < HARDFORK_CORE_1468_TIME) {
9999
FC_ASSERT(!op.new_parameters.extensions.value.updatable_htlc_options.valid(), "Unable to set HTLC options before hardfork 1468");
100-
// TODO: Do not allow changing of fees before hardfork
100+
FC_ASSERT(!op.new_parameters.current_fees->exists<htlc_create_operation>());
101+
FC_ASSERT(!op.new_parameters.current_fees->exists<htlc_redeem_operation>());
102+
FC_ASSERT(!op.new_parameters.current_fees->exists<htlc_extend_operation>());
101103
}
102104
}
103105
// loop and self visit in proposals

0 commit comments

Comments
 (0)