Skip to content
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 @@ -16,6 +16,8 @@

package com.exonum.binding.core.transaction;

import com.exonum.core.messages.Runtime.ExecutionError;

/**
* An Exonum transaction.
*
Expand All @@ -31,34 +33,15 @@ public interface Transaction {
* @param context a transaction execution context, which allows to access the information about
* this transaction and modify the blockchain state through the included database fork
* @throws TransactionExecutionException if the transaction cannot be executed normally
* and has to be rolled back. The transaction will be committed as failed (status "error"),
* the error code with the optional description will be saved into the storage. The client
* can request the error code to know the reason of the failure
* and has to be rolled back. The transaction will be committed as failed (error kind
* {@linkplain com.exonum.core.messages.Runtime.ErrorKind#SERVICE SERVICE}),
* the {@linkplain ExecutionError#getCode() error code} with the optional description
* will be saved into the storage. The client can request the error code to know the reason
* of the failure
* @throws RuntimeException if an unexpected error occurs. A correct transaction implementation
* must not throw such exceptions. The transaction will be committed as failed
* (status "panic")
*/
void execute(TransactionContext context) throws TransactionExecutionException;

/**
* Returns the information about this transaction in JSON format.
* For example, it is included in the blockchain explorer response to
* a <a href="https://exonum.com/doc/version/0.12/advanced/node-management/#transaction">
* transaction</a> request as 'content.debug'.
*
* <p>By default, no information is provided. If needed, it can be easily implemented
* with {@linkplain com.exonum.binding.common.serialization.json.JsonSerializer Gson}:
*
* <pre><code>
* &#64;Override
* public String info() {
* return JsonSerializer.json().toJson(this);
* }
* </code></pre>
*/
default String info() {
// Empty object by default
return "{}";
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.exonum.binding.cryptocurrency.transactions;

import static com.exonum.binding.common.serialization.StandardSerializers.protobuf;
import static com.exonum.binding.common.serialization.json.JsonSerializer.json;
import static com.exonum.binding.cryptocurrency.transactions.TransactionError.WALLET_ALREADY_EXISTS;
import static com.google.common.base.Preconditions.checkArgument;

Expand Down Expand Up @@ -75,11 +74,6 @@ public void execute(TransactionContext context) throws TransactionExecutionExcep
wallets.put(ownerPublicKey, wallet);
}

@Override
public String info() {
return json().toJson(this);
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.exonum.binding.cryptocurrency.transactions;

import static com.exonum.binding.common.serialization.StandardSerializers.protobuf;
import static com.exonum.binding.common.serialization.json.JsonSerializer.json;
import static com.exonum.binding.cryptocurrency.transactions.TransactionError.INSUFFICIENT_FUNDS;
import static com.exonum.binding.cryptocurrency.transactions.TransactionError.SAME_SENDER_AND_RECEIVER;
import static com.exonum.binding.cryptocurrency.transactions.TransactionError.UNKNOWN_RECEIVER;
Expand Down Expand Up @@ -110,11 +109,6 @@ private static void checkExecution(boolean precondition, byte errorCode)
}
}

@Override
public String info() {
return json().toJson(this);
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.exonum.binding.cryptocurrency.transactions;

import static com.exonum.binding.common.blockchain.ExecutionStatuses.serviceError;
import static com.exonum.binding.common.serialization.json.JsonSerializer.json;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.ARTIFACT_FILENAME;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.ARTIFACT_ID;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.SERVICE_ID;
Expand Down Expand Up @@ -119,18 +118,6 @@ void executeAlreadyExistingWalletTx(TestKit testKit) {
assertThat(txResult).hasValue(expectedTransactionResult);
}

@Test
void info() {
CreateWalletTx tx = new CreateWalletTx(DEFAULT_INITIAL_BALANCE);

String info = tx.info();

CreateWalletTx txParams = json()
.fromJson(info, CreateWalletTx.class);

assertThat(txParams).isEqualTo(tx);
}

@Test
void verifyEquals() {
EqualsVerifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.exonum.binding.cryptocurrency.transactions;

import static com.exonum.binding.common.blockchain.ExecutionStatuses.serviceError;
import static com.exonum.binding.common.serialization.json.JsonSerializer.json;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.ARTIFACT_FILENAME;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.ARTIFACT_ID;
import static com.exonum.binding.cryptocurrency.transactions.PredefinedServiceParameters.SERVICE_ID;
Expand All @@ -40,15 +39,13 @@
import com.exonum.binding.core.blockchain.Blockchain;
import com.exonum.binding.core.storage.database.Snapshot;
import com.exonum.binding.core.storage.indices.ProofMapIndexProxy;
import com.exonum.binding.core.transaction.Transaction;
import com.exonum.binding.cryptocurrency.CryptocurrencySchema;
import com.exonum.binding.cryptocurrency.PredefinedOwnerKeys;
import com.exonum.binding.cryptocurrency.Wallet;
import com.exonum.binding.test.RequiresNativeLibrary;
import com.exonum.binding.testkit.TestKit;
import com.exonum.binding.testkit.TestKitExtension;
import com.exonum.core.messages.Runtime.ExecutionStatus;
import com.google.common.reflect.TypeToken;
import java.util.Optional;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -223,20 +220,6 @@ void executeTransfer_InsufficientFunds(TestKit testKit) {
assertThat(txResult).hasValue(expectedTransactionResult);
}

@Test
void info() {
long seed = Long.MAX_VALUE - 1L;
TransferTx tx = new TransferTx(seed, TO_KEY_PAIR.getPublicKey(), 50L);

String info = tx.info();

// Check the transaction parameters in JSON
Transaction txParameters = json().fromJson(info, new TypeToken<TransferTx>() {
}.getType());

assertThat(txParameters).isEqualTo(tx);
}

@Test
void verifyEquals() {
EqualsVerifier
Expand Down

This file was deleted.

This file was deleted.