mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 13:05:09 +00:00
test: protobuf vectors for reactors (#5221)
## Description Add test vectors for all reactors - [x] state-sync - [x] privval - [x] mempool - [x] p2p - [x] evidence - [ ] light? this PR is primarily oriented at testvectors for things going over the wire. should we expand the testvectors into types as well? Closes: #XXX
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package statesync
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
@@ -81,3 +82,26 @@ func TestValidateMsg(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:lll // ignore line length
|
||||
func TestStateSyncVectors(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
testName string
|
||||
msg proto.Message
|
||||
expBytes string
|
||||
}{
|
||||
{"SnapshotsRequest", &ssproto.SnapshotsRequest{}, "0a00"},
|
||||
{"SnapshotsResponse", &ssproto.SnapshotsResponse{Height: 1, Format: 2, Chunks: 3, Hash: []byte("chuck hash"), Metadata: []byte("snapshot metadata")}, "1225080110021803220a636875636b20686173682a11736e617073686f74206d65746164617461"},
|
||||
{"ChunkRequest", &ssproto.ChunkRequest{Height: 1, Format: 2, Index: 3}, "1a06080110021803"},
|
||||
{"ChunkResponse", &ssproto.ChunkResponse{Height: 1, Format: 2, Index: 3, Chunk: []byte("it's a chunk")}, "2214080110021803220c697427732061206368756e6b"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
bz := mustEncodeMsg(tc.msg)
|
||||
|
||||
require.Equal(t, tc.expBytes, hex.EncodeToString(bz), tc.testName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user