4
4
"context"
5
5
6
6
"github.com/renproject/multichain/chain/bitcoin"
7
+ "github.com/renproject/pack"
7
8
8
9
. "github.com/onsi/ginkgo"
9
10
. "github.com/onsi/gomega"
@@ -18,23 +19,34 @@ var _ = Describe("Gas", func() {
18
19
client := bitcoin .NewClient (bitcoin .DefaultClientOptions ())
19
20
20
21
// estimate fee to include tx within 1 block.
21
- gasEstimator1 := bitcoin .NewGasEstimator (client , 1 )
22
+ fallback1 := uint64 (123 )
23
+ gasEstimator1 := bitcoin .NewGasEstimator (client , 1 , pack .NewU256FromUint64 (fallback1 ))
22
24
gasPrice1 , _ , err := gasEstimator1 .EstimateGas (ctx )
23
- Expect (err ).NotTo (HaveOccurred ())
25
+ if err != nil {
26
+ Expect (gasPrice1 ).To (Equal (pack .NewU256FromUint64 (fallback1 )))
27
+ }
24
28
25
29
// estimate fee to include tx within 10 blocks.
26
- gasEstimator2 := bitcoin .NewGasEstimator (client , 10 )
30
+ fallback2 := uint64 (234 )
31
+ gasEstimator2 := bitcoin .NewGasEstimator (client , 10 , pack .NewU256FromUint64 (fallback2 ))
27
32
gasPrice2 , _ , err := gasEstimator2 .EstimateGas (ctx )
28
- Expect (err ).NotTo (HaveOccurred ())
33
+ if err != nil {
34
+ Expect (gasPrice2 ).To (Equal (pack .NewU256FromUint64 (fallback2 )))
35
+ }
29
36
30
37
// estimate fee to include tx within 100 blocks.
31
- gasEstimator3 := bitcoin .NewGasEstimator (client , 100 )
38
+ fallback3 := uint64 (345 )
39
+ gasEstimator3 := bitcoin .NewGasEstimator (client , 100 , pack .NewU256FromUint64 (fallback3 ))
32
40
gasPrice3 , _ , err := gasEstimator3 .EstimateGas (ctx )
33
- Expect (err ).NotTo (HaveOccurred ())
41
+ if err != nil {
42
+ Expect (gasPrice3 ).To (Equal (pack .NewU256FromUint64 (fallback3 )))
43
+ }
34
44
35
45
// expect fees in this order at the very least.
36
- Expect (gasPrice1 .GreaterThanEqual (gasPrice2 )).To (BeTrue ())
37
- Expect (gasPrice2 .GreaterThanEqual (gasPrice3 )).To (BeTrue ())
46
+ if err == nil {
47
+ Expect (gasPrice1 .GreaterThanEqual (gasPrice2 )).To (BeTrue ())
48
+ Expect (gasPrice2 .GreaterThanEqual (gasPrice3 )).To (BeTrue ())
49
+ }
38
50
})
39
51
})
40
52
})
0 commit comments