@@ -626,10 +626,10 @@ mod tests {
626
626
} ;
627
627
const TESTING_MEMORY_CACHE_SIZE : Size = Size :: mebi ( 200 ) ;
628
628
629
- static CONTRACT : & [ u8 ] = include_bytes ! ( "../testdata/hackatom.wasm" ) ;
630
- static IBC_CONTRACT : & [ u8 ] = include_bytes ! ( "../testdata/ibc_reflect.wasm" ) ;
631
- static IBC2_CONTRACT : & [ u8 ] = include_bytes ! ( "../testdata/ibc2.wasm" ) ;
632
- static EMPTY_CONTRACT : & [ u8 ] = include_bytes ! ( "../testdata/empty.wasm" ) ;
629
+ static HACKATOM : & [ u8 ] = include_bytes ! ( "../testdata/hackatom.wasm" ) ;
630
+ static IBC_REFLECT : & [ u8 ] = include_bytes ! ( "../testdata/ibc_reflect.wasm" ) ;
631
+ static IBC2 : & [ u8 ] = include_bytes ! ( "../testdata/ibc2.wasm" ) ;
632
+ static EMPTY : & [ u8 ] = include_bytes ! ( "../testdata/empty.wasm" ) ;
633
633
// Invalid because it doesn't contain required memory and exports
634
634
static INVALID_CONTRACT_WAT : & str = r#"(module
635
635
(type $t0 (func (param i32) (result i32)))
@@ -719,14 +719,14 @@ mod tests {
719
719
fn store_code_checked_works ( ) {
720
720
let cache: Cache < MockApi , MockStorage , MockQuerier > =
721
721
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
722
- cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
722
+ cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
723
723
}
724
724
725
725
#[ test]
726
726
fn store_code_without_persist_works ( ) {
727
727
let cache: Cache < MockApi , MockStorage , MockQuerier > =
728
728
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
729
- let checksum = cache. store_code ( CONTRACT , true , false ) . unwrap ( ) ;
729
+ let checksum = cache. store_code ( HACKATOM , true , false ) . unwrap ( ) ;
730
730
731
731
assert ! (
732
732
cache. load_wasm( & checksum) . is_err( ) ,
@@ -739,8 +739,8 @@ mod tests {
739
739
fn store_code_allows_saving_multiple_times ( ) {
740
740
let cache: Cache < MockApi , MockStorage , MockQuerier > =
741
741
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
742
- cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
743
- cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
742
+ cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
743
+ cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
744
744
}
745
745
746
746
#[ test]
@@ -764,7 +764,7 @@ mod tests {
764
764
// memory cache before the init call.
765
765
766
766
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
767
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
767
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
768
768
769
769
let backend = mock_backend ( & [ ] ) ;
770
770
let _ = cache
@@ -780,7 +780,7 @@ mod tests {
780
780
fn store_code_unchecked_works ( ) {
781
781
let cache: Cache < MockApi , MockStorage , MockQuerier > =
782
782
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
783
- cache. store_code ( CONTRACT , false , true ) . unwrap ( ) ;
783
+ cache. store_code ( HACKATOM , false , true ) . unwrap ( ) ;
784
784
}
785
785
786
786
#[ test]
@@ -796,10 +796,10 @@ mod tests {
796
796
fn load_wasm_works ( ) {
797
797
let cache: Cache < MockApi , MockStorage , MockQuerier > =
798
798
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
799
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
799
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
800
800
801
801
let restored = cache. load_wasm ( & checksum) . unwrap ( ) ;
802
- assert_eq ! ( restored, CONTRACT ) ;
802
+ assert_eq ! ( restored, HACKATOM ) ;
803
803
}
804
804
805
805
#[ test]
@@ -816,7 +816,7 @@ mod tests {
816
816
} ;
817
817
let cache1: Cache < MockApi , MockStorage , MockQuerier > =
818
818
unsafe { Cache :: new ( options1) . unwrap ( ) } ;
819
- id = cache1. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
819
+ id = cache1. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
820
820
}
821
821
822
822
{
@@ -829,7 +829,7 @@ mod tests {
829
829
let cache2: Cache < MockApi , MockStorage , MockQuerier > =
830
830
unsafe { Cache :: new ( options2) . unwrap ( ) } ;
831
831
let restored = cache2. load_wasm ( & id) . unwrap ( ) ;
832
- assert_eq ! ( restored, CONTRACT ) ;
832
+ assert_eq ! ( restored, HACKATOM ) ;
833
833
}
834
834
}
835
835
@@ -861,7 +861,7 @@ mod tests {
861
861
} ;
862
862
let cache: Cache < MockApi , MockStorage , MockQuerier > =
863
863
unsafe { Cache :: new ( options) . unwrap ( ) } ;
864
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
864
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
865
865
866
866
// Corrupt cache file
867
867
let filepath = tmp_dir
@@ -887,7 +887,7 @@ mod tests {
887
887
unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
888
888
889
889
// Store
890
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
890
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
891
891
892
892
// Exists
893
893
cache. load_wasm ( & checksum) . unwrap ( ) ;
@@ -915,7 +915,7 @@ mod tests {
915
915
#[ test]
916
916
fn get_instance_finds_cached_module ( ) {
917
917
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
918
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
918
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
919
919
let backend = mock_backend ( & [ ] ) ;
920
920
let _instance = cache
921
921
. get_instance ( & checksum, backend, TESTING_OPTIONS )
@@ -929,7 +929,7 @@ mod tests {
929
929
#[ test]
930
930
fn get_instance_finds_cached_modules_and_stores_to_memory ( ) {
931
931
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
932
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
932
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
933
933
let backend1 = mock_backend ( & [ ] ) ;
934
934
let backend2 = mock_backend ( & [ ] ) ;
935
935
let backend3 = mock_backend ( & [ ] ) ;
@@ -993,7 +993,7 @@ mod tests {
993
993
fn get_instance_recompiles_module ( ) {
994
994
let options = make_testing_options ( ) ;
995
995
let cache = unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
996
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
996
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
997
997
998
998
// Remove compiled module from disk
999
999
remove_dir_all ( options. base_dir . join ( CACHE_DIR ) . join ( MODULES_DIR ) ) . unwrap ( ) ;
@@ -1022,7 +1022,7 @@ mod tests {
1022
1022
#[ test]
1023
1023
fn call_instantiate_on_cached_contract ( ) {
1024
1024
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1025
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1025
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1026
1026
1027
1027
// from file system
1028
1028
{
@@ -1108,7 +1108,7 @@ mod tests {
1108
1108
#[ test]
1109
1109
fn call_execute_on_cached_contract ( ) {
1110
1110
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1111
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1111
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1112
1112
1113
1113
// from file system
1114
1114
{
@@ -1219,7 +1219,7 @@ mod tests {
1219
1219
fn call_execute_on_recompiled_contract ( ) {
1220
1220
let options = make_testing_options ( ) ;
1221
1221
let cache = unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
1222
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1222
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1223
1223
1224
1224
// Remove compiled module from disk
1225
1225
remove_dir_all ( options. base_dir . join ( CACHE_DIR ) . join ( MODULES_DIR ) ) . unwrap ( ) ;
@@ -1239,7 +1239,7 @@ mod tests {
1239
1239
#[ test]
1240
1240
fn use_multiple_cached_instances_of_same_contract ( ) {
1241
1241
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1242
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1242
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1243
1243
1244
1244
// these differentiate the two instances of the same contract
1245
1245
let backend1 = mock_backend ( & [ ] ) ;
@@ -1299,7 +1299,7 @@ mod tests {
1299
1299
#[ test]
1300
1300
fn resets_gas_when_reusing_instance ( ) {
1301
1301
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1302
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1302
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1303
1303
1304
1304
let backend1 = mock_backend ( & [ ] ) ;
1305
1305
let backend2 = mock_backend ( & [ ] ) ;
@@ -1338,7 +1338,7 @@ mod tests {
1338
1338
#[ test]
1339
1339
fn recovers_from_out_of_gas ( ) {
1340
1340
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1341
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1341
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1342
1342
1343
1343
let backend1 = mock_backend ( & [ ] ) ;
1344
1344
let backend2 = mock_backend ( & [ ] ) ;
@@ -1454,7 +1454,7 @@ mod tests {
1454
1454
let cache: Cache < MockApi , MockStorage , MockQuerier > =
1455
1455
unsafe { Cache :: new ( make_stargate_testing_options ( ) ) . unwrap ( ) } ;
1456
1456
1457
- let checksum1 = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1457
+ let checksum1 = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1458
1458
let report1 = cache. analyze ( & checksum1) . unwrap ( ) ;
1459
1459
assert_eq ! (
1460
1460
report1,
@@ -1473,7 +1473,7 @@ mod tests {
1473
1473
}
1474
1474
) ;
1475
1475
1476
- let checksum2 = cache. store_code ( IBC_CONTRACT , true , true ) . unwrap ( ) ;
1476
+ let checksum2 = cache. store_code ( IBC_REFLECT , true , true ) . unwrap ( ) ;
1477
1477
let report2 = cache. analyze ( & checksum2) . unwrap ( ) ;
1478
1478
let mut ibc_contract_entrypoints =
1479
1479
BTreeSet :: from ( [ E :: Instantiate , E :: Migrate , E :: Reply , E :: Query ] ) ;
@@ -1492,7 +1492,7 @@ mod tests {
1492
1492
}
1493
1493
) ;
1494
1494
1495
- let checksum3 = cache. store_code ( EMPTY_CONTRACT , true , true ) . unwrap ( ) ;
1495
+ let checksum3 = cache. store_code ( EMPTY , true , true ) . unwrap ( ) ;
1496
1496
let report3 = cache. analyze ( & checksum3) . unwrap ( ) ;
1497
1497
assert_eq ! (
1498
1498
report3,
@@ -1505,7 +1505,7 @@ mod tests {
1505
1505
}
1506
1506
) ;
1507
1507
1508
- let mut wasm_with_version = EMPTY_CONTRACT . to_vec ( ) ;
1508
+ let mut wasm_with_version = EMPTY . to_vec ( ) ;
1509
1509
let custom_section = wasm_encoder:: CustomSection {
1510
1510
name : Cow :: Borrowed ( "cw_migrate_version" ) ,
1511
1511
data : Cow :: Borrowed ( b"21" ) ,
@@ -1527,7 +1527,7 @@ mod tests {
1527
1527
1528
1528
let cache: Cache < MockApi , MockStorage , MockQuerier > =
1529
1529
unsafe { Cache :: new ( make_ibc2_testing_options ( ) ) . unwrap ( ) } ;
1530
- let checksum5 = cache. store_code ( IBC2_CONTRACT , true , true ) . unwrap ( ) ;
1530
+ let checksum5 = cache. store_code ( IBC2 , true , true ) . unwrap ( ) ;
1531
1531
let report5 = cache. analyze ( & checksum5) . unwrap ( ) ;
1532
1532
let mut ibc2_contract_entrypoints = BTreeSet :: from ( [ E :: Instantiate , E :: Query ] ) ;
1533
1533
ibc2_contract_entrypoints. extend ( [ REQUIRED_IBC2_EXPORT ] ) ;
@@ -1549,7 +1549,7 @@ mod tests {
1549
1549
#[ test]
1550
1550
fn pinned_metrics_works ( ) {
1551
1551
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1552
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1552
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1553
1553
1554
1554
cache. pin ( & checksum) . unwrap ( ) ;
1555
1555
@@ -1568,7 +1568,7 @@ mod tests {
1568
1568
assert_eq ! ( pinned_metrics. per_module[ 0 ] . 0 , checksum) ;
1569
1569
assert_eq ! ( pinned_metrics. per_module[ 0 ] . 1 . hits, 1 ) ;
1570
1570
1571
- let empty_checksum = cache. store_code ( EMPTY_CONTRACT , true , true ) . unwrap ( ) ;
1571
+ let empty_checksum = cache. store_code ( EMPTY , true , true ) . unwrap ( ) ;
1572
1572
cache. pin ( & empty_checksum) . unwrap ( ) ;
1573
1573
1574
1574
let pinned_metrics = cache. pinned_metrics ( ) ;
@@ -1591,7 +1591,7 @@ mod tests {
1591
1591
#[ test]
1592
1592
fn pin_unpin_works ( ) {
1593
1593
let cache = unsafe { Cache :: new ( make_testing_options ( ) ) . unwrap ( ) } ;
1594
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1594
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1595
1595
1596
1596
// check not pinned
1597
1597
let backend = mock_backend ( & [ ] ) ;
@@ -1656,7 +1656,7 @@ mod tests {
1656
1656
let options = make_testing_options ( ) ;
1657
1657
let cache: Cache < MockApi , MockStorage , MockQuerier > =
1658
1658
unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
1659
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1659
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1660
1660
1661
1661
// Remove compiled module from disk
1662
1662
remove_dir_all ( options. base_dir . join ( CACHE_DIR ) . join ( MODULES_DIR ) ) . unwrap ( ) ;
@@ -1691,7 +1691,7 @@ mod tests {
1691
1691
} ;
1692
1692
let cache: Cache < MockApi , MockStorage , MockQuerier > =
1693
1693
unsafe { Cache :: new ( options) . unwrap ( ) } ;
1694
- let checksum = cache. store_code ( CONTRACT , true , true ) . unwrap ( ) ;
1694
+ let checksum = cache. store_code ( HACKATOM , true , true ) . unwrap ( ) ;
1695
1695
1696
1696
// Move the saved wasm to the old path (without extension)
1697
1697
let old_path = tmp_dir
@@ -1704,7 +1704,7 @@ mod tests {
1704
1704
1705
1705
// loading wasm from before the wasm extension was added should still work
1706
1706
let restored = cache. load_wasm ( & checksum) . unwrap ( ) ;
1707
- assert_eq ! ( restored, CONTRACT ) ;
1707
+ assert_eq ! ( restored, HACKATOM ) ;
1708
1708
}
1709
1709
1710
1710
#[ test]
@@ -1726,7 +1726,7 @@ mod tests {
1726
1726
1727
1727
let cache: Cache < MockApi , MockStorage , MockQuerier > =
1728
1728
unsafe { Cache :: new_with_config ( config) . unwrap ( ) } ;
1729
- let err = cache. store_code ( CONTRACT , true , true ) . unwrap_err ( ) ;
1729
+ let err = cache. store_code ( HACKATOM , true , true ) . unwrap_err ( ) ;
1730
1730
assert ! ( matches!( err, VmError :: StaticValidationErr { .. } ) ) ;
1731
1731
}
1732
1732
}
0 commit comments