This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PAN-2499] debug trace transaction (#1258)
* move subclass * Update Transaction.java * fix 500 error on tx not found Returns a JSON RPC error instead of failing due to NPE. * Handle reason on revert operation Implement reason string on revert operation as in the following EIP : https://github.com/ethereum/EIPs/blob/master/EIPS/eip-140.md * Update MessageFrame.java * Update RevertOperationTest.java * fix PR discussion * fix PR * Update DebugTraceTransaction.java
- Loading branch information
1 parent
5a43c61
commit cda51a9
Showing
11 changed files
with
213 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
.../core/src/test/java/tech/pegasys/pantheon/ethereum/vm/operations/RevertOperationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2018 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.pantheon.ethereum.vm.operations; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import tech.pegasys.pantheon.ethereum.mainnet.ConstantinopleGasCalculator; | ||
import tech.pegasys.pantheon.ethereum.vm.MessageFrame; | ||
import tech.pegasys.pantheon.util.bytes.Bytes32; | ||
import tech.pegasys.pantheon.util.bytes.BytesValue; | ||
import tech.pegasys.pantheon.util.uint.UInt256; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Mockito; | ||
|
||
@RunWith(Parameterized.class) | ||
public class RevertOperationTest { | ||
|
||
private final String code; | ||
|
||
private final MessageFrame messageFrame = mock(MessageFrame.class); | ||
private final RevertOperation operation = new RevertOperation(new ConstantinopleGasCalculator()); | ||
|
||
@Parameters(name = "sender: {0}, salt: {1}, code: {2}") | ||
public static Object[][] params() { | ||
return new Object[][] { | ||
{ | ||
"0x6c726576657274656420646174616000557f726576657274206d657373616765000000000000000000000000000000000000600052600e6000fd", | ||
} | ||
}; | ||
} | ||
|
||
public RevertOperationTest(final String code) { | ||
this.code = code; | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
when(messageFrame.popStackItem()) | ||
.thenReturn(Bytes32.fromHexString("0x00")) | ||
.thenReturn(Bytes32.fromHexString("0x0e")); | ||
when(messageFrame.readMemory(UInt256.ZERO, UInt256.of(0x0e))) | ||
.thenReturn(BytesValue.fromHexString("726576657274206d657373616765")); | ||
} | ||
|
||
@Test | ||
public void shouldReturnReason() { | ||
assertTrue(code.contains("726576657274206d657373616765")); | ||
ArgumentCaptor<String> arg = ArgumentCaptor.forClass(String.class); | ||
operation.execute(messageFrame); | ||
Mockito.verify(messageFrame).setRevertReason(arg.capture()); | ||
assertEquals("revert message", arg.getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.