Ethereum-types and various libs upgrade (#315)

* Upgrade Eth types

ethereum-types -> 0.9.2
rlp -> 0.4.6
keccak-hash -> 0.5.0
parity-crypto -> 0.6.2
ethabi -> 0.12.0
ethabi-derive -> 0.12.0
ethabi-contract -> 0.11.0
ethbloom -> 0.9.1
rand -> 0.7.3
trie-standardmap -> 0.15.2
triehash -> 0.5.0

* backport #10714. Small changes, merge fixes

Co-authored-by: mdben1247 <mdben1247@users.noreply.github.com>
This commit is contained in:
rakita
2021-03-12 10:12:42 +01:00
committed by GitHub
parent 3f8e0cfec4
commit a0f406e26b
273 changed files with 3051 additions and 4775 deletions

View File

@@ -223,15 +223,15 @@ fn rpc_eth_chain_id() {
fn rpc_eth_hashrate() {
let tester = EthTester::default();
tester.hashrates.lock().insert(
H256::from(0),
H256::from_low_u64_be(0),
(Instant::now() + Duration::from_secs(2), U256::from(0xfffa)),
);
tester.hashrates.lock().insert(
H256::from(0),
H256::from_low_u64_be(0),
(Instant::now() + Duration::from_secs(2), U256::from(0xfffb)),
);
tester.hashrates.lock().insert(
H256::from(1),
H256::from_low_u64_be(1),
(Instant::now() + Duration::from_secs(2), U256::from(0x1)),
);
@@ -302,10 +302,16 @@ fn rpc_eth_logs() {
#[test]
fn rpc_eth_logs_error() {
fn h256_from_digit_be(d: u8) -> H256 {
let mut bytes = [0u8; 32];
bytes[0] = d;
H256(bytes)
}
let tester = EthTester::default();
tester
.client
.set_error_on_logs(Some(BlockId::Hash(H256::from([5u8].as_ref()))));
.set_error_on_logs(Some(BlockId::Hash(h256_from_digit_be(5))));
let request = r#"{"jsonrpc": "2.0", "method": "eth_getLogs", "params": [{"limit":1,"blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"One of the blocks specified in filter (fromBlock, toBlock or blockHash) cannot be found","data":"0x0500000000000000000000000000000000000000000000000000000000000000"},"id":1}"#;
assert_eq!(
@@ -457,9 +463,10 @@ fn rpc_eth_submit_hashrate() {
tester
.hashrates
.lock()
.get(&H256::from(
"0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"
))
.get(
&H256::from_str("59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c")
.unwrap()
)
.cloned()
.unwrap()
.1,
@@ -536,10 +543,10 @@ fn rpc_eth_accounts() {
let address = tester.accounts_provider.new_account(&"".into()).unwrap();
tester
.accounts_provider
.set_address_name(1.into(), "1".into());
.set_address_name(Address::from_low_u64_be(1), "1".into());
tester
.accounts_provider
.set_address_name(10.into(), "10".into());
.set_address_name(Address::from_low_u64_be(10), "10".into());
// with current policy it should return the account
let request = r#"{"jsonrpc": "2.0", "method": "eth_accounts", "params": [], "id": 1}"#;
@@ -569,7 +576,9 @@ fn rpc_eth_block_number() {
#[test]
fn rpc_eth_balance() {
let tester = EthTester::default();
tester.client.set_balance(Address::from(1), U256::from(5));
tester
.client
.set_balance(Address::from_low_u64_be(1), U256::from(5));
let request = r#"{
"jsonrpc": "2.0",
@@ -588,7 +597,9 @@ fn rpc_eth_balance() {
#[test]
fn rpc_eth_balance_pending() {
let tester = EthTester::default();
tester.client.set_balance(Address::from(1), U256::from(5));
tester
.client
.set_balance(Address::from_low_u64_be(1), U256::from(5));
let request = r#"{
"jsonrpc": "2.0",
@@ -608,9 +619,11 @@ fn rpc_eth_balance_pending() {
#[test]
fn rpc_eth_storage_at() {
let tester = EthTester::default();
tester
.client
.set_storage(Address::from(1), H256::from(4), H256::from(7));
tester.client.set_storage(
Address::from_low_u64_be(1),
H256::from_low_u64_be(4),
H256::from_low_u64_be(7),
);
let request = r#"{
"jsonrpc": "2.0",
@@ -755,7 +768,9 @@ fn rpc_eth_uncle_count_by_block_number() {
#[test]
fn rpc_eth_code() {
let tester = EthTester::default();
tester.client.set_code(Address::from(1), vec![0xff, 0x21]);
tester
.client
.set_code(Address::from_low_u64_be(1), vec![0xff, 0x21]);
let request = r#"{
"jsonrpc": "2.0",
@@ -1162,13 +1177,13 @@ fn rpc_eth_transaction_receipt() {
)
.unwrap(),
block_number: 0x4510c,
transaction_hash: H256::new(),
transaction_hash: H256::default(),
transaction_index: 0,
transaction_log_index: 0,
log_index: 1,
}],
log_bloom: 0.into(),
outcome: TransactionOutcome::StateRoot(0.into()),
log_bloom: Bloom::zero(),
outcome: TransactionOutcome::StateRoot(H256::zero()),
};
let hash =

View File

@@ -29,6 +29,7 @@ use v1::{EthPubSub, EthPubSubClient, Metadata};
use ethcore::client::{
ChainNotify, ChainRoute, ChainRouteType, EachBlockWith, NewBlocks, TestBlockChainClient,
};
use ethereum_types::{Address, H256};
use parity_runtime::Runtime;
const DURATION_ZERO: Duration = Duration::from_millis(0);
@@ -58,7 +59,7 @@ fn should_subscribe_to_new_heads() {
// Subscribe
let request =
r#"{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["newHeads"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x416d77337e24399d","id":1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x43ca64edf03768e1","id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata.clone()),
Some(response.to_owned())
@@ -75,7 +76,7 @@ fn should_subscribe_to_new_heads() {
true,
));
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x1","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x1","parentHash":"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x1","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x1","parentHash":"0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// Notify about two blocks
@@ -94,14 +95,14 @@ fn should_subscribe_to_new_heads() {
// Receive both
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x2","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0x44e5ecf454ea99af9d8a8f2ca0daba96964c90de05db7a78f59b84ae9e749706","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x2","parentHash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x2","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0x44e5ecf454ea99af9d8a8f2ca0daba96964c90de05db7a78f59b84ae9e749706","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x2","parentHash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x3","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0xdf04a98bb0c6fa8441bd429822f65a46d0cb553f6bcef602b973e65c81497f8e","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x3","parentHash":"0x44e5ecf454ea99af9d8a8f2ca0daba96964c90de05db7a78f59b84ae9e749706","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"author":"0x0000000000000000000000000000000000000000","difficulty":"0x3","extraData":"0x","gasLimit":"0xf4240","gasUsed":"0x0","hash":"0xdf04a98bb0c6fa8441bd429822f65a46d0cb553f6bcef602b973e65c81497f8e","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","number":"0x3","parentHash":"0x44e5ecf454ea99af9d8a8f2ca0daba96964c90de05db7a78f59b84ae9e749706","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sealFields":[],"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1c9","stateRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","timestamp":"0x0","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"},"subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// And unsubscribe
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x416d77337e24399d"], "id": 1}"#;
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x43ca64edf03768e1"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata),
@@ -130,8 +131,13 @@ fn should_subscribe_to_logs() {
let tx_hash = block.transactions()[0].hash();
client.set_logs(vec![LocalizedLogEntry {
entry: LogEntry {
address: 5.into(),
topics: vec![1.into(), 2.into(), 0.into(), 0.into()],
address: Address::from_low_u64_be(5),
topics: vec![
H256::from_low_u64_be(1),
H256::from_low_u64_be(2),
H256::from_low_u64_be(0),
H256::from_low_u64_be(0),
],
data: vec![],
},
block_hash: h1,
@@ -156,7 +162,7 @@ fn should_subscribe_to_logs() {
// Subscribe
let request =
r#"{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["logs", {}], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x416d77337e24399d","id":1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x43ca64edf03768e1","id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata.clone()),
Some(response.to_owned())
@@ -175,7 +181,7 @@ fn should_subscribe_to_logs() {
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"address":"0x0000000000000000000000000000000000000005","blockHash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","blockNumber":"0x1","data":"0x","logIndex":"0x0","removed":false,"topics":["0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000002","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],"transactionHash":""#.to_owned()
+ &format!("0x{:x}", tx_hash)
+ r#"","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"mined"},"subscription":"0x416d77337e24399d"}}"#;
+ r#"","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"mined"},"subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// Check notifications (retracted)
@@ -191,11 +197,11 @@ fn should_subscribe_to_logs() {
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":{"address":"0x0000000000000000000000000000000000000005","blockHash":"0x3457d2fa2e3dd33c78ac681cf542e429becf718859053448748383af67e23218","blockNumber":"0x1","data":"0x","logIndex":"0x0","removed":true,"topics":["0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000002","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],"transactionHash":""#.to_owned()
+ &format!("0x{:x}", tx_hash)
+ r#"","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"removed"},"subscription":"0x416d77337e24399d"}}"#;
+ r#"","transactionIndex":"0x0","transactionLogIndex":"0x0","type":"removed"},"subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// And unsubscribe
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x416d77337e24399d"], "id": 1}"#;
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x43ca64edf03768e1"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata),
@@ -233,25 +239,25 @@ fn should_subscribe_to_pending_transactions() {
// Subscribe
let request = r#"{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["newPendingTransactions"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x416d77337e24399d","id":1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x43ca64edf03768e1","id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata.clone()),
Some(response.to_owned())
);
// Send new transactions
handler.notify_new_transactions(&[5.into(), 7.into()]);
handler.notify_new_transactions(&[H256::from_low_u64_be(5), H256::from_low_u64_be(7)]);
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":"0x0000000000000000000000000000000000000000000000000000000000000005","subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":"0x0000000000000000000000000000000000000000000000000000000000000005","subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":"0x0000000000000000000000000000000000000000000000000000000000000007","subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"eth_subscription","params":{"result":"0x0000000000000000000000000000000000000000000000000000000000000007","subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// And unsubscribe
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x416d77337e24399d"], "id": 1}"#;
let request = r#"{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x43ca64edf03768e1"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata),

View File

@@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use crypto::publickey::{Generator, Random};
use ethcore::client::{Executed, TestBlockChainClient, TransactionId};
use ethcore_logger::RotatingLogger;
use ethereum_types::{Address, H256, U256};
use ethstore::ethkey::{Generator, Random};
use ethereum_types::{Address, BigEndianHash, Bloom, H256, U256};
use miner::pool::local_transactions::Status as LocalTransactionStatus;
use std::sync::Arc;
use sync::ManageNetwork;
@@ -294,7 +294,7 @@ fn rpc_parity_pending_transactions() {
fn rpc_parity_encrypt() {
let deps = Dependencies::new();
let io = deps.default_client();
let key = format!("{:x}", Random.generate().unwrap().public());
let key = format!("{:x}", Random.generate().public());
let request = r#"{"jsonrpc": "2.0", "method": "parity_encryptMessage", "params":["0x"#
.to_owned()
@@ -382,16 +382,16 @@ fn rpc_parity_local_transactions() {
data: vec![1, 2, 3],
nonce: 0.into(),
})
.fake_sign(3.into());
.fake_sign(Address::from_low_u64_be(3));
let tx = Arc::new(::miner::pool::VerifiedTransaction::from_pending_block_transaction(tx));
deps.miner
.local_transactions
.lock()
.insert(10.into(), LocalTransactionStatus::Pending(tx.clone()));
deps.miner
.local_transactions
.lock()
.insert(15.into(), LocalTransactionStatus::Pending(tx.clone()));
deps.miner.local_transactions.lock().insert(
H256::from_low_u64_be(10),
LocalTransactionStatus::Pending(tx.clone()),
);
deps.miner.local_transactions.lock().insert(
H256::from_low_u64_be(15),
LocalTransactionStatus::Pending(tx.clone()),
);
let request =
r#"{"jsonrpc": "2.0", "method": "parity_localTransactions", "params":[], "id": 1}"#;
@@ -406,7 +406,7 @@ fn rpc_parity_chain_status() {
let io = deps.default_client();
*deps.client.ancient_block.write() = Some((H256::default(), 5));
*deps.client.first_block.write() = Some((H256::from(U256::from(1234)), 3333));
*deps.client.first_block.write() = Some((BigEndianHash::from_uint(&U256::from(1234)), 3333));
let request = r#"{"jsonrpc": "2.0", "method": "parity_chainStatus", "params":[], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":{"blockGap":["0x6","0xd05"]},"id":1}"#;
@@ -467,21 +467,21 @@ fn rpc_parity_call() {
fn rpc_parity_block_receipts() {
let deps = Dependencies::new();
deps.client.receipts.write().insert(
TransactionId::Hash(1.into()),
TransactionId::Hash(H256::from_low_u64_be(1)),
LocalizedReceipt {
transaction_hash: 1.into(),
transaction_hash: H256::from_low_u64_be(1),
transaction_type: TypedTxId::Legacy,
transaction_index: 0,
block_hash: 3.into(),
block_hash: H256::from_low_u64_be(3),
block_number: 0,
cumulative_gas_used: 21_000.into(),
gas_used: 21_000.into(),
contract_address: None,
logs: vec![],
log_bloom: 1.into(),
log_bloom: Bloom::from_low_u64_be(1),
outcome: TransactionOutcome::Unknown,
to: None,
from: 9.into(),
from: Address::from_low_u64_be(9),
},
);
let io = deps.default_client();

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
use std::sync::Arc;
use std::{str::FromStr, sync::Arc};
use accounts::{AccountProvider, AccountProviderSettings};
use ethereum_types::Address;
@@ -76,7 +76,9 @@ fn rpc_parity_accounts_info() {
assert_eq!(accounts.len(), 1);
let address = accounts[0];
tester.accounts.set_address_name(1.into(), "XX".into());
tester
.accounts
.set_address_name(Address::from_low_u64_be(1), "XX".into());
tester
.accounts
.set_account_name(address.clone(), "Test".into())
@@ -645,7 +647,7 @@ fn should_import_wallet() {
let account_meta = tester
.accounts
.account_meta("0x00bac56a8a27232baa044c03f43bf3648c961735".into())
.account_meta(Address::from_str("00bac56a8a27232baa044c03f43bf3648c961735").unwrap())
.unwrap();
let account_uuid: String = account_meta.uuid.unwrap().into();

View File

@@ -191,11 +191,11 @@ fn rpc_parity_remove_transaction() {
nonce: 1.into(),
gas_price: 0x9184e72a000u64.into(),
gas: 0x76c0.into(),
action: Action::Call(5.into()),
action: Action::Call(Address::from_low_u64_be(5)),
value: 0x9184e72au64.into(),
data: vec![],
});
let signed = tx.fake_sign(2.into());
let signed = tx.fake_sign(Address::from_low_u64_be(2));
let hash = signed.hash();
let request = r#"{"jsonrpc": "2.0", "method": "parity_removeTransaction", "params":[""#

View File

@@ -18,6 +18,7 @@ use std::{str::FromStr, sync::Arc};
use accounts::AccountProvider;
use bytes::ToPretty;
use crypto::publickey::Secret;
use ethcore::client::TestBlockChainClient;
use ethereum_types::{Address, H520, U256};
use hash::keccak;
@@ -26,7 +27,6 @@ use parity_runtime::Runtime;
use parking_lot::Mutex;
use types::transaction::{Action, Transaction, TypedTransaction};
use ethkey::Secret;
use serde_json::to_value;
use v1::{
helpers::{
@@ -392,6 +392,7 @@ fn ec_recover_invalid_signature() {
fn should_unlock_account_permanently() {
let tester = setup();
let address = tester.accounts.new_account(&"password123".into()).unwrap();
let message = [1u8; 32].into();
let request = r#"{
"jsonrpc": "2.0",
@@ -412,10 +413,7 @@ fn should_unlock_account_permanently() {
Some(response.into())
);
assert!(
tester
.accounts
.sign(address, None, Default::default())
.is_ok(),
tester.accounts.sign(address, None, message).is_ok(),
"Should unlock account."
);
}
@@ -446,7 +444,7 @@ fn sign_eip191_with_validator() {
}"#;
let with_validator = to_value(PresignedTransaction {
validator: address.into(),
data: keccak("hello world").to_vec().into(),
data: keccak("hello world").as_bytes().to_vec().into(),
})
.unwrap();
let result = eip191::hash_message(EIP191Version::PresignedTransaction, with_validator).unwrap();

View File

@@ -57,7 +57,7 @@ fn should_subscribe_to_a_method() {
// Subscribe
let request =
r#"{"jsonrpc": "2.0", "method": "parity_subscribe", "params": ["hello", []], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x416d77337e24399d","id":1}"#;
let response = r#"{"jsonrpc":"2.0","result":"0x43ca64edf03768e1","id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata.clone()),
Some(response.to_owned())
@@ -65,15 +65,15 @@ fn should_subscribe_to_a_method() {
// Check notifications
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"parity_subscription","params":{"result":"hello","subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"parity_subscription","params":{"result":"hello","subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
let (res, receiver) = receiver.into_future().wait().unwrap();
let response = r#"{"jsonrpc":"2.0","method":"parity_subscription","params":{"result":"world","subscription":"0x416d77337e24399d"}}"#;
let response = r#"{"jsonrpc":"2.0","method":"parity_subscription","params":{"result":"world","subscription":"0x43ca64edf03768e1"}}"#;
assert_eq!(res, Some(response.into()));
// And unsubscribe
let request = r#"{"jsonrpc": "2.0", "method": "parity_unsubscribe", "params": ["0x416d77337e24399d"], "id": 1}"#;
let request = r#"{"jsonrpc": "2.0", "method": "parity_unsubscribe", "params": ["0x43ca64edf03768e1"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(
io.handle_request_sync(request, metadata),

View File

@@ -17,9 +17,11 @@
use std::sync::Arc;
use accounts::AccountProvider;
use crypto::DEFAULT_MAC;
use crypto::{
publickey::{verify_public, KeyPair, Signature},
DEFAULT_MAC,
};
use ethereum_types::H256;
use ethkey::{verify_public, KeyPair, Signature};
use jsonrpc_core::{IoHandler, Success};
use serde_json;

View File

@@ -92,7 +92,7 @@ fn should_return_list_of_items_to_confirm() {
.add_request(
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
transaction_type: Default::default(),
from: Address::from(1),
from: Address::from_low_u64_be(1),
used_default_from: false,
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
gas_price: U256::from(10_000),
@@ -109,7 +109,7 @@ fn should_return_list_of_items_to_confirm() {
let _sign_future = tester
.signer
.add_request(
ConfirmationPayload::EthSignMessage(1.into(), vec![5].into()),
ConfirmationPayload::EthSignMessage(Address::from_low_u64_be(1), vec![5].into()),
Origin::Unknown,
)
.unwrap();
@@ -139,7 +139,7 @@ fn should_reject_transaction_from_queue_without_dispatching() {
.add_request(
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
transaction_type: Default::default(),
from: Address::from(1),
from: Address::from_low_u64_be(1),
used_default_from: false,
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
gas_price: U256::from(10_000),
@@ -177,7 +177,7 @@ fn should_not_remove_transaction_if_password_is_invalid() {
.add_request(
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
transaction_type: Default::default(),
from: Address::from(1),
from: Address::from_low_u64_be(1),
used_default_from: false,
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
gas_price: U256::from(10_000),
@@ -213,7 +213,7 @@ fn should_not_remove_sign_if_password_is_invalid() {
let _confirmation_future = tester
.signer
.add_request(
ConfirmationPayload::EthSignMessage(0.into(), vec![5].into()),
ConfirmationPayload::EthSignMessage(Address::from_low_u64_be(0), vec![5].into()),
Origin::Unknown,
)
.unwrap();
@@ -308,7 +308,7 @@ fn should_alter_the_sender_and_nonce() {
.add_request(
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
transaction_type: Default::default(),
from: 0.into(),
from: Address::from_low_u64_be(0),
used_default_from: false,
to: Some(recipient),
gas_price: U256::from(10_000),

View File

@@ -32,10 +32,9 @@ use v1::{
use accounts::AccountProvider;
use bytes::ToPretty;
use crypto::publickey::{Generator, Random, Secret};
use ethcore::client::TestBlockChainClient;
use ethereum_types::{Address, U256};
use ethkey::Secret;
use ethstore::ethkey::{Generator, Random};
use ethereum_types::{Address, H256, H520, U256};
use parity_runtime::{Executor, Runtime};
use parking_lot::Mutex;
use serde_json;
@@ -156,7 +155,10 @@ fn should_add_sign_to_queue() {
if signer.requests().len() == 1 {
// respond
let sender = signer.take(&1.into()).unwrap();
signer.request_confirmed(sender, Ok(ConfirmationResponse::Signature(0.into())));
signer.request_confirmed(
sender,
Ok(ConfirmationResponse::Signature(H520::from_low_u64_be(0))),
);
break;
}
::std::thread::sleep(Duration::from_millis(100))
@@ -250,9 +252,10 @@ fn should_check_status_of_request_when_its_resolved() {
}"#;
tester.io.handle_request_sync(&request).expect("Sent");
let sender = tester.signer.take(&1.into()).unwrap();
tester
.signer
.request_confirmed(sender, Ok(ConfirmationResponse::Signature(1.into())));
tester.signer.request_confirmed(
sender,
Ok(ConfirmationResponse::Signature(H520::from_low_u64_be(1))),
);
// This is not ideal, but we need to give futures some time to be executed, and they need to run in a separate thread
thread::sleep(Duration::from_millis(20));
@@ -343,7 +346,12 @@ fn should_add_transaction_to_queue() {
if signer.requests().len() == 1 {
// respond
let sender = signer.take(&1.into()).unwrap();
signer.request_confirmed(sender, Ok(ConfirmationResponse::SendTransaction(0.into())));
signer.request_confirmed(
sender,
Ok(ConfirmationResponse::SendTransaction(
H256::from_low_u64_be(0),
)),
);
break;
}
::std::thread::sleep(Duration::from_millis(100))
@@ -549,7 +557,7 @@ fn should_decrypt_message_if_account_is_unlocked() {
fn should_add_decryption_to_the_queue() {
// given
let tester = eth_signing();
let acc = Random.generate().unwrap();
let acc = Random.generate();
assert_eq!(tester.signer.requests().len(), 0);
// when
@@ -592,7 +600,7 @@ fn should_add_decryption_to_the_queue() {
fn should_compose_transaction() {
// given
let tester = eth_signing();
let acc = Random.generate().unwrap();
let acc = Random.generate();
assert_eq!(tester.signer.requests().len(), 0);
let from = format!("{:x}", acc.address());

View File

@@ -256,7 +256,7 @@ fn rpc_eth_send_transaction_with_bad_to() {
"id": 1
}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: prefix is missing."},"id":1}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: 0x prefix is missing."},"id":1}"#;
assert_eq!(
tester.io.handle_request_sync(&request),

View File

@@ -24,6 +24,7 @@ use ethcore::{
LocalizedTrace,
},
};
use ethereum_types::{Address, H256};
use vm::CallType;
@@ -40,8 +41,8 @@ fn io() -> Tester {
let client = Arc::new(TestBlockChainClient::new());
*client.traces.write() = Some(vec![LocalizedTrace {
action: Action::Call(Call {
from: 0xf.into(),
to: 0x10.into(),
from: Address::from_low_u64_be(0xf),
to: Address::from_low_u64_be(0x10),
value: 0x1.into(),
gas: 0x100.into(),
input: vec![1, 2, 3],
@@ -51,9 +52,9 @@ fn io() -> Tester {
subtraces: 0,
trace_address: vec![0],
transaction_number: Some(0),
transaction_hash: Some(5.into()),
transaction_hash: Some(H256::from_low_u64_be(5)),
block_number: 10,
block_hash: 10.into(),
block_hash: H256::from_low_u64_be(10),
}]);
*client.execution_result.write() = Some(Ok(Executed {
exception: None,