Skip to content

Commit

Permalink
Add TestGetSignerUIDShouldBeOk ref fibercrypto#139
Browse files Browse the repository at this point in the history
  • Loading branch information
stdevAlDen committed Oct 14, 2019
1 parent 9aebbca commit cff2f3a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ clean: ## Clean project FiberCrypto Wallet.
find . -path "*moc_*" -delete
@echo "Done."

test: ## Run project test suite
test: mocks ## Run project test suite
go test github.com/fibercrypto/FiberCryptoWallet/src/coin/skycoin
go test github.com/fibercrypto/FiberCryptoWallet/src/hardware

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
34 changes: 34 additions & 0 deletions src/hardware/sky-wallet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package hardware

import (
"github.com/fibercrypto/FiberCryptoWallet/src/core"
"github.com/fibercrypto/FiberCryptoWallet/src/hardware/mocks"
"github.com/micro/protobuf/proto"
"github.com/skycoin/hardware-wallet-go/src/skywallet/wire"
"github.com/skycoin/hardware-wallet-protob/go"
"github.com/stretchrcom/testify/require"
"testing"
)

func TestGetSignerUIDShouldBeOk(t *testing.T) {
// Giving
dev := mocks.Devicer{}
expectedDevId := "c24a046d-7d7b-484d-baf6-abedd883023f"
f := messages.Features{
DeviceId: proto.String(expectedDevId),
}
fb, err := proto.Marshal(&f)
require.Nil(t, err)
msg := wire.Message{
Kind: uint16(messages.MessageType_MessageType_Features),
Data: fb,
}
dev.On("GetFeatures").Return(msg, nil)
sw := NewSkyWallet(&dev)

// When
devId := sw.GetSignerUID()

// Then
require.Equal(t, core.UID(expectedDevId), devId)
}

0 comments on commit cff2f3a

Please sign in to comment.