14 additional GeneralStateTests and clean up some empty hex string parsing kludginess

This commit is contained in:
Dustin Brody 2018-09-15 13:39:30 -07:00
parent beb1befc6e
commit fe761cd4ff
2 changed files with 28 additions and 31 deletions

View File

@ -727,15 +727,15 @@ OK: 65/67 Fail: 2/67 Skip: 0/67
+ NonZeroValue_SUICIDE_ToNonNonZeroBalance.json OK
+ NonZeroValue_SUICIDE_ToOneStorageKey.json OK
+ NonZeroValue_TransactionCALL.json OK
- NonZeroValue_TransactionCALL_ToEmpty.json Fail
- NonZeroValue_TransactionCALL_ToNonNonZeroBalance.json Fail
- NonZeroValue_TransactionCALL_ToOneStorageKey.json Fail
+ NonZeroValue_TransactionCALL_ToEmpty.json OK
+ NonZeroValue_TransactionCALL_ToNonNonZeroBalance.json OK
+ NonZeroValue_TransactionCALL_ToOneStorageKey.json OK
+ NonZeroValue_TransactionCALLwithData.json OK
- NonZeroValue_TransactionCALLwithData_ToEmpty.json Fail
- NonZeroValue_TransactionCALLwithData_ToNonNonZeroBalance.json Fail
- NonZeroValue_TransactionCALLwithData_ToOneStorageKey.json Fail
+ NonZeroValue_TransactionCALLwithData_ToEmpty.json OK
+ NonZeroValue_TransactionCALLwithData_ToNonNonZeroBalance.json OK
+ NonZeroValue_TransactionCALLwithData_ToOneStorageKey.json OK
```
OK: 6/24 Fail: 18/24 Skip: 0/24
OK: 12/24 Fail: 12/24 Skip: 0/24
## stPreCompiledContracts
```diff
identity_to_bigger.json Skip
@ -1556,7 +1556,7 @@ OK: 11/19 Fail: 8/19 Skip: 0/19
- returndatacopy_0_0_following_successful_create.json Fail
returndatacopy_afterFailing_create.json Skip
+ returndatacopy_after_failing_callcode.json OK
- returndatacopy_after_failing_delegatecall.json Fail
+ returndatacopy_after_failing_delegatecall.json OK
+ returndatacopy_after_failing_staticcall.json OK
+ returndatacopy_after_revert_in_staticcall.json OK
+ returndatacopy_after_successful_callcode.json OK
@ -1585,7 +1585,7 @@ OK: 11/19 Fail: 8/19 Skip: 0/19
+ returndatasize_initial.json OK
+ returndatasize_initial_zero_read.json OK
```
OK: 25/37 Fail: 9/37 Skip: 3/37
OK: 26/37 Fail: 8/37 Skip: 3/37
## stRevertTest
```diff
- LoopCallsDepthThenRevert.json Fail
@ -2125,13 +2125,13 @@ OK: 23/67 Fail: 42/67 Skip: 2/67
- TransactionSendingToEmpty.json Fail
+ TransactionSendingToZero.json OK
+ TransactionToAddressh160minusOne.json OK
- TransactionToItself.json Fail
+ TransactionToItself.json OK
- TransactionToItselfNotEnoughFounds.json Fail
+ UserTransactionGasLimitIsTooLowWhenZeroCost.json OK
+ UserTransactionZeroCost.json OK
+ UserTransactionZeroCostWithData.json OK
```
OK: 19/44 Fail: 25/44 Skip: 0/44
OK: 20/44 Fail: 24/44 Skip: 0/44
## stTransitionTest
```diff
- createNameRegistratorPerTxsAfter.json Fail
@ -2238,15 +2238,15 @@ OK: 0/24 Fail: 0/24 Skip: 24/24
+ ZeroValue_SUICIDE_ToNonZeroBalance.json OK
+ ZeroValue_SUICIDE_ToOneStorageKey.json OK
+ ZeroValue_TransactionCALL.json OK
- ZeroValue_TransactionCALL_ToEmpty.json Fail
- ZeroValue_TransactionCALL_ToNonZeroBalance.json Fail
- ZeroValue_TransactionCALL_ToOneStorageKey.json Fail
+ ZeroValue_TransactionCALL_ToEmpty.json OK
+ ZeroValue_TransactionCALL_ToNonZeroBalance.json OK
+ ZeroValue_TransactionCALL_ToOneStorageKey.json OK
+ ZeroValue_TransactionCALLwithData.json OK
- ZeroValue_TransactionCALLwithData_ToEmpty.json Fail
- ZeroValue_TransactionCALLwithData_ToNonZeroBalance.json Fail
- ZeroValue_TransactionCALLwithData_ToOneStorageKey.json Fail
+ ZeroValue_TransactionCALLwithData_ToEmpty.json OK
+ ZeroValue_TransactionCALLwithData_ToNonZeroBalance.json OK
+ ZeroValue_TransactionCALLwithData_ToOneStorageKey.json OK
```
OK: 6/24 Fail: 18/24 Skip: 0/24
OK: 12/24 Fail: 12/24 Skip: 0/24
## stZeroKnowledge
```diff
ecmul_1-2_2_28000_128.json Skip

View File

@ -113,6 +113,13 @@ macro jsonTest*(s: static[string], handler: untyped): untyped =
func ethAddressFromHex*(s: string): EthAddress = hexToByteArray(s, result)
# XXX should probably be part of hexToSeqByte
func safeHexToSeqByte*(hexStr: string): seq[byte] =
if hexStr == "":
@[]
else:
hexStr.hexToSeqByte
proc setupStateDB*(wantedState: JsonNode, stateDB: var AccountStateDB) =
for ac, accountData in wantedState:
let account = ethAddressFromHex(ac)
@ -120,12 +127,7 @@ proc setupStateDB*(wantedState: JsonNode, stateDB: var AccountStateDB) =
stateDB.setStorage(account, fromHex(UInt256, slot), fromHex(UInt256, value.getStr))
let nonce = accountData{"nonce"}.getStr.parseHexInt.AccountNonce
# Keep workaround local until another case needing it is found,
# to ensure failure modes obvious.
let rawCode = accountData{"code"}.getStr
let code = hexToSeqByte(if rawCode == "": "0x" else: rawCode).toRange
let code = accountData{"code"}.getStr.safeHexToSeqByte.toRange
let balance = UInt256.fromHex accountData{"balance"}.getStr
stateDB.setNonce(account, nonce)
@ -179,12 +181,7 @@ proc getFixtureTransaction*(j: JsonNode): Transaction =
let rawTo = j["to"].getStr
transaction.to = (if rawTo == "": "0x" else: rawTo).parseAddress
transaction.value = j["value"][0].getStr.parseHexInt.u256
# Another, slightly distinct, case of this "" as special-cased hex string
# One possibility's a string prefix func which adds only if 0x is missing
# which can be used across the various hex-string-parsing utility funcs.
let rawData = j["data"][0].getStr
transaction.payload = (if rawData == "": "0x" else: rawData).hexToSeqByte
transaction.payload = j["data"][0].getStr.safeHexToSeqByte
return transaction
@ -207,7 +204,7 @@ func getFixtureCode*(pre: JsonNode, targetAccount: EthAddress) : seq[byte] =
# XXX: Workaround for broken setCode/getCode. Remove when feasible.
for ac, preState in pre:
if ethAddressFromHex(ac) == targetAccount:
return preState["code"].getStr.hexToSeqByte
return preState["code"].getStr.safeHexToSeqByte
# Fail loudly if it falls off the end (by default)