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