Skip to content

Commit

Permalink
test: add htsTransferFromForNFTViaContractCreateLazyCreate to `Lazy…
Browse files Browse the repository at this point in the history
…CreateThroughPrecompileSuite` and enable fuzzy-matching on it (#11163)

Signed-off-by: Nikita Lebedev <[email protected]>
  • Loading branch information
thenswan authored Jan 30, 2024
1 parent 50bedf0 commit 83333db
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"specSnapshots":{"htsTransferFromForNFTViaContractCreateLazyCreate":{"placeholderNum":1007,"encodedItems":[{"b64Body":"Cg4KCAjZ/M6tBhBPEgIYAhICGAMY/svNLCICCHgyIMODwq7DgsK3w4PCuXRGOMOCwq5Kw4PCi8ODwpDDg8KOigGPARIMCJXLqbEGEIi36e4CGm0KIhIgwFiapi3PJDgf7Rojp1XyUodSs86WZsCkYyRwlVX0K3oKIzohA18uoVz0gvv4/PCDptXa1j4qzChLiPsztl/GlTzmsIeZCiISIP1sBW60zZcohKhMIVoRRf3XS8QAZA51VdMEVR4zHXc+IgxIZWxsbyBXb3JsZCEqADIA","b64Record":"CiUIFhoDGPAHKhwKDAgBEAwaBgiArpmkDxIMCAEQDxoGCICumaQPEjB+O9WBEdDEDeEJsAMYw5V5Q2tZurLPTun9G20v8p2z9+HVOp/KLPJiW0yIoMvPSGkaDAiV/c6tBhDD57aYAyIOCggI2fzOrQYQTxICGAIqIMODwq7DgsK3w4PCuXRGOMOCwq5Kw4PCi8ODwpDDg8KOUgA="},{"b64Body":"Cg4KCAja/M6tBhBTEgIYAhICGAMYodLHMSICCHgyIMODwq7DgsK3w4PCuXRGOMOCwq5Kw4PCi8ODwpDDg8KOmgHICQoDGPAHIsAJNjA4MDYwNDA1MjYwNDA1MTYxMDI2MDM4MDM4MDYxMDI2MDgzMzk4MTgxMDE2MDQwNTI4MTAxOTA2MTAwMjU5MTkwNjEwMTMyNTY1YjVmODE3M2ZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm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wQmUeIdmj1CaxzNIoF5lXQr9JMgwIQ9KOgHQgUIgM7aA0ogAAAAAAAAAAAAAAAADFbMFPcitUFfF1kZMYjxTh5f5QdSAFoAagtjZWxsYXIgZG9vcg==","b64Record":"CiUIFiIDGPEHKhwKDAgBEAwaBgiArpmkDxIMCAEQDxoGCICumaQPEjCKiIHFbLs73WHHFRqmA/DUTXoOld27WZi7uLO4ASZujUHXt9R9V6q/uKgBjbqkG8waDAiX/c6tBhC73P2cAiIOCggI2/zOrQYQVRICGAIqIMODwq7DgsK3w4PCuXRGOMOCwq5Kw4PCi8ODwpDDg8KOMIDmihtC8gIKAxjxBxI+YIBgQFJfgP3+omRpcGZzWCISIAx4hfviz8r8csqEuNZH4/s1JcE7I7cftHXoCm+mPBk2ZHNvbGNDAAgVADMigAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKIDqMDoDGPEHShYKFAAAAAAAAAAAAAAAAAAAAAAAAAPxcgcKAxjxBxABUiAKCQoCGAIQz9uVNgoJCgIYYhCAzJU2CggKAxjyBxDQDw=="}]}}}
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.reduceFeeFor;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.resetToDefault;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.snapshotMode;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.tokenTransferList;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.tokenTransferLists;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.uploadDefaultFeeSchedules;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_CONSTRUCTOR_PARAMETERS;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMatchMode.NONDETERMINISTIC_NONCE;
import static com.hedera.services.bdd.spec.utilops.records.SnapshotMode.FUZZY_MATCH_AGAINST_HAPI_TEST_STREAMS;
import static com.hedera.services.bdd.suites.contract.Utils.FunctionType.FUNCTION;
import static com.hedera.services.bdd.suites.contract.Utils.aaWith;
import static com.hedera.services.bdd.suites.contract.Utils.asAddress;
Expand Down Expand Up @@ -159,6 +163,7 @@
import static com.hedera.services.bdd.suites.contract.precompile.CryptoTransferHTSSuite.TRANSFER_MULTIPLE_TOKENS;
import static com.hedera.services.bdd.suites.contract.precompile.ERCPrecompileSuite.NAME_TXN;
import static com.hedera.services.bdd.suites.contract.precompile.V1SecurityModelOverrides.CONTRACTS_MAX_NUM_WITH_HAPI_SIGS_ACCESS;
import static com.hedera.services.bdd.suites.crypto.AutoAccountCreationSuite.LAZY_MEMO;
import static com.hedera.services.bdd.suites.crypto.AutoAccountCreationSuite.TRUE;
import static com.hedera.services.bdd.suites.crypto.AutoCreateUtils.updateSpecFor;
import static com.hedera.services.bdd.suites.crypto.CryptoApproveAllowanceSuite.ADMIN_KEY;
Expand Down Expand Up @@ -306,6 +311,7 @@ public class LeakyContractTestsSuite extends HapiSuite {
public static final String CONTRACT_REPORTED_LOG_MESSAGE = "Contract reported TestContract initcode is {} bytes";
public static final String DEPLOY = "deploy";
private static final String CREATE_2_TXN_2 = "create2Txn2";
private static final String NESTED_LAZY_CREATE_VIA_CONSTRUCTOR = "NestedLazyCreateViaConstructor";

public static void main(String... args) {
new LeakyContractTestsSuite().runSuiteSync();
Expand Down Expand Up @@ -2942,6 +2948,37 @@ HapiSpec invalidContract() {
.then();
}

@HapiTest
final HapiSpec htsTransferFromForNFTViaContractCreateLazyCreate() {
final var depositAmount = 1000;

return defaultHapiSpec("htsTransferFromForNFTViaContractCreateLazyCreate")
.given(
snapshotMode(
FUZZY_MATCH_AGAINST_HAPI_TEST_STREAMS,
NONDETERMINISTIC_NONCE,
NONDETERMINISTIC_CONSTRUCTOR_PARAMETERS),
newKeyNamed(ECDSA_KEY).shape(SECP_256K1_SHAPE),
uploadInitCode(NESTED_LAZY_CREATE_VIA_CONSTRUCTOR))
.when(withOpContext((spec, opLog) -> {
final var ecdsaKey = spec.registry().getKey(ECDSA_KEY);
final var tmp = ecdsaKey.getECDSASecp256K1().toByteArray();
final var addressBytes = recoverAddressFromPubKey(tmp);
allRunFor(
spec,
contractCreate(
NESTED_LAZY_CREATE_VIA_CONSTRUCTOR,
HapiParserUtil.asHeadlongAddress(addressBytes))
.balance(depositAmount)
.gas(GAS_TO_OFFER)
.via(TRANSFER_TXN)
.hasKnownStatus(SUCCESS),
getTxnRecord(TRANSFER_TXN).andAllChildRecords().logged());
}))
.then(childRecordsCheck(
TRANSFER_TXN, SUCCESS, recordWith().status(SUCCESS).memo(LAZY_MEMO)));
}

private HapiContractCallLocal setExpectedCreate2Address(
String contract,
BigInteger salt,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
608060405260405161026038038061026083398181016040528101906100259190610132565b5f8173ffffffffffffffffffffffffffffffffffffffff163460405161004a9061018a565b5f6040518083038185875af1925050503d805f8114610084576040519150601f19603f3d011682016040523d82523d5f602084013e610089565b606091505b50509050806100cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100c4906101f8565b60405180910390fd5b5050610216565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610101826100d8565b9050919050565b610111816100f7565b811461011b575f80fd5b50565b5f8151905061012c81610108565b92915050565b5f60208284031215610147576101466100d4565b5b5f6101548482850161011e565b91505092915050565b5f81905092915050565b50565b5f6101755f8361015d565b915061018082610167565b5f82019050919050565b5f6101948261016a565b9150819050919050565b5f82825260208201905092915050565b7f4661696c656420746f2073656e642076616c75650000000000000000000000005f82015250565b5f6101e260148361019e565b91506101ed826101ae565b602082019050919050565b5f6020820190508181035f83015261020f816101d6565b9050919050565b603e806102225f395ff3fe60806040525f80fdfea26469706673582212200c7885fbe2cfcafc72ca84b8d647e3fb3525c13b23b71fb475e80a6fa63c193664736f6c63430008150033
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_address",
"type": "address"
}
],
"stateMutability": "payable",
"type": "constructor"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract NestedLazyCreateViaConstructor {

constructor(address _address) public payable {
(bool sent, ) = _address.call{value: msg.value}("");
require(sent, "Failed to send value");
}
}

0 comments on commit 83333db

Please sign in to comment.