From e150407953ea71853b7f4a60f4e336a38b79b7a9 Mon Sep 17 00:00:00 2001 From: PiVortex Date: Fri, 6 Sep 2024 12:35:21 +0100 Subject: [PATCH] fix tests --- contract-rs/01-basic-auction/Cargo.toml | 8 +++---- contract-rs/02-owner-claims-money/Cargo.toml | 24 +++++++------------ .../tests/test_basics.rs | 11 +++++++-- .../Cargo.toml | 24 +++++++------------ .../tests/test_basics.rs | 11 +++++++-- .../Cargo.toml | 24 +++++++------------ .../tests/test_basics.rs | 13 +++++++--- 7 files changed, 56 insertions(+), 59 deletions(-) diff --git a/contract-rs/01-basic-auction/Cargo.toml b/contract-rs/01-basic-auction/Cargo.toml index acab547e..30c90f34 100644 --- a/contract-rs/01-basic-auction/Cargo.toml +++ b/contract-rs/01-basic-auction/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "contract-rs" -description = "Auction" +name = "auction-contract" +description = "Auction Example Part 1" version = "0.1.0" edition = "2021" @@ -9,10 +9,10 @@ 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 = { version = "5.4.0" } [dev-dependencies] -near-sdk = { version = "5.3", features = ["unit-testing"] } +near-sdk = { version = "5.4.0", features = ["unit-testing"] } near-workspaces = { version = "0.11.0", features = ["unstable"] } tokio = { version = "1.12.0", features = ["full"] } serde_json = "1" diff --git a/contract-rs/02-owner-claims-money/Cargo.toml b/contract-rs/02-owner-claims-money/Cargo.toml index c5c280bf..e2b152bf 100644 --- a/contract-rs/02-owner-claims-money/Cargo.toml +++ b/contract-rs/02-owner-claims-money/Cargo.toml @@ -1,35 +1,27 @@ [package] -name = "contract-rs" -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 = { version = "5.4.0" } [dev-dependencies] -near-sdk = { version = "5.1.0", features = ["unit-testing"] } -near-workspaces = { version = "0.10.0", features = ["unstable"] } +near-sdk = { version = "5.4.0", features = ["unit-testing"] } +near-workspaces = { version = "0.11.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 \ No newline at end of file diff --git a/contract-rs/02-owner-claims-money/tests/test_basics.rs b/contract-rs/02-owner-claims-money/tests/test_basics.rs index 4ff7634d..a503b20f 100644 --- a/contract-rs/02-owner-claims-money/tests/test_basics.rs +++ b/contract-rs/02-owner-claims-money/tests/test_basics.rs @@ -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); diff --git a/contract-rs/03-owner-claims-winner-gets-nft/Cargo.toml b/contract-rs/03-owner-claims-winner-gets-nft/Cargo.toml index c5c280bf..fe2c8220 100644 --- a/contract-rs/03-owner-claims-winner-gets-nft/Cargo.toml +++ b/contract-rs/03-owner-claims-winner-gets-nft/Cargo.toml @@ -1,35 +1,27 @@ [package] -name = "contract-rs" -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 = { version = "5.4.0" } [dev-dependencies] -near-sdk = { version = "5.1.0", features = ["unit-testing"] } -near-workspaces = { version = "0.10.0", features = ["unstable"] } +near-sdk = { version = "5.4.0", features = ["unit-testing"] } +near-workspaces = { version = "0.11.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 \ No newline at end of file diff --git a/contract-rs/03-owner-claims-winner-gets-nft/tests/test_basics.rs b/contract-rs/03-owner-claims-winner-gets-nft/tests/test_basics.rs index 70c206f2..d0a766e7 100644 --- a/contract-rs/03-owner-claims-winner-gets-nft/tests/test_basics.rs +++ b/contract-rs/03-owner-claims-winner-gets-nft/tests/test_basics.rs @@ -1,8 +1,15 @@ use chrono::Utc; -use contract_rs::Bid; -use near_sdk::{Gas, NearToken}; use near_workspaces::result::ExecutionFinalResult; 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); const NFT_WASM_FILEPATH: &str = "./tests/non_fungible_token.wasm"; diff --git a/contract-rs/04-ft-owner-claims-winner-gets-nft/Cargo.toml b/contract-rs/04-ft-owner-claims-winner-gets-nft/Cargo.toml index c5c280bf..a798c9a6 100644 --- a/contract-rs/04-ft-owner-claims-winner-gets-nft/Cargo.toml +++ b/contract-rs/04-ft-owner-claims-winner-gets-nft/Cargo.toml @@ -1,35 +1,27 @@ [package] -name = "contract-rs" -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 = { version = "5.4.0" } [dev-dependencies] -near-sdk = { version = "5.1.0", features = ["unit-testing"] } -near-workspaces = { version = "0.10.0", features = ["unstable"] } +near-sdk = { version = "5.4.0", features = ["unit-testing"] } +near-workspaces = { version = "0.11.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 \ No newline at end of file diff --git a/contract-rs/04-ft-owner-claims-winner-gets-nft/tests/test_basics.rs b/contract-rs/04-ft-owner-claims-winner-gets-nft/tests/test_basics.rs index 7ce134c1..94f2c4e7 100644 --- a/contract-rs/04-ft-owner-claims-winner-gets-nft/tests/test_basics.rs +++ b/contract-rs/04-ft-owner-claims-winner-gets-nft/tests/test_basics.rs @@ -1,10 +1,17 @@ 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_workspaces::result::ExecutionFinalResult; use near_workspaces::{Account, Contract}; 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: U128, +} const TEN_NEAR: NearToken = NearToken::from_near(10); const FT_WASM_FILEPATH: &str = "./tests/fungible_token.wasm";