@@ -29,9 +29,7 @@ const (
29
29
var TESTING_CAPABILITIES = []string {"staking" , "stargate" , "iterator" , "cosmwasm_1_1" , "cosmwasm_1_2" , "cosmwasm_1_3" }
30
30
31
31
func TestInitAndReleaseCache (t * testing.T ) {
32
- tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
33
- require .NoError (t , err )
34
- defer os .RemoveAll (tmpdir )
32
+ tmpdir := t .TempDir ()
35
33
36
34
config := types.VMConfig {
37
35
Cache : types.CacheOptions {
@@ -49,9 +47,7 @@ func TestInitAndReleaseCache(t *testing.T) {
49
47
// wasmd expects us to create the base directory
50
48
// https://github.com/CosmWasm/wasmd/blob/v0.30.0/x/wasm/keeper/keeper.go#L128
51
49
func TestInitCacheWorksForNonExistentDir (t * testing.T ) {
52
- tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
53
- require .NoError (t , err )
54
- defer os .RemoveAll (tmpdir )
50
+ tmpdir := t .TempDir ()
55
51
56
52
createMe := filepath .Join (tmpdir , "does-not-yet-exist" )
57
53
config := types.VMConfig {
@@ -85,9 +81,7 @@ func TestInitCacheErrorsForBrokenDir(t *testing.T) {
85
81
}
86
82
87
83
func TestInitLockingPreventsConcurrentAccess (t * testing.T ) {
88
- tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
89
- require .NoError (t , err )
90
- defer os .RemoveAll (tmpdir )
84
+ tmpdir := t .TempDir ()
91
85
92
86
config1 := types.VMConfig {
93
87
Cache : types.CacheOptions {
@@ -128,15 +122,9 @@ func TestInitLockingPreventsConcurrentAccess(t *testing.T) {
128
122
}
129
123
130
124
func TestInitLockingAllowsMultipleInstancesInDifferentDirs (t * testing.T ) {
131
- tmpdir1 , err := os .MkdirTemp ("" , "wasmvm-testing1" )
132
- require .NoError (t , err )
133
- tmpdir2 , err := os .MkdirTemp ("" , "wasmvm-testing2" )
134
- require .NoError (t , err )
135
- tmpdir3 , err := os .MkdirTemp ("" , "wasmvm-testing3" )
136
- require .NoError (t , err )
137
- defer os .RemoveAll (tmpdir1 )
138
- defer os .RemoveAll (tmpdir2 )
139
- defer os .RemoveAll (tmpdir3 )
125
+ tmpdir1 := t .TempDir ()
126
+ tmpdir2 := t .TempDir ()
127
+ tmpdir3 := t .TempDir ()
140
128
141
129
config1 := types.VMConfig {
142
130
Cache : types.CacheOptions {
@@ -175,9 +163,7 @@ func TestInitLockingAllowsMultipleInstancesInDifferentDirs(t *testing.T) {
175
163
}
176
164
177
165
func TestInitCacheEmptyCapabilities (t * testing.T ) {
178
- tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
179
- require .NoError (t , err )
180
- defer os .RemoveAll (tmpdir )
166
+ tmpdir := t .TempDir ()
181
167
config := types.VMConfig {
182
168
Cache : types.CacheOptions {
183
169
BaseDir : tmpdir ,
@@ -193,8 +179,7 @@ func TestInitCacheEmptyCapabilities(t *testing.T) {
193
179
194
180
func withCache (tb testing.TB ) (Cache , func ()) {
195
181
tb .Helper ()
196
- tmpdir , err := os .MkdirTemp ("" , "wasmvm-testing" )
197
- require .NoError (tb , err )
182
+ tmpdir := tb .TempDir ()
198
183
config := types.VMConfig {
199
184
Cache : types.CacheOptions {
200
185
BaseDir : tmpdir ,
@@ -207,7 +192,6 @@ func withCache(tb testing.TB) (Cache, func()) {
207
192
require .NoError (tb , err )
208
193
209
194
cleanup := func () {
210
- os .RemoveAll (tmpdir )
211
195
ReleaseCache (cache )
212
196
}
213
197
return cache , cleanup
0 commit comments