Skip to content

Commit

Permalink
second commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackliu-miaozi committed Dec 18, 2023
1 parent 9d72824 commit 888f60b
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions contracts/01-tamagotchi/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,15 @@ fn smoke_test() {
let sys = System::new();
sys.init_logger();
let program = Program::current(&sys);
let result = program.send(2, String::from("Goodmoring"));
let result = program.send(2, String::from("Goodmorning"));
assert!(!result.main_failed());
let result = program.send(2, TmgAction::Name);
let log = Log::builder()
.dest(2)
.payload(TmgEvent::Name(String::from("Goodmoring")));
.payload(TmgEvent::Name(String::from("Goodmorning")));
assert!(result.contains(&log));
let _result = program.send(2, TmgAction::Age);
// let log = Log::builder().dest(2).payload(TmgEvent::Age(sys.block_timestamp()));
// let age = sys.spend_blocks(1);
// let log = Log::builder().dest(2).payload(TmgEvent::Age(age[0]));
// assert!(result.contains(&log));

//How to test the age?
}

#[test]
fn negative_smoke_test() {
let sys = System::new();
sys.init_logger();
let program = Program::current(&sys);
let payload = vec![1, 2, 3];
let _result = program.send(2, payload);
// assert!(result.main_failed());
// Why the assert is panic?

// let result = program.send(1, TmgAction::Name);
// let log = Log::builder().dest(2).payload(TmgEvent::Name("Goodmoring".to_string()));
// assert!(!result.contains(&log));
// let result = program.send(1, TmgAction::Age);
// let log = Log::builder().dest(2).payload(TmgEvent::Age(sys.block_timestamp()));
// assert!(!result.contains(&log));
}

0 comments on commit 888f60b

Please sign in to comment.