-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb36a7
commit 34c9ba8
Showing
39 changed files
with
1,358 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
module github.com/xyield/xumm-go-client | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/gorilla/websocket v1.4.2 | ||
github.com/json-iterator/go v1.1.12 | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/stretchr/testify v1.7.0 | ||
github.com/ugorji/go/codec v1.2.7 | ||
github.com/xyield/xumm-user-device v0.0.0-20220315190815-aed3ae39e4ab | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= |
Submodule xumm-go-client
added at
96aadd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package meta | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/xyield/xumm-go-client/xumm" | ||
statictestdata "github.com/xyield/xumm-go-client/xumm/meta/static-test-data" | ||
) | ||
|
||
func TestGetAccountMetaIntegrationTest(t *testing.T) { | ||
|
||
cfg, err := xumm.NewConfig() | ||
assert.NoError(t, err) | ||
m := &Meta{ | ||
Cfg: cfg, | ||
} | ||
|
||
am, err := m.GetAccountMeta(statictestdata.AccountMetaTestResult.Account) | ||
|
||
assert.NoError(t, err) | ||
assert.NotEmpty(t, am) | ||
assert.Equal(t, statictestdata.AccountMetaTestResult, am) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package meta | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
testutils "github.com/xyield/xumm-go-client/utils/test-utils" | ||
"github.com/xyield/xumm-go-client/xumm" | ||
statictestdata "github.com/xyield/xumm-go-client/xumm/meta/static-test-data" | ||
"github.com/xyield/xumm-go-client/xumm/models" | ||
) | ||
|
||
func TestGetAccountMeta(t *testing.T) { | ||
|
||
jsonResponse := `{ | ||
"account": "rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ", | ||
"kycApproved": true, | ||
"xummPro": true, | ||
"blocked": false, | ||
"force_dtag": false, | ||
"avatar": "https://xumm.app/avatar/rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ.png", | ||
"xummProfile": { | ||
"accountAlias": "XRPL Labs - Wietse Wind", | ||
"ownerAlias": "Wietse Wind", | ||
"slug": "wietsewind", | ||
"profileUrl": "https://xumm.me/wietsewind", | ||
"accountSlug": null, | ||
"payString": "wietsewind$xumm.me" | ||
}, | ||
"thirdPartyProfiles": [ | ||
{ | ||
"accountAlias": "Wietse Wind", | ||
"source": "xumm.app" | ||
}, | ||
{ | ||
"accountAlias": "wietse.com", | ||
"source": "xrpl" | ||
}, | ||
{ | ||
"accountAlias": "XRPL-Labs", | ||
"source": "bithomp.com" | ||
} | ||
], | ||
"globalid": { | ||
"linked": "2021-06-29T10:22:25.000Z", | ||
"profileUrl": "https://app.global.id/u/wietse", | ||
"sufficientTrust": true | ||
} | ||
}` | ||
|
||
tests := []struct { | ||
testName string | ||
inputValue string | ||
expectedOutput *models.AccountMetaResponse | ||
expectedError error | ||
httpStatusCode int | ||
}{ | ||
{testName: "correctData", inputValue: jsonResponse, expectedOutput: statictestdata.AccountMetaTestResult, expectedError: nil, httpStatusCode: 200}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|
||
t.Run(tt.testName, func(t *testing.T) { | ||
m := &testutils.MockClient{} | ||
m.DoFunc = testutils.MockResponse(tt.inputValue, tt.httpStatusCode, m) | ||
cfg, err := xumm.NewConfig(xumm.WithHttpClient(m), xumm.WithAuth("testApiKey", "testApiSecret")) | ||
assert.NoError(t, err) | ||
meta := &Meta{ | ||
Cfg: cfg, | ||
} | ||
ca, err := meta.GetAccountMeta(statictestdata.AccountMetaTestResult.Account) | ||
|
||
if tt.expectedError != nil { | ||
assert.Nil(t, ca) | ||
assert.Error(t, err) | ||
assert.EqualError(t, err, tt.expectedError.Error()) | ||
} else { | ||
assert.Equal(t, http.Header{ | ||
"X-API-Key": {"testApiKey"}, | ||
"X-API-Secret": {"testApiSecret"}, | ||
"Content-Type": {"application/json"}, | ||
}, m.Spy.Header) | ||
assert.NoError(t, err) | ||
assert.Equal(t, tt.expectedOutput, ca) | ||
} | ||
}) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package meta | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/xyield/xumm-go-client/xumm" | ||
"github.com/xyield/xumm-go-client/xumm/models" | ||
) | ||
|
||
func TestGetHookHashIntegrationTest(t *testing.T) { | ||
|
||
cfg, err := xumm.NewConfig() | ||
assert.NoError(t, err) | ||
m := &Meta{ | ||
Cfg: cfg, | ||
} | ||
|
||
hookHash := "31C3EC186C367DA66DFBD0E576D6170A2C1AB846BFC35FC0B49D202F2A8CDFD8" | ||
|
||
hh, err := m.GetHookHash(hookHash) | ||
|
||
assert.NoError(t, err) | ||
assert.IsType(t, &models.HookHashResponse{}, hh) | ||
assert.NotEmpty(t, hh.Name) | ||
assert.NotEmpty(t, hh.Description) | ||
} |
Oops, something went wrong.