add more unit tests, add integration tests (#53)

This commit is contained in:
noot
2021-12-01 23:54:39 -05:00
committed by GitHub
parent 7fc25772e8
commit 0c41b794e7
22 changed files with 688 additions and 120 deletions

View File

@@ -9,7 +9,7 @@ import (
type Client interface {
GetAccounts() (*getAccountsResponse, error)
GetAddress(idx uint) (*getAddressResponse, error)
GetBalance(idx uint) (*getBalanceResponse, error)
GetBalance(idx uint) (*GetBalanceResponse, error)
Transfer(to Address, accountIdx, amount uint) (*TransferResponse, error)
GenerateFromKeys(kp *PrivateKeyPair, filename, password string, env common.Environment) error
GenerateViewOnlyWalletFromKeys(vk *PrivateViewKey, address Address, filename, password string) error
@@ -33,7 +33,7 @@ func (c *client) GetAccounts() (*getAccountsResponse, error) {
return c.callGetAccounts()
}
func (c *client) GetBalance(idx uint) (*getBalanceResponse, error) {
func (c *client) GetBalance(idx uint) (*GetBalanceResponse, error) {
return c.callGetBalance(idx)
}

View File

@@ -78,10 +78,6 @@ type transferRequest struct {
Destinations []Destination `json:"destinations"`
AccountIndex uint // optional
Priority uint `json:"priority"`
// Mixin uint `json:"mixin"`
// RingSize uint `json:"ring_size"`
// UnlockTime uint `json:"unlock_time"`
// GetTxKey bool
}
type TransferResponse struct {
@@ -104,7 +100,6 @@ func (c *client) callTransfer(destinations []Destination, accountIdx uint) (*Tra
Destinations: destinations,
AccountIndex: accountIdx,
Priority: 0,
//RingSize: 11,
}
params, err := json.Marshal(req)
@@ -133,14 +128,14 @@ type getBalanceRequest struct {
AccountIndex uint `json:"account_index"`
}
type getBalanceResponse struct {
type GetBalanceResponse struct {
Balance float64 `json:"balance"`
BlocksToUnlock uint `json:"blocks_to_unlock"`
UnlockedBalance float64 `json:"unlocked_balance"`
PerSubaddress []map[string]interface{} `json:"per_subaddress"`
}
func (c *client) callGetBalance(idx uint) (*getBalanceResponse, error) {
func (c *client) callGetBalance(idx uint) (*GetBalanceResponse, error) {
const method = "get_balance"
req := &getBalanceRequest{
@@ -161,7 +156,7 @@ func (c *client) callGetBalance(idx uint) (*getBalanceResponse, error) {
return nil, resp.Error
}
var res *getBalanceResponse
var res *GetBalanceResponse
if err = json.Unmarshal(resp.Result, &res); err != nil {
return nil, err
}