upgrade lbrynet to support 0.32.*

This commit is contained in:
Niko Storni 2019-02-22 15:54:52 +01:00
parent d33ac919d1
commit 38d493fdd1
No known key found for this signature in database
GPG key ID: F37FE63398800368
5 changed files with 30 additions and 47 deletions

View file

@ -191,9 +191,6 @@ type Metadata struct {
Thumbnail *string `json:"thumbnail,omitempty"` Thumbnail *string `json:"thumbnail,omitempty"`
Preview *string `json:"preview,omitempty"` Preview *string `json:"preview,omitempty"`
NSFW bool `json:"nsfw"` NSFW bool `json:"nsfw"`
Sources *struct {
LBRYSDHash string `json:"lbry_sd_hash"`
} `json:"sources,omitempty"`
} }
type PublishOptions struct { type PublishOptions struct {
*Metadata `json:"metadata"` *Metadata `json:"metadata"`
@ -297,15 +294,10 @@ func (d *Client) Version() (*VersionResponse, error) {
return response, d.call(response, "version", map[string]interface{}{}) return response, d.call(response, "version", map[string]interface{}{})
} }
func (d *Client) Commands() (*CommandsResponse, error) {
response := new(CommandsResponse)
return response, d.call(response, "commands", map[string]interface{}{})
}
func (d *Client) Resolve(uri string) (*ResolveResponse, error) { func (d *Client) Resolve(uri string) (*ResolveResponse, error) {
response := new(ResolveResponse) response := new(ResolveResponse)
return response, d.call(response, "resolve", map[string]interface{}{ return response, d.call(response, "resolve", map[string]interface{}{
"uri": uri, "urls": uri,
}) })
} }

View file

@ -30,28 +30,6 @@ func TestClient_AccountBalance(t *testing.T) {
log.Infof("%s", *got) log.Infof("%s", *got)
} }
func TestClient_AccountFund(t *testing.T) {
d := NewClient("")
accounts, err := d.AccountList()
if err != nil {
t.Error(err)
}
account := (accounts.LBCRegtest)[0].ID
balanceString, err := d.AccountBalance(&account)
if err != nil {
t.Error(err)
}
balance, err := strconv.ParseFloat(string(*balanceString), 64)
if err != nil {
t.Error(err)
}
got, err := d.AccountFund(account, account, fmt.Sprintf("%f", balance-0.1), 40)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_AddressUnused(t *testing.T) { func TestClient_AddressUnused(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.AddressUnused(nil) got, err := d.AddressUnused(nil)
@ -63,7 +41,7 @@ func TestClient_AddressUnused(t *testing.T) {
func TestClient_ChannelList(t *testing.T) { func TestClient_ChannelList(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.ChannelList(nil, 0, 50) got, err := d.ChannelList(nil, 1, 50)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
@ -77,7 +55,7 @@ func TestClient_Publish(t *testing.T) {
t.Error(err) t.Error(err)
} }
address := string(*addressResponse) address := string(*addressResponse)
got, err := d.Publish("test", "/home/niko/test.txt", 14.37, PublishOptions{ got, err := d.Publish("test", "/home/niko/work/allClaims.txt", 14.37, PublishOptions{
Metadata: &Metadata{ Metadata: &Metadata{
Fee: &Fee{ Fee: &Fee{
Currency: "LBC", Currency: "LBC",
@ -93,10 +71,9 @@ func TestClient_Publish(t *testing.T) {
Thumbnail: util.PtrToString("https://scrn.storni.info/2019-01-18_16-37-39-098537783.png"), Thumbnail: util.PtrToString("https://scrn.storni.info/2019-01-18_16-37-39-098537783.png"),
Preview: nil, Preview: nil,
NSFW: false, NSFW: false,
Sources: nil,
}, },
ChannelName: nil, ChannelName: nil,
ChannelID: util.PtrToString("0a32af305113435d1cdf4ec61452b9a6dcb74da8"), ChannelID: util.PtrToString("bda0520bff61e4a70c966d7298e6b89107cf8bed"),
ChannelAccountID: nil, ChannelAccountID: nil,
AccountID: nil, AccountID: nil,
ClaimAddress: &address, ClaimAddress: &address,
@ -187,15 +164,6 @@ func TestClient_Version(t *testing.T) {
log.Infof("%+v", *got) log.Infof("%+v", *got)
} }
func TestClient_Commands(t *testing.T) {
d := NewClient("")
got, err := d.Commands()
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}
func TestClient_Resolve(t *testing.T) { func TestClient_Resolve(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.Resolve("test") got, err := d.Resolve("test")
@ -211,7 +179,7 @@ func TestClient_Resolve(t *testing.T) {
func TestClient_NumClaimsInChannel(t *testing.T) { func TestClient_NumClaimsInChannel(t *testing.T) {
d := NewClient("") d := NewClient("")
got, err := d.NumClaimsInChannel("@Test#0a32af305113435d1cdf4ec61452b9a6dcb74da8") got, err := d.NumClaimsInChannel("@Test#bda0520bff61e4a70c966d7298e6b89107cf8bed")
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
@ -226,3 +194,25 @@ func TestClient_ClaimShow(t *testing.T) {
} }
log.Infof("%+v", *got) log.Infof("%+v", *got)
} }
func TestClient_AccountFund(t *testing.T) {
d := NewClient("")
accounts, err := d.AccountList()
if err != nil {
t.Error(err)
}
account := (accounts.LBCRegtest)[0].ID
balanceString, err := d.AccountBalance(&account)
if err != nil {
t.Error(err)
}
balance, err := strconv.ParseFloat(string(*balanceString), 64)
if err != nil {
t.Error(err)
}
got, err := d.AccountFund(account, account, fmt.Sprintf("%f", balance-0.1), 40)
if err != nil {
t.Error(err)
}
log.Infof("%+v", *got)
}

View file

@ -419,8 +419,6 @@ type VersionResponse struct {
PythonVersion string `json:"python_version"` PythonVersion string `json:"python_version"`
} }
type CommandsResponse []string
type ResolveResponse map[string]ResolveResponseItem type ResolveResponse map[string]ResolveResponseItem
type ResolveResponseItem struct { type ResolveResponseItem struct {
Certificate *Claim `json:"certificate,omitempty"` Certificate *Claim `json:"certificate,omitempty"`

1
go.mod
View file

@ -8,6 +8,7 @@ require (
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/davecgh/go-spew v1.1.0 github.com/davecgh/go-spew v1.1.0
github.com/fatih/structs v1.1.0
github.com/go-errors/errors v1.0.1 github.com/go-errors/errors v1.0.1
github.com/go-ini/ini v1.38.2 github.com/go-ini/ini v1.38.2
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect github.com/go-ozzo/ozzo-validation v3.5.0+incompatible // indirect

2
go.sum
View file

@ -14,6 +14,8 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=