Skip to content

Commit

Permalink
Merge remote-tracking branch 'fc/develop' into stdevRulo_t279_improve…
Browse files Browse the repository at this point in the history
…_coverage
  • Loading branch information
olemis committed Jan 22, 2020
2 parents ee62b8f + d9032fd commit a03f7b0
Show file tree
Hide file tree
Showing 43 changed files with 3,588 additions and 153 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ rcc_cgo_*.go
darwin


# Auto-generates go files.

*.pb.go
44 changes: 17 additions & 27 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ ignored = [
[prune]
go-tests = true
unused-packages = true

[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ICONSET := resources/images/icons/appIcon/appIcon.iconset
CONVERT := convert
SIPS := sips
ICONUTIL := iconutil
UNAME_S = $(shell uname -s)
DEFAULT_TARGET ?= desktop
DEFAULT_ARCH ?= linux

# Platform-specific switches
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -248,6 +251,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

$(COVERAGEFILE):
echo 'mode: set' > $(COVERAGEFILE)
Expand All @@ -262,9 +266,13 @@ test-core: ## Run tests for API core and helpers
go test -coverprofile=$(COVERAGETEMP) -timeout 30s github.com/fibercrypto/fibercryptowallet/src/util
cat $(COVERAGETEMP) | grep -v '^mode: set$$' >> $(COVERAGEFILE)

test-data: ## Run tests for data package
go test -coverprofile=src/data/coverage.out -timeout 30s github.com/fibercrypto/fibercryptowallet/src/data
test-html-cover:
go tool cover -html=$(COVERAGEFILE) -o $(COVERAGEPREFIX).html



test-cover-travis: clean-test
go test -covermode=count -coverprofile=$(COVERAGEFILE) -timeout 30s github.com/fibercrypto/fibercryptowallet/src/util
$(GOPATH)/bin/goveralls -coverprofile=$(COVERAGEFILE) -service=travis-ci -repotoken 1zkcSxi8TkcxpL2zTQOK9G5FFoVgWjceP
Expand All @@ -277,6 +285,7 @@ test-cover: test test-html-cover ## Show more details of test coverage

test: clean-test $(COVERAGEFILE) test-core test-sky ## Run project test suite

test: clean-test test-core test-sky test-data## Run project test suite
run-docker: DOCKER_GOPATH=$(shell docker inspect $(DOCKER_QT):$(DEFAULT_ARCH) | grep '"GOPATH=' | head -n1 | cut -d = -f2 | cut -d '"' -f1)
run-docker: install-docker-deps ## Run CMD inside Docker container
@echo "Docker container GOPATH found at $(DOCKER_GOPATH)"
Expand Down
19 changes: 6 additions & 13 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 Expand Up @@ -44,21 +45,13 @@ func main() {
// url := core.NewQUrl3("qrc:/ui/src/ui/main.qml", 0)
url := core.NewQUrl3("src/ui/main.qml", 0) // disable this to make a release

// TODO: Find a way to use a `core.Qt__QueuedConnection`, so we can remove the flag `allOk`
allOk := true
engine.ConnectObjectCreated(func(object *core.QObject, objUrl *core.QUrl) {
if object.Pointer() == nil && url.ToString(0) == objUrl.ToString(0) {
allOk = false
app.Exit(-1) // Ignored because we need a `core.Qt__QueuedConnection`
engine.ConnectSignal(engine.ConnectObjectCreated, func(object *core.QObject, objUrl *core.QUrl) {
if object.Pointer() == nil && url.ToString(0) == objUrl.ToString(0)[len(objUrl.ToString(0)) - len(url.ToString(0)):] {
app.Exit(-1)
}
})
}, core.Qt__QueuedConnection)
engine.Load(url)
splash.QWidget.Close()

// A `core.Qt__QueuedConnection` will allows us to remove the condition bellow, leaving only `app.Exec()`
if allOk == true {
app.Exec()
} else {
app.Exit(-1)
}
app.Exec()
}
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.
25 changes: 25 additions & 0 deletions src/coin/skycoin/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/user"
"path/filepath"
"strconv"
"strings"

local "github.com/fibercrypto/fibercryptowallet/src/main"
Expand Down Expand Up @@ -65,6 +66,30 @@ func getValues(prefix string) ([]string, error) {
return sectionManager.GetValues(strings.Split(prefix, "/"))
}

func GetDataRefreshTimeout() uint64 {
cm := local.GetConfigManager()
sm := cm.GetSectionManager("global")
value, err := sm.GetValue("cache", nil)
if err != nil {
return 0
}

keyValue := make(map[string]string)
err = json.Unmarshal([]byte(value), &keyValue)
if err != nil {
return 0
}
strVal, ok := keyValue["lifeTime"]
if !ok {
return 0
}
val, err := strconv.ParseUint(strVal, 10, 64)
if err != nil {
return 0
}
return val
}

func GetWalletSources() ([]*walletSource, error) {
wltsString, err := getValues(SettingPathToWalletSource)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions src/coin/skycoin/models/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/fibercrypto/fibercryptowallet/src/core"
"github.com/fibercrypto/fibercryptowallet/src/errors"
//local "github.com/fibercrypto/fibercryptowallet/src/main"
appParams "github.com/fibercrypto/fibercryptowallet/src/params"
)

// SkyFiberPlugin provide support for SkyFiber coins
Expand Down Expand Up @@ -100,7 +99,7 @@ func (p *SkyFiberPlugin) LoadTransactionAPI(netType string) (core.BlockchainTran
if netType != "MainNet" {
return nil, errors.ErrInvalidNetworkType
}
return NewSkycoinBlockchain(appParams.DataRefreshTimeout), nil
return NewSkycoinBlockchain(config.GetDataRefreshTimeout()), nil
}

// LoadSignService sign service entry point
Expand Down
47 changes: 47 additions & 0 deletions src/core/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,50 @@ 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, error)
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)
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 a03f7b0

Please sign in to comment.