Skip to content

Commit

Permalink
fix: fix the jump problem in format_operation_source
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 26, 2021
1 parent acdd872 commit 3d59cc3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
36 changes: 26 additions & 10 deletions src/stellar_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,35 @@ static void format_confirm_transaction_details(tx_context_t *txCtx) {
format_memo(txCtx);
}

static void format_next_operation(tx_context_t *txCtx) {
formatter_stack[formatter_index] = NULL;
set_state_data(true);
}

static void format_operation_source(tx_context_t *txCtx) {
if (txCtx->opDetails.sourceAccountPresent) {
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_confirm_transaction_details);
} else {
if (txCtx->opIdx == txCtx->opCount) {
// last operation: show transaction details
if (txCtx->opIdx == txCtx->opCount) {
// last operation
if (txCtx->opDetails.sourceAccountPresent) {
// If there is a source account, wait for the user to
// enter the next step after displaying the source account
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_confirm_transaction_details);
} else {
// Otherwise, go to the next step and display the transaction information.
format_confirm_transaction_details(txCtx);
}
} else {
// more operations
if (txCtx->opDetails.sourceAccountPresent) {
// If there is a source account, wait for the user to
// enter the next step after displaying the source account
strcpy(detailCaption, "Op Source");
print_public_key(txCtx->opDetails.sourceAccount, detailValue, 0, 0);
push_to_formatter_stack(&format_next_operation);
} else {
// more operations: show next operation
formatter_stack[formatter_index] = NULL;
set_state_data(true);
// Otherwise, show the next operation.
format_next_operation(txCtx);
}
}
}
Expand Down
44 changes: 15 additions & 29 deletions tests/src/test_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,21 @@ stellar_context_t ctx;
tx_context_t tx_ctx;

static const char *testcases[] = {
"../testcases/txMultiOp.raw",
"../testcases/txSimple.raw",
"../testcases/txMemoId.raw",
"../testcases/txMemoText.raw",
"../testcases/txMemoHash.raw",
"../testcases/txCustomAsset4.raw",
"../testcases/txCustomAsset12.raw",
"../testcases/txTimeBounds.raw",
"../testcases/txOpSource.raw",
"../testcases/txCreateAccount.raw",
"../testcases/txAccountMerge.raw",
"../testcases/txPathPayment.raw",
"../testcases/txSetData.raw",
"../testcases/txRemoveData.raw",
"../testcases/txChangeTrust.raw",
"../testcases/txRemoveTrust.raw",
"../testcases/txAllowTrust.raw",
"../testcases/txRevokeTrust.raw",
"../testcases/txCreateOffer.raw",
"../testcases/txCreateOffer2.raw",
"../testcases/txChangeOffer.raw",
"../testcases/txRemoveOffer.raw",
"../testcases/txPassiveOffer.raw",
"../testcases/txSetAllOptions.raw",
"../testcases/txSetSomeOptions.raw",
"../testcases/txInflation.raw",
"../testcases/txBumpSequence.raw",
"../testcases/txManageBuyOffer.raw",
NULL,
"../testcases/txMultiOp.raw", "../testcases/txMultiOpWithSource.raw",
"../testcases/txSimple.raw", "../testcases/txMemoId.raw",
"../testcases/txMemoText.raw", "../testcases/txMemoHash.raw",
"../testcases/txCustomAsset4.raw", "../testcases/txCustomAsset12.raw",
"../testcases/txTimeBounds.raw", "../testcases/txOpSource.raw",
"../testcases/txCreateAccount.raw", "../testcases/txAccountMerge.raw",
"../testcases/txPathPayment.raw", "../testcases/txSetData.raw",
"../testcases/txRemoveData.raw", "../testcases/txChangeTrust.raw",
"../testcases/txRemoveTrust.raw", "../testcases/txAllowTrust.raw",
"../testcases/txRevokeTrust.raw", "../testcases/txCreateOffer.raw",
"../testcases/txCreateOffer2.raw", "../testcases/txChangeOffer.raw",
"../testcases/txRemoveOffer.raw", "../testcases/txPassiveOffer.raw",
"../testcases/txSetAllOptions.raw", "../testcases/txSetSomeOptions.raw",
"../testcases/txInflation.raw", "../testcases/txBumpSequence.raw",
"../testcases/txManageBuyOffer.raw", NULL,
};

static void load_transaction_data(const char *filename, tx_context_t *txCtx) {
Expand Down
Binary file modified tests/testcases/txMultiOp.raw
Binary file not shown.

0 comments on commit 3d59cc3

Please sign in to comment.