forked from bpancost/sila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sila_test.go
79 lines (69 loc) · 2.56 KB
/
sila_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package sila_test
import (
"time"
. "github.com/smartystreets/goconvey/convey"
"github.com/spf13/viper"
"github.com/kappapay/silaclient"
"github.com/kappapay/silaclient/domain"
)
type TestConfigData struct {
AuthPrivateKeyKex string
AuthHandle string
UserHandle string
UserWalletPrivateKeyHex string
}
func readTestConfig() (TestConfigData, error) {
testConfigData := TestConfigData{}
config := viper.New()
config.SetConfigName("test_config")
config.SetConfigType("yaml")
config.AddConfigPath(".")
err := config.ReadInConfig()
if err != nil {
return testConfigData, err
}
testConfigData.AuthPrivateKeyKex = config.GetString("auth.private_key_hex")
testConfigData.AuthHandle = config.GetString("auth.handle")
testConfigData.UserHandle = config.GetString("user.handle")
testConfigData.UserWalletPrivateKeyHex = config.GetString("user.wallet_private_key_hex")
return testConfigData, nil
}
func ensureIntegrationUserExistsWithLinkedAccount(silaClient sila.Client, userHandle string, userWalletAddress string, userWalletPrivateKey string) {
ensureIntegrationUserExists(silaClient, userHandle, userWalletAddress, userWalletPrivateKey)
response, err := silaClient.LinkAccount(userHandle).
SetAccountName("default").
SetAccountType("CHECKING").
SetDirectLinkAccount("123456789012", "123456789").
Do(userWalletPrivateKey)
So(err, ShouldBeNil)
So(response.Success, ShouldBeTrue)
}
func ensureIntegrationUserExists(silaClient sila.Client, userHandle string, userWalletAddress string, userWalletPrivateKey string) {
response, err := silaClient.CheckHandle(userHandle).Do()
So(err, ShouldBeNil)
if response.Success == true {
registerResponse, err := silaClient.Register(userHandle).
SetIndividualEntity("Alberta", "Bobbeth", "1950-10-31").
SetAddress(domain.RegistrationAddress{
AddressAlias: "Home",
StreetAddress1: "1234 Fake St.",
City: "Los Angeles",
State: "CA",
Country: "US",
PostalCode: "90001",
}).
SetIdentity(domain.Ssn, "181-91-1478").
SetContact("Home", "123-456-7890", "[email protected]").
SetCrypto("Main Address", userWalletAddress).
Do()
So(err, ShouldBeNil)
So(registerResponse.Success, ShouldBeTrue)
requestKycResponse, err := silaClient.RequestKyc(userHandle).Do(userWalletPrivateKey)
So(err, ShouldBeNil)
So(requestKycResponse.Success, ShouldBeTrue)
time.Sleep(30 * time.Second)
checkKycResponse, err := silaClient.CheckKyc(userHandle).Do(userWalletPrivateKey)
So(err, ShouldBeNil)
So(checkKycResponse.Success, ShouldBeTrue)
}
}