-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] refs #279 - Add initial test for NewGenericOutput
Pending: - Find how to register skycoin coins without import the skycoin package, import it produces cyclic imports
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/fibercrypto/fibercryptowallet/src/coin/mocks" | ||
) | ||
|
||
func TestNewGenericOutput(t *testing.T) { | ||
addr := &mocks.Address{} | ||
|
||
output := NewGenericOutput(addr, "id") | ||
require.Equal(t, GenericOutput{Address: addr, id: "id", Balance: make(map[string]uint64)}, output) | ||
|
||
output.SetCoins("some_coin", uint64(20)) | ||
some_coin, err := output.GetCoins("some_coin") | ||
require.Equal(t, uint64(20), some_coin) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, addr, output.GetAddress()) | ||
require.Equal(t, "id", output.GetId()) | ||
require.False(t, output.IsSpent()) | ||
|
||
assets := output.SupportedAssets() | ||
require.Equal(t, 1, len(assets)) | ||
find := false | ||
for _, asset := range assets { | ||
if asset == "some_coin" { | ||
find = true | ||
break | ||
} | ||
} | ||
require.True(t, find) | ||
|
||
//TODO: Find how to test PushCoin. There are problems registering coins | ||
|
||
} |