-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8c8e72
commit 90e8ccc
Showing
5 changed files
with
124 additions
and
25 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
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
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
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
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,43 @@ | ||
package blockchain | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewWallet(t *testing.T) { | ||
w := NewWallet() | ||
assert.Equal(t, w.GetEffectiveBalance(), uint64(0)) | ||
assert.Equal(t, len(w.PendingTxns), 0) | ||
} | ||
|
||
func TestSetAllPending(t *testing.T) { | ||
w := NewWallet() | ||
txn := NewTestTransaction() | ||
|
||
// Set the balance approprately to handle the txn. | ||
w.SetBalance(txn.GetTotalOutput()) | ||
|
||
// Set and check. | ||
w.SetAllPending([]*Transaction{txn}) | ||
result, i := w.IsPending(txn) | ||
|
||
// Make sure transaction is actually pending. | ||
assert.True(t, result) | ||
assert.Equal(t, i, 0) | ||
} | ||
|
||
func TestDropAllPending(t *testing.T) { | ||
w := NewWallet() | ||
txn := NewTestTransaction() | ||
w.SetBalance(txn.GetTotalOutput()) | ||
w.SetAllPending([]*Transaction{txn}) | ||
|
||
// Drop all pending | ||
result, _ := w.IsPending(txn) | ||
assert.True(t, result) | ||
w.DropAllPending([]*Transaction{txn}) | ||
result, _ = w.IsPending(txn) | ||
assert.False(t, result) | ||
} |