rpc tests, now 421 passing / 116 failing
This commit is contained in:
parent
906e9b395e
commit
52dbcd8152
@ -103,6 +103,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
timestamp: U256::from(view.timestamp()),
|
timestamp: U256::from(view.timestamp()),
|
||||||
difficulty: view.difficulty(),
|
difficulty: view.difficulty(),
|
||||||
total_difficulty: total_difficulty,
|
total_difficulty: total_difficulty,
|
||||||
|
nonce: view.seal().get(1).map_or_else(H64::zero, |r| H64::from_slice(r)),
|
||||||
uncles: vec![],
|
uncles: vec![],
|
||||||
transactions: {
|
transactions: {
|
||||||
if include_txs {
|
if include_txs {
|
||||||
@ -111,7 +112,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
BlockTransactions::Hashes(block_view.transaction_hashes())
|
BlockTransactions::Hashes(block_view.transaction_hashes())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extra_data: Bytes::default()
|
extra_data: Bytes::new(view.extra_data())
|
||||||
};
|
};
|
||||||
to_value(&block)
|
to_value(&block)
|
||||||
},
|
},
|
||||||
|
@ -63,6 +63,7 @@ pub struct Block {
|
|||||||
pub difficulty: U256,
|
pub difficulty: U256,
|
||||||
#[serde(rename="totalDifficulty")]
|
#[serde(rename="totalDifficulty")]
|
||||||
pub total_difficulty: U256,
|
pub total_difficulty: U256,
|
||||||
|
pub nonce: H64,
|
||||||
pub uncles: Vec<U256>,
|
pub uncles: Vec<U256>,
|
||||||
pub transactions: BlockTransactions
|
pub transactions: BlockTransactions
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ mod tests {
|
|||||||
fn test_serialize_block_transactions() {
|
fn test_serialize_block_transactions() {
|
||||||
let t = BlockTransactions::Full(vec![Transaction::default()]);
|
let t = BlockTransactions::Full(vec![Transaction::default()]);
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x00"}]"#);
|
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x"}]"#);
|
||||||
|
|
||||||
let t = BlockTransactions::Hashes(vec![H256::default()]);
|
let t = BlockTransactions::Hashes(vec![H256::default()]);
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
@ -104,11 +105,12 @@ mod tests {
|
|||||||
timestamp: U256::default(),
|
timestamp: U256::default(),
|
||||||
difficulty: U256::default(),
|
difficulty: U256::default(),
|
||||||
total_difficulty: U256::default(),
|
total_difficulty: U256::default(),
|
||||||
|
nonce: H64::default(),
|
||||||
uncles: vec![],
|
uncles: vec![],
|
||||||
transactions: BlockTransactions::Hashes(vec![])
|
transactions: BlockTransactions::Hashes(vec![])
|
||||||
};
|
};
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&block).unwrap();
|
let serialized = serde_json::to_string(&block).unwrap();
|
||||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x00","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","uncles":[],"transactions":[]}"#);
|
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","author":"0x0000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","number":"0x00","gasUsed":"0x00","gasLimit":"0x00","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x00","difficulty":"0x00","totalDifficulty":"0x00","nonce":"0x0000000000000000","uncles":[],"transactions":[]}"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ use serde::de::Visitor;
|
|||||||
use util::common::FromHex;
|
use util::common::FromHex;
|
||||||
|
|
||||||
/// Wrapper structure around vector of bytes.
|
/// Wrapper structure around vector of bytes.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Default)]
|
||||||
pub struct Bytes(Vec<u8>);
|
pub struct Bytes(Vec<u8>);
|
||||||
|
|
||||||
impl Bytes {
|
impl Bytes {
|
||||||
@ -31,13 +31,6 @@ impl Bytes {
|
|||||||
pub fn to_vec(self) -> Vec<u8> { let Bytes(x) = self; x }
|
pub fn to_vec(self) -> Vec<u8> { let Bytes(x) = self; x }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Bytes {
|
|
||||||
fn default() -> Self {
|
|
||||||
// default serialized value is 0x00
|
|
||||||
Bytes(vec![0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Bytes {
|
impl Serialize for Bytes {
|
||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: Serializer {
|
where S: Serializer {
|
||||||
|
@ -67,7 +67,7 @@ mod tests {
|
|||||||
fn test_transaction_serialize() {
|
fn test_transaction_serialize() {
|
||||||
let t = Transaction::default();
|
let t = Transaction::default();
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x00"}"#);
|
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x"}"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user