Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Add wasm32 support to integration tests #590

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ jobs:
if: matrix.rust == 'nightly' && matrix.os != 'windows-latest'
shell: bash

wasm-test:
name: Wasm tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- run: wasm-pack test --node

coverage:
name: Coverage
runs-on: ubuntu-latest
Expand Down
129 changes: 129 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ winapi = { version = "0.3", features = ["memoryapi", "sysinfoapi", "winnt", "err
[target.'cfg(not(windows))'.dependencies]
libc = { version = "0.2", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.6", features = ["js", "wasm-bindgen"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[features]
default = ["jit"]
jit = ["libc", "winapi"]
Expand Down
2 changes: 2 additions & 0 deletions tests/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern crate test_utils;
use solana_rbpf::{assembler::assemble, ebpf, program::BuiltinProgram, vm::TestContextObject};
use std::sync::Arc;
use test_utils::{TCP_SACK_ASM, TCP_SACK_BIN};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

fn asm(src: &str) -> Result<Vec<ebpf::Insn>, String> {
let executable = assemble::<TestContextObject>(src, Arc::new(BuiltinProgram::new_mock()))?;
Expand Down
2 changes: 2 additions & 0 deletions tests/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use solana_rbpf::{
vm::{Config, TestContextObject},
};
use std::sync::Arc;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

// Using a macro to keep actual line numbers in failure output
macro_rules! disasm {
Expand Down
2 changes: 2 additions & 0 deletions tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern crate libc;
extern crate solana_rbpf;
extern crate test_utils;
extern crate thiserror;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use byteorder::{ByteOrder, LittleEndian};
#[cfg(all(not(windows), target_arch = "x86_64"))]
Expand Down
2 changes: 2 additions & 0 deletions tests/exercise_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern crate libc;
extern crate solana_rbpf;
extern crate test_utils;
extern crate thiserror;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use rand::{rngs::SmallRng, RngCore, SeedableRng};
use solana_rbpf::{
Expand Down
Loading
Loading