Skip to content

Commit

Permalink
add integration test for iah (#90)
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Yadav <[email protected]>
Co-authored-by: Robert Zaremba <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2023
1 parent 981a7dd commit 94184b4
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 39 deletions.
7 changes: 7 additions & 0 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions contracts/easy-poll/tests/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Ok;
use easy_poll::{PollResult, Results, Status};
use near_sdk::serde_json::json;
use near_units::parse_near;
use test_util::{build_contract, get_block_timestamp, registry_default};
use test_util::{deploy_contract, get_block_timestamp, registry_default};
use workspaces::{network::Sandbox, Account, AccountId, Contract, Worker};

async fn respond(
Expand Down Expand Up @@ -37,7 +37,7 @@ async fn init(worker: &Worker<Sandbox>) -> anyhow::Result<(Contract, Account, Ac
.await?;

// Setup easy-poll contract
let easy_poll_contract = build_contract(
let easy_poll_contract = deploy_contract(
&worker,
"./",
"new",
Expand Down
18 changes: 9 additions & 9 deletions contracts/kudos/tests/test_kudos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ mod utils;

use crate::types::*;
use crate::utils::*;
use test_util::{build_contract, gen_user_account, get_block_timestamp, transfer_near};
use kudos_contract::WrappedCid;
use kudos_contract::{utils::*, CommentId};
use kudos_contract::{Commentary, PROOF_OF_KUDOS_SBT_CLASS_ID};
use near_sdk::serde_json::{self, json, Value};
use near_sdk::AccountId;
use near_units::parse_near;
use std::collections::{BTreeMap, HashMap};
use test_util::{deploy_contract, gen_user_account, get_block_timestamp, transfer_near};

#[tokio::test]
async fn test_give_kudos() -> anyhow::Result<()> {
Expand Down Expand Up @@ -72,7 +72,7 @@ async fn test_give_kudos() -> anyhow::Result<()> {
.into_result()?;

// Setup NDC Kudos Contract
let kudos_contract = build_contract(
let kudos_contract = deploy_contract(
&worker,
"./",
"init",
Expand Down Expand Up @@ -169,9 +169,7 @@ async fn test_give_kudos() -> anyhow::Result<()> {
kudos_contract.id(),
user2_account.id(),
user1_account.id(),
serde_json::to_string(&hashtags)
.unwrap()
.escape_default(),
serde_json::to_string(&hashtags).unwrap().escape_default(),
)
);

Expand Down Expand Up @@ -342,7 +340,7 @@ async fn test_mint_proof_of_kudos_sbt() -> anyhow::Result<()> {
.into_result()?;

// Setup NDC Kudos Contract
let kudos_contract = build_contract(
let kudos_contract = deploy_contract(
&worker,
"./",
"init",
Expand Down Expand Up @@ -416,11 +414,13 @@ async fn test_mint_proof_of_kudos_sbt() -> anyhow::Result<()> {
let _ = mint_fv_sbt(
&iah_registry_id,
&admin_account,
&[user1_account.id(),
&[
user1_account.id(),
user2_account.id(),
user3_account.id(),
user4_account.id(),
user5_account.id()],
user5_account.id(),
],
now_ms,
now_ms + 86_400_000,
)
Expand Down Expand Up @@ -539,7 +539,7 @@ async fn test_mass_give_kudos() -> anyhow::Result<()> {
.into_result()?;

// Setup NDC Kudos Contract
let kudos_contract = build_contract(
let kudos_contract = deploy_contract(
&worker,
"./",
"init",
Expand Down
4 changes: 2 additions & 2 deletions contracts/kudos/tests/test_required_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ mod types;
mod utils;

use crate::utils::*;
use test_util::{build_contract, gen_user_account, get_block_timestamp, transfer_near};
use kudos_contract::{utils::*, WrappedCid};
use kudos_contract::{GIVE_KUDOS_COST, LEAVE_COMMENT_COST, UPVOTE_KUDOS_COST};
use near_sdk::serde_json::json;
use near_units::parse_near;
use test_util::{deploy_contract, gen_user_account, get_block_timestamp, transfer_near};

#[tokio::test]
async fn test_required_deposit() -> anyhow::Result<()> {
Expand Down Expand Up @@ -68,7 +68,7 @@ async fn test_required_deposit() -> anyhow::Result<()> {
.into_result()?;

// Setup NDC Kudos Contract
let kudos_contract = build_contract(
let kudos_contract = deploy_contract(
&worker,
"./",
"init",
Expand Down
4 changes: 2 additions & 2 deletions contracts/kudos/tests/test_social_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ mod types;
mod utils;

use crate::utils::*;
use test_util::{build_contract, gen_user_account, transfer_near};
use kudos_contract::utils::*;
use kudos_contract::SOCIAL_DB_GRANT_WRITE_PERMISSION_COST;
use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds};
use near_sdk::json_types::U128;
use near_sdk::serde_json::{self, json, Value};
use near_sdk::ONE_YOCTO;
use near_units::parse_near;
use test_util::{deploy_contract, gen_user_account, transfer_near};

#[tokio::test]
async fn test_social_db_required_deposit() -> anyhow::Result<()> {
Expand Down Expand Up @@ -71,7 +71,7 @@ async fn test_social_db_required_deposit() -> anyhow::Result<()> {
.into_result()?;

// Setup NDC Kudos Contract
let kudos_contract = build_contract(
let kudos_contract = deploy_contract(
&worker,
"./",
"init",
Expand Down
4 changes: 4 additions & 0 deletions contracts/oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ tokio.workspace = true
workspaces.workspace = true
near-units.workspace = true
tracing.workspace = true
near-crypto = "^0"
chrono = "0.4.26"

test-util = { path = "../test-util" }
Loading

0 comments on commit 94184b4

Please sign in to comment.