@@ -136,6 +136,29 @@ func TestStore_GetRangeByHeight_ExpectedRange(t *testing.T) {
136
136
assert .Equal (t , lastHeaderInRangeHeight , out [len (out )- 1 ].Height ())
137
137
}
138
138
139
+ func TestStore_Append_BadHeader (t * testing.T ) {
140
+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
141
+ t .Cleanup (cancel )
142
+
143
+ suite := headertest .NewTestSuite (t )
144
+
145
+ ds := sync .MutexWrap (datastore .NewMapDatastore ())
146
+ store , err := NewStoreWithHead (ctx , ds , suite .Head ())
147
+ require .NoError (t , err )
148
+
149
+ err = store .Start (ctx )
150
+ require .NoError (t , err )
151
+
152
+ head , err := store .Head (ctx )
153
+ require .NoError (t , err )
154
+ assert .EqualValues (t , suite .Head ().Hash (), head .Hash ())
155
+
156
+ in := suite .GenDummyHeaders (10 )
157
+ in [0 ].VerifyFailure = true
158
+ err = store .Append (ctx , in ... )
159
+ require .Error (t , err )
160
+ }
161
+
139
162
// TestStore_GetRange tests possible combinations of requests and ensures that
140
163
// the store can handle them adequately (even malformed requests)
141
164
func TestStore_GetRange (t * testing.T ) {
@@ -159,7 +182,7 @@ func TestStore_GetRange(t *testing.T) {
159
182
err = store .Append (ctx , in ... )
160
183
require .NoError (t , err )
161
184
162
- var tests = []struct {
185
+ tests : = []struct {
163
186
name string
164
187
from uint64
165
188
to uint64
@@ -212,7 +235,6 @@ func TestStore_GetRange(t *testing.T) {
212
235
assert .Equal (t , lastHeaderInRangeHeight , out [len (out )- 1 ].Height ())
213
236
})
214
237
}
215
-
216
238
}
217
239
218
240
func TestStorePendingCacheMiss (t * testing.T ) {
0 commit comments