@@ -116,22 +116,21 @@ mod tests {
116
116
const TESTING_MEMORY_LIMIT : Option < Size > = Some ( Size :: mebi ( 16 ) ) ;
117
117
const TESTING_GAS_LIMIT : u64 = 500_000_000 ;
118
118
119
+ const SOME_WAT : & str = r#"(module
120
+ (type $t0 (func (param i32) (result i32)))
121
+ (func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32)
122
+ get_local $p0
123
+ i32.const 1
124
+ i32.add))
125
+ "# ;
126
+
119
127
#[ test]
120
128
fn file_system_cache_run ( ) {
121
129
let tmp_dir = TempDir :: new ( ) . unwrap ( ) ;
122
130
let mut cache = unsafe { FileSystemCache :: new ( tmp_dir. path ( ) ) . unwrap ( ) } ;
123
131
124
132
// Create module
125
- let wasm = wat:: parse_str (
126
- r#"(module
127
- (type $t0 (func (param i32) (result i32)))
128
- (func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32)
129
- get_local $p0
130
- i32.const 1
131
- i32.add))
132
- "# ,
133
- )
134
- . unwrap ( ) ;
133
+ let wasm = wat:: parse_str ( SOME_WAT ) . unwrap ( ) ;
135
134
let checksum = Checksum :: generate ( & wasm) ;
136
135
137
136
// Module does not exist
@@ -160,4 +159,22 @@ mod tests {
160
159
assert_eq ! ( result[ 0 ] . unwrap_i32( ) , 43 ) ;
161
160
}
162
161
}
162
+
163
+ #[ test]
164
+ fn file_system_cache_store_uses_expected_path ( ) {
165
+ let tmp_dir = TempDir :: new ( ) . unwrap ( ) ;
166
+ let mut cache = unsafe { FileSystemCache :: new ( tmp_dir. path ( ) ) . unwrap ( ) } ;
167
+
168
+ // Create module
169
+ let wasm = wat:: parse_str ( SOME_WAT ) . unwrap ( ) ;
170
+ let checksum = Checksum :: generate ( & wasm) ;
171
+
172
+ // Store module
173
+ let module = compile ( & wasm, None , & [ ] ) . unwrap ( ) ;
174
+ cache. store ( & checksum, & module) . unwrap ( ) ;
175
+
176
+ let file_path = format ! ( "{}/v1/{}" , tmp_dir. path( ) . to_string_lossy( ) , checksum) ;
177
+ let serialized_module = fs:: read ( file_path) . unwrap ( ) ;
178
+ assert_eq ! ( serialized_module. len( ) , 1040 ) ;
179
+ }
163
180
}
0 commit comments