Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added determinisic builds test tool #26

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ linters-settings:
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default
goimports:
local-prefixes: github.com/SkycoinProject/hardware-wallet-go
local-prefixes: github.com/skycoin/hardware-wallet-go


linters:
Expand Down
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ before_install:
- source ./ci-scripts/install-$TRAVIS_OS_NAME.sh

install:
- if [[ ! -d $GOPATH/src/github.com/SkycoinProject/hardware-wallet-go ]]; then mkdir -p $GOPATH/src/github.com/skycoin; ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/SkycoinProject/hardware-wallet-go; fi
- go get github.com/vektra/mockery/.../
- cd $GOPATH/src/github.com/SkycoinProject/hardware-wallet-go
- if [[ ! -d $GOPATH/src/github.com/skycoin/hardware-wallet-go ]]; then mkdir -p $GOPATH/src/github.com/skycoin; ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/skycoin/hardware-wallet-go; fi
- go get github.com/vektra/mockery/v2/.../
- cd $GOPATH/src/github.com/skycoin/hardware-wallet-go
- make mocks
- make install-linters
- make lint
Expand All @@ -31,7 +31,7 @@ before_script:
fi
# Install hardware wallet for running tests against emulator
- mkdir -p tmp/hardware-wallet
- git clone --depth=1 --single-branch --branch develop https://github.com/SkycoinProject/hardware-wallet.git tmp/hardware-wallet
- git clone --depth=1 --single-branch --branch develop https://github.com/skycoin/hardware-wallet.git tmp/hardware-wallet
- git -C tmp/hardware-wallet submodule update --init
# Install OS-specific test and build dependencies for hardware-wallet
- ( cd ./tmp/hardware-wallet && sh "ci-scripts/install-${TRAVIS_OS_NAME}.sh" )
Expand Down Expand Up @@ -88,6 +88,5 @@ deploy:
skip_cleanup: true
draft: true
on:
repo: SkycoinProject/hardware-wallet-go
repo: skycoin/hardware-wallet-go
tags: true

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@


[[constraint]]
name = "github.com/SkycoinProject/skycoin"
name = "github.com/skycoin/skycoin"
branch = "develop"

[[constraint]]
name = "github.com/SkycoinProject/hardware-wallet-protob"
name = "github.com/skycoin/hardware-wallet-protob"
branch = "develop"

[[constraint]]
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ dep: ## Ensure package dependencies are up to date

mocks: ## Create all mock files for unit tests
echo "Generating mock files"
mockery -name Devicer -dir ./src/skywallet -case underscore -inpkg -testonly
mockery -name DeviceDriver -dir ./src/skywallet -case underscore -inpkg -testonly
mockery --name Devicer --dir ./src/skywallet --case underscore --inpackage
mockery --name DeviceDriver --dir ./src/skywallet --case underscore --inpackage

test-unit: ## Run unit tests
go test -v github.com/SkycoinProject/hardware-wallet-go/src/skywallet
go test -v github.com/skycoin/hardware-wallet-go/src/skywallet

test-integration-emulator: ## Run emulator integration tests
./ci-scripts/integration-test.sh -a -m EMULATOR -n emulator-integration
Expand All @@ -50,8 +50,8 @@ lint: ## Run linters. Use make install-linters first.
golangci-lint run -c .golangci.yml ./...

format: ## Formats the code. Must have goimports installed (use make install-linters).
goimports -w -local github.com/SkycoinProject/hardware-wallet-go ./cmd
goimports -w -local github.com/SkycoinProject/hardware-wallet-go ./src
goimports -w -local github.com/skycoin/hardware-wallet-go ./cmd
goimports -w -local github.com/skycoin/hardware-wallet-go ./src

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down
43 changes: 41 additions & 2 deletions cmd/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ OPTIONS:
--addressN value Number of addresses to generate (default: 1)
--startIndex value Start to generate deterministic addresses from startIndex (default: 0)
--confirmAddress If requesting one address it will be sent only if user confirms operation by pressing device's button.
--coinType Coin Type, which will be used on hardware-wallet. Supported values: SKY, BTC (default: SKY))
--coinType Coin Type, which will be used on hardware-wallet. Supported values: SKY, BTC (default: SKY))
```

#### Examples
Expand Down Expand Up @@ -542,7 +542,7 @@ OPTIONS:
--coin value Amount of coins
--hour value Number of hours
--addressIndex value If the address is a return address tell its index in the wallet
--coinType Coin Type, which will be used on hardware-wallet. Supported values: SKY, BTC (default: SKY))
--coinType Coin Type, which will be used on hardware-wallet. Supported values: SKY, BTC (default: SKY))
```

