text
stringlengths 0
14.1k
|
---|
} |
// Ensure transactions are properly cleared. |
msg.ClearTransactions() |
if len(msg.Transactions) != 0 { |
t.Errorf(""ClearTransactions: wrong transactions - got %v, want %v"", |
len(msg.Transactions), 0) |
} |
// Ensure stake transactions are added properly. |
stx := testBlock.STransactions[0].Copy() |
msg.AddSTransaction(stx) |
if !reflect.DeepEqual(msg.STransactions, testBlock.STransactions) { |
t.Errorf(""AddSTransaction: wrong transactions - got %v, want %v"", |
spew.Sdump(msg.STransactions), |
spew.Sdump(testBlock.STransactions)) |
} |
// Ensure transactions are properly cleared. |
msg.ClearSTransactions() |
if len(msg.STransactions) != 0 { |
t.Errorf(""ClearTransactions: wrong transactions - got %v, want %v"", |
len(msg.STransactions), 0) |
} |
return |
} |
// TestBlockTxShas tests the ability to generate a slice of all transaction |
// hashes from a block accurately. |
func TestBlockTxShas(t *testing.T) { |
// Block 1, transaction 1 hash. |
hashStr := ""55a25248c04dd8b6599ca2a708413c00d79ae90ce075c54e8a967a647d7e4bea"" |
wantHash, err := chainhash.NewHashFromStr(hashStr) |
if err != nil { |
t.Errorf(""NewShaHashFromStr: %v"", err) |
return |
} |
wantShas := []chainhash.Hash{*wantHash} |
shas := testBlock.TxShas() |
if !reflect.DeepEqual(shas, wantShas) { |
t.Errorf(""TxShas: wrong transaction hashes - got %v, want %v"", |
spew.Sdump(shas), spew.Sdump(wantShas)) |
} |
} |
// TestBlockSTxShas tests the ability to generate a slice of all stake transaction |
// hashes from a block accurately. |
func TestBlockSTxShas(t *testing.T) { |
// Block 1, transaction 1 hash. |
hashStr := ""ae208a69f3ee088d0328126e3d9bef7652b108d1904f27b166c5999233a801d4"" |
wantHash, err := chainhash.NewHashFromStr(hashStr) |
if err != nil { |
t.Errorf(""NewShaHashFromStr: %v"", err) |
return |
} |
wantShas := []chainhash.Hash{*wantHash} |
shas := testBlock.STxShas() |
if !reflect.DeepEqual(shas, wantShas) { |
t.Errorf(""STxShas: wrong transaction hashes - got %v, want %v"", |
spew.Sdump(shas), spew.Sdump(wantShas)) |
} |
} |
// TestBlockSha tests the ability to generate the hash of a block accurately. |
func TestBlockSha(t *testing.T) { |
// Block 1 hash. |
hashStr := ""152437dada95368c42b19febc1702939fa9c1ccdb6fd7284e5b7a19d8fe6df7a"" |
wantHash, err := chainhash.NewHashFromStr(hashStr) |
if err != nil { |
t.Errorf(""NewShaHashFromStr: %v"", err) |
} |
// Ensure the hash produced is expected. |
blockHash := testBlock.BlockSha() |
if !blockHash.IsEqual(wantHash) { |
t.Errorf(""BlockSha: wrong hash - got %v, want %v"", |
spew.Sprint(blockHash), spew.Sprint(wantHash)) |
} |
} |
// TestBlockWire tests the MsgBlock wire encode and decode for various numbers |
// of transaction inputs and outputs and protocol versions. |
func TestBlockWire(t *testing.T) { |
tests := []struct { |
in *wire.MsgBlock // Message to encode |
out *wire.MsgBlock // Expected decoded message |
buf []byte // Wire encoding |
txLocs []wire.TxLoc // Expected transaction locations |
sTxLocs []wire.TxLoc // Expected stake transaction locations |
pver uint32 // Protocol version for wire encoding |
}{ |
// Latest protocol version. |
{ |
&testBlock, |
&testBlock, |
testBlockBytes, |
testBlockTxLocs, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.