forked from Qortal/qortal
015f4fa725
Too many calls needing Connection object in args when they're only simple database reads. Even worse, some methods had database-less counterparts with different outputs, e.g. toJSON(). Now Connections can be requested from the pool for general database read scenarios. Code paths that might perform a multi-statement database transaction still require a Connection arg passed around as the database transaction are local to that Connection. In light of above, added support for database opening, closing, setting URL. Fixed out of bounds array index bug in unknown-length version of DB.getResultSetBytes(). Fixed Block's lazy-instantiation of Transactions. Implemented Block's isSignatureValid(). Fixed bug in Crypto.isValidAddress() which was using the wrong bytes. Fix GenesisTransaction generic constructor calling super with PaymentTransaction type! Fix GenesisTransaction signature constructor using wrong column indexes from ResultSet. In Transaction, don't expect CREATOR_LENGTH bytes from database in case we're dealing with a GenesisTransaction where the creator's public key is only 8 bytes long. Improvements to unit tests, including changing migrate so it can be run repeatedly to do incremental migrations.
34 lines
917 B
Java
34 lines
917 B
Java
package test;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.sql.Connection;
|
|
import java.sql.SQLException;
|
|
import java.time.Instant;
|
|
|
|
import org.junit.Test;
|
|
|
|
import database.DB;
|
|
import qora.account.PublicKeyAccount;
|
|
import qora.transaction.PaymentTransaction;
|
|
import utils.Base58;
|
|
|
|
public class save extends common {
|
|
|
|
@Test
|
|
public void testSavePaymentTransaction() throws SQLException {
|
|
String reference58 = "rrrr";
|
|
byte[] reference = Base58.decode(reference58);
|
|
String signature58 = "ssss";
|
|
byte[] signature = Base58.decode(signature58);
|
|
PublicKeyAccount sender = new PublicKeyAccount("Qsender".getBytes());
|
|
|
|
PaymentTransaction paymentTransaction = new PaymentTransaction(sender, "Qrecipient", BigDecimal.valueOf(12345L), BigDecimal.ONE,
|
|
Instant.now().getEpochSecond(), reference, signature);
|
|
|
|
try (final Connection connection = DB.getConnection()) {
|
|
paymentTransaction.save(connection);
|
|
}
|
|
}
|
|
|
|
}
|