Search in sources :

Example 1 with SEND_REPEATEDLY_ABI

use of com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SEND_REPEATEDLY_ABI in project hedera-services by hashgraph.

the class ContractCreateSuite method receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix.

private HapiApiSpec receiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix() {
    final var justSendInitcode = "justSendInitcode";
    final var sendInternalAndDelegateInitcode = "sendInternalAndDelegateInitcode";
    final var justSend = "justSend";
    final var sendInternalAndDelegate = "sendInternalAndDelegate";
    final var beneficiary = "civilian";
    final var balanceToDistribute = 1_000L;
    final AtomicLong justSendContractNum = new AtomicLong();
    final AtomicLong beneficiaryAccountNum = new AtomicLong();
    return defaultHapiSpec("ReceiverSigReqTransferRecipientMustSignWithFullPubKeyPrefix").given(cryptoCreate(beneficiary).balance(0L).receiverSigRequired(true).exposingCreatedIdTo(id -> beneficiaryAccountNum.set(id.getAccountNum())), fileCreate(justSendInitcode).path(ContractResources.JUST_SEND_BYTECODE_PATH), fileCreate(sendInternalAndDelegateInitcode).path(ContractResources.SEND_INTERNAL_AND_DELEGATE_BYTECODE_PATH)).when(contractCreate(justSend).bytecode(justSendInitcode).gas(300_000L).exposingNumTo(justSendContractNum::set), contractCreate(sendInternalAndDelegate).bytecode(sendInternalAndDelegateInitcode).gas(300_000L).balance(balanceToDistribute)).then(/* Sending requires receiver signature */
    sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).hasKnownStatus(INVALID_SIGNATURE)), /* But it's not enough to just sign using an incomplete prefix */
    sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).signedBy(DEFAULT_PAYER, beneficiary).hasKnownStatus(INVALID_SIGNATURE)), /* We have to specify the full prefix so the sig can be verified async */
    getAccountInfo(beneficiary).logged(), sourcing(() -> contractCall(sendInternalAndDelegate, SEND_REPEATEDLY_ABI, justSendContractNum.get(), beneficiaryAccountNum.get(), balanceToDistribute / 2).alsoSigningWithFullPrefix(beneficiary)), getAccountBalance(beneficiary).logged());
}
Also used : Arrays(java.util.Arrays) ContractFnResultAsserts.isContractWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isContractWith) SEND_REPEATEDLY_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SEND_REPEATEDLY_ABI) SigControl(com.hedera.services.bdd.spec.keys.SigControl) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) ContractID(com.hederahashgraph.api.proto.java.ContractID) EMPTY_CONSTRUCTOR(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.EMPTY_CONSTRUCTOR) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) FIBONACCI_PLUS_CONSTRUCTOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_CONSTRUCTOR_ABI) CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.CONTRACT) UtilVerbs.inParallel(com.hedera.services.bdd.spec.utilops.UtilVerbs.inParallel) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) BigInteger(java.math.BigInteger) Bytes32(org.apache.tuweni.bytes.Bytes32) Path(java.nio.file.Path) Longs(com.google.common.primitives.Longs) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TRANSACTION_OVERSIZE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_OVERSIZE) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) ByteString(com.google.protobuf.ByteString) UncheckedIOException(java.io.UncheckedIOException) MEMO_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MEMO_TOO_LONG) List(java.util.List) ControlForKey.forKey(com.hedera.services.bdd.spec.keys.ControlForKey.forKey) Logger(org.apache.logging.log4j.Logger) CONSPICUOUS_DONATION_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CONSPICUOUS_DONATION_ABI) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) IntStream(java.util.stream.IntStream) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) SEND_THEN_REVERT_NESTED_SENDS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SEND_THEN_REVERT_NESTED_SENDS_ABI) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) DELEGATE_CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) MAX_GAS_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_GAS_LIMIT_EXCEEDED) MULTIPURPOSE_BYTECODE_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MULTIPURPOSE_BYTECODE_PATH) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) UtilVerbs.newKeyListNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyListNamed) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PROPAGATE_NESTED_CREATIONS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.PROPAGATE_NESTED_CREATIONS_ABI) FIBONACCI_PLUS_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_PATH) Files(java.nio.file.Files) ERROR_DECODING_BYTESTRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ERROR_DECODING_BYTESTRING) INVALID_ZERO_BYTE_IN_STRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING) IOException(java.io.IOException) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) UtilVerbs.contractListWithPropertiesInheritedFrom(com.hedera.services.bdd.spec.utilops.UtilVerbs.contractListWithPropertiesInheritedFrom) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) HapiPropertySource.asSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) INSUFFICIENT_GAS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_GAS) OFF(com.hedera.services.bdd.spec.keys.SigControl.OFF) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) THRESHOLD(com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD) Assertions(org.junit.jupiter.api.Assertions) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) ADD_NTH_FIB_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADD_NTH_FIB_ABI) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) LogManager(org.apache.logging.log4j.LogManager) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

Longs (com.google.common.primitives.Longs)1 ByteString (com.google.protobuf.ByteString)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 HapiPropertySource.asSolidityAddress (com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress)1 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)1 AssertUtils.inOrder (com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder)1 ContractFnResultAsserts.isContractWith (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isContractWith)1 ContractFnResultAsserts.isLiteralResult (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult)1 ContractFnResultAsserts.resultWith (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith)1 ContractInfoAsserts.contractWith (com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith)1 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)1 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)1 ADD_NTH_FIB_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.ADD_NTH_FIB_ABI)1 CONSPICUOUS_DONATION_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CONSPICUOUS_DONATION_ABI)1 EMPTY_CONSTRUCTOR (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.EMPTY_CONSTRUCTOR)1 FIBONACCI_PLUS_CONSTRUCTOR_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_CONSTRUCTOR_ABI)1 FIBONACCI_PLUS_PATH (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.FIBONACCI_PLUS_PATH)1