@@ -186,6 +186,28 @@ func TestStoreCodeUnchecked(t *testing.T) {
186
186
require .Equal (t , wasm , code )
187
187
}
188
188
189
+ func TestStoreCodeUncheckedWorksWithInvalidWasm (t * testing.T ) {
190
+ cache , cleanup := withCache (t )
191
+ defer cleanup ()
192
+
193
+ wasm , err := os .ReadFile ("../../testdata/hackatom.wasm" )
194
+ require .NoError (t , err )
195
+
196
+ // Look for "interface_version_8" in the wasm file and replace it with "interface_version_9".
197
+ // This makes the wasm file invalid.
198
+ wasm = bytes .Replace (wasm , []byte ("interface_version_8" ), []byte ("interface_version_9" ), 1 )
199
+
200
+ // StoreCode should fail
201
+ _ , err = StoreCode (cache , wasm , true )
202
+ require .ErrorContains (t , err , "Wasm contract has unknown interface_version_* marker export" )
203
+
204
+ // StoreCodeUnchecked should not fail
205
+ checksum , err := StoreCodeUnchecked (cache , wasm )
206
+ require .NoError (t , err )
207
+ expectedChecksum := sha256 .Sum256 (wasm )
208
+ assert .Equal (t , expectedChecksum [:], checksum )
209
+ }
210
+
189
211
func TestPin (t * testing.T ) {
190
212
cache , cleanup := withCache (t )
191
213
defer cleanup ()
0 commit comments