text
stringlengths 0
14.1k
|
---|
0x00, // Revocations |
0x00, 0x00, 0x00, 0x00, // Poolsize |
0xff, 0xff, 0x00, 0x1d, // Bits |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SBits |
0x01, 0x00, 0x00, 0x00, // Height |
0x01, 0x00, 0x00, 0x00, // Size |
0x61, 0xbc, 0x66, 0x49, // Timestamp |
0x01, 0xe3, 0x62, 0x99, // Nonce |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ExtraData |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
0x00, 0x00, 0x00, 0x00, |
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
0xff, // TxnCount |
}, pver, &wire.MessageError{}, |
}, |
} |
t.Logf(""Running %d tests"", len(tests)) |
for i, test := range tests { |
// Decode from wire format. |
var msg wire.MsgBlock |
r := bytes.NewReader(test.buf) |
err := msg.BtcDecode(r, test.pver) |
if reflect.TypeOf(err) != reflect.TypeOf(test.err) { |
t.Errorf(""BtcDecode #%d wrong error got: %v, want: %v"", |
i, err, reflect.TypeOf(test.err)) |
continue |
} |
// Deserialize from wire format. |
r = bytes.NewReader(test.buf) |
err = msg.Deserialize(r) |
if reflect.TypeOf(err) != reflect.TypeOf(test.err) { |
t.Errorf(""Deserialize #%d wrong error got: %v, want: %v"", |
i, err, reflect.TypeOf(test.err)) |
continue |
} |
// Deserialize with transaction location info from wire format. |
br := bytes.NewBuffer(test.buf) |
_, _, err = msg.DeserializeTxLoc(br) |
if reflect.TypeOf(err) != reflect.TypeOf(test.err) { |
t.Errorf(""DeserializeTxLoc #%d wrong error got: %v, ""+ |
""want: %v"", i, err, reflect.TypeOf(test.err)) |
continue |
} |
} |
} |
// TestBlockSerializeSize performs tests to ensure the serialize size for |
// various blocks is accurate. |
func TestBlockSerializeSize(t *testing.T) { |
// Block with no transactions. |
noTxBlock := wire.NewMsgBlock(&testBlock.Header) |
tests := []struct { |
in *wire.MsgBlock // Block to encode |
size int // Expected serialized size |
}{ |
// Block with no transactions (header + 2x numtx) |
{noTxBlock, 182}, |
// First block in the mainnet block chain. |
{&testBlock, len(testBlockBytes)}, |
} |
t.Logf(""Running %d tests"", len(tests)) |
for i, test := range tests { |
serializedSize := test.in.SerializeSize() |
if serializedSize != test.size { |
t.Errorf(""MsgBlock.SerializeSize: #%d got: %d, want: ""+ |
""%d"", i, serializedSize, test.size) |
continue |
} |
} |
} |
// testBlock is a basic normative block that is used throughout tests. |
var testBlock = wire.MsgBlock{ |
Header: wire.BlockHeader{ |
Version: 1, |
PrevBlock: chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. |
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, |
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, |
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, |
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, |
}), |
MerkleRoot: chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. |
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44, |
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67, |
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1, |
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, |
}), |
StakeRoot: chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. |
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44, |
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67, |
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1, |
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.