runtime.rs 515 B

123456789101112131415161718192021
  1. use borsh::BorshSerialize;
  2. use darkfi::{
  3. runtime::{util::serialize_payload, vm_runtime::Runtime},
  4. Result,
  5. };
  6. use pasta_curves::pallas;
  7. use smart_contract::Args;
  8. #[test]
  9. fn run_contract() -> Result<()> {
  10. let wasm_bytes = std::fs::read("smart_contract.wasm")?;
  11. let mut runtime = Runtime::new(&wasm_bytes)?;
  12. let args = Args { a: pallas::Base::from(777), b: pallas::Base::from(666) };
  13. let payload = args.try_to_vec()?;
  14. let input = serialize_payload(&payload);
  15. runtime.run(&input)
  16. }