Skip to content

Commit

Permalink
update the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sczembor committed Sep 25, 2023
1 parent 9f1d878 commit 4af45a7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions contracts/easy-poll/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ use crate::events::emit_create_poll;
use crate::events::emit_respond;
pub use crate::ext::*;
pub use crate::storage::*;
use cost::MILI_NEAR;
use ext::ext_registry;
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::LookupMap;
use near_sdk::collections::LookupSet;
use near_sdk::Gas;
use near_sdk::{env, near_bindgen, require, AccountId, PanicOnDefault};
use near_sdk::{Balance, Gas};

mod errors;
mod events;
mod ext;
mod storage;

pub const RESPOND_COST: Balance = MILI_NEAR;
pub const RESPOND_CALLBACK_GAS: Gas = Gas(2 * Gas::ONE_TERA.0);
pub const MAX_TEXT_ANSWER_LEN: usize = 500; // TODO: decide on the maximum length of the text answers to

Expand Down Expand Up @@ -293,16 +291,17 @@ impl Contract {

#[cfg(test)]
mod tests {
use cost::MILI_NEAR;
use near_sdk::{
test_utils::{self, VMContextBuilder},
testing_env, AccountId, VMContext,
testing_env, AccountId, Balance, VMContext,
};

use crate::{
Answer, Contract, OpinionRangeResult, PollError, PollResult, Question, Results, Status,
RESPOND_COST,
};

pub const RESPOND_COST: Balance = MILI_NEAR;
const MILI_SECOND: u64 = 1000000; // nanoseconds

fn alice() -> AccountId {
Expand Down Expand Up @@ -470,7 +469,7 @@ mod tests {
String::from(""),
);
ctx.block_timestamp = MILI_SECOND * 3;
ctx.attached_deposit = RESPOND_COST - 1;
ctx.attached_deposit = 1;
testing_env!(ctx.clone());
match ctr.on_human_verifed(
vec![],
Expand Down Expand Up @@ -546,6 +545,7 @@ mod tests {
String::from(""),
String::from(""),
);
ctx.attached_deposit = RESPOND_COST;
ctx.block_timestamp = MILI_SECOND * 3;
testing_env!(ctx.clone());
let mut res = ctr.on_human_verifed(
Expand Down Expand Up @@ -682,6 +682,7 @@ mod tests {
String::from(""),
String::from(""),
);
ctx.attached_deposit = RESPOND_COST;
ctx.predecessor_account_id = alice();
ctx.block_timestamp = MILI_SECOND * 3;
testing_env!(ctx.clone());
Expand Down Expand Up @@ -739,6 +740,7 @@ mod tests {
String::from(""),
String::from(""),
);
ctx.attached_deposit = RESPOND_COST;
ctx.predecessor_account_id = alice();
ctx.block_timestamp = MILI_SECOND * 3;
testing_env!(ctx.clone());
Expand Down Expand Up @@ -794,6 +796,7 @@ mod tests {
String::from(""),
String::from(""),
);
ctx.attached_deposit = RESPOND_COST;
ctx.predecessor_account_id = alice();
ctx.block_timestamp = MILI_SECOND * 3;
testing_env!(ctx.clone());
Expand Down

0 comments on commit 4af45a7

Please sign in to comment.