-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtesthelpers.go
88 lines (80 loc) · 2.27 KB
/
testhelpers.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package bip352
import (
"encoding/json"
"io/ioutil"
"testing"
)
type VinReceiveTestCase struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
ScriptSig string `json:"scriptSig"`
Txinwitness string `json:"txinwitness"`
Prevout struct {
ScriptPubKey struct {
Hex string `json:"hex"`
Type string `json:"type"`
} `json:"scriptPubKey"`
} `json:"prevout"`
}
type FullTestCase struct {
Comment string `json:"comment"`
Sending []struct {
Given struct {
Vin []struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
ScriptSig string `json:"scriptSig"`
Txinwitness string `json:"txinwitness"`
Prevout struct {
ScriptPubKey struct {
Hex string `json:"hex"`
Type string `json:"type"`
} `json:"scriptPubKey"`
} `json:"prevout"`
PrivateKey string `json:"private_key"`
} `json:"vin"`
Recipients []string `json:"recipients"`
} `json:"given"`
Expected struct {
Outputs []string `json:"outputs"`
} `json:"expected"`
} `json:"sending"`
Receiving []struct {
Given struct {
Vin []VinReceiveTestCase `json:"vin"`
Outputs []string `json:"outputs"`
KeyMaterial struct {
SpendPrivKey string `json:"spend_priv_key"`
ScanPrivKey string `json:"scan_priv_key"`
} `json:"key_material"`
Labels []uint32 `json:"labels"`
} `json:"given"`
Expected struct {
Addresses []string `json:"addresses"`
Outputs []struct {
PubKey string `json:"pub_key"`
PrivKeyTweak string `json:"priv_key_tweak"`
Signature string `json:"signature"`
} `json:"outputs"`
Tweak string `json:"tweak"`
} `json:"expected"`
} `json:"receiving"`
}
func LoadFullCaseData(t *testing.T) ([]FullTestCase, error) {
filePath := "./test_data/send_and_receive_test_vectors_modified.json"
// Read the JSON file
data, err := ioutil.ReadFile(filePath)
//if err != nil {
// t.Errorf("Error reading JSON file: %s", err)
// return nil, err
//}
// Assuming `testCases` is the variable for storing the unmarshaled data
var testCases []FullTestCase
// Unmarshal the JSON data into the struct
err = json.Unmarshal(data, &testCases)
//if err != nil {
// t.Errorf("Error unmarshaling JSON: %s", err)
// return nil, err
//}
return testCases, err
}