Skip to content

Commit 9a1c80c

Browse files
authored
Merge pull request #2214 from CosmWasm/unit-test-cost
Add unit test for cost function
2 parents abb7f0e + a939206 commit 9a1c80c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/vm/src/wasm_backend/engine.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ fn limit_to_pages(limit: Size) -> Pages {
100100
mod tests {
101101
use super::*;
102102

103+
#[test]
104+
fn cost_works() {
105+
// accounting operator
106+
assert_eq!(cost(&Operator::Br { relative_depth: 3 }), 1610);
107+
assert_eq!(cost(&Operator::Return {}), 1610);
108+
109+
// anything else
110+
assert_eq!(cost(&Operator::I64Const { value: 7 }), 115);
111+
assert_eq!(cost(&Operator::I64Extend8S {}), 115);
112+
}
113+
103114
#[test]
104115
fn limit_to_pages_works() {
105116
// rounds down

0 commit comments

Comments
 (0)