```bash
Expand Down Expand Up @@ -614,3 +614,42 @@ INFO [skycoin-hw-cli]: Getting mixed entropy from device
</details>

A real example about how to use this feature can be checked at the [TRNG validation](https://github.com/SkycoinProject/hardware-wallet/tree/8edc2a28027875f464b68348c44fb188efb4dfbb#validate-the-trng) (please get noticed that the firmware should be build with this feature enabled trough `ENABLE_GETENTROPY`). The tool is use specifically [from here](https://github.com/SkycoinProject/hardware-wallet/blob/8edc2a28027875f464b68348c44fb188efb4dfbb/trng-test/Makefile#L7-L8).


## For developers purpose only
### deterministicBuild

Test for deterministic builds of address

```
OPTIONS:
--file_name string Name of file to store results (JSON only!!!!!!)
--mnemonic string Mnemonic for HW
--file_action string Two actions allowed - APPEND or OVERWRITE
--coinType value SKY only
--deviceType value EMULATOR only
```
#### Examples

```bash
$ skycoin-hw-cli deterministicBuild --file_name="test.json" --mnemonic="wire junk original sword bread bottom armor dog snow accident inform rigid" --file_action="OVERWRITE" --coinType=SKY --deviceType=EMULATOR
```

If you want automate testing deterministic builds, you can write simple Python or bash script

```python
import os

#set mnemonic and file to store results (should be JSON only)
mnemonics = ["wire junk original sword bread bottom armor dog snow accident inform rigid",
"all all all all all all all all all all all all"]

filename = "test.json"

#set env variable for button auto press
os.environ["AUTO_PRESS_BUTTONS"] = "1"

for mnemonic in mnemonics:
#run command in terminal using Python
os.system('skycoin-hw-cli deterministicBuild --file_name="{0}" --mnemonic="{1}" --file_action="{2}" --coinType=SKY --deviceType=EMULATOR'.format(filename, mnemonic, "APPEND"))
```
4 changes: 2 additions & 2 deletions src/cli/address_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"os"
"runtime"

messages "github.com/SkycoinProject/hardware-wallet-protob/go"
messages "github.com/skycoin/hardware-wallet-protob/go"

gcli "github.com/urfave/cli"

skyWallet "github.com/SkycoinProject/hardware-wallet-go/src/skywallet"
skyWallet "github.com/skycoin/hardware-wallet-go/src/skywallet"
)

func addressGenCmd() gcli.Command {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/apply_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

gcli "github.com/urfave/cli"

messages "github.com/SkycoinProject/hardware-wallet-protob/go"
messages "github.com/skycoin/hardware-wallet-protob/go"

skyWallet "github.com/SkycoinProject/hardware-wallet-go/src/skywallet"
skyWallet "github.com/skycoin/hardware-wallet-go/src/skywallet"
)

func applySettingsCmd() gcli.Command {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

gcli "github.com/urfave/cli"

messages "github.com/SkycoinProject/hardware-wallet-protob/go"
messages "github.com/skycoin/hardware-wallet-protob/go"

skyWallet "github.com/SkycoinProject/hardware-wallet-go/src/skywallet"
skyWallet "github.com/skycoin/hardware-wallet-go/src/skywallet"
)

func backupCmd() gcli.Command {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

gcli "github.com/urfave/cli"

skyWallet "github.com/SkycoinProject/hardware-wallet-go/src/skywallet"
skyWallet "github.com/skycoin/hardware-wallet-go/src/skywallet"
)

func cancelCmd() gcli.Command {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/check_message_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

gcli "github.com/urfave/cli"

skyWallet "github.com/SkycoinProject/hardware-wallet-go/src/skywallet"
skyWallet "github.com/skycoin/hardware-wallet-go/src/skywallet"
)

func checkMessageSignatureCmd() gcli.Command {
Expand Down
3 changes: 2 additions & 1 deletion src/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cli
import (
"fmt"

"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/skycoin/skycoin/src/util/logging"
gcli "github.com/urfave/cli"
)

Expand Down Expand Up @@ -98,6 +98,7 @@ func NewApp() (*App, error) {
getRawEntropyCmd(),
getMixedEntropyCmd(),
getUsbDetails(),
deterministicBuildCmd(),
}

app.Name = "skycoin-hw-cli"
Expand Down
Loading