mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
packet test
This commit is contained in:
parent
d2baa38f9c
commit
d177a32930
@ -142,10 +142,11 @@ func EncodePooledTransactions66(txsRlp [][]byte, requestId uint64, encodeBuf []b
|
||||
dataLen := rlp.U64Len(requestId) + rlp.ListPrefixLen(txsRlpLen) + txsRlpLen
|
||||
|
||||
encodeBuf = ensureEnoughSize(encodeBuf, rlp.ListPrefixLen(dataLen)+dataLen)
|
||||
|
||||
// Length Prefix for the entire structure
|
||||
pos += rlp.EncodeListPrefix(dataLen, encodeBuf[pos:])
|
||||
pos += rlp.EncodeU64(requestId, encodeBuf[pos:])
|
||||
pos += rlp.ListPrefixLen(txsRlpLen)
|
||||
pos += rlp.EncodeListPrefix(txsRlpLen, encodeBuf[pos:])
|
||||
for i := range txsRlp {
|
||||
copy(encodeBuf[pos:], txsRlp[i])
|
||||
pos += len(txsRlp[i])
|
||||
|
@ -109,3 +109,30 @@ func TestEncodeGPT66(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var ptp66EncodeTests = []struct {
|
||||
txs [][]byte
|
||||
encoded string
|
||||
requestId uint64
|
||||
expectedErr bool
|
||||
}{
|
||||
{
|
||||
txs: [][]byte{
|
||||
decodeHex("f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10"),
|
||||
decodeHex("f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb"),
|
||||
},
|
||||
encoded: "f8d7820457f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afb", requestId: 1111, expectedErr: false},
|
||||
}
|
||||
|
||||
func TestPooledTransactionsPacket66(t *testing.T) {
|
||||
for i, tt := range ptp66EncodeTests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
var encodeBuf []byte
|
||||
var err error
|
||||
encodeBuf = EncodePooledTransactions66(tt.txs, tt.requestId, encodeBuf)
|
||||
require.Equal(tt.expectedErr, err != nil)
|
||||
require.Equal(tt.encoded, fmt.Sprintf("%x", encodeBuf))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user