Skip to content

Commit 6e3dcd1

Browse files
committed
Adapt tests to new realities
1 parent 3c4fea4 commit 6e3dcd1

File tree

10 files changed

+77
-21
lines changed

10 files changed

+77
-21
lines changed

packages/vm/benches/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn bench_instance(c: &mut Criterion) {
101101

102102
b.iter(|| {
103103
let info = mock_info(&verifier, &coins(15, "earth"));
104-
let msg = br#"{"release":{}}"#;
104+
let msg = br#"{"release":{"denom":"earth"}}"#;
105105
let contract_result =
106106
call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg).unwrap();
107107
assert!(contract_result.into_result().is_ok());

packages/vm/examples/heap_profiling.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn contracts() -> Vec<Contract> {
7777
.into_bytes(),
7878
),
7979
execute_msgs: vec![Execute {
80-
msg: br#"{"release":{}}"#,
80+
msg: br#"{"release":{"denom":"earth"}}"#,
8181
expect_error: false,
8282
}],
8383
},
@@ -88,7 +88,7 @@ fn contracts() -> Vec<Contract> {
8888
.into_bytes(),
8989
),
9090
execute_msgs: vec![Execute {
91-
msg: br#"{"release":{}}"#,
91+
msg: br#"{"release":{"denom":"earth"}}"#,
9292
expect_error: false,
9393
}],
9494
},

packages/vm/examples/multi_threaded_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn main() {
6969
assert!(contract_result.into_result().is_ok());
7070

7171
let info = mock_info(&verifier, &coins(15, "earth"));
72-
let msg = br#"{"release":{}}"#;
72+
let msg = br#"{"release":{"denom":"earth"}}"#;
7373
let contract_result =
7474
call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg).unwrap();
7575
assert!(contract_result.into_result().is_ok());

