mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 05:44:40 +00:00
14 additional GeneralStateTests and clean up some empty hex string parsing kludginess
This commit is contained in:
parent
beb1befc6e
commit
fe761cd4ff
@ -727,15 +727,15 @@ OK: 65/67 Fail: 2/67 Skip: 0/67
|
|||||||
+ NonZeroValue_SUICIDE_ToNonNonZeroBalance.json OK
|
+ NonZeroValue_SUICIDE_ToNonNonZeroBalance.json OK
|
||||||
+ NonZeroValue_SUICIDE_ToOneStorageKey.json OK
|
+ NonZeroValue_SUICIDE_ToOneStorageKey.json OK
|
||||||
+ NonZeroValue_TransactionCALL.json OK
|
+ NonZeroValue_TransactionCALL.json OK
|
||||||
- NonZeroValue_TransactionCALL_ToEmpty.json Fail
|
+ NonZeroValue_TransactionCALL_ToEmpty.json OK
|
||||||
- NonZeroValue_TransactionCALL_ToNonNonZeroBalance.json Fail
|
+ NonZeroValue_TransactionCALL_ToNonNonZeroBalance.json OK
|
||||||
- NonZeroValue_TransactionCALL_ToOneStorageKey.json Fail
|
+ NonZeroValue_TransactionCALL_ToOneStorageKey.json OK
|
||||||
+ NonZeroValue_TransactionCALLwithData.json OK
|
+ NonZeroValue_TransactionCALLwithData.json OK
|
||||||
- NonZeroValue_TransactionCALLwithData_ToEmpty.json Fail
|
+ NonZeroValue_TransactionCALLwithData_ToEmpty.json OK
|
||||||
- NonZeroValue_TransactionCALLwithData_ToNonNonZeroBalance.json Fail
|
+ NonZeroValue_TransactionCALLwithData_ToNonNonZeroBalance.json OK
|
||||||
- NonZeroValue_TransactionCALLwithData_ToOneStorageKey.json Fail
|
+ NonZeroValue_TransactionCALLwithData_ToOneStorageKey.json OK
|
||||||
```
|
```
|
||||||
OK: 6/24 Fail: 18/24 Skip: 0/24
|
OK: 12/24 Fail: 12/24 Skip: 0/24
|
||||||
## stPreCompiledContracts
|
## stPreCompiledContracts
|
||||||
```diff
|
```diff
|
||||||
identity_to_bigger.json Skip
|
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_0_0_following_successful_create.json Fail
|
||||||
returndatacopy_afterFailing_create.json Skip
|
returndatacopy_afterFailing_create.json Skip
|
||||||
+ returndatacopy_after_failing_callcode.json OK
|
+ 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_failing_staticcall.json OK
|
||||||
+ returndatacopy_after_revert_in_staticcall.json OK
|
+ returndatacopy_after_revert_in_staticcall.json OK
|
||||||
+ returndatacopy_after_successful_callcode.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.json OK
|
||||||
+ returndatasize_initial_zero_read.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
|
## stRevertTest
|
||||||
```diff
|
```diff
|
||||||
- LoopCallsDepthThenRevert.json Fail
|
- LoopCallsDepthThenRevert.json Fail
|
||||||
@ -2125,13 +2125,13 @@ OK: 23/67 Fail: 42/67 Skip: 2/67
|
|||||||
- TransactionSendingToEmpty.json Fail
|
- TransactionSendingToEmpty.json Fail
|
||||||
+ TransactionSendingToZero.json OK
|
+ TransactionSendingToZero.json OK
|
||||||
+ TransactionToAddressh160minusOne.json OK
|
+ TransactionToAddressh160minusOne.json OK
|
||||||
- TransactionToItself.json Fail
|
+ TransactionToItself.json OK
|
||||||
- TransactionToItselfNotEnoughFounds.json Fail
|
- TransactionToItselfNotEnoughFounds.json Fail
|
||||||
+ UserTransactionGasLimitIsTooLowWhenZeroCost.json OK
|
+ UserTransactionGasLimitIsTooLowWhenZeroCost.json OK
|
||||||
+ UserTransactionZeroCost.json OK
|
+ UserTransactionZeroCost.json OK
|
||||||
+ UserTransactionZeroCostWithData.json OK
|
+ UserTransactionZeroCostWithData.json OK
|
||||||
```
|
```
|
||||||
OK: 19/44 Fail: 25/44 Skip: 0/44
|
OK: 20/44 Fail: 24/44 Skip: 0/44
|
||||||
## stTransitionTest
|
## stTransitionTest
|
||||||
```diff
|
```diff
|
||||||
- createNameRegistratorPerTxsAfter.json Fail
|
- createNameRegistratorPerTxsAfter.json Fail
|
||||||
@ -2238,15 +2238,15 @@ OK: 0/24 Fail: 0/24 Skip: 24/24
|
|||||||
+ ZeroValue_SUICIDE_ToNonZeroBalance.json OK
|
+ ZeroValue_SUICIDE_ToNonZeroBalance.json OK
|
||||||
+ ZeroValue_SUICIDE_ToOneStorageKey.json OK
|
+ ZeroValue_SUICIDE_ToOneStorageKey.json OK
|
||||||
+ ZeroValue_TransactionCALL.json OK
|
+ ZeroValue_TransactionCALL.json OK
|
||||||
- ZeroValue_TransactionCALL_ToEmpty.json Fail
|
+ ZeroValue_TransactionCALL_ToEmpty.json OK
|
||||||
- ZeroValue_TransactionCALL_ToNonZeroBalance.json Fail
|
+ ZeroValue_TransactionCALL_ToNonZeroBalance.json OK
|
||||||
- ZeroValue_TransactionCALL_ToOneStorageKey.json Fail
|
+ ZeroValue_TransactionCALL_ToOneStorageKey.json OK
|
||||||
+ ZeroValue_TransactionCALLwithData.json OK
|
+ ZeroValue_TransactionCALLwithData.json OK
|
||||||
- ZeroValue_TransactionCALLwithData_ToEmpty.json Fail
|
+ ZeroValue_TransactionCALLwithData_ToEmpty.json OK
|
||||||
- ZeroValue_TransactionCALLwithData_ToNonZeroBalance.json Fail
|
+ ZeroValue_TransactionCALLwithData_ToNonZeroBalance.json OK
|
||||||
- ZeroValue_TransactionCALLwithData_ToOneStorageKey.json Fail
|
+ ZeroValue_TransactionCALLwithData_ToOneStorageKey.json OK
|
||||||
```
|
```
|
||||||
OK: 6/24 Fail: 18/24 Skip: 0/24
|
OK: 12/24 Fail: 12/24 Skip: 0/24
|
||||||
## stZeroKnowledge
|
## stZeroKnowledge
|
||||||
```diff
|
```diff
|
||||||
ecmul_1-2_2_28000_128.json Skip
|
ecmul_1-2_2_28000_128.json Skip
|
||||||
|
@ -113,6 +113,13 @@ macro jsonTest*(s: static[string], handler: untyped): untyped =
|
|||||||
|
|
||||||
func ethAddressFromHex*(s: string): EthAddress = hexToByteArray(s, result)
|
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) =
|
proc setupStateDB*(wantedState: JsonNode, stateDB: var AccountStateDB) =
|
||||||
for ac, accountData in wantedState:
|
for ac, accountData in wantedState:
|
||||||
let account = ethAddressFromHex(ac)
|
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))
|
stateDB.setStorage(account, fromHex(UInt256, slot), fromHex(UInt256, value.getStr))
|
||||||
|
|
||||||
let nonce = accountData{"nonce"}.getStr.parseHexInt.AccountNonce
|
let nonce = accountData{"nonce"}.getStr.parseHexInt.AccountNonce
|
||||||
|
let code = accountData{"code"}.getStr.safeHexToSeqByte.toRange
|
||||||
# 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 balance = UInt256.fromHex accountData{"balance"}.getStr
|
let balance = UInt256.fromHex accountData{"balance"}.getStr
|
||||||
|
|
||||||
stateDB.setNonce(account, nonce)
|
stateDB.setNonce(account, nonce)
|
||||||
@ -179,12 +181,7 @@ proc getFixtureTransaction*(j: JsonNode): Transaction =
|
|||||||
let rawTo = j["to"].getStr
|
let rawTo = j["to"].getStr
|
||||||
transaction.to = (if rawTo == "": "0x" else: rawTo).parseAddress
|
transaction.to = (if rawTo == "": "0x" else: rawTo).parseAddress
|
||||||
transaction.value = j["value"][0].getStr.parseHexInt.u256
|
transaction.value = j["value"][0].getStr.parseHexInt.u256
|
||||||
|
transaction.payload = j["data"][0].getStr.safeHexToSeqByte
|
||||||
# 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
|
|
||||||
|
|
||||||
return transaction
|
return transaction
|
||||||
|
|
||||||
@ -207,7 +204,7 @@ func getFixtureCode*(pre: JsonNode, targetAccount: EthAddress) : seq[byte] =
|
|||||||
# XXX: Workaround for broken setCode/getCode. Remove when feasible.
|
# XXX: Workaround for broken setCode/getCode. Remove when feasible.
|
||||||
for ac, preState in pre:
|
for ac, preState in pre:
|
||||||
if ethAddressFromHex(ac) == targetAccount:
|
if ethAddressFromHex(ac) == targetAccount:
|
||||||
return preState["code"].getStr.hexToSeqByte
|
return preState["code"].getStr.safeHexToSeqByte
|
||||||
|
|
||||||
# Fail loudly if it falls off the end (by default)
|
# Fail loudly if it falls off the end (by default)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user