Skip to content

Commit

Permalink
test: Increase code coverage in CryptoDeleteHandlerTest (#16832)
Browse files Browse the repository at this point in the history
Signed-off-by: Petar Tonev <petar.tonev@limechain.tech>
  • Loading branch information
petreze authored Nov 29, 2024
1 parent 2a82e0d commit b8f0637
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import com.hedera.hapi.node.base.AccountID;
Expand All @@ -55,6 +57,10 @@
import com.hedera.node.app.service.token.impl.test.handlers.util.CryptoHandlerTestBase;
import com.hedera.node.app.service.token.impl.validators.StakingValidator;
import com.hedera.node.app.service.token.records.CryptoDeleteStreamBuilder;
import com.hedera.node.app.spi.fees.FeeCalculator;
import com.hedera.node.app.spi.fees.FeeCalculatorFactory;
import com.hedera.node.app.spi.fees.FeeContext;
import com.hedera.node.app.spi.fees.Fees;
import com.hedera.node.app.spi.fixtures.workflows.FakePreHandleContext;
import com.hedera.node.app.spi.metrics.StoreMetricsService;
import com.hedera.node.app.spi.store.StoreFactory;
Expand All @@ -68,7 +74,9 @@
import com.swirlds.state.spi.WritableStates;
import java.util.List;
import java.util.Map;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -384,6 +392,19 @@ void failsIfEitherDeleteOrTransferAccountDoesntExist() throws PreCheckException
.has(responseCode(ACCOUNT_ID_DOES_NOT_EXIST));
}

@Test
@DisplayName("check that fees are 1 for delete account trx")
void testCalculateFeesReturnsCorrectFeeForDeleteAccount() {
final var feeCtx = mock(FeeContext.class);
final var feeCalcFact = mock(FeeCalculatorFactory.class);
final var feeCalc = mock(FeeCalculator.class);
given(feeCtx.feeCalculatorFactory()).willReturn(feeCalcFact);
given(feeCalcFact.feeCalculator(any())).willReturn(feeCalc);
given(feeCalc.legacyCalculate(any())).willReturn(new Fees(1, 0, 0));

Assertions.assertThat(subject.calculateFees(feeCtx)).isEqualTo(new Fees(1, 0, 0));
}

private TransactionBody deleteAccountTransaction(
final AccountID deleteAccountId, final AccountID transferAccountId) {
final var transactionID = TransactionID.newBuilder().accountID(id).transactionValidStart(consensusTimestamp);
Expand Down

0 comments on commit b8f0637

Please sign in to comment.