Browse Source

Fixed all rpc test cases.

cn
Jianping Wu 6 years ago
parent
commit
0c6a908f7c
  1. 8
      src/chainparams.cpp
  2. 8
      test/functional/rpc_fundrawtransaction.py
  3. 6
      test/functional/rpc_rawtransaction.py
  4. 2
      test/functional/rpc_signmessage.py
  5. 6
      test/functional/rpc_txoutproof.py

8
src/chainparams.cpp

@ -282,10 +282,10 @@ public:
// By default assume that the signatures in ancestors of this block are valid. // By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x00"); consensus.defaultAssumeValid = uint256S("0x00");
pchMessageStart[0] = 0xe3; pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0x0c; pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0x1a; pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0x2f; pchMessageStart[3] = 0xda;
nDefaultPort = 19444; nDefaultPort = 19444;
nPruneAfterHeight = 1000; nPruneAfterHeight = 1000;

8
test/functional/rpc_fundrawtransaction.py

@ -48,13 +48,13 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
# ensure that setting changePosition in fundraw with an exact match is handled properly # ensure that setting changePosition in fundraw with an exact match is handled properly
rawmatch = self.nodes[2].createrawtransaction([], {self.nodes[2].getnewaddress():50}) rawmatch = self.nodes[2].createrawtransaction([], {self.nodes[2].getnewaddress():500})
rawmatch = self.nodes[2].fundrawtransaction(rawmatch, {"changePosition":1, "subtractFeeFromOutputs":[0]}) rawmatch = self.nodes[2].fundrawtransaction(rawmatch, {"changePosition":1, "subtractFeeFromOutputs":[0]})
assert_equal(rawmatch["changepos"], -1) assert_equal(rawmatch["changepos"], -1)
watchonly_address = self.nodes[0].getnewaddress() watchonly_address = self.nodes[0].getnewaddress()
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"] watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
watchonly_amount = Decimal(200) watchonly_amount = Decimal(2000)
self.nodes[3].importpubkey(watchonly_pubkey, "", True) self.nodes[3].importpubkey(watchonly_pubkey, "", True)
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount) watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10) self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
@ -506,7 +506,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
# make sure funds are received at node1 # make sure funds are received at node1
assert_equal(oldBalance+Decimal('51.10000000'), self.nodes[0].getbalance()) assert_equal(oldBalance+Decimal('501.10000000'), self.nodes[0].getbalance())
############################################### ###############################################
@ -566,7 +566,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward assert_equal(oldBalance+Decimal('500.19000000'), self.nodes[0].getbalance()) #0.19+block reward
##################################################### #####################################################
# test fundrawtransaction with OP_RETURN and no vin # # test fundrawtransaction with OP_RETURN and no vin #

6
test/functional/rpc_rawtransaction.py

@ -85,7 +85,7 @@ class RawTransactionsTest(BitcoinTestFramework):
address = self.nodes[0].getnewaddress() address = self.nodes[0].getnewaddress()
assert_raises_rpc_error(-3, "Expected type object", self.nodes[0].createrawtransaction, [], 'foo') assert_raises_rpc_error(-3, "Expected type object", self.nodes[0].createrawtransaction, [], 'foo')
assert_raises_rpc_error(-8, "Data must be hexadecimal string", self.nodes[0].createrawtransaction, [], {'data': 'foo'}) assert_raises_rpc_error(-8, "Data must be hexadecimal string", self.nodes[0].createrawtransaction, [], {'data': 'foo'})
assert_raises_rpc_error(-5, "Invalid Kevacoin address", self.nodes[0].createrawtransaction, [], {'foo': 0}) assert_raises_rpc_error(-5, "Invalid kevacoin address", self.nodes[0].createrawtransaction, [], {'foo': 0})
assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].createrawtransaction, [], {address: 'foo'}) assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].createrawtransaction, [], {address: 'foo'})
assert_raises_rpc_error(-3, "Amount out of range", self.nodes[0].createrawtransaction, [], {address: -1}) assert_raises_rpc_error(-3, "Amount out of range", self.nodes[0].createrawtransaction, [], {address: -1})
assert_raises_rpc_error(-8, "Invalid parameter, duplicated address: %s" % address, self.nodes[0].createrawtransaction, [], multidict([(address, 1), (address, 1)])) assert_raises_rpc_error(-8, "Invalid parameter, duplicated address: %s" % address, self.nodes[0].createrawtransaction, [], multidict([(address, 1), (address, 1)]))
@ -263,7 +263,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal+Decimal('50.00000000')+Decimal('2.19000000')) #block reward + tx assert_equal(self.nodes[0].getbalance(), bal+Decimal('500.00000000')+Decimal('2.19000000')) #block reward + tx
# 2of2 test for combining transactions # 2of2 test for combining transactions
bal = self.nodes[2].getbalance() bal = self.nodes[2].getbalance()
@ -312,7 +312,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal+Decimal('50.00000000')+Decimal('2.19000000')) #block reward + tx assert_equal(self.nodes[0].getbalance(), bal+Decimal('500.00000000')+Decimal('2.19000000')) #block reward + tx
# decoderawtransaction tests # decoderawtransaction tests
# witness transaction # witness transaction

2
test/functional/rpc_signmessage.py

@ -19,7 +19,7 @@ class SignMessagesTest(BitcoinTestFramework):
self.log.info('test signing with priv_key') self.log.info('test signing with priv_key')
priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N' priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'
address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB' address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'
expected_signature = 'IGve8AOjIcu+a/nYW1PABSfmp2oQlEqLIOwPgNW5/Y5teggr8S0vy4SMdjL2Viv3iuBZjJbhvyBo0tv5m3H63b8=' expected_signature = 'IAbLaZ5ZuYSQGPpCxxiLFWmZC19TlTy9BGdAfQqRlzhKfe0OqcEYiWgmB/Pc67JF4EN87MBUUbIiH4ndR30uU+w='
signature = self.nodes[0].signmessagewithprivkey(priv_key, message) signature = self.nodes[0].signmessagewithprivkey(priv_key, message)
assert_equal(expected_signature, signature) assert_equal(expected_signature, signature)
assert(self.nodes[0].verifymessage(address, signature, message)) assert(self.nodes[0].verifymessage(address, signature, message))

6
test/functional/rpc_txoutproof.py

@ -35,9 +35,9 @@ class MerkleBlockTest(BitcoinTestFramework):
assert_equal(self.nodes[2].getbalance(), 0) assert_equal(self.nodes[2].getbalance(), 0)
node0utxos = self.nodes[0].listunspent(1) node0utxos = self.nodes[0].listunspent(1)
tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 499.99})
txid1 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx1)["hex"]) txid1 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx1)["hex"])
tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99}) tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 499.99})
txid2 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx2)["hex"]) txid2 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx2)["hex"])
# This will raise an exception because the transaction is not yet in a block # This will raise an exception because the transaction is not yet in a block
assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [txid1]) assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [txid1])
@ -56,7 +56,7 @@ class MerkleBlockTest(BitcoinTestFramework):
assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid1, txid2], blockhash)), txlist) assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid1, txid2], blockhash)), txlist)
txin_spent = self.nodes[1].listunspent(1).pop() txin_spent = self.nodes[1].listunspent(1).pop()
tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 49.98}) tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 499.98})
txid3 = self.nodes[0].sendrawtransaction(self.nodes[1].signrawtransaction(tx3)["hex"]) txid3 = self.nodes[0].sendrawtransaction(self.nodes[1].signrawtransaction(tx3)["hex"])
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()

Loading…
Cancel
Save