fixed time conversion
This commit is contained in:
@@ -24,7 +24,7 @@ use super::{
|
||||
};
|
||||
|
||||
fn slot_to_begin_posix_time(slot: u64, sc: &SlotConfig) -> u64 {
|
||||
let ms_after_begin = slot * sc.slot_length;
|
||||
let ms_after_begin = (slot - sc.zero_slot) * sc.slot_length;
|
||||
sc.zero_time + ms_after_begin
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ pub struct TimeRange {
|
||||
|
||||
pub struct SlotConfig {
|
||||
pub slot_length: u64,
|
||||
pub zero_slot: u64,
|
||||
pub zero_time: u64,
|
||||
}
|
||||
|
||||
@@ -91,7 +92,8 @@ impl Default for SlotConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
slot_length: 1000,
|
||||
zero_time: 1596491091,
|
||||
zero_slot: 4492800,
|
||||
zero_time: 1596059091000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ fn test_eval() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -292,6 +293,7 @@ fn test_eval_1() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -561,6 +563,7 @@ fn test_eval_2() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -659,6 +662,7 @@ fn test_eval_3() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -925,6 +929,7 @@ fn test_eval_4() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1006,6 +1011,7 @@ fn test_eval_5() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1108,6 +1114,7 @@ fn test_eval_6() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1596059091000, // Mainnet network
|
||||
zero_slot: 4492800,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1211,6 +1218,7 @@ fn test_eval_7() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1596059091000, // Mainnet network
|
||||
zero_slot: 4492800,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1301,6 +1309,7 @@ fn test_eval_8() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1596059091000, // Mainnet network
|
||||
zero_slot: 4492800,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1564,6 +1573,7 @@ fn eval_missing_redeemer() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
@@ -1642,6 +1652,7 @@ fn eval_extraneous_redeemer() {
|
||||
|
||||
let slot_config = SlotConfig {
|
||||
zero_time: 1660003200000, // Preview network
|
||||
zero_slot: 0,
|
||||
slot_length: 1000,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user