Skip to content

Commit

Permalink
add unit tests for sky-wallet derivationType ref #255
Browse files Browse the repository at this point in the history
  • Loading branch information
stdevAlDen committed Feb 26, 2020
1 parent 3540a16 commit bd54f4e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/contrib/hardware-wallet/skywallet/sky-wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/fibercrypto/fibercryptowallet/src/coin/mocks"
"github.com/fibercrypto/fibercryptowallet/src/core"
fce "github.com/fibercrypto/fibercryptowallet/src/errors"
skyWallet "github.com/fibercrypto/skywallet-go/src/skywallet"
messages "github.com/fibercrypto/skywallet-protob/go"
"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -145,4 +146,42 @@ func TestGetFeaturesShouldHandleInvalidMsgResponse(t *testing.T) {

// Then
require.Error(t, err)
}

func TestVerifyDerivationTypeBip44(t *testing.T) {
// Giving
addr := &mocks.Address{}
addr.On("IsBip32").Return(true)
output := &mocks.TransactionOutput{}
output.On("GetAddress").Return(addr)
input := &mocks.TransactionInput{}
input.On("GetSpentOutput").Return(output)
inputs := []core.TransactionInput{input}
txn := &mocks.Transaction{}
txn.On("GetInputs").Return(inputs)

// When
dt := derivationType(txn)

// Then
require.Equal(t, dt, skyWallet.WalletTypeBip44)
}

func TestVerifyDerivationTypeDeterministic(t *testing.T) {
// Giving
addr := &mocks.Address{}
addr.On("IsBip32").Return(false)
output := &mocks.TransactionOutput{}
output.On("GetAddress").Return(addr)
input := &mocks.TransactionInput{}
input.On("GetSpentOutput").Return(output)
inputs := []core.TransactionInput{input}
txn := &mocks.Transaction{}
txn.On("GetInputs").Return(inputs)

// When
dt := derivationType(txn)

// Then
require.Equal(t, dt, skyWallet.WalletTypeDeterministic)
}

0 comments on commit bd54f4e

Please sign in to comment.