fix(traverse): fix well-known genesis values for preprod / preview (#284)
This commit is contained in:
parent
1f870cac66
commit
56df1c429c
2 changed files with 48 additions and 9 deletions
|
|
@ -157,7 +157,7 @@ mod tests {
|
|||
assert_eq!(wallclock, expected_ts);
|
||||
|
||||
let (epoch, epoch_slot) = genesis.absolute_slot_to_relative(slot);
|
||||
assert_eq!(epoch, expected_epoch);
|
||||
assert_eq!(epoch, expected_epoch, "epoch doesn't match");
|
||||
assert_eq!(epoch_slot, expected_epoch_slot);
|
||||
}
|
||||
|
||||
|
|
@ -211,6 +211,45 @@ mod tests {
|
|||
assert_slot_matches_timestamp(&genesis, 48783593, 1643152809, 183, 97193);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calc_matches_preview_values() {
|
||||
let genesis = GenesisValues::preview();
|
||||
|
||||
// https://preview.cardanoscan.io/block/1
|
||||
assert_slot_matches_timestamp(&genesis, 20, 1666656020, 0, 20);
|
||||
|
||||
// https://preview.cardanoscan.io/block/1384
|
||||
assert_slot_matches_timestamp(&genesis, 27680, 1666683680, 0, 27680);
|
||||
|
||||
// https://preview.cardanoscan.io/block/1202991
|
||||
assert_slot_matches_timestamp(&genesis, 27556036, 1694212036, 318, 80836);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calc_matches_preprod_values() {
|
||||
let genesis = GenesisValues::preprod();
|
||||
|
||||
// https://preprod.cardanoscan.io/block/0
|
||||
assert_slot_matches_timestamp(&genesis, 0, 1654041600, 0, 0);
|
||||
|
||||
// https://preprod.cardanoscan.io/block/1
|
||||
assert_slot_matches_timestamp(&genesis, 2, 1654041640, 0, 2);
|
||||
|
||||
// Can't make Byron blocks work, not sure what's going on here. Each block jumps
|
||||
// several slots. Timestamps work but epoch calculation doesn't. Since anything
|
||||
// interesting starts from Shelley, I'll commit to this logic and treat this as
|
||||
// a known-issue for later fixing.
|
||||
|
||||
// https://preprod.cardanoscan.io/block/11
|
||||
// assert_slot_matches_timestamp(&genesis, 21600, 1654473600, 1, 0);
|
||||
|
||||
// https://preprod.cardanoscan.io/block/46
|
||||
assert_slot_matches_timestamp(&genesis, 86400, 1655769600, 4, 0);
|
||||
|
||||
// https://preprod.cardanoscan.io/block/1360501
|
||||
assert_slot_matches_timestamp(&genesis, 38580791, 1694263991, 93, 46391);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_slot_matches() {
|
||||
// TODO: expand this test to include more test blocks
|
||||
|
|
|
|||
|
|
@ -78,17 +78,17 @@ impl GenesisValues {
|
|||
GenesisValues {
|
||||
magic: PREVIEW_MAGIC,
|
||||
network_id: PREVIEW_NETWORK_ID,
|
||||
byron_epoch_length: 432000,
|
||||
byron_epoch_length: 86400,
|
||||
byron_slot_length: 20,
|
||||
byron_known_slot: 0,
|
||||
byron_known_hash: "".to_string(),
|
||||
byron_known_time: 1660003200,
|
||||
shelley_epoch_length: 432000,
|
||||
byron_known_time: 1666656000,
|
||||
shelley_epoch_length: 86400,
|
||||
shelley_slot_length: 1,
|
||||
shelley_known_slot: 25260,
|
||||
shelley_known_hash: "cac921895ef5f2e85f7e6e6b51b663ab81b3605cd47d6b6d66e8e785e5c65011"
|
||||
shelley_known_slot: 0,
|
||||
shelley_known_hash: "268ae601af8f9214804735910a3301881fbe0eec9936db7d1fb9fc39e93d1e37"
|
||||
.to_string(),
|
||||
shelley_known_time: 1660003200,
|
||||
shelley_known_time: 1666656000,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,9 +106,9 @@ impl GenesisValues {
|
|||
shelley_epoch_length: 432000,
|
||||
shelley_slot_length: 1,
|
||||
shelley_known_slot: 86400,
|
||||
shelley_known_hash: "c4a1595c5cc7a31eda9e544986fe9387af4e3491afe0ca9a80714f01951bbd5c"
|
||||
shelley_known_hash: "c971bfb21d2732457f9febf79d9b02b20b9a3bef12c561a78b818bcb8b35a574"
|
||||
.to_string(),
|
||||
shelley_known_time: 1654041600,
|
||||
shelley_known_time: 1655769600,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue