-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pass args to make test * Add InfiniteLoop test contract * Fix Conbase test contract comments * Pay l1 fee for halted tx
- Loading branch information
Showing
9 changed files
with
209 additions
and
16 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
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
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 @@ | ||
[{"inputs":[],"name":"infiniteLoop","outputs":[],"stateMutability":"pure","type":"function"}] |
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 @@ | ||
6080604052348015600e575f80fd5b5060f98061001b5f395ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c80631dbf353d14602a575b5f80fd5b60306032565b005b5f5b600115604857806042906081565b90506034565b50565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f819050919050565b5f6089826078565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820360b85760b7604b565b5b60018201905091905056fea264697066735822122063d45c8f67ee9489817454d921213bbbd708c138a0e8b730c7f0f0bfc61ceaac64736f6c63430008190033 |
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,14 @@ | ||
// SPDX-License-Identifier: GPL-3 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
// solc --abi --bin InfiniteLoop.sol -o . --overwrite | ||
contract InfiniteLoop { | ||
// Function to infinitely loop and do nothing. | ||
function infiniteLoop() pure public { | ||
uint256 a = 0; | ||
while (true) { | ||
++a; | ||
} | ||
} | ||
} |
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,65 @@ | ||
use std::any::Any; | ||
|
||
use ethers_contract::BaseContract; | ||
use ethers_core::types::Bytes; | ||
|
||
use super::{make_contract_from_abi, test_data_path, TestContract}; | ||
|
||
/// InfiniteLoopContract wrapper. | ||
pub struct InfiniteLoopContract { | ||
bytecode: Bytes, | ||
base_contract: BaseContract, | ||
} | ||
|
||
impl Default for InfiniteLoopContract { | ||
fn default() -> Self { | ||
let contract_data = { | ||
let mut path = test_data_path(); | ||
path.push("InfiniteLoop.bin"); | ||
|
||
let contract_data = std::fs::read_to_string(path).unwrap(); | ||
hex::decode(contract_data).unwrap() | ||
}; | ||
|
||
let contract = { | ||
let mut path = test_data_path(); | ||
path.push("InfiniteLoop.abi"); | ||
|
||
make_contract_from_abi(path) | ||
}; | ||
|
||
Self { | ||
bytecode: Bytes::from(contract_data), | ||
base_contract: contract, | ||
} | ||
} | ||
} | ||
|
||
impl TestContract for InfiniteLoopContract { | ||
/// Caller bytecode. | ||
fn byte_code(&self) -> Bytes { | ||
self.byte_code() | ||
} | ||
/// Dynamically dispatch from trait. Downcast to InfiniteLoopContract. | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
/// Create the default instance of the smart contract. | ||
fn default_(&self) -> Self | ||
where | ||
Self: Sized, | ||
{ | ||
Self::default() | ||
} | ||
} | ||
|
||
impl InfiniteLoopContract { | ||
/// InfiniteLoop bytecode. | ||
pub fn byte_code(&self) -> Bytes { | ||
self.bytecode.clone() | ||
} | ||
/// Calls InfiniteLoop::infiniteLoop. | ||
pub fn call_infinite_loop(&self) -> Bytes { | ||
self.base_contract.encode("infiniteLoop", ()).unwrap() | ||
} | ||
} |
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