qortal/src/test/Common.java

27 lines
791 B
Java
Raw Normal View History

package test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import repository.DataException;
import repository.RepositoryFactory;
import repository.RepositoryManager;
import repository.hsqldb.HSQLDBRepositoryFactory;
public class Common {
Arbitrary Transaction support + various fixes NOTE: requires HSQLDB built from svn rev 5836 or later Fixed BuyNameTransactionData constructors not picking up nameReference. Added new "orphan" tool to regress blockchain back to specified block. Added new Block constructor for when receiving a block from the network. Fixed Block generatingBalance/forging code to be compliant with v1. Added logging of transactions that fail validation during block validation. Fixed buyer/seller balances not being updated during name purchase. Generally replace BigDecimal.compareTo expressions with "<operator> 0" form. e.g. instead of someBigDecimal.compareTo(anotherBigDecimal) == 1 we now have someBigDecimal.compareTo(anotherBigDecimal) > 0 Fix amounts involved in BuyNameTransactions. Renamed Transaction.calcSignature to .sign Refactored Transaction.toBytesLessSignature to TransactionTransformer.toBytesForSigning, which itself calls subclass' toBytesForSigningImpl, which might override Transaction.toBytesForSigningImpl when special v1 mangling is required. Corrected more cases of NTP.getTime in transaction processing which should really be transaction's timestmap instead. Fixed HSQLDB-related issue where strings were padded with spaces during comparison. Some column types no longer case-insensitive as that mode of comparison is done during transaction validation. Added missing option_index column to CreatePollTransactionOptions which was causing out-of-order options during fetching from repository and hence signature failures. Added unit tests for v1-special mangled transaction signature checking. Removed checks for remaining bytes to ByteBuffer in various transaction transformers' fromByteBuffer() methods as the buffer underflow exception is now caught in TransactionTransformer.fromBytes. Corrected byte-related transformations of CreatePollTransactions that were missing voter counts (albeit always zero). Corrected byte-related transformations of IssueAssetTransactions that were missing duplicate signature/reference (v1-special). Added "txhex" tool to output transaction in hex form, given base58 tx signature. Added "v1feeder" tool to fetch blocks from v1 node and process them.
2018-08-02 10:02:33 +01:00
public static final String connectionUrl = "jdbc:hsqldb:file:db/test;create=true;close_result=true;sql.strict_exec=true;sql.enforce_names=true;sql.syntax_mys=true;sql.pad_space=false";
@BeforeClass
public static void setRepository() throws DataException {
RepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(connectionUrl);
RepositoryManager.setRepositoryFactory(repositoryFactory);
}
@AfterClass
public static void closeRepository() throws DataException {
RepositoryManager.closeRepositoryFactory();
}
}