This repository has been archived by the owner on Feb 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from paritytech/call-gasleft
call_gasleft test added
- Loading branch information
Showing
6 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
Binary file not shown.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![no_std] | ||
|
||
#[macro_use] extern crate pwasm_std; | ||
extern crate pwasm_ethereum; | ||
|
||
use pwasm_std::logger; | ||
use pwasm_std::hash::Address; | ||
use pwasm_ethereum::{call as ext_call, gas_left as ext_gasleft, ret}; | ||
|
||
#[no_mangle] | ||
pub fn call() { | ||
let addr = Address::from([99, 88, 77, 66, 55, 44, 33, 22, 11, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 0]); | ||
|
||
let input = [129u8, 123, 113, 107, 101, 97]; | ||
let mut temp = vec![0u8; 256]; | ||
// `700` is a fixed CALL price, that's why we have to subtract it | ||
match ext_call(ext_gasleft() - 700, &addr, 1000000000.into(), &input, &mut temp[..]) { | ||
Ok(_) => { | ||
logger::debug("Call succeed"); | ||
}, | ||
Err(_) => { | ||
logger::debug("Call failed"); | ||
} | ||
} | ||
|
||
ret(&[]); | ||
} |
This file contains 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