lbcwallet/createtx_test.go

30 lines
682 B
Go
Raw Normal View History

package main
import (
"reflect"
"sort"
2014-07-03 13:45:40 +02:00
"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,
2014-01-16 18:04:47 +01:00
}
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)
}
}