-
Notifications
You must be signed in to change notification settings - Fork 2
/
vin_test.go
53 lines (43 loc) · 1.06 KB
/
vin_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package bip352
import (
"bytes"
"encoding/hex"
"github.com/btcsuite/btcd/btcutil"
"testing"
)
func TestVin(t *testing.T) {
txid, _ := hex.DecodeString("f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16")
pkScript, _ := hex.DecodeString("5120f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16")
var vout uint32 = 3
var targetAmount uint64 = 10_000_000
var vin = Vin{
Txid: ConvertToFixedLength32(txid),
Vout: vout,
ScriptPubKey: pkScript,
Amount: targetAmount,
}
if !bytes.Equal(vin.Hash()[:], txid) {
t.Errorf("Error: txid hashes don't match")
return
}
if !bytes.Equal(vin.PkScript(), pkScript) {
t.Errorf("Error: scriptPubKeys don't match")
return
}
if vin.Index() != vout {
t.Errorf("Error: vouts don't match")
return
}
if vin.Value() != btcutil.Amount(targetAmount) {
t.Errorf("Error: amounts don't match")
return
}
if vin.NumConfs() != 0 {
t.Errorf("Error: wrong numConfs returned")
return
}
if vin.ValueAge() != 0 {
t.Errorf("Error: wrong valueAge returned")
return
}
}