[Tests] added tests for RPC Wallet #3837

pull alonmuroch wants to merge 1 commits into bitcoin:master from alonmuroch:rpc_wallet_tests changing 1 files +87 −0
  1. alonmuroch commented at 6:30 PM on March 10, 2014: contributor

    added the following tests to rpc_wallet_tests.cpp: 1)setaccount 2)getrawchangeaddress 3)getnewaddress 4)getaccountaddress 5)getaccount 6)signmessage 7)getaddressesbyaccount

  2. alonmuroch commented at 3:07 PM on March 16, 2014: contributor

    Any comments ? I'm new here, it will be helpful to hear rejects.

  3. in src/test/rpc_wallet_tests.cpp:None in b2fba37e0f outdated
     161 | +	BOOST_CHECK(CBitcoinAddress(arr[0].get_str()).Get() == demoAddress.Get());
     162 | +
     163 | +	/*********************************
     164 | +	 * 		getreceivedbyaddress
     165 | +	 *********************************/
     166 | +	//TODO - init some balance for testing
    


    laanwj commented at 3:22 PM on March 16, 2014:

    For these cases (where you need a setup to have a balance) it makes sense to use a Python based test with regtest mode (see qa/rpc-tests/listtransactions.py for an example).


    alonmuroch commented at 3:36 PM on March 16, 2014:

    I asked around the irc channel about the python external testing precisely because of that ... i will write balance related tests in python.

  4. in src/test/rpc_wallet_tests.cpp:None in b2fba37e0f outdated
      62 | @@ -63,6 +63,33 @@
      63 |  
      64 |      LOCK(pwalletMain->cs_wallet);
      65 |  
      66 | +    BOOST_CHECK_NO_THROW();
    


    laanwj commented at 3:23 PM on March 16, 2014:

    What does an empty BOOST_CHECK_NO_THROW statement do?


    alonmuroch commented at 3:36 PM on March 16, 2014:

    My mistake

  5. in src/test/rpc_wallet_tests.cpp:None in b2fba37e0f outdated
      69 | +	CBitcoinAddress demoAddress = CBitcoinAddress(CTxDestination(demoPubkey.GetID()));
      70 | +	Value retValue;
      71 | +	string strAccount = "walletDemoAccount";
      72 | +	string strPurpose = "receive";
      73 | +	BOOST_CHECK_NO_THROW({ /*Initialize Wallet with an account */
      74 | +		CWalletDB walletdb(pwalletMain->strWalletFile);
    


    laanwj commented at 3:25 PM on March 16, 2014:

    Does this actually write anything to disk? Where does this create a wallet? I hope it doesn't overwrite the users's actual wallet? Probably the idea would be to create either a wallet that is only memory-backed, or a temporary file.


    alonmuroch commented at 3:36 PM on March 16, 2014:

    It does write but to a temp directory created in test_bitcoin.cpp, so it does not touch the user's wallet


    laanwj commented at 9:06 AM on March 26, 2014:

    OK

  6. in src/test/rpc_wallet_tests.cpp:None in b2fba37e0f outdated
     147 | +	 * 			signmessage
     148 | +	 *********************************/
     149 | +	BOOST_CHECK_NO_THROW(CallRPC("signmessage " + demoAddress.ToString() + " mymessage"));
     150 | +	BOOST_CHECK_THROW(CallRPC("signmessage"), runtime_error);
     151 | +	/* Should throw error because this address is not loaded in the wallet */
     152 | +	BOOST_CHECK_THROW(CallRPC("signmessage 1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ mymessage"), runtime_error);
    


    laanwj commented at 3:26 PM on March 16, 2014:

    Maybe also test verifymessage here


    alonmuroch commented at 3:36 PM on March 16, 2014:

    will do :)


    alonmuroch commented at 9:02 AM on March 26, 2014:

    Hi laanwj, verifymessage is a mining RPC call. Isn't it better to test it in a new rpc_mining_tests ?


    laanwj commented at 9:05 AM on March 26, 2014:

    What does verifymessage have to do with mining?


    alonmuroch commented at 9:18 AM on March 26, 2014:

    In rpcserver.cpp where the RPC commands are listed, verifymessage is under mining, although it makes sense to test it here after sign message. I will add it here.


    laanwj commented at 9:21 AM on March 26, 2014:

    OK it's clearly categorized wrong there. It is a general independent utility function.


    alonmuroch commented at 11:10 AM on March 26, 2014:

    added verifymessage tests

  7. in src/test/rpc_wallet_tests.cpp:None in a1be3f0014 outdated
      84 | +	/*********************************
      85 | +	 * 			setaccount
      86 | +	 *********************************/
      87 | +	BOOST_CHECK_NO_THROW(CallRPC("setaccount 1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ nullaccount"));
      88 | +	BOOST_CHECK_THROW(CallRPC("setaccount"), runtime_error);
      89 | +	/* address param is 33 chars instead of 34, illegal address */
    


    luke-jr commented at 9:25 AM on March 26, 2014:

    This comment is wrong. Perfectly valid addresses can be 33 chars too.


    alonmuroch commented at 11:10 AM on March 26, 2014:

    You are right ! changed the comment. The address is simply wrong, it is a 34 char address. I just deleted the last char to make it break.

  8. in src/test/rpc_wallet_tests.cpp:None in a1be3f0014 outdated
     132 | +    BOOST_CHECK_NO_THROW(CallRPC("getnewaddress getnewaddress_demoaccount"));
     133 | +
     134 | +    /*********************************
     135 | +	 * 		getaccountaddress
     136 | +	 *********************************/
     137 | +    BOOST_CHECK_NO_THROW(CallRPC("getaccountaddress \"\""));
    


    luke-jr commented at 9:25 AM on March 26, 2014:

    Account stuff is going away, no point testing it now.


    alonmuroch commented at 11:11 AM on March 26, 2014:

    If they are irrelevant i will delete those tests.


    laanwj commented at 11:22 AM on March 26, 2014:

    No need to delete them. Doesn't hurt to test them for as long as they do exist.

  9. laanwj commented at 1:43 PM on April 1, 2014: member

    Please squash into one commit.

  10. added many rpc wallet tests
    deleted the empty no throw test in rpc_wallet_tests line 65
    
    fixed some comments
    
    starting verify tests
    
    finished verify message tests
    
    changed some comments
    75ebced499
  11. alonmuroch commented at 2:09 PM on April 1, 2014: contributor

    squashed

  12. BitcoinPullTester commented at 2:26 AM on April 2, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/75ebced4992aab97b63c1a0842faf7dc37b86768 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  13. laanwj merged this on Jun 2, 2014
  14. laanwj closed this on Jun 2, 2014

  15. laanwj referenced this in commit 73b072252b on Jun 2, 2014
  16. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-29 03:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me