@@ -23,7 +23,7 @@ use witnet_data_structures::{
23
23
calculate_tally_change, calculate_witness_reward, create_tally, DataRequestPool ,
24
24
} ,
25
25
error:: { BlockError , DataRequestError , Secp256k1ConversionError , TransactionError } ,
26
- proto:: versioning:: ProtocolVersion ,
26
+ proto:: versioning:: { ProtocolVersion , VersionedHashable } ,
27
27
radon_error:: RadonError ,
28
28
radon_report:: { RadonReport , ReportContext , TypeLike } ,
29
29
staking:: stakes:: StakesTracker ,
@@ -1497,6 +1497,7 @@ fn data_request_no_inputs() {
1497
1497
MAX_DR_WEIGHT ,
1498
1498
REQUIRED_REWARD_COLLATERAL_RATIO ,
1499
1499
& current_active_wips ( ) ,
1500
+ None ,
1500
1501
) ;
1501
1502
assert_eq ! (
1502
1503
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1534,6 +1535,7 @@ fn data_request_no_inputs_but_one_signature() {
1534
1535
MAX_DR_WEIGHT ,
1535
1536
REQUIRED_REWARD_COLLATERAL_RATIO ,
1536
1537
& current_active_wips ( ) ,
1538
+ None ,
1537
1539
) ;
1538
1540
assert_eq ! (
1539
1541
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1580,6 +1582,7 @@ fn data_request_one_input_but_no_signature() {
1580
1582
MAX_DR_WEIGHT ,
1581
1583
REQUIRED_REWARD_COLLATERAL_RATIO ,
1582
1584
& current_active_wips ( ) ,
1585
+ None ,
1583
1586
) ;
1584
1587
assert_eq ! (
1585
1588
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1627,6 +1630,7 @@ fn data_request_one_input_signatures() {
1627
1630
MAX_DR_WEIGHT ,
1628
1631
REQUIRED_REWARD_COLLATERAL_RATIO ,
1629
1632
& current_active_wips ( ) ,
1633
+ None ,
1630
1634
) ?;
1631
1635
verify_signatures_test ( signatures_to_verify) ?;
1632
1636
@@ -1670,6 +1674,7 @@ fn data_request_input_double_spend() {
1670
1674
MAX_DR_WEIGHT ,
1671
1675
REQUIRED_REWARD_COLLATERAL_RATIO ,
1672
1676
& current_active_wips ( ) ,
1677
+ None ,
1673
1678
) ;
1674
1679
assert_eq ! (
1675
1680
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1710,6 +1715,7 @@ fn data_request_input_not_in_utxo() {
1710
1715
MAX_DR_WEIGHT ,
1711
1716
REQUIRED_REWARD_COLLATERAL_RATIO ,
1712
1717
& current_active_wips ( ) ,
1718
+ None ,
1713
1719
) ;
1714
1720
assert_eq ! (
1715
1721
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1755,6 +1761,7 @@ fn data_request_input_not_enough_value() {
1755
1761
MAX_DR_WEIGHT ,
1756
1762
REQUIRED_REWARD_COLLATERAL_RATIO ,
1757
1763
& current_active_wips ( ) ,
1764
+ None ,
1758
1765
) ;
1759
1766
assert_eq ! (
1760
1767
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1824,6 +1831,7 @@ fn data_request_output_value_overflow() {
1824
1831
MAX_DR_WEIGHT ,
1825
1832
REQUIRED_REWARD_COLLATERAL_RATIO ,
1826
1833
& current_active_wips ( ) ,
1834
+ None ,
1827
1835
) ;
1828
1836
assert_eq ! (
1829
1837
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -1861,6 +1869,7 @@ fn test_drtx(dr_output: DataRequestOutput) -> Result<(), failure::Error> {
1861
1869
u32:: MAX ,
1862
1870
REQUIRED_REWARD_COLLATERAL_RATIO ,
1863
1871
& all_wips_active ( ) ,
1872
+ None ,
1864
1873
)
1865
1874
. map ( |_| ( ) )
1866
1875
}
@@ -2263,6 +2272,7 @@ fn data_request_http_post_before_wip_activation() {
2263
2272
u32:: MAX ,
2264
2273
REQUIRED_REWARD_COLLATERAL_RATIO ,
2265
2274
& active_wips,
2275
+ None ,
2266
2276
)
2267
2277
. map ( |_| ( ) )
2268
2278
} ;
@@ -2331,6 +2341,7 @@ fn data_request_http_get_with_headers_before_wip_activation() {
2331
2341
u32:: MAX ,
2332
2342
REQUIRED_REWARD_COLLATERAL_RATIO ,
2333
2343
& active_wips,
2344
+ None ,
2334
2345
)
2335
2346
. map ( |_| ( ) )
2336
2347
} ;
@@ -2389,6 +2400,7 @@ fn data_request_parse_xml_before_wip_activation() {
2389
2400
u32:: MAX ,
2390
2401
REQUIRED_REWARD_COLLATERAL_RATIO ,
2391
2402
& active_wips,
2403
+ None ,
2392
2404
)
2393
2405
. map ( |_| ( ) )
2394
2406
} ;
@@ -2445,6 +2457,7 @@ fn data_request_parse_xml_after_wip_activation() {
2445
2457
u32:: MAX ,
2446
2458
REQUIRED_REWARD_COLLATERAL_RATIO ,
2447
2459
& active_wips,
2460
+ None ,
2448
2461
)
2449
2462
. map ( |_| ( ) )
2450
2463
} ;
@@ -2478,6 +2491,7 @@ fn dr_validation_weight_limit_exceeded() {
2478
2491
1625 - 1 ,
2479
2492
REQUIRED_REWARD_COLLATERAL_RATIO ,
2480
2493
& current_active_wips ( ) ,
2494
+ None ,
2481
2495
) ;
2482
2496
2483
2497
assert_eq ! (
@@ -2566,6 +2580,7 @@ fn data_request_miner_fee() {
2566
2580
MAX_DR_WEIGHT ,
2567
2581
REQUIRED_REWARD_COLLATERAL_RATIO ,
2568
2582
& current_active_wips ( ) ,
2583
+ None ,
2569
2584
)
2570
2585
. map ( |( _, _, fee) | fee)
2571
2586
. unwrap ( ) ;
@@ -2617,6 +2632,7 @@ fn data_request_miner_fee_with_change() {
2617
2632
MAX_DR_WEIGHT ,
2618
2633
REQUIRED_REWARD_COLLATERAL_RATIO ,
2619
2634
& current_active_wips ( ) ,
2635
+ None ,
2620
2636
)
2621
2637
. map ( |( _, _, fee) | fee)
2622
2638
. unwrap ( ) ;
@@ -2668,6 +2684,7 @@ fn data_request_change_to_different_pkh() {
2668
2684
MAX_DR_WEIGHT ,
2669
2685
REQUIRED_REWARD_COLLATERAL_RATIO ,
2670
2686
& current_active_wips ( ) ,
2687
+ None ,
2671
2688
) ;
2672
2689
2673
2690
assert_eq ! (
@@ -2729,6 +2746,7 @@ fn data_request_two_change_outputs() {
2729
2746
MAX_DR_WEIGHT ,
2730
2747
REQUIRED_REWARD_COLLATERAL_RATIO ,
2731
2748
& current_active_wips ( ) ,
2749
+ None ,
2732
2750
) ;
2733
2751
2734
2752
assert_eq ! (
@@ -2782,6 +2800,7 @@ fn data_request_miner_fee_with_too_much_change() {
2782
2800
MAX_DR_WEIGHT ,
2783
2801
REQUIRED_REWARD_COLLATERAL_RATIO ,
2784
2802
& current_active_wips ( ) ,
2803
+ None ,
2785
2804
) ;
2786
2805
assert_eq ! (
2787
2806
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -2830,6 +2849,7 @@ fn data_request_zero_value_output() {
2830
2849
MAX_DR_WEIGHT ,
2831
2850
REQUIRED_REWARD_COLLATERAL_RATIO ,
2832
2851
& current_active_wips ( ) ,
2852
+ None ,
2833
2853
) ;
2834
2854
assert_eq ! (
2835
2855
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -2881,6 +2901,7 @@ fn data_request_reward_collateral_ratio_wip() {
2881
2901
MAX_DR_WEIGHT ,
2882
2902
PSEUDO_CONSENSUS_CONSTANTS_WIP0022_REWARD_COLLATERAL_RATIO ,
2883
2903
& active_wips,
2904
+ None ,
2884
2905
) ;
2885
2906
x. unwrap ( ) ;
2886
2907
@@ -2897,6 +2918,7 @@ fn data_request_reward_collateral_ratio_wip() {
2897
2918
MAX_DR_WEIGHT ,
2898
2919
PSEUDO_CONSENSUS_CONSTANTS_WIP0022_REWARD_COLLATERAL_RATIO ,
2899
2920
& active_wips,
2921
+ None ,
2900
2922
) ;
2901
2923
assert_eq ! (
2902
2924
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -2952,6 +2974,7 @@ fn data_request_reward_collateral_ratio_limit() {
2952
2974
MAX_DR_WEIGHT ,
2953
2975
PSEUDO_CONSENSUS_CONSTANTS_WIP0022_REWARD_COLLATERAL_RATIO ,
2954
2976
& active_wips,
2977
+ None ,
2955
2978
) ;
2956
2979
x. unwrap ( ) ;
2957
2980
@@ -2979,6 +3002,7 @@ fn data_request_reward_collateral_ratio_limit() {
2979
3002
MAX_DR_WEIGHT ,
2980
3003
PSEUDO_CONSENSUS_CONSTANTS_WIP0022_REWARD_COLLATERAL_RATIO ,
2981
3004
& active_wips,
3005
+ None ,
2982
3006
) ;
2983
3007
assert_eq ! (
2984
3008
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -10002,6 +10026,7 @@ fn test_blocks(txns: Vec<(BlockTransactions, u64)>) -> Result<(), failure::Error
10002
10026
MAX_VT_WEIGHT ,
10003
10027
MAX_DR_WEIGHT ,
10004
10028
GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
10029
+ None ,
10005
10030
)
10006
10031
}
10007
10032
@@ -10010,6 +10035,7 @@ fn test_blocks_with_limits(
10010
10035
max_vt_weight : u32 ,
10011
10036
max_dr_weight : u32 ,
10012
10037
genesis_block_hash : Hash ,
10038
+ protocol_version : Option < ProtocolVersion > ,
10013
10039
) -> Result < ( ) , failure:: Error > {
10014
10040
if txns. len ( ) > 1 {
10015
10041
// FIXME(#685): add sequence validations
@@ -10022,7 +10048,7 @@ fn test_blocks_with_limits(
10022
10048
let mut utxo_set = UnspentOutputsPool :: default ( ) ;
10023
10049
let block_number = 0 ;
10024
10050
let stakes = StakesTracker :: default ( ) ;
10025
- let protocol_version = ProtocolVersion :: default ( ) ;
10051
+ let protocol_version = protocol_version . unwrap_or_default ( ) ;
10026
10052
10027
10053
let consensus_constants = ConsensusConstants {
10028
10054
checkpoint_zero_timestamp : 0 ,
@@ -11305,6 +11331,7 @@ fn validate_vt_weight_overflow() {
11305
11331
2 * 493 - 1 ,
11306
11332
0 ,
11307
11333
GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
11334
+ None ,
11308
11335
) ;
11309
11336
assert_eq ! (
11310
11337
x. unwrap_err( ) . downcast:: <BlockError >( ) . unwrap( ) ,
@@ -11343,7 +11370,13 @@ fn validate_vt_weight_valid() {
11343
11370
DEFAULT_INPUT_VALUE - 2 * 10 ,
11344
11371
)
11345
11372
} ;
11346
- let x = test_blocks_with_limits ( vec ! [ t0] , 2 * 493 , 0 , GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ) ;
11373
+ let x = test_blocks_with_limits (
11374
+ vec ! [ t0] ,
11375
+ 2 * 493 ,
11376
+ 0 ,
11377
+ GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
11378
+ None ,
11379
+ ) ;
11347
11380
x. unwrap ( ) ;
11348
11381
}
11349
11382
@@ -11370,7 +11403,7 @@ fn validate_vt_weight_genesis_valid() {
11370
11403
1_000_000 - 10 ,
11371
11404
)
11372
11405
} ;
11373
- let x = test_blocks_with_limits ( vec ! [ t0] , 0 , 0 , new_genesis. parse ( ) . unwrap ( ) ) ;
11406
+ let x = test_blocks_with_limits ( vec ! [ t0] , 0 , 0 , new_genesis. parse ( ) . unwrap ( ) , None ) ;
11374
11407
x. unwrap ( ) ;
11375
11408
}
11376
11409
@@ -11406,6 +11439,7 @@ fn validate_dr_weight_overflow() {
11406
11439
0 ,
11407
11440
2 * 1589 - 1 ,
11408
11441
GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
11442
+ None ,
11409
11443
) ;
11410
11444
assert_eq ! (
11411
11445
x. unwrap_err( ) . downcast:: <BlockError >( ) . unwrap( ) ,
@@ -11445,6 +11479,7 @@ fn validate_dr_weight_overflow_126_witnesses() {
11445
11479
0 ,
11446
11480
MAX_DR_WEIGHT ,
11447
11481
GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
11482
+ None ,
11448
11483
) ;
11449
11484
assert_eq ! (
11450
11485
x. unwrap_err( ) . downcast:: <TransactionError >( ) . unwrap( ) ,
@@ -11483,7 +11518,13 @@ fn validate_dr_weight_valid() {
11483
11518
DEFAULT_INPUT_VALUE - 2 * dr_value,
11484
11519
)
11485
11520
} ;
11486
- let x = test_blocks_with_limits ( vec ! [ t0] , 0 , 2 * 1605 , GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ) ;
11521
+ let x = test_blocks_with_limits (
11522
+ vec ! [ t0] ,
11523
+ 0 ,
11524
+ 2 * 1605 ,
11525
+ GENESIS_BLOCK_HASH . parse ( ) . unwrap ( ) ,
11526
+ None ,
11527
+ ) ;
11487
11528
x. unwrap ( ) ;
11488
11529
}
11489
11530
0 commit comments