lbcwallet/createtx_test.go
Guilherme Salgado ef6aa91b6a Refactor Wallet.txToPairs into smaller functions
Also add a unit test for one of them.
2014-07-31 16:52:52 -03:00

29 lines
682 B
Go

package main
import (
"reflect"
"sort"
"testing"
"github.com/conformal/btcutil"
"github.com/conformal/btcwire"
)
func Test_addOutputs(t *testing.T) {
msgtx := btcwire.NewMsgTx()
pairs := map[string]btcutil.Amount{
"1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX": 10,
"12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG": 1,
}
if err := addOutputs(msgtx, pairs); err != nil {
t.Fatal(err)
}
if len(msgtx.TxOut) != 2 {
t.Fatalf("Expected 2 outputs, found only %d", len(msgtx.TxOut))
}
values := []int{int(msgtx.TxOut[0].Value), int(msgtx.TxOut[1].Value)}
sort.Ints(values)
if !reflect.DeepEqual(values, []int{1, 10}) {
t.Fatalf("Expected values to be [1, 10], got: %v", values)
}
}