packages/vm/src/cache.rs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ fn remove_wasm_from_disk(dir: impl Into<PathBuf>, checksum: &Checksum) -> VmResu
611611
mod tests {
612612
use super::*;
613613
use crate::calls::{call_execute, call_instantiate};
614-
use crate::capabilities::capabilities_from_csv;
615614
use crate::testing::{mock_backend, mock_env, mock_info, MockApi, MockQuerier, MockStorage};
616615
use cosmwasm_std::{coins, Empty};
617616
use std::borrow::Cow;
@@ -640,7 +639,19 @@ mod tests {
640639
"#;
641640

642641
fn default_capabilities() -> HashSet<String> {
643-
capabilities_from_csv("iterator,staking")
642+
HashSet::from([
643+
"cosmwasm_1_1".to_string(),
644+
"cosmwasm_1_2".to_string(),
645+
"cosmwasm_1_3".to_string(),
646+
"cosmwasm_1_4".to_string(),
647+
"cosmwasm_1_4".to_string(),
648+
"cosmwasm_2_0".to_string(),
649+
"cosmwasm_2_1".to_string(),
650+
"cosmwasm_2_2".to_string(),
651+
"iterator".to_string(),
652+
"staking".to_string(),
653+
"stargate".to_string(),
654+
])
644655
}
645656

646657
fn make_testing_options() -> CacheOptions {
@@ -693,7 +704,7 @@ mod tests {
693704

694705
// execute
695706
let info = mock_info(&verifier, &coins(15, "earth"));
696-
let msg = br#"{"release":{}}"#;
707+
let msg = br#"{"release":{"denom":"earth"}}"#;
697708
let response = call_execute::<_, _, _, Empty>(instance, &mock_env(), &info, msg)
698709
.unwrap()
699710
.unwrap();
@@ -1137,7 +1148,7 @@ mod tests {
11371148

11381149
// execute
11391150
let info = mock_info(&verifier, &coins(15, "earth"));
1140-
let msg = br#"{"release":{}}"#;
1151+
let msg = br#"{"release":{"denom":"earth"}}"#;
11411152
let response = call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg)
11421153
.unwrap()
11431154
.unwrap();
@@ -1171,7 +1182,7 @@ mod tests {
11711182

11721183
// execute
11731184
let info = mock_info(&verifier, &coins(15, "earth"));
1174-
let msg = br#"{"release":{}}"#;
1185+
let msg = br#"{"release":{"denom":"earth"}}"#;
11751186
let response = call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg)
11761187
.unwrap()
11771188
.unwrap();
@@ -1207,7 +1218,7 @@ mod tests {
12071218

12081219
// execute
12091220
let info = mock_info(&verifier, &coins(15, "earth"));
1210-
let msg = br#"{"release":{}}"#;
1221+
let msg = br#"{"release":{"denom":"earth"}}"#;
12111222
let response = call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg)
12121223
.unwrap()
12131224
.unwrap();
@@ -1280,7 +1291,7 @@ mod tests {
12801291
.get_instance(&checksum, backend2, TESTING_OPTIONS)
12811292
.unwrap();
12821293
let info = mock_info(&bob, &coins(15, "earth"));
1283-
let msg = br#"{"release":{}}"#;
1294+
let msg = br#"{"release":{"denom":"earth"}}"#;
12841295
let res = call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg).unwrap();
12851296
let msgs = res.unwrap().messages;
12861297
assert_eq!(1, msgs.len());
@@ -1290,7 +1301,7 @@ mod tests {
12901301
.get_instance(&checksum, backend1, TESTING_OPTIONS)
12911302
.unwrap();
12921303
let info = mock_info(&sue, &coins(15, "earth"));
1293-
let msg = br#"{"release":{}}"#;
1304+
let msg = br#"{"release":{"denom":"earth"}}"#;
12941305
let res = call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg).unwrap();
12951306
let msgs = res.unwrap().messages;
12961307
assert_eq!(1, msgs.len());
@@ -1468,15 +1479,24 @@ mod tests {
14681479
E::Execute,
14691480
E::Query
14701481
]),
1471-
required_capabilities: BTreeSet::new(),
1472-
contract_migrate_version: Some(42),
1482+
required_capabilities: BTreeSet::from([
1483+
"cosmwasm_1_1".to_string(),
1484+
"cosmwasm_1_2".to_string(),
1485+
"cosmwasm_1_3".to_string(),
1486+
"cosmwasm_1_4".to_string(),
1487+
"cosmwasm_1_4".to_string(),
1488+
"cosmwasm_2_0".to_string(),
1489+
"cosmwasm_2_1".to_string(),
1490+
"cosmwasm_2_2".to_string(),
1491+
]),
1492+
contract_migrate_version: Some(420),
14731493
}
14741494
);
14751495

14761496
let checksum2 = cache.store_code(IBC_REFLECT, true, true).unwrap();
14771497
let report2 = cache.analyze(&checksum2).unwrap();
14781498
let mut ibc_contract_entrypoints =
1479-
BTreeSet::from([E::Instantiate, E::Migrate, E::Reply, E::Query]);
1499+
BTreeSet::from([E::Instantiate, E::Migrate, E::Execute, E::Reply, E::Query]);
14801500
ibc_contract_entrypoints.extend(REQUIRED_IBC_EXPORTS);
14811501
assert_eq!(
14821502
report2,
@@ -1485,6 +1505,14 @@ mod tests {
14851505
has_ibc2_entry_points: false,
14861506
entrypoints: ibc_contract_entrypoints,
14871507
required_capabilities: BTreeSet::from_iter([
1508+
"cosmwasm_1_1".to_string(),
1509+
"cosmwasm_1_2".to_string(),
1510+
"cosmwasm_1_3".to_string(),
1511+
"cosmwasm_1_4".to_string(),
1512+
"cosmwasm_1_4".to_string(),
1513+
"cosmwasm_2_0".to_string(),
1514+
"cosmwasm_2_1".to_string(),
1515+
"cosmwasm_2_2".to_string(),
14881516
"iterator".to_string(),
14891517
"stargate".to_string()
14901518
]),

packages/vm/src/calls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ mod tests {
847847

848848
// execute
849849
let info = mock_info(&verifier, &coins(15, "earth"));
850-
let msg = br#"{"release":{}}"#;
850+
let msg = br#"{"release":{"denom":"earth"}}"#;
851851
call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg)
852852
.unwrap()
853853
.unwrap();

packages/vm/src/compatibility.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ fn check_wasm_functions(module: &ParsedWasm, limits: &WasmLimits, logs: Logger)
331331
#[cfg(test)]
332332
mod tests {
333333
use super::*;
334-
use crate::capabilities_from_csv;
335334

336335
static CONTRACT_0_7: &[u8] = include_bytes!("../testdata/hackatom_0.7.wasm");
337336
static CONTRACT_0_12: &[u8] = include_bytes!("../testdata/hackatom_0.12.wasm");
@@ -342,7 +341,19 @@ mod tests {
342341
static CYBERPUNK_RUST_170: &[u8] = include_bytes!("../testdata/cyberpunk_rust170.wasm");
343342

344343
fn default_capabilities() -> HashSet<String> {
345-
capabilities_from_csv("cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,iterator,staking,stargate")
344+
HashSet::from([
345+
"cosmwasm_1_1".to_string(),
346+
"cosmwasm_1_2".to_string(),
347+
"cosmwasm_1_3".to_string(),
348+
"cosmwasm_1_4".to_string(),
349+
"cosmwasm_1_4".to_string(),
350+
"cosmwasm_2_0".to_string(),
351+
"cosmwasm_2_1".to_string(),
352+
"cosmwasm_2_2".to_string(),
353+
"iterator".to_string(),
354+
"staking".to_string(),
355+
"stargate".to_string(),
356+
])
346357
}
347358

348359
#[test]

packages/vm/src/environment.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,11 @@ mod tests {
601601
"addr_validate" => Function::new_typed(&mut store, |_a: u32| -> u32 { 0 }),
602602
"addr_canonicalize" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
603603
"addr_humanize" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
604+
"bls12_381_aggregate_g1" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
605+
"bls12_381_aggregate_g2" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
606+
"bls12_381_pairing_equality" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
607+
"bls12_381_hash_to_g1" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
608+
"bls12_381_hash_to_g2" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
604609
"secp256k1_verify" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }),
605610
"secp256k1_recover_pubkey" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }),
606611
"secp256r1_verify" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }),

