Skip to content

Commit

Permalink
[test] refs fibercrypto#136 - Add tests for wallet.go
Browse files Browse the repository at this point in the history
Tests:
- RemoteWallet::Encrypt,
- RemoteWallet:Decrypt
- RemoteWallet::SetLabel
  • Loading branch information
AntiD2ta committed Nov 16, 2019
1 parent 109354c commit 8070801
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/coin/skycoin/models/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ func TestSkycoinRemoteWalletCreateWallet(t *testing.T) {
require.Equal(t, "FiberCrypto", wlt2.GetId())
}

func TestSkycoinRemoteWalletEncrypt(t *testing.T) {
CleanGlobalMock()
global_mock.On("EncryptWallet", "wallet", "pwd").Return(&api.WalletResponse{}, nil)

wltSrv := &SkycoinRemoteWallet{poolSection: PoolSection}
pwdReader := func(message string) (string, error) {
return "pwd", nil
}

wltSrv.Encrypt("wallet", pwdReader)
}

func TestSkycoinRemoteWalletDecrypt(t *testing.T) {
CleanGlobalMock()
global_mock.On("DecryptWallet", "wallet", "pwd").Return(&api.WalletResponse{}, nil)

wltSrv := &SkycoinRemoteWallet{poolSection: PoolSection}
pwdReader := func(message string) (string, error) {
return "pwd", nil
}

wltSrv.Decrypt("wallet", pwdReader)
}

func TestSkycoinRemoteWalletIsEncrypted(t *testing.T) {

global_mock.On("Wallet", "encrypted").Return(
Expand Down Expand Up @@ -220,6 +244,18 @@ func TestRemoteWalletSignSkycoinTxn(t *testing.T) {
require.Equal(t, uint64(100), value)
}

func TestRemoteWalletSetLabel(t *testing.T) {
CleanGlobalMock()
global_mock.On("UpdateWallet", "walletId", "wallet").Return(nil)

wlt := &RemoteWallet{
Id: "walletId",
poolSection: PoolSection,
}

wlt.SetLabel("wallet")
}

type TransferOptions struct {
values map[string]interface{}
}
Expand Down

0 comments on commit 8070801

Please sign in to comment.