MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestWALEncoderDecoder

Function TestWALEncoderDecoder

internal/consensus/wal_test.go:79–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…