Reactivate the precompiles test + consume gas

This commit is contained in:
mratsim 2018-12-04 15:52:59 +01:00
parent 29f8a8a066
commit f50bb57eb6
2 changed files with 12 additions and 11 deletions

View File

@ -138,10 +138,12 @@ proc modExpInternal(computation: var BaseComputation, base_len, exp_len, mod_len
max(adj_exp_len, 1)
) div GasQuadDivisor
computation.gasMeter.consumeGas(gasFee, reason="ModExp Precompile")
block: # Processing
# TODO: specs mentions that we should return in "M" format
# i.e. if Base and exp are uint512 and Modulo an uint256
# we should return a 256-bit big-endian byte array
# i.e. if Base and exp are uint512 and Modulo an uint256
# we should return a 256-bit big-endian byte array
# Force static evaluation
func zero(): static array[T.bits div 8, byte] = discard

View File

@ -39,18 +39,17 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped =
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
for label, child in fixtures:
case toLowerAscii(label)
# of "ecrecover": child.doTest(paEcRecover.ord, ecRecover)
# of "sha256": child.doTest(paSha256.ord, sha256)
# of "ripemd": child.doTest(paRipeMd160.ord, ripemd160)
# of "identity": child.doTest(paIdentity.ord, identity)
of "ecrecover": child.doTest(paEcRecover.ord, ecRecover)
of "sha256": child.doTest(paSha256.ord, sha256)
of "ripemd": child.doTest(paRipeMd160.ord, ripemd160)
of "identity": child.doTest(paIdentity.ord, identity)
of "modexp": child.doTest(paModExp.ord, modexp)
# of "bn256add": child.doTest(paEcAdd.ord, bn256ECAdd)
# of "bn256mul": child.doTest(paEcMul.ord, bn256ECMul)
# of "ecpairing": child.doTest(paPairing.ord, bn256ecPairing)
of "bn256add": child.doTest(paEcAdd.ord, bn256ECAdd)
of "bn256mul": child.doTest(paEcMul.ord, bn256ECMul)
of "ecpairing": child.doTest(paPairing.ord, bn256ecPairing)
else:
#raise newException(ValueError, "Unknown test vector '" & $label & "'")
# echo "Unknown test vector '" & $label & "'"
discard
echo "Unknown test vector '" & $label & "'"
suite "Precompiles":
jsonTest("PrecompileTests", testFixture)