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());
}
Aggregations