Browse Source

Continuing port of java comptool

0.13
mrbandrews 9 years ago
parent
commit
291f8aa5da
  1. 1085
      qa/rpc-tests/p2p-fullblocktest.py
  2. 23
      qa/rpc-tests/test_framework/blocktools.py
  3. 1
      qa/rpc-tests/test_framework/mininode.py

1085
qa/rpc-tests/p2p-fullblocktest.py

File diff suppressed because it is too large Load Diff

23
qa/rpc-tests/test_framework/blocktools.py

@ -56,12 +56,27 @@ def create_coinbase(height, pubkey = None):
coinbase.calc_sha256() coinbase.calc_sha256()
return coinbase return coinbase
# Create a transaction with an anyone-can-spend output, that spends the # Create a transaction.
# nth output of prevtx. # If the scriptPubKey is not specified, make it anyone-can-spend.
def create_transaction(prevtx, n, sig, value): def create_transaction(prevtx, n, sig, value, scriptPubKey=CScript()):
tx = CTransaction() tx = CTransaction()
assert(n < len(prevtx.vout)) assert(n < len(prevtx.vout))
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), sig, 0xffffffff)) tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), sig, 0xffffffff))
tx.vout.append(CTxOut(value, b"")) tx.vout.append(CTxOut(value, scriptPubKey))
tx.calc_sha256() tx.calc_sha256()
return tx return tx
def get_legacy_sigopcount_block(block, fAccurate=True):
count = 0
for tx in block.vtx:
count += get_legacy_sigopcount_tx(tx, fAccurate)
return count
def get_legacy_sigopcount_tx(tx, fAccurate=True):
count = 0
for i in tx.vout:
count += i.scriptPubKey.GetSigOpCount(fAccurate)
for j in tx.vin:
# scriptSig might be of type bytes, so convert to CScript for the moment
count += CScript(j.scriptSig).GetSigOpCount(fAccurate)
return count

1
qa/rpc-tests/test_framework/mininode.py

@ -556,7 +556,6 @@ class CBlock(CBlockHeader):
self.nNonce += 1 self.nNonce += 1
self.rehash() self.rehash()
def __repr__(self): def __repr__(self):
return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x vtx=%s)" \ return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x vtx=%s)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot,

Loading…
Cancel
Save