Skip to content

Commit

Permalink
got all the tests/err reporting to work
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyTimes committed Jan 15, 2022
1 parent 78737e4 commit 1f7f41e
Show file tree
Hide file tree
Showing 33 changed files with 971 additions and 1,969 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ jobs:
- name: Check Enclave Compile
run: |
yarn enclave:ci
- name: Check Mock-Enclave VM Compile
run: |
yarn mock-enclave:test
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exclude = [
'mock-enclave/src/skw-vm-host',
'mock-enclave/src/skw-vm-engine',
'mock-enclave/src/skw-vm-engine-cli',
'mock-enclave/src/near-test-contracts',
]
[profile.release]
panic = 'unwind'
5 changes: 0 additions & 5 deletions mock-enclave/result.json
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
{
"outcome": "None",
"state": "{\"YgkAAABzeXN0ZW0uc2s=\":\"DAAAAHN5c3RlbV9oZWxsbw==\",\"U1RBVEU=\":\"AQAAAGI=\"}",
"error": "None"
}
6 changes: 3 additions & 3 deletions mock-enclave/scripts/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function build() {
const srcPath = path.join(__dirname, '../src');

// compile the runner
execute(`cd ${srcPath}/near-vm-logic && cargo test --release`);
execute(`cd ${srcPath}/near-vm-runner && cargo test --release`);
execute(`cd ${srcPath}/near-vm-errors && cargo test --release`);
execute(`cd ${srcPath}/skw-vm-host && cargo check --release && cargo test --release`);
execute(`cd ${srcPath}/skw-vm-engine && cargo check --release && cargo test --release`);
execute(`cd ${srcPath}/skw-vm-engine-cli && cargo check --release && cargo test --release`);
}

build();
4 changes: 2 additions & 2 deletions mock-enclave/scripts/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ console.log('$ yarn vm', process.argv.slice(2).join(' '));

function compile() {
// compile the runner
execute('cd src/near-vm-runner-standalone && cargo build --release')
execute('cd src/skw-vm-engine-cli && cargo build --release')
}


Expand Down Expand Up @@ -48,7 +48,7 @@ function runVM({
wasmFile = "./wasm/greeting.wasm",
profiling = false
}) {
const runnerPath = "./src/near-vm-runner-standalone/target/release/near-vm-runner-standalone";
const runnerPath = "./src/skw-vm-engine-cli/target/release/skw-vm-engine-cli";
execute(`${runnerPath} --context '${injectOrigin(origin)}' --wasm-file ${wasmFile} --method-name ${methodName} --input \'${input}\' --state \'${stateInput}\' ${profiling ? "--timings" : ""} > result.json`)

// parse the output
Expand Down
55 changes: 55 additions & 0 deletions mock-enclave/src/near-test-contracts/Cargo.lock

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

22 changes: 11 additions & 11 deletions mock-enclave/src/near-test-contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ fn main() {

fn try_main() -> io::Result<()> {
build_contract("./test-contract-rs", &[], "test_contract_rs")?;
build_contract(
"./test-contract-rs",
&["--features", "nightly_protocol_features"],
"nightly_test_contract_rs",
)?;
build_contract("./contract-for-fuzzing-rs", &[], "contract_for_fuzzing_rs")?;
build_contract(
"./test-contract-rs",
&["--features", "base_protocol"],
"test_contract_rs_base_protocol",
)?;
// build_contract(
// "./test-contract-rs",
// &["--features", "nightly_protocol_features"],
// "nightly_test_contract_rs",
// )?;
// build_contract("./contract-for-fuzzing-rs", &[], "contract_for_fuzzing_rs")?;
// build_contract(
// "./test-contract-rs",
// &["--features", "base_protocol"],
// "test_contract_rs_base_protocol",
// )?;
Ok(())
}

Expand Down
30 changes: 15 additions & 15 deletions mock-enclave/src/near-test-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ pub fn rs_contract() -> &'static [u8] {
CONTRACT.get_or_init(|| read_contract("test_contract_rs.wasm")).as_slice()
}

pub fn rs_contract_base_protocol() -> &'static [u8] {
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
CONTRACT.get_or_init(|| read_contract("test_contract_rs_base_protocol.wasm")).as_slice()
}
// pub fn rs_contract_base_protocol() -> &'static [u8] {
// static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
// CONTRACT.get_or_init(|| read_contract("test_contract_rs_base_protocol.wasm")).as_slice()
// }

pub fn nightly_rs_contract() -> &'static [u8] {
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
CONTRACT.get_or_init(|| read_contract("nightly_test_contract_rs.wasm")).as_slice()
}
// pub fn nightly_rs_contract() -> &'static [u8] {
// static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
// CONTRACT.get_or_init(|| read_contract("nightly_test_contract_rs.wasm")).as_slice()
// }

pub fn ts_contract() -> &'static [u8] {
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
CONTRACT.get_or_init(|| read_contract("test_contract_ts.wasm")).as_slice()
}

pub fn fuzzing_contract() -> &'static [u8] {
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
CONTRACT.get_or_init(|| read_contract("contract_for_fuzzing_rs.wasm")).as_slice()
}
// pub fn fuzzing_contract() -> &'static [u8] {
// static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
// CONTRACT.get_or_init(|| read_contract("contract_for_fuzzing_rs.wasm")).as_slice()
// }

/// Read given wasm file or panic if unable to.
fn read_contract(file_name: &str) -> Vec<u8> {
Expand All @@ -54,11 +54,11 @@ fn read_contract(file_name: &str) -> Vec<u8> {
#[test]
fn smoke_test() {
assert!(!rs_contract().is_empty());
assert!(!nightly_rs_contract().is_empty());
// assert!(!nightly_rs_contract().is_empty());
assert!(!ts_contract().is_empty());
assert!(!trivial_contract().is_empty());
assert!(!fuzzing_contract().is_empty());
assert!(!rs_contract_base_protocol().is_empty());
// assert!(!fuzzing_contract().is_empty());
// assert!(!rs_contract_base_protocol().is_empty());
}

pub fn many_functions_contract(function_count: u32) -> Vec<u8> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "test-contract-rs"
version = "0.1.0"
authors = ["Near Inc <[email protected]>"]
authors = ["SkyeKiwi <[email protected]>", "Near Inc <[email protected]>"]
publish = false
# Please update rust-toolchain.toml as well when changing version here:
rust-version = "1.56.0"
Expand Down Expand Up @@ -30,6 +30,3 @@ incremental = false
members = []

[features]
nightly_protocol_features = ["protocol_feature_alt_bn128"]
protocol_feature_alt_bn128 = []
base_protocol = []
Loading

0 comments on commit 1f7f41e

Please sign in to comment.