@@ -194,9 +194,10 @@ func TestInitCacheEmptyCapabilities(t *testing.T) {
194
194
ReleaseCache (cache )
195
195
}
196
196
197
- func withCache (t testing.TB ) (Cache , func ()) {
197
+ func withCache (tb testing.TB ) (Cache , func ()) {
198
+ tb .Helper ()
198
199
tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
199
- require .NoError (t , err )
200
+ require .NoError (tb , err )
200
201
config := types.VMConfig {
201
202
Cache : types.CacheOptions {
202
203
BaseDir : tmpdir ,
@@ -206,7 +207,7 @@ func withCache(t testing.TB) (Cache, func()) {
206
207
},
207
208
}
208
209
cache , err := InitCache (config )
209
- require .NoError (t , err )
210
+ require .NoError (tb , err )
210
211
211
212
cleanup := func () {
212
213
os .RemoveAll (tmpdir )
@@ -848,9 +849,7 @@ func Benchmark100ConcurrentContractCalls(b *testing.B) {
848
849
errChan := make (chan error , callCount )
849
850
resChan := make (chan []byte , callCount )
850
851
wg .Add (callCount )
851
- testMutex .Lock ()
852
- info = MockInfoBin (b , "fred" )
853
- testMutex .Unlock ()
852
+ info = mockInfoBinNoAssert ("fred" )
854
853
for i := 0 ; i < callCount ; i ++ {
855
854
go func () {
856
855
defer wg .Done ()
@@ -1172,6 +1171,7 @@ func TestReplyAndQuery(t *testing.T) {
1172
1171
}
1173
1172
1174
1173
func requireOkResponse (tb testing.TB , res []byte , expectedMsgs int ) {
1174
+ tb .Helper ()
1175
1175
var result types.ContractResult
1176
1176
err := json .Unmarshal (res , & result )
1177
1177
require .NoError (tb , err )
@@ -1180,6 +1180,7 @@ func requireOkResponse(tb testing.TB, res []byte, expectedMsgs int) {
1180
1180
}
1181
1181
1182
1182
func requireQueryError (t * testing.T , res []byte ) {
1183
+ t .Helper ()
1183
1184
var result types.QueryResult
1184
1185
err := json .Unmarshal (res , & result )
1185
1186
require .NoError (t , err )
@@ -1188,6 +1189,7 @@ func requireQueryError(t *testing.T, res []byte) {
1188
1189
}
1189
1190
1190
1191
func requireQueryOk (t * testing.T , res []byte ) []byte {
1192
+ t .Helper ()
1191
1193
var result types.QueryResult
1192
1194
err := json .Unmarshal (res , & result )
1193
1195
require .NoError (t , err )
@@ -1196,36 +1198,43 @@ func requireQueryOk(t *testing.T, res []byte) []byte {
1196
1198
return result .Ok
1197
1199
}
1198
1200
1199
- func createHackatomContract (t testing.TB , cache Cache ) []byte {
1200
- return createContract (t , cache , "../../testdata/hackatom.wasm" )
1201
+ func createHackatomContract (tb testing.TB , cache Cache ) []byte {
1202
+ tb .Helper ()
1203
+ return createContract (tb , cache , "../../testdata/hackatom.wasm" )
1201
1204
}
1202
1205
1203
- func createCyberpunkContract (t testing.TB , cache Cache ) []byte {
1204
- return createContract (t , cache , "../../testdata/cyberpunk.wasm" )
1206
+ func createCyberpunkContract (tb testing.TB , cache Cache ) []byte {
1207
+ tb .Helper ()
1208
+ return createContract (tb , cache , "../../testdata/cyberpunk.wasm" )
1205
1209
}
1206
1210
1207
- func createQueueContract (t testing.TB , cache Cache ) []byte {
1208
- return createContract (t , cache , "../../testdata/queue.wasm" )
1211
+ func createQueueContract (tb testing.TB , cache Cache ) []byte {
1212
+ tb .Helper ()
1213
+ return createContract (tb , cache , "../../testdata/queue.wasm" )
1209
1214
}
1210
1215
1211
- func createReflectContract (t testing.TB , cache Cache ) []byte {
1212
- return createContract (t , cache , "../../testdata/reflect.wasm" )
1216
+ func createReflectContract (tb testing.TB , cache Cache ) []byte {
1217
+ tb .Helper ()
1218
+ return createContract (tb , cache , "../../testdata/reflect.wasm" )
1213
1219
}
1214
1220
1215
- func createFloaty2 (t testing.TB , cache Cache ) []byte {
1216
- return createContract (t , cache , "../../testdata/floaty_2.0.wasm" )
1221
+ func createFloaty2 (tb testing.TB , cache Cache ) []byte {
1222
+ tb .Helper ()
1223
+ return createContract (tb , cache , "../../testdata/floaty_2.0.wasm" )
1217
1224
}
1218
1225
1219
- func createContract (t testing.TB , cache Cache , wasmFile string ) []byte {
1226
+ func createContract (tb testing.TB , cache Cache , wasmFile string ) []byte {
1227
+ tb .Helper ()
1220
1228
wasm , err := os .ReadFile (wasmFile )
1221
- require .NoError (t , err )
1229
+ require .NoError (tb , err )
1222
1230
checksum , err := StoreCode (cache , wasm , true )
1223
- require .NoError (t , err )
1231
+ require .NoError (tb , err )
1224
1232
return checksum
1225
1233
}
1226
1234
1227
1235
// exec runs the handle tx with the given signer
1228
1236
func exec (t * testing.T , cache Cache , checksum []byte , signer types.HumanAddress , store types.KVStore , api * types.GoAPI , querier Querier , gasExpected uint64 ) types.ContractResult {
1237
+ t .Helper ()
1229
1238
gasMeter := NewMockGasMeter (TESTING_GAS_LIMIT )
1230
1239
igasMeter := types .GasMeter (gasMeter )
1231
1240
env := MockEnvBin (t )
@@ -1461,3 +1470,16 @@ func TestFloats(t *testing.T) {
1461
1470
hash := hasher .Sum (nil )
1462
1471
require .Equal (t , "95f70fa6451176ab04a9594417a047a1e4d8e2ff809609b8f81099496bee2393" , hex .EncodeToString (hash ))
1463
1472
}
1473
+
1474
+ // mockInfoBinNoAssert creates the message binary without using testify assertions
1475
+ func mockInfoBinNoAssert (sender types.HumanAddress ) []byte {
1476
+ info := types.MessageInfo {
1477
+ Sender : sender ,
1478
+ Funds : types.Array [types.Coin ]{},
1479
+ }
1480
+ res , err := json .Marshal (info )
1481
+ if err != nil {
1482
+ panic (err )
1483
+ }
1484
+ return res
1485
+ }
0 commit comments