@@ -21,6 +21,10 @@ func isHexString(enc []byte) error {
21
21
return fmt .Errorf ("invalid hex: %v" , str )
22
22
}
23
23
24
+ if str == "null" {
25
+ return nil
26
+ }
27
+
24
28
// remove the "
25
29
str = str [1 : len (str )- 1 ]
26
30
_ , err := hex .DecodeString (str )
@@ -62,6 +66,8 @@ func TestEncodableNetworkPubKeyNil(t *testing.T) {
62
66
err = json .Unmarshal (enc , & dec )
63
67
require .NoError (t , err )
64
68
require .Equal (t , key , dec )
69
+
70
+ require .NoError (t , isHexString (enc ))
65
71
}
66
72
67
73
func TestEncodableNetworkPrivKey (t * testing.T ) {
@@ -77,6 +83,8 @@ func TestEncodableNetworkPrivKey(t *testing.T) {
77
83
err = json .Unmarshal (enc , & dec )
78
84
require .NoError (t , err )
79
85
require .True (t , key .Equals (dec .PrivateKey ))
86
+
87
+ require .NoError (t , isHexString (enc ))
80
88
}
81
89
82
90
func TestEncodableNetworkPrivKeyNil (t * testing.T ) {
@@ -90,6 +98,8 @@ func TestEncodableNetworkPrivKeyNil(t *testing.T) {
90
98
err = json .Unmarshal (enc , & dec )
91
99
require .NoError (t , err )
92
100
require .Equal (t , key , dec )
101
+
102
+ require .NoError (t , isHexString (enc ))
93
103
}
94
104
95
105
func TestEncodableStakingPubKey (t * testing.T ) {
@@ -105,6 +115,8 @@ func TestEncodableStakingPubKey(t *testing.T) {
105
115
err = json .Unmarshal (enc , & dec )
106
116
require .NoError (t , err )
107
117
require .True (t , key .Equals (dec .PublicKey ))
118
+
119
+ require .NoError (t , isHexString (enc ))
108
120
}
109
121
110
122
func TestEncodableStakingPubKeyNil (t * testing.T ) {
@@ -118,6 +130,8 @@ func TestEncodableStakingPubKeyNil(t *testing.T) {
118
130
err = json .Unmarshal (enc , & dec )
119
131
require .NoError (t , err )
120
132
require .Equal (t , key , dec )
133
+
134
+ require .NoError (t , isHexString (enc ))
121
135
}
122
136
123
137
func TestEncodableStakingPrivKey (t * testing.T ) {
@@ -134,6 +148,8 @@ func TestEncodableStakingPrivKey(t *testing.T) {
134
148
require .NoError (t , err )
135
149
136
150
require .True (t , key .Equals (dec .PrivateKey ), "encoded/decoded key equality check failed" )
151
+
152
+ require .NoError (t , isHexString (enc ))
137
153
}
138
154
139
155
func TestEncodableStakingPrivKeyNil (t * testing.T ) {
@@ -147,6 +163,8 @@ func TestEncodableStakingPrivKeyNil(t *testing.T) {
147
163
err = json .Unmarshal (enc , & dec )
148
164
require .NoError (t , err )
149
165
require .Equal (t , key , dec )
166
+
167
+ require .NoError (t , isHexString (enc ))
150
168
}
151
169
152
170
func TestEncodableRandomBeaconPubKey (t * testing.T ) {
@@ -162,6 +180,8 @@ func TestEncodableRandomBeaconPubKey(t *testing.T) {
162
180
err = json .Unmarshal (enc , & dec )
163
181
require .NoError (t , err )
164
182
require .True (t , key .Equals (dec .PublicKey ))
183
+
184
+ require .NoError (t , isHexString (enc ))
165
185
}
166
186
167
187
func TestEncodableRandomBeaconPubKeyNil (t * testing.T ) {
@@ -175,6 +195,8 @@ func TestEncodableRandomBeaconPubKeyNil(t *testing.T) {
175
195
err = json .Unmarshal (enc , & dec )
176
196
require .NoError (t , err )
177
197
require .Equal (t , key , dec )
198
+
199
+ require .NoError (t , isHexString (enc ))
178
200
}
179
201
180
202
func TestEncodableRandomBeaconPrivKey (t * testing.T ) {
@@ -191,6 +213,8 @@ func TestEncodableRandomBeaconPrivKey(t *testing.T) {
191
213
require .NoError (t , err )
192
214
193
215
require .True (t , key .Equals (dec .PrivateKey ), "encoded/decoded key equality check failed" )
216
+
217
+ require .NoError (t , isHexString (enc ))
194
218
}
195
219
196
220
func TestEncodableRandomBeaconPrivKeyNil (t * testing.T ) {
@@ -204,6 +228,8 @@ func TestEncodableRandomBeaconPrivKeyNil(t *testing.T) {
204
228
err = json .Unmarshal (enc , & dec )
205
229
require .NoError (t , err )
206
230
require .Equal (t , key , dec )
231
+
232
+ require .NoError (t , isHexString (enc ))
207
233
}
208
234
209
235
func generateRandomSeed (t * testing.T ) []byte {
0 commit comments