MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestWALEncoderDecoder

Function TestWALEncoderDecoder

consensus/wal_test.go:83–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestWALEncoderDecoder(t *testing.T) {
84 now := tmtime.Now()
85 msgs := []TimedWALMessage{
86 {Time: now, Msg: EndHeightMessage{0}},
87 {Time: now, Msg: timeoutInfo{Duration: time.Second, Height: 1, Round: 1, Step: types.RoundStepPropose}},
88 {Time: now, Msg: tmtypes.EventDataRoundState{Height: 1, Round: 1, Step: ""}},
89 }
90
91 b := new(bytes.Buffer)
92
93 for _, msg := range msgs {
94 msg := msg
95
96 b.Reset()
97
98 enc := NewWALEncoder(b)
99 err := enc.Encode(&msg)
100 require.NoError(t, err)
101
102 dec := NewWALDecoder(b)
103 decoded, err := dec.Decode()
104 require.NoError(t, err)
105 assert.Equal(t, msg.Time.UTC(), decoded.Time)
106 assert.Equal(t, msg.Msg, decoded.Msg)
107 }
108}
109
110func TestWALWrite(t *testing.T) {
111 walDir, err := os.MkdirTemp("", "wal")

Callers

nothing calls this directly

Calls 6

EncodeMethod · 0.95
DecodeMethod · 0.95
NewWALEncoderFunction · 0.70
NewWALDecoderFunction · 0.70
ResetMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected