Skip to content

Commit

Permalink
Rebuild new test contract and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Feb 7, 2020
1 parent e559b64 commit fdb5ec1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
47 changes: 46 additions & 1 deletion contracts/hackatom/schema/handle_msg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "HandleMsg",
"type": "object"
"anyOf": [
{
"type": "object",
"required": [
"release"
],
"properties": {
"release": {
"type": "object"
}
}
},
{
"type": "object",
"required": [
"cpuloop"
],
"properties": {
"cpuloop": {
"type": "object"
}
}
},
{
"type": "object",
"required": [
"storageloop"
],
"properties": {
"storageloop": {
"type": "object"
}
}
},
{
"type": "object",
"required": [
"panic"
],
"properties": {
"panic": {
"type": "object"
}
}
}
]
}
6 changes: 3 additions & 3 deletions lib/vm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mod test {
&coin("15", "earth"),
&coin("1015", "earth"),
);
let msg = b"{}";
let msg = br#"{"release":{}}"#;
let res = call_handle(&mut instance, &params, msg).unwrap();
let msgs = res.unwrap().messages;
assert_eq!(1, msgs.len());
Expand Down Expand Up @@ -230,7 +230,7 @@ mod test {
&coin("15", "earth"),
&coin("1015", "earth"),
);
let msg = b"{}";
let msg = br#"{"release":{}}"#;
let res = call_handle(&mut instance, &params, msg).unwrap();
let msgs = res.unwrap().messages;
assert_eq!(1, msgs.len());
Expand All @@ -244,7 +244,7 @@ mod test {
&coin("15", "earth"),
&coin("1015", "earth"),
);
let msg = b"{}";
let msg = br#"{"release":{}}"#;
let res = call_handle(&mut instance, &params, msg).unwrap();
let msgs = res.unwrap().messages;
assert_eq!(1, msgs.len());
Expand Down
6 changes: 3 additions & 3 deletions lib/vm/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod test {

let init_used = orig_gas - instance.get_gas();
println!("init used: {}", init_used);
assert_eq!(init_used, 66_763);
assert_eq!(init_used, 66_765);

// run contract - just sanity check - results validate in contract unit tests
instance.set_gas(orig_gas);
Expand All @@ -176,14 +176,14 @@ mod test {
&coin("15", "earth"),
&coin("1015", "earth"),
);
let msg = b"{}";
let msg = br#"{"release":{}}"#;
let res = call_handle(&mut instance, &params, msg).unwrap();
let msgs = res.unwrap().messages;
assert_eq!(1, msgs.len());

let handle_used = orig_gas - instance.get_gas();
println!("handle used: {}", handle_used);
assert_eq!(handle_used, 110_267);
assert_eq!(handle_used, 112_832);
}

#[test]
Expand Down
Binary file modified lib/vm/testdata/contract.wasm
Binary file not shown.

0 comments on commit fdb5ec1

Please sign in to comment.