Litecoin: Tests
This commit is contained in:
parent
a1e47d9f0e
commit
d1d5fa80fb
@ -115,7 +115,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
|
||||
} else {
|
||||
CTxDestination destination = DecodeDestination(name_);
|
||||
if (!IsValidDestination(destination)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_);
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Litecoin address: ") + name_);
|
||||
}
|
||||
|
||||
if (!destinations.insert(destination).second) {
|
||||
|
||||
@ -64,7 +64,7 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
|
||||
|
||||
inc_conf_file2_path = os.path.join(self.nodes[0].datadir, 'include2.conf')
|
||||
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
|
||||
with open(os.path.join(self.nodes[0].datadir, 'litecoin.conf'), 'a', encoding='utf-8') as conf:
|
||||
conf.write('includeconf={}\n'.format(inc_conf_file2_path))
|
||||
|
||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||
|
||||
@ -149,7 +149,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||
assert isinstance(cmd, Socks5Command)
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, b"bitcoinostk4e4re.onion")
|
||||
assert_equal(cmd.port, 9333)
|
||||
assert_equal(cmd.port, 8333)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
assert_equal(cmd.password, None)
|
||||
@ -163,7 +163,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||
assert isinstance(cmd, Socks5Command)
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, b"node.noumenon")
|
||||
assert_equal(cmd.port, 9333)
|
||||
assert_equal(cmd.port, 8333)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
assert_equal(cmd.password, None)
|
||||
|
||||
@ -22,7 +22,7 @@ class SettingsTest(BitcoinTestFramework):
|
||||
def run_test(self):
|
||||
node, = self.nodes
|
||||
settings = Path(node.datadir, self.chain, "settings.json")
|
||||
conf = Path(node.datadir, "bitcoin.conf")
|
||||
conf = Path(node.datadir, "litecoin.conf")
|
||||
|
||||
# Assert empty settings file was created
|
||||
self.stop_node(0)
|
||||
|
||||
@ -50,7 +50,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
|
||||
txid = w0.sendrawtransaction(signed_tx)
|
||||
self.sync_all()
|
||||
|
||||
assert_raises_rpc_error(-32, 'Using bumpfee with wallets that have private keys disabled is deprecated. Use psbtbumpfee instead or restart bitcoind with -deprecatedrpc=bumpfee. This functionality will be removed in 0.22', noprivs0.bumpfee, txid)
|
||||
assert_raises_rpc_error(-32, 'Using bumpfee with wallets that have private keys disabled is deprecated. Use psbtbumpfee instead or restart litecoind with -deprecatedrpc=bumpfee. This functionality will be removed in 0.22', noprivs0.bumpfee, txid)
|
||||
bumped_psbt = noprivs1.bumpfee(txid)
|
||||
assert 'psbt' in bumped_psbt
|
||||
else:
|
||||
|
||||
@ -707,7 +707,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
wwatch.unloadwallet()
|
||||
|
||||
def test_option_feerate(self):
|
||||
self.log.info("Test fundrawtxn with explicit fee rates (fee_rate sat/vB and feeRate BTC/kvB)")
|
||||
self.log.info("Test fundrawtxn with explicit fee rates (fee_rate sat/vB and feeRate LTC/kvB)")
|
||||
node = self.nodes[3]
|
||||
# Make sure there is exactly one input so coin selection can't skew the result.
|
||||
assert_equal(len(self.nodes[3].listunspent(1)), 1)
|
||||
@ -773,7 +773,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
node.fundrawtransaction(rawtx, {"feeRate": 0.00000999, "add_inputs": True})
|
||||
|
||||
self.log.info("- raises RPC error if both feeRate and fee_rate are passed")
|
||||
assert_raises_rpc_error(-8, "Cannot specify both fee_rate (sat/vB) and feeRate (BTC/kvB)",
|
||||
assert_raises_rpc_error(-8, "Cannot specify both fee_rate (sat/vB) and feeRate (LTC/kvB)",
|
||||
node.fundrawtransaction, rawtx, {"fee_rate": 0.1, "feeRate": 0.1, "add_inputs": True})
|
||||
|
||||
self.log.info("- raises RPC error if both feeRate and estimate_mode passed")
|
||||
|
||||
@ -55,7 +55,7 @@ class RPCWhitelistTest(BitcoinTestFramework):
|
||||
]
|
||||
# These commands shouldn't be allowed for any user to test failures
|
||||
self.never_allowed = ["getnetworkinfo"]
|
||||
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "bitcoin.conf"), 'a', encoding='utf8') as f:
|
||||
with open(os.path.join(get_datadir_path(self.options.tmpdir, 0), "litecoin.conf"), 'a', encoding='utf8') as f:
|
||||
f.write("\nrpcwhitelistdefault=0\n")
|
||||
for user in self.users:
|
||||
f.write("rpcauth=" + user[0] + ":" + user[1] + "\n")
|
||||
|
||||
@ -43,7 +43,7 @@ MAX_BLOOM_FILTER_SIZE = 36000
|
||||
MAX_BLOOM_HASH_FUNCS = 50
|
||||
|
||||
COIN = 100000000 # 1 btc in satoshis
|
||||
MAX_MONEY = 21000000 * COIN
|
||||
MAX_MONEY = 84000000 * COIN
|
||||
|
||||
BIP125_SEQUENCE_NUMBER = 0xfffffffd # Sequence number that is BIP 125 opt-in and BIP 68-opt-out
|
||||
|
||||
@ -586,7 +586,7 @@ class CTransaction:
|
||||
def is_valid(self):
|
||||
self.calc_sha256()
|
||||
for tout in self.vout:
|
||||
if tout.nValue < 0 or tout.nValue > 21000000 * COIN:
|
||||
if tout.nValue < 0 or tout.nValue > 84000000 * COIN:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ class TestNode():
|
||||
|
||||
self.index = i
|
||||
self.datadir = datadir
|
||||
self.bitcoinconf = os.path.join(self.datadir, "bitcoin.conf")
|
||||
self.bitcoinconf = os.path.join(self.datadir, "litecoin.conf")
|
||||
self.stdout_dir = os.path.join(self.datadir, "stdout")
|
||||
self.stderr_dir = os.path.join(self.datadir, "stderr")
|
||||
self.chain = chain
|
||||
|
||||
@ -136,7 +136,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
||||
for k, v in {"number": 42, "object": {"foo": "bar"}}.items():
|
||||
assert_raises_rpc_error(-3, "Expected type string for estimate_mode, got {}".format(k),
|
||||
rbf_node.bumpfee, rbfid, {"estimate_mode": v})
|
||||
for mode in ["foo", Decimal("3.1415"), "sat/B", "BTC/kB"]:
|
||||
for mode in ["foo", Decimal("3.1415"), "sat/B", "LTC/kB"]:
|
||||
assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"',
|
||||
rbf_node.bumpfee, rbfid, {"estimate_mode": mode})
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
assert_equal(change_addrV["hdkeypath"], "m/0'/1'/0'") #first internal child key
|
||||
|
||||
# Import a non-HD private key in the HD wallet
|
||||
non_hd_add = 'bcrt1qmevj8zfx0wdvp05cqwkmr6mxkfx60yezwjksmt'
|
||||
non_hd_key = 'cS9umN9w6cDMuRVYdbkfE4c7YUFLJRoXMfhQ569uY4odiQbVN8Rt'
|
||||
non_hd_add = 'rltc1qjgtc00yzwc28lxl88cw7g5773p7xeyp3mxtuuc'
|
||||
non_hd_key = 'cQn6W2TKuDLaRtRgr8BJvuBzRgHwW8yQPxTLwGEgx3TcLaJi1PDT'
|
||||
self.nodes[1].importprivkey(non_hd_key)
|
||||
|
||||
# This should be enough to keep the master key and the non-HD key
|
||||
|
||||
@ -289,14 +289,14 @@ class WalletSendTest(BitcoinTestFramework):
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=target, estimate_mode=mode,
|
||||
expect_error=(-8, "Invalid conf_target, must be between 1 and 1008")) # max value of 1008 per src/policy/fees.h
|
||||
msg = 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"'
|
||||
for target, mode in product([-1, 0], ["btc/kb", "sat/b"]):
|
||||
for target, mode in product([-1, 0], ["ltc/kb", "sat/b"]):
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=target, estimate_mode=mode, expect_error=(-8, msg))
|
||||
for mode in ["", "foo", Decimal("3.141592")]:
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=0.1, estimate_mode=mode, expect_error=(-8, msg))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_conf_target=0.1, arg_estimate_mode=mode, expect_error=(-8, msg))
|
||||
assert_raises_rpc_error(-8, msg, w0.send, {w1.getnewaddress(): 1}, 0.1, mode)
|
||||
|
||||
for mode in ["economical", "conservative", "btc/kb", "sat/b"]:
|
||||
for mode in ["economical", "conservative", "ltc/kb", "sat/b"]:
|
||||
self.log.debug("{}".format(mode))
|
||||
for k, v in {"string": "true", "object": {"foo": "bar"}}.items():
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, conf_target=v, estimate_mode=mode,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user