packages/vm/src/imports.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,11 @@ mod tests {
10861086
"addr_validate" => Function::new_typed(&mut store, |_a: u32| -> u32 { 0 }),
10871087
"addr_canonicalize" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
10881088
"addr_humanize" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
1089+
"bls12_381_aggregate_g1" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
1090+
"bls12_381_aggregate_g2" => Function::new_typed(&mut store, |_a: u32, _b: u32| -> u32 { 0 }),
1091+
"bls12_381_pairing_equality" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
1092+
"bls12_381_hash_to_g1" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
1093+
"bls12_381_hash_to_g2" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32, _d: u32| -> u32 { 0 }),
10891094
"secp256k1_verify" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }),
10901095
"secp256k1_recover_pubkey" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u64 { 0 }),
10911096
"secp256r1_verify" => Function::new_typed(&mut store, |_a: u32, _b: u32, _c: u32| -> u32 { 0 }),

packages/vm/src/instance.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ mod tests {
548548
const MIB: usize = 1024 * 1024;
549549
const DEFAULT_QUERY_GAS_LIMIT: u64 = 300_000;
550550
static HACKATOM: &[u8] = include_bytes!("../testdata/hackatom.wasm");
551+
static HACKATOM_1_3: &[u8] = include_bytes!("../testdata/hackatom_1.3.wasm");
551552
static CYBERPUNK: &[u8] = include_bytes!("../testdata/cyberpunk.wasm");
552553

553554
#[test]
@@ -600,8 +601,14 @@ mod tests {
600601
let backend = mock_backend(&[]);
601602
let (instance_options, memory_limit) = mock_instance_options();
602603
let instance =
603-
Instance::from_code(HACKATOM, backend, instance_options, memory_limit).unwrap();
604+
Instance::from_code(HACKATOM_1_3, backend, instance_options, memory_limit).unwrap();
604605
assert_eq!(instance.required_capabilities().len(), 0);
606+
607+
let backend = mock_backend(&[]);
608+
let (instance_options, memory_limit) = mock_instance_options();
609+
let instance =
610+
Instance::from_code(HACKATOM, backend, instance_options, memory_limit).unwrap();
611+
assert_eq!(instance.required_capabilities().len(), 7);
605612
}
606613

607614
#[test]
@@ -1098,7 +1105,7 @@ mod tests {
10981105
// run contract - just sanity check - results validate in contract unit tests
10991106
let gas_before_execute = instance.get_gas_left();
11001107
let info = mock_info(&verifier, &coins(15, "earth"));
1101-
let msg = br#"{"release":{}}"#;
1108+
let msg = br#"{"release":{"denom":"earth"}}"#;
11021109
call_execute::<_, _, _, Empty>(&mut instance, &mock_env(), &info, msg)
11031110
.unwrap()
11041111
.unwrap();

packages/vm/src/static_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ mod tests {
133133
.exports
134134
.iter()
135135
.filter(|entry| matches!(entry.kind, ExternalKind::Func));
136-
assert_eq!(exported_functions.count(), 8); // 4 required exports plus "execute", "migrate", "query" and "sudo"
136+
assert_eq!(exported_functions.count(), 15);
137137

138138
let exported_memories = module
139139
.exports

0 commit comments

Comments
 (0)