Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unboxing issue causing errors in acceptance tests #10375

Merged
merged 4 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ public static EntityId toEntityId(final com.hedera.hapi.node.base.FileID fileID)
}

public static com.hedera.hapi.node.base.AccountID toAccountId(final Long id) {
if (id == null) {
return null;
}
final var decodedEntityId = EntityId.of(id);

return toAccountId(decodedEntityId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,44 @@ void associateToken(final Boolean single) throws Exception {
// Given
final var notAssociatedAccount = accountEntityPersist();

final var tokenEntity = tokenEntityPersist();
final var token = fungibleTokenPersist();
final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);

domainBuilder
.token()
.customize(t -> t.tokenId(tokenEntity.getId()).type(TokenTypeEnum.FUNGIBLE_COMMON))
.persist();
// When
final var functionCall = single
? contract.call_associateTokenExternal(
getAddressFromEntity(notAssociatedAccount),
toAddress(token.getTokenId()).toHexString())
: contract.call_associateTokensExternal(
getAddressFromEntity(notAssociatedAccount),
List.of(toAddress(token.getTokenId()).toHexString()));

// Then
verifyEthCallAndEstimateGas(functionCall, contract, ZERO_VALUE);
verifyOpcodeTracerCall(functionCall.encodeFunctionCall(), contract);
}

@ParameterizedTest
@ValueSource(booleans = {true, false})
void associateTokenWithNullAutoRenew(final Boolean single) throws Exception {
// Given
final var notAssociatedAccount = accountEntityPersistCustomizable(e -> e.type(EntityType.ACCOUNT)
.balance(DEFAULT_ACCOUNT_BALANCE)
.autoRenewAccountId(null)
.alias(null)
.evmAddress(null));

final var token = fungibleTokenPersist();
final var contract = testWeb3jService.deploy(ModificationPrecompileTestContract::deploy);

// When
final var functionCall = single
? contract.call_associateTokenExternal(
getAddressFromEntity(notAssociatedAccount), getAddressFromEntity(tokenEntity))
getAddressFromEntity(notAssociatedAccount),
toAddress(token.getTokenId()).toHexString())
: contract.call_associateTokensExternal(
getAddressFromEntity(notAssociatedAccount), List.of(getAddressFromEntity(tokenEntity)));
getAddressFromEntity(notAssociatedAccount),
List.of(toAddress(token.getTokenId()).toHexString()));

// Then
verifyEthCallAndEstimateGas(functionCall, contract, ZERO_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ void toAccountIdFromId() {
assertEquals(expectedAccountId, EntityIdUtils.toAccountId(id));
}

@Test
void toAccountIdFromNullId() {
assertThat(EntityIdUtils.toAccountId((Long) null)).isNull();
}

@Test
void toAccountIdFromShardRealmNum() {
final var expectedAccountId = com.hedera.hapi.node.base.AccountID.newBuilder()
Expand Down
Loading