Skip to content

Commit

Permalink
first passing rs test
Browse files Browse the repository at this point in the history
  • Loading branch information
idea404 committed May 4, 2022
1 parent 1a4d294 commit dc2c3a8
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 140 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true

[workspace]
members = []
16 changes: 6 additions & 10 deletions ava.config.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
require('util').inspect.defaultOptions.depth = 5; // Increase AVA's printing depth
require("util").inspect.defaultOptions.depth = 5; // Increase AVA's printing depth

module.exports = {
timeout: '300000',
files: ['**/*.ava.ts'],
timeout: "300000",
files: ["**/*.ava.ts"],
failWithoutAssertions: false,
extensions: [
'ts'
],
require: [
'ts-node/register',
],
};
extensions: ["ts"],
require: ["ts-node/register"],
};
126 changes: 0 additions & 126 deletions integration-tests/js/test.js

This file was deleted.

22 changes: 22 additions & 0 deletions integration-tests/rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "rust-status-message-integration-tests"
version = "1.0.0"
publish = false
edition = "2018"

[dev-dependencies]
anyhow = "1.0"
borsh = "0.9"
maplit = "1.0"
near-units = "0.2.0"
# arbitrary_precision enabled for u128 types that workspaces requires for Balance types
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
tokio = { version = "1.18.1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
workspaces = "0.2.1"
pkg-config = "0.3.1"

[[example]]
name = "set"
path = "src/set.rs"
39 changes: 39 additions & 0 deletions integration-tests/rs/src/set.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use serde_json::json;
use near_units::parse_near;
use workspaces::prelude::*;

const WASM_FILEPATH: &str = "../../res/status_message.wasm";

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let worker = workspaces::sandbox().await?;
let wasm = std::fs::read(WASM_FILEPATH)?;
let contract = worker.dev_deploy(&wasm).await?;

// create accounts
let owner = worker.root_account();
let alice = owner
.create_subaccount(&worker, "alice")
.initial_balance(parse_near!("30 N"))
.transact()
.await?
.into_result()?;

// begin test
alice
.call(&worker, contract.id(), "set_status")
.args_json(json!({ "message": "hello" }))?
.transact()
.await?;

let alice_status: String = owner
.call(&worker, contract.id(), "get_status")
.args_json(json!({ "account_id": alice.id() }))?
.transact()
.await?
.json()?;

assert_eq!(alice_status, "hello");
println!("Passed ✅");
Ok(())
}
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "npm run test:unit && npm run test:integration",
"test:unit": "cargo test -- --nocapture",
"test:integration": "npm run build && npm run postbuild && npm run test:integration:rs && npm run test:integration:ts",
"test:integration:rs": "cd integration-tests/rs && cargo run --example ",
"test:integration:rs": "cd integration-tests/rs && cargo run --example set",
"test:integration:ts": "ava --verbose"
},
"repository": {
Expand Down

0 comments on commit dc2c3a8

Please sign in to comment.