@@ -15,10 +15,6 @@ import (
15
15
"github.com/stretchr/testify/require"
16
16
)
17
17
18
- const (
19
- minRelayFeeRate = chainfee .FeePerKwFloor
20
- )
21
-
22
18
// TestOrderedSweeps checks that methods batch.getOrderedSweeps and
23
19
// batch.getSweepsGroups works properly.
24
20
func TestOrderedSweeps (t * testing.T ) {
@@ -490,6 +486,7 @@ func TestEnsurePresigned(t *testing.T) {
490
486
primarySweepID wire.OutPoint
491
487
sweeps []* sweep
492
488
destPkScript []byte
489
+ minRelayFeeRate chainfee.SatPerKWeight
493
490
wantInputAmt btcutil.Amount
494
491
destPkScriptErr error
495
492
signedTxErr error
@@ -504,8 +501,24 @@ func TestEnsurePresigned(t *testing.T) {
504
501
timeout : 1000 ,
505
502
},
506
503
},
507
- destPkScript : batchPkScript ,
508
- wantInputAmt : 1_000_000 ,
504
+ destPkScript : batchPkScript ,
505
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
506
+ wantInputAmt : 1_000_000 ,
507
+ },
508
+
509
+ {
510
+ name : "one input, higher minRelayFeeRate" ,
511
+ primarySweepID : op1 ,
512
+ sweeps : []* sweep {
513
+ {
514
+ outpoint : op1 ,
515
+ value : 1_000_000 ,
516
+ timeout : 1000 ,
517
+ },
518
+ },
519
+ destPkScript : batchPkScript ,
520
+ minRelayFeeRate : 1000 ,
521
+ wantInputAmt : 1_000_000 ,
509
522
},
510
523
511
524
{
@@ -523,8 +536,9 @@ func TestEnsurePresigned(t *testing.T) {
523
536
timeout : 1000 ,
524
537
},
525
538
},
526
- destPkScript : batchPkScript ,
527
- wantInputAmt : 3_000_000 ,
539
+ destPkScript : batchPkScript ,
540
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
541
+ wantInputAmt : 3_000_000 ,
528
542
},
529
543
530
544
{
@@ -537,6 +551,7 @@ func TestEnsurePresigned(t *testing.T) {
537
551
timeout : 1000 ,
538
552
},
539
553
},
554
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
540
555
destPkScriptErr : fmt .Errorf ("test DestPkScript error" ),
541
556
},
542
557
@@ -550,8 +565,9 @@ func TestEnsurePresigned(t *testing.T) {
550
565
timeout : 1000 ,
551
566
},
552
567
},
553
- destPkScript : batchPkScript ,
554
- signedTxErr : fmt .Errorf ("test SignTx error" ),
568
+ destPkScript : batchPkScript ,
569
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
570
+ signedTxErr : fmt .Errorf ("test SignTx error" ),
555
571
},
556
572
}
557
573
@@ -565,7 +581,7 @@ func TestEnsurePresigned(t *testing.T) {
565
581
}
566
582
567
583
err := ensurePresigned (
568
- ctx , tc .sweeps , c , minRelayFeeRate ,
584
+ ctx , tc .sweeps , c , tc . minRelayFeeRate ,
569
585
& chaincfg .RegressionNetParams ,
570
586
)
571
587
switch {
@@ -580,11 +596,11 @@ func TestEnsurePresigned(t *testing.T) {
580
596
t , tc .wantInputAmt , c .recordedInputAmt ,
581
597
)
582
598
require .Equal (
583
- t , chainfee . FeePerKwFloor ,
599
+ t , tc . minRelayFeeRate ,
584
600
c .recordedMinRelayFee ,
585
601
)
586
602
require .Equal (
587
- t , chainfee . FeePerKwFloor ,
603
+ t , tc . minRelayFeeRate ,
588
604
c .recordedFeeRate ,
589
605
)
590
606
require .True (t , c .recordedLoadOnly )
@@ -664,6 +680,7 @@ func TestPresign(t *testing.T) {
664
680
sweeps []sweep
665
681
destAddr btcutil.Address
666
682
nextBlockFeeRate chainfee.SatPerKWeight
683
+ minRelayFeeRate chainfee.SatPerKWeight
667
684
wantErr string
668
685
wantOutputs []btcutil.Amount
669
686
wantLockTimes []uint32
@@ -680,6 +697,7 @@ func TestPresign(t *testing.T) {
680
697
},
681
698
destAddr : destAddr ,
682
699
nextBlockFeeRate : chainfee .FeePerKwFloor ,
700
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
683
701
wantErr : "presigner is not installed" ,
684
702
},
685
703
@@ -689,6 +707,7 @@ func TestPresign(t *testing.T) {
689
707
presigner : & mockPresigner {},
690
708
destAddr : destAddr ,
691
709
nextBlockFeeRate : chainfee .FeePerKwFloor ,
710
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
692
711
wantErr : "there are no sweeps" ,
693
712
},
694
713
@@ -704,6 +723,7 @@ func TestPresign(t *testing.T) {
704
723
},
705
724
},
706
725
nextBlockFeeRate : chainfee .FeePerKwFloor ,
726
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
707
727
wantErr : "unsupported address type <nil>" ,
708
728
},
709
729
@@ -723,8 +743,30 @@ func TestPresign(t *testing.T) {
723
743
timeout : 1000 ,
724
744
},
725
745
},
726
- destAddr : destAddr ,
727
- wantErr : "nextBlockFeeRate is not set" ,
746
+ destAddr : destAddr ,
747
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
748
+ wantErr : "nextBlockFeeRate is not set" ,
749
+ },
750
+
751
+ {
752
+ name : "error: zero minRelayFeeRate" ,
753
+ presigner : & mockPresigner {},
754
+ primarySweepID : op1 ,
755
+ sweeps : []sweep {
756
+ {
757
+ outpoint : op1 ,
758
+ value : 1_000_000 ,
759
+ timeout : 1000 ,
760
+ },
761
+ {
762
+ outpoint : op2 ,
763
+ value : 2_000_000 ,
764
+ timeout : 1000 ,
765
+ },
766
+ },
767
+ destAddr : destAddr ,
768
+ nextBlockFeeRate : chainfee .FeePerKwFloor ,
769
+ wantErr : "minRelayFeeRate is not set" ,
728
770
},
729
771
730
772
{
@@ -743,6 +785,7 @@ func TestPresign(t *testing.T) {
743
785
},
744
786
destAddr : destAddr ,
745
787
nextBlockFeeRate : chainfee .FeePerKwFloor ,
788
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
746
789
wantErr : "timeout is invalid: 0" ,
747
790
},
748
791
@@ -763,6 +806,7 @@ func TestPresign(t *testing.T) {
763
806
},
764
807
destAddr : destAddr ,
765
808
nextBlockFeeRate : chainfee .FeePerKwFloor ,
809
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
766
810
wantErr : "not in tx" ,
767
811
},
768
812
@@ -779,6 +823,7 @@ func TestPresign(t *testing.T) {
779
823
},
780
824
destAddr : destAddr ,
781
825
nextBlockFeeRate : chainfee .FeePerKwFloor ,
826
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
782
827
wantErr : "not in tx" ,
783
828
},
784
829
@@ -795,6 +840,7 @@ func TestPresign(t *testing.T) {
795
840
},
796
841
destAddr : destAddr ,
797
842
nextBlockFeeRate : chainfee .FeePerKwFloor ,
843
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
798
844
wantOutputs : []btcutil.Amount {
799
845
999900 , 999880 , 999856 , 999827 , 999793 , 999752 ,
800
846
999702 , 999643 , 999572 , 999486 , 999384 , 999260 ,
@@ -812,6 +858,34 @@ func TestPresign(t *testing.T) {
812
858
},
813
859
},
814
860
861
+ {
862
+ name : "higher minRelayFeeRate, fewer txns" ,
863
+ presigner : & mockPresigner {},
864
+ primarySweepID : op1 ,
865
+ sweeps : []sweep {
866
+ {
867
+ outpoint : op1 ,
868
+ value : 1_000_000 ,
869
+ timeout : 1000 ,
870
+ },
871
+ },
872
+ destAddr : destAddr ,
873
+ nextBlockFeeRate : 10 * chainfee .FeePerKwFloor ,
874
+ minRelayFeeRate : 10 * chainfee .FeePerKwFloor ,
875
+ wantOutputs : []btcutil.Amount {
876
+ 998998 , 998797 , 998557 , 998269 , 997923 , 997507 ,
877
+ 997009 , 996411 , 995694 , 994833 , 993800 , 992560 ,
878
+ 991072 , 989286 , 987144 , 984573 , 981488 , 977786 ,
879
+ 973343 , 968012 , 961614 , 953937 , 944725 , 933670 ,
880
+ 920405 , 904486 , 885383 , 862460 , 834952 ,
881
+ },
882
+ wantLockTimes : []uint32 {
883
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 950 , 950 ,
884
+ 950 , 950 , 950 , 950 , 950 , 950 , 950 , 950 , 950 ,
885
+ 950 , 950 , 950 , 950 , 950 ,
886
+ },
887
+ },
888
+
815
889
{
816
890
name : "two sweeps" ,
817
891
presigner : & mockPresigner {},
@@ -830,6 +904,7 @@ func TestPresign(t *testing.T) {
830
904
},
831
905
destAddr : destAddr ,
832
906
nextBlockFeeRate : chainfee .FeePerKwFloor ,
907
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
833
908
wantOutputs : []btcutil.Amount {
834
909
2999841 , 2999810 , 2999773 , 2999728 , 2999673 ,
835
910
2999608 , 2999530 , 2999436 , 2999323 , 2999188 ,
@@ -867,6 +942,7 @@ func TestPresign(t *testing.T) {
867
942
},
868
943
destAddr : destAddr ,
869
944
nextBlockFeeRate : chainfee .FeePerKwFloor ,
945
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
870
946
wantOutputs : []btcutil.Amount {
871
947
2999841 , 2999810 , 2999773 , 2999728 , 2999673 ,
872
948
2999608 , 2999530 , 2999436 , 2999323 , 2999188 ,
@@ -904,6 +980,7 @@ func TestPresign(t *testing.T) {
904
980
},
905
981
destAddr : destAddr ,
906
982
nextBlockFeeRate : 50 * chainfee .FeePerKwFloor ,
983
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
907
984
wantOutputs : []btcutil.Amount {
908
985
2999841 , 2999810 , 2999773 , 2999728 , 2999673 ,
909
986
2999608 , 2999530 , 2999436 , 2999323 , 2999188 ,
@@ -940,6 +1017,7 @@ func TestPresign(t *testing.T) {
940
1017
},
941
1018
destAddr : destAddr ,
942
1019
nextBlockFeeRate : 50 * chainfee .FeePerKwFloor ,
1020
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
943
1021
wantOutputs : []btcutil.Amount {
944
1022
2999841 , 2999810 , 2999773 , 2999728 , 2999673 ,
945
1023
2999608 , 2999530 , 2999436 , 2999323 , 2999188 ,
@@ -976,6 +1054,7 @@ func TestPresign(t *testing.T) {
976
1054
},
977
1055
destAddr : destAddr ,
978
1056
nextBlockFeeRate : chainfee .FeePerKwFloor ,
1057
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
979
1058
wantOutputs : []btcutil.Amount {
980
1059
2841 , 2810 , 2773 , 2728 , 2673 , 2608 , 2530 , 2436 ,
981
1060
2400 ,
@@ -1005,6 +1084,7 @@ func TestPresign(t *testing.T) {
1005
1084
},
1006
1085
destAddr : destAddr ,
1007
1086
nextBlockFeeRate : chainfee .FeePerKwFloor ,
1087
+ minRelayFeeRate : chainfee .FeePerKwFloor ,
1008
1088
wantErr : "for feeRate 363 sat/kw" ,
1009
1089
},
1010
1090
}
@@ -1014,7 +1094,7 @@ func TestPresign(t *testing.T) {
1014
1094
err := presign (
1015
1095
ctx , tc .presigner , tc .destAddr ,
1016
1096
tc .primarySweepID , tc .sweeps ,
1017
- tc .nextBlockFeeRate , minRelayFeeRate ,
1097
+ tc .nextBlockFeeRate , tc . minRelayFeeRate ,
1018
1098
)
1019
1099
if tc .wantErr != "" {
1020
1100
require .Error (t , err )
0 commit comments