Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Jan 30, 2024
1 parent 88a5560 commit 5c9f1ee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arbitrator/stylus/tests/evm-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
stylus-sdk = { path = "../../../langs/rust/stylus-sdk" }
stylus-sdk = { path = "../../../langs/rust/stylus-sdk", features = ["debug"] }
hex = "0.4.3"

[profile.release]
Expand Down
7 changes: 7 additions & 0 deletions arbitrator/stylus/tests/evm-data/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ fn user_main(input: Vec<u8>) -> Result<Vec<u8>, Vec<u8>> {
let eth_precompile_codehash = eth_precompile_addr.codehash();
let arb_precompile_codehash = arb_test_addr.codehash();
let contract_codehash = contract_addr.codehash();

let code = contract_addr.code();
assert_eq!(code.len(), contract_addr.code_size());
assert_eq!(arb_test_addr.code_size(), 1);
assert_eq!(arb_test_addr.code(), [0xfe]);
assert_eq!(eth_precompile_addr.code_size(), 0);
assert_eq!(eth_precompile_addr.code(), []);

let basefee = block::basefee();
let chainid = block::chainid();
let coinbase = block::coinbase();
Expand Down
2 changes: 2 additions & 0 deletions arbitrator/wasm-libraries/user-host-trait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ pub trait UserHost: GasMeteredMachine {
dest: u32,
) -> Result<u32, Self::Err> {
self.buy_ink(HOSTIO_INK + EVM_API_INK)?;
self.require_gas(evm::COLD_ACCOUNT_GAS)?; // not necessary since we also check in Go
let address = self.read_bytes20(address)?;
let gas = self.gas_left()?;

Expand All @@ -504,6 +505,7 @@ pub trait UserHost: GasMeteredMachine {
/// [`EXT_CODESIZE`]: https://www.evm.codes/#3B
fn account_code_size(&mut self, address: u32) -> Result<u32, Self::Err> {
self.buy_ink(HOSTIO_INK + EVM_API_INK)?;
self.require_gas(evm::COLD_ACCOUNT_GAS)?; // not necessary since we also check in Go
let address = self.read_bytes20(address)?;
let gas = self.gas_left()?;

Expand Down
2 changes: 1 addition & 1 deletion arbos/programs/native_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func newApi(
emit_log: (*[0]byte)(C.emitLogWrap),
account_balance: (*[0]byte)(C.accountBalanceWrap),
account_code: (*[0]byte)(C.accountCodeWrap),
account_codehash: (*[0]byte)(C.accountCodeHashWrap),
account_code_size: (*[0]byte)(C.accountCodeSizeWrap),
account_codehash: (*[0]byte)(C.accountCodeHashWrap),
add_pages: (*[0]byte)(C.addPagesWrap),
capture_hostio: (*[0]byte)(C.captureHostioWrap),
id: id,
Expand Down
2 changes: 1 addition & 1 deletion contracts

0 comments on commit 5c9f1ee

Please sign in to comment.