github.com/decred/dcrlnd@v0.7.6/lntest/fee_service_test.go (about) 1 package lntest 2 3 import ( 4 "io/ioutil" 5 "net/http" 6 "testing" 7 "time" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 // TestFeeService tests the itest fee estimating web service. 13 func TestFeeService(t *testing.T) { 14 service := startFeeService() 15 defer service.stop() 16 17 service.setFee(5000) 18 19 // Wait for service to start accepting connections. 20 var resp *http.Response 21 require.Eventually( 22 t, 23 func() bool { 24 var err error 25 resp, err = http.Get(service.url) // nolint:bodyclose 26 return err == nil 27 }, 28 10*time.Second, time.Second, 29 ) 30 31 defer resp.Body.Close() 32 33 body, err := ioutil.ReadAll(resp.Body) 34 require.NoError(t, err) 35 36 require.Equal( 37 t, "{\"fee_by_block_target\":{\"1\":5000}}", string(body), 38 ) 39 }