Skip to content

Commit

Permalink
add cache
Browse files Browse the repository at this point in the history
  • Loading branch information
prin-r committed Jul 6, 2020
1 parent 6403337 commit b8d6847
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions mumu/tests/src/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#[cfg(test)]
mod tests {
use casperlabs_engine_test_support::{Code, Error, SessionBuilder, TestContextBuilder, Value};
use casperlabs_types::{account::PublicKey, U512};

const MY_ACCOUNT: PublicKey = PublicKey::ed25519_from([7u8; 32]);
// define KEY constant to match that in the contract
const KEY: &str = "special_value";
const VALUE: &str = "hello world";

#[test]
fn should_store_hello_world() {
let mut context = TestContextBuilder::new()
.with_account(MY_ACCOUNT, U512::from(128_000_000))
.build();

// The test framework checks for compiled Wasm files in '<current working dir>/wasm'. Paths
// relative to the current working dir (e.g. 'wasm/contract.wasm') can also be used, as can
// absolute paths.
let session_code = Code::from("contract.wasm");
let session_args = (VALUE,);
let session = SessionBuilder::new(session_code, session_args)
.with_address(MY_ACCOUNT)
.with_authorization_keys(&[MY_ACCOUNT])
.build();

let result_of_query: Result<Value, Error> = context.run(session).query(MY_ACCOUNT, &[KEY]);

let returned_value = result_of_query.expect("should be a value");

let expected_value = Value::from_t(VALUE.to_string()).expect("should construct Value");
assert_eq!(expected_value, returned_value);
}
}

fn main() {
panic!("Execute \"cargo test\" to test the contract, not \"cargo run\".");
}

0 comments on commit b8d6847

Please sign in to comment.