Skip to content

Commit

Permalink
fix: edge when can not get epoch response
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Kungla <marko.kungla@gmail.com>
  • Loading branch information
mkungla committed Oct 3, 2022
1 parent ed00ca2 commit 74ecbb2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion address.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *Client) GetCredentialTxs(
return res, ReadAndUnmarshalResponse(rsp, &res.Response, &res.Data)
}

// String returns of address
// String returns of address.
func (a Address) String() string {
return string(a)
}
Expand Down
6 changes: 4 additions & 2 deletions address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *addressTestSuite) TestGetCredentialTxsEndpoint() {
}
}

// Requires more tests with supported address formats
// Requires more tests with supported address formats.
func (s *addressTestSuite) TestInvalidAddress() {
var tests = []struct {
Addr koios.Address
Expand Down Expand Up @@ -175,5 +175,7 @@ func (s *addressTestSuite) TestBytes() {
0x6b, 0x34, 0x77, 0x36, 0x71, 0x72, 0x78, 0x33,
0x70, 0x39, 0x38, 0x7a, 0x61, 0x64, 0x33, 0x66,
0x71, 0x30, 0x37, 0x78, 0x65, 0x39, 0x67},
koios.Address("addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g").Bytes())
koios.Address(
"addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g",
).Bytes())
}
6 changes: 6 additions & 0 deletions epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package koios

import (
"context"
"fmt"

"github.com/shopspring/decimal"
)
Expand Down Expand Up @@ -214,6 +215,11 @@ func (c *Client) GetEpochParams(
if err != nil {
return
}

err = ReadAndUnmarshalResponse(rsp, &res.Response, &res.Data)

if len(res.Data) == 0 {
return nil, fmt.Errorf("%w: could not get epoch params %s", ErrResponse, epoch)
}
return
}

0 comments on commit 74ecbb2

Please sign in to comment.