@@ -15,7 +15,7 @@ func TestCLNBackend_Wait_NotSynced(t *testing.T) {
1515 w .WriteHeader (http .StatusBadRequest )
1616 return
1717 }
18- json .NewEncoder (w ).Encode (map [string ]interface {}{
18+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
1919 "warning_bitcoind_sync" : "syncing blocks" ,
2020 "warning_lightningd_sync" : "" ,
2121 "blockheight" : 100 ,
@@ -47,13 +47,13 @@ func TestCLNBackend_Wait_Synced(t *testing.T) {
4747 }
4848 callCount ++
4949 if callCount < 2 {
50- json .NewEncoder (w ).Encode (map [string ]interface {}{
50+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
5151 "warning_bitcoind_sync" : "" ,
5252 "warning_lightningd_sync" : "syncing" ,
5353 "blockheight" : 100 ,
5454 })
5555 } else {
56- json .NewEncoder (w ).Encode (map [string ]interface {}{
56+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
5757 "warning_bitcoind_sync" : "" ,
5858 "warning_lightningd_sync" : "" ,
5959 "blockheight" : 101 ,
@@ -87,14 +87,17 @@ func TestCLNBackend_CreateInvoice(t *testing.T) {
8787 }
8888
8989 var req map [string ]interface {}
90- json .NewDecoder (r .Body ).Decode (& req )
90+ if err := json .NewDecoder (r .Body ).Decode (& req ); err != nil {
91+ w .WriteHeader (http .StatusBadRequest )
92+ return
93+ }
9194
9295 if req ["amount_msat" ].(float64 ) != 5000 || req ["description" ].(string ) != "test memo" {
9396 w .WriteHeader (http .StatusBadRequest )
9497 return
9598 }
9699
97- json .NewEncoder (w ).Encode (map [string ]string {
100+ _ = json .NewEncoder (w ).Encode (map [string ]string {
98101 "payment_hash" : "abcd1234567890ef" ,
99102 "bolt11" : "lnbc50u1p..." ,
100103 })
@@ -128,7 +131,7 @@ func TestCLNBackend_VerifyPayment_Unpaid(t *testing.T) {
128131 w .WriteHeader (http .StatusBadRequest )
129132 return
130133 }
131- json .NewEncoder (w ).Encode (map [string ]interface {}{
134+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
132135 "invoices" : []map [string ]string {
133136 {"status" : "unpaid" },
134137 },
@@ -157,7 +160,7 @@ func TestCLNBackend_VerifyPayment_Paid(t *testing.T) {
157160 w .WriteHeader (http .StatusBadRequest )
158161 return
159162 }
160- json .NewEncoder (w ).Encode (map [string ]interface {}{
163+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
161164 "invoices" : []map [string ]string {
162165 {"status" : "paid" },
163166 },
@@ -186,7 +189,7 @@ func TestCLNBackend_VerifyPayment_NotFound(t *testing.T) {
186189 w .WriteHeader (http .StatusBadRequest )
187190 return
188191 }
189- json .NewEncoder (w ).Encode (map [string ]interface {}{
192+ _ = json .NewEncoder (w ).Encode (map [string ]interface {}{
190193 "invoices" : []map [string ]string {},
191194 })
192195 }))
@@ -210,7 +213,7 @@ func TestCLNBackend_VerifyPayment_NotFound(t *testing.T) {
210213func TestCLNBackend_HTTPError (t * testing.T ) {
211214 server := httptest .NewTLSServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
212215 w .WriteHeader (http .StatusUnauthorized )
213- w .Write ([]byte ("Invalid rune" ))
216+ _ , _ = w .Write ([]byte ("Invalid rune" ))
214217 }))
215218 defer server .Close ()
216219
0 commit comments