|
1 |
| -from ethereum.utils import sha3, privtoaddr, int_to_addr, to_string |
| 1 | +from ethereum.utils import sha3, privtoaddr, int_to_addr, to_string, big_endian_to_int |
2 | 2 | from ethereum.parse_genesis_declaration import mk_basic_state
|
3 | 3 | from ethereum import chain
|
4 | 4 | from ethereum.transactions import Transaction
|
@@ -90,6 +90,10 @@ def kall(self, *args, **kwargs):
|
90 | 90 | startgas=kwargs.get('startgas', STARTGAS)
|
91 | 91 | )
|
92 | 92 |
|
| 93 | + if result is False: |
| 94 | + return result |
| 95 | + if result == b'': |
| 96 | + return None |
93 | 97 | o = self.translator.decode(function_name, result)
|
94 | 98 | return o[0] if len(o) == 1 else o
|
95 | 99 | return kall
|
@@ -136,9 +140,18 @@ def mine(self, number_of_blocks=1, coinbase=a0):
|
136 | 140 | assert self.chain.add_block(self.block)
|
137 | 141 | assert self.head_state.trie.root_hash == self.chain.state.trie.root_hash
|
138 | 142 | for i in range(1, number_of_blocks):
|
139 |
| - b = self.cs.block_setup(self.chain, timestamp=self.chain.state.timestamp + 1) |
| 143 | + b = self.cs.block_setup(self.chain, timestamp=self.chain.state.timestamp + 14) |
140 | 144 | pre_seal(self.chain.state.ephemeral_clone(), b)
|
141 | 145 | b = Miner(b).mine(rounds=100, start_nonce=0)
|
142 | 146 | assert self.chain.add_block(b)
|
143 |
| - self.block = self.cs.block_setup(self.chain, timestamp=self.chain.state.timestamp + 1) |
| 147 | + self.block = self.cs.block_setup(self.chain, timestamp=self.chain.state.timestamp + 14) |
144 | 148 | self.head_state = self.chain.state.ephemeral_clone()
|
| 149 | + |
| 150 | + def snapshot(self): |
| 151 | + return self.head_state.snapshot(), len(self.block.transactions), self.block.number |
| 152 | + |
| 153 | + def revert(self, snapshot): |
| 154 | + state_snapshot, txcount, blknum = snapshot |
| 155 | + assert blknum == self.block.number |
| 156 | + self.block.transactions = self.block.transactions[:txcount] |
| 157 | + self.head_state.revert(state_snapshot) |
0 commit comments