Skip to content

Commit

Permalink
Integrations tests to cargo tests (#11)
Browse files Browse the repository at this point in the history
* integrations tests to cargo tests

* to dev deps

* separated withdrawal tests

* remove container after build, update bin
  • Loading branch information
VladasZ authored Sep 8, 2023
1 parent 7a16a2a commit c216b24
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 86 deletions.
99 changes: 57 additions & 42 deletions 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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ cov:
./scripts/coverage.sh

test:
cargo test --all
cargo test --package sweat_jar

integration:
cargo run -p integration-tests
cargo test --package integration-tests

int: integration

Expand Down
1 change: 0 additions & 1 deletion contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ crate-type = ["cdylib"]
near-sdk = { workspace = true }

near-contract-standards = "4.1.1"
uint = { version = "0.9.3", default-features = false }
ed25519-dalek = "1.0.1"
near-self-update = { git = "https://github.com/sweatco/near-self-update.git", rev = "7064db3cdd924efc7fa7c00664920a2b482e7bcf" }

Expand Down
2 changes: 1 addition & 1 deletion contract/src/ft_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl FtTransferPromise for Promise {
let args = json!({
"receiver_id": receiver_id,
"amount": amount.to_string(),
"memo": memo.unwrap_or("".to_string()),
"memo": memo.unwrap_or_default(),
})
.to_string()
.as_bytes()
Expand Down
4 changes: 2 additions & 2 deletions contract/src/withdraw/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ impl Contract {
WithdrawalFee::Fix(amount) => *amount,
WithdrawalFee::Percent(percent) => percent * jar.principal,
})
.map(|fee| Fee {
amount: fee,
.map(|amount| Fee {
beneficiary_id: self.fee_account_id.clone(),
amount,
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ version = "1.0.0"
publish = false
edition = "2021"

[[bin]]
name = "integration-tests"
[lib]
name = "integration_tests"

[dependencies]
[dev-dependencies]
near-sdk = { workspace = true }

anyhow = "1.0"
Expand Down
7 changes: 2 additions & 5 deletions integration-tests/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ impl Context {
let worker = workspaces::sandbox().await?;
let root_account = worker.dev_create_account().await?;

let jar_contract_path = env::args().nth(1).unwrap_or("res/sweat_jar.wasm".to_string());
let ft_contract_path = env::args().nth(2).unwrap_or("res/sweat.wasm".to_string());

let jar_contract = worker.dev_deploy(&Self::load_wasm(&jar_contract_path)).await?;
let ft_contract = worker.dev_deploy(&Self::load_wasm(&ft_contract_path)).await?;
let jar_contract = worker.dev_deploy(&Self::load_wasm("../res/sweat_jar.wasm")).await?;
let ft_contract = worker.dev_deploy(&Self::load_wasm("../res/sweat.wasm")).await?;

println!("@@ jar contract deployed to {}", jar_contract.id());
println!("@@ ft contract deployed to {}", ft_contract.id());
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/src/happy_flow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{common::ValueGetters, context::Context, product::RegisterProductCommand};

pub(crate) async fn run() -> anyhow::Result<()> {
#[tokio::test]
async fn happy_flow() -> anyhow::Result<()> {
println!("👷🏽 Run happy flow test");

let mut context = Context::new().await?;
Expand Down
Loading

0 comments on commit c216b24

Please sign in to comment.