text
stringlengths 0
14.1k
|
---|
ASTRUNCD, |
ASJMP, |
ASBRANCH, |
ASRET, |
ASCALL, |
ASCALLE, |
ASCALLEX, |
ASPAR, |
ASPARE, |
ASALLOC, |
ASFORM, |
ASCOPYB, |
ASCOPYH, |
ASCOPYW, |
ASCOPYL, |
ASCOPYS, |
ASCOPYD, |
ASVSTAR, |
ASVARG, |
}; |
" isc |
Dirbaio/btcd wire/msgblock_test.go 28011 "// Copyright (c) 2013-2015 The btcsuite developers |
// Copyright (c) 2015 The Decred developers |
// Use of this source code is governed by an ISC |
// license that can be found in the LICENSE file. |
package wire_test |
import ( |
""bytes"" |
""io"" |
""reflect"" |
""testing"" |
""time"" |
""github.com/davecgh/go-spew/spew"" |
""github.com/decred/dcrd/chaincfg/chainhash"" |
""github.com/decred/dcrd/wire"" |
""github.com/decred/dcrutil"" |
) |
// TestBlock tests the MsgBlock API. |
func TestBlock(t *testing.T) { |
pver := wire.ProtocolVersion |
// Test block header. |
bh := wire.NewBlockHeader( |
int32(pver), // Version |
&testBlock.Header.PrevBlock, // PrevHash |
&testBlock.Header.MerkleRoot, // MerkleRoot |
&testBlock.Header.StakeRoot, // StakeRoot |
uint16(0x0000), // VoteBits |
[6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // FinalState |
uint16(0x0000), // Voters |
uint8(0x00), // FreshStake |
uint8(0x00), // Revocations |
uint32(0), // Poolsize |
testBlock.Header.Bits, // Bits |
int64(0x0000000000000000), // Sbits |
uint32(1), // Height |
uint32(1), // Size |
testBlock.Header.Nonce, // Nonce |
[36]byte{}, // ExtraData |
) |
// Ensure the command is expected value. |
wantCmd := ""block"" |
msg := wire.NewMsgBlock(bh) |
if cmd := msg.Command(); cmd != wantCmd { |
t.Errorf(""NewMsgBlock: wrong command - got %v want %v"", |
cmd, wantCmd) |
} |
// Ensure max payload is expected value for latest protocol version. |
// Num addresses (varInt) + max allowed addresses. |
wantPayload := uint32(1000000) |
maxPayload := msg.MaxPayloadLength(pver) |
if maxPayload != wantPayload { |
t.Errorf(""MaxPayloadLength: wrong max payload length for ""+ |
""protocol version %d - got %v, want %v"", pver, |
maxPayload, wantPayload) |
} |
// Ensure we get the same block header data back out. |
if !reflect.DeepEqual(&msg.Header, bh) { |
t.Errorf(""NewMsgBlock: wrong block header - got %v, want %v"", |
spew.Sdump(&msg.Header), spew.Sdump(bh)) |
} |
// Ensure transactions are added properly. |
tx := testBlock.Transactions[0].Copy() |
msg.AddTransaction(tx) |
if !reflect.DeepEqual(msg.Transactions, testBlock.Transactions) { |
t.Errorf(""AddTransaction: wrong transactions - got %v, want %v"", |
spew.Sdump(msg.Transactions), |
spew.Sdump(testBlock.Transactions)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.