use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS in project hedera-services by hashgraph.
the class TokenTransferBasicLoadTest method activeTokenAssociatesFactory.
private Function<HapiApiSpec, OpProvider> activeTokenAssociatesFactory(PerfTestLoadSettings settings) {
int numTotalTokens = settings.getTotalTokens();
int numActiveTokenAccounts = settings.getTotalTestTokenAccounts();
int totalClients = settings.getTotalClients();
int numActiveTokens = (totalClients >= 1) ? numTotalTokens / totalClients : numTotalTokens;
AtomicLong remainingAssociations = new AtomicLong(numActiveTokens * numActiveTokenAccounts - 1);
if (log.isDebugEnabled()) {
log.debug("Total active token accounts {}, total test tokens {}, my portion of tokens {}", numActiveTokenAccounts, numTotalTokens, numActiveTokens);
}
long startAccountId = settings.getTestTreasureStartAccount();
return spec -> new OpProvider() {
@Override
public List<HapiSpecOperation> suggestedInitializers() {
return Collections.emptyList();
}
@Override
public Optional<HapiSpecOperation> get() {
long nextAssocId;
if ((nextAssocId = remainingAssociations.getAndDecrement()) < 0) {
return Optional.empty();
}
int curToken = (int) nextAssocId / numActiveTokenAccounts;
long curAccount = nextAssocId % numActiveTokenAccounts;
var accountId = "0.0." + (startAccountId + curAccount);
var op = tokenAssociate(accountId, tokenRegistryName(curToken)).payingWith(DEFAULT_PAYER).signedBy(DEFAULT_PAYER).hasRetryPrecheckFrom(BUSY, PLATFORM_TRANSACTION_NOT_CREATED, DUPLICATE_TRANSACTION, INSUFFICIENT_PAYER_BALANCE).hasPrecheckFrom(DUPLICATE_TRANSACTION, OK).hasKnownStatusFrom(SUCCESS, TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT, INVALID_TOKEN_ID, TRANSACTION_EXPIRED, TOKENS_PER_ACCOUNT_LIMIT_EXCEEDED, FAIL_INVALID, OK).fee(ONE_HUNDRED_HBARS).noLogging().suppressStats(true).deferStatusResolution();
return Optional.of(op);
}
};
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS in project hedera-services by hashgraph.
the class FileAppendTransitionLogicTest method happyPathFlowsForSpecialFile.
@Test
void happyPathFlowsForSpecialFile() {
// setup:
InOrder inOrder = inOrder(hfs, txnCtx);
givenTxnCtxAppending(TargetType.SPECIAL);
// and:
given(hfs.append(any(), any())).willReturn(success);
// when:
subject.doStateTransition();
// then:
inOrder.verify(hfs).append(argThat(special::equals), argThat(bytes -> Arrays.equals(moreContents, bytes)));
inOrder.verify(txnCtx).setStatus(SUCCESS);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS in project hedera-services by hashgraph.
the class FileAppendTransitionLogicTest method happyPathFlowsForNonSpecialFile.
@Test
void happyPathFlowsForNonSpecialFile() {
// setup:
InOrder inOrder = inOrder(hfs, txnCtx);
givenTxnCtxAppending(TargetType.VALID);
// and:
given(hfs.append(any(), any())).willReturn(success);
// when:
subject.doStateTransition();
// then:
inOrder.verify(hfs).append(argThat(target::equals), argThat(bytes -> Arrays.equals(moreContents, bytes)));
inOrder.verify(txnCtx).setStatus(SUCCESS);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS in project hedera-services by hashgraph.
the class FileUpdateTransitionLogicTest method allowsSysAdminToUpdateImmutableSysFile.
@Test
void allowsSysAdminToUpdateImmutableSysFile() {
givenTxnCtxUpdating(EnumSet.of(UpdateTarget.CONTENTS), sysFileTarget);
given(txnCtx.activePayer()).willReturn(sysAdmin);
// and:
given(hfs.exists(sysFileTarget)).willReturn(true);
given(hfs.getattr(sysFileTarget)).willReturn(immutableAttr);
// and:
given(hfs.overwrite(any(), any())).willReturn(new SimpleUpdateResult(false, true, SUCCESS));
given(hfs.setattr(any(), any())).willReturn(new SimpleUpdateResult(true, false, SUCCESS));
// when:
subject.doStateTransition();
// then:
verify(hfs).overwrite(argThat(sysFileTarget::equals), argThat(bytes -> Arrays.equals(newContents, bytes)));
verify(txnCtx).setStatus(SUCCESS);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS in project hedera-services by hashgraph.
the class FileUpdateTransitionLogicTest method doesntAllowSysAdminToUpdateImmutableNonSysFile.
@Test
void doesntAllowSysAdminToUpdateImmutableNonSysFile() {
givenTxnCtxUpdating(EnumSet.of(UpdateTarget.CONTENTS), nonSysFileTarget);
given(txnCtx.activePayer()).willReturn(sysAdmin);
// and:
given(hfs.exists(nonSysFileTarget)).willReturn(true);
given(hfs.getattr(nonSysFileTarget)).willReturn(immutableAttr);
// and:
given(hfs.overwrite(any(), any())).willReturn(new SimpleUpdateResult(false, true, SUCCESS));
given(hfs.setattr(any(), any())).willReturn(new SimpleUpdateResult(true, false, SUCCESS));
// when:
subject.doStateTransition();
// then:
verify(hfs, never()).overwrite(argThat(nonSysFileTarget::equals), argThat(bytes -> Arrays.equals(newContents, bytes)));
verify(txnCtx).setStatus(UNAUTHORIZED);
}
Aggregations