@@ -503,41 +503,43 @@ mod test {
503
503
assert_eq ! ( gas_used, 800013 as u64 ) ;
504
504
}
505
505
506
- // #[test]
507
- // fn test_ask_count_gas_used() {
508
- // let wasm = wat2wasm(
509
- // r#"(module
510
- // (type (func (param i64 i64 i64 i64)))
511
- // (import "env" "ask_external_data" (func $ask_external_data (type 0)))
512
- // (func
513
- // (local $idx i32)
514
- // (i64.const 1)
515
- // (i64.const 1)
516
- // (i64.const 1048576)
517
- // (i64.const 4)
518
- // call 0
519
- // (local.set $idx (i32.const 0))
520
- // (block
521
- // (loop
522
- // (local.set $idx (local.get $idx) (i32.const 1) (i32.add) )
523
- // (br_if 0 (i32.lt_u (local.get $idx) (i32.const 100000)))
524
- // )
525
- // )
526
- // )
527
- // (func (;"execute": Resolves with result "beeb";)
528
- // )
529
- // (memory 17)
530
- // (data (i32.const 1048576) "beeb") (;str = "beeb";)
531
- // (export "prepare" (func 1))
532
- // (export "execute" (func 2)))
533
- // "#,
534
- // );
535
- // let code = compile(&wasm).unwrap();
536
- // let mut cache = Cache::new(CacheOptions { cache_size: 10000 });
537
- // let env = MockEnv {};
538
- // let gas_used = run(&mut cache, &code, 4294967290, true, env).unwrap();
539
- // assert_eq!(gas_used, 1000015 as u32);
540
- // }
506
+ #[ test]
507
+ fn test_ask_count_gas_used ( ) {
508
+ let wasm = wat2wasm (
509
+ r#"(module
510
+ (type (func (param i64 i64 i64 i64) (result)))
511
+ (import "env" "ask_external_data" (func (type 0)))
512
+ (func
513
+ (local $idx i32)
514
+
515
+ (i64.const 1)
516
+ (i64.const 1)
517
+ (i64.const 1048576)
518
+ (i64.const 4)
519
+ call 0
520
+
521
+ (local.set $idx (i32.const 0))
522
+ (block
523
+ (loop
524
+ (local.set $idx (local.get $idx) (i32.const 1) (i32.add) )
525
+ (br_if 0 (i32.lt_u (local.get $idx) (i32.const 100000)))
526
+ )
527
+ )
528
+ )
529
+ (func (;"execute": Resolves with result "beeb";))
530
+ (memory (export "memory") 17)
531
+ (data (i32.const 1048576) "beeb")
532
+ (export "prepare" (func 1))
533
+ (export "execute" (func 2)))
534
+ "# ,
535
+ ) ;
536
+
537
+ let code = compile ( & wasm) . unwrap ( ) ;
538
+ let mut cache = Cache :: new ( CacheOptions { cache_size : 10000 } ) ;
539
+ let env = MockEnv { } ;
540
+ let gas_used = run ( & mut cache, & code, 4294967290 , true , env) . unwrap ( ) ;
541
+ assert_eq ! ( gas_used, 830018 as u64 ) ;
542
+ }
541
543
542
544
#[ test]
543
545
fn test_inject_memory_no_memory ( ) {
0 commit comments