Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #716 from karlfloersch/state_revamp_fix_tester2
Browse files Browse the repository at this point in the history
Fix tester2 broken revert & undefined variable
  • Loading branch information
vbuterin authored May 2, 2017
2 parents 7ae7622 + 93684a6 commit 13743a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ethereum/tester2.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(self, alloc=None, env=None):

@property
def last_tx(self):
return self.txs_this_block[-1] if self.txs_this_block else None
return self.block.transactions[-1] if self.block.transactions else None

def tx(self, sender=k0, to=b'\x00' * 20, value=0, data=b'', startgas=STARTGAS, gasprice=GASPRICE):
sender_addr = privtoaddr(sender)
Expand All @@ -133,7 +133,7 @@ def contract(self, sourcecode, args=[], sender=k0, value=0, language='evm', star
code = compiler.compile(sourcecode) + (ct.encode_constructor_arguments(args) if args else b'')
addr = self.tx(sender=sender, to=b'', value=value, data=code, startgas=startgas, gasprice=gasprice)
return ABIContract(self, ct, addr)

def mine(self, number_of_blocks=1, coinbase=a0):
pre_seal(self.head_state, self.block)
self.block = Miner(self.block).mine(rounds=100, start_nonce=0)
Expand All @@ -148,6 +148,7 @@ def mine(self, number_of_blocks=1, coinbase=a0):
self.head_state = self.chain.state.ephemeral_clone()

def snapshot(self):
self.head_state.commit()
return self.head_state.snapshot(), len(self.block.transactions), self.block.number

def revert(self, snapshot):
Expand Down

0 comments on commit 13743a4

Please sign in to comment.