@@ -24,7 +24,6 @@ import (
24
24
"github.com/iotexproject/iotex-core/config"
25
25
"github.com/iotexproject/iotex-core/crypto"
26
26
"github.com/iotexproject/iotex-core/iotxaddress"
27
- "github.com/iotexproject/iotex-core/pkg/enc"
28
27
"github.com/iotexproject/iotex-core/pkg/hash"
29
28
"github.com/iotexproject/iotex-core/pkg/keypair"
30
29
"github.com/iotexproject/iotex-core/pkg/version"
@@ -69,27 +68,33 @@ func TestMerkle(t *testing.T) {
69
68
require .NotNil (cbtsf4 )
70
69
71
70
// verify tx hash
72
- hash0 , _ := hex .DecodeString ("c42f754fdf676a6ac4cdccba96f2dc1055c41c25effc72ac9477e120712e5634" )
71
+ hash0 , e := hex .DecodeString ("057f3817e6eefc3eadfb14a3bee75aafd7d1913a54798cc339e394b9860c8bcd" )
72
+ require .NoError (e )
73
73
actual := cbtsf0 .Hash ()
74
74
require .Equal (hash0 , actual [:])
75
75
t .Logf ("actual hash = %x" , actual [:])
76
76
77
- hash1 , _ := hex .DecodeString ("2c4bcfb59297b3e472f7c15ff31a3ed080b749a952c18bb585ef517542c8381d" )
77
+ hash1 , e := hex .DecodeString ("c5363bbfd115ca7457e34883a0af2274334561e4cc4b7f977df9890c918eeb0e" )
78
+ require .NoError (e )
78
79
actual = cbtsf1 .Hash ()
79
80
require .Equal (hash1 , actual [:])
80
81
t .Logf ("actual hash = %x" , actual [:])
81
82
82
- hash2 , _ := hex .DecodeString ("46e07d8753a07d66f9b76797a0e3257fd2b70b019722dfb3394ba51db2b21b62" )
83
+ hash2 , e := hex .DecodeString ("a587acce738d152fbf6aee0422ad9d9b69a0c78a8b362fe618a8a5f6b386ea0e" )
84
+ require .NoError (e )
83
85
actual = cbtsf2 .Hash ()
84
86
require .Equal (hash2 , actual [:])
87
+ //require.Equal(hash2, actual[:])
85
88
t .Logf ("actual hash = %x" , actual [:])
86
89
87
- hash3 , _ := hex .DecodeString ("d300718263371fb0218a2616f8822866547dade0f0b1dbe3d326950c4488f6de" )
90
+ hash3 , e := hex .DecodeString ("95326afce0c2b6e86c8bece513675306cd690c86b35ba7c0d41c1bc3611976d1" )
91
+ require .NoError (e )
88
92
actual = cbtsf3 .Hash ()
89
93
require .Equal (hash3 , actual [:])
90
94
t .Logf ("actual hash = %x" , actual [:])
91
95
92
- hash4 , _ := hex .DecodeString ("75b315ef2baaa13af4579876d018db0f512e132d3c4b41b5ebe9d0b75e9cf054" )
96
+ hash4 , e := hex .DecodeString ("9e2e1f21422978399a5626ee80f53ec30f1c056a5b924275cb408befe2ac0837" )
97
+ require .NoError (e )
93
98
actual = cbtsf4 .Hash ()
94
99
require .Equal (hash4 , actual [:])
95
100
t .Logf ("actual hash = %x" , actual [:])
@@ -243,15 +248,13 @@ func TestWrongNonce(t *testing.T) {
243
248
require .Nil (err )
244
249
require .Nil (sf .Commit ())
245
250
246
- chainID := enc .MachineEndian .Uint32 (iotxaddress .ChainID )
247
-
248
251
// correct nonce
249
252
coinbaseTsf := action .NewCoinBaseTransfer (big .NewInt (int64 (Gen .BlockReward )), ta .Addrinfo ["producer" ].RawAddress )
250
253
tsf1 , err := action .NewTransfer (1 , big .NewInt (20 ), ta .Addrinfo ["producer" ].RawAddress , ta .Addrinfo ["alfa" ].RawAddress , []byte {}, uint64 (100000 ), big .NewInt (10 ))
251
254
require .NoError (err )
252
255
require .NoError (action .Sign (tsf1 , ta .Addrinfo ["producer" ].PrivateKey ))
253
256
hash := tsf1 .Hash ()
254
- blk := NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf1 }, nil , nil )
257
+ blk := NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf1 }, nil , nil )
255
258
err = blk .SignBlock (ta .Addrinfo ["producer" ])
256
259
require .NoError (err )
257
260
require .Nil (val .Validate (blk , 2 , hash , true ))
@@ -264,7 +267,7 @@ func TestWrongNonce(t *testing.T) {
264
267
require .NoError (err )
265
268
require .NoError (action .Sign (tsf2 , ta .Addrinfo ["producer" ].PrivateKey ))
266
269
hash = tsf1 .Hash ()
267
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf1 , tsf2 }, nil , nil )
270
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf1 , tsf2 }, nil , nil )
268
271
err = blk .SignBlock (ta .Addrinfo ["producer" ])
269
272
require .NoError (err )
270
273
err = val .Validate (blk , 2 , hash , true )
@@ -274,7 +277,7 @@ func TestWrongNonce(t *testing.T) {
274
277
require .NoError (err )
275
278
require .NoError (action .Sign (vote , ta .Addrinfo ["producer" ].PrivateKey ))
276
279
hash = tsf1 .Hash ()
277
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote }, nil )
280
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote }, nil )
278
281
err = blk .SignBlock (ta .Addrinfo ["producer" ])
279
282
require .NoError (err )
280
283
err = val .Validate (blk , 2 , hash , true )
@@ -289,7 +292,7 @@ func TestWrongNonce(t *testing.T) {
289
292
require .NoError (err )
290
293
require .NoError (action .Sign (tsf4 , ta .Addrinfo ["producer" ].PrivateKey ))
291
294
hash = tsf1 .Hash ()
292
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf3 , tsf4 }, nil , nil )
295
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf3 , tsf4 }, nil , nil )
293
296
err = blk .SignBlock (ta .Addrinfo ["producer" ])
294
297
require .NoError (err )
295
298
err = val .Validate (blk , 2 , hash , true )
@@ -303,7 +306,7 @@ func TestWrongNonce(t *testing.T) {
303
306
require .NoError (err )
304
307
require .NoError (action .Sign (vote3 , ta .Addrinfo ["producer" ].PrivateKey ))
305
308
hash = tsf1 .Hash ()
306
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote2 , vote3 }, nil )
309
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote2 , vote3 }, nil )
307
310
err = blk .SignBlock (ta .Addrinfo ["producer" ])
308
311
require .NoError (err )
309
312
err = val .Validate (blk , 2 , hash , true )
@@ -318,7 +321,7 @@ func TestWrongNonce(t *testing.T) {
318
321
require .NoError (err )
319
322
require .NoError (action .Sign (tsf6 , ta .Addrinfo ["producer" ].PrivateKey ))
320
323
hash = tsf1 .Hash ()
321
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf5 , tsf6 }, nil , nil )
324
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf , tsf5 , tsf6 }, nil , nil )
322
325
err = blk .SignBlock (ta .Addrinfo ["producer" ])
323
326
require .NoError (err )
324
327
err = val .Validate (blk , 2 , hash , true )
@@ -332,7 +335,7 @@ func TestWrongNonce(t *testing.T) {
332
335
require .NoError (err )
333
336
require .NoError (action .Sign (vote5 , ta .Addrinfo ["producer" ].PrivateKey ))
334
337
hash = tsf1 .Hash ()
335
- blk = NewBlock (chainID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote4 , vote5 }, nil )
338
+ blk = NewBlock (cfg . Chain . ID , 3 , hash , clock .New (), []* action.Transfer {coinbaseTsf }, []* action.Vote {vote4 , vote5 }, nil )
336
339
err = blk .SignBlock (ta .Addrinfo ["producer" ])
337
340
require .NoError (err )
338
341
err = val .Validate (blk , 2 , hash , true )
@@ -467,8 +470,11 @@ func TestValidateSecretBlock(t *testing.T) {
467
470
idList := make ([][]uint8 , 0 )
468
471
delegates := []string {ta .Addrinfo ["producer" ].RawAddress }
469
472
for i := 0 ; i < 20 ; i ++ {
470
- addr , _ := iotxaddress .NewAddress (iotxaddress .IsTestnet , iotxaddress .ChainID )
471
- delegates = append (delegates , addr .RawAddress )
473
+ pk , _ , err := crypto .EC283 .NewKeyPair ()
474
+ require .NoError (err )
475
+ pkHash := keypair .HashPubKey (pk )
476
+ addr := address .New (cfg .Chain .ID , pkHash [:])
477
+ delegates = append (delegates , addr .IotxAddress ())
472
478
}
473
479
474
480
for _ , delegate := range delegates {
0 commit comments