Skip to content

TestMessages68 / TestEmptyMessages68

Source (upstream pre-purge) Current
File eth/protocols/eth/protocol_test.go protocol_pow_test.go
Symbol TestMessages TestMessages68
Ref 723aae2b4~1 etc/v1.17.4-full-node

Revival of the ETH68 rows #33511 deleted from the upstream table-driven protocol tests, extracted into standalone functions because the rows live inside upstream test bodies that cannot be extended without touching the file. Carries upstream's golden hex vectors verbatim, including the pair that matters most here: ReceiptsPacket68 built from NewReceiptList68 and ReceiptsRLPPacket built from rlp.EncodeToBytes(types.Receipts) must encode to the SAME bytes ("Identical to the eth/68 encoding above", upstream's own comment). That is the wire-compatibility guarantee for core-geth peers, and it is what pins the raw ServiceGetReceiptsQuery68 serving path to the decode-and-re-encode output the fork shipped before. The receipts fixture and the loop bodies are verbatim; only the surrounding declarations were narrowed to the variables the ETH68 rows actually use.

3-way merge — purge → getc ← upstream

pre-purgecommon≈ adapted (origin inferred by similarity)fork-only
func TestMessages68(t *testing.T) {
// Some basic structs used during testing
var (
receipts []*types.Receipt
receiptsRlp rlp.RawValue
)
// init the receipts
{
receipts = []*types.Receipt{
{
Status: types.ReceiptStatusFailed,
CumulativeGasUsed: 333,
Logs: []*types.Log{
{
Address: common.BytesToAddress([]byte{0x11}),
Topics: []common.Hash{common.HexToHash("dead"), common.HexToHash("beef")},
Data: []byte{0x01, 0x00, 0xff},
},
},
},
{
Status: types.ReceiptStatusSuccessful,
CumulativeGasUsed: 444,
Logs: []*types.Log{
{
Address: common.BytesToAddress([]byte{0x22}),
Topics: []common.Hash{common.HexToHash("05668"), common.HexToHash("9773")},
Data: []byte{0x02, 0x0f, 0x0f, 0x0f, 0x06, 0x08},
},
},
},
}
miniDeriveFields(receipts[0], 0)
miniDeriveFields(receipts[1], 1)
rlpData, err := rlp.EncodeToBytes(receipts)
if err != nil {
t.Fatal(err)
}
receiptsRlp = rlpData
}
for i, tc := range []struct {
message interface{}
want []byte
}{
{
ReceiptsPacket68{1111, encodeRL([]*ReceiptList68{NewReceiptList68(receipts)})},
common.FromHex("f902e6820457f902e0f902ddf901688082014db9010000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000004000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ffb9016f01f9016b018201bcb9010000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000001000000000000000000000000000000000000000000000000040000000000000000000000000004000000000000000000000000000000000000000000000000000000008000400000000000000000000000000000000000000000000000000000000000000000000000000000040f862f860940000000000000000000000000000000000000022f842a00000000000000000000000000000000000000000000000000000000000005668a0000000000000000000000000000000000000000000000000000000000000977386020f0f0f0608"),
},
{
// Identical to the eth/68 encoding above.
ReceiptsRLPPacket{1111, ReceiptsRLPResponse([]rlp.RawValue{receiptsRlp})},
common.FromHex("f902e6820457f902e0f902ddf901688082014db9010000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000004000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ffb9016f01f9016b018201bcb9010000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000001000000000000000000000000000000000000000000000000040000000000000000000000000004000000000000000000000000000000000000000000000000000000008000400000000000000000000000000000000000000000000000000000000000000000000000000000040f862f860940000000000000000000000000000000000000022f842a00000000000000000000000000000000000000000000000000000000000005668a0000000000000000000000000000000000000000000000000000000000000977386020f0f0f0608"),
},
} {
if have, _ := rlp.EncodeToBytes(tc.message); !bytes.Equal(have, tc.want) {
t.Errorf("test %d, type %T, have\n\t%x\nwant\n\t%x", i, tc.message, have, tc.want)
}
}
}

← eth Protocol