Skip to content

Commit

Permalink
implemented test_return_address
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhea committed Nov 20, 2019
1 parent c7f1486 commit e781d37
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bindings/java/java/src/test/java/org/ethereum/evmc/EvmcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ void testInit() {
assert (result == 0);
}

@Test
void test_return_address() {
EvmcVm.init(System.getProperty("user.dir") + "/../c/build/example_vm.so");
HostContext context = new TestHostContext();
int BYZANTIUM = 4;
int EVMC_CALL = 0;
int kind = EVMC_CALL;
char[] sender = "39bf71de1b7d7be3b51\0".toCharArray();
char[] destination = "53cf77204eEef952e25\0".toCharArray();
char[] value = "1\0".toCharArray();
char[] inputData = "hello w\0".toCharArray();
long gas = 200000;
int depth = 0;
ByteBuffer msg =
new TestMessage(kind, sender, destination, value, inputData, gas, depth).toByteBuffer();

byte[] code = {0x30, 0x60, 0x00, 0x52, 0x59, 0x60, 0x00, (byte) 0xf3}; // return_address
ByteBuffer bbcode = ByteBuffer.allocateDirect(code.length).put(code);

ByteBuffer result =
EvmcVm.execute(context, BYZANTIUM, msg, bbcode, code.length).order(ByteOrder.nativeOrder());
int statusCode = result.getInt();
result.getInt(); // padding
long gasLeft = result.getLong();
assert (statusCode == 0);
assert (gasLeft == 0);
}

/** Tests callbacks: get_tx_context_fn & set_storage_fn */
@Test
void test_save_return_block_number() {
Expand Down

0 comments on commit e781d37

Please sign in to comment.