Skip to content

Commit

Permalink
add eth_* methods that don't have any params
Browse files Browse the repository at this point in the history
  • Loading branch information
feuGeneA committed Jun 1, 2023
1 parent 6dd4fb3 commit efbd8dd
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions crates/rethnet_eth/src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ impl From<BlockSpec> for SerializableBlockSpec {
#[derive(Debug, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(tag = "method", content = "params")]
enum MethodInvocation {
#[serde(rename = "eth_accounts")]
Accounts(),
#[serde(rename = "eth_blockNumber")]
BlockNumber(),
#[serde(rename = "eth_chainId")]
ChainId(),
#[serde(rename = "eth_coinbase")]
Coinbase(),
#[serde(rename = "eth_gasPrice")]
GasPrice(),
#[serde(rename = "eth_getBalance")]
GetBalance(Address, SerializableBlockSpec),
#[serde(rename = "eth_getBlockByNumber")]
Expand Down Expand Up @@ -172,6 +182,10 @@ enum MethodInvocation {
deserialize_with = "sequence_to_single"
)]
GetTransactionReceipt(B256),
#[serde(rename = "eth_mining")]
Mining(),
#[serde(rename = "eth_syncing")]
Syncing(),
}

#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
Expand All @@ -194,6 +208,31 @@ mod tests {
assert_eq!(call, call_decoded);
}

#[test]
fn test_serde_eth_accounts() {
help_test_method_invocation_serde(MethodInvocation::Accounts());
}

#[test]
fn test_serde_eth_block_number() {
help_test_method_invocation_serde(MethodInvocation::BlockNumber());
}

#[test]
fn test_serde_eth_chain_id() {
help_test_method_invocation_serde(MethodInvocation::ChainId());
}

#[test]
fn test_serde_eth_coinbase() {
help_test_method_invocation_serde(MethodInvocation::Coinbase());
}

#[test]
fn test_serde_eth_gas_price() {
help_test_method_invocation_serde(MethodInvocation::GasPrice());
}

#[test]
fn test_serde_eth_get_balance_by_block_number() {
help_test_method_invocation_serde(MethodInvocation::GetBalance(
Expand Down Expand Up @@ -315,4 +354,14 @@ mod tests {
B256::from_low_u64_ne(1),
));
}

#[test]
fn test_serde_eth_mining() {
help_test_method_invocation_serde(MethodInvocation::Mining());
}

#[test]
fn test_serde_eth_syncing() {
help_test_method_invocation_serde(MethodInvocation::Syncing());
}
}

0 comments on commit efbd8dd

Please sign in to comment.