11//! Verification of calculated values against captured CSV from Haskell node / DBSync
22use crate :: rewards:: { RewardDetail , RewardType , RewardsResult } ;
33use crate :: state:: Pots ;
4- use acropolis_common:: { KeyHash , RewardAccount } ;
4+ use acropolis_common:: { KeyHash , RewardAccount , StakeAddress } ;
55use hex:: FromHex ;
66use itertools:: EitherOrBoth :: { Both , Left , Right } ;
77use itertools:: Itertools ;
@@ -114,7 +114,7 @@ impl Verifier {
114114 match ( & left. rtype , & right. rtype ) {
115115 ( RewardType :: Leader , RewardType :: Member ) => Ordering :: Less ,
116116 ( RewardType :: Member , RewardType :: Leader ) => Ordering :: Greater ,
117- _ => left. account . cmp ( & right. account ) ,
117+ _ => left. account . get_hash ( ) . cmp ( & right. account . get_hash ( ) ) ,
118118 }
119119 }
120120
@@ -161,12 +161,13 @@ impl Verifier {
161161 _ => continue ,
162162 } ;
163163
164- // Convert account with e1 header to just hash
165- // TODO: use StakeAddress, skipping first byte (e1) for now
166- let account = RewardAccount :: from ( & account[ 1 ..] ) ;
164+ let Ok ( stake_address) = StakeAddress :: from_binary ( & account[ 1 ..] ) else {
165+ error ! ( "Bad stake address in {path} for address: {address} - skipping" ) ;
166+ continue ;
167+ } ;
167168
168169 expected_rewards. entry ( spo) . or_default ( ) . push ( RewardDetail {
169- account,
170+ account : stake_address ,
170171 rtype,
171172 amount,
172173 } ) ;
@@ -217,7 +218,7 @@ impl Verifier {
217218 error ! (
218219 "Missing reward: SPO {} account {} {:?} {}" ,
219220 hex:: encode( & expected_spo. 0 ) ,
220- hex:: encode( & expected. account) ,
221+ hex:: encode( & expected. account. get_hash ( ) ) ,
221222 expected. rtype,
222223 expected. amount
223224 ) ;
@@ -227,7 +228,7 @@ impl Verifier {
227228 error ! (
228229 "Extra reward: SPO {} account {} {:?} {}" ,
229230 hex:: encode( & actual_spo. 0 ) ,
230- hex:: encode( & actual. account) ,
231+ hex:: encode( & actual. account. get_hash ( ) ) ,
231232 actual. rtype,
232233 actual. amount
233234 ) ;
@@ -237,7 +238,7 @@ impl Verifier {
237238 if expected. amount != actual. amount {
238239 error ! ( "Different reward: SPO {} account {} {:?} expected {}, actual {} ({})" ,
239240 hex:: encode( & expected_spo. 0 ) ,
240- hex:: encode( & expected. account) ,
241+ hex:: encode( & expected. account. get_hash ( ) ) ,
241242 expected. rtype,
242243 expected. amount,
243244 actual. amount,
@@ -247,7 +248,7 @@ impl Verifier {
247248 debug ! (
248249 "Reward match: SPO {} account {} {:?} {}" ,
249250 hex:: encode( & expected_spo. 0 ) ,
250- hex:: encode( & expected. account) ,
251+ hex:: encode( & expected. account. get_hash ( ) ) ,
251252 expected. rtype,
252253 expected. amount
253254 ) ;
0 commit comments