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

Commit 1d67f9e

Browse files
committed
Reverted False to TransactionFailed in tester
1 parent e921e68 commit 1d67f9e

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

ethereum/tools/tester2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
except ImportError:
5151
pass
5252

53+
class TransactionFailed(Exception):
54+
pass
55+
5356
from ethereum.abi import ContractTranslator
5457
import types
5558

@@ -134,7 +137,7 @@ def tx(self, sender=k0, to=b'\x00' * 20, value=0, data=b'', startgas=STARTGAS, g
134137
success, output = apply_transaction(self.head_state, transaction)
135138
self.block.transactions.append(transaction)
136139
if not success:
137-
return False
140+
raise TransactionFailed()
138141
return output
139142

140143
def contract(self, sourcecode, args=[], sender=k0, value=0, language='evm', startgas=STARTGAS, gasprice=GASPRICE):

tools/mk_ecadd_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def intrinsic_gas_of_data(d):
3434
def mk_test(p1, p2, execgas, datarestrict=128):
3535
encoded = mk_ecadd_data(p1, p2)[:datarestrict] + b'\x00' * max(datarestrict - 128, 0)
3636
pre = tester2.mk_state_test_prefill(c)
37-
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
38-
if o is False:
39-
print('OOG %r %r %d %d' % (p1, p2, datarestrict, execgas))
40-
else:
37+
try:
38+
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
4139
x, y = big_endian_to_int(o[:32]), big_endian_to_int(o[32:])
4240
if py_pairing.normalize(py_pairing.add(p1, p2)) != (py_pairing.FQ(x), py_pairing.FQ(y)):
4341
raise Exception("Mismatch! %r %r %d, expected %r computed %r" %
4442
(p1, p2, datarestrict, py_pairing.normalize(py_pairing.add(p1, p2)), (x, y)))
4543
print('Succeeded! %r %r %d %r' % (p1, p2, datarestrict, (x, y)))
44+
except tester2.TransactionFailed:
45+
print('OOG %r %r %d %d' % (p1, p2, datarestrict, execgas))
4646
o = tester2.mk_state_test_postfill(c, pre)
4747
o2 = tester2.mk_state_test_postfill(c, pre, filler_mode=True)
4848
assert new_statetest_utils.verify_state_test(o)

tools/mk_ecmul_tests.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ def intrinsic_gas_of_data(d):
3131
def mk_test(p1, m, execgas, datarestrict=96):
3232
encoded = mk_ecmul_data(p1, m)[:datarestrict] + b'\x00' * max(datarestrict - 96, 0)
3333
pre = tester2.mk_state_test_prefill(c)
34-
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
35-
if o is False:
36-
print('OOG %r %d %d %d' % (p1, m, datarestrict, execgas))
37-
else:
34+
try:
35+
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
3836
x, y = big_endian_to_int(o[:32]), big_endian_to_int(o[32:])
39-
print('m', p1, m, py_pairing.multiply(p1, m))
4037
if py_pairing.normalize(py_pairing.multiply(p1, m)) != (py_pairing.FQ(x), py_pairing.FQ(y)):
4138
raise Exception("Mismatch! %r %r %d, expected %r computed %r" %
4239
(p1, m, datarestrict, py_pairing.normalize(py_pairing.multiply(p1, m)), (x, y)))
4340
print('Succeeded! %r %d %d %r' % (p1, m, datarestrict, (x, y)))
41+
except tester2.TransactionFailed:
42+
print('OOG %r %d %d %d' % (p1, m, datarestrict, execgas))
4443
o = tester2.mk_state_test_postfill(c, pre)
4544
o2 = tester2.mk_state_test_postfill(c, pre, filler_mode=True)
4645
assert new_statetest_utils.verify_state_test(o)

tools/mk_ecpairing_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def intrinsic_gas_of_data(d):
5454

5555
def mk_test(encoded, execgas, expect):
5656
pre = tester2.mk_state_test_prefill(c)
57-
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
57+
try:
58+
o = x1.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x1.translator.encode('foo', [encoded])) + execgas)
59+
except tester2.TransactionFailed:
60+
o = False
5861
if o is False:
5962
if expect != 'error':
6063
raise Exception('OOG')

tools/mk_modexp_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ def mk_test(b, e, m, execgas):
3333
s = c.snapshot()
3434
x = c.contract(kode % (len(encoded) + 36, max(intlen(m), 1), max(intlen(m), 1)), language='viper')
3535
pre = tester2.mk_state_test_prefill(c)
36-
o = x.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x.translator.encode('foo', [encoded])) + execgas)
37-
if o is False:
38-
print('OOG %d %d %d sg %d' % (b, e, m, execgas))
39-
else:
36+
try:
37+
o = x.foo(encoded, startgas=21000 + intrinsic_gas_of_data(x.translator.encode('foo', [encoded])) + execgas)
4038
if big_endian_to_int(o[:intlen(m)]) != (pow(b, e, m) if m else 0):
4139
raise Exception("Mismatch! %d %d %d expected %d computed %d" % (b, e, m, pow(b, e, m), big_endian_to_int(o[:intlen(m)])))
4240
print("Succeeded %d %d %d sg %d" % (b, e, m, execgas))
41+
except tester2.TransactionFailed:
42+
print('OOG %d %d %d sg %d' % (b, e, m, execgas))
4343
o = tester2.mk_state_test_postfill(c, pre)
4444
o2 = tester2.mk_state_test_postfill(c, pre, filler_mode=True)
4545
assert new_statetest_utils.verify_state_test(o)

0 commit comments

Comments
 (0)