Fix fee-related issues and make all fees zero by default

A situation where there are no votes (and hence default values are
used) can be considered pathological anyway.
parent bdffe821
Pipeline #30050101 passed with stages
in 19 minutes and 9 seconds
......@@ -84,16 +84,16 @@ fees(Data) ->
protocol,
maps:merge(
#{fee_per_256_bytes => 0,
fee_per_account_day => 1,
fee_per_account_day => 0,
fee_per_tx => 0},
voted_choices(Data))).
-spec merge_choices_vps(choices(), voting_power(), map()) -> map().
merge_choices_vps(SingleChoices, VP, ChoicesVPs) ->
Keys = maps:keys(ChoicesVPs),
Keys = maps:keys(SingleChoices),
lists:foldl(
fun (Key, Acc) ->
ChoiceVPsForKey = maps:get(Key, Acc),
ChoiceVPsForKey = maps:get(Key, Acc, []),
Acc#{Key => [{maps:get(Key, SingleChoices), VP}|ChoiceVPsForKey]}
end,
ChoicesVPs,
......
%% Licensed under the Apache License, Version 2.0 (the “License”);
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an “AS IS” BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
-module(ercoin_fee_tests).
-include_lib("include/ercoin_test.hrl").
prop_fees_are_sometimes_non_negative() ->
fails(
?FORALL(
{Data, Tx},
?SUCHTHAT(
{_, Tx},
ercoin_tx_gen:data_with_tx(),
not is_record(Tx, vote_tx)),
ercoin_fee:total(Tx, Data) =:= 0)).
......@@ -287,9 +287,9 @@ data_with_invalid_tx_bin() ->
{{{Data, _}, Tx},
LackingFunds},
{?SUCHTHAT(
{_, Tx},
{{Data, _}, Tx},
data_sks_and_tx(),
not is_record(Tx, vote_tx)),
not is_record(Tx, vote_tx) andalso ercoin_fee:total(Tx, Data) > 0),
pos_integer()},
begin
Account = ercoin_account:get(ercoin_tx:from(Tx), Data),
......
......@@ -125,7 +125,7 @@ prop_burn_tx_destroys_money() ->
{{Data, _}, Tx=#burn_tx{address=Address, value=Value}},
data_sks_and_burn_tx(),
ercoin_account:lookup_balance(Address, ercoin_tx:apply(Tx, Data)) =:=
ercoin_account:lookup_balance(Address, Data) - Value).
ercoin_account:lookup_balance(Address, Data) - Value - ercoin_fee:total(Tx, Data)).
prop_lock_tx_locks_account_or_extends_lock_and_sets_validator_pk() ->
?FORALL(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment