mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
TransactionTest: Reformat some lengthy method invocations.
This commit is contained in:
parent
3ec862cf99
commit
083136e9e8
@ -176,11 +176,26 @@ public class TransactionTest {
|
||||
tx.getInput(0).setSequenceNumber(0);
|
||||
tx.setLockTime(time.subtract(BigInteger.ONE).longValue());
|
||||
TransactionSignature fromSig =
|
||||
tx.calculateSignature(0, from, outputScript, Transaction.SigHash.SINGLE, false);
|
||||
tx.calculateSignature(
|
||||
0,
|
||||
from,
|
||||
outputScript,
|
||||
Transaction.SigHash.SINGLE,
|
||||
false);
|
||||
TransactionSignature toSig =
|
||||
tx.calculateSignature(0, to, outputScript, Transaction.SigHash.SINGLE, false);
|
||||
tx.calculateSignature(
|
||||
0,
|
||||
to,
|
||||
outputScript,
|
||||
Transaction.SigHash.SINGLE,
|
||||
false);
|
||||
TransactionSignature incorrectSig =
|
||||
tx.calculateSignature(0, incorrect, outputScript, Transaction.SigHash.SINGLE, false);
|
||||
tx.calculateSignature(
|
||||
0,
|
||||
incorrect,
|
||||
outputScript,
|
||||
Transaction.SigHash.SINGLE,
|
||||
false);
|
||||
Script scriptSig =
|
||||
ScriptBuilder.createCLTVPaymentChannelInput(fromSig, toSig);
|
||||
Script refundSig =
|
||||
@ -223,9 +238,19 @@ public class TransactionTest {
|
||||
tx.getInput(0).setSequenceNumber(0);
|
||||
tx.setLockTime(time.add(BigInteger.ONE).longValue());
|
||||
TransactionSignature fromSig =
|
||||
tx.calculateSignature(0, from, outputScript, Transaction.SigHash.SINGLE, false);
|
||||
tx.calculateSignature(
|
||||
0,
|
||||
from,
|
||||
outputScript,
|
||||
Transaction.SigHash.SINGLE,
|
||||
false);
|
||||
TransactionSignature incorrectSig =
|
||||
tx.calculateSignature(0, incorrect, outputScript, Transaction.SigHash.SINGLE, false);
|
||||
tx.calculateSignature(
|
||||
0,
|
||||
incorrect,
|
||||
outputScript,
|
||||
Transaction.SigHash.SINGLE,
|
||||
false);
|
||||
Script scriptSig =
|
||||
ScriptBuilder.createCLTVPaymentChannelRefund(fromSig);
|
||||
Script invalidScriptSig =
|
||||
@ -347,7 +372,8 @@ public class TransactionTest {
|
||||
@Test
|
||||
public void testCoinbaseHeightCheck() throws VerificationException {
|
||||
// Coinbase transaction from block 300,000
|
||||
final byte[] transactionBytes = HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803e09304062f503253482f0403c86d53087ceca141295a00002e522cfabe6d6d7561cf262313da1144026c8f7a43e3899c44f6145f39a36507d36679a8b7006104000000000000000000000001c8704095000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000");
|
||||
final byte[] transactionBytes = HEX.decode(
|
||||
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803e09304062f503253482f0403c86d53087ceca141295a00002e522cfabe6d6d7561cf262313da1144026c8f7a43e3899c44f6145f39a36507d36679a8b7006104000000000000000000000001c8704095000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000");
|
||||
final int height = 300000;
|
||||
final Transaction transaction = PARAMS.getDefaultSerializer().makeTransaction(transactionBytes);
|
||||
transaction.checkCoinBaseHeight(height);
|
||||
@ -361,11 +387,7 @@ public class TransactionTest {
|
||||
public void testCoinbaseHeightCheckWithDamagedScript() throws VerificationException {
|
||||
// Coinbase transaction from block 224,430
|
||||
final byte[] transactionBytes = HEX.decode(
|
||||
"010000000100000000000000000000000000000000000000000000000000000000"
|
||||
+ "00000000ffffffff3b03ae6c0300044bd7031a0400000000522cfabe6d6d0000"
|
||||
+ "0000000000b7b8bf0100000068692066726f6d20706f6f6c7365727665726aac"
|
||||
+ "1eeeed88ffffffff01e0587597000000001976a91421c0d001728b3feaf11551"
|
||||
+ "5b7c135e779e9f442f88ac00000000");
|
||||
"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3b03ae6c0300044bd7031a0400000000522cfabe6d6d00000000000000b7b8bf0100000068692066726f6d20706f6f6c7365727665726aac1eeeed88ffffffff01e0587597000000001976a91421c0d001728b3feaf115515b7c135e779e9f442f88ac00000000");
|
||||
final int height = 224430;
|
||||
final Transaction transaction = PARAMS.getDefaultSerializer().makeTransaction(transactionBytes);
|
||||
transaction.checkCoinBaseHeight(height);
|
||||
@ -392,14 +414,24 @@ public class TransactionTest {
|
||||
|
||||
final Transaction tx = block1.getTransactions().get(1);
|
||||
final String txHash = tx.getHashAsString();
|
||||
final String txNormalizedHash = tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString();
|
||||
final String txNormalizedHash = tx.hashForSignature(
|
||||
0,
|
||||
new byte[0],
|
||||
Transaction.SigHash.ALL.byteValue())
|
||||
.toString();
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
// ensure the transaction object itself was not modified; if it was, the hash will change
|
||||
assertEquals(txHash, tx.getHashAsString());
|
||||
new Thread(){
|
||||
public void run() {
|
||||
assertEquals(txNormalizedHash, tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString());
|
||||
assertEquals(
|
||||
txNormalizedHash,
|
||||
tx.hashForSignature(
|
||||
0,
|
||||
new byte[0],
|
||||
Transaction.SigHash.ALL.byteValue())
|
||||
.toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user