Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

PAN-2875 - Update Reference Tests #1633

Merged
merged 4 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Gas cost(final MessageFrame frame) {
public void execute(final MessageFrame frame) {
final Address address = Words.toAddress(frame.popStackItem());
final Account account = frame.getWorldState().get(address);
if (account == null) {
if (account == null || account.isEmpty()) {
frame.pushStackItem(Bytes32.ZERO);
} else {
frame.pushStackItem(account.getCodeHash());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public void constantinople() {
milestone("Constantinople");
}

@Test
public void constantinopleFix() {
milestone("ConstantinopleFix");
}

public void milestone(final String milestone) {

final TransactionTestCaseSpec.Expectation expected = spec.expectation(milestone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand Down Expand Up @@ -61,26 +62,22 @@ public Address getSender() {

private final BytesValue rlp;

@SuppressWarnings("unchecked")
@JsonCreator
public TransactionTestCaseSpec(
@JsonProperty("Frontier") final Expectation frontierExpectation,
@JsonProperty("Homestead") final Expectation homesteadExpectation,
@JsonProperty("EIP150") final Expectation EIP150Expectation,
@JsonProperty("EIP158") final Expectation EIP158Expectation,
@JsonProperty("Byzantium") final Expectation byzantiumExpectation,
@JsonProperty("Constantinople") final Expectation constantinopleExpectation,
@JsonProperty("rlp") final String rlp) {
public TransactionTestCaseSpec(final Map<String, Object> props) {
expectations = new HashMap<>();
expectations.put("Frontier", frontierExpectation);
expectations.put("Homestead", homesteadExpectation);
expectations.put("EIP150", EIP150Expectation);
expectations.put("EIP158", EIP158Expectation);
expectations.put("Byzantium", byzantiumExpectation);
expectations.put("Constantinople", constantinopleExpectation);
for (final Map.Entry<String, Object> entry : props.entrySet()) {
if ("rlp".equals(entry.getKey())) continue;

final Map<String, Object> expectation = (Map<String, Object>) entry.getValue();
expectations.put(
entry.getKey(),
new Expectation((String) expectation.get("hash"), (String) expectation.get("sender")));
}

BytesValue parsedRlp = null;
try {
parsedRlp = BytesValue.fromHexString(rlp);
parsedRlp = BytesValue.fromHexString(props.get("rlp").toString());
} catch (final IllegalArgumentException e) {
// Some test cases include rlp "hex strings" with invalid characters
// In this case, just set rlp to null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public ParsedExtraData parseExtraData(final BlockHeader header) {
@JsonIgnoreProperties({
"expectExceptionByzantium",
"expectExceptionConstantinople",
"expectExceptionConstantinopleFix",
"expectExceptionIstanbul",
"expectExceptionEIP150",
"expectExceptionEIP158",
"expectExceptionFrontier",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public class BlockchainReferenceTestTools {
}

// Known bad test.
params.blacklist("RevertPrecompiledTouch_d0g0v0_(EIP158|Byzantium)");
params.blacklist(
"RevertPrecompiledTouch(_storage)?_d(0|3)g0v0_(EIP158|Byzantium|Constantinople|ConstantinopleFix)");

// Consumes a huge amount of memory
params.blacklist(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private static TransactionProcessor transactionProcessor(final String name) {
params.blacklistAll();
}
// Known incorrect test.
params.blacklist("RevertPrecompiledTouch-(EIP158|Byzantium)");
params.blacklist(
"RevertPrecompiledTouch(_storage)?-(EIP158|Byzantium|Constantinople|ConstantinopleFix)");
// Gas integer value is too large to construct a valid transaction.
params.blacklist("OverflowGasRequire");
// Consumes a huge amount of memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ public void shouldReturnZeroWhenAccountDoesNotExist() {

@Test
public void shouldReturnHashOfEmptyDataWhenAccountExistsButDoesNotHaveCode() {
worldStateUpdater.getOrCreate(REQUESTED_ADDRESS);
worldStateUpdater.getOrCreate(REQUESTED_ADDRESS).setBalance(Wei.of(1));
assertThat(executeOperation(REQUESTED_ADDRESS)).isEqualTo(Hash.EMPTY);
}

@Test
public void shouldReturnZeroWhenAccountExistsButIsEmpty() {
worldStateUpdater.getOrCreate(REQUESTED_ADDRESS);
assertThat(executeOperation(REQUESTED_ADDRESS)).isEqualTo(Bytes32.ZERO);
}

@Test
public void shouldReturnZeroWhenPrecompiledContractHasNoBalance() {
assertThat(executeOperation(Address.ECREC)).isEqualTo(Bytes32.ZERO);
Expand Down
2 changes: 1 addition & 1 deletion ethereum/referencetests/src/test/resources
Submodule resources updated 25069 files