diff options
author | chriseth <chris@ethereum.org> | 2017-10-20 23:04:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 23:04:52 +0800 |
commit | 90b0a6efb9ad07444be6e1de0394c8b1d0e70187 (patch) | |
tree | 5f8c1ef7205f79d8d1d146ce09576ee380182a4d | |
parent | 7d0e46bf59cd966f943ef9839e8e26d857150192 (diff) | |
parent | faa0a662c740a0d0d26d58e0e19bb4b887d642a5 (diff) | |
download | dexon-solidity-90b0a6efb9ad07444be6e1de0394c8b1d0e70187.tar.gz dexon-solidity-90b0a6efb9ad07444be6e1de0394c8b1d0e70187.tar.zst dexon-solidity-90b0a6efb9ad07444be6e1de0394c8b1d0e70187.zip |
Merge pull request #3119 from ethereum/rpc-account
Fix RPC account creation with gaps
-rw-r--r-- | test/RPCSession.cpp | 19 | ||||
-rw-r--r-- | test/RPCSession.h | 1 |
2 files changed, 12 insertions, 8 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index 634954a3..c06c3997 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -339,22 +339,25 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const& return result["result"]; } +string const& RPCSession::accountCreate() +{ + m_accounts.push_back(personal_newAccount("")); + personal_unlockAccount(m_accounts.back(), "", 100000); + return m_accounts.back(); +} + string const& RPCSession::accountCreateIfNotExists(size_t _id) { - if (_id >= m_accounts.size()) - { - m_accounts.push_back(personal_newAccount("")); - personal_unlockAccount(m_accounts.back(), "", 100000); - } + while ((_id + 1) > m_accounts.size()) + accountCreate(); return m_accounts[_id]; } RPCSession::RPCSession(const string& _path): m_ipcSocket(_path) { - string account = personal_newAccount(""); - personal_unlockAccount(account, "", 100000); - m_accounts.push_back(account); + accountCreate(); + // This will pre-fund the accounts create prior. test_setChainParams(m_accounts); } diff --git a/test/RPCSession.h b/test/RPCSession.h index eae6a09c..63f1dd21 100644 --- a/test/RPCSession.h +++ b/test/RPCSession.h @@ -121,6 +121,7 @@ public: Json::Value rpcCall(std::string const& _methodName, std::vector<std::string> const& _args = std::vector<std::string>(), bool _canFail = false); std::string const& account(size_t _id) const { return m_accounts.at(_id); } + std::string const& accountCreate(); std::string const& accountCreateIfNotExists(size_t _id); private: |