@@ -764,6 +764,7 @@ mod tests {
764
764
assert_eq ! ( policy. n_keys( ) , 0 ) ;
765
765
assert_eq ! ( policy. minimum_n_keys( ) , Some ( 0 ) ) ;
766
766
767
+ // Block height 1000.
767
768
let policy = StringPolicy :: from_str ( "after(1000)" ) . unwrap ( ) ;
768
769
assert_eq ! ( policy, Policy :: After ( 1000 ) ) ;
769
770
assert_eq ! ( policy. absolute_timelocks( ) , vec![ 1000 ] ) ;
@@ -772,6 +773,26 @@ mod tests {
772
773
assert_eq ! ( policy. clone( ) . at_height( 999 ) , Policy :: Unsatisfiable ) ;
773
774
assert_eq ! ( policy. clone( ) . at_height( 1000 ) , policy. clone( ) ) ;
774
775
assert_eq ! ( policy. clone( ) . at_height( 10000 ) , policy. clone( ) ) ;
776
+ // Pass a UNIX timestamp to at_height while policy uses a block height.
777
+ assert_eq ! ( policy. clone( ) . at_height( 500_000_001 ) , Policy :: Unsatisfiable ) ;
778
+ assert_eq ! ( policy. n_keys( ) , 0 ) ;
779
+ assert_eq ! ( policy. minimum_n_keys( ) , Some ( 0 ) ) ;
780
+
781
+ // UNIX timestamp of 10 seconds after the epoch.
782
+ let policy = StringPolicy :: from_str ( "after(500000010)" ) . unwrap ( ) ;
783
+ assert_eq ! ( policy, Policy :: After ( 500_000_010 ) ) ;
784
+ assert_eq ! ( policy. absolute_timelocks( ) , vec![ 500_000_010 ] ) ;
785
+ assert_eq ! ( policy. relative_timelocks( ) , vec![ ] ) ;
786
+ // Pass a block height to at_height while policy uses a UNIX timestapm.
787
+ assert_eq ! ( policy. clone( ) . at_height( 0 ) , Policy :: Unsatisfiable ) ;
788
+ assert_eq ! ( policy. clone( ) . at_height( 999 ) , Policy :: Unsatisfiable ) ;
789
+ assert_eq ! ( policy. clone( ) . at_height( 1000 ) , Policy :: Unsatisfiable ) ;
790
+ assert_eq ! ( policy. clone( ) . at_height( 10000 ) , Policy :: Unsatisfiable ) ;
791
+ // And now pass a UNIX timestamp to at_height while policy also uses a timestamp.
792
+ assert_eq ! ( policy. clone( ) . at_height( 500_000_000 ) , Policy :: Unsatisfiable ) ;
793
+ assert_eq ! ( policy. clone( ) . at_height( 500_000_001 ) , Policy :: Unsatisfiable ) ;
794
+ assert_eq ! ( policy. clone( ) . at_height( 500_000_010 ) , policy. clone( ) ) ;
795
+ assert_eq ! ( policy. clone( ) . at_height( 500_000_012 ) , policy. clone( ) ) ;
775
796
assert_eq ! ( policy. n_keys( ) , 0 ) ;
776
797
assert_eq ! ( policy. minimum_n_keys( ) , Some ( 0 ) ) ;
777
798
}
0 commit comments