@@ -255,10 +255,38 @@ func TestGetTransaction(t *testing.T) {
255
255
require .NoError (t , err )
256
256
}
257
257
258
+ t .Run ("returns_empty_try" , func (t * testing.T ) {
259
+ txHash := "hash"
260
+ ctx := context .Background ()
261
+ _ = store .UpsertTransaction (ctx , "localhost:8080/webhook" , txHash , "xdr" , tss.RPCTXStatus {OtherStatus : tss .NewStatus })
262
+ req , err := http .NewRequest (http .MethodGet , path .Join (endpoint , txHash ), nil )
263
+ require .NoError (t , err )
264
+
265
+ // Serve request
266
+ rw := httptest .NewRecorder ()
267
+ r .ServeHTTP (rw , req )
268
+ resp := rw .Result ()
269
+ respBody , err := io .ReadAll (resp .Body )
270
+ require .NoError (t , err )
271
+ var tssResp tss.TSSResponse
272
+ _ = json .Unmarshal (respBody , & tssResp )
273
+
274
+ assert .Equal (t , http .StatusOK , resp .StatusCode )
275
+ assert .Equal (t , txHash , tssResp .TransactionHash )
276
+ assert .Equal (t , fmt .Sprint (tss .NoCode ), tssResp .TransactionResultCode )
277
+ assert .Equal (t , fmt .Sprint (tss .NewStatus ), tssResp .Status )
278
+ assert .Equal (t , "" , tssResp .ResultXDR )
279
+ assert .Equal (t , "" , tssResp .EnvelopeXDR )
280
+
281
+ clearTransactions (ctx )
282
+ })
283
+
258
284
t .Run ("returns_transaction" , func (t * testing.T ) {
259
285
txHash := "hash"
286
+ resultXdr := "resultXdr"
260
287
ctx := context .Background ()
261
288
_ = store .UpsertTransaction (ctx , "localhost:8080/webhook" , txHash , "xdr" , tss.RPCTXStatus {OtherStatus : tss .NewStatus })
289
+ _ = store .UpsertTry (ctx , txHash , "feebumphash" , "feebumpxdr" , tss.RPCTXStatus {OtherStatus : tss .NewStatus }, tss.RPCTXCode {OtherCodes : tss .NewCode }, resultXdr )
262
290
req , err := http .NewRequest (http .MethodGet , path .Join (endpoint , txHash ), nil )
263
291
require .NoError (t , err )
264
292
@@ -268,13 +296,14 @@ func TestGetTransaction(t *testing.T) {
268
296
resp := rw .Result ()
269
297
respBody , err := io .ReadAll (resp .Body )
270
298
require .NoError (t , err )
271
- var getTxResp GetTransactionResponse
272
- _ = json .Unmarshal (respBody , & getTxResp )
299
+ var tssResp tss. TSSResponse
300
+ _ = json .Unmarshal (respBody , & tssResp )
273
301
274
302
assert .Equal (t , http .StatusOK , resp .StatusCode )
275
- assert .Equal (t , "hash" , getTxResp .Hash )
276
- assert .Equal (t , "xdr" , getTxResp .XDR )
277
- assert .Equal (t , "NEW" , getTxResp .Status )
303
+ assert .Equal (t , txHash , tssResp .TransactionHash )
304
+ assert .Equal (t , fmt .Sprint (tss .NewCode ), tssResp .TransactionResultCode )
305
+ assert .Equal (t , fmt .Sprint (tss .NewStatus ), tssResp .Status )
306
+ assert .Equal (t , resultXdr , tssResp .ResultXDR )
278
307
279
308
clearTransactions (ctx )
280
309
})
@@ -290,13 +319,13 @@ func TestGetTransaction(t *testing.T) {
290
319
resp := rw .Result ()
291
320
respBody , err := io .ReadAll (resp .Body )
292
321
require .NoError (t , err )
293
- var getTxResp GetTransactionResponse
294
- _ = json .Unmarshal (respBody , & getTxResp )
322
+ var tssResp tss. TSSResponse
323
+ _ = json .Unmarshal (respBody , & tssResp )
295
324
296
325
assert .Equal (t , http .StatusNotFound , resp .StatusCode )
297
- assert .Empty (t , getTxResp . Hash )
298
- assert .Empty (t , getTxResp . XDR )
299
- assert .Empty (t , getTxResp .Status )
326
+ assert .Empty (t , tssResp . TransactionHash )
327
+ assert .Empty (t , tssResp . EnvelopeXDR )
328
+ assert .Empty (t , tssResp .Status )
300
329
301
330
})
302
331
0 commit comments