MCPcopy Create free account
hub / github.com/CPChain/chain / TestBlockEncodingBuildHex

Function TestBlockEncodingBuildHex

types/block_test.go:73–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestBlockEncodingBuildHex(t *testing.T) {
74
75 tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), 50000, big.NewInt(10), nil)
76
77 tx1, _ = tx1.WithSignature(HomesteadSigner{}, common.Hex2Bytes("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b100"))
78
79 newHeader := &Header{
80 ParentHash: common.HexToHash("0x83cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55"),
81 Coinbase: common.HexToAddress("0x8888f1F195AFa192CfeE860698584c030f4c9dB1"),
82 StateRoot: common.HexToHash("0xef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017"),
83 TxsRoot: common.HexToHash("0x5fe50b260da63ø08036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67"),
84 ReceiptsRoot: common.HexToHash("0xbc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52"),
85 Number: big.NewInt(1),
86 GasLimit: uint64(3141592),
87 GasUsed: uint64(21000),
88 Time: big.NewInt(1426516743),
89 }
90
91 newBlock := NewBlockWithHeader(newHeader)
92 var xx1 []*Transaction = make([]*Transaction, 1)
93 xx1[0] = tx1
94 newBlock.transactions = xx1
95
96 bb, _ := rlp.EncodeToBytes(newBlock)
97 hex := common.Bytes2Hex(bb)
98
99 expected := "f90259f901f2a083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a000000000000000000000000000000000000000000000000000005fe50b260da6a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001832fefd8825208845506eb0780f846b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0c0c0f862f86080800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1"
100 assert.Equal(t, expected, hex)
101}
102
103var (
104 addr1 = common.HexToAddress("0xef3dd127de235f15ffb4fc0d71469d1339df6465")

Callers

nothing calls this directly

Calls 4

WithSignatureMethod · 0.95
NewTransactionFunction · 0.85
NewBlockWithHeaderFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected