@@ -281,3 +281,72 @@ var testNetGenesisBlockBytes = []byte{
281281func TestRegtestGenesisBlock (t * testing.T ) {
282282 assert .Equal (t , "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206" , regTestGenesisBlock .Header .BlockHash ().String ())
283283}
284+
285+ // TestTeraTestNetGenesisBlock tests the genesis block of the tera test network
286+ // for validity by checking the encoded bytes and hashes.
287+ func TestTeraTestNetGenesisBlock (t * testing.T ) {
288+ // Encode the genesis block to raw bytes.
289+ var buf bytes.Buffer
290+
291+ err := TeraTestNetParams .GenesisBlock .Serialize (& buf )
292+ if err != nil {
293+ t .Fatalf ("TestTeraTestNetGenesisBlock: %v" , err )
294+ }
295+
296+ // Ensure the encoded block matches the expected bytes.
297+ if ! bytes .Equal (buf .Bytes (), teraTestNetGenesisBlockBytes ) {
298+ t .Fatalf ("TestTeraTestNetGenesisBlock: Genesis block does not " +
299+ "appear valid - got %v, want %v" ,
300+ spew .Sdump (buf .Bytes ()),
301+ spew .Sdump (teraTestNetGenesisBlockBytes ))
302+ }
303+
304+ // Check the hash of the block against the expected hash.
305+ hash := TeraTestNetParams .GenesisBlock .BlockHash ()
306+ if ! TeraTestNetParams .GenesisHash .IsEqual (& hash ) {
307+ t .Fatalf ("TestTeraTestNetGenesisBlock: Genesis block hash does " +
308+ "not appear valid - got %v, want %v" , spew .Sdump (hash ),
309+ spew .Sdump (TeraTestNetParams .GenesisHash ))
310+ }
311+ }
312+
313+ // teraTestNetGenesisBlockBytes are the wire-encoded bytes for the genesis block of
314+ // the tera test network as of protocol version 60002.
315+ var teraTestNetGenesisBlockBytes = []byte {
316+ 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
317+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
318+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
319+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
320+ 0x00 , 0x00 , 0x00 , 0x00 , 0x3b , 0xa3 , 0xed , 0xfd , /* |....;...| */
321+ 0x7a , 0x7b , 0x12 , 0xb2 , 0x7a , 0xc7 , 0x2c , 0x3e , /* |z{..z.,>| */
322+ 0x67 , 0x76 , 0x8f , 0x61 , 0x7f , 0xc8 , 0x1b , 0xc3 , /* |gv.a....| */
323+ 0x88 , 0x8a , 0x51 , 0x32 , 0x3a , 0x9f , 0xb8 , 0xaa , /* |..Q2:...| */
324+ 0x4b , 0x1e , 0x5e , 0x4a , 0x34 , 0x6f , 0xa4 , 0x68 , /* |K.^J4o.h| */
325+ 0xff , 0xff , 0x00 , 0x1d , 0x1a , 0xa4 , 0xae , 0x18 , /* |........| */
326+ 0x01 , 0x01 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , /* |........| */
327+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
328+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
329+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , /* |........| */
330+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xff , 0xff , /* |........| */
331+ 0xff , 0xff , 0x4d , 0x04 , 0xff , 0xff , 0x00 , 0x1d , /* |..M.....| */
332+ 0x01 , 0x04 , 0x45 , 0x54 , 0x68 , 0x65 , 0x20 , 0x54 , /* |..EThe T| */
333+ 0x69 , 0x6d , 0x65 , 0x73 , 0x20 , 0x30 , 0x33 , 0x2f , /* |imes 03/| */
334+ 0x4a , 0x61 , 0x6e , 0x2f , 0x32 , 0x30 , 0x30 , 0x39 , /* |Jan/2009| */
335+ 0x20 , 0x43 , 0x68 , 0x61 , 0x6e , 0x63 , 0x65 , 0x6c , /* | Chancel| */
336+ 0x6c , 0x6f , 0x72 , 0x20 , 0x6f , 0x6e , 0x20 , 0x62 , /* |lor on b| */
337+ 0x72 , 0x69 , 0x6e , 0x6b , 0x20 , 0x6f , 0x66 , 0x20 , /* |rink of | */
338+ 0x73 , 0x65 , 0x63 , 0x6f , 0x6e , 0x64 , 0x20 , 0x62 , /* |second b| */
339+ 0x61 , 0x69 , 0x6c , 0x6f , 0x75 , 0x74 , 0x20 , 0x66 , /* |ailout f| */
340+ 0x6f , 0x72 , 0x20 , 0x62 , 0x61 , 0x6e , 0x6b , 0x73 , /* |or banks| */
341+ 0xff , 0xff , 0xff , 0xff , 0x01 , 0x00 , 0xf2 , 0x05 , /* |........| */
342+ 0x2a , 0x01 , 0x00 , 0x00 , 0x00 , 0x43 , 0x41 , 0x04 , /* |*....CA.| */
343+ 0x67 , 0x8a , 0xfd , 0xb0 , 0xfe , 0x55 , 0x48 , 0x27 , /* |g....UH'| */
344+ 0x19 , 0x67 , 0xf1 , 0xa6 , 0x71 , 0x30 , 0xb7 , 0x10 , /* |.g..q0..| */
345+ 0x5c , 0xd6 , 0xa8 , 0x28 , 0xe0 , 0x39 , 0x09 , 0xa6 , /* |\..(.9..| */
346+ 0x79 , 0x62 , 0xe0 , 0xea , 0x1f , 0x61 , 0xde , 0xb6 , /* |yb...a..| */
347+ 0x49 , 0xf6 , 0xbc , 0x3f , 0x4c , 0xef , 0x38 , 0xc4 , /* |I..?L.8.| */
348+ 0xf3 , 0x55 , 0x04 , 0xe5 , 0x1e , 0xc1 , 0x12 , 0xde , /* |.U......| */
349+ 0x5c , 0x38 , 0x4d , 0xf7 , 0xba , 0x0b , 0x8d , 0x57 , /* |\8M....W| */
350+ 0x8a , 0x4c , 0x70 , 0x2b , 0x6b , 0xf1 , 0x1d , 0x5f , /* |.Lp+k.._| */
351+ 0xac , 0x00 , 0x00 , 0x00 , 0x00 , /* |.....| */
352+ }
0 commit comments