Skip to content

Commit

Permalink
Merge pull request #265 from simelo/stdevHsequeda_t152_AddressBook
Browse files Browse the repository at this point in the history
Address book
  • Loading branch information
stdevMac committed Dec 21, 2019
2 parents c60a2be + 5e74b1b commit 86f2d7d
Show file tree
Hide file tree
Showing 31 changed files with 3,457 additions and 19 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ htmlcov/
nosetests.xml
coverage.xml
coverage.html
coverage.out
*.cover
.hypothesis/

Expand Down Expand Up @@ -85,4 +84,3 @@ android
rcc_cgo_*.go
darwin


8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ LICENSE := GPLv3
COPYRIGHT := Copyright © 2019 $(ORG_NAME)

UNAME_S = $(shell uname -s)
OSNAME = $(shell echo $(UNAME_S) | tr A-Z a-z)
DEFAULT_TARGET ?= desktop
DEFAULT_ARCH ?= linux
## In future use as a parameter tu make command.
Expand Down Expand Up @@ -232,6 +231,7 @@ clean: clean-test clean-build ## Remove temporary files

gen-mocks: ## Generate mocks for interface types
mockery -all -output src/coin/mocks -outpkg mocks -dir src/core
find src/coin/mocks/ -name '*.go' -type f -print0 | xargs -0 -I PATH sed -i '' -e 's/fibercryptowallet/fibercryptowallet/g' PATH

test-sky: ## Run Skycoin plugin test suite
go test -cover -timeout 30s github.com/fibercrypto/fibercryptowallet/src/coin/skycoin
Expand All @@ -240,6 +240,10 @@ test-sky: ## Run Skycoin plugin test suite
test-core: ## Run tests for API core and helpers
go test -cover -timeout 30s github.com/fibercrypto/fibercryptowallet/src/util

test-data: ## Run tests for data package
go test -cover -timeout 30s github.com/fibercrypto/fibercryptowallet/src/data


test-sky-launch-html-cover:
go test -cover -timeout 30s github.com/fibercrypto/fibercryptowallet/src/coin/skycoin
go test -coverprofile=$(COVERAGEFILE) -timeout 30s github.com/fibercrypto/fibercryptowallet/src/coin/skycoin/models
Expand All @@ -256,7 +260,7 @@ test-cover-travis:

test-cover: clean-test test-sky-launch-html-cover ## Show more details of test coverage

test: clean-test test-core test-sky ## Run project test suite
test: clean-test test-core test-sky test-data ## Run project test suite

install-linters: ## Install linters
go get -u github.com/FiloSottile/vendorcheck
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

_ "github.com/fibercrypto/fibercryptowallet/src/coin/skycoin"
_ "github.com/fibercrypto/fibercryptowallet/src/models"
_ "github.com/fibercrypto/fibercryptowallet/src/models/addressBook"
_ "github.com/fibercrypto/fibercryptowallet/src/models/history"
_ "github.com/fibercrypto/fibercryptowallet/src/models/pending"
"github.com/therecipe/qt/core"
Expand Down
1 change: 1 addition & 0 deletions resources/images/icons/user_icon-icons.com_66546.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/coin/skycoin/models/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestSkycoinTransactionGetStatus(t *testing.T) {
}

