Skip to content

Instantly share code, notes, and snippets.

@matklad
Created March 6, 2021 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matklad/b6992862d1e55263e671e2011aad3488 to your computer and use it in GitHub Desktop.
Save matklad/b6992862d1e55263e671e2011aad3488 to your computer and use it in GitHub Desktop.
pub struct TestResource {
path: &'static str,
cell: OnceCell<Vec<u8>>,
}
impl TestResource {
pub const fn new(path: &'static str) -> TestResource {
TestResource { path, cell: OnceCell::new() }
}
pub fn bytes(&self) -> &[u8] {
self.cell.get_or_init(|| {
let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let path = Path::new(dir.as_str()).join(self.path);
std::fs::read(&path).unwrap()
})
}
}
static TEST_CONTRACT: TestResource =
TestResource::new("../../runtime/near-vm-runner/tests/res/test_contract_rs.wasm");
#[test]
fn feature() {
compile(TEST_CONTRACT.bytes())
}
fn compile(x: &[u8]) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment