github.com/trezor/blockbook@v0.4.1-0.20240328132726-e9a08582ee2c/bchain/coins/btc/mempoolspace_test.go (about)

     1  package btc
     2  
     3  import (
     4  	"math/big"
     5  	"strconv"
     6  	"testing"
     7  )
     8  
     9  func Test_mempoolSpaceFeeProvider(t *testing.T) {
    10  	m := &mempoolSpaceFeeProvider{alternativeFeeProvider: &alternativeFeeProvider{}}
    11  	m.mempoolSpaceFeeProcessData(&mempoolSpaceFeeResult{
    12  		MinimumFee:  10,
    13  		EconomyFee:  20,
    14  		HourFee:     30,
    15  		HalfHourFee: 40,
    16  		FastestFee:  50,
    17  	})
    18  
    19  	tests := []struct {
    20  		blocks int
    21  		want   big.Int
    22  	}{
    23  		{0, *big.NewInt(50000)},
    24  		{1, *big.NewInt(50000)},
    25  		{2, *big.NewInt(40000)},
    26  		{5, *big.NewInt(40000)},
    27  		{6, *big.NewInt(40000)},
    28  		{7, *big.NewInt(30000)},
    29  		{10, *big.NewInt(30000)},
    30  		{18, *big.NewInt(30000)},
    31  		{19, *big.NewInt(30000)},
    32  		{36, *big.NewInt(30000)},
    33  		{37, *big.NewInt(20000)},
    34  		{100, *big.NewInt(20000)},
    35  		{101, *big.NewInt(20000)},
    36  		{200, *big.NewInt(20000)},
    37  		{201, *big.NewInt(20000)},
    38  		{500, *big.NewInt(20000)},
    39  		{501, *big.NewInt(10000)},
    40  		{5000000, *big.NewInt(10000)},
    41  	}
    42  	for _, tt := range tests {
    43  		t.Run(strconv.Itoa(tt.blocks), func(t *testing.T) {
    44  			got, err := m.estimateFee(tt.blocks)
    45  			if err != nil {
    46  				t.Error("estimateFee returned error ", err)
    47  			}
    48  			if got.Cmp(&tt.want) != 0 {
    49  				t.Errorf("estimateFee(%d) = %v, want %v", tt.blocks, got, tt.want)
    50  			}
    51  		})
    52  	}
    53  }