Closed jeff-aion closed 5 years ago
The last BlockchainRuntime.call in this following test case could be probably not correct. The response should be probably null instead of JUST_RETURN. It is in in SelfDestructResource.java.
public static int callToDeleteSuccess(Address beneficiary, Address target) {
// Call the target to get them to delete themselves.
BigInteger value = BigInteger.ZERO;
byte[] data = ABIEncoder.encodeMethodArguments("deleteAndReturn", beneficiary);
long energyLimit = BlockchainRuntime.getRemainingEnergy() / 2;
byte[] response = BlockchainRuntime.call(target, value, data, energyLimit).getReturnData();
assert (DELETE_AND_RETURN == (Integer)ABIDecoder.decodeOneObject(response));
// Call back to ourselves, to verify that we are ok.
data = ABIEncoder.encodeMethodArguments("justReturn");
energyLimit = BlockchainRuntime.getRemainingEnergy() / 2;
response = BlockchainRuntime.call(BlockchainRuntime.getAddress(), value, data, energyLimit).getReturnData();
assert (JUST_RETURN == (Integer)ABIDecoder.decodeOneObject(response));
// Try to call them, verifying that they are not accessible.
data = ABIEncoder.encodeMethodArguments("justReturn");
energyLimit = BlockchainRuntime.getRemainingEnergy() / 2;
response = BlockchainRuntime.call(target, value, data, energyLimit).getReturnData();
assert (JUST_RETURN == (Integer)ABIDecoder.decodeOneObject(response));
return CALL_TO_DELETE_SUCCESS;
}
Sending a call to a self-destructed DApp instance results in this exception:
At first glance, I suspect that the problem is that we are not failing earlier-on, possibly due to the DApp code still being present in the
SoftCache
. This hypothesis hasn't been verified, however.