[dependencies]: unify rustc-hex (#11506)

* [dependency]: unify `rustc-hex`

* [private tx]: fix upgrade to `rustc hex 2.1.0`
This commit is contained in:
Niklas Adolfsson
2020-02-21 15:10:00 +01:00
committed by GitHub
parent bec867be03
commit 2018f5b0ab
52 changed files with 355 additions and 357 deletions

View File

@@ -513,7 +513,7 @@ pub fn vm(error: &VMError, output: &[u8]) -> Error {
use rustc_hex::ToHex;
let data = match error {
&VMError::Reverted => format!("{} 0x{}", VMError::Reverted, output.to_hex()),
&VMError::Reverted => format!("{} 0x{}", VMError::Reverted, output.to_hex::<String>()),
error => format!("{}", error),
};

View File

@@ -564,12 +564,11 @@ fn rpc_eth_transaction_count_by_number_pending() {
#[test]
fn rpc_eth_pending_transaction_by_hash() {
use ethereum_types::H256;
use rlp;
use types::transaction::SignedTransaction;
let tester = EthTester::default();
{
let bytes = FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap();
let bytes: Vec<u8> = FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap();
let tx = rlp::decode(&bytes).expect("decoding failure");
let tx = SignedTransaction::new(tx).unwrap();
tester.miner.pending_transactions.lock().insert(H256::zero(), tx);
@@ -913,7 +912,7 @@ fn rpc_eth_send_raw_transaction() {
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let rlp = rlp::encode(&t).to_hex();
let rlp: String = rlp::encode(&t).to_hex();
let req = r#"{
"jsonrpc": "2.0",

View File

@@ -166,7 +166,7 @@ fn rpc_parity_set_extra_data() {
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
assert_eq!(miner.authoring_params().extra_data, "cd1722f3947def4cf144679da39c4c32bdc35681".from_hex().unwrap());
assert_eq!(miner.authoring_params().extra_data, "cd1722f3947def4cf144679da39c4c32bdc35681".from_hex::<Vec<u8>>().unwrap());
}
#[test]

View File

@@ -368,8 +368,8 @@ fn sign_eip191_with_validator() {
data: keccak("hello world").as_bytes().to_vec().into()
}).unwrap();
let result = eip191::hash_message(EIP191Version::PresignedTransaction, with_validator).unwrap();
let result = tester.accounts.sign(address, Some("password123".into()), result).unwrap().into_electrum();
let expected = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{}", result.to_hex()) + r#"","id":1}"#;
let result: String = tester.accounts.sign(address, Some("password123".into()), result).unwrap().into_electrum().to_hex();
let expected = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{}", result) + r#"","id":1}"#;
let response = tester.io.handle_request_sync(&request).unwrap();
assert_eq!(response, expected)
}

View File

@@ -87,13 +87,10 @@ fn eth_signing(signing_queue_enabled: bool) -> SigningTester {
#[test]
fn rpc_eth_sign() {
use rustc_hex::FromHex;
let tester = eth_signing(true);
let account = tester.accounts.insert_account(Secret::from([69u8; 32]), &"abcd".into()).unwrap();
tester.accounts.unlock_account_permanently(account, "abcd".into()).unwrap();
let _message = "0cc175b9c0f1b6a831c399e26977266192eb5ffee6ae2fec3ad71c777531578f".from_hex().unwrap();
let req = r#"{
"jsonrpc": "2.0",

View File

@@ -165,10 +165,10 @@ fn rpc_eth_sign_transaction() {
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None);
let signature = t.signature();
let rlp = rlp::encode(&t);
let rlp: String = rlp::encode(&t).to_hex();
let response = r#"{"jsonrpc":"2.0","result":{"#.to_owned() +
r#""raw":"0x"# + &rlp.to_hex() + r#"","# +
r#""raw":"0x"# + &rlp + r#"","# +
r#""tx":{"# +
r#""blockHash":null,"blockNumber":null,"# +
&format!("\"chainId\":{},", t.chain_id().map_or("null".to_owned(), |n| format!("{}", n))) +
@@ -180,7 +180,7 @@ fn rpc_eth_sign_transaction() {
r#""nonce":"0x1","# +
&format!("\"publicKey\":\"0x{:x}\",", t.recover_public().unwrap()) +
&format!("\"r\":\"0x{:x}\",", U256::from(signature.r())) +
&format!("\"raw\":\"0x{}\",", rlp.to_hex()) +
&format!("\"raw\":\"0x{}\",", rlp) +
&format!("\"s\":\"0x{:x}\",", U256::from(signature.s())) +
&format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v())) +
r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"# +

View File

@@ -50,9 +50,10 @@ impl Into<Vec<u8>> for Bytes {
impl Serialize for Bytes {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
where S: Serializer
{
let mut serialized = "0x".to_owned();
serialized.push_str(self.0.to_hex().as_ref());
serialized.push_str(self.0.to_hex::<String>().as_ref());
serializer.serialize_str(serialized.as_ref())
}
}
@@ -89,7 +90,6 @@ impl<'a> Visitor<'a> for BytesVisitor {
#[cfg(test)]
mod tests {
use super::*;
use serde_json;
use rustc_hex::FromHex;
#[test]

View File

@@ -103,7 +103,7 @@ mod tests {
gas_price: Some(U256::from_str("9184e72a000").unwrap()),
gas: Some(U256::from_str("76c0").unwrap()),
value: Some(U256::from_str("9184e72a").unwrap()),
data: Some("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675".from_hex().unwrap().into()),
data: Some("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675".from_hex::<Vec<u8>>().unwrap().into()),
nonce: None
});
}

View File

@@ -186,7 +186,7 @@ mod tests {
gas_price: Some(U256::from_str("9184e72a000").unwrap()),
gas: Some(U256::from_str("76c0").unwrap()),
value: Some(U256::from_str("9184e72a").unwrap()),
data: Some("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675".from_hex().unwrap().into()),
data: Some("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675".from_hex::<Vec<u8>>().unwrap().into()),
nonce: None,
condition: None,
});