mostly purge x! from ethcore
This commit is contained in:
parent
3788b3a149
commit
ff7c755930
@ -261,7 +261,7 @@ mod tests {
|
|||||||
let mut db = MemoryDB::new();
|
let mut db = MemoryDB::new();
|
||||||
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
||||||
let rlp = {
|
let rlp = {
|
||||||
let mut a = Account::new_contract(x!(69), x!(0));
|
let mut a = Account::new_contract(69.into(), 0.into());
|
||||||
a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64)));
|
a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64)));
|
||||||
a.commit_storage(&mut db);
|
a.commit_storage(&mut db);
|
||||||
a.init_code(vec![]);
|
a.init_code(vec![]);
|
||||||
@ -281,7 +281,7 @@ mod tests {
|
|||||||
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
||||||
|
|
||||||
let rlp = {
|
let rlp = {
|
||||||
let mut a = Account::new_contract(x!(69), x!(0));
|
let mut a = Account::new_contract(69.into(), 0.into());
|
||||||
a.init_code(vec![0x55, 0x44, 0xffu8]);
|
a.init_code(vec![0x55, 0x44, 0xffu8]);
|
||||||
a.commit_code(&mut db);
|
a.commit_code(&mut db);
|
||||||
a.rlp()
|
a.rlp()
|
||||||
@ -296,10 +296,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn commit_storage() {
|
fn commit_storage() {
|
||||||
let mut a = Account::new_contract(x!(69), x!(0));
|
let mut a = Account::new_contract(69.into(), 0.into());
|
||||||
let mut db = MemoryDB::new();
|
let mut db = MemoryDB::new();
|
||||||
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
||||||
a.set_storage(x!(0), x!(0x1234));
|
a.set_storage(0.into(), 0x1234.into());
|
||||||
assert_eq!(a.storage_root(), None);
|
assert_eq!(a.storage_root(), None);
|
||||||
a.commit_storage(&mut db);
|
a.commit_storage(&mut db);
|
||||||
assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2");
|
assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2");
|
||||||
@ -307,21 +307,21 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn commit_remove_commit_storage() {
|
fn commit_remove_commit_storage() {
|
||||||
let mut a = Account::new_contract(x!(69), x!(0));
|
let mut a = Account::new_contract(69.into(), 0.into());
|
||||||
let mut db = MemoryDB::new();
|
let mut db = MemoryDB::new();
|
||||||
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
||||||
a.set_storage(x!(0), x!(0x1234));
|
a.set_storage(0.into(), 0x1234.into());
|
||||||
a.commit_storage(&mut db);
|
a.commit_storage(&mut db);
|
||||||
a.set_storage(x!(1), x!(0x1234));
|
a.set_storage(1.into(), 0x1234.into());
|
||||||
a.commit_storage(&mut db);
|
a.commit_storage(&mut db);
|
||||||
a.set_storage(x!(1), x!(0));
|
a.set_storage(1.into(), 0.into());
|
||||||
a.commit_storage(&mut db);
|
a.commit_storage(&mut db);
|
||||||
assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2");
|
assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn commit_code() {
|
fn commit_code() {
|
||||||
let mut a = Account::new_contract(x!(69), x!(0));
|
let mut a = Account::new_contract(69.into(), 0.into());
|
||||||
let mut db = MemoryDB::new();
|
let mut db = MemoryDB::new();
|
||||||
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
let mut db = AccountDBMut::new(&mut db, &Address::new());
|
||||||
a.init_code(vec![0x55, 0x44, 0xffu8]);
|
a.init_code(vec![0x55, 0x44, 0xffu8]);
|
||||||
|
@ -20,7 +20,7 @@ impl<'db> AccountDB<'db> {
|
|||||||
pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> {
|
pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> {
|
||||||
AccountDB {
|
AccountDB {
|
||||||
db: db,
|
db: db,
|
||||||
address: x!(address),
|
address: address.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ impl<'db> AccountDBMut<'db> {
|
|||||||
pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> {
|
pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> {
|
||||||
AccountDBMut {
|
AccountDBMut {
|
||||||
db: db,
|
db: db,
|
||||||
address: x!(address),
|
address: address.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +86,9 @@ impl Engine for BasicAuthority {
|
|||||||
let gas_limit = parent.gas_limit;
|
let gas_limit = parent.gas_limit;
|
||||||
let bound_divisor = self.our_params.gas_limit_bound_divisor;
|
let bound_divisor = self.our_params.gas_limit_bound_divisor;
|
||||||
if gas_limit < gas_floor_target {
|
if gas_limit < gas_floor_target {
|
||||||
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - x!(1))
|
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
|
||||||
} else {
|
} else {
|
||||||
max(gas_floor_target, gas_limit - gas_limit / bound_divisor + x!(1))
|
max(gas_floor_target, gas_limit - gas_limit / bound_divisor + 1.into())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
header.note_dirty();
|
header.note_dirty();
|
||||||
@ -211,12 +211,12 @@ mod tests {
|
|||||||
let engine = new_test_authority().engine;
|
let engine = new_test_authority().engine;
|
||||||
let schedule = engine.schedule(&EnvInfo {
|
let schedule = engine.schedule(&EnvInfo {
|
||||||
number: 10000000,
|
number: 10000000,
|
||||||
author: x!(0),
|
author: 0.into(),
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
difficulty: x!(0),
|
difficulty: 0.into(),
|
||||||
last_hashes: vec![],
|
last_hashes: vec![],
|
||||||
gas_used: x!(0),
|
gas_used: 0.into(),
|
||||||
gas_limit: x!(0)
|
gas_limit: 0.into()
|
||||||
});
|
});
|
||||||
|
|
||||||
assert!(schedule.stack_limit > 0);
|
assert!(schedule.stack_limit > 0);
|
||||||
@ -278,7 +278,7 @@ mod tests {
|
|||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let last_hashes = vec![genesis_header.hash()];
|
let last_hashes = vec![genesis_header.hash()];
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, addr.clone(), x!(3141562), vec![]);
|
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, addr.clone(), 3141562.into(), vec![]);
|
||||||
let b = b.close_and_lock();
|
let b = b.close_and_lock();
|
||||||
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
|
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ pub fn enact(header: &Header, transactions: &[SignedTransaction], uncles: &[Head
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut b = OpenBlock::new(engine, vm_factory, tracing, db, parent, last_hashes, header.author().clone(), x!(3141562), header.extra_data().clone());
|
let mut b = OpenBlock::new(engine, vm_factory, tracing, db, parent, last_hashes, header.author().clone(), 3141562.into(), header.extra_data().clone());
|
||||||
b.set_difficulty(*header.difficulty());
|
b.set_difficulty(*header.difficulty());
|
||||||
b.set_gas_limit(*header.gas_limit());
|
b.set_gas_limit(*header.gas_limit());
|
||||||
b.set_timestamp(header.timestamp());
|
b.set_timestamp(header.timestamp());
|
||||||
@ -514,7 +514,7 @@ mod tests {
|
|||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let last_hashes = vec![genesis_header.hash()];
|
let last_hashes = vec![genesis_header.hash()];
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), x!(3141562), vec![]);
|
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), 3141562.into(), vec![]);
|
||||||
let b = b.close_and_lock();
|
let b = b.close_and_lock();
|
||||||
let _ = b.seal(engine.deref(), vec![]);
|
let _ = b.seal(engine.deref(), vec![]);
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ mod tests {
|
|||||||
let mut db = db_result.take();
|
let mut db = db_result.take();
|
||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, vec![genesis_header.hash()], Address::zero(), x!(3141562), vec![]).close_and_lock().seal(engine.deref(), vec![]).unwrap();
|
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, vec![genesis_header.hash()], Address::zero(), 3141562.into(), vec![]).close_and_lock().seal(engine.deref(), vec![]).unwrap();
|
||||||
let orig_bytes = b.rlp_bytes();
|
let orig_bytes = b.rlp_bytes();
|
||||||
let orig_db = b.drain();
|
let orig_db = b.drain();
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ mod tests {
|
|||||||
let mut db = db_result.take();
|
let mut db = db_result.take();
|
||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let mut open_block = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, vec![genesis_header.hash()], Address::zero(), x!(3141562), vec![]);
|
let mut open_block = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, vec![genesis_header.hash()], Address::zero(), 3141562.into(), vec![]);
|
||||||
let mut uncle1_header = Header::new();
|
let mut uncle1_header = Header::new();
|
||||||
uncle1_header.extra_data = b"uncle1".to_vec();
|
uncle1_header.extra_data = b"uncle1".to_vec();
|
||||||
let mut uncle2_header = Header::new();
|
let mut uncle2_header = Header::new();
|
||||||
|
@ -311,17 +311,17 @@ impl BlockQueue {
|
|||||||
let h = header.hash();
|
let h = header.hash();
|
||||||
{
|
{
|
||||||
if self.processing.read().unwrap().contains(&h) {
|
if self.processing.read().unwrap().contains(&h) {
|
||||||
return Err(x!(ImportError::AlreadyQueued));
|
return Err(ImportError::AlreadyQueued.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bad = self.verification.bad.lock().unwrap();
|
let mut bad = self.verification.bad.lock().unwrap();
|
||||||
if bad.contains(&h) {
|
if bad.contains(&h) {
|
||||||
return Err(x!(ImportError::KnownBad));
|
return Err(ImportError::KnownBad.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if bad.contains(&header.parent_hash) {
|
if bad.contains(&header.parent_hash) {
|
||||||
bad.insert(h.clone());
|
bad.insert(h.clone());
|
||||||
return Err(x!(ImportError::KnownBad));
|
return Err(ImportError::KnownBad.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,10 +655,10 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
|
|||||||
{
|
{
|
||||||
let header = BlockView::new(&bytes).header_view();
|
let header = BlockView::new(&bytes).header_view();
|
||||||
if self.chain.is_known(&header.sha3()) {
|
if self.chain.is_known(&header.sha3()) {
|
||||||
return Err(x!(ImportError::AlreadyInChain));
|
return Err(ImportError::AlreadyInChain.into());
|
||||||
}
|
}
|
||||||
if self.block_status(BlockID::Hash(header.parent_hash())) == BlockStatus::Unknown {
|
if self.block_status(BlockID::Hash(header.parent_hash())) == BlockStatus::Unknown {
|
||||||
return Err(x!(BlockError::UnknownParent(header.parent_hash())));
|
return Err(BlockError::UnknownParent(header.parent_hash()).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.block_queue.import_block(bytes)
|
self.block_queue.import_block(bytes)
|
||||||
|
@ -47,10 +47,10 @@ impl Default for EnvInfo {
|
|||||||
number: 0,
|
number: 0,
|
||||||
author: Address::new(),
|
author: Address::new(),
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
difficulty: x!(0),
|
difficulty: 0.into(),
|
||||||
gas_limit: x!(0),
|
gas_limit: 0.into(),
|
||||||
last_hashes: vec![],
|
last_hashes: vec![],
|
||||||
gas_used: x!(0),
|
gas_used: 0.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,15 +92,15 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(env_info.number, 1112339);
|
assert_eq!(env_info.number, 1112339);
|
||||||
assert_eq!(env_info.author, Address::from_str("000000f00000000f000000000000f00000000f00").unwrap());
|
assert_eq!(env_info.author, Address::from_str("000000f00000000f000000000000f00000000f00").unwrap());
|
||||||
assert_eq!(env_info.gas_limit, x!(40000));
|
assert_eq!(env_info.gas_limit, 40000.into());
|
||||||
assert_eq!(env_info.difficulty, x!(50000));
|
assert_eq!(env_info.difficulty, 50000.into());
|
||||||
assert_eq!(env_info.gas_used, x!(0));
|
assert_eq!(env_info.gas_used, 0.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_can_be_created_as_default() {
|
fn it_can_be_created_as_default() {
|
||||||
let default_env_info = EnvInfo::default();
|
let default_env_info = EnvInfo::default();
|
||||||
|
|
||||||
assert_eq!(default_env_info.difficulty, x!(0));
|
assert_eq!(default_env_info.difficulty, 0.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ impl Engine for Ethash {
|
|||||||
let gas_limit = parent.gas_limit;
|
let gas_limit = parent.gas_limit;
|
||||||
let bound_divisor = self.ethash_params.gas_limit_bound_divisor;
|
let bound_divisor = self.ethash_params.gas_limit_bound_divisor;
|
||||||
if gas_limit < gas_floor_target {
|
if gas_limit < gas_floor_target {
|
||||||
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - x!(1))
|
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
|
||||||
} else {
|
} else {
|
||||||
max(gas_floor_target, gas_limit - gas_limit / bound_divisor + x!(1) + (header.gas_used * x!(6) / x!(5)) / bound_divisor)
|
max(gas_floor_target, gas_limit - gas_limit / bound_divisor + 1.into() + (header.gas_used * 6.into() / 5.into()) / bound_divisor)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
header.note_dirty();
|
header.note_dirty();
|
||||||
@ -255,12 +255,12 @@ impl Ethash {
|
|||||||
|
|
||||||
/// Convert an Ethash boundary to its original difficulty. Basically just `f(x) = 2^256 / x`.
|
/// Convert an Ethash boundary to its original difficulty. Basically just `f(x) = 2^256 / x`.
|
||||||
pub fn boundary_to_difficulty(boundary: &H256) -> U256 {
|
pub fn boundary_to_difficulty(boundary: &H256) -> U256 {
|
||||||
U256::from((U512::one() << 256) / x!(U256::from(boundary.as_slice())))
|
U256::from((U512::one() << 256) / U256::from(boundary.as_slice()).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert an Ethash difficulty to the target boundary. Basically just `f(x) = 2^256 / x`.
|
/// Convert an Ethash difficulty to the target boundary. Basically just `f(x) = 2^256 / x`.
|
||||||
pub fn difficulty_to_boundary(difficulty: &U256) -> H256 {
|
pub fn difficulty_to_boundary(difficulty: &U256) -> H256 {
|
||||||
x!(U256::from((U512::one() << 256) / x!(difficulty)))
|
U256::from((U512::one() << 256) / difficulty.into()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_ethash(hash: H256) -> EH256 {
|
fn to_ethash(hash: H256) -> EH256 {
|
||||||
@ -308,7 +308,7 @@ mod tests {
|
|||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let last_hashes = vec![genesis_header.hash()];
|
let last_hashes = vec![genesis_header.hash()];
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), x!(3141562), vec![]);
|
let b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), 3141562.into(), vec![]);
|
||||||
let b = b.close();
|
let b = b.close();
|
||||||
assert_eq!(b.state().balance(&Address::zero()), U256::from_str("4563918244f40000").unwrap());
|
assert_eq!(b.state().balance(&Address::zero()), U256::from_str("4563918244f40000").unwrap());
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ mod tests {
|
|||||||
spec.ensure_db_good(db.as_hashdb_mut());
|
spec.ensure_db_good(db.as_hashdb_mut());
|
||||||
let last_hashes = vec![genesis_header.hash()];
|
let last_hashes = vec![genesis_header.hash()];
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let mut b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), x!(3141562), vec![]);
|
let mut b = OpenBlock::new(engine.deref(), &vm_factory, false, db, &genesis_header, last_hashes, Address::zero(), 3141562.into(), vec![]);
|
||||||
let mut uncle = Header::new();
|
let mut uncle = Header::new();
|
||||||
let uncle_author = address_from_hex("ef2d6d194084c2de36e0dabfce45d046b37d1106");
|
let uncle_author = address_from_hex("ef2d6d194084c2de36e0dabfce45d046b37d1106");
|
||||||
uncle.author = uncle_author.clone();
|
uncle.author = uncle_author.clone();
|
||||||
@ -346,24 +346,24 @@ mod tests {
|
|||||||
let engine = new_morden().engine;
|
let engine = new_morden().engine;
|
||||||
let schedule = engine.schedule(&EnvInfo {
|
let schedule = engine.schedule(&EnvInfo {
|
||||||
number: 10000000,
|
number: 10000000,
|
||||||
author: x!(0),
|
author: 0.into(),
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
difficulty: x!(0),
|
difficulty: 0.into(),
|
||||||
last_hashes: vec![],
|
last_hashes: vec![],
|
||||||
gas_used: x!(0),
|
gas_used: 0.into(),
|
||||||
gas_limit: x!(0)
|
gas_limit: 0.into()
|
||||||
});
|
});
|
||||||
|
|
||||||
assert!(schedule.stack_limit > 0);
|
assert!(schedule.stack_limit > 0);
|
||||||
|
|
||||||
let schedule = engine.schedule(&EnvInfo {
|
let schedule = engine.schedule(&EnvInfo {
|
||||||
number: 100,
|
number: 100,
|
||||||
author: x!(0),
|
author: 0.into(),
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
difficulty: x!(0),
|
difficulty: 0.into(),
|
||||||
last_hashes: vec![],
|
last_hashes: vec![],
|
||||||
gas_used: x!(0),
|
gas_used: 0.into(),
|
||||||
gas_limit: x!(0)
|
gas_limit: 0.into()
|
||||||
});
|
});
|
||||||
|
|
||||||
assert!(!schedule.have_delegate_call);
|
assert!(!schedule.have_delegate_call);
|
||||||
|
@ -361,7 +361,7 @@ impl<'a> Executive<'a> {
|
|||||||
let refunds_bound = sstore_refunds + suicide_refunds;
|
let refunds_bound = sstore_refunds + suicide_refunds;
|
||||||
|
|
||||||
// real ammount to refund
|
// real ammount to refund
|
||||||
let gas_left_prerefund = match result { Ok(x) => x, _ => x!(0) };
|
let gas_left_prerefund = match result { Ok(x) => x, _ => 0.into() };
|
||||||
let refunded = cmp::min(refunds_bound, (t.gas - gas_left_prerefund) / U256::from(2));
|
let refunded = cmp::min(refunds_bound, (t.gas - gas_left_prerefund) / U256::from(2));
|
||||||
let gas_left = gas_left_prerefund + refunded;
|
let gas_left = gas_left_prerefund + refunded;
|
||||||
|
|
||||||
@ -588,10 +588,10 @@ mod tests {
|
|||||||
let expected_trace = vec![ Trace {
|
let expected_trace = vec![ Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("cd1722f3947def4cf144679da39c4c32bdc35681"),
|
from: "cd1722f3947def4cf144679da39c4c32bdc35681".into(),
|
||||||
to: x!("b010143a42d5980c7e5ef0e4a4416dc098a4fed3"),
|
to: "b010143a42d5980c7e5ef0e4a4416dc098a4fed3".into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(100000),
|
gas: 100000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -601,9 +601,9 @@ mod tests {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Create(trace::Create {
|
action: trace::Action::Create(trace::Create {
|
||||||
from: x!("b010143a42d5980c7e5ef0e4a4416dc098a4fed3"),
|
from: "b010143a42d5980c7e5ef0e4a4416dc098a4fed3".into(),
|
||||||
value: x!(23),
|
value: 23.into(),
|
||||||
gas: x!(67979),
|
gas: 67979.into(),
|
||||||
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85]
|
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85]
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Create(trace::CreateResult {
|
result: trace::Res::Create(trace::CreateResult {
|
||||||
@ -642,7 +642,7 @@ mod tests {
|
|||||||
params.origin = sender.clone();
|
params.origin = sender.clone();
|
||||||
params.gas = U256::from(100_000);
|
params.gas = U256::from(100_000);
|
||||||
params.code = Some(code.clone());
|
params.code = Some(code.clone());
|
||||||
params.value = ActionValue::Transfer(x!(100));
|
params.value = ActionValue::Transfer(100.into());
|
||||||
let mut state_result = get_temp_state();
|
let mut state_result = get_temp_state();
|
||||||
let mut state = state_result.reference_mut();
|
let mut state = state_result.reference_mut();
|
||||||
state.add_balance(&sender, &U256::from(100));
|
state.add_balance(&sender, &U256::from(100));
|
||||||
@ -660,7 +660,7 @@ mod tests {
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Create(trace::Create {
|
action: trace::Action::Create(trace::Create {
|
||||||
from: params.sender,
|
from: params.sender,
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: params.gas,
|
gas: params.gas,
|
||||||
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
|
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
|
||||||
}),
|
}),
|
||||||
|
@ -311,12 +311,12 @@ mod tests {
|
|||||||
fn get_test_env_info() -> EnvInfo {
|
fn get_test_env_info() -> EnvInfo {
|
||||||
EnvInfo {
|
EnvInfo {
|
||||||
number: 100,
|
number: 100,
|
||||||
author: x!(0),
|
author: 0.into(),
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
difficulty: x!(0),
|
difficulty: 0.into(),
|
||||||
last_hashes: vec![],
|
last_hashes: vec![],
|
||||||
gas_used: x!(0),
|
gas_used: 0.into(),
|
||||||
gas_limit: x!(0)
|
gas_limit: 0.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +114,11 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn existence() {
|
fn existence() {
|
||||||
let a = PodAccount{balance: x!(69), nonce: x!(0), code: vec![], storage: map![]};
|
let a = PodAccount{balance: 69.into(), nonce: 0.into(), code: vec![], storage: map![]};
|
||||||
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&a)), None);
|
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&a)), None);
|
||||||
assert_eq!(AccountDiff::diff_pod(None, Some(&a)), Some(AccountDiff{
|
assert_eq!(AccountDiff::diff_pod(None, Some(&a)), Some(AccountDiff{
|
||||||
balance: Diff::Born(x!(69)),
|
balance: Diff::Born(69.into()),
|
||||||
nonce: Diff::Born(x!(0)),
|
nonce: Diff::Born(0.into()),
|
||||||
code: Diff::Born(vec![]),
|
code: Diff::Born(vec![]),
|
||||||
storage: map![],
|
storage: map![],
|
||||||
}));
|
}));
|
||||||
@ -126,11 +126,11 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic() {
|
fn basic() {
|
||||||
let a = PodAccount{balance: x!(69), nonce: x!(0), code: vec![], storage: map![]};
|
let a = PodAccount{balance: 69.into(), nonce: 0.into(), code: vec![], storage: map![]};
|
||||||
let b = PodAccount{balance: x!(42), nonce: x!(1), code: vec![], storage: map![]};
|
let b = PodAccount{balance: 42.into(), nonce: 1.into(), code: vec![], storage: map![]};
|
||||||
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
||||||
balance: Diff::Changed(x!(69), x!(42)),
|
balance: Diff::Changed(69.into(), 42.into()),
|
||||||
nonce: Diff::Changed(x!(0), x!(1)),
|
nonce: Diff::Changed(0.into(), 1.into()),
|
||||||
code: Diff::Same,
|
code: Diff::Same,
|
||||||
storage: map![],
|
storage: map![],
|
||||||
}));
|
}));
|
||||||
@ -138,11 +138,11 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn code() {
|
fn code() {
|
||||||
let a = PodAccount{balance: x!(0), nonce: x!(0), code: vec![], storage: map![]};
|
let a = PodAccount{balance: 0.into(), nonce: 0.into(), code: vec![], storage: map![]};
|
||||||
let b = PodAccount{balance: x!(0), nonce: x!(1), code: vec![0], storage: map![]};
|
let b = PodAccount{balance: 0.into(), nonce: 1.into(), code: vec![0], storage: map![]};
|
||||||
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
assert_eq!(AccountDiff::diff_pod(Some(&a), Some(&b)), Some(AccountDiff {
|
||||||
balance: Diff::Same,
|
balance: Diff::Same,
|
||||||
nonce: Diff::Changed(x!(0), x!(1)),
|
nonce: Diff::Changed(0.into(), 1.into()),
|
||||||
code: Diff::Changed(vec![], vec![0]),
|
code: Diff::Changed(vec![], vec![0]),
|
||||||
storage: map![],
|
storage: map![],
|
||||||
}));
|
}));
|
||||||
@ -151,14 +151,14 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn storage() {
|
fn storage() {
|
||||||
let a = PodAccount {
|
let a = PodAccount {
|
||||||
balance: x!(0),
|
balance: 0.into(),
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
code: vec![],
|
code: vec![],
|
||||||
storage: mapx![1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 0, 6 => 0, 7 => 0]
|
storage: mapx![1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 0, 6 => 0, 7 => 0]
|
||||||
};
|
};
|
||||||
let b = PodAccount {
|
let b = PodAccount {
|
||||||
balance: x!(0),
|
balance: 0.into(),
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
code: vec![],
|
code: vec![],
|
||||||
storage: mapx![1 => 1, 2 => 3, 3 => 0, 5 => 0, 7 => 7, 8 => 0, 9 => 9]
|
storage: mapx![1 => 1, 2 => 3, 3 => 0, 5 => 0, 7 => 7, 8 => 0, 9 => 9]
|
||||||
};
|
};
|
||||||
@ -167,11 +167,11 @@ mod test {
|
|||||||
nonce: Diff::Same,
|
nonce: Diff::Same,
|
||||||
code: Diff::Same,
|
code: Diff::Same,
|
||||||
storage: map![
|
storage: map![
|
||||||
x!(2) => Diff::new(x!(2), x!(3)),
|
2.into() => Diff::new(2.into(), 3.into()),
|
||||||
x!(3) => Diff::new(x!(3), x!(0)),
|
3.into() => Diff::new(3.into(), 0.into()),
|
||||||
x!(4) => Diff::new(x!(4), x!(0)),
|
4.into() => Diff::new(4.into(), 0.into()),
|
||||||
x!(7) => Diff::new(x!(0), x!(7)),
|
7.into() => Diff::new(0.into(), 7.into()),
|
||||||
x!(9) => Diff::new(x!(0), x!(9))
|
9.into() => Diff::new(0.into(), 9.into()),
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ impl State {
|
|||||||
/// Initialise the code of account `a` so that it is `value` for `key`.
|
/// Initialise the code of account `a` so that it is `value` for `key`.
|
||||||
/// NOTE: Account should have been created with `new_contract`.
|
/// NOTE: Account should have been created with `new_contract`.
|
||||||
pub fn init_code(&mut self, a: &Address, code: Bytes) {
|
pub fn init_code(&mut self, a: &Address, code: Bytes) {
|
||||||
self.require_or_from(a, true, || Account::new_contract(x!(0), self.account_start_nonce), |_|{}).init_code(code);
|
self.require_or_from(a, true, || Account::new_contract(0.into(), self.account_start_nonce), |_|{}).init_code(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute a given transaction.
|
/// Execute a given transaction.
|
||||||
@ -377,27 +377,27 @@ fn should_apply_create_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Create,
|
action: Action::Create,
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: FromHex::from_hex("601080600c6000396000f3006000355415600957005b60203560003555").unwrap(),
|
data: FromHex::from_hex("601080600c6000396000f3006000355415600957005b60203560003555").unwrap(),
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Create(trace::Create {
|
action: trace::Action::Create(trace::Create {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(77412),
|
gas: 77412.into(),
|
||||||
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
|
init: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Create(trace::CreateResult {
|
result: trace::Res::Create(trace::CreateResult {
|
||||||
@ -438,27 +438,27 @@ fn should_trace_failed_create_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Create,
|
action: Action::Create,
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: FromHex::from_hex("5b600056").unwrap(),
|
data: FromHex::from_hex("5b600056").unwrap(),
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Create(trace::Create {
|
action: trace::Action::Create(trace::Create {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(78792),
|
gas: 78792.into(),
|
||||||
init: vec![91, 96, 0, 86],
|
init: vec![91, 96, 0, 86],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::FailedCreate,
|
result: trace::Res::FailedCreate,
|
||||||
@ -476,29 +476,29 @@ fn should_trace_call_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("6000").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -519,28 +519,28 @@ fn should_trace_basic_call_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -561,15 +561,15 @@ fn should_trace_call_transaction_to_builtin() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = Spec::new_test().engine;
|
let engine = Spec::new_test().engine;
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0x1)),
|
action: Action::Call(0x1.into()),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
@ -579,10 +579,10 @@ fn should_trace_call_transaction_to_builtin() {
|
|||||||
assert_eq!(result.trace, Some(Trace {
|
assert_eq!(result.trace, Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!("0000000000000000000000000000000000000001"),
|
to: "0000000000000000000000000000000000000001".into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(79_000),
|
gas: 79_000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -601,29 +601,29 @@ fn should_not_trace_subcall_transaction_to_builtin() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = Spec::new_test().engine;
|
let engine = Spec::new_test().engine;
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("600060006000600060006001610be0f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("600060006000600060006001610be0f1").unwrap());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
||||||
|
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -643,30 +643,30 @@ fn should_not_trace_callcode() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = Spec::new_test().engine;
|
let engine = Spec::new_test().engine;
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006000600b611000f2").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b611000f2").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("6000").unwrap());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
||||||
|
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -686,33 +686,33 @@ fn should_not_trace_delegatecall() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
info.number = 0x789b0;
|
info.number = 0x789b0;
|
||||||
let engine = Spec::new_test().engine;
|
let engine = Spec::new_test().engine;
|
||||||
|
|
||||||
println!("schedule.have_delegate_call: {:?}", engine.schedule(&info).have_delegate_call);
|
println!("schedule.have_delegate_call: {:?}", engine.schedule(&info).have_delegate_call);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("6000600060006000600b618000f4").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("6000600060006000600b618000f4").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("6000").unwrap());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, engine.deref(), &vm_factory, &t, true).unwrap();
|
||||||
|
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -732,29 +732,29 @@ fn should_trace_failed_call_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("5b600056").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("5b600056").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::FailedCall,
|
result: trace::Res::FailedCall,
|
||||||
@ -774,30 +774,30 @@ fn should_trace_call_with_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("6000").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -807,10 +807,10 @@ fn should_trace_call_with_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xa),
|
from: 0xa.into(),
|
||||||
to: x!(0xb),
|
to: 0xb.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78934),
|
gas: 78934.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -832,29 +832,29 @@ fn should_trace_call_with_basic_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006045600b6000f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006045600b6000f1").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -864,10 +864,10 @@ fn should_trace_call_with_basic_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xa),
|
from: 0xa.into(),
|
||||||
to: x!(0xb),
|
to: 0xb.into(),
|
||||||
value: x!(69),
|
value: 69.into(),
|
||||||
gas: x!(2300),
|
gas: 2300.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult::default()),
|
result: trace::Res::Call(trace::CallResult::default()),
|
||||||
@ -886,29 +886,29 @@ fn should_not_trace_call_with_invalid_basic_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("600060006000600060ff600b6000f1").unwrap()); // not enough funds.
|
state.init_code(&0xa.into(), FromHex::from_hex("600060006000600060ff600b6000f1").unwrap()); // not enough funds.
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -929,30 +929,30 @@ fn should_trace_failed_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],//600480600b6000396000f35b600056
|
data: vec![],//600480600b6000396000f35b600056
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("5b600056").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("5b600056").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -962,10 +962,10 @@ fn should_trace_failed_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xa),
|
from: 0xa.into(),
|
||||||
to: x!(0xb),
|
to: 0xb.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78934),
|
gas: 78934.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::FailedCall,
|
result: trace::Res::FailedCall,
|
||||||
@ -984,31 +984,31 @@ fn should_trace_call_with_subcall_with_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],
|
data: vec![],
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("60006000600060006000600c602b5a03f1").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("60006000600060006000600c602b5a03f1").unwrap());
|
||||||
state.init_code(&x!(0xc), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xc.into(), FromHex::from_hex("6000").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -1018,10 +1018,10 @@ fn should_trace_call_with_subcall_with_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xa),
|
from: 0xa.into(),
|
||||||
to: x!(0xb),
|
to: 0xb.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78934),
|
gas: 78934.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -1031,10 +1031,10 @@ fn should_trace_call_with_subcall_with_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 2,
|
depth: 2,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xb),
|
from: 0xb.into(),
|
||||||
to: x!(0xc),
|
to: 0xb.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78868),
|
gas: 78868.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -1057,31 +1057,31 @@ fn should_trace_failed_subcall_with_subcall_transaction() {
|
|||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
|
|
||||||
let mut info = EnvInfo::default();
|
let mut info = EnvInfo::default();
|
||||||
info.gas_limit = x!(1_000_000);
|
info.gas_limit = 1_000_000.into();
|
||||||
let engine = TestEngine::new(5);
|
let engine = TestEngine::new(5);
|
||||||
|
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: x!(0),
|
nonce: 0.into(),
|
||||||
gas_price: x!(0),
|
gas_price: 0.into(),
|
||||||
gas: x!(100_000),
|
gas: 100_000.into(),
|
||||||
action: Action::Call(x!(0xa)),
|
action: Action::Call(0xa.into()),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
data: vec![],//600480600b6000396000f35b600056
|
data: vec![],//600480600b6000396000f35b600056
|
||||||
}.sign(&"".sha3());
|
}.sign(&"".sha3());
|
||||||
|
|
||||||
state.init_code(&x!(0xa), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b602b5a03f1").unwrap());
|
||||||
state.init_code(&x!(0xb), FromHex::from_hex("60006000600060006000600c602b5a03f1505b601256").unwrap());
|
state.init_code(&0xb.into(), FromHex::from_hex("60006000600060006000600c602b5a03f1505b601256").unwrap());
|
||||||
state.init_code(&x!(0xc), FromHex::from_hex("6000").unwrap());
|
state.init_code(&0xc.into(), FromHex::from_hex("6000").unwrap());
|
||||||
state.add_balance(t.sender().as_ref().unwrap(), &x!(100));
|
state.add_balance(t.sender().as_ref().unwrap(), &100.into());
|
||||||
let vm_factory = Default::default();
|
let vm_factory = Default::default();
|
||||||
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
let result = state.apply(&info, &engine, &vm_factory, &t, true).unwrap();
|
||||||
let expected_trace = Some(Trace {
|
let expected_trace = Some(Trace {
|
||||||
depth: 0,
|
depth: 0,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!("9cce34f7ab185c7aba1b7c8140d620b4bda941d6"),
|
from: "9cce34f7ab185c7aba1b7c8140d620b4bda941d6".into(),
|
||||||
to: x!(0xa),
|
to: 0xa.into(),
|
||||||
value: x!(100),
|
value: 100.into(),
|
||||||
gas: x!(79000),
|
gas: 79000.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -1091,20 +1091,20 @@ fn should_trace_failed_subcall_with_subcall_transaction() {
|
|||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 1,
|
depth: 1,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xa),
|
from: 0xa.into(),
|
||||||
to: x!(0xb),
|
to: 0xb.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78934),
|
gas: 78934.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::FailedCall,
|
result: trace::Res::FailedCall,
|
||||||
subs: vec![Trace {
|
subs: vec![Trace {
|
||||||
depth: 2,
|
depth: 2,
|
||||||
action: trace::Action::Call(trace::Call {
|
action: trace::Action::Call(trace::Call {
|
||||||
from: x!(0xb),
|
from: 0xb.into(),
|
||||||
to: x!(0xc),
|
to: 0xc.into(),
|
||||||
value: x!(0),
|
value: 0.into(),
|
||||||
gas: x!(78868),
|
gas: 78868.into(),
|
||||||
input: vec![],
|
input: vec![],
|
||||||
}),
|
}),
|
||||||
result: trace::Res::Call(trace::CallResult {
|
result: trace::Res::Call(trace::CallResult {
|
||||||
@ -1125,7 +1125,7 @@ fn code_from_database() {
|
|||||||
let temp = RandomTempPath::new();
|
let temp = RandomTempPath::new();
|
||||||
let (root, db) = {
|
let (root, db) = {
|
||||||
let mut state = get_temp_state_in(temp.as_path());
|
let mut state = get_temp_state_in(temp.as_path());
|
||||||
state.require_or_from(&a, false, ||Account::new_contract(x!(42), x!(0)), |_|{});
|
state.require_or_from(&a, false, ||Account::new_contract(42.into(), 0.into()), |_|{});
|
||||||
state.init_code(&a, vec![1, 2, 3]);
|
state.init_code(&a, vec![1, 2, 3]);
|
||||||
assert_eq!(state.code(&a), Some([1u8, 2, 3].to_vec()));
|
assert_eq!(state.code(&a), Some([1u8, 2, 3].to_vec()));
|
||||||
state.commit();
|
state.commit();
|
||||||
|
@ -74,7 +74,7 @@ mod tests {
|
|||||||
topics: vec![],
|
topics: vec![],
|
||||||
data: vec![]
|
data: vec![]
|
||||||
});
|
});
|
||||||
sub_state.sstore_clears_count = x!(5);
|
sub_state.sstore_clears_count = 5.into();
|
||||||
sub_state.suicides.insert(address_from_u64(10u64));
|
sub_state.suicides.insert(address_from_u64(10u64));
|
||||||
|
|
||||||
let mut sub_state_2 = Substate::new();
|
let mut sub_state_2 = Substate::new();
|
||||||
@ -84,11 +84,11 @@ mod tests {
|
|||||||
topics: vec![],
|
topics: vec![],
|
||||||
data: vec![]
|
data: vec![]
|
||||||
});
|
});
|
||||||
sub_state_2.sstore_clears_count = x!(7);
|
sub_state_2.sstore_clears_count = 7.into();
|
||||||
|
|
||||||
sub_state.accrue(sub_state_2);
|
sub_state.accrue(sub_state_2);
|
||||||
assert_eq!(sub_state.contracts_created.len(), 2);
|
assert_eq!(sub_state.contracts_created.len(), 2);
|
||||||
assert_eq!(sub_state.sstore_clears_count, x!(12));
|
assert_eq!(sub_state.sstore_clears_count, 12.into());
|
||||||
assert_eq!(sub_state.suicides.len(), 1);
|
assert_eq!(sub_state.suicides.len(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ fn can_mine() {
|
|||||||
let client_result = get_test_client_with_blocks(vec![dummy_blocks[0].clone()]);
|
let client_result = get_test_client_with_blocks(vec![dummy_blocks[0].clone()]);
|
||||||
let client = client_result.reference();
|
let client = client_result.reference();
|
||||||
|
|
||||||
let b = client.prepare_sealing(Address::default(), x!(31415926), vec![], vec![]).0.unwrap();
|
let b = client.prepare_sealing(Address::default(), 31415926.into(), vec![], vec![]).0.unwrap();
|
||||||
|
|
||||||
assert_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
|
assert_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
|
||||||
assert!(client.try_seal(b.lock(), vec![]).is_ok());
|
assert!(client.try_seal(b.lock(), vec![]).is_ok());
|
||||||
|
@ -98,8 +98,8 @@ pub fn create_test_block(header: &Header) -> Bytes {
|
|||||||
|
|
||||||
fn create_unverifiable_block_header(order: u32, parent_hash: H256) -> Header {
|
fn create_unverifiable_block_header(order: u32, parent_hash: H256) -> Header {
|
||||||
let mut header = Header::new();
|
let mut header = Header::new();
|
||||||
header.gas_limit = x!(0);
|
header.gas_limit = 0.into();
|
||||||
header.difficulty = x!(order * 100);
|
header.difficulty = order * 100.into();
|
||||||
header.timestamp = (order * 10) as u64;
|
header.timestamp = (order * 10) as u64;
|
||||||
header.number = order as u64;
|
header.number = order as u64;
|
||||||
header.parent_hash = parent_hash;
|
header.parent_hash = parent_hash;
|
||||||
@ -335,7 +335,7 @@ pub fn get_bad_state_dummy_block() -> Bytes {
|
|||||||
block_header.timestamp = 40;
|
block_header.timestamp = 40;
|
||||||
block_header.number = 1;
|
block_header.number = 1;
|
||||||
block_header.parent_hash = test_spec.genesis_header().hash();
|
block_header.parent_hash = test_spec.genesis_header().hash();
|
||||||
block_header.state_root = x!(0xbad);
|
block_header.state_root = 0xbad.into();
|
||||||
|
|
||||||
create_test_block(&block_header)
|
create_test_block(&block_header)
|
||||||
}
|
}
|
||||||
|
@ -105,10 +105,10 @@ pub struct LocalizedReceipt {
|
|||||||
fn test_basic() {
|
fn test_basic() {
|
||||||
let expected = ::rustc_serialize::hex::FromHex::from_hex("f90162a02f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee83040caeb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000f838f794dcf421d093428b096ca501a7cd1a740855a7976fc0a00000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
let expected = ::rustc_serialize::hex::FromHex::from_hex("f90162a02f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee83040caeb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000f838f794dcf421d093428b096ca501a7cd1a740855a7976fc0a00000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
||||||
let r = Receipt::new(
|
let r = Receipt::new(
|
||||||
x!("2f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee"),
|
"2f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee".into(),
|
||||||
x!(0x40cae),
|
0x40cae.into(),
|
||||||
vec![LogEntry {
|
vec![LogEntry {
|
||||||
address: x!("dcf421d093428b096ca501a7cd1a740855a7976f"),
|
address: "dcf421d093428b096ca501a7cd1a740855a7976f".into(),
|
||||||
topics: vec![],
|
topics: vec![],
|
||||||
data: vec![0u8; 32]
|
data: vec![0u8; 32]
|
||||||
}]
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user