Skip to content

Commit

Permalink
Merge pull request #25 from stellar/fix-stoml-test
Browse files Browse the repository at this point in the history
clients/stellartoml:  fixes failing example
  • Loading branch information
nullstyle authored Dec 7, 2016
2 parents d8b0f52 + 002d4f9 commit 06e2f5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 3 additions & 2 deletions clients/stellartoml/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func (c *Client) GetStellarToml(domain string) (resp *Response, err error) {
limitReader := io.LimitReader(hresp.Body, StellarTomlMaxSize)
_, err = toml.DecodeReader(limitReader, &resp)

// There is one corner case not handled here: response is exactly StellarTomlMaxSize long and is incorrect toml.
// Check discussion: https://github.com/stellar/go/pull/24#discussion_r89909696
// There is one corner case not handled here: response is exactly
// StellarTomlMaxSize long and is incorrect toml. Check discussion:
// https://github.com/stellar/go/pull/24#discussion_r89909696
if err != nil && limitReader.(*io.LimitedReader).N == 0 {
err = errors.Errorf("stellar.toml response exceeds %d bytes limit", StellarTomlMaxSize)
return
Expand Down
12 changes: 3 additions & 9 deletions clients/stellartoml/main_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package stellartoml

import (
"fmt"
"log"
)
import "log"

// ExampleGetTOML gets the stellar.toml file for stellar.org
// ExampleGetTOML gets the stellar.toml file for coins.asia
func ExampleGetTOML() {
resp, err := DefaultClient.GetStellarToml("stellar.org")
_, err := DefaultClient.GetStellarToml("coins.asia")
if err != nil {
log.Fatal(err)
}

fmt.Printf("Signing key: %s\n", resp.SigningKey)
// Output: Signing key: GDZ2LHRX35XR7PEVVWYRMFP7OMRL7W2X5JGLDUWS6YBRIXPYU553TADF
}

0 comments on commit 06e2f5a

Please sign in to comment.