Skip to content

Commit

Permalink
Merge pull request #15 from near-examples/fix-tests
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
garikbesson authored Sep 17, 2024
2 parents 7d6a78a + 337fc4a commit 264bbd2
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 62 deletions.
10 changes: 5 additions & 5 deletions contract-rs/01-basic-auction/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auction"
description = "Auction"
name = "auction-contract"
description = "Auction Example Part 1"
version = "0.1.0"
edition = "2021"

Expand All @@ -9,11 +9,11 @@ crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
near-sdk = { version = "5.3" }
near-sdk = "5.5.0"

[dev-dependencies]
near-sdk = { version = "5.3", features = ["unit-testing"] }
near-workspaces = { version = "0.11.0", features = ["unstable"] }
near-sdk = { version = "5.5.0", features = ["unit-testing"] }
near-workspaces = { version = "0.14.0", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
serde_json = "1"
chrono = "0.4.38"
Expand Down
24 changes: 8 additions & 16 deletions contract-rs/02-owner-claims-money/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
[package]
name = "auction"
description = "Hello Near Example"
name = "auction-contract"
description = "Auction Example Part 2"
version = "0.1.0"
edition = "2021"
# TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project.
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
# Link to the repository will be available via `contract_source_metadata` view-function.
repository = "https://github.com/near-examples/auction-examples"

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
near-sdk = { version = "5.1.0", features = ["legacy"] }
chrono = "0.4.38"
tracing = "0.1"
tracing-subscriber = "0.3"
near-sdk = "5.5.0"

[dev-dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"] }
near-workspaces = { version = "0.10.0", features = ["unstable"] }
near-sdk = { version = "5.5.0", features = ["unit-testing"] }
near-workspaces = { version = "0.14.0", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
serde_json = "1.0.117"
serde_json = "1"
chrono = "0.4.38"

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true
overflow-checks = true
11 changes: 9 additions & 2 deletions contract-rs/02-owner-claims-money/tests/test_basics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
use chrono::Utc;
use contract_rs::Bid;
use near_sdk::{Gas, NearToken};
use serde_json::json;
use near_workspaces::types::{NearToken, AccountId, Gas};
use near_sdk::near;

#[near(serializers = [json])]
#[derive(Clone)]
pub struct Bid {
pub bidder: AccountId,
pub bid: NearToken,
}

const TEN_NEAR: NearToken = NearToken::from_near(10);

Expand Down
24 changes: 8 additions & 16 deletions contract-rs/03-owner-claims-winner-gets-nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
[package]
name = "auction"
description = "Hello Near Example"
name = "auction-contract"
description = "Auction Example Part 3"
version = "0.1.0"
edition = "2021"
# TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project.
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
# Link to the repository will be available via `contract_source_metadata` view-function.
repository = "https://github.com/near-examples/auction-examples"

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
near-sdk = { version = "5.1.0", features = ["legacy"] }
chrono = "0.4.38"
tracing = "0.1"
tracing-subscriber = "0.3"
near-sdk = "5.5.0"

[dev-dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"] }
near-workspaces = { version = "0.10.0", features = ["unstable"] }
near-sdk = { version = "5.5.0", features = ["unit-testing"] }
near-workspaces = { version = "0.14.0", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
serde_json = "1.0.117"
serde_json = "1"
chrono = "0.4.38"

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true
overflow-checks = true
Binary file modified contract-rs/03-owner-claims-winner-gets-nft/tests/non_fungible_token.wasm
100644 → 100755
Binary file not shown.
13 changes: 10 additions & 3 deletions contract-rs/03-owner-claims-winner-gets-nft/tests/test_basics.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use chrono::Utc;
use contract_rs::Bid;
use near_sdk::{Gas, NearToken};
use near_sdk::near;
use near_workspaces::result::ExecutionFinalResult;
use near_workspaces::types::{AccountId, Gas, NearToken};
use serde_json::json;

#[near(serializers = [json])]
#[derive(Clone)]
pub struct Bid {
pub bidder: AccountId,
pub bid: NearToken,
}

const TEN_NEAR: NearToken = NearToken::from_near(10);
const NFT_WASM_FILEPATH: &str = "./tests/non_fungible_token.wasm";

Expand Down Expand Up @@ -36,7 +43,7 @@ async fn test_contract_is_operational() -> Result<(), Box<dyn std::error::Error>
let request_payload = json!({
"token_id": TOKEN_ID,
"receiver_id": contract_account.id(),
"metadata": {
"token_metadata": {
"title": "LEEROYYYMMMJENKINSSS",
"description": "Alright time's up, let's do this.",
"media": "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.Fhp4lHufCdTzTeGCAblOdgHaF7%26pid%3DApi&f=1"
Expand Down
24 changes: 8 additions & 16 deletions contract-rs/04-ft-owner-claims-winner-gets-nft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
[package]
name = "auction"
description = "Hello Near Example"
name = "auction-contract"
description = "Auction Example Part 4"
version = "0.1.0"
edition = "2021"
# TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project.
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
# Link to the repository will be available via `contract_source_metadata` view-function.
repository = "https://github.com/near-examples/auction-examples"

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
near-sdk = { version = "5.1.0", features = ["legacy"] }
chrono = "0.4.38"
tracing = "0.1"
tracing-subscriber = "0.3"
near-sdk = "5.5.0"

[dev-dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"] }
near-workspaces = { version = "0.10.0", features = ["unstable"] }
near-sdk = { version = "5.5.0", features = ["unit-testing"] }
near-workspaces = { version = "0.14.0", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
serde_json = "1.0.117"
serde_json = "1"
chrono = "0.4.38"

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true
overflow-checks = true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use chrono::Utc;
use contract_rs::Bid;
use near_sdk::{json_types::U128, NearToken};
use near_sdk::{AccountId, Gas};
use near_sdk::json_types::U128;
use near_sdk::near;
use near_workspaces::result::ExecutionFinalResult;
use near_workspaces::types::{AccountId, Gas, NearToken};
use near_workspaces::{Account, Contract};
use serde_json::json;

#[near(serializers = [json])]
#[derive(Clone)]
pub struct Bid {
pub bidder: AccountId,
pub bid: U128,
}

const TEN_NEAR: NearToken = NearToken::from_near(10);
const FT_WASM_FILEPATH: &str = "./tests/fungible_token.wasm";
const NFT_WASM_FILEPATH: &str = "./tests/non_fungible_token.wasm";
Expand Down Expand Up @@ -54,7 +61,7 @@ async fn test_contract_is_operational() -> Result<(), Box<dyn std::error::Error>
let request_payload = json!({
"token_id": "1",
"receiver_id": contract_account.id(),
"metadata": {
"token_metadata": {
"title": "LEEROYYYMMMJENKINSSS",
"description": "Alright time's up, let's do this.",
"media": "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.Fhp4lHufCdTzTeGCAblOdgHaF7%26pid%3DApi&f=1"
Expand Down

0 comments on commit 264bbd2

Please sign in to comment.