@@ -318,7 +318,7 @@ var teraTestNetGenesisBlockBytes = []byte{
318318 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |................| */
319319 0x00 , 0x00 , 0x00 , 0x00 , 0x3b , 0xa3 , 0xed , 0xfd , 0x7a , 0x7b , 0x12 , 0xb2 , 0x7a , 0xc7 , 0x2c , 0x3e , /* |....;...z{..z.,>| */
320320 0x67 , 0x76 , 0x8f , 0x61 , 0x7f , 0xc8 , 0x1b , 0xc3 , 0x88 , 0x8a , 0x51 , 0x32 , 0x3a , 0x9f , 0xb8 , 0xaa , /* |gv.a......Q2:...| */
321- 0x4b , 0x1e , 0x5e , 0x4a , 0x34 , 0x6f , 0xa4 , 0x68 , 0xff , 0xff , 0x7f , 0x20 , 0x02 , 0x00 , 0x00 , 0x00 , /* |K.^J4o.h... ....| */
321+ 0x4b , 0x1e , 0x5e , 0x4a , 0x34 , 0x6f , 0xa4 , 0x68 , 0xff , 0xff , 0x7f , 0x20 , 0x05 , 0x00 , 0x00 , 0x00 , /* |K.^J4o.h... ....| */
322322 0x01 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |................| */
323323 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |................| */
324324 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , 0xff , 0xff , 0x4d , 0x04 , 0xff , 0xff , 0x00 , 0x1d , /* |..........M.....| */
@@ -345,24 +345,25 @@ func TestTeraTestNetGenesisProofOfWork(t *testing.T) {
345345
346346 // Get the target from bits
347347 bits := genesisBlock .Header .Bits
348- mantissa := bits & 0x00ffffff
349348 exponent := bits >> 24
349+ mantissa := bits & 0x007fffff
350350
351351 target := new (big.Int ).SetInt64 (int64 (mantissa ))
352352 if exponent > 3 {
353353 target .Lsh (target , 8 * (uint (exponent )- 3 ))
354354 }
355355
356356 // Check if hash meets difficulty
357- hashInt := new (big.Int ).SetBytes (hash .CloneBytes ())
357+ bn := big .NewInt (0 )
358+ bn .SetBytes (bt .ReverseBytes (hash [:]))
358359
359- if hashInt .Cmp (target ) > 0 {
360+ if bn .Cmp (target ) > 0 {
360361 t .Fatalf ("TestTeraTestNetGenesisProofOfWork: Genesis block does not meet difficulty requirement. " +
361362 "Hash: %s, Target: %064x" , hash , target .Bytes ())
362363 }
363364
364365 // Verify the nonce is the expected value
365- expectedNonce := uint32 (0x00000002 )
366+ expectedNonce := uint32 (0x00000005 )
366367 if genesisBlock .Header .Nonce != expectedNonce {
367368 t .Fatalf ("TestTeraTestNetGenesisProofOfWork: Unexpected nonce - got %d, want %d" ,
368369 genesisBlock .Header .Nonce , expectedNonce )
0 commit comments