@@ -136,76 +136,121 @@ func TestSecp256k1Address(t *testing.T) {
136
136
137
137
func TestVectorSecp256k1Address (t * testing.T ) {
138
138
testCases := []struct {
139
- input []byte
140
- expected string
139
+ input []byte
140
+ expectedTestnetAddrStr string
141
+ expectedMainnetAddrStr string
141
142
}{
142
143
{[]byte {4 , 148 , 2 , 250 , 195 , 126 , 100 , 50 , 164 , 22 , 163 , 160 , 202 , 84 ,
143
144
38 , 181 , 24 , 90 , 179 , 178 , 79 , 97 , 52 , 239 , 162 , 92 , 228 , 135 , 200 ,
144
145
45 , 46 , 78 , 19 , 191 , 69 , 37 , 17 , 224 , 210 , 36 , 84 , 33 , 248 , 97 , 59 ,
145
146
193 , 13 , 114 , 250 , 33 , 102 , 102 , 169 , 108 , 59 , 193 , 57 , 32 , 211 ,
146
147
255 , 35 , 63 , 208 , 188 , 5 },
147
- "t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq" },
148
+ "t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq" ,
149
+ "f15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq" ,
150
+ },
148
151
149
152
{[]byte {4 , 118 , 135 , 185 , 16 , 55 , 155 , 242 , 140 , 190 , 58 , 234 , 103 , 75 ,
150
153
18 , 0 , 12 , 107 , 125 , 186 , 70 , 255 , 192 , 95 , 108 , 148 , 254 , 42 , 34 ,
151
154
187 , 204 , 38 , 2 , 255 , 127 , 92 , 118 , 242 , 28 , 165 , 93 , 54 , 149 , 145 ,
152
155
82 , 176 , 225 , 232 , 135 , 145 , 124 , 57 , 53 , 118 , 238 , 240 , 147 , 246 ,
153
156
30 , 189 , 58 , 208 , 111 , 127 , 218 },
154
- "t12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a" },
157
+ "t12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a" ,
158
+ "f12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a" ,
159
+ },
155
160
{[]byte {4 , 222 , 253 , 208 , 16 , 1 , 239 , 184 , 110 , 1 , 222 , 213 , 206 , 52 ,
156
161
248 , 71 , 167 , 58 , 20 , 129 , 158 , 230 , 65 , 188 , 182 , 11 , 185 , 41 , 147 ,
157
162
89 , 111 , 5 , 220 , 45 , 96 , 95 , 41 , 133 , 248 , 209 , 37 , 129 , 45 , 172 ,
158
163
65 , 99 , 163 , 150 , 52 , 155 , 35 , 193 , 28 , 194 , 255 , 53 , 157 , 229 , 75 ,
159
164
226 , 135 , 234 , 98 , 49 , 155 },
160
- "t1wbxhu3ypkuo6eyp6hjx6davuelxaxrvwb2kuwva" },
165
+ "t1wbxhu3ypkuo6eyp6hjx6davuelxaxrvwb2kuwva" ,
166
+ "f1wbxhu3ypkuo6eyp6hjx6davuelxaxrvwb2kuwva" ,
167
+ },
161
168
{[]byte {4 , 3 , 237 , 18 , 200 , 20 , 182 , 177 , 13 , 46 , 224 , 157 , 149 , 180 ,
162
169
104 , 141 , 178 , 209 , 128 , 208 , 169 , 163 , 122 , 107 , 106 , 125 , 182 , 61 ,
163
170
41 , 129 , 30 , 233 , 115 , 4 , 121 , 216 , 239 , 145 , 57 , 233 , 18 , 73 , 202 ,
164
171
189 , 57 , 50 , 145 , 207 , 229 , 210 , 119 , 186 , 118 , 222 , 69 , 227 , 224 ,
165
172
133 , 163 , 118 , 129 , 191 , 54 , 69 , 210 },
166
- "t1xtwapqc6nh4si2hcwpr3656iotzmlwumogqbuaa" },
173
+ "t1xtwapqc6nh4si2hcwpr3656iotzmlwumogqbuaa" ,
174
+ "f1xtwapqc6nh4si2hcwpr3656iotzmlwumogqbuaa" ,
175
+ },
167
176
{[]byte {4 , 247 , 150 , 129 , 154 , 142 , 39 , 22 , 49 , 175 , 124 , 24 , 151 , 151 ,
168
177
181 , 69 , 214 , 2 , 37 , 147 , 97 , 71 , 230 , 1 , 14 , 101 , 98 , 179 , 206 , 158 ,
169
178
254 , 139 , 16 , 20 , 65 , 97 , 169 , 30 , 208 , 180 , 236 , 137 , 8 , 0 , 37 , 63 ,
170
179
166 , 252 , 32 , 172 , 144 , 251 , 241 , 251 , 242 , 113 , 48 , 164 , 236 , 195 ,
171
180
228 , 3 , 183 , 5 , 118 },
172
- "t1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy" },
181
+ "t1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy" ,
182
+ "f1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy" ,
183
+ },
173
184
{[]byte {4 , 66 , 131 , 43 , 248 , 124 , 206 , 158 , 163 , 69 , 185 , 3 , 80 , 222 ,
174
185
125 , 52 , 149 , 133 , 156 , 164 , 73 , 5 , 156 , 94 , 136 , 221 , 231 , 66 , 133 ,
175
186
223 , 251 , 158 , 192 , 30 , 186 , 188 , 95 , 200 , 98 , 104 , 207 , 234 , 235 ,
176
187
167 , 174 , 5 , 191 , 184 , 214 , 142 , 183 , 90 , 82 , 104 , 120 , 44 , 248 , 111 ,
177
188
200 , 112 , 43 , 239 , 138 , 31 , 224 },
178
- "t17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy" },
189
+ "t17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy" ,
190
+ "f17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy" ,
191
+ },
179
192
}
180
193
181
194
for _ , tc := range testCases {
182
195
tc := tc
183
- t .Run (fmt .Sprintf ("testing secp256k1 address: %s" , tc .expected ), func (t * testing.T ) {
196
+ name := fmt .Sprintf (
197
+ "testing secp256k1 address: %s (testnet), %s (mainnet)" ,
198
+ tc .expectedTestnetAddrStr ,
199
+ tc .expectedMainnetAddrStr ,
200
+ )
201
+ t .Run (name , func (t * testing.T ) {
184
202
assert := assert .New (t )
185
203
204
+ // Testnet
186
205
// Round trip encoding and decoding from string
206
+ CurrentNetwork = Testnet
187
207
addr , err := NewSecp256k1Address (tc .input )
188
208
assert .NoError (err )
189
- assert .Equal (tc .expected , addr .String ())
209
+ assert .Equal (tc .expectedTestnetAddrStr , addr .String ())
190
210
191
- maybeAddr , err := NewFromString (tc .expected )
211
+ maybeTestnetAddr , err := NewFromString (tc .expectedTestnetAddrStr )
192
212
assert .NoError (err )
193
- assert .Equal (SECP256K1 , maybeAddr .Protocol ())
194
- assert .Equal (addressHash (tc .input ), maybeAddr .Payload ())
213
+ assert .Equal (SECP256K1 , maybeTestnetAddr .Protocol ())
214
+ assert .Equal (addressHash (tc .input ), maybeTestnetAddr .Payload ())
195
215
196
216
// Round trip to and from bytes
197
- maybeAddrBytes , err := NewFromBytes (maybeAddr .Bytes ())
217
+ maybeTestnetAddrBytes , err := NewFromBytes (maybeTestnetAddr .Bytes ())
198
218
assert .NoError (err )
199
- assert .Equal (maybeAddr , maybeAddrBytes )
219
+ assert .Equal (maybeTestnetAddr , maybeTestnetAddrBytes )
200
220
201
221
// Round trip encoding and decoding json
202
- b , err := addr .MarshalJSON ()
222
+ tb , err := addr .MarshalJSON ()
203
223
assert .NoError (err )
204
224
205
- var newAddr Address
206
- err = newAddr .UnmarshalJSON (b )
225
+ var newTestnetAddr Address
226
+ err = newTestnetAddr .UnmarshalJSON (tb )
207
227
assert .NoError (err )
208
- assert .Equal (addr , newAddr )
228
+ assert .Equal (addr , newTestnetAddr )
229
+
230
+ // Mainnet
231
+ // Round trip encoding and decoding from string
232
+ CurrentNetwork = Mainnet
233
+ assert .Equal (tc .expectedMainnetAddrStr , addr .String ())
234
+
235
+ maybeMainnetAddr , err := NewFromString (tc .expectedMainnetAddrStr )
236
+ assert .NoError (err )
237
+ assert .Equal (SECP256K1 , maybeMainnetAddr .Protocol ())
238
+ assert .Equal (addressHash (tc .input ), maybeMainnetAddr .Payload ())
239
+
240
+ // Round trip to and from bytes
241
+ maybeMainnetAddrBytes , err := NewFromBytes (maybeMainnetAddr .Bytes ())
242
+ assert .NoError (err )
243
+ assert .Equal (maybeMainnetAddr , maybeMainnetAddrBytes )
244
+
245
+ // Round trip encoding and decoding json
246
+ mb , err := addr .MarshalJSON ()
247
+ assert .NoError (err )
248
+
249
+ var newMainnetAddr Address
250
+ err = newMainnetAddr .UnmarshalJSON (mb )
251
+ assert .NoError (err )
252
+ assert .Equal (addr , newMainnetAddr )
253
+
209
254
})
210
255
}
211
256
}
@@ -232,117 +277,201 @@ func TestRandomActorAddress(t *testing.T) {
232
277
func TestVectorActorAddress (t * testing.T ) {
233
278
testCases := []struct {
234
279
input []byte
235
- expected string
280
+ expectedTestnetAddrStr string
281
+ expectedMainnetAddrStr string
236
282
}{
237
283
{[]byte {118 , 18 , 129 , 144 , 205 , 240 , 104 , 209 , 65 , 128 , 68 , 172 , 192 ,
238
284
62 , 11 , 103 , 129 , 151 , 13 , 96 },
239
- "t24vg6ut43yw2h2jqydgbg2xq7x6f4kub3bg6as6i" },
285
+ "t24vg6ut43yw2h2jqydgbg2xq7x6f4kub3bg6as6i" ,
286
+ "f24vg6ut43yw2h2jqydgbg2xq7x6f4kub3bg6as6i" ,
287
+ },
240
288
{[]byte {44 , 175 , 184 , 226 , 224 , 107 , 186 , 152 , 234 , 101 , 124 , 92 , 245 ,
241
289
244 , 32 , 35 , 170 , 35 , 232 , 142 },
242
- "t25nml2cfbljvn4goqtclhifepvfnicv6g7mfmmvq" },
290
+ "t25nml2cfbljvn4goqtclhifepvfnicv6g7mfmmvq" ,
291
+ "f25nml2cfbljvn4goqtclhifepvfnicv6g7mfmmvq" ,
292
+ },
243
293
{[]byte {2 , 44 , 158 , 14 , 162 , 157 , 143 , 64 , 197 , 106 , 190 , 195 , 92 , 141 ,
244
294
88 , 125 , 160 , 166 , 76 , 24 },
245
- "t2nuqrg7vuysaue2pistjjnt3fadsdzvyuatqtfei" },
295
+ "t2nuqrg7vuysaue2pistjjnt3fadsdzvyuatqtfei" ,
296
+ "f2nuqrg7vuysaue2pistjjnt3fadsdzvyuatqtfei" ,
297
+ },
246
298
{[]byte {223 , 236 , 3 , 14 , 32 , 79 , 15 , 89 , 216 , 15 , 29 , 94 , 233 , 29 , 253 ,
247
299
6 , 109 , 127 , 99 , 189 },
248
- "t24dd4ox4c2vpf5vk5wkadgyyn6qtuvgcpxxon64a" },
300
+ "t24dd4ox4c2vpf5vk5wkadgyyn6qtuvgcpxxon64a" ,
301
+ "f24dd4ox4c2vpf5vk5wkadgyyn6qtuvgcpxxon64a" ,
302
+ },
249
303
{[]byte {61 , 58 , 137 , 232 , 221 , 171 , 84 , 120 , 50 , 113 , 108 , 109 , 70 , 140 ,
250
304
53 , 96 , 201 , 244 , 127 , 216 },
251
- "t2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y" },
305
+ "t2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y" ,
306
+ "f2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y" ,
307
+ },
252
308
}
253
309
254
310
for _ , tc := range testCases {
255
311
tc := tc
256
- t .Run (fmt .Sprintf ("testing Actor address: %s" , tc .expected ), func (t * testing.T ) {
312
+ name := fmt .Sprintf (
313
+ "testing Actor address: %s (testnet), %s (mainnet)" ,
314
+ tc .expectedTestnetAddrStr ,
315
+ tc .expectedMainnetAddrStr ,
316
+ )
317
+ t .Run (name , func (t * testing.T ) {
257
318
assert := assert .New (t )
258
319
320
+ // Testnet
259
321
// Round trip encoding and decoding from string
322
+ CurrentNetwork = Testnet
260
323
addr , err := NewActorAddress (tc .input )
261
324
assert .NoError (err )
262
- assert .Equal (tc .expected , addr .String ())
325
+ assert .Equal (tc .expectedTestnetAddrStr , addr .String ())
263
326
264
- maybeAddr , err := NewFromString (tc .expected )
327
+ maybeTestnetAddr , err := NewFromString (tc .expectedTestnetAddrStr )
265
328
assert .NoError (err )
266
- assert .Equal (Actor , maybeAddr .Protocol ())
267
- assert .Equal (addressHash (tc .input ), maybeAddr .Payload ())
329
+ assert .Equal (Actor , maybeTestnetAddr .Protocol ())
330
+ assert .Equal (addressHash (tc .input ), maybeTestnetAddr .Payload ())
268
331
269
332
// Round trip to and from bytes
270
- maybeAddrBytes , err := NewFromBytes (maybeAddr .Bytes ())
333
+ maybeTestnetAddrBytes , err := NewFromBytes (maybeTestnetAddr .Bytes ())
271
334
assert .NoError (err )
272
- assert .Equal (maybeAddr , maybeAddrBytes )
335
+ assert .Equal (maybeTestnetAddr , maybeTestnetAddrBytes )
273
336
274
337
// Round trip encoding and decoding json
275
- b , err := addr .MarshalJSON ()
338
+ tb , err := addr .MarshalJSON ()
276
339
assert .NoError (err )
277
340
278
- var newAddr Address
279
- err = newAddr .UnmarshalJSON (b )
341
+ var newTestnetAddr Address
342
+ err = newTestnetAddr .UnmarshalJSON (tb )
280
343
assert .NoError (err )
281
- assert .Equal (addr , newAddr )
344
+ assert .Equal (addr , newTestnetAddr )
345
+
346
+ // Mainnet
347
+ // Round trip encoding and decoding from string
348
+ CurrentNetwork = Mainnet
349
+ assert .Equal (tc .expectedMainnetAddrStr , addr .String ())
350
+
351
+ maybeMainnetAddr , err := NewFromString (tc .expectedMainnetAddrStr )
352
+ assert .NoError (err )
353
+ assert .Equal (Actor , maybeMainnetAddr .Protocol ())
354
+ assert .Equal (addressHash (tc .input ), maybeMainnetAddr .Payload ())
355
+
356
+ // Round trip to and from bytes
357
+ maybeMainnetAddrBytes , err := NewFromBytes (maybeMainnetAddr .Bytes ())
358
+ assert .NoError (err )
359
+ assert .Equal (maybeMainnetAddr , maybeMainnetAddrBytes )
360
+
361
+ // Round trip encoding and decoding json
362
+ mb , err := addr .MarshalJSON ()
363
+ assert .NoError (err )
364
+
365
+ var newMainnetAddr Address
366
+ err = newMainnetAddr .UnmarshalJSON (mb )
367
+ assert .NoError (err )
368
+ assert .Equal (addr , newMainnetAddr )
282
369
})
283
370
}
284
371
}
285
372
286
373
func TestVectorBLSAddress (t * testing.T ) {
287
374
testCases := []struct {
288
375
input []byte
289
- expected string
376
+ expectedTestnetAddrStr string
377
+ expectedMainnetAddrStr string
290
378
}{
291
379
{[]byte {173 , 88 , 223 , 105 , 110 , 45 , 78 , 145 , 234 , 134 , 200 , 129 , 233 , 56 ,
292
380
186 , 78 , 168 , 27 , 57 , 94 , 18 , 121 , 123 , 132 , 185 , 207 , 49 , 75 , 149 , 70 ,
293
381
112 , 94 , 131 , 156 , 122 , 153 , 214 , 6 , 178 , 71 , 221 , 180 , 249 , 172 , 122 ,
294
382
52 , 20 , 221 },
295
- "t3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a" },
383
+ "t3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a" ,
384
+ "f3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a" ,
385
+ },
296
386
{[]byte {179 , 41 , 79 , 10 , 46 , 41 , 224 , 198 , 110 , 188 , 35 , 93 , 47 , 237 ,
297
387
202 , 86 , 151 , 191 , 120 , 74 , 246 , 5 , 199 , 90 , 246 , 8 , 230 , 166 , 61 , 92 ,
298
388
211 , 142 , 168 , 92 , 168 , 152 , 158 , 14 , 253 , 233 , 24 , 139 , 56 , 47 ,
299
389
147 , 114 , 70 , 13 },
300
- "t3wmuu6crofhqmm3v4enos73okk2l366ck6yc4owxwbdtkmpk42ohkqxfitcpa57pjdcftql4tojda2poeruwa" },
390
+ "t3wmuu6crofhqmm3v4enos73okk2l366ck6yc4owxwbdtkmpk42ohkqxfitcpa57pjdcftql4tojda2poeruwa" ,
391
+ "f3wmuu6crofhqmm3v4enos73okk2l366ck6yc4owxwbdtkmpk42ohkqxfitcpa57pjdcftql4tojda2poeruwa" ,
392
+ },
301
393
{[]byte {150 , 161 , 163 , 228 , 234 , 122 , 20 , 212 , 153 , 133 , 230 , 97 , 178 ,
302
394
36 , 1 , 212 , 79 , 237 , 64 , 45 , 29 , 9 , 37 , 178 , 67 , 201 , 35 , 88 , 156 ,
303
395
15 , 188 , 126 , 50 , 205 , 4 , 226 , 158 , 215 , 141 , 21 , 211 , 125 , 58 , 170 ,
304
396
63 , 230 , 218 , 51 },
305
- "t3s2q2hzhkpiknjgmf4zq3ejab2rh62qbndueslmsdzervrhapxr7dftie4kpnpdiv2n6tvkr743ndhrsw6d3a" },
397
+ "t3s2q2hzhkpiknjgmf4zq3ejab2rh62qbndueslmsdzervrhapxr7dftie4kpnpdiv2n6tvkr743ndhrsw6d3a" ,
398
+ "f3s2q2hzhkpiknjgmf4zq3ejab2rh62qbndueslmsdzervrhapxr7dftie4kpnpdiv2n6tvkr743ndhrsw6d3a" ,
399
+ },
306
400
{[]byte {134 , 180 , 84 , 37 , 140 , 88 , 148 , 117 , 247 , 209 , 111 , 90 , 172 , 1 ,
307
401
138 , 121 , 246 , 193 , 22 , 157 , 32 , 252 , 51 , 146 , 29 , 216 , 181 , 206 , 28 ,
308
402
172 , 108 , 52 , 143 , 144 , 163 , 96 , 54 , 36 , 246 , 174 , 185 , 27 , 100 , 81 ,
309
403
140 , 46 , 128 , 149 },
310
- "t3q22fijmmlckhl56rn5nkyamkph3mcfu5ed6dheq53c244hfmnq2i7efdma3cj5voxenwiummf2ajlsbxc65a" },
404
+ "t3q22fijmmlckhl56rn5nkyamkph3mcfu5ed6dheq53c244hfmnq2i7efdma3cj5voxenwiummf2ajlsbxc65a" ,
405
+ "f3q22fijmmlckhl56rn5nkyamkph3mcfu5ed6dheq53c244hfmnq2i7efdma3cj5voxenwiummf2ajlsbxc65a" ,
406
+ },
311
407
{[]byte {167 , 114 , 107 , 3 , 128 , 34 , 247 , 90 , 56 , 70 , 23 , 88 , 83 , 96 , 206 ,
312
408
230 , 41 , 7 , 10 , 45 , 157 , 40 , 113 , 41 , 101 , 229 , 242 , 110 , 204 , 64 ,
313
409
133 , 131 , 130 , 128 , 55 , 36 , 237 , 52 , 242 , 114 , 3 , 54 , 240 , 157 , 182 ,
314
410
49 , 240 , 116 },
315
- "t3u5zgwa4ael3vuocgc5mfgygo4yuqocrntuuhcklf4xzg5tcaqwbyfabxetwtj4tsam3pbhnwghyhijr5mixa" },
411
+ "t3u5zgwa4ael3vuocgc5mfgygo4yuqocrntuuhcklf4xzg5tcaqwbyfabxetwtj4tsam3pbhnwghyhijr5mixa" ,
412
+ "f3u5zgwa4ael3vuocgc5mfgygo4yuqocrntuuhcklf4xzg5tcaqwbyfabxetwtj4tsam3pbhnwghyhijr5mixa" ,
413
+ },
316
414
}
317
415
318
416
for _ , tc := range testCases {
319
417
tc := tc
320
- t .Run (fmt .Sprintf ("testing bls address: %s" , tc .expected ), func (t * testing.T ) {
418
+ name := fmt .Sprintf (
419
+ "testing bls address: %s (testnet), %s (mainnet)" ,
420
+ tc .expectedTestnetAddrStr ,
421
+ tc .expectedMainnetAddrStr ,
422
+ )
423
+ t .Run (name , func (t * testing.T ) {
321
424
assert := assert .New (t )
322
425
426
+ // Testnet
323
427
// Round trip encoding and decoding from string
428
+ CurrentNetwork = Testnet
324
429
addr , err := NewBLSAddress (tc .input )
325
430
assert .NoError (err )
326
- assert .Equal (tc .expected , addr .String ())
431
+ assert .Equal (tc .expectedTestnetAddrStr , addr .String ())
327
432
328
- maybeAddr , err := NewFromString (tc .expected )
433
+ maybeTestnetAddr , err := NewFromString (tc .expectedTestnetAddrStr )
329
434
assert .NoError (err )
330
- assert .Equal (BLS , maybeAddr .Protocol ())
331
- assert .Equal (tc .input , maybeAddr .Payload ())
435
+ assert .Equal (BLS , maybeTestnetAddr .Protocol ())
436
+ assert .Equal (tc .input , maybeTestnetAddr .Payload ())
332
437
333
438
// Round trip to and from bytes
334
- maybeAddrBytes , err := NewFromBytes (maybeAddr .Bytes ())
439
+ maybeTestnetAddrBytes , err := NewFromBytes (maybeTestnetAddr .Bytes ())
335
440
assert .NoError (err )
336
- assert .Equal (maybeAddr , maybeAddrBytes )
441
+ assert .Equal (maybeTestnetAddr , maybeTestnetAddrBytes )
337
442
338
443
// Round trip encoding and decoding json
339
- b , err := addr .MarshalJSON ()
444
+ tb , err := addr .MarshalJSON ()
340
445
assert .NoError (err )
341
446
342
- var newAddr Address
343
- err = newAddr .UnmarshalJSON (b )
447
+ var newTestnetAddr Address
448
+ err = newTestnetAddr .UnmarshalJSON (tb )
344
449
assert .NoError (err )
345
- assert .Equal (addr , newAddr )
450
+ assert .Equal (addr , newTestnetAddr )
451
+
452
+ // Mainnet
453
+ // Round trip encoding and decoding from string
454
+ CurrentNetwork = Mainnet
455
+ assert .Equal (tc .expectedMainnetAddrStr , addr .String ())
456
+
457
+ maybeMainnetAddr , err := NewFromString (tc .expectedMainnetAddrStr )
458
+ assert .NoError (err )
459
+ assert .Equal (BLS , maybeMainnetAddr .Protocol ())
460
+ assert .Equal (tc .input , maybeMainnetAddr .Payload ())
461
+
462
+ // Round trip to and from bytes
463
+ maybeMainnetAddrBytes , err := NewFromBytes (maybeMainnetAddr .Bytes ())
464
+ assert .NoError (err )
465
+ assert .Equal (maybeMainnetAddr , maybeMainnetAddrBytes )
466
+
467
+ // Round trip encoding and decoding json
468
+ mb , err := addr .MarshalJSON ()
469
+ assert .NoError (err )
470
+
471
+ var newMainnetAddr Address
472
+ err = newMainnetAddr .UnmarshalJSON (mb )
473
+ assert .NoError (err )
474
+ assert .Equal (addr , newMainnetAddr )
346
475
})
347
476
}
348
477
}
0 commit comments