Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_wallet_standardness.py
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
address_nonstd = nonstd_node.getnewaddress() | address_nonstd = nonstd_node.getnewaddress() | ||||
# make and mature some coins for the nonstandard node | # make and mature some coins for the nonstandard node | ||||
nonstd_node.generate(120) | nonstd_node.generate(120) | ||||
self.sync_blocks() | self.sync_blocks() | ||||
def fund_and_test_wallet(scriptPubKey, is_standard, expected_in_std_wallet, | def fund_and_test_wallet(scriptPubKey, is_standard, expected_in_std_wallet, | ||||
amount=10000, spendfee=500, nonstd_error="scriptpubkey (code 64)", sign_error=None): | amount=10000, spendfee=500, nonstd_error="scriptpubkey", sign_error=None): | ||||
""" | """ | ||||
Get the nonstandard node to fund a transaction, test its | Get the nonstandard node to fund a transaction, test its | ||||
standardness by trying to broadcast on the standard node, | standardness by trying to broadcast on the standard node, | ||||
then mine it and see if it ended up in the standard node's wallet. | then mine it and see if it ended up in the standard node's wallet. | ||||
Finally, it attempts to spend the coin. | Finally, it attempts to spend the coin. | ||||
""" | """ | ||||
self.log.info("Trying script {}".format(scriptPubKey.hex(),)) | self.log.info("Trying script {}".format(scriptPubKey.hex(),)) | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
sign_error='Input SigChecks limit exceeded') | sign_error='Input SigChecks limit exceeded') | ||||
fund_and_test_wallet( | fund_and_test_wallet( | ||||
CScript([OP_1, pubkey, pubkey, pubkey, OP_PUSHDATA1, | CScript([OP_1, pubkey, pubkey, pubkey, OP_PUSHDATA1, | ||||
pubkey, pubkey, OP_5, OP_CHECKMULTISIG]), False, False, | pubkey, pubkey, OP_5, OP_CHECKMULTISIG]), False, False, | ||||
sign_error='Data push larger than necessary') | sign_error='Data push larger than necessary') | ||||
# Dust also is nonstandard to fund but standard to spend. | # Dust also is nonstandard to fund but standard to spend. | ||||
fund_and_test_wallet( | fund_and_test_wallet( | ||||
CScript([pubkey, OP_CHECKSIG]), False, True, amount=200, nonstd_error="dust (code 64)") | CScript([pubkey, OP_CHECKSIG]), False, True, amount=200, nonstd_error="dust") | ||||
# and we end with an empty wallet | # and we end with an empty wallet | ||||
assert_equal(std_node.getbalance(), 0) | assert_equal(std_node.getbalance(), 0) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
WalletStandardnessTest().main() | WalletStandardnessTest().main() |