@@ -159,19 +159,23 @@ basic_test(Config) ->
159159 Start = 1 ,
160160 End = 30 ,
161161
162- Vars = blockchain_txn_rewards_v3 :get_reward_vars (Start , End , Ledger ),
163- ct :pal (" Vars: ~p " , [Vars ]),
162+ % % Ensure that RewardsMD has the necessary keys
163+ {ok , RewardsMD } = blockchain_txn_rewards_v3 :calculate_rewards_md (Start , End , Chain ),
164+ [consensus_rewards , securities_rewards , treasury_rewards ] = lists :sort (maps :keys (RewardsMD )),
164165
165- Rewards = blockchain_txn_rewards_v3 : calculate_rewards ( Start , End , Chain ),
166- ct : pal ( " Rewards: ~p " , [ Rewards ] ),
167-
168- RewardsMD = blockchain_txn_rewards_v3 : calculate_rewards_md ( Start , End , Chain ),
169- ct : pal ( " RewardsMD: ~p " , [ RewardsMD ] ),
166+ % % Construct a rewards_v3 txn
167+ { ok , Rewards } = blockchain_txn_rewards_v3 : calculate_rewards ( Start , End , Chain ),
168+ T = blockchain_txn_rewards_v3 : new ( Start , End , Rewards ),
169+ % % NOTE: Signing rewards txn is pointless
170+ ok = blockchain_txn : is_valid ( T , Chain ),
170171
171- % % TODO: Missing consensus rewards?
172+ {ok , Block31 } = test_utils :create_block (ConsensusMembers , [T ]),
173+ _ = blockchain_gossip_handler :add_block (Block31 , Chain , self (), blockchain_swarm :tid ()),
172174
173- % % Construct a rewards_v3 txn
174- % % T = blockchain_txn_rewards_v3:new(1, 30, Rewards)
175+ ? assertEqual ({ok , blockchain_block :hash_block (Block31 )}, blockchain :head_hash (Chain )),
176+ ? assertEqual ({ok , Block31 }, blockchain :head_block (Chain )),
177+ ? assertEqual ({ok , 31 }, blockchain :height (Chain )),
178+ ? assertEqual ({ok , Block31 }, blockchain :get_block (31 , Chain )),
175179
176180 ok .
177181
@@ -181,25 +185,26 @@ basic_test(Config) ->
181185extra_vars (TestCase ) ->
182186 #{secret := _TSec , public := TPub } = libp2p_crypto :generate_keys (ed25519 ),
183187 TPubkeyBin = libp2p_crypto :pubkey_to_bin (TPub ),
184- ExistingVars = existing_reward_vars (TestCase ),
188+ ExistingVars = on_chain_vars (TestCase ),
185189 NewVars = #{
186190 ? allowed_num_reward_server_keys => 1 ,
187191 ? token_version => 2 ,
188192 ? subnetwork_reward_per_block_limit => 10 ,
189- ? reward_version => 3 ,
193+ ? reward_version => 7 ,
190194 ? treasury_pubkey_bin => TPubkeyBin
191195 },
192196 maps :merge (ExistingVars , NewVars ).
193197
194- existing_reward_vars (_TestCase ) ->
198+ on_chain_vars (_TestCase ) ->
195199 #{
196200 ? monthly_reward => 250000000000000 ,
197201 ? securities_percent => 0.33 ,
198202 ? consensus_percent => 0.06 ,
199203 ? election_interval => 30 ,
200204 ? election_restart_interval => 5 ,
201205 ? block_time => 60000 ,
202- ? net_emissions_max_rate => 3424000000
206+ ? net_emissions_max_rate => 3424000000 ,
207+ ? election_version => 6
203208 }.
204209
205210token_allocations (_ , Config ) ->
0 commit comments