Remove UTXO rules which test non-existant protocol rules

This commit is contained in:
Matt Corallo
2014-09-26 23:21:28 -07:00
committed by Mike Hearn
parent ce41c10a9e
commit fed5891ef8
2 changed files with 1 additions and 63 deletions

View File

@@ -213,7 +213,6 @@ public class BitcoindComparisonTool {
int differingBlocks = 0;
int invalidBlocks = 0;
int mempoolRulesFailed = 0;
int utxoRulesFailed = 0;
for (Rule rule : blockList.list) {
if (rule instanceof BlockAndValidity) {
BlockAndValidity block = (BlockAndValidity) rule;
@@ -318,17 +317,6 @@ public class BitcoindComparisonTool {
mempoolRulesFailed++;
}
mostRecentInv = null;
} else if (rule instanceof UTXORule) {
UTXORule r = (UTXORule) rule;
UTXOsMessage result = bitcoind.getUTXOs(r.query).get();
if (!result.equals(r.result)) {
log.error("utxo result was not what we expected.");
log.error("Wanted {}", r.result);
log.error("but got {}", result);
utxoRulesFailed++;
} else {
log.info("Successful utxo query {}: {}", r.ruleName, result);
}
} else {
throw new RuntimeException("Unknown rule");
}
@@ -338,8 +326,7 @@ public class BitcoindComparisonTool {
"Blocks which were not handled the same between bitcoind/bitcoinj: " + differingBlocks + "\n" +
"Blocks which should/should not have been accepted but weren't/were: " + invalidBlocks + "\n" +
"Transactions which were/weren't in memory pool but shouldn't/should have been: " + mempoolRulesFailed + "\n" +
"UTXO query mismatches: " + utxoRulesFailed + "\n" +
"Unexpected inv messages: " + unexpectedInvs.get());
System.exit(differingBlocks > 0 || invalidBlocks > 0 || mempoolRulesFailed > 0 || utxoRulesFailed > 0 || unexpectedInvs.get() > 0 ? 1 : 0);
System.exit(differingBlocks > 0 || invalidBlocks > 0 || mempoolRulesFailed > 0 || unexpectedInvs.get() > 0 ? 1 : 0);
}
}

View File

@@ -100,23 +100,6 @@ class MemoryPoolState extends Rule {
}
}
class UTXORule extends Rule {
List<TransactionOutPoint> query;
UTXOsMessage result;
public UTXORule(String ruleName, TransactionOutPoint query, UTXOsMessage result) {
super(ruleName);
this.query = singletonList(query);
this.result = result;
}
public UTXORule(String ruleName, List<TransactionOutPoint> query, UTXOsMessage result) {
super(ruleName);
this.query = query;
this.result = result;
}
}
class RuleList {
public List<Rule> list;
public int maximumReorgBlockCount;
@@ -225,17 +208,6 @@ public class FullBlockTestGenerator {
// Make sure nothing breaks if we add b3 twice
blocks.add(new BlockAndValidity(blockToHeightMap, hashHeaderMap, b3, true, false, b2.getHash(), chainHeadHeight + 2, "b3"));
// Do a simple UTXO query.
UTXORule utxo1;
{
Transaction coinbase = b2.getTransactions().get(0);
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getHash());
long[] heights = new long[] {chainHeadHeight + 2};
UTXOsMessage result = new UTXOsMessage(params, ImmutableList.of(coinbase.getOutput(0)), heights, b2.getHash(), chainHeadHeight + 2);
utxo1 = new UTXORule("utxo1", outpoint, result);
blocks.add(utxo1);
}
// Now we add another block to make the alternative chain longer.
//
// genesis -> b1 (0) -> b2 (1)
@@ -245,18 +217,6 @@ public class FullBlockTestGenerator {
Block b4 = createNextBlock(b3, chainHeadHeight + 3, out2, null);
blocks.add(new BlockAndValidity(blockToHeightMap, hashHeaderMap, b4, true, false, b4.getHash(), chainHeadHeight + 3, "b4"));
// Check that the old coinbase is no longer in the UTXO set and the new one is.
{
Transaction coinbase = b4.getTransactions().get(0);
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getHash());
List<TransactionOutPoint> queries = ImmutableList.of(utxo1.query.get(0), outpoint);
List<TransactionOutput> results = Lists.asList(null, coinbase.getOutput(0), new TransactionOutput[] {});
long[] heights = new long[] {chainHeadHeight + 3};
UTXOsMessage result = new UTXOsMessage(params, results, heights, b4.getHash(), chainHeadHeight + 3);
UTXORule utxo2 = new UTXORule("utxo2", queries, result);
blocks.add(utxo2);
}
// ... and back to the first chain.
Block b5 = createNextBlock(b2, chainHeadHeight + 3, out2, null);
blocks.add(new BlockAndValidity(blockToHeightMap, hashHeaderMap, b5, true, false, b4.getHash(), chainHeadHeight + 3, "b5"));
@@ -1589,15 +1549,6 @@ public class FullBlockTestGenerator {
post82Mempool.add(new InventoryItem(InventoryItem.Type.Transaction, b79tx.getHash()));
blocks.add(new MemoryPoolState(post82Mempool, "post-b82 tx resurrection"));
// Check the UTXO query takes mempool into account.
{
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, b79tx.getHash());
long[] heights = new long[] { UTXOsMessage.MEMPOOL_HEIGHT };
UTXOsMessage result = new UTXOsMessage(params, ImmutableList.of(b79tx.getOutput(0)), heights, b82.getHash(), chainHeadHeight + 28);
UTXORule utxo3 = new UTXORule("utxo3", outpoint, result);
blocks.add(utxo3);
}
// Test invalid opcodes in dead execution paths.
// -> b81 (26) -> b82 (27) -> b83 (28)
// b83 creates a tx which contains a transaction script with an invalid opcode in a dead execution path: