Created
March 6, 2021 13:55
-
-
Save matklad/b6992862d1e55263e671e2011aad3488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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