@@ -722,6 +722,7 @@ pub mod tests {
722
722
}
723
723
724
724
#[ test]
725
+ #[ cfg( unix) ]
725
726
fn test_get_unconfirmed_commits ( ) {
726
727
use std:: os:: unix:: fs:: PermissionsExt ;
727
728
let shell_code = r#"#!/bin/bash
808
809
) ;
809
810
}
810
811
812
+ #[ test]
813
+ #[ cfg( windows) ]
814
+ fn test_get_unconfirmed_commits ( ) {
815
+ let shell_code = r#"@echo off
816
+ (
817
+ echo [
818
+ echo {
819
+ echo "txid": "73c318be8cd272a73200b9630089d77a44342d84b2c0d81c937da714152cf402",
820
+ echo "burn": 555000,
821
+ echo "address": "1FCcoFSKWvNyhjazNvVdLLw8mGkGdcRMux",
822
+ echo "input_txid": "ef0dbf0fc4755de5e94843a4da7c1d943571299afb15f32b76bac5d18d8668ce",
823
+ echo "input_index": 3,
824
+ echo "pox_addrs": [
825
+ echo "0014db14133a9dbb1d0e16b60513453e48b6ff2847a9",
826
+ echo "a91418c42080a1e87fd02dd3fca94c4513f9ecfe741487"
827
+ echo ]
828
+ echo }
829
+ echo ]
830
+ )
831
+ "# ;
832
+ let path = "/tmp/test-get-unconfirmed-commits.bat" ;
833
+ if fs:: metadata ( path) . is_ok ( ) {
834
+ fs:: remove_file ( path) . unwrap ( ) ;
835
+ }
836
+ {
837
+ let mut f = fs:: File :: create ( path) . unwrap ( ) ;
838
+ f. write_all ( shell_code. as_bytes ( ) ) . unwrap ( ) ;
839
+ }
840
+
841
+ let ms = MinerStats {
842
+ unconfirmed_commits_helper : path. to_string ( ) ,
843
+ } ;
844
+
845
+ let mut commits = ms. get_unconfirmed_commits ( 123 , & [ ] ) . unwrap ( ) ;
846
+ assert_eq ! ( commits. len( ) , 1 ) ;
847
+ let commit = commits. pop ( ) . unwrap ( ) ;
848
+
849
+ assert_eq ! (
850
+ commit. txid,
851
+ Txid :: from_hex( "73c318be8cd272a73200b9630089d77a44342d84b2c0d81c937da714152cf402" )
852
+ . unwrap( )
853
+ ) ;
854
+ assert_eq ! ( commit. burn_fee, 555000 ) ;
855
+ assert_eq ! (
856
+ commit. apparent_sender. 0 ,
857
+ "1FCcoFSKWvNyhjazNvVdLLw8mGkGdcRMux" . to_string( )
858
+ ) ;
859
+ assert_eq ! (
860
+ commit. input. 0 ,
861
+ Txid :: from_hex( "ef0dbf0fc4755de5e94843a4da7c1d943571299afb15f32b76bac5d18d8668ce" )
862
+ . unwrap( )
863
+ ) ;
864
+ assert_eq ! ( commit. input. 1 , 3 ) ;
865
+ assert_eq ! ( commit. block_height, 123 ) ;
866
+
867
+ assert_eq ! (
868
+ commit. commit_outs,
869
+ vec![
870
+ PoxAddress :: Addr20 (
871
+ true ,
872
+ PoxAddressType20 :: P2WPKH ,
873
+ [
874
+ 219 , 20 , 19 , 58 , 157 , 187 , 29 , 14 , 22 , 182 , 5 , 19 , 69 , 62 , 72 , 182 , 255 ,
875
+ 40 , 71 , 169
876
+ ]
877
+ ) ,
878
+ PoxAddress :: Standard (
879
+ StacksAddress :: new(
880
+ 20 ,
881
+ Hash160 ( [
882
+ 0x18 , 0xc4 , 0x20 , 0x80 , 0xa1 , 0xe8 , 0x7f , 0xd0 , 0x2d , 0xd3 , 0xfc , 0xa9 ,
883
+ 0x4c , 0x45 , 0x13 , 0xf9 , 0xec , 0xfe , 0x74 , 0x14
884
+ ] )
885
+ )
886
+ . unwrap( ) ,
887
+ None
888
+ )
889
+ ]
890
+ ) ;
891
+ }
892
+
811
893
#[ test]
812
894
fn test_get_spend_and_win_distribution ( ) {
813
895
let active_miners_and_commits = vec ! [
0 commit comments