@@ -274,6 +274,28 @@ func TestStoreCodeUnchecked(t *testing.T) {
274
274
require .Equal (t , wasm , code )
275
275
}
276
276
277
+ func TestStoreCodeUncheckedWorksWithInvalidWasm (t * testing.T ) {
278
+ cache , cleanup := withCache (t )
279
+ defer cleanup ()
280
+
281
+ wasm , err := os .ReadFile ("../../testdata/hackatom.wasm" )
282
+ require .NoError (t , err )
283
+
284
+ // Look for "interface_version_8" in the wasm file and replace it with "interface_version_9".
285
+ // This makes the wasm file invalid.
286
+ wasm = bytes .Replace (wasm , []byte ("interface_version_8" ), []byte ("interface_version_9" ), 1 )
287
+
288
+ // StoreCode should fail
289
+ _ , err = StoreCode (cache , wasm , true )
290
+ require .ErrorContains (t , err , "Wasm contract has unknown interface_version_* marker export" )
291
+
292
+ // StoreCodeUnchecked should not fail
293
+ checksum , err := StoreCodeUnchecked (cache , wasm )
294
+ require .NoError (t , err )
295
+ expectedChecksum := sha256 .Sum256 (wasm )
296
+ assert .Equal (t , expectedChecksum [:], checksum )
297
+ }
298
+
277
299
func TestPin (t * testing.T ) {
278
300
cache , cleanup := withCache (t )
279
301
defer cleanup ()
0 commit comments