Fixed a few more tests (#70)

* Fixed getting reading balance from the test fixtures

* Fixed sha3 opcode
This commit is contained in:
Yuriy Glukhov 2018-07-17 10:57:14 +02:00 committed by Mamy Ratsimbazafy
parent c8be4be5f1
commit 601db4d9f3
3 changed files with 29 additions and 25 deletions

View File

@ -287,10 +287,10 @@ OK: 11/12 Fail: 1/12 Skip: 0/12
+ address1.json OK + address1.json OK
+ balance0.json OK + balance0.json OK
- balance01.json Fail - balance01.json Fail
- balance1.json Fail + balance1.json OK
+ balanceAddress2.json OK + balanceAddress2.json OK
+ balanceAddressInputTooBig.json OK + balanceAddressInputTooBig.json OK
- balanceAddressInputTooBigLeftMyAddress.json Fail + balanceAddressInputTooBigLeftMyAddress.json OK
balanceAddressInputTooBigRightMyAddress.json Skip balanceAddressInputTooBigRightMyAddress.json Skip
+ balanceCaller3.json OK + balanceCaller3.json OK
calldatacopy0.json Skip calldatacopy0.json Skip
@ -334,7 +334,7 @@ OK: 11/12 Fail: 1/12 Skip: 0/12
+ gasprice.json OK + gasprice.json OK
+ origin.json OK + origin.json OK
``` ```
OK: 26/52 Fail: 11/52 Skip: 15/52 OK: 28/52 Fail: 9/52 Skip: 15/52
## vmIOandFlowOperations ## vmIOandFlowOperations
```diff ```diff
+ BlockNumberDynamicJump0_AfterJumpdest.json OK + BlockNumberDynamicJump0_AfterJumpdest.json OK
@ -602,7 +602,7 @@ OK: 0/18 Fail: 0/18 Skip: 18/18
+ push30.json OK + push30.json OK
+ push31.json OK + push31.json OK
+ push32.json OK + push32.json OK
+ push32AndSuicide.json OK - push32AndSuicide.json Fail
+ push32FillUpInputWithZerosAtTheEnd.json OK + push32FillUpInputWithZerosAtTheEnd.json OK
+ push32Undefined.json OK + push32Undefined.json OK
+ push32Undefined2.json OK + push32Undefined2.json OK
@ -614,7 +614,7 @@ OK: 0/18 Fail: 0/18 Skip: 18/18
+ push7.json OK + push7.json OK
+ push8.json OK + push8.json OK
+ push9.json OK + push9.json OK
- swap1.json Fail + swap1.json OK
+ swap10.json OK + swap10.json OK
+ swap11.json OK + swap11.json OK
+ swap12.json OK + swap12.json OK
@ -658,25 +658,25 @@ OK: 0/17 Fail: 0/17 Skip: 17/17
## vmSha3Test ## vmSha3Test
```diff ```diff
+ sha3_0.json OK + sha3_0.json OK
- sha3_1.json Fail + sha3_1.json OK
- sha3_2.json Fail + sha3_2.json OK
+ sha3_3.json OK + sha3_3.json OK
+ sha3_4.json OK + sha3_4.json OK
+ sha3_5.json OK + sha3_5.json OK
- sha3_6.json Fail + sha3_6.json OK
- sha3_bigOffset.json Fail + sha3_bigOffset.json OK
- sha3_bigOffset2.json Fail + sha3_bigOffset2.json OK
- sha3_bigSize.json Fail + sha3_bigSize.json OK
- sha3_memSizeNoQuadraticCost31.json Fail + sha3_memSizeNoQuadraticCost31.json OK
- sha3_memSizeQuadraticCost32.json Fail + sha3_memSizeQuadraticCost32.json OK
- sha3_memSizeQuadraticCost32_zeroSize.json Fail - sha3_memSizeQuadraticCost32_zeroSize.json Fail
- sha3_memSizeQuadraticCost33.json Fail + sha3_memSizeQuadraticCost33.json OK
- sha3_memSizeQuadraticCost63.json Fail + sha3_memSizeQuadraticCost63.json OK
- sha3_memSizeQuadraticCost64.json Fail + sha3_memSizeQuadraticCost64.json OK
+ sha3_memSizeQuadraticCost64_2.json OK + sha3_memSizeQuadraticCost64_2.json OK
- sha3_memSizeQuadraticCost65.json Fail + sha3_memSizeQuadraticCost65.json OK
``` ```
OK: 5/18 Fail: 13/18 Skip: 0/18 OK: 17/18 Fail: 1/18 Skip: 0/18
## vmSystemOperations ## vmSystemOperations
```diff ```diff
ABAcalls0.json Skip ABAcalls0.json Skip
@ -722,6 +722,6 @@ OK: 0/36 Fail: 0/36 Skip: 36/36
- arith.json Fail - arith.json Fail
- boolean.json Fail - boolean.json Fail
- mktx.json Fail - mktx.json Fail
+ suicide.json OK - suicide.json Fail
``` ```
OK: 1/4 Fail: 3/4 Skip: 0/4 OK: 0/4 Fail: 4/4 Skip: 0/4

View File

@ -172,13 +172,16 @@ op sha3, inline = true, startPos, length:
## 0x20, Compute Keccak-256 hash. ## 0x20, Compute Keccak-256 hash.
let (pos, len) = (startPos.toInt, length.toInt) let (pos, len) = (startPos.toInt, length.toInt)
if pos < 0 or len < 0:
raise newException(OutOfBoundsRead, "Out of bounds memory access")
computation.gasMeter.consumeGas( computation.gasMeter.consumeGas(
computation.gasCosts[Op.Sha3].m_handler(computation.memory.len, pos, len), computation.gasCosts[Op.Sha3].m_handler(computation.memory.len, pos, len),
reason="SHA3: word gas cost" reason="SHA3: word gas cost"
) )
computation.memory.extend(pos, len) computation.memory.extend(pos, len)
let endRange = min(pos + len, computation.memory.len - 1) let endRange = min(pos + len, computation.memory.len) - 1
push: push:
keccak256.digest computation.memory.bytes.toOpenArray(pos, endRange) keccak256.digest computation.memory.bytes.toOpenArray(pos, endRange)

View File

@ -96,7 +96,7 @@ proc setupStateDB*(wantedState: JsonNode, stateDB: var AccountStateDB) =
let nonce = accountData{"nonce"}.getInt.u256 let nonce = accountData{"nonce"}.getInt.u256
let code = hexToSeqByte(accountData{"code"}.getStr).toRange let code = hexToSeqByte(accountData{"code"}.getStr).toRange
let balance = accountData{"balance"}.getInt.u256 let balance = UInt256.fromHex accountData{"balance"}.getStr
stateDB.setNonce(account, nonce) stateDB.setNonce(account, nonce)
stateDB.setCode(account, code) stateDB.setCode(account, code)
@ -107,17 +107,18 @@ proc verifyStateDB*(wantedState: JsonNode, stateDB: AccountStateDB) =
let account = ethAddressFromHex(ac) let account = ethAddressFromHex(ac)
for slot, value in accountData{"storage"}: for slot, value in accountData{"storage"}:
let let
slotId = slot.parseHexInt.u256 slotId = UInt256.fromHex slot
wantedValue = UInt256.fromHex value.getStr wantedValue = UInt256.fromHex value.getStr
let (actualValue, found) = stateDB.getStorage(account, slotId) let (actualValue, found) = stateDB.getStorage(account, slotId)
# echo "FOUND ", found # echo "FOUND ", found
# echo "ACTUAL VALUE ", actualValue.toHex # echo "ACTUAL VALUE ", actualValue.toHex
doAssert found and actualValue == wantedValue doAssert found
doAssert actualValue == wantedValue
let let
wantedCode = hexToSeqByte(accountData{"code"}.getStr).toRange wantedCode = hexToSeqByte(accountData{"code"}.getStr).toRange
wantedBalance = accountData{"balance"}.getInt.u256 wantedBalance = UInt256.fromHex accountData{"balance"}.getStr
wantedNonce = accountData{"nonce"}.getInt.u256 wantedNonce = accountData{"nonce"}.getInt.u256
actualCode = stateDB.getCode(account) actualCode = stateDB.getCode(account)