func TestSkycoinTransactionGetInputs(t *testing.T) {
//set correct return value
// set correct return value
response := &readable.TransactionWithStatusVerbose{
Transaction: readable.TransactionVerbose{},
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestSkycoinTransactionInputGetSpentOutput(t *testing.T) {
input := &SkycoinTransactionInput{skyIn: readable.TransactionInput{Hash: "in1"}}
output := input.GetSpentOutput()

t.Logf("%#v",output)
t.Logf("%#v", output)
require.Equal(t, output.GetId(), "out1")
require.Equal(t, output.GetAddress().String(), "2JJ8pgq8EDAnrzf9xxBJapE2qkYLefW4uF8")
sky, err := output.GetCoins(Sky)
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestSkycoinUninjectedTransactionGetInputs(t *testing.T) {
hours, err := ti.GetCoins(CoinHour)
require.NoError(t, err)
require.Equal(t, hours, uint64(20))
//TODO: Find a way to get the calculatedHours for the expected value
// TODO: Find a way to get the calculatedHours for the expected value
val, err := ti.GetCoins("INVALID_TICKER")
require.Error(t, err)
require.Equal(t, uint64(0), val)
Expand Down
22 changes: 12 additions & 10 deletions src/coin/skycoin/models/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package skycoin

import (
"fmt"
"github.com/stretchr/testify/assert"
"io/ioutil"
"math"
"strconv"
Expand Down Expand Up @@ -288,7 +289,7 @@ func TestRemoteWalletTransfer(t *testing.T) {
hash := testutil.RandSHA256(t)

addr, err := NewSkycoinAddress(destinationAddress.String())
require.NoError(t, err)
assert.NoError(t, err)
opt := NewTransferOptions()
opt.SetValue("BurnFactor", "0.5")
opt.SetValue("CoinHoursSelectionType", "auto")
Expand Down Expand Up @@ -364,9 +365,9 @@ func TestRemoteWalletSendFromAddress(t *testing.T) {
},
}
fromAddr, err := NewSkycoinAddress(startAddress.String())
require.NoError(t, err)
assert.NoError(t, err)
chgAddr, err := NewSkycoinAddress(changeAddress)
require.NoError(t, err)
assert.NoError(t, err)

opt1 := NewTransferOptions()
opt1.SetValue("BurnFactor", "0.5")
Expand Down Expand Up @@ -477,7 +478,7 @@ func TestRemoteWalletSpend(t *testing.T) {
},
}
chgAddr, err := NewSkycoinAddress(changeAddress)
require.NoError(t, err)
assert.NoError(t, err)
opt := NewTransferOptions()
opt.SetValue("BurnFactor", "0.5")
opt.SetValue("CoinHoursSelectionType", "auto")
Expand Down Expand Up @@ -1003,7 +1004,7 @@ func TestLocalWalletTransfer(t *testing.T) {
wlt := makeLocalWallet(t)

addr, err := NewSkycoinAddress(destinationAddress.String())
require.NoError(t, err)
assert.NoError(t, err)
loadedAddrs, err := wlt.GetLoadedAddresses()
require.NoError(t, err)
addrs := make([]string, 0)
Expand Down Expand Up @@ -1077,9 +1078,9 @@ func TestLocalWalletSendFromAddress(t *testing.T) {
},
}
fromAddr, err := NewSkycoinAddress(startAddress.String())
require.NoError(t, err)
assert.NoError(t, err)
chgAddr, err := NewSkycoinAddress(changeAddress)
require.NoError(t, err)
assert.NoError(t, err)

opt1 := NewTransferOptions()
opt1.SetValue("BurnFactor", "0.5")
Expand Down Expand Up @@ -1169,7 +1170,7 @@ func TestLocalWalletSpend(t *testing.T) {
},
}
chgAddr, err := NewSkycoinAddress(changeAddress)
require.NoError(t, err)
assert.NoError(t, err)
opt := NewTransferOptions()
opt.SetValue("BurnFactor", "0.5")
opt.SetValue("CoinHoursSelectionType", "auto")
Expand Down Expand Up @@ -1318,7 +1319,7 @@ func TestSkycoinBlockchainSendFromAddress(t *testing.T) {
},
ChangeAddress: &changeAddrString,
To: []api.Receiver{
{
api.Receiver{
Address: destinationAddress.String(),
Coins: strconv.Itoa(sky),
},
Expand All @@ -1337,7 +1338,7 @@ func TestSkycoinBlockchainSendFromAddress(t *testing.T) {
},
ChangeAddress: &changeAddrString,
To: []api.Receiver{
{
api.Receiver{
Address: destinationAddress.String(),
Coins: strconv.Itoa(sky),
Hours: "250",
Expand Down Expand Up @@ -1444,6 +1445,7 @@ func TestSkycoinBlockchainSpend(t *testing.T) {
opt1 := NewTransferOptions()
opt1.SetValue("BurnFactor", "0.5")
opt1.SetValue("CoinHoursSelectionType", "auto")

changeAddrString := changeAddr.String()
req1 := api.CreateTransactionRequest{
UxOuts: uxOutsStr,
Expand Down
49 changes: 49 additions & 0 deletions src/core/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,52 @@ const (
// TypeNameWalletStorage WalletStorage type name
TypeNameWalletStorage = "WalletStorage"
)

// AddressBook provides method to manage a contact database.
type AddressBook interface {
Init(secType int, password string) error
Authenticate(password string) error
ChangeSecurity(NewSecType int, oldPassword, newPassword string) error
GetContact(id uint64) (Contact, error)
ListContact() ([]Contact, error)
InsertContact(contact Contact) (uint64, error)
DeleteContact(id uint64) error
UpdateContact(id uint64, contact Contact) error
GetStorage() Storage
HasInit() bool
IsOpen() bool
GetSecType() int
Close() error
}

type Storage interface {
InsertValue(value interface{}) (uint64, error)
GetValue(key uint64) (interface{}, error)
ListValues() (map[uint64]interface{}, error)
DeleteValue(key uint64) error
UpdateValue(key uint64, newValue interface{}) error
Path() string
GetConfig() map[string]string
InsertConfig(map[string]string) error
Close() error
}

// Contact provides encrypt / decrypt data.
type Contact interface {
GetID() uint64
SetID(id uint64)
Encrypt(secType int, key []byte) ([]byte, error)
Decrypt(secType int, data, key []byte) error
GetAddresses() []StringAddress
SetAddresses([]StringAddress)
GetName() string
SetName(string)
IsValid() bool
}
type StringAddress interface {
GetValue() []byte
SetValue(val []byte)
GetCoinType() []byte
SetCoinType(val []byte)
IsValid() bool
}
Loading

0 comments on commit 86f2d7d

Please sign in to comment.