Fix eth_call so it doesn't need the secret of the sender.
This commit is contained in:
@@ -905,7 +905,7 @@ mod tests {
|
||||
gas: U256::from(100_000),
|
||||
gas_price: U256::zero(),
|
||||
nonce: U256::zero()
|
||||
}.fake_sign();
|
||||
}.invalid_sign();
|
||||
let mut state_result = get_temp_state();
|
||||
let mut state = state_result.reference_mut();
|
||||
let mut info = EnvInfo::default();
|
||||
|
||||
@@ -134,7 +134,7 @@ impl Transaction {
|
||||
|
||||
/// Useful for test incorrectly signed transactions.
|
||||
#[cfg(test)]
|
||||
pub fn fake_sign(self) -> SignedTransaction {
|
||||
pub fn invalid_sign(self) -> SignedTransaction {
|
||||
SignedTransaction {
|
||||
unsigned: self,
|
||||
r: U256::zero(),
|
||||
@@ -145,6 +145,18 @@ impl Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Specify the sender; this won't survive the serialize/deserialize process, but can be cloned.
|
||||
pub fn fake_sign(self, from: Address) -> SignedTransaction {
|
||||
SignedTransaction {
|
||||
unsigned: self,
|
||||
r: U256::zero(),
|
||||
s: U256::zero(),
|
||||
v: 0,
|
||||
hash: Cell::new(None),
|
||||
sender: Cell::new(Some(from)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the transaction cost in gas for the given params.
|
||||
pub fn gas_required_for(is_create: bool, data: &[u8], schedule: &Schedule) -> u64 {
|
||||
data.iter().fold(
|
||||
@@ -342,3 +354,19 @@ fn signing() {
|
||||
}.sign(&key.secret());
|
||||
assert_eq!(Address::from(key.public().sha3()), t.sender().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fake_signing() {
|
||||
let t = Transaction {
|
||||
action: Action::Create,
|
||||
nonce: U256::from(42),
|
||||
gas_price: U256::from(3000),
|
||||
gas: U256::from(50_000),
|
||||
value: U256::from(1),
|
||||
data: b"Hello!".to_vec()
|
||||
}.fake_sign(Address::from(0x69));
|
||||
assert_eq!(Address::from(0x69), t.sender().unwrap());
|
||||
|
||||
let t = t.clone();
|
||||
assert_eq!(Address::from(0x69), t.sender().unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user