Skip to content

Commit

Permalink
Backend.Tests: add failing test for string error
Browse files Browse the repository at this point in the history
We noticed in [1] that some servers return error response
that has only a string error instead of an error object,
so we're adding a test to prove the issue.

[1] nblockchain#221
  • Loading branch information
aarani committed Oct 10, 2023
1 parent ae83bae commit de7a1f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/GWallet.Backend.Tests/Deserialization.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open System
open NUnit.Framework

open GWallet.Backend
open GWallet.Backend.UtxoCoin

[<TestFixture>]
type Deserialization() =
Expand Down
11 changes: 10 additions & 1 deletion src/GWallet.Backend.Tests/StratumParsing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ type StratumParsing() =
StratumClient.Deserialize<BlockchainScriptHashGetBalanceResult> errorResponse
|> ignore<BlockchainScriptHashGetBalanceResult>
)
Assert.That(ex.ErrorCode, Is.EqualTo(-32603))
Assert.That(ex.ErrorCode, Is.EqualTo(-32603))

[<Test>]
member __.``can deserialize error result with string error``() =
Assert.Throws<ElectrumServerReturningErrorInJsonResponseException> (
fun () ->
StratumClient.Deserialize<BlockchainTransactionGetResult> """{"error":"bad tx_hash","id":0,"jsonrpc":"2.0"}"""
|> ignore
)
|> ignore

0 comments on commit de7a1f3

Please sign in